VirtualBox

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


Ignore:
Timestamp:
Jul 24, 2012 12:13:00 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
79433
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

    r42272 r42354  
    1919#define ____H_GUESTIMPLPRIVATE
    2020
     21#include <iprt/asm.h>
    2122#include <iprt/semaphore.h>
    2223
     
    6768
    6869/**
    69  * Generic class for a all guest control callbacks.
    70  */
    71 class GuestCtrlCallback
    72 {
    73 public:
    74 
     70 * Generic class for a all guest control callbacks/events.
     71 */
     72class GuestCtrlEvent
     73{
     74public:
     75
     76    GuestCtrlEvent(void);
     77
     78    virtual ~GuestCtrlEvent(void);
     79
     80    /** @todo Copy/comparison operator? */
     81
     82public:
     83
     84    int Cancel(void);
     85
     86    bool Canceled(void);
     87
     88    virtual void Destroy(void);
     89
     90    int Init(void);
     91
     92    virtual int Signal(int rc = VINF_SUCCESS);
     93
     94    int GetResultCode(void) { return mRC; }
     95
     96    int Wait(ULONG uTimeoutMS);
     97
     98protected:
     99
     100    /** Was the callback canceled? */
     101    bool                        fCanceled;
     102    /** Did the callback complete? */
     103    bool                        fCompleted;
     104    /** The event semaphore for triggering
     105     *  the actual event. */
     106    RTSEMEVENT                  hEventSem;
     107    /** The waiting mutex. */
     108    RTSEMMUTEX                  hEventMutex;
     109    /** Overall result code. */
     110    int                         mRC;
     111};
     112
     113/*
     114 * Class representing a guest control callback.
     115 */
     116class GuestCtrlCallback : public GuestCtrlEvent
     117{
     118public:
    75119    GuestCtrlCallback(void);
    76120
     
    79123    virtual ~GuestCtrlCallback(void);
    80124
    81     /** @todo Copy/comparison operator? */
    82 
    83 public:
    84 
    85     int Cancel(void);
    86 
    87     bool Canceled(void);
     125public:
     126
     127    void Destroy(void);
    88128
    89129    int Init(eVBoxGuestCtrlCallbackType enmType);
    90130
    91     void Destroy(void);
    92 
    93     int Signal(int rc = VINF_SUCCESS, const Utf8Str &strMsg = "");
    94 
    95     Utf8Str GetMessage(void) { return mMessage; }
    96 
    97     int GetResultCode(void) { return mRC; }
    98 
    99     eVBoxGuestCtrlCallbackType GetType(void) { return mType; }
    100 
    101     int Wait(ULONG uTimeoutMS);
    102 
    103 protected:
    104 
     131    eVBoxGuestCtrlCallbackType GetCallbackType(void) { return mType; }
     132
     133protected:
     134
     135    /** Pointer to user-supplied data. */
     136    void                       *pvData;
     137    /** Size of user-supplied data. */
     138    size_t                      cbData;
    105139    /** The callback type. */
    106140    eVBoxGuestCtrlCallbackType  mType;
    107141    /** Callback flags. */
    108142    uint32_t                    uFlags;
    109     /** Was the callback canceled? */
    110     bool                        fCanceled;
    111     /** Did the callback complete? */
    112     bool                        fCompleted;
    113     /** Pointer to user-supplied data. */
    114     void                       *pvData;
    115     /** Size of user-supplied data. */
    116     size_t                      cbData;
    117     /** The event semaphore triggering the*/
    118     RTSEMEVENT                  hEventSem;
    119     /** Overall result code. */
     143};
     144typedef std::map < uint32_t, GuestCtrlCallback* > GuestCtrlCallbacks;
     145
     146struct GuestProcessWaitResult
     147{
     148    /** The wait result when returning from the wait call. */
     149    ProcessWaitResult_T         mResult;
    120150    int                         mRC;
    121     /** Error / information message to the
    122      *  result code. */
    123     Utf8Str                     mMessage;
    124 };
    125 typedef std::map < uint32_t, GuestCtrlCallback* > GuestCtrlCallbacks;
     151};
     152
     153/*
     154 * Class representing a guest control process event.
     155 */
     156class GuestProcessEvent : public GuestCtrlEvent
     157{
     158public:
     159    GuestProcessEvent(void);
     160
     161    GuestProcessEvent(uint32_t uWaitFlags);
     162
     163    virtual ~GuestProcessEvent(void);
     164
     165public:
     166
     167    void Destroy(void);
     168
     169    int Init(uint32_t uWaitFlags);
     170
     171    uint32_t GetWaitFlags(void) { return ASMAtomicReadU32(&mWaitFlags); }
     172
     173    GuestProcessWaitResult GetResult(void) { return mWaitResult; }
     174
     175    int Signal(ProcessWaitResult enmResult, int rc = VINF_SUCCESS);
     176
     177protected:
     178
     179    /** The waiting flag(s). The specifies what to
     180     *  wait for. */
     181    uint32_t                    mWaitFlags;
     182    /** Structure containing the overall result. */
     183    GuestProcessWaitResult      mWaitResult;
     184};
    126185
    127186/**
  • trunk/src/VBox/Main/include/GuestImpl.h

    r42214 r42354  
    209209    int         sessionClose(ComObjPtr<GuestSession> pSession);
    210210    int         sessionCreate(const Utf8Str &strUser, const Utf8Str &aPassword, const Utf8Str &aDomain,
    211                               const Utf8Str &aSessionName, IGuestSession **aGuestSession);
     211                              const Utf8Str &aSessionName, ComObjPtr<GuestSession> &pGuestSession);
    212212    inline bool sessionExists(uint32_t uSessionID);
    213213    /** @}  */
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r42272 r42354  
    6262    STDMETHOD(Read)(ULONG aHandle, ULONG aSize, ULONG aTimeoutMS, ComSafeArrayOut(BYTE, aData));
    6363    STDMETHOD(Terminate)(void);
    64     STDMETHOD(WaitFor)(ComSafeArrayIn(ProcessWaitForFlag_T, aFlags), ULONG aTimeoutMS, ProcessWaitReason_T *aReason);
     64    STDMETHOD(WaitFor)(ComSafeArrayIn(ProcessWaitForFlag_T, aFlags), ULONG aTimeoutMS, ProcessWaitResult_T *aReason);
    6565    STDMETHOD(Write)(ULONG aHandle, ComSafeArrayIn(BYTE, aData), ULONG aTimeoutMS, ULONG *aWritten);
    6666    /** @}  */
     
    6969    /** @name Public internal methods.
    7070     * @{ */
    71     int callbackAdd(GuestCtrlCallback *pCallback, ULONG *puContextID);
    7271    int callbackDispatcher(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData);
    7372    inline bool callbackExists(ULONG uContextID);
     73    void close(void);
    7474    bool isReady(void);
    7575    ULONG getPID(void) { return mData.mPID; }
     76    int readData(ULONG uHandle, ULONG uSize, ULONG uTimeoutMS, BYTE *pbData, size_t cbData);
     77    int startProcess(void);
     78    int startProcessAsync(void);
     79    int terminateProcess(void);
     80    int waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestProcessWaitResult &guestResult);
     81    HRESULT waitResultToErrorEx(const GuestProcessWaitResult &waitResult, bool fLog);
     82    int writeData(ULONG uHandle, BYTE const *pbData, size_t cbData, ULONG uTimeoutMS, ULONG *puWritten);
     83    /** @}  */
     84
     85protected:
     86    /** @name Protected internal methods.
     87     * @{ */
     88    inline int callbackAdd(GuestCtrlCallback *pCallback, ULONG *puContextID);
     89    inline int callbackRemove(ULONG uContextID);
    7690    int onGuestDisconnected(GuestCtrlCallback *pCallback, PCALLBACKDATACLIENTDISCONNECTED pData);
    7791    int onProcessInputStatus(GuestCtrlCallback *pCallback, PCALLBACKDATAEXECINSTATUS pData);
     
    7993    int onProcessOutput(GuestCtrlCallback *pCallback, PCALLBACKDATAEXECOUT pData);
    8094    int prepareExecuteEnv(const char *pszEnv, void **ppvList, ULONG *pcbList, ULONG *pcEnvVars);
    81     int readData(ULONG uHandle, ULONG uSize, ULONG uTimeoutMS, BYTE *pbData, size_t cbData);
    8295    int sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
    83     int signalWaiters(int rc, const Utf8Str strMessage = "");
    84     int startProcess(int *pRC = NULL, Utf8Str *pstrMessage = NULL);
     96    int signalWaiters(ProcessWaitResult enmWaitResult, int rc = VINF_SUCCESS);
    8597    static DECLCALLBACK(int) startProcessThread(RTTHREAD Thread, void *pvUser);
    86     int terminateProcess(void);
    87     int waitFor(uint32_t fFlags, ULONG uTimeoutMS, ProcessWaitReason_T *penmReason);
    88     int writeData(ULONG uHandle, BYTE const *pbData, size_t cbData, ULONG uTimeoutMS, ULONG *puWritten);
    8998    /** @}  */
    9099
     
    110119        /** The current process status. */
    111120        ProcessStatus_T          mStatus;
    112         /** Flag indicating whether the process has been started. */
     121        /** Flag indicating whether the process has been started
     122         *  so that it can't be started a second time. */
    113123        bool                     mStarted;
    114124        /** The next upcoming context ID. */
    115125        ULONG                    mNextContextID;
    116         /** Flag indicating someone is waiting for an event. */
    117         bool                     mWaiting;
    118         /** The waiting mutex. */
    119         RTSEMMUTEX               mWaitMutex;
    120         /** The waiting flag(s). */
    121         uint32_t                 mWaitFlags;
    122         /** The waiting event. */
    123         RTSEMEVENT               mWaitEvent;
     126        /** How many waiters? At the moment there can only
     127         *  be one. */
     128        uint32_t                 mWaitCount;
     129        /** The actual process event for doing the waits.
     130         *  At the moment we only support one wait a time. */
     131        GuestProcessEvent       *mWaitEvent;
    124132    } mData;
    125133};
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r42272 r42354  
    126126    const GuestEnvironment &getEnvironment(void);
    127127    int                     processClose(ComObjPtr<GuestProcess> pProcess);
    128     int                     processCreateExInteral(const GuestProcessInfo &aProcInfo, IGuestProcess **aProcess);
     128    int                     processCreateExInteral(GuestProcessInfo &procInfo, ComObjPtr<GuestProcess> &pProgress);
    129129    inline bool             processExists(ULONG uProcessID, ComObjPtr<GuestProcess> *pProcess);
    130130    inline int              processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess);
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