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