VirtualBox

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

Last change on this file since 31685 was 31436, checked in by vboxsync, 14 years ago

Guest Additions version lookup/status: Moved actual version string lookup/fallback to Main to support all other frontends, build up version string using revision number.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2010 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#if 0
78 /** @todo Will replace old AdditionsActive call. */
79 STDMETHOD(COMGETTER(AdditionsActive)) (ULONG aLevel, BOOL *aAdditionsActive);
80#endif
81 STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
82 STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
83 /** @todo Remove later by replacing it by AdditionsFeatureAvailable(). */
84 STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
85 STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
86#if 0
87 /** @todo Will replace SupportsSeamless, SupportsGraphics, ... */
88 STDMETHOD(COMGETTER(AdditionsFeatureAvailable)) (ULONG64 aFeature, BOOL *aActive, BOOL *aAvailable);
89#endif
90 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
91 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
92 STDMETHOD(COMGETTER(PageFusionEnabled)) (BOOL *aPageFusionEnabled);
93 STDMETHOD(COMSETTER(PageFusionEnabled)) (BOOL aPageFusionEnabled);
94 STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
95 STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
96
97 // IGuest methods
98 STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
99 IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
100 STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
101 ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
102 IN_BSTR aUserName, IN_BSTR aPassword,
103 ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
104 STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
105 STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus);
106 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
107 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
108 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
109
110 // Public methods that are not in IDL (only called internally).
111 void setAdditionsInfo(Bstr aInterfaceVersion, VBOXOSTYPE aOsType);
112 void setAdditionsInfo2(Bstr aAdditionsVersion, Bstr aVersionName, Bstr aRevision);
113 void setAdditionsStatus(VBoxGuestStatusFacility Facility, VBoxGuestStatusCurrent Status, ULONG ulFlags);
114 void setSupportedFeatures(ULONG64 ulCaps, ULONG64 ulActive);
115 HRESULT setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
116
117# ifdef VBOX_WITH_GUEST_CONTROL
118 /** Static callback for handling guest notifications. */
119 static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
120# endif
121
122private:
123
124# ifdef VBOX_WITH_GUEST_CONTROL
125 struct CallbackContext
126 {
127 eVBoxGuestCtrlCallbackType mType;
128 /** Pointer to user-supplied data. */
129 void *pvData;
130 /** Size of user-supplied data. */
131 uint32_t cbData;
132 /** Pointer to user-supplied IProgress. */
133 ComObjPtr<Progress> pProgress;
134 };
135 /*
136 * The map key is the context ID.
137 */
138 typedef std::map< uint32_t, CallbackContext > CallbackMap;
139 typedef std::map< uint32_t, CallbackContext >::iterator CallbackMapIter;
140 typedef std::map< uint32_t, CallbackContext >::const_iterator CallbackMapIterConst;
141
142 struct GuestProcess
143 {
144 uint32_t mStatus;
145 uint32_t mFlags;
146 uint32_t mExitCode;
147 };
148 /*
149 * The map key is the PID (process identifier).
150 */
151 typedef std::map< uint32_t, GuestProcess > GuestProcessMap;
152 typedef std::map< uint32_t, GuestProcess >::iterator GuestProcessMapIter;
153 typedef std::map< uint32_t, GuestProcess >::const_iterator GuestProcessMapIterConst;
154
155 int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
156 /** Handler for guest execution control notifications. */
157 int notifyCtrlClientDisconnected(uint32_t u32Function, PCALLBACKDATACLIENTDISCONNECTED pData);
158 int notifyCtrlExecStatus(uint32_t u32Function, PCALLBACKDATAEXECSTATUS pData);
159 int notifyCtrlExecOut(uint32_t u32Function, PCALLBACKDATAEXECOUT pData);
160 CallbackMapIter getCtrlCallbackContextByID(uint32_t u32ContextID);
161 GuestProcessMapIter getProcessByPID(uint32_t u32PID);
162 void destroyCtrlCallbackContext(CallbackMapIter it);
163 uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
164# endif
165
166 struct Data
167 {
168 Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
169 mSupportsGraphics (FALSE) {}
170
171 Bstr mOSTypeId;
172 BOOL mAdditionsActive;
173 Bstr mAdditionsVersion;
174 Bstr mInterfaceVersion;
175 BOOL mSupportsSeamless;
176 BOOL mSupportsGraphics;
177 };
178
179 ULONG mMemoryBalloonSize;
180 ULONG mStatUpdateInterval;
181 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
182 BOOL mfPageFusionEnabled;
183
184 Console *mParent;
185 Data mData;
186
187# ifdef VBOX_WITH_GUEST_CONTROL
188 /** General extension callback for guest control. */
189 HGCMSVCEXTHANDLE mhExtCtrl;
190
191 volatile uint32_t mNextContextID;
192 CallbackMap mCallbackMap;
193 GuestProcessMap mGuestProcessMap;
194# endif
195};
196
197#endif // ____H_GUESTIMPL
198/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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