VirtualBox

source: vbox/trunk/src/VBox/Main/include/GuestImpl.h@ 30739

Last change on this file since 30739 was 30739, checked in by vboxsync, 15 years ago

Main: remove VirtualBoxSupportTranslation template, add translation support to generic base class, clean up COM headers more, remove SupportErrorInfo.cpp|h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 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_GUESTIMPL
19#define ____H_GUESTIMPL
20
21#include "VirtualBoxBase.h"
22#include <VBox/ostypes.h>
23
24#ifdef VBOX_WITH_GUEST_CONTROL
25# include <VBox/HostServices/GuestControlSvc.h>
26# include <hgcm/HGCM.h>
27using namespace guestControl;
28#endif
29
30typedef enum
31{
32 GUESTSTATTYPE_CPUUSER = 0,
33 GUESTSTATTYPE_CPUKERNEL = 1,
34 GUESTSTATTYPE_CPUIDLE = 2,
35 GUESTSTATTYPE_MEMTOTAL = 3,
36 GUESTSTATTYPE_MEMFREE = 4,
37 GUESTSTATTYPE_MEMBALLOON = 5,
38 GUESTSTATTYPE_MEMCACHE = 6,
39 GUESTSTATTYPE_PAGETOTAL = 7,
40 GUESTSTATTYPE_PAGEFREE = 8,
41 GUESTSTATTYPE_MAX = 9
42} GUESTSTATTYPE;
43
44class Console;
45#ifdef VBOX_WITH_GUEST_CONTROL
46class Progress;
47#endif
48
49class ATL_NO_VTABLE Guest :
50 public VirtualBoxBase,
51 VBOX_SCRIPTABLE_IMPL(IGuest)
52{
53public:
54 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Guest, IGuest)
55
56 DECLARE_NOT_AGGREGATABLE(Guest)
57
58 DECLARE_PROTECT_FINAL_CONSTRUCT()
59
60 BEGIN_COM_MAP(Guest)
61 COM_INTERFACE_ENTRY(ISupportErrorInfo)
62 COM_INTERFACE_ENTRY(IGuest)
63 COM_INTERFACE_ENTRY(IDispatch)
64 END_COM_MAP()
65
66 DECLARE_EMPTY_CTOR_DTOR (Guest)
67
68 HRESULT FinalConstruct();
69 void FinalRelease();
70
71 // public initializer/uninitializer for internal purposes only
72 HRESULT init (Console *aParent);
73 void uninit();
74
75 // IGuest properties
76 STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
77 STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
78 STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
79 STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
80 STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
81 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
82 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
83 STDMETHOD(COMGETTER(PageFusionEnabled)) (BOOL *aPageFusionEnabled);
84 STDMETHOD(COMSETTER(PageFusionEnabled)) (BOOL aPageFusionEnabled);
85 STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
86 STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
87
88 // IGuest methods
89 STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
90 IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
91 STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
92 ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
93 IN_BSTR aUserName, IN_BSTR aPassword,
94 ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
95 STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
96 STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus);
97 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
98 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
99 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
100
101 // public methods that are not in IDL
102 void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
103
104 void setSupportsSeamless (BOOL aSupportsSeamless);
105
106 void setSupportsGraphics (BOOL aSupportsGraphics);
107
108 HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
109
110# ifdef VBOX_WITH_GUEST_CONTROL
111 /** Static callback for handling guest notifications. */
112 static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
113# endif
114
115private:
116
117# ifdef VBOX_WITH_GUEST_CONTROL
118 struct CallbackContext
119 {
120 eVBoxGuestCtrlCallbackType mType;
121 /** Pointer to user-supplied data. */
122 void *pvData;
123 /** Size of user-supplied data. */
124 uint32_t cbData;
125 /** Pointer to user-supplied IProgress. */
126 ComObjPtr<Progress> pProgress;
127 };
128 /*
129 * The map key is the context ID.
130 */
131 typedef std::map< uint32_t, CallbackContext > CallbackMap;
132 typedef std::map< uint32_t, CallbackContext >::iterator CallbackMapIter;
133 typedef std::map< uint32_t, CallbackContext >::const_iterator CallbackMapIterConst;
134
135 struct GuestProcess
136 {
137 uint32_t mStatus;
138 uint32_t mFlags;
139 uint32_t mExitCode;
140 };
141 /*
142 * The map key is the PID (process identifier).
143 */
144 typedef std::map< uint32_t, GuestProcess > GuestProcessMap;
145 typedef std::map< uint32_t, GuestProcess >::iterator GuestProcessMapIter;
146 typedef std::map< uint32_t, GuestProcess >::const_iterator GuestProcessMapIterConst;
147
148 int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
149 /** Handler for guest execution control notifications. */
150 int notifyCtrlClientDisconnected(uint32_t u32Function, PCALLBACKDATACLIENTDISCONNECTED pData);
151 int notifyCtrlExecStatus(uint32_t u32Function, PCALLBACKDATAEXECSTATUS pData);
152 int notifyCtrlExecOut(uint32_t u32Function, PCALLBACKDATAEXECOUT pData);
153 CallbackMapIter getCtrlCallbackContextByID(uint32_t u32ContextID);
154 GuestProcessMapIter getProcessByPID(uint32_t u32PID);
155 void destroyCtrlCallbackContext(CallbackMapIter it);
156 uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
157# endif
158
159 struct Data
160 {
161 Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
162 mSupportsGraphics (FALSE) {}
163
164 Bstr mOSTypeId;
165 BOOL mAdditionsActive;
166 Bstr mAdditionsVersion;
167 BOOL mSupportsSeamless;
168 BOOL mSupportsGraphics;
169 };
170
171 ULONG mMemoryBalloonSize;
172 ULONG mStatUpdateInterval;
173 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
174 BOOL mfPageFusionEnabled;
175
176 Console *mParent;
177 Data mData;
178
179# ifdef VBOX_WITH_GUEST_CONTROL
180 /** General extension callback for guest control. */
181 HGCMSVCEXTHANDLE mhExtCtrl;
182
183 volatile uint32_t mNextContextID;
184 CallbackMap mCallbackMap;
185 GuestProcessMap mGuestProcessMap;
186# endif
187};
188
189#endif // ____H_GUESTIMPL
190/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette