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