1 | /* $Id: VBoxManageGuestCtrl.h 62493 2016-07-22 18:44:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManageGuestCtrl.h - Definitions for guest control.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2016 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ___H_VBOXMANAGE_GUESTCTRL
|
---|
19 | #define ___H_VBOXMANAGE_GUESTCTRL
|
---|
20 |
|
---|
21 | #ifndef VBOX_ONLY_DOCS
|
---|
22 |
|
---|
23 | #include <VBox/com/com.h>
|
---|
24 | #include <VBox/com/listeners.h>
|
---|
25 | #include <VBox/com/VirtualBox.h>
|
---|
26 |
|
---|
27 | #include <iprt/time.h>
|
---|
28 |
|
---|
29 | #include <map>
|
---|
30 |
|
---|
31 | const char *gctlFileStatusToText(FileStatus_T enmStatus);
|
---|
32 | const char *gctlProcessStatusToText(ProcessStatus_T enmStatus);
|
---|
33 | const char *gctlGuestSessionStatusToText(GuestSessionStatus_T enmStatus);
|
---|
34 |
|
---|
35 | using namespace com;
|
---|
36 |
|
---|
37 | class GuestFileEventListener;
|
---|
38 | typedef ListenerImpl<GuestFileEventListener> GuestFileEventListenerImpl;
|
---|
39 |
|
---|
40 | class GuestProcessEventListener;
|
---|
41 | typedef ListenerImpl<GuestProcessEventListener> GuestProcessEventListenerImpl;
|
---|
42 |
|
---|
43 | class GuestSessionEventListener;
|
---|
44 | typedef ListenerImpl<GuestSessionEventListener> GuestSessionEventListenerImpl;
|
---|
45 |
|
---|
46 | class GuestEventListener;
|
---|
47 | typedef ListenerImpl<GuestEventListener> GuestEventListenerImpl;
|
---|
48 |
|
---|
49 | /** Simple statistics class for binding locally
|
---|
50 | * held data to a specific guest object. */
|
---|
51 | class GuestEventStats
|
---|
52 | {
|
---|
53 |
|
---|
54 | public:
|
---|
55 |
|
---|
56 | GuestEventStats(void)
|
---|
57 | : uLastUpdatedMS(RTTimeMilliTS())
|
---|
58 | {
|
---|
59 | }
|
---|
60 |
|
---|
61 | /** @todo Make this more a class than a structure. */
|
---|
62 | public:
|
---|
63 |
|
---|
64 | uint64_t uLastUpdatedMS;
|
---|
65 | };
|
---|
66 |
|
---|
67 | class GuestFileStats : public GuestEventStats
|
---|
68 | {
|
---|
69 |
|
---|
70 | public:
|
---|
71 |
|
---|
72 | GuestFileStats(void) { }
|
---|
73 |
|
---|
74 | GuestFileStats(ComObjPtr<GuestFileEventListenerImpl> pListenerImpl)
|
---|
75 | : mListener(pListenerImpl)
|
---|
76 | {
|
---|
77 | }
|
---|
78 |
|
---|
79 | public: /** @todo */
|
---|
80 |
|
---|
81 | ComObjPtr<GuestFileEventListenerImpl> mListener;
|
---|
82 | };
|
---|
83 |
|
---|
84 | class GuestProcStats : public GuestEventStats
|
---|
85 | {
|
---|
86 |
|
---|
87 | public:
|
---|
88 |
|
---|
89 | GuestProcStats(void) { }
|
---|
90 |
|
---|
91 | GuestProcStats(ComObjPtr<GuestProcessEventListenerImpl> pListenerImpl)
|
---|
92 | : mListener(pListenerImpl)
|
---|
93 | {
|
---|
94 | }
|
---|
95 |
|
---|
96 | public: /** @todo */
|
---|
97 |
|
---|
98 | ComObjPtr<GuestProcessEventListenerImpl> mListener;
|
---|
99 | };
|
---|
100 |
|
---|
101 | class GuestSessionStats : public GuestEventStats
|
---|
102 | {
|
---|
103 |
|
---|
104 | public:
|
---|
105 |
|
---|
106 | GuestSessionStats(void) { }
|
---|
107 |
|
---|
108 | GuestSessionStats(ComObjPtr<GuestSessionEventListenerImpl> pListenerImpl)
|
---|
109 | : mListener(pListenerImpl)
|
---|
110 | {
|
---|
111 | }
|
---|
112 |
|
---|
113 | public: /** @todo */
|
---|
114 |
|
---|
115 | ComObjPtr<GuestSessionEventListenerImpl> mListener;
|
---|
116 | };
|
---|
117 |
|
---|
118 | /** Map containing all watched guest files. */
|
---|
119 | typedef std::map< ComPtr<IGuestFile>, GuestFileStats > GuestEventFiles;
|
---|
120 | /** Map containing all watched guest processes. */
|
---|
121 | typedef std::map< ComPtr<IGuestProcess>, GuestProcStats > GuestEventProcs;
|
---|
122 | /** Map containing all watched guest sessions. */
|
---|
123 | typedef std::map< ComPtr<IGuestSession>, GuestSessionStats > GuestEventSessions;
|
---|
124 |
|
---|
125 | class GuestListenerBase
|
---|
126 | {
|
---|
127 | public:
|
---|
128 |
|
---|
129 | GuestListenerBase(void);
|
---|
130 |
|
---|
131 | virtual ~GuestListenerBase(void);
|
---|
132 |
|
---|
133 | public:
|
---|
134 |
|
---|
135 | HRESULT init(bool fVerbose = false);
|
---|
136 |
|
---|
137 | protected:
|
---|
138 |
|
---|
139 | /** Verbose flag. */
|
---|
140 | bool mfVerbose;
|
---|
141 | };
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Handler for guest process events.
|
---|
145 | */
|
---|
146 | class GuestFileEventListener : public GuestListenerBase
|
---|
147 | {
|
---|
148 | public:
|
---|
149 |
|
---|
150 | GuestFileEventListener(void);
|
---|
151 |
|
---|
152 | virtual ~GuestFileEventListener(void);
|
---|
153 |
|
---|
154 | public:
|
---|
155 |
|
---|
156 | void uninit(void);
|
---|
157 |
|
---|
158 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
159 |
|
---|
160 | protected:
|
---|
161 |
|
---|
162 | };
|
---|
163 |
|
---|
164 | /**
|
---|
165 | * Handler for guest process events.
|
---|
166 | */
|
---|
167 | class GuestProcessEventListener : public GuestListenerBase
|
---|
168 | {
|
---|
169 | public:
|
---|
170 |
|
---|
171 | GuestProcessEventListener(void);
|
---|
172 |
|
---|
173 | virtual ~GuestProcessEventListener(void);
|
---|
174 |
|
---|
175 | public:
|
---|
176 |
|
---|
177 | void uninit(void);
|
---|
178 |
|
---|
179 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
180 |
|
---|
181 | protected:
|
---|
182 |
|
---|
183 | };
|
---|
184 |
|
---|
185 | /**
|
---|
186 | * Handler for guest session events.
|
---|
187 | */
|
---|
188 | class GuestSessionEventListener : public GuestListenerBase
|
---|
189 | {
|
---|
190 | public:
|
---|
191 |
|
---|
192 | GuestSessionEventListener(void);
|
---|
193 |
|
---|
194 | virtual ~GuestSessionEventListener(void);
|
---|
195 |
|
---|
196 | public:
|
---|
197 |
|
---|
198 | void uninit(void);
|
---|
199 |
|
---|
200 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
201 |
|
---|
202 | protected:
|
---|
203 |
|
---|
204 | GuestEventFiles mFiles;
|
---|
205 | GuestEventProcs mProcs;
|
---|
206 | };
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * Handler for guest events.
|
---|
210 | */
|
---|
211 | class GuestEventListener : public GuestListenerBase
|
---|
212 | {
|
---|
213 |
|
---|
214 | public:
|
---|
215 |
|
---|
216 | GuestEventListener(void);
|
---|
217 |
|
---|
218 | virtual ~GuestEventListener(void);
|
---|
219 |
|
---|
220 | public:
|
---|
221 |
|
---|
222 | void uninit(void);
|
---|
223 |
|
---|
224 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
225 |
|
---|
226 | protected:
|
---|
227 |
|
---|
228 | GuestEventSessions mSessions;
|
---|
229 | };
|
---|
230 | #endif /* !VBOX_ONLY_DOCS */
|
---|
231 |
|
---|
232 | #endif /* !___H_VBOXMANAGE_GUESTCTRL */
|
---|
233 |
|
---|