VirtualBox

Changeset 42160 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Jul 16, 2012 11:41:10 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79137
Message:

Guest Control 2.0: Update.

Location:
trunk/src/VBox/Main/include
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r40575 r42160  
    11/** @file
    22 *
    3  * VirtualBox Guest Control - Private data definitions / classes.
     3 * Internal helpers/structures for guest control functionality.
    44 */
    55
    66/*
    7  * Copyright (C) 2011 Oracle Corporation
     7 * Copyright (C) 2011-2012 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919#define ____H_GUESTIMPLPRIVATE
    2020
     21#include <iprt/semaphore.h>
     22
    2123#include <VBox/com/com.h>
     24#include <VBox/com/ErrorInfo.h>
    2225#include <VBox/com/string.h>
    2326#include <VBox/com/VirtualBox.h>
     
    3336#endif
    3437
    35 class Guest;
    36 class Progress;
    37 
    38 /** Structure representing the "value" side of a "key=value" pair. */
     38
     39/* Builds a context ID out of the session ID, process ID and an
     40 * increasing count. */
     41#define VBOX_GUESTCTRL_CONTEXTID_MAKE(uSession, uProcess, uCount) \
     42    (  (uint32_t)((uSession) &   0xff) << 24 \
     43     | (uint32_t)((uProcess) &   0xff) << 16 \
     44     | (uint32_t)((uCount)   & 0xffff)       \
     45    )
     46
     47
     48typedef std::vector <LONG> ProcessAffinity;
     49typedef std::vector <Utf8Str> ProcessArguments;
     50typedef std::map <Utf8Str, Utf8Str> ProcessEnvironmentMap;
     51
     52
     53/**
     54 * Generic class for a all guest control callbacks.
     55 */
     56class GuestCtrlCallback
     57{
     58public:
     59
     60    GuestCtrlCallback(void);
     61
     62    GuestCtrlCallback(eVBoxGuestCtrlCallbackType enmType);
     63
     64    virtual ~GuestCtrlCallback(void);
     65
     66    /** @todo Copy/comparison operator? */
     67
     68public:
     69
     70    int Init(eVBoxGuestCtrlCallbackType enmType);
     71
     72    void Destroy(void);
     73
     74    eVBoxGuestCtrlCallbackType Type(void);
     75
     76    int Wait(RTMSINTERVAL timeoutMS);
     77
     78protected:
     79
     80    /** The callback type. */
     81    eVBoxGuestCtrlCallbackType  mType;
     82    /** Callback flags. */
     83    uint32_t                    mFlags;
     84    /** Pointer to user-supplied data. */
     85    void                       *pvData;
     86    /** Size of user-supplied data. */
     87    size_t                      cbData;
     88    /** The event semaphore triggering the*/
     89    RTSEMEVENT                  mEventSem;
     90    /** Extended error information, if any. */
     91    ErrorInfo                   mErrorInfo;
     92};
     93typedef std::map <uint32_t, GuestCtrlCallback> GuestCtrlCallbacks;
     94
     95/**
     96 * Simple structure mantaining guest credentials.
     97 */
     98class GuestCredentials
     99{
     100public:
     101
     102
     103public:
     104
     105    Utf8Str                     mUser;
     106    Utf8Str                     mPassword;
     107    Utf8Str                     mDomain;
     108};
     109
     110/**
     111 * Structure for keeping all the relevant process
     112 * starting parameters around.
     113 */
     114struct GuestProcessInfo
     115{
     116    Utf8Str                     mCommand;
     117    ProcessArguments            mArguments;
     118    ProcessEnvironmentMap       mEnvironment;
     119    uint32_t                    mFlags;
     120    ULONG                       mTimeoutMS;
     121    ProcessPriority_T           mPriority;
     122    ProcessAffinity             mAffinity;
     123};
     124
     125/**
     126 * Class representing the "value" side of a "key=value" pair.
     127 */
    39128class GuestProcessStreamValue
    40129{
     
    144233    BYTE *m_pbBuffer;
    145234};
     235
     236class Guest;
     237class Progress;
    146238
    147239class GuestTask
  • trunk/src/VBox/Main/include/GuestImpl.h

    r42105 r42160  
    44
    55/*
    6  * Copyright (C) 2006-2011 Oracle Corporation
     6 * Copyright (C) 2006-2012 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    205205    /** @name Public internal methods.
    206206     * @{ */
    207     int sessionClose(ComObjPtr<GuestSession> pSession);
     207    Console    *getConsole(void) { return mParent; }
     208    int         sessionClose(ComObjPtr<GuestSession> pSession);
     209    int         sessionCreate(const Utf8Str &strUser, const Utf8Str &aPassword, const Utf8Str &aDomain,
     210                              const Utf8Str &aSessionName, IGuestSession **aGuestSession);
     211    inline bool sessionExists(uint32_t uSessionID);
    208212    /** @}  */
    209213
     
    303307    typedef std::map< AdditionsFacilityType_T, ComObjPtr<AdditionsFacility> >::const_iterator FacilityMapIterConst;
    304308
    305     typedef std::list <ComObjPtr<GuestSession> > GuestSessions;
     309    /** Map for keeping the guest sessions. The primary key marks the guest session ID. */
     310    typedef std::map <uint32_t, ComObjPtr<GuestSession> > GuestSessions;
    306311
    307312    struct Data
     
    320325        Bstr                    mInterfaceVersion;
    321326        GuestSessions           mGuestSessions;
     327        uint32_t                mNextSessionID;
    322328    };
    323329
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r42117 r42160  
    2121
    2222#include "VirtualBoxBase.h"
     23#include "GuestCtrlImplPrivate.h"
    2324
    24 #include <vector>
    25 
    26 typedef std::vector<Utf8Str> StringsArray;
    27 
     25class Console;
    2826class GuestSession;
    2927
     
    4745    DECLARE_EMPTY_CTOR_DTOR(GuestProcess)
    4846
    49     int     init(GuestSession *pSession,
    50                  const Utf8Str &aCommand, const StringsArray &aArguments, const StringsArray &aEnvironment,
    51                  ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
    52                  ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity));
     47    int     init(Console *aConsole, GuestSession *aSession, uint32_t aProcessID, const GuestProcessInfo &aProcInfo);
    5348    void    uninit(void);
    5449    HRESULT FinalConstruct(void);
     
    7469    /** @name Public internal methods.
    7570     * @{ */
     71    int callbackAdd(const GuestCtrlCallback& theCallback, uint32_t *puContextID);
     72    bool callbackExists(uint32_t uContextID);
     73    bool isReady(void);
     74    int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnvVars);
     75    int readData(ULONG aHandle, ULONG aSize, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData));
     76    int startProcess(void);
     77    static DECLCALLBACK(int) GuestProcess::startProcessThread(RTTHREAD Thread, void *pvUser);
     78    int terminateProcess(void);
     79    int waitFor(ComSafeArrayIn(ProcessWaitForFlag_T, aFlags), ULONG aTimeoutMS, ProcessWaitReason_T *aReason);
     80    int writeData(ULONG aHandle, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
    7681    /** @}  */
    7782
    7883private:
    7984
    80     typedef std::map <Utf8Str, Utf8Str> MyStringMap;
    81 
    8285    struct Data
    8386    {
    84         GuestSession        *mParent;
    85         Bstr                 mName;
     87        /** Pointer to parent session. */
     88        GuestSession            *mParent;
     89        /** Pointer to the console object. Needed
     90         *  for HGCM (VMMDev) communication. */
     91        Console                 *mConsole;
     92        /** All related callbacks to this process. */
     93        GuestCtrlCallbacks       mCallbacks;
     94        /** The process start information. */
     95        GuestProcessInfo         mProcess;
     96        /** Exit code if process has been terminated. */
     97        LONG                     mExitCode;
     98        /** PID reported from the guest. */
     99        ULONG                    mPID;
     100        /** Internal, host-side process ID. */
     101        uint32_t                 mProcessID;
     102        /** The current process status. */
     103        ProcessStatus_T          mStatus;
     104        /** Flag indicating whether the process has been started. */
     105        bool                     mStarted;
     106        /** The next upcoming context ID. */
     107        uint32_t                 mNextContextID;
    86108    } mData;
    87109};
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r42117 r42160  
    2222#include "VirtualBoxBase.h"
    2323
     24#include "GuestCtrlImplPrivate.h"
    2425#include "GuestProcessImpl.h"
    2526#include "GuestDirectoryImpl.h"
    2627#include "GuestFileImpl.h"
    2728#include "GuestFsObjInfoImpl.h"
    28 
    29 #include <map>
    30 #include <vector>
    31 
    32 typedef std::vector<Utf8Str> StringsArray;
    3329
    3430class Guest;
     
    5248    DECLARE_EMPTY_CTOR_DTOR(GuestSession)
    5349
    54     int     init(Guest *aGuest, Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName);
     50    int     init(Guest *aGuest, uint32_t aSessionID, Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName);
    5551    void    uninit(void);
    5652    HRESULT FinalConstruct(void);
     
    115111    /** @name Public internal methods.
    116112     * @{ */
    117     int directoryClose(ComObjPtr<GuestDirectory> pDirectory);
    118     int fileClose(ComObjPtr<GuestFile> pFile);
    119     int processClose(ComObjPtr<GuestProcess> pProcess);
    120     int processCreateExInteral(const Utf8Str &aCommand, const StringsArray &aArguments, const StringsArray &aEnvironment,
    121                                ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
    122                                ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
    123                                IGuestProcess **aProcess);
     113    int                     directoryClose(ComObjPtr<GuestDirectory> pDirectory);
     114    int                     fileClose(ComObjPtr<GuestFile> pFile);
     115    const GuestCredentials &getCredentials(void);
     116    int                     processClose(ComObjPtr<GuestProcess> pProcess);
     117    int                     processCreateExInteral(GuestProcessInfo &aProcInfo, IGuestProcess **aProcess);
     118    inline bool             processExists(uint32_t uProcessID);
    124119    /** @}  */
    125120
     
    128123    typedef std::map <Utf8Str, Utf8Str> SessionEnvironment;
    129124
    130     typedef std::list <ComObjPtr<GuestDirectory> > SessionDirectories;
    131     typedef std::list <ComObjPtr<GuestFile> > SessionFiles;
    132     typedef std::list <ComObjPtr<GuestProcess> > SessionProcesses;
     125    typedef std::vector <ComObjPtr<GuestDirectory> > SessionDirectories;
     126    typedef std::vector <ComObjPtr<GuestFile> > SessionFiles;
     127    typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
    133128
    134129    struct Data
     
    137132         *  or not. Internal session are not accessible by clients. */
    138133        bool                 fInternal;
    139         /** Pointer to the parent (IGuest). */
     134        /** Pointer to the parent (Guest). */
    140135        Guest               *mParent;
    141136        /** The session credentials. */
    142         Utf8Str              mUser;
    143         Utf8Str              mPassword;
    144         Utf8Str              mDomain;
     137        GuestCredentials     mCredentials;
    145138        /** The (optional) session name. */
    146139        Utf8Str              mName;
Note: See TracChangeset for help on using the changeset viewer.

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