1 | /* $Id: VBoxManageGuestCtrl.h 84519 2020-05-25 17:29:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManageGuestCtrl.h - Definitions for guest control.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2020 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 VBOX_INCLUDED_SRC_VBoxManage_VBoxManageGuestCtrl_h
|
---|
19 | #define VBOX_INCLUDED_SRC_VBoxManage_VBoxManageGuestCtrl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #ifndef VBOX_ONLY_DOCS
|
---|
25 |
|
---|
26 | #include <VBox/com/com.h>
|
---|
27 | #include <VBox/com/listeners.h>
|
---|
28 | #include <VBox/com/VirtualBox.h>
|
---|
29 |
|
---|
30 | #include <iprt/semaphore.h>
|
---|
31 | #include <iprt/time.h>
|
---|
32 |
|
---|
33 | #include <map>
|
---|
34 |
|
---|
35 | const char *gctlFileStatusToText(FileStatus_T enmStatus);
|
---|
36 | const char *gctlProcessStatusToText(ProcessStatus_T enmStatus);
|
---|
37 | const char *gctlGuestSessionStatusToText(GuestSessionStatus_T enmStatus);
|
---|
38 |
|
---|
39 | using namespace com;
|
---|
40 |
|
---|
41 | class GuestFileEventListener;
|
---|
42 | typedef ListenerImpl<GuestFileEventListener> GuestFileEventListenerImpl;
|
---|
43 |
|
---|
44 | class GuestProcessEventListener;
|
---|
45 | typedef ListenerImpl<GuestProcessEventListener> GuestProcessEventListenerImpl;
|
---|
46 |
|
---|
47 | class GuestSessionEventListener;
|
---|
48 | typedef ListenerImpl<GuestSessionEventListener> GuestSessionEventListenerImpl;
|
---|
49 |
|
---|
50 | class GuestEventListener;
|
---|
51 | typedef ListenerImpl<GuestEventListener> GuestEventListenerImpl;
|
---|
52 |
|
---|
53 | class GuestAdditionsRunlevelListener;
|
---|
54 | typedef ListenerImpl<GuestAdditionsRunlevelListener> GuestAdditionsRunlevelListenerImpl;
|
---|
55 |
|
---|
56 | /** Simple statistics class for binding locally
|
---|
57 | * held data to a specific guest object. */
|
---|
58 | class GuestEventStats
|
---|
59 | {
|
---|
60 |
|
---|
61 | public:
|
---|
62 |
|
---|
63 | GuestEventStats(void)
|
---|
64 | : uLastUpdatedMS(RTTimeMilliTS())
|
---|
65 | {
|
---|
66 | }
|
---|
67 |
|
---|
68 | /** @todo Make this more a class than a structure. */
|
---|
69 | public:
|
---|
70 |
|
---|
71 | uint64_t uLastUpdatedMS;
|
---|
72 | };
|
---|
73 |
|
---|
74 | class GuestFileStats : public GuestEventStats
|
---|
75 | {
|
---|
76 |
|
---|
77 | public:
|
---|
78 |
|
---|
79 | GuestFileStats(void) { }
|
---|
80 |
|
---|
81 | GuestFileStats(ComObjPtr<GuestFileEventListenerImpl> pListenerImpl)
|
---|
82 | : mListener(pListenerImpl)
|
---|
83 | {
|
---|
84 | }
|
---|
85 |
|
---|
86 | public: /** @todo */
|
---|
87 |
|
---|
88 | ComObjPtr<GuestFileEventListenerImpl> mListener;
|
---|
89 | };
|
---|
90 |
|
---|
91 | class GuestProcStats : public GuestEventStats
|
---|
92 | {
|
---|
93 |
|
---|
94 | public:
|
---|
95 |
|
---|
96 | GuestProcStats(void) { }
|
---|
97 |
|
---|
98 | GuestProcStats(ComObjPtr<GuestProcessEventListenerImpl> pListenerImpl)
|
---|
99 | : mListener(pListenerImpl)
|
---|
100 | {
|
---|
101 | }
|
---|
102 |
|
---|
103 | public: /** @todo */
|
---|
104 |
|
---|
105 | ComObjPtr<GuestProcessEventListenerImpl> mListener;
|
---|
106 | };
|
---|
107 |
|
---|
108 | class GuestSessionStats : public GuestEventStats
|
---|
109 | {
|
---|
110 |
|
---|
111 | public:
|
---|
112 |
|
---|
113 | GuestSessionStats(void) { }
|
---|
114 |
|
---|
115 | GuestSessionStats(ComObjPtr<GuestSessionEventListenerImpl> pListenerImpl)
|
---|
116 | : mListener(pListenerImpl)
|
---|
117 | {
|
---|
118 | }
|
---|
119 |
|
---|
120 | public: /** @todo */
|
---|
121 |
|
---|
122 | ComObjPtr<GuestSessionEventListenerImpl> mListener;
|
---|
123 | };
|
---|
124 |
|
---|
125 | /** Map containing all watched guest files. */
|
---|
126 | typedef std::map< ComPtr<IGuestFile>, GuestFileStats > GuestEventFiles;
|
---|
127 | /** Map containing all watched guest processes. */
|
---|
128 | typedef std::map< ComPtr<IGuestProcess>, GuestProcStats > GuestEventProcs;
|
---|
129 | /** Map containing all watched guest sessions. */
|
---|
130 | typedef std::map< ComPtr<IGuestSession>, GuestSessionStats > GuestEventSessions;
|
---|
131 |
|
---|
132 | class GuestListenerBase
|
---|
133 | {
|
---|
134 | public:
|
---|
135 |
|
---|
136 | GuestListenerBase(void);
|
---|
137 |
|
---|
138 | virtual ~GuestListenerBase(void);
|
---|
139 |
|
---|
140 | public:
|
---|
141 |
|
---|
142 | HRESULT init(bool fVerbose = false);
|
---|
143 |
|
---|
144 | protected:
|
---|
145 |
|
---|
146 | /** Verbose flag. */
|
---|
147 | bool mfVerbose;
|
---|
148 | };
|
---|
149 |
|
---|
150 | /**
|
---|
151 | * Handler for guest process events.
|
---|
152 | */
|
---|
153 | class GuestFileEventListener : public GuestListenerBase
|
---|
154 | {
|
---|
155 | public:
|
---|
156 |
|
---|
157 | GuestFileEventListener(void);
|
---|
158 |
|
---|
159 | virtual ~GuestFileEventListener(void);
|
---|
160 |
|
---|
161 | public:
|
---|
162 |
|
---|
163 | void uninit(void);
|
---|
164 |
|
---|
165 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
166 |
|
---|
167 | protected:
|
---|
168 |
|
---|
169 | };
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Handler for guest process events.
|
---|
173 | */
|
---|
174 | class GuestProcessEventListener : public GuestListenerBase
|
---|
175 | {
|
---|
176 | public:
|
---|
177 |
|
---|
178 | GuestProcessEventListener(void);
|
---|
179 |
|
---|
180 | virtual ~GuestProcessEventListener(void);
|
---|
181 |
|
---|
182 | public:
|
---|
183 |
|
---|
184 | void uninit(void);
|
---|
185 |
|
---|
186 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
187 |
|
---|
188 | protected:
|
---|
189 |
|
---|
190 | };
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * Handler for guest session events.
|
---|
194 | */
|
---|
195 | class GuestSessionEventListener : public GuestListenerBase
|
---|
196 | {
|
---|
197 | public:
|
---|
198 |
|
---|
199 | GuestSessionEventListener(void);
|
---|
200 |
|
---|
201 | virtual ~GuestSessionEventListener(void);
|
---|
202 |
|
---|
203 | public:
|
---|
204 |
|
---|
205 | void uninit(void);
|
---|
206 |
|
---|
207 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
208 |
|
---|
209 | protected:
|
---|
210 |
|
---|
211 | GuestEventFiles mFiles;
|
---|
212 | GuestEventProcs mProcs;
|
---|
213 | };
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * Handler for guest events.
|
---|
217 | */
|
---|
218 | class GuestEventListener : public GuestListenerBase
|
---|
219 | {
|
---|
220 |
|
---|
221 | public:
|
---|
222 |
|
---|
223 | GuestEventListener(void);
|
---|
224 |
|
---|
225 | virtual ~GuestEventListener(void);
|
---|
226 |
|
---|
227 | public:
|
---|
228 |
|
---|
229 | void uninit(void);
|
---|
230 |
|
---|
231 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
232 |
|
---|
233 | protected:
|
---|
234 |
|
---|
235 | GuestEventSessions mSessions;
|
---|
236 | };
|
---|
237 |
|
---|
238 | /**
|
---|
239 | * Handler for Guest Additions runlevel change events.
|
---|
240 | */
|
---|
241 | class GuestAdditionsRunlevelListener : public GuestListenerBase
|
---|
242 | {
|
---|
243 |
|
---|
244 | public:
|
---|
245 |
|
---|
246 | GuestAdditionsRunlevelListener(AdditionsRunLevelType_T enmRunLevel);
|
---|
247 |
|
---|
248 | virtual ~GuestAdditionsRunlevelListener(void);
|
---|
249 |
|
---|
250 | public:
|
---|
251 |
|
---|
252 | void uninit(void);
|
---|
253 |
|
---|
254 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
255 |
|
---|
256 | protected:
|
---|
257 |
|
---|
258 | /** The run level target we're waiting for. */
|
---|
259 | AdditionsRunLevelType_T mRunLevelTarget;
|
---|
260 | };
|
---|
261 | #endif /* !VBOX_ONLY_DOCS */
|
---|
262 |
|
---|
263 | #endif /* !VBOX_INCLUDED_SRC_VBoxManage_VBoxManageGuestCtrl_h */
|
---|
264 |
|
---|