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 | typedef enum
|
---|
29 | {
|
---|
30 | GUESTSTATTYPE_CPUUSER = 0,
|
---|
31 | GUESTSTATTYPE_CPUKERNEL = 1,
|
---|
32 | GUESTSTATTYPE_CPUIDLE = 2,
|
---|
33 | GUESTSTATTYPE_MEMTOTAL = 3,
|
---|
34 | GUESTSTATTYPE_MEMFREE = 4,
|
---|
35 | GUESTSTATTYPE_MEMBALLOON = 5,
|
---|
36 | GUESTSTATTYPE_MEMCACHE = 6,
|
---|
37 | GUESTSTATTYPE_PAGETOTAL = 7,
|
---|
38 | GUESTSTATTYPE_PAGEFREE = 8,
|
---|
39 | GUESTSTATTYPE_MAX = 9
|
---|
40 | } GUESTSTATTYPE;
|
---|
41 |
|
---|
42 | class Console;
|
---|
43 |
|
---|
44 | class ATL_NO_VTABLE Guest :
|
---|
45 | public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
|
---|
46 | public VirtualBoxSupportTranslation<Guest>,
|
---|
47 | public VirtualBoxBase,
|
---|
48 | VBOX_SCRIPTABLE_IMPL(IGuest)
|
---|
49 | {
|
---|
50 | public:
|
---|
51 |
|
---|
52 | DECLARE_NOT_AGGREGATABLE(Guest)
|
---|
53 |
|
---|
54 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
55 |
|
---|
56 | BEGIN_COM_MAP(Guest)
|
---|
57 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
58 | COM_INTERFACE_ENTRY(IGuest)
|
---|
59 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
60 | END_COM_MAP()
|
---|
61 |
|
---|
62 | DECLARE_EMPTY_CTOR_DTOR (Guest)
|
---|
63 |
|
---|
64 | HRESULT FinalConstruct();
|
---|
65 | void FinalRelease();
|
---|
66 |
|
---|
67 | // public initializer/uninitializer for internal purposes only
|
---|
68 | HRESULT init (Console *aParent);
|
---|
69 | void uninit();
|
---|
70 |
|
---|
71 | // IGuest properties
|
---|
72 | STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
|
---|
73 | STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
|
---|
74 | STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
|
---|
75 | STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
|
---|
76 | STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
|
---|
77 | STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
|
---|
78 | STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
|
---|
79 | STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
|
---|
80 | STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
|
---|
81 |
|
---|
82 | // IGuest methods
|
---|
83 | STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
|
---|
84 | IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
|
---|
85 | STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
|
---|
86 | ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
|
---|
87 | IN_BSTR aStdIn, IN_BSTR aStdOut, IN_BSTR aStdErr,
|
---|
88 | IN_BSTR aUserName, IN_BSTR aPassword,
|
---|
89 | ULONG aTimeoutMS, ULONG* aPID, IProgress **aProgress);
|
---|
90 | STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
|
---|
91 | ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
|
---|
92 | ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal);
|
---|
93 |
|
---|
94 | // public methods that are not in IDL
|
---|
95 | void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
|
---|
96 |
|
---|
97 | void setSupportsSeamless (BOOL aSupportsSeamless);
|
---|
98 |
|
---|
99 | void setSupportsGraphics (BOOL aSupportsGraphics);
|
---|
100 |
|
---|
101 | HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
|
---|
102 |
|
---|
103 | // for VirtualBoxSupportErrorInfoImpl
|
---|
104 | static const wchar_t *getComponentName() { return L"Guest"; }
|
---|
105 |
|
---|
106 | private:
|
---|
107 |
|
---|
108 | # ifdef VBOX_WITH_GUEST_CONTROL
|
---|
109 | int prepareExecuteArgs(const char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs);
|
---|
110 | int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
|
---|
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 |
|
---|
115 | struct Data
|
---|
116 | {
|
---|
117 | Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
|
---|
118 | mSupportsGraphics (FALSE) {}
|
---|
119 |
|
---|
120 | Bstr mOSTypeId;
|
---|
121 | BOOL mAdditionsActive;
|
---|
122 | Bstr mAdditionsVersion;
|
---|
123 | BOOL mSupportsSeamless;
|
---|
124 | BOOL mSupportsGraphics;
|
---|
125 | };
|
---|
126 |
|
---|
127 | ULONG mMemoryBalloonSize;
|
---|
128 | ULONG mStatUpdateInterval;
|
---|
129 | ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
|
---|
130 |
|
---|
131 | Console *mParent;
|
---|
132 | Data mData;
|
---|
133 | bool mSignalled;
|
---|
134 | };
|
---|
135 |
|
---|
136 | #endif // ____H_GUESTIMPL
|
---|
137 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|