VirtualBox

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

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

Guest Control: Update (update on contexts for callbacks).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_GUESTIMPL
23#define ____H_GUESTIMPL
24
25#include "VirtualBoxBase.h"
26#include <VBox/ostypes.h>
27
28#ifdef VBOX_WITH_GUEST_CONTROL
29# include <VBox/HostServices/GuestControlSvc.h>
30# include <hgcm/HGCM.h>
31using namespace guestControl;
32#endif
33
34typedef enum
35{
36 GUESTSTATTYPE_CPUUSER = 0,
37 GUESTSTATTYPE_CPUKERNEL = 1,
38 GUESTSTATTYPE_CPUIDLE = 2,
39 GUESTSTATTYPE_MEMTOTAL = 3,
40 GUESTSTATTYPE_MEMFREE = 4,
41 GUESTSTATTYPE_MEMBALLOON = 5,
42 GUESTSTATTYPE_MEMCACHE = 6,
43 GUESTSTATTYPE_PAGETOTAL = 7,
44 GUESTSTATTYPE_PAGEFREE = 8,
45 GUESTSTATTYPE_MAX = 9
46} GUESTSTATTYPE;
47
48class Console;
49
50class ATL_NO_VTABLE Guest :
51 public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
52 public VirtualBoxSupportTranslation<Guest>,
53 public VirtualBoxBase,
54 VBOX_SCRIPTABLE_IMPL(IGuest)
55{
56public:
57
58 DECLARE_NOT_AGGREGATABLE(Guest)
59
60 DECLARE_PROTECT_FINAL_CONSTRUCT()
61
62 BEGIN_COM_MAP(Guest)
63 COM_INTERFACE_ENTRY(ISupportErrorInfo)
64 COM_INTERFACE_ENTRY(IGuest)
65 COM_INTERFACE_ENTRY(IDispatch)
66 END_COM_MAP()
67
68 DECLARE_EMPTY_CTOR_DTOR (Guest)
69
70 HRESULT FinalConstruct();
71 void FinalRelease();
72
73 // public initializer/uninitializer for internal purposes only
74 HRESULT init (Console *aParent);
75 void uninit();
76
77 // IGuest properties
78 STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
79 STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
80 STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
81 STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
82 STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
83 STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
84 STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
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 aStdIn, IN_BSTR aStdOut, IN_BSTR aStdErr,
94 IN_BSTR aUserName, IN_BSTR aPassword,
95 ULONG aTimeoutMS, ULONG* aPID, IProgress **aProgress);
96 STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
97 ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
98 ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal);
99
100 // public methods that are not in IDL
101 void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
102
103 void setSupportsSeamless (BOOL aSupportsSeamless);
104
105 void setSupportsGraphics (BOOL aSupportsGraphics);
106
107 HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
108
109 // for VirtualBoxSupportErrorInfoImpl
110 static const wchar_t *getComponentName() { return L"Guest"; }
111
112# ifdef VBOX_WITH_GUEST_CONTROL
113 /** Static callback for handling guest notifications. */
114 static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
115# endif
116
117private:
118
119# ifdef VBOX_WITH_GUEST_CONTROL
120 struct CallbackContext
121 {
122 uint32_t mContextID;
123 void *pvData;
124 uint32_t cbData;
125 /** Atomic flag whether callback was called. */
126 volatile bool bCalled;
127 };
128 typedef std::list< CallbackContext > CallbackList;
129 typedef std::list< CallbackContext >::iterator CallbackListIter;
130 typedef std::list< CallbackContext >::const_iterator CallbackListIterConst;
131
132 int prepareExecuteArgs(const char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs);
133 int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
134 /** Handler for guest execution control notifications. */
135 int notifyCtrlExec(uint32_t u32Function, PHOSTEXECCALLBACKDATA pData);
136 CallbackListIter getCtrlCallbackContext(uint32_t u32ContextID);
137 void removeCtrlCallbackContext(CallbackListIter it);
138 uint32_t addCtrlCallbackContext(void *pvData, uint32_t cbData);
139# endif
140
141 struct Data
142 {
143 Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
144 mSupportsGraphics (FALSE) {}
145
146 Bstr mOSTypeId;
147 BOOL mAdditionsActive;
148 Bstr mAdditionsVersion;
149 BOOL mSupportsSeamless;
150 BOOL mSupportsGraphics;
151 };
152
153 ULONG mMemoryBalloonSize;
154 ULONG mStatUpdateInterval;
155 ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
156
157 Console *mParent;
158 Data mData;
159
160# ifdef VBOX_WITH_GUEST_CONTROL
161 /** General extension callback for guest control. */
162 HGCMSVCEXTHANDLE mhExtCtrl;
163
164 volatile uint32_t mNextContextID;
165 CallbackList mCallbackList;
166# endif
167};
168
169#endif // ____H_GUESTIMPL
170/* 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