VirtualBox

Changeset 85744 in vbox for trunk/src


Ignore:
Timestamp:
Aug 13, 2020 8:28:29 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139892
Message:

DnD/Main: Renaming (GuestDnDResponse -> GuestDnDState).

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

Legend:

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

    r85739 r85744  
    3737class Guest;
    3838class GuestDnDBase;
    39 class GuestDnDResponse;
     39class GuestDnDState;
    4040class GuestDnDSource;
    4141class GuestDnDTarget;
     
    481481    /** Pointer to guest target class this context belongs to. */
    482482    GuestDnDTarget                     *pTarget;
    483     /** Pointer to guest response class this context belongs to. */
    484     GuestDnDResponse                   *pResp;
     483    /** Pointer to guest state this context belongs to. */
     484    GuestDnDState                      *pState;
    485485    /** Target (VM) screen ID. */
    486486    uint32_t                            uScreenID;
     
    558558    /** Pointer to guest source class this context belongs to. */
    559559    GuestDnDSource                     *pSource;
    560     /** Pointer to guest response class this context belongs to. */
    561     GuestDnDResponse                   *pResp;
     560    /** Pointer to guest state this context belongs to. */
     561    GuestDnDState                      *pState;
    562562    /** Formats offered by the guest (and supported by the host). */
    563563    GuestDnDMIMEList                    lstFmtOffered;
     
    797797typedef std::map<uint32_t, GuestDnDCallback> GuestDnDCallbackMap;
    798798
    799 /** @todo r=andy This class needs to go, as this now is too inflexible when it comes to all
    800  *               the callback handling/dispatching. It's part of the initial code and only adds
    801  *               unnecessary complexity. */
    802 class GuestDnDResponse
    803 {
    804 
    805 public:
    806 
    807     GuestDnDResponse(const ComObjPtr<Guest>& pGuest);
    808     virtual ~GuestDnDResponse(void);
     799/**
     800 * Class for keeping a DnD guest state around.
     801 */
     802class GuestDnDState
     803{
     804
     805public:
     806
     807    GuestDnDState(const ComObjPtr<Guest>& pGuest);
     808    virtual ~GuestDnDState(void);
    809809
    810810public:
     
    925925     * @{ */
    926926    HRESULT           adjustScreenCoordinates(ULONG uScreenId, ULONG *puX, ULONG *puY) const;
     927    GuestDnDState    *getState(uint32_t = 0) const;
    927928    int               hostCall(uint32_t u32Function, uint32_t cParms, PVBOXHGCMSVCPARM paParms) const;
    928     GuestDnDResponse *response(void) { return m_pResponse; }
    929929    GuestDnDMIMEList  defaultFormats(void) const { return m_strDefaultFormats; }
    930930    /** @}  */
     
    968968    /** Pointer to guest implementation. */
    969969    const ComObjPtr<Guest>      m_pGuest;
    970     /** The current (last) response from the guest. At the
    971      *  moment we only support only response a time (ARQ-style). */
    972     GuestDnDResponse           *m_pResponse;
     970    /** The current state from the guest. At the
     971     *  moment we only support only state a time (ARQ-style). */
     972    GuestDnDState              *m_pState;
    973973    /** Critical section to serialize access. */
    974974    RTCRITSECT                  m_CritSect;
     
    10221022
    10231023    int sendCancel(void);
    1024     int updateProgress(GuestDnDData *pData, GuestDnDResponse *pResp, size_t cbDataAdd = 0);
    1025     int waitForEvent(GuestDnDCallbackEvent *pEvent, GuestDnDResponse *pResp, RTMSINTERVAL msTimeout);
     1024    int updateProgress(GuestDnDData *pData, GuestDnDState *pState, size_t cbDataAdd = 0);
     1025    int waitForEvent(GuestDnDCallbackEvent *pEvent, GuestDnDState *pState, RTMSINTERVAL msTimeout);
    10261026
    10271027protected:
     
    10371037    /** Whether the object still is in pending state. */
    10381038    bool                            m_fIsPending;
    1039     /** Pointer to response bound to this object. */
    1040     GuestDnDResponse               *m_pResp;
     1039    /** Pointer to state bound to this object. */
     1040    GuestDnDState                  *m_pState;
    10411041    /** @}  */
    10421042
  • trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp

    r85739 r85744  
    184184GuestDnDSendCtx::GuestDnDSendCtx(void)
    185185    : pTarget(NULL)
    186     , pResp(NULL)
     186    , pState(NULL)
    187187{
    188188    reset();
     
    194194void GuestDnDSendCtx::reset(void)
    195195{
    196     if (pResp)
    197         pResp->reset();
     196    if (pState)
     197        pState->reset();
    198198
    199199    uScreenID  = 0;
     
    213213GuestDnDRecvCtx::GuestDnDRecvCtx(void)
    214214    : pSource(NULL)
    215     , pResp(NULL)
     215    , pState(NULL)
    216216{
    217217    reset();
     
    223223void GuestDnDRecvCtx::reset(void)
    224224{
    225     if (pResp)
    226         pResp->reset();
     225    if (pState)
     226        pState->reset();
    227227
    228228    lstFmtOffered.clear();
     
    290290 ********************************************************************************************************************************/
    291291
    292 GuestDnDResponse::GuestDnDResponse(const ComObjPtr<Guest>& pGuest)
     292GuestDnDState::GuestDnDState(const ComObjPtr<Guest>& pGuest)
    293293    : m_uProtocolVersion(0)
    294294    , m_fGuestFeatures0(VBOX_DND_GF_NONE)
     
    303303}
    304304
    305 GuestDnDResponse::~GuestDnDResponse(void)
     305GuestDnDState::~GuestDnDState(void)
    306306{
    307307    reset();
     
    314314 * Notifies the waiting side about a guest notification response.
    315315 */
    316 int GuestDnDResponse::notifyAboutGuestResponse(void) const
     316int GuestDnDState::notifyAboutGuestResponse(void) const
    317317{
    318318    return RTSemEventSignal(m_EventSem);
     
    322322 * Resets a GuestDnDResponse object.
    323323 */
    324 void GuestDnDResponse::reset(void)
     324void GuestDnDState::reset(void)
    325325{
    326326    LogFlowThisFuncEnter();
     
    338338 * @param   pParent             Parent to set for the progress object.
    339339 */
    340 HRESULT GuestDnDResponse::resetProgress(const ComObjPtr<Guest>& pParent)
     340HRESULT GuestDnDState::resetProgress(const ComObjPtr<Guest>& pParent)
    341341{
    342342    m_pProgress.setNull();
     
    358358 * @returns \c true if canceled, \c false if not.
    359359 */
    360 bool GuestDnDResponse::isProgressCanceled(void) const
     360bool GuestDnDState::isProgressCanceled(void) const
    361361{
    362362    BOOL fCanceled;
     
    380380 * @param   pvUser              User-provided arguments for the callback function. Optional and can be NULL.
    381381 */
    382 int GuestDnDResponse::setCallback(uint32_t uMsg, PFNGUESTDNDCALLBACK pfnCallback, void *pvUser /* = NULL */)
     382int GuestDnDState::setCallback(uint32_t uMsg, PFNGUESTDNDCALLBACK pfnCallback, void *pvUser /* = NULL */)
    383383{
    384384    GuestDnDCallbackMap::iterator it = m_mapCallbacks.find(uMsg);
     
    413413 * @param   strMsg              Message to set. Optional.
    414414 */
    415 int GuestDnDResponse::setProgress(unsigned uPercentage, uint32_t uStatus,
    416                                   int rcOp /* = VINF_SUCCESS */, const Utf8Str &strMsg /* = "" */)
     415int GuestDnDState::setProgress(unsigned uPercentage, uint32_t uStatus,
     416                               int rcOp /* = VINF_SUCCESS */, const Utf8Str &strMsg /* = "" */)
    417417{
    418418    LogFlowFunc(("uPercentage=%u, uStatus=%RU32, , rcOp=%Rrc, strMsg=%s\n",
     
    516516 * @param   cbParms             Size (in bytes) of \a pvParms.
    517517 */
    518 int GuestDnDResponse::onDispatch(uint32_t u32Function, void *pvParms, uint32_t cbParms)
     518int GuestDnDState::onDispatch(uint32_t u32Function, void *pvParms, uint32_t cbParms)
    519519{
    520520    LogFlowFunc(("u32Function=%RU32, pvParms=%p, cbParms=%RU32\n", u32Function, pvParms, cbParms));
     
    687687 * @param   ppProgress          Where to query the progress object to.
    688688 */
    689 HRESULT GuestDnDResponse::queryProgressTo(IProgress **ppProgress)
     689HRESULT GuestDnDState::queryProgressTo(IProgress **ppProgress)
    690690{
    691691    return m_pProgress.queryInterfaceTo(ppProgress);
     
    698698 * @param   msTimeout           Timeout (in ms) for waiting. Optional, waits 500 ms if not specified.
    699699 */
    700 int GuestDnDResponse::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */) const
     700int GuestDnDState::waitForGuestResponse(RTMSINTERVAL msTimeout /*= 500 */) const
    701701{
    702702    int rc = RTSemEventWait(m_EventSem, msTimeout);
     
    722722    try
    723723    {
    724         m_pResponse = new GuestDnDResponse(pGuest);
     724        m_pState = new GuestDnDState(pGuest);
    725725    }
    726726    catch (std::bad_alloc &)
     
    751751    RTCritSectDelete(&m_CritSect);
    752752
    753     if (m_pResponse)
    754         delete m_pResponse;
     753    if (m_pState)
     754        delete m_pState;
    755755}
    756756
     
    794794
    795795/**
     796 * Returns a DnD guest state.
     797 *
     798 * @returns Pointer to DnD guest state, or NULL if not found / invalid.
     799 * @param   uID                 ID of DnD guest state to return.
     800 */
     801GuestDnDState *GuestDnD::getState(uint32_t uID /* = 0 */) const
     802{
     803    AssertMsgReturn(uID == 0, ("Only one state (0) is supported at the moment\n"), NULL);
     804
     805    return m_pState;
     806}
     807
     808/**
    796809 * Sends a (blocking) message to the host side of the host service.
    797810 *
     
    941954     *        would be the place to lookup and dispatch to those. For the moment we
    942955     *        only have one response -- simple. */
    943     GuestDnDResponse *pResp = pGuestDnD->m_pResponse;
    944     if (pResp)
    945         return pResp->onDispatch(u32Function, pvParms, cbParms);
     956    if (pGuestDnD->m_pState)
     957        return pGuestDnD->m_pState->onDispatch(u32Function, pvParms, cbParms);
    946958
    947959    return VERR_NOT_SUPPORTED;
     
    13081320    GuestDnDMsg Msg;
    13091321    Msg.setType(HOST_DND_CANCEL);
    1310     if (m_pResp->m_uProtocolVersion >= 3)
     1322    if (m_pState->m_uProtocolVersion >= 3)
    13111323        Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    13121324
     
    13251337 * @returns VBox status code.
    13261338 * @param   pData               GuestDnDData object to use for accounting.
    1327  * @param   pResp               GuestDnDResponse to update its progress object for.
     1339 * @param   pState              Guest state to update its progress object for.
    13281340 * @param   cbDataAdd           By how much data (in bytes) to update the progress.
    13291341 */
    1330 int GuestDnDBase::updateProgress(GuestDnDData *pData, GuestDnDResponse *pResp,
     1342int GuestDnDBase::updateProgress(GuestDnDData *pData, GuestDnDState *pState,
    13311343                                 size_t cbDataAdd /* = 0 */)
    13321344{
    13331345    AssertPtrReturn(pData, VERR_INVALID_POINTER);
    1334     AssertPtrReturn(pResp, VERR_INVALID_POINTER);
     1346    AssertPtrReturn(pState, VERR_INVALID_POINTER);
    13351347    /* cbDataAdd is optional. */
    13361348
     
    13381350                 pData->cbExtra, pData->cbProcessed, pData->getRemaining(), cbDataAdd));
    13391351
    1340     if (   !pResp
     1352    if (   !pState
    13411353        || !cbDataAdd) /* Only update if something really changes. */
    13421354        return VINF_SUCCESS;
     
    13491361    LogRel2(("DnD: Transfer %RU8%% complete\n", uPercent));
    13501362
    1351     int rc = pResp->setProgress(uPercent,
    1352                                   pData->isComplete()
    1353                                 ? DND_PROGRESS_COMPLETE
    1354                                 : DND_PROGRESS_RUNNING);
     1363    int rc = pState->setProgress(uPercent,
     1364                                   pData->isComplete()
     1365                                 ? DND_PROGRESS_COMPLETE
     1366                                 : DND_PROGRESS_RUNNING);
    13551367    LogFlowFuncLeaveRC(rc);
    13561368    return rc;
     
    13601372 * Waits for a specific guest callback event to get signalled.
    13611373 *
    1362  ** @todo GuestDnDResponse *pResp needs to go.
    1363  *
    13641374 * @returns VBox status code. Will return VERR_CANCELLED if the user has cancelled the progress object.
    13651375 * @param   pEvent                  Callback event to wait for.
    1366  * @param   pResp                   Response to update.
     1376 * @param   pState                  Guest state to update.
    13671377 * @param   msTimeout               Timeout (in ms) to wait.
    13681378 */
    1369 int GuestDnDBase::waitForEvent(GuestDnDCallbackEvent *pEvent, GuestDnDResponse *pResp, RTMSINTERVAL msTimeout)
     1379int GuestDnDBase::waitForEvent(GuestDnDCallbackEvent *pEvent, GuestDnDState *pState, RTMSINTERVAL msTimeout)
    13701380{
    13711381    AssertPtrReturn(pEvent, VERR_INVALID_POINTER);
    1372     AssertPtrReturn(pResp, VERR_INVALID_POINTER);
     1382    AssertPtrReturn(pState, VERR_INVALID_POINTER);
    13731383
    13741384    int rc;
     
    14001410            LogRel2(("DnD: Error: Guest did not respond within time\n"));
    14011411        }
    1402         else if (pResp->isProgressCanceled()) /** @todo GuestDnDResponse *pResp needs to go. */
     1412        else if (pState->isProgressCanceled())
    14031413        {
    14041414            LogRel2(("DnD: Operation was canceled by user\n"));
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r85743 r85744  
    163163     *  nor 2) mixed transfers (G->H + H->G at the same time).
    164164     */
    165     m_pResp = GuestDnDInst()->response();
    166     AssertPtrReturn(m_pResp, E_POINTER);
     165    m_pState = GuestDnDInst()->getState();
     166    AssertPtrReturn(m_pState, E_POINTER);
    167167
    168168    /* Confirm a successful initialization when it's the case. */
     
    276276    GuestDnDMsg Msg;
    277277    Msg.setType(HOST_DND_GH_REQ_PENDING);
    278     if (m_pResp->m_uProtocolVersion >= 3)
     278    if (m_pState->m_uProtocolVersion >= 3)
    279279        Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    280280    Msg.appendUInt32(uScreenId);
     
    283283    if (RT_SUCCESS(rc))
    284284    {
    285         GuestDnDResponse *pResp = GuestDnDInst()->response();
    286         AssertPtr(pResp);
     285        GuestDnDState *pState = GuestDnDInst()->getState();
     286        AssertPtr(pState);
    287287
    288288        bool fFetchResult = true;
    289289
    290         rc = pResp->waitForGuestResponse(100 /* Timeout in ms */);
     290        rc = pState->waitForGuestResponse(100 /* Timeout in ms */);
    291291        if (RT_FAILURE(rc))
    292292            fFetchResult = false;
    293293
    294294        if (   fFetchResult
    295             && isDnDIgnoreAction(pResp->getActionDefault()))
     295            && isDnDIgnoreAction(pState->getActionDefault()))
    296296            fFetchResult = false;
    297297
     
    305305             * which are not supported by the host.
    306306             */
    307             GuestDnDMIMEList lstFiltered  = GuestDnD::toFilteredFormatList(m_lstFmtSupported, pResp->formats());
     307            GuestDnDMIMEList lstFiltered  = GuestDnD::toFilteredFormatList(m_lstFmtSupported, pState->formats());
    308308            if (lstFiltered.size())
    309309            {
     
    313313
    314314                aFormats            = lstFiltered;
    315                 aAllowedActions     = GuestDnD::toMainActions(pResp->getActionsAllowed());
     315                aAllowedActions     = GuestDnD::toMainActions(pState->getActionsAllowed());
    316316                if (aDefaultAction)
    317                     *aDefaultAction = GuestDnD::toMainAction(pResp->getActionDefault());
     317                    *aDefaultAction = GuestDnD::toMainAction(pState->getActionDefault());
    318318
    319319                /* Apply the (filtered) formats list. */
     
    324324        }
    325325
    326         LogFlowFunc(("fFetchResult=%RTbool, lstActionsAllowed=0x%x\n", fFetchResult, pResp->getActionsAllowed()));
     326        LogFlowFunc(("fFetchResult=%RTbool, lstActionsAllowed=0x%x\n", fFetchResult, pState->getActionsAllowed()));
    327327    }
    328328
     
    370370
    371371    /* Reset progress object. */
    372     GuestDnDResponse *pResp = GuestDnDInst()->response();
    373     AssertPtr(pResp);
    374     HRESULT hr = pResp->resetProgress(m_pGuest);
     372    GuestDnDState *pState = GuestDnDInst()->getState();
     373    AssertPtr(pState);
     374    HRESULT hr = pState->resetProgress(m_pGuest);
    375375    if (FAILED(hr))
    376376        return hr;
     
    381381    {
    382382        mData.mRecvCtx.pSource       = this;
    383         mData.mRecvCtx.pResp         = pResp;
     383        mData.mRecvCtx.pState        = pState;
    384384        mData.mRecvCtx.enmAction     = dndAction;
    385385        mData.mRecvCtx.strFmtReq     = aFormat;
     
    419419        GuestDnDInst()->registerSource(this);
    420420
    421         hr = pResp->queryProgressTo(aProgress.asOutParam());
     421        hr = pState->queryProgressTo(aProgress.asOutParam());
    422422        ComAssertComRC(hr);
    423423
     
    665665        size_t  cbMetaAnnounced;
    666666
    667         if (m_pResp->m_uProtocolVersion < 3)
     667        if (m_pState->m_uProtocolVersion < 3)
    668668        {
    669669            cbData  = pSndData->u.v1.cbData;
     
    748748                {
    749749                    /* Update our process with the data we already received. */
    750                     rc = updateProgress(pCtx, pCtx->pResp, cbMetaAnnounced);
     750                    rc = updateProgress(pCtx, pCtx->pState, cbMetaAnnounced);
    751751                    AssertRC(rc);
    752752                }
     
    757757            else /* Raw data. */
    758758            {
    759                 rc = updateProgress(pCtx, pCtx->pResp, cbData);
     759                rc = updateProgress(pCtx, pCtx->pState, cbData);
    760760                AssertRC(rc);
    761761            }
     
    882882
    883883        /* Note: Protocol v1 does not send any file sizes, so always 0. */
    884         if (m_pResp->m_uProtocolVersion >= 2)
     884        if (m_pState->m_uProtocolVersion >= 2)
    885885            rc = DnDTransferObjectSetSize(pObj, cbSize);
    886886
     
    966966        }
    967967
    968         rc = updateProgress(pCtx, pCtx->pResp, cbWritten);
     968        rc = updateProgress(pCtx, pCtx->pState, cbWritten);
    969969        AssertRCBreak(rc);
    970970
     
    11041104    LogFlowFuncEnter();
    11051105
    1106     GuestDnDResponse *pResp = pCtx->pResp;
    1107     AssertPtr(pCtx->pResp);
     1106    GuestDnDState *pState = pCtx->pState;
     1107    AssertPtr(pCtx->pState);
    11081108
    11091109    GuestDnD *pInst = GuestDnDInst();
     
    11121112
    11131113#define REGISTER_CALLBACK(x) \
    1114     do {                                                            \
    1115         rc = pResp->setCallback(x, i_receiveRawDataCallback, pCtx); \
    1116         if (RT_FAILURE(rc))                                         \
    1117             return rc;                                              \
     1114    do {                                                             \
     1115        rc = pState->setCallback(x, i_receiveRawDataCallback, pCtx); \
     1116        if (RT_FAILURE(rc))                                          \
     1117            return rc;                                               \
    11181118    } while (0)
    11191119
    11201120#define UNREGISTER_CALLBACK(x)                                      \
    11211121    do {                                                            \
    1122         int rc2 = pResp->setCallback(x, NULL);                      \
     1122        int rc2 = pState->setCallback(x, NULL);                     \
    11231123        AssertRC(rc2);                                              \
    11241124    } while (0)
     
    11301130    REGISTER_CALLBACK(GUEST_DND_DISCONNECT);
    11311131    REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1132     if (m_pResp->m_uProtocolVersion >= 3)
     1132    if (m_pState->m_uProtocolVersion >= 3)
    11331133        REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR);
    11341134    REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA);
     
    11411141        GuestDnDMsg Msg;
    11421142        Msg.setType(HOST_DND_GH_EVT_DROPPED);
    1143         if (m_pResp->m_uProtocolVersion >= 3)
     1143        if (m_pState->m_uProtocolVersion >= 3)
    11441144            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    11451145        Msg.appendPointer((void*)pCtx->strFmtRecv.c_str(), (uint32_t)pCtx->strFmtRecv.length() + 1);
     
    11521152        if (RT_SUCCESS(rc))
    11531153        {
    1154             rc = waitForEvent(&pCtx->EventCallback, pCtx->pResp, msTimeout);
     1154            rc = waitForEvent(&pCtx->EventCallback, pCtx->pState, msTimeout);
    11551155            if (RT_SUCCESS(rc))
    1156                 rc = pCtx->pResp->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
     1156                rc = pCtx->pState->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
    11571157        }
    11581158
     
    11651165    UNREGISTER_CALLBACK(GUEST_DND_DISCONNECT);
    11661166    UNREGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1167     if (m_pResp->m_uProtocolVersion >= 3)
     1167    if (m_pState->m_uProtocolVersion >= 3)
    11681168        UNREGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR);
    11691169    UNREGISTER_CALLBACK(GUEST_DND_GH_SND_DATA);
     
    11841184            AssertRC(rc2);
    11851185
    1186             rc2 = pCtx->pResp->setProgress(100, DND_PROGRESS_CANCELLED);
     1186            rc2 = pCtx->pState->setProgress(100, DND_PROGRESS_CANCELLED);
    11871187            AssertRC(rc2);
    11881188        }
    11891189        else if (rc != VERR_GSTDND_GUEST_ERROR) /* Guest-side error are already handled in the callback. */
    11901190        {
    1191             int rc2 = pCtx->pResp->setProgress(100, DND_PROGRESS_ERROR,
    1192                                                rc, GuestDnDSource::i_hostErrorToString(rc));
     1191            int rc2 = pCtx->pState->setProgress(100, DND_PROGRESS_ERROR,
     1192                                                rc, GuestDnDSource::i_hostErrorToString(rc));
    11931193            AssertRC(rc2);
    11941194        }
     
    12161216    LogFlowFuncEnter();
    12171217
    1218     GuestDnDResponse *pResp = pCtx->pResp;
    1219     AssertPtr(pCtx->pResp);
     1218    GuestDnDState *pState = pCtx->pState;
     1219    AssertPtr(pCtx->pState);
    12201220
    12211221    GuestDnD *pInst = GuestDnDInst();
     
    12231223        return VERR_INVALID_POINTER;
    12241224
    1225 #define REGISTER_CALLBACK(x)                                             \
    1226     do {                                                                 \
    1227         rc = pResp->setCallback(x, i_receiveTransferDataCallback, pCtx); \
    1228         if (RT_FAILURE(rc))                                              \
    1229             return rc;                                                   \
     1225#define REGISTER_CALLBACK(x)                                              \
     1226    do {                                                                  \
     1227        rc = pState->setCallback(x, i_receiveTransferDataCallback, pCtx); \
     1228        if (RT_FAILURE(rc))                                               \
     1229            return rc;                                                    \
    12301230    } while (0)
    12311231
    1232 #define UNREGISTER_CALLBACK(x)                                      \
    1233     do {                                                            \
    1234         int rc2 = pResp->setCallback(x, NULL);                      \
    1235         AssertRC(rc2);                                              \
     1232#define UNREGISTER_CALLBACK(x)                                       \
     1233    do {                                                             \
     1234        int rc2 = pState->setCallback(x, NULL);                      \
     1235        AssertRC(rc2);                                               \
    12361236    } while (0)
    12371237
     
    12431243    REGISTER_CALLBACK(GUEST_DND_DISCONNECT);
    12441244    REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1245     if (m_pResp->m_uProtocolVersion >= 3)
     1245    if (m_pState->m_uProtocolVersion >= 3)
    12461246        REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR);
    12471247    REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA);
    12481248    REGISTER_CALLBACK(GUEST_DND_GH_SND_DIR);
    1249     if (m_pResp->m_uProtocolVersion >= 2)
     1249    if (m_pState->m_uProtocolVersion >= 2)
    12501250        REGISTER_CALLBACK(GUEST_DND_GH_SND_FILE_HDR);
    12511251    REGISTER_CALLBACK(GUEST_DND_GH_SND_FILE_DATA);
     
    12681268        GuestDnDMsg Msg;
    12691269        Msg.setType(HOST_DND_GH_EVT_DROPPED);
    1270         if (m_pResp->m_uProtocolVersion >= 3)
     1270        if (m_pState->m_uProtocolVersion >= 3)
    12711271            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    12721272        Msg.appendPointer((void*)pCtx->strFmtRecv.c_str(), (uint32_t)pCtx->strFmtRecv.length() + 1);
     
    12811281            LogFlowFunc(("Waiting ...\n"));
    12821282
    1283             rc = waitForEvent(&pCtx->EventCallback, pCtx->pResp, msTimeout);
     1283            rc = waitForEvent(&pCtx->EventCallback, pCtx->pState, msTimeout);
    12841284            if (RT_SUCCESS(rc))
    1285                 rc = pCtx->pResp->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
     1285                rc = pCtx->pState->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
    12861286
    12871287            LogFlowFunc(("Waiting ended with rc=%Rrc\n", rc));
     
    13221322            AssertRC(rc2);
    13231323
    1324             rc2 = pCtx->pResp->setProgress(100, DND_PROGRESS_CANCELLED);
     1324            rc2 = pCtx->pState->setProgress(100, DND_PROGRESS_CANCELLED);
    13251325            AssertRC(rc2);
    13261326
     
    13301330        else if (rc != VERR_GSTDND_GUEST_ERROR) /* Guest-side error are already handled in the callback. */
    13311331        {
    1332             rc2 = pCtx->pResp->setProgress(100, DND_PROGRESS_ERROR,
    1333                                            rc, GuestDnDSource::i_hostErrorToString(rc));
     1332            rc2 = pCtx->pState->setProgress(100, DND_PROGRESS_ERROR,
     1333                                            rc, GuestDnDSource::i_hostErrorToString(rc));
    13341334            AssertRC(rc2);
    13351335        }
     
    14051405            AssertReturn(CB_MAGIC_DND_GH_EVT_ERROR == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
    14061406
    1407             pCtx->pResp->reset();
     1407            pCtx->pState->reset();
    14081408
    14091409            if (RT_SUCCESS(pCBData->rc))
     
    14141414            else if (pCBData->rc == VERR_WRONG_ORDER)
    14151415            {
    1416                 rc = pCtx->pResp->setProgress(100, DND_PROGRESS_CANCELLED);
     1416                rc = pCtx->pState->setProgress(100, DND_PROGRESS_CANCELLED);
    14171417            }
    14181418            else
    1419                 rc = pCtx->pResp->setProgress(100, DND_PROGRESS_ERROR, pCBData->rc,
    1420                                               GuestDnDSource::i_guestErrorToString(pCBData->rc));
     1419                rc = pCtx->pState->setProgress(100, DND_PROGRESS_ERROR, pCBData->rc,
     1420                                               GuestDnDSource::i_guestErrorToString(pCBData->rc));
    14211421
    14221422            LogRel3(("DnD: Guest reported data transfer error: %Rrc\n", pCBData->rc));
     
    14581458
    14591459        /* Unregister this callback. */
    1460         AssertPtr(pCtx->pResp);
    1461         int rc2 = pCtx->pResp->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);
     1460        AssertPtr(pCtx->pState);
     1461        int rc2 = pCtx->pState->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);
    14621462        AssertRC(rc2);
    14631463    }
     
    15641564            AssertReturn(CB_MAGIC_DND_GH_SND_FILE_DATA == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
    15651565
    1566             if (pThis->m_pResp->m_uProtocolVersion <= 1)
     1566            if (pThis->m_pState->m_uProtocolVersion <= 1)
    15671567            {
    15681568                /**
     
    15891589            AssertReturn(CB_MAGIC_DND_GH_EVT_ERROR == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
    15901590
    1591             pCtx->pResp->reset();
     1591            pCtx->pState->reset();
    15921592
    15931593            if (RT_SUCCESS(pCBData->rc))
     
    15981598            else if (pCBData->rc == VERR_WRONG_ORDER)
    15991599            {
    1600                 rc = pCtx->pResp->setProgress(100, DND_PROGRESS_CANCELLED);
     1600                rc = pCtx->pState->setProgress(100, DND_PROGRESS_CANCELLED);
    16011601            }
    16021602            else
    1603                 rc = pCtx->pResp->setProgress(100, DND_PROGRESS_ERROR, pCBData->rc,
    1604                                               GuestDnDSource::i_guestErrorToString(pCBData->rc));
     1603                rc = pCtx->pState->setProgress(100, DND_PROGRESS_ERROR, pCBData->rc,
     1604                                               GuestDnDSource::i_guestErrorToString(pCBData->rc));
    16051605
    16061606            LogRel3(("DnD: Guest reported file transfer error: %Rrc\n", pCBData->rc));
     
    16421642
    16431643        /* Unregister this callback. */
    1644         AssertPtr(pCtx->pResp);
    1645         int rc2 = pCtx->pResp->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);
     1644        AssertPtr(pCtx->pState);
     1645        int rc2 = pCtx->pState->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);
    16461646        AssertRC(rc2);
    16471647    }
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r85743 r85744  
    161161     *  nor 2) mixed transfers (G->H + H->G at the same time).
    162162     */
    163     m_pResp = GuestDnDInst()->response();
    164     AssertPtrReturn(m_pResp, E_POINTER);
     163    m_pState = GuestDnDInst()->getState();
     164    AssertPtrReturn(m_pState, E_POINTER);
    165165
    166166    /* Confirm a successful initialization when it's the case. */
     
    316316        GuestDnDMsg Msg;
    317317        Msg.setType(HOST_DND_HG_EVT_ENTER);
    318         if (m_pResp->m_uProtocolVersion >= 3)
     318        if (m_pState->m_uProtocolVersion >= 3)
    319319            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    320320        Msg.appendUInt32(aScreenId);
     
    329329        if (RT_SUCCESS(rc))
    330330        {
    331             if (RT_SUCCESS(m_pResp->waitForGuestResponse()))
    332                 resAction = GuestDnD::toMainAction(m_pResp->getActionDefault());
     331            if (RT_SUCCESS(m_pState->waitForGuestResponse()))
     332                resAction = GuestDnD::toMainAction(m_pState->getActionDefault());
    333333        }
    334334    }
     
    393393        GuestDnDMsg Msg;
    394394        Msg.setType(HOST_DND_HG_EVT_MOVE);
    395         if (m_pResp->m_uProtocolVersion >= 3)
     395        if (m_pState->m_uProtocolVersion >= 3)
    396396            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    397397        Msg.appendUInt32(aScreenId);
     
    406406        if (RT_SUCCESS(rc))
    407407        {
    408             GuestDnDResponse *pResp = GuestDnDInst()->response();
    409             if (pResp && RT_SUCCESS(pResp->waitForGuestResponse()))
    410                 resAction = GuestDnD::toMainAction(pResp->getActionDefault());
     408            GuestDnDState *pState = GuestDnDInst()->getState();
     409            if (pState && RT_SUCCESS(pState->waitForGuestResponse()))
     410                resAction = GuestDnD::toMainAction(pState->getActionDefault());
    411411        }
    412412    }
     
    440440    GuestDnDMsg Msg;
    441441    Msg.setType(HOST_DND_HG_EVT_LEAVE);
    442     if (m_pResp->m_uProtocolVersion >= 3)
     442    if (m_pState->m_uProtocolVersion >= 3)
    443443        Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    444444
     
    446446    if (RT_SUCCESS(rc))
    447447    {
    448         GuestDnDResponse *pResp = GuestDnDInst()->response();
    449         if (pResp)
    450             pResp->waitForGuestResponse();
     448        GuestDnDState *pState = GuestDnDInst()->getState();
     449        if (pState)
     450            pState->waitForGuestResponse();
    451451    }
    452452
     
    516516        GuestDnDMsg Msg;
    517517        Msg.setType(HOST_DND_HG_EVT_DROPPED);
    518         if (m_pResp->m_uProtocolVersion >= 3)
     518        if (m_pState->m_uProtocolVersion >= 3)
    519519            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    520520        Msg.appendUInt32(aScreenId);
     
    529529        if (RT_SUCCESS(vrc))
    530530        {
    531             GuestDnDResponse *pResp = GuestDnDInst()->response();
    532             if (pResp && RT_SUCCESS(pResp->waitForGuestResponse()))
     531            GuestDnDState *pState = GuestDnDInst()->getState();
     532            if (pState && RT_SUCCESS(pState->waitForGuestResponse()))
    533533            {
    534                 resAct = GuestDnD::toMainAction(pResp->getActionDefault());
    535 
    536                 GuestDnDMIMEList lstFormats = pResp->formats();
     534                resAct = GuestDnD::toMainAction(pState->getActionDefault());
     535
     536                GuestDnDMIMEList lstFormats = pState->formats();
    537537                if (lstFormats.size() == 1) /* Exactly one format to use specified? */
    538538                {
     
    606606
    607607    /* Reset progress object. */
    608     GuestDnDResponse *pResp = GuestDnDInst()->response();
    609     AssertPtr(pResp);
    610     HRESULT hr = pResp->resetProgress(m_pGuest);
     608    GuestDnDState *pState = GuestDnDInst()->getState();
     609    AssertPtr(pState);
     610    HRESULT hr = pState->resetProgress(m_pGuest);
    611611    if (FAILED(hr))
    612612        return hr;
     
    619619
    620620        mData.mSendCtx.pTarget   = this;
    621         mData.mSendCtx.pResp     = pResp;
     621        mData.mSendCtx.pState    = pState;
    622622        mData.mSendCtx.uScreenID = aScreenId;
    623623
     
    654654
    655655        /* Return progress to caller. */
    656         hr = pResp->queryProgressTo(aProgress.asOutParam());
     656        hr = pState->queryProgressTo(aProgress.asOutParam());
    657657        ComAssertComRC(hr);
    658658    }
     
    835835    const char   *pcszFmt = pCtx->Meta.strFmt.c_str();
    836836
    837     LogFlowFunc(("uProtoVer=%RU32, szFmt=%s, cbFmt=%RU32, cbData=%zu\n", m_pResp->m_uProtocolVersion, pcszFmt, cbFmt, cbData));
     837    LogFlowFunc(("uProtoVer=%RU32, szFmt=%s, cbFmt=%RU32, cbData=%zu\n", m_pState->m_uProtocolVersion, pcszFmt, cbFmt, cbData));
    838838
    839839    LogRel2(("DnD: Sending meta data to guest as '%s' (%zu bytes)\n", pcszFmt, cbData));
     
    853853        Msg.setType(HOST_DND_HG_SND_DATA);
    854854
    855         if (m_pResp->m_uProtocolVersion < 3)
     855        if (m_pState->m_uProtocolVersion < 3)
    856856        {
    857857            Msg.appendUInt32(pCtx->uScreenID);                                 /* uScreenId */
     
    883883    if (RT_SUCCESS(rc))
    884884    {
    885         rc = updateProgress(pCtx, pCtx->pResp, (uint32_t)pCtx->Meta.cbData);
     885        rc = updateProgress(pCtx, pCtx->pState, (uint32_t)pCtx->Meta.cbData);
    886886        AssertRC(rc);
    887887    }
     
    901901    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    902902
    903     if (m_pResp->m_uProtocolVersion < 3) /* Protocol < v3 did not support this, skip. */
     903    if (m_pState->m_uProtocolVersion < 3) /* Protocol < v3 did not support this, skip. */
    904904        return VINF_SUCCESS;
    905905
     
    950950
    951951    pMsg->setType(HOST_DND_HG_SND_DIR);
    952     if (m_pResp->m_uProtocolVersion >= 3)
     952    if (m_pState->m_uProtocolVersion >= 3)
    953953        pMsg->appendUInt32(0); /** @todo ContextID not used yet. */
    954954    pMsg->appendString(pcszDstPath);                    /* path */
     
    997997    if (RT_SUCCESS(rc))
    998998    {
    999         if (m_pResp->m_uProtocolVersion >= 2)
     999        if (m_pState->m_uProtocolVersion >= 2)
    10001000        {
    10011001            if (!(pCtx->Transfer.fObjState & DND_OBJ_STATE_HAS_HDR))
     
    10671067    AssertPtrReturn(pMsg, VERR_INVALID_POINTER);
    10681068
    1069     AssertPtrReturn(pCtx->pResp, VERR_WRONG_ORDER);
     1069    AssertPtrReturn(pCtx->pState, VERR_WRONG_ORDER);
    10701070
    10711071    /** @todo Don't allow concurrent reads per context! */
     
    10791079    /* Protocol version 1 sends the file path *every* time with a new file chunk.
    10801080     * In protocol version 2 we only do this once with HOST_DND_HG_SND_FILE_HDR. */
    1081     if (m_pResp->m_uProtocolVersion <= 1)
     1081    if (m_pState->m_uProtocolVersion <= 1)
    10821082    {
    10831083        const size_t cchDstPath = RTStrNLen(pcszDstPath, RTPATH_MAX);
     
    10861086        pMsg->appendUInt32((uint32_t)cchDstPath + 1); /* cbName */
    10871087    }
    1088     else if (m_pResp->m_uProtocolVersion >= 2)
     1088    else if (m_pState->m_uProtocolVersion >= 2)
    10891089    {
    10901090        pMsg->appendUInt32(0);                        /** @todo ContextID not used yet. */
     
    11031103        LogFlowFunc(("cbBufe=%zu, cbRead=%RU32\n", cbBuf, cbRead));
    11041104
    1105         if (m_pResp->m_uProtocolVersion <= 1)
     1105        if (m_pState->m_uProtocolVersion <= 1)
    11061106        {
    11071107            pMsg->appendPointer(pvBuf, cbRead);                            /* pvData */
     
    11141114            pMsg->appendUInt32(cbRead);                                    /* cbData */
    11151115
    1116             if (m_pResp->m_uProtocolVersion >= 3)
     1116            if (m_pState->m_uProtocolVersion >= 3)
    11171117            {
    11181118                /** @todo Calculate checksum. */
     
    11221122        }
    11231123
    1124         int rc2 = updateProgress(pCtx, pCtx->pResp, (uint32_t)cbRead);
     1124        int rc2 = updateProgress(pCtx, pCtx->pState, (uint32_t)cbRead);
    11251125        AssertRC(rc2);
    11261126
     
    12231223            AssertReturn(CB_MAGIC_DND_GH_EVT_ERROR == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
    12241224
    1225             pCtx->pResp->reset();
     1225            pCtx->pState->reset();
    12261226
    12271227            if (RT_SUCCESS(pCBData->rc))
     
    12311231            }
    12321232
    1233             rc = pCtx->pResp->setProgress(100, DND_PROGRESS_ERROR, pCBData->rc,
    1234                                           GuestDnDTarget::i_guestErrorToString(pCBData->rc));
     1233            rc = pCtx->pState->setProgress(100, DND_PROGRESS_ERROR, pCBData->rc,
     1234                                           GuestDnDTarget::i_guestErrorToString(pCBData->rc));
    12351235            if (RT_SUCCESS(rc))
    12361236            {
     
    13431343    {
    13441344        /* Unregister this callback. */
    1345         AssertPtr(pCtx->pResp);
    1346         int rc2 = pCtx->pResp->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);
     1345        AssertPtr(pCtx->pState);
     1346        int rc2 = pCtx->pState->setCallback(uMsg, NULL /* PFNGUESTDNDCALLBACK */);
    13471347        AssertRC(rc2);
    13481348
     
    13731373{
    13741374    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    1375     AssertPtr(pCtx->pResp);
     1375    AssertPtr(pCtx->pState);
    13761376
    13771377#define REGISTER_CALLBACK(x)                                                 \
    13781378    do {                                                                     \
    1379         rc = pCtx->pResp->setCallback(x, i_sendTransferDataCallback, pCtx); \
     1379        rc = pCtx->pState->setCallback(x, i_sendTransferDataCallback, pCtx); \
    13801380        if (RT_FAILURE(rc))                                                  \
    13811381            return rc;                                                       \
     
    13841384#define UNREGISTER_CALLBACK(x)                        \
    13851385    do {                                              \
    1386         int rc2 = pCtx->pResp->setCallback(x, NULL); \
     1386        int rc2 = pCtx->pState->setCallback(x, NULL); \
    13871387        AssertRC(rc2);                                \
    13881388    } while (0)
     
    14061406    /* Host callbacks. */
    14071407    REGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
    1408     if (m_pResp->m_uProtocolVersion >= 2)
     1408    if (m_pState->m_uProtocolVersion >= 2)
    14091409        REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
    14101410    REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
     
    14731473         * Send the data header first.
    14741474         */
    1475         if (m_pResp->m_uProtocolVersion >= 3)
     1475        if (m_pState->m_uProtocolVersion >= 3)
    14761476            rc = i_sendMetaDataHeader(pCtx);
    14771477
     
    14841484        if (RT_SUCCESS(rc))
    14851485        {
    1486             rc = waitForEvent(&pCtx->EventCallback, pCtx->pResp, msTimeout);
     1486            rc = waitForEvent(&pCtx->EventCallback, pCtx->pState, msTimeout);
    14871487            if (RT_SUCCESS(rc))
    1488                 pCtx->pResp->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
     1488                pCtx->pState->setProgress(100, DND_PROGRESS_COMPLETE, VINF_SUCCESS);
    14891489        }
    14901490
     
    15011501    /* Host callbacks. */
    15021502    UNREGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
    1503     if (m_pResp->m_uProtocolVersion >= 2)
     1503    if (m_pState->m_uProtocolVersion >= 2)
    15041504        UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
    15051505    UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
     
    15221522            LogRel2(("DnD: Sending transfer data to guest cancelled by user\n"));
    15231523
    1524             rc2 = pCtx->pResp->setProgress(100, DND_PROGRESS_CANCELLED, VINF_SUCCESS);
     1524            rc2 = pCtx->pState->setProgress(100, DND_PROGRESS_CANCELLED, VINF_SUCCESS);
    15251525            AssertRC(rc2);
    15261526
     
    15311531        {
    15321532            LogRel(("DnD: Sending transfer data to guest failed with rc=%Rrc\n", rc));
    1533             int rc2 = pCtx->pResp->setProgress(100, DND_PROGRESS_ERROR, rc,
    1534                                                GuestDnDTarget::i_hostErrorToString(rc));
     1533            int rc2 = pCtx->pState->setProgress(100, DND_PROGRESS_ERROR, rc,
     1534                                                GuestDnDTarget::i_hostErrorToString(rc));
    15351535            AssertRC(rc2);
    15361536        }
     
    15551555    AssertPtrReturn(pMsg, VERR_INVALID_POINTER);
    15561556
    1557     int rc = updateProgress(pCtx, pCtx->pResp);
     1557    int rc = updateProgress(pCtx, pCtx->pState);
    15581558    AssertRCReturn(rc, rc);
    15591559
     
    16191619    {
    16201620        LogRel(("DnD: Sending raw data to guest failed with rc=%Rrc\n", rc));
    1621         rc2 = pCtx->pResp->setProgress(100 /* Percent */, DND_PROGRESS_ERROR, rc,
    1622                                        GuestDnDTarget::i_hostErrorToString(rc));
     1621        rc2 = pCtx->pState->setProgress(100 /* Percent */, DND_PROGRESS_ERROR, rc,
     1622                                        GuestDnDTarget::i_hostErrorToString(rc));
    16231623    }
    16241624    else
    1625         rc2 = pCtx->pResp->setProgress(100 /* Percent */, DND_PROGRESS_COMPLETE, rc);
     1625        rc2 = pCtx->pState->setProgress(100 /* Percent */, DND_PROGRESS_COMPLETE, rc);
    16261626    AssertRC(rc2);
    16271627
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