1 | /* $Id: VBoxManageGuestCtrl.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxManageGuestCtrl.h - Definitions for guest control.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2013-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VBOX_INCLUDED_SRC_VBoxManage_VBoxManageGuestCtrl_h
|
---|
29 | #define VBOX_INCLUDED_SRC_VBoxManage_VBoxManageGuestCtrl_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <VBox/com/com.h>
|
---|
35 | #include <VBox/com/listeners.h>
|
---|
36 | #include <VBox/com/VirtualBox.h>
|
---|
37 |
|
---|
38 | #include <iprt/semaphore.h>
|
---|
39 | #include <iprt/time.h>
|
---|
40 |
|
---|
41 | #include <map>
|
---|
42 |
|
---|
43 | const char *gctlFileStatusToText(FileStatus_T enmStatus);
|
---|
44 | const char *gctlProcessStatusToText(ProcessStatus_T enmStatus);
|
---|
45 | const char *gctlGuestSessionStatusToText(GuestSessionStatus_T enmStatus);
|
---|
46 |
|
---|
47 | using namespace com;
|
---|
48 |
|
---|
49 | class GuestFileEventListener;
|
---|
50 | typedef ListenerImpl<GuestFileEventListener> GuestFileEventListenerImpl;
|
---|
51 |
|
---|
52 | class GuestProcessEventListener;
|
---|
53 | typedef ListenerImpl<GuestProcessEventListener> GuestProcessEventListenerImpl;
|
---|
54 |
|
---|
55 | class GuestSessionEventListener;
|
---|
56 | typedef ListenerImpl<GuestSessionEventListener> GuestSessionEventListenerImpl;
|
---|
57 |
|
---|
58 | class GuestEventListener;
|
---|
59 | typedef ListenerImpl<GuestEventListener> GuestEventListenerImpl;
|
---|
60 |
|
---|
61 | class GuestAdditionsRunlevelListener;
|
---|
62 | typedef ListenerImpl<GuestAdditionsRunlevelListener> GuestAdditionsRunlevelListenerImpl;
|
---|
63 |
|
---|
64 | /** Simple statistics class for binding locally
|
---|
65 | * held data to a specific guest object. */
|
---|
66 | class GuestEventStats
|
---|
67 | {
|
---|
68 |
|
---|
69 | public:
|
---|
70 |
|
---|
71 | GuestEventStats(void)
|
---|
72 | : uLastUpdatedMS(RTTimeMilliTS())
|
---|
73 | {
|
---|
74 | }
|
---|
75 |
|
---|
76 | /** @todo Make this more a class than a structure. */
|
---|
77 | public:
|
---|
78 |
|
---|
79 | uint64_t uLastUpdatedMS;
|
---|
80 | };
|
---|
81 |
|
---|
82 | class GuestFileStats : public GuestEventStats
|
---|
83 | {
|
---|
84 |
|
---|
85 | public:
|
---|
86 |
|
---|
87 | GuestFileStats(void) { }
|
---|
88 |
|
---|
89 | GuestFileStats(ComObjPtr<GuestFileEventListenerImpl> pListenerImpl)
|
---|
90 | : mListener(pListenerImpl)
|
---|
91 | {
|
---|
92 | }
|
---|
93 |
|
---|
94 | public: /** @todo */
|
---|
95 |
|
---|
96 | ComObjPtr<GuestFileEventListenerImpl> mListener;
|
---|
97 | };
|
---|
98 |
|
---|
99 | class GuestProcStats : public GuestEventStats
|
---|
100 | {
|
---|
101 |
|
---|
102 | public:
|
---|
103 |
|
---|
104 | GuestProcStats(void) { }
|
---|
105 |
|
---|
106 | GuestProcStats(ComObjPtr<GuestProcessEventListenerImpl> pListenerImpl)
|
---|
107 | : mListener(pListenerImpl)
|
---|
108 | {
|
---|
109 | }
|
---|
110 |
|
---|
111 | public: /** @todo */
|
---|
112 |
|
---|
113 | ComObjPtr<GuestProcessEventListenerImpl> mListener;
|
---|
114 | };
|
---|
115 |
|
---|
116 | class GuestSessionStats : public GuestEventStats
|
---|
117 | {
|
---|
118 |
|
---|
119 | public:
|
---|
120 |
|
---|
121 | GuestSessionStats(void) { }
|
---|
122 |
|
---|
123 | GuestSessionStats(ComObjPtr<GuestSessionEventListenerImpl> pListenerImpl)
|
---|
124 | : mListener(pListenerImpl)
|
---|
125 | {
|
---|
126 | }
|
---|
127 |
|
---|
128 | public: /** @todo */
|
---|
129 |
|
---|
130 | ComObjPtr<GuestSessionEventListenerImpl> mListener;
|
---|
131 | };
|
---|
132 |
|
---|
133 | /** Map containing all watched guest files. */
|
---|
134 | typedef std::map< ComPtr<IGuestFile>, GuestFileStats > GuestEventFiles;
|
---|
135 | /** Map containing all watched guest processes. */
|
---|
136 | typedef std::map< ComPtr<IGuestProcess>, GuestProcStats > GuestEventProcs;
|
---|
137 | /** Map containing all watched guest sessions. */
|
---|
138 | typedef std::map< ComPtr<IGuestSession>, GuestSessionStats > GuestEventSessions;
|
---|
139 |
|
---|
140 | class GuestListenerBase
|
---|
141 | {
|
---|
142 | public:
|
---|
143 |
|
---|
144 | GuestListenerBase(void);
|
---|
145 |
|
---|
146 | virtual ~GuestListenerBase(void);
|
---|
147 |
|
---|
148 | public:
|
---|
149 |
|
---|
150 | HRESULT init(bool fVerbose = false);
|
---|
151 |
|
---|
152 | protected:
|
---|
153 |
|
---|
154 | /** Verbose flag. */
|
---|
155 | bool mfVerbose;
|
---|
156 | };
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Handler for guest process events.
|
---|
160 | */
|
---|
161 | class GuestFileEventListener : public GuestListenerBase
|
---|
162 | {
|
---|
163 | public:
|
---|
164 |
|
---|
165 | GuestFileEventListener(void);
|
---|
166 |
|
---|
167 | virtual ~GuestFileEventListener(void);
|
---|
168 |
|
---|
169 | public:
|
---|
170 |
|
---|
171 | void uninit(void);
|
---|
172 |
|
---|
173 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
174 |
|
---|
175 | protected:
|
---|
176 |
|
---|
177 | };
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Handler for guest process events.
|
---|
181 | */
|
---|
182 | class GuestProcessEventListener : public GuestListenerBase
|
---|
183 | {
|
---|
184 | public:
|
---|
185 |
|
---|
186 | GuestProcessEventListener(void);
|
---|
187 |
|
---|
188 | virtual ~GuestProcessEventListener(void);
|
---|
189 |
|
---|
190 | public:
|
---|
191 |
|
---|
192 | void uninit(void);
|
---|
193 |
|
---|
194 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
195 |
|
---|
196 | protected:
|
---|
197 |
|
---|
198 | };
|
---|
199 |
|
---|
200 | /**
|
---|
201 | * Handler for guest session events.
|
---|
202 | */
|
---|
203 | class GuestSessionEventListener : public GuestListenerBase
|
---|
204 | {
|
---|
205 | public:
|
---|
206 |
|
---|
207 | GuestSessionEventListener(void);
|
---|
208 |
|
---|
209 | virtual ~GuestSessionEventListener(void);
|
---|
210 |
|
---|
211 | public:
|
---|
212 |
|
---|
213 | void uninit(void);
|
---|
214 |
|
---|
215 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
216 |
|
---|
217 | protected:
|
---|
218 |
|
---|
219 | GuestEventFiles mFiles;
|
---|
220 | GuestEventProcs mProcs;
|
---|
221 | };
|
---|
222 |
|
---|
223 | /**
|
---|
224 | * Handler for guest events.
|
---|
225 | */
|
---|
226 | class GuestEventListener : public GuestListenerBase
|
---|
227 | {
|
---|
228 |
|
---|
229 | public:
|
---|
230 |
|
---|
231 | GuestEventListener(void);
|
---|
232 |
|
---|
233 | virtual ~GuestEventListener(void);
|
---|
234 |
|
---|
235 | public:
|
---|
236 |
|
---|
237 | void uninit(void);
|
---|
238 |
|
---|
239 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
240 |
|
---|
241 | protected:
|
---|
242 |
|
---|
243 | GuestEventSessions mSessions;
|
---|
244 | };
|
---|
245 |
|
---|
246 | /**
|
---|
247 | * Handler for Guest Additions runlevel change events.
|
---|
248 | */
|
---|
249 | class GuestAdditionsRunlevelListener : public GuestListenerBase
|
---|
250 | {
|
---|
251 |
|
---|
252 | public:
|
---|
253 |
|
---|
254 | GuestAdditionsRunlevelListener(AdditionsRunLevelType_T enmRunLevel);
|
---|
255 |
|
---|
256 | virtual ~GuestAdditionsRunlevelListener(void);
|
---|
257 |
|
---|
258 | public:
|
---|
259 |
|
---|
260 | void uninit(void);
|
---|
261 |
|
---|
262 | STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent *aEvent);
|
---|
263 |
|
---|
264 | protected:
|
---|
265 |
|
---|
266 | /** The run level target we're waiting for. */
|
---|
267 | AdditionsRunLevelType_T mRunLevelTarget;
|
---|
268 | };
|
---|
269 |
|
---|
270 | #endif /* !VBOX_INCLUDED_SRC_VBoxManage_VBoxManageGuestCtrl_h */
|
---|