~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Main/include/GuestImpl.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/** @file
2
 
 *
3
2
 * VirtualBox COM class implementation
4
3
 */
5
4
 
19
18
#define ____H_GUESTIMPL
20
19
 
21
20
#include "VirtualBoxBase.h"
 
21
#include <iprt/list.h>
22
22
#include <VBox/ostypes.h>
23
23
 
24
24
#ifdef VBOX_WITH_GUEST_CONTROL
25
25
# include <VBox/HostServices/GuestControlSvc.h>
26
 
# include <hgcm/HGCM.h>
 
26
# include "HGCM.h"
27
27
using namespace guestControl;
28
28
#endif
29
29
 
47
47
#endif
48
48
 
49
49
class ATL_NO_VTABLE Guest :
50
 
    public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
51
 
    public VirtualBoxSupportTranslation<Guest>,
52
50
    public VirtualBoxBase,
53
51
    VBOX_SCRIPTABLE_IMPL(IGuest)
54
52
{
55
53
public:
 
54
    VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Guest, IGuest)
56
55
 
57
56
    DECLARE_NOT_AGGREGATABLE(Guest)
58
57
 
75
74
 
76
75
    // IGuest properties
77
76
    STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
78
 
#if 0
79
 
    /** @todo Will replace old AdditionsActive call. */
80
 
    STDMETHOD(COMGETTER(AdditionsActive)) (ULONG aLevel, BOOL *aAdditionsActive);
81
 
#endif
82
 
    STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
83
 
#if 0
84
 
    /** @todo Will replace AdditionsVersion to be more clear. */
85
 
    STDMETHOD(COMGETTER(AdditionsAPIVersion)) (BSTR *aAdditionsVersion);
86
 
#endif
 
77
    STDMETHOD(COMGETTER(AdditionsRunLevel)) (AdditionsRunLevelType_T *aRunLevel);
87
78
    STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
88
 
    /** @todo Remove */
 
79
    /** @todo Remove later by replacing it by AdditionsFeatureAvailable(). */
89
80
    STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
90
81
    STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
91
82
#if 0
92
83
    /** @todo Will replace SupportsSeamless, SupportsGraphics, ... */
93
 
    STDMETHOD(COMGETTER(AdditionsFeatureAvailable)) (ULONG64 aFeature, BOOL *aActive, BOOL *aAvailable);
 
84
    STDMETHOD(COMGETTER(AdditionsFeatureAvailable)) (LONG64 aFeature, BOOL *aActive, BOOL *aAvailable);
94
85
#endif
95
86
    STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
96
87
    STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
97
 
    STDMETHOD(COMGETTER(PageFusionEnabled)) (BOOL *aPageFusionEnabled);
98
 
    STDMETHOD(COMSETTER(PageFusionEnabled)) (BOOL aPageFusionEnabled);
99
88
    STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
100
89
    STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
101
90
 
102
91
    // IGuest methods
 
92
    STDMETHOD(GetAdditionsStatus)(AdditionsRunLevelType_T aLevel, BOOL *aActive);
103
93
    STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
104
94
                              IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
105
95
    STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
106
96
                              ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
107
97
                              IN_BSTR aUserName, IN_BSTR aPassword,
108
98
                              ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
109
 
    STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
 
99
    STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, LONG64 aSize, ComSafeArrayOut(BYTE, aData));
 
100
    STDMETHOD(SetProcessInput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ComSafeArrayIn(BYTE, aData), ULONG *aBytesWritten);
110
101
    STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus);
 
102
    STDMETHOD(CopyToGuest)(IN_BSTR aSource, IN_BSTR aDest, IN_BSTR aUserName, IN_BSTR aPassword, ULONG aFlags, IProgress **aProgress);
 
103
    STDMETHOD(CreateDirectory)(IN_BSTR aDirectory, IN_BSTR aUserName, IN_BSTR aPassword, ULONG aMode, ULONG aFlags, IProgress **aProgress);
111
104
    STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
112
105
                                     ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
113
106
                                     ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
 
107
    STDMETHOD(UpdateGuestAdditions)(IN_BSTR aSource, ULONG aFlags, IProgress **aProgress);
114
108
 
115
109
    // Public methods that are not in IDL (only called internally).
116
 
    void setAdditionsInfo(Bstr aVersion, VBOXOSTYPE aOsType);
 
110
    HRESULT executeProcessInternal(IN_BSTR aCommand, ULONG aFlags,
 
111
                                   ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
 
112
                                   IN_BSTR aUserName, IN_BSTR aPassword,
 
113
                                   ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress, int *pRC);
 
114
    HRESULT createDirectoryInternal(IN_BSTR aDirectory, IN_BSTR aUserName, IN_BSTR aPassword,
 
115
                                    ULONG aMode, ULONG aFlags, IProgress **aProgress, int *pRC);
 
116
    void setAdditionsInfo(Bstr aInterfaceVersion, VBOXOSTYPE aOsType);
 
117
    void setAdditionsInfo2(Bstr aAdditionsVersion, Bstr aVersionName, Bstr aRevision);
117
118
    void setAdditionsStatus(VBoxGuestStatusFacility Facility, VBoxGuestStatusCurrent Status, ULONG ulFlags);
118
 
    void setSupportedFeatures(ULONG64 ulCaps, ULONG64 ulActive);
 
119
    void setSupportedFeatures(uint32_t fCaps, uint32_t fActive);
119
120
    HRESULT setStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
120
 
 
121
 
    // for VirtualBoxSupportErrorInfoImpl
122
 
    static const wchar_t *getComponentName() { return L"Guest"; }
123
 
 
 
121
    BOOL isPageFusionEnabled();
124
122
# ifdef VBOX_WITH_GUEST_CONTROL
125
123
    /** Static callback for handling guest notifications. */
126
124
    static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
127
125
# endif
 
126
    static HRESULT setErrorStatic(HRESULT aResultCode,
 
127
                                  const Utf8Str &aText)
 
128
    {
 
129
        return setErrorInternal(aResultCode, getStaticClassIID(), getStaticComponentName(), aText, false, true);
 
130
    }
128
131
 
129
132
private:
130
133
 
131
 
# ifdef VBOX_WITH_GUEST_CONTROL
 
134
    // Internal tasks
 
135
    struct TaskGuest; /* Worker thread helper. */
 
136
#ifdef VBOX_WITH_GUEST_CONTROL
 
137
    HRESULT taskCopyFile(TaskGuest *aTask);
 
138
    HRESULT taskUpdateGuestAdditions(TaskGuest *aTask);
 
139
 
132
140
    struct CallbackContext
133
141
    {
134
142
        eVBoxGuestCtrlCallbackType  mType;
135
 
        /** Pointer to user-supplied data. */        
 
143
        /** Pointer to user-supplied data. */
136
144
        void                       *pvData;
137
145
        /** Size of user-supplied data. */
138
146
        uint32_t                    cbData;
159
167
    typedef std::map< uint32_t, GuestProcess >::iterator GuestProcessMapIter;
160
168
    typedef std::map< uint32_t, GuestProcess >::const_iterator GuestProcessMapIterConst;
161
169
 
 
170
    int directoryEntryAppend(const char *pszPath, PRTLISTNODE pList);
 
171
    int directoryRead(const char *pszDirectory, const char *pszFilter, ULONG uFlags, ULONG *pcObjects, PRTLISTNODE pList);
 
172
 
162
173
    int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
163
174
    /** Handler for guest execution control notifications. */
164
175
    int notifyCtrlClientDisconnected(uint32_t u32Function, PCALLBACKDATACLIENTDISCONNECTED pData);
165
176
    int notifyCtrlExecStatus(uint32_t u32Function, PCALLBACKDATAEXECSTATUS pData);
166
177
    int notifyCtrlExecOut(uint32_t u32Function, PCALLBACKDATAEXECOUT pData);
 
178
    int notifyCtrlExecInStatus(uint32_t u32Function, PCALLBACKDATAEXECINSTATUS pData);
167
179
    CallbackMapIter getCtrlCallbackContextByID(uint32_t u32ContextID);
168
180
    GuestProcessMapIter getProcessByPID(uint32_t u32PID);
 
181
    void notifyCtrlCallbackContext(Guest::CallbackMapIter it, const char *pszText);
169
182
    void destroyCtrlCallbackContext(CallbackMapIter it);
170
183
    uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
 
184
    HRESULT waitForProcessStatusChange(ULONG uPID, ULONG *puRetStatus, ULONG *puRetExitCode, ULONG uTimeoutMS);
171
185
# endif
172
186
 
173
187
    struct Data
174
188
    {
175
 
        Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
 
189
        Data() : mAdditionsRunLevel (AdditionsRunLevelType_None),
 
190
                 mSupportsSeamless (FALSE),
176
191
                 mSupportsGraphics (FALSE) {}
177
192
 
178
 
        Bstr  mOSTypeId;
179
 
        BOOL  mAdditionsActive;
180
 
        Bstr  mAdditionsVersion;
181
 
        BOOL  mSupportsSeamless;
182
 
        BOOL  mSupportsGraphics;
 
193
        Bstr                    mOSTypeId;
 
194
        AdditionsRunLevelType_T mAdditionsRunLevel;
 
195
        Bstr                    mAdditionsVersion;
 
196
        Bstr                    mInterfaceVersion;
 
197
        BOOL                    mSupportsSeamless;
 
198
        BOOL                    mSupportsGraphics;
183
199
    };
184
200
 
185
201
    ULONG mMemoryBalloonSize;