VirtualBox

Changeset 85739 in vbox for trunk/src


Ignore:
Timestamp:
Aug 13, 2020 7:08:34 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139887
Message:

DnD/Main: Got rid of protocol-guessing via Guest Additions version and pass down the reported (now marked as deprecated) protocol version and guest feature bits to Main.

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

Legend:

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

    r85583 r85739  
    837837    /** @}  */
    838838
    839 protected:
     839public:
    840840
    841841    /** Pointer to context this class is tied to. */
    842842    void                 *m_pvCtx;
     843    /** The DnD protocol version to use, depending on the
     844     *  installed Guest Additions. See DragAndDropSvc.h for
     845     *  a protocol changelog. */
     846    uint32_t              m_uProtocolVersion;
     847    /** The guest feature flags reported to the host (VBOX_DND_GF_XXX).  */
     848    uint64_t              m_fGuestFeatures0;
    843849    /** Event for waiting for response. */
    844850    RTSEMEVENT            m_EventSem;
     
    10031009    HRESULT i_addFormats(const GuestDnDMIMEList &aFormats);
    10041010    HRESULT i_removeFormats(const GuestDnDMIMEList &aFormats);
    1005 
    1006     HRESULT i_getProtocolVersion(ULONG *puVersion);
    10071011    /** @}  */
    10081012
    10091013protected:
    1010 
    1011     int getProtocolVersion(uint32_t *puVersion);
    10121014
    10131015    /** @name Functions for handling a simple host HGCM message queue.
     
    10351037    /** Whether the object still is in pending state. */
    10361038    bool                            m_fIsPending;
     1039    /** Pointer to response bound to this object. */
     1040    GuestDnDResponse               *m_pResp;
    10371041    /** @}  */
    10381042
     
    10421046    struct
    10431047    {
    1044         /** The DnD protocol version to use, depending on the
    1045          *  installed Guest Additions. See DragAndDropSvc.h for
    1046          *  a protocol changelog. */
    1047         uint32_t                    uProtocolVersion;
    10481048        /** Outgoing message queue (FIFO). */
    10491049        GuestDnDMsgList             lstMsgOut;
  • trunk/src/VBox/Main/src-client/GuestDnDPrivate.cpp

    r85681 r85739  
    291291
    292292GuestDnDResponse::GuestDnDResponse(const ComObjPtr<Guest>& pGuest)
    293     : m_EventSem(NIL_RTSEMEVENT)
     293    : m_uProtocolVersion(0)
     294    , m_fGuestFeatures0(VBOX_DND_GF_NONE)
     295    , m_EventSem(NIL_RTSEMEVENT)
    294296    , m_dndActionDefault(0)
    295297    , m_dndLstActionsAllowed(0)
     
    519521
    520522    int rc = VERR_WRONG_ORDER; /* Play safe. */
     523
     524    /* Whether or not to try calling host-installed callbacks after successfully processing the message. */
    521525    bool fTryCallbacks = false;
    522526
     
    525529        case DragAndDropSvc::GUEST_DND_CONNECT:
    526530        {
    527             LogThisFunc(("Client connected\n"));
    528 
    529             /* Nothing to do here (yet). */
     531            DragAndDropSvc::PVBOXDNDCBCONNECTDATA pCBData = reinterpret_cast<DragAndDropSvc::PVBOXDNDCBCONNECTDATA>(pvParms);
     532            AssertPtr(pCBData);
     533            AssertReturn(sizeof(DragAndDropSvc::VBOXDNDCBCONNECTDATA) == cbParms, VERR_INVALID_PARAMETER);
     534            AssertReturn(DragAndDropSvc::CB_MAGIC_DND_CONNECT == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
     535
     536            m_uProtocolVersion = pCBData->uProtocolVersion;
     537            /** @todo Handle flags. */
     538
     539            LogThisFunc(("Client connected, using protocol v%RU32\n", m_uProtocolVersion));
     540
     541            rc = VINF_SUCCESS;
     542            break;
     543        }
     544
     545        case DragAndDropSvc::GUEST_DND_REPORT_FEATURES:
     546        {
     547            DragAndDropSvc::PVBOXDNDCBREPORTFEATURESDATA pCBData = reinterpret_cast<DragAndDropSvc::PVBOXDNDCBREPORTFEATURESDATA>(pvParms);
     548            AssertPtr(pCBData);
     549            AssertReturn(sizeof(DragAndDropSvc::VBOXDNDCBREPORTFEATURESDATA) == cbParms, VERR_INVALID_PARAMETER);
     550            AssertReturn(DragAndDropSvc::CB_MAGIC_DND_REPORT_FEATURES == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
     551
     552            m_fGuestFeatures0 = pCBData->fGuestFeatures0;
     553
     554            LogThisFunc(("Client reported features: %#RX64\n", m_fGuestFeatures0));
     555
    530556            rc = VINF_SUCCESS;
    531557            break;
     
    11511177    /* Initialize public attributes. */
    11521178    m_lstFmtSupported = GuestDnDInst()->defaultFormats();
    1153 
    1154     /* Initialzie private stuff. */
    1155     m_DataBase.uProtocolVersion  = 0;
    11561179}
    11571180
     
    12181241}
    12191242
    1220 /* Deprecated. */
    1221 HRESULT GuestDnDBase::i_getProtocolVersion(ULONG *puVersion)
    1222 {
    1223     int rc = getProtocolVersion((uint32_t *)puVersion);
    1224     return RT_SUCCESS(rc) ? S_OK : E_FAIL;
    1225 }
    1226 
    1227 /**
    1228  * Tries to guess the DnD protocol version to use on the guest, based on the
    1229  * installed Guest Additions version + revision.
    1230  *
    1231  * Deprecated.
    1232  *
    1233  * If unable to retrieve the protocol version, VERR_NOT_FOUND is returned along
    1234  * with protocol version 1.
    1235  *
    1236  * @return  IPRT status code.
    1237  * @param   puProto                 Where to store the protocol version.
    1238  */
    1239 int GuestDnDBase::getProtocolVersion(uint32_t *puProto)
    1240 {
    1241     AssertPtrReturn(puProto, VERR_INVALID_POINTER);
    1242 
    1243     int rc;
    1244 
    1245     uint32_t uProto = 0;
    1246     uint32_t uVerAdditions;
    1247     uint32_t uRevAdditions;
    1248     if (   m_pGuest
    1249         && (uVerAdditions = m_pGuest->i_getAdditionsVersion())  > 0
    1250         && (uRevAdditions = m_pGuest->i_getAdditionsRevision()) > 0)
    1251     {
    1252 #if 0 && defined(DEBUG)
    1253         /* Hardcode the to-used protocol version; nice for testing side effects. */
    1254         if (true)
    1255             uProto = 3;
    1256         else
    1257 #endif
    1258         if (uVerAdditions >= VBOX_FULL_VERSION_MAKE(5, 0, 0))
    1259         {
    1260 /** @todo
    1261  *  r=bird: This is just too bad for anyone using an OSE additions build...
    1262  */
    1263             if (uRevAdditions >= 103344) /* Since r103344: Protocol v3. */
    1264                 uProto = 3;
    1265             else
    1266                 uProto = 2; /* VBox 5.0.0 - 5.0.8: Protocol v2. */
    1267         }
    1268         /* else: uProto: 0 */
    1269 
    1270         LogFlowFunc(("uVerAdditions=%RU32 (%RU32.%RU32.%RU32), r%RU32\n",
    1271                      uVerAdditions, VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions),
    1272                                     VBOX_FULL_VERSION_GET_BUILD(uVerAdditions), uRevAdditions));
    1273         rc = VINF_SUCCESS;
    1274     }
    1275     else
    1276     {
    1277         uProto = 1; /* Fallback. */
    1278         rc = VERR_NOT_FOUND;
    1279     }
    1280 
    1281     LogRel2(("DnD: Guest is using protocol v%RU32, rc=%Rrc\n", uProto, rc));
    1282 
    1283     *puProto = uProto;
    1284     return rc;
    1285 }
    1286 
    12871243/**
    12881244 * Adds a new guest DnD message to the internal message queue.
     
    13521308    GuestDnDMsg Msg;
    13531309    Msg.setType(HOST_DND_CANCEL);
    1354     if (m_DataBase.uProtocolVersion >= 3)
     1310    if (m_pResp->m_uProtocolVersion >= 3)
    13551311        Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    13561312
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r85681 r85739  
    156156    unconst(m_pGuest) = pGuest;
    157157
     158    /* Set the response we're going to use for this object.
     159     *
     160     * At the moment we only have one response total, as we
     161     * don't allow
     162     *      1) parallel transfers (multiple G->H at the same time)
     163     *  nor 2) mixed transfers (G->H + H->G at the same time).
     164     */
     165    m_pResp = GuestDnDInst()->response();
     166    AssertPtrReturn(m_pResp, VERR_INVALID_POINTER);
     167
    158168    /* Confirm a successful initialization when it's the case. */
    159169    autoInitSpan.setSucceeded();
     
    254264    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    255265
    256     return GuestDnDBase::i_getProtocolVersion(aProtocolVersion);
     266    *aProtocolVersion = m_pResp->m_uProtocolVersion;
     267
     268    return S_OK;
    257269#endif /* VBOX_WITH_DRAG_AND_DROP */
    258270}
     
    273285    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    274286
    275     /* Determine guest DnD protocol to use. */
    276     GuestDnDBase::getProtocolVersion(&m_DataBase.uProtocolVersion);
    277 
    278287    /* Default is ignoring the action. */
    279288    if (aDefaultAction)
     
    284293    GuestDnDMsg Msg;
    285294    Msg.setType(HOST_DND_GH_REQ_PENDING);
    286     if (m_DataBase.uProtocolVersion >= 3)
     295    if (m_pResp->m_uProtocolVersion >= 3)
    287296        Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    288297    Msg.appendUInt32(uScreenId);
     
    673682        size_t  cbMetaAnnounced;
    674683
    675         if (m_DataBase.uProtocolVersion < 3)
     684        if (m_pResp->m_uProtocolVersion < 3)
    676685        {
    677686            cbData  = pSndData->u.v1.cbData;
     
    890899
    891900        /* Note: Protocol v1 does not send any file sizes, so always 0. */
    892         if (m_DataBase.uProtocolVersion >= 2)
     901        if (m_pResp->m_uProtocolVersion >= 2)
    893902            rc = DnDTransferObjectSetSize(pObj, cbSize);
    894903
     
    11381147    REGISTER_CALLBACK(GUEST_DND_DISCONNECT);
    11391148    REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1140     if (m_DataBase.uProtocolVersion >= 3)
     1149    if (m_pResp->m_uProtocolVersion >= 3)
    11411150        REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR);
    11421151    REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA);
     
    11491158        GuestDnDMsg Msg;
    11501159        Msg.setType(HOST_DND_GH_EVT_DROPPED);
    1151         if (m_DataBase.uProtocolVersion >= 3)
     1160        if (m_pResp->m_uProtocolVersion >= 3)
    11521161            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    11531162        Msg.appendPointer((void*)pCtx->strFmtRecv.c_str(), (uint32_t)pCtx->strFmtRecv.length() + 1);
     
    11731182    UNREGISTER_CALLBACK(GUEST_DND_DISCONNECT);
    11741183    UNREGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1175     if (m_DataBase.uProtocolVersion >= 3)
     1184    if (m_pResp->m_uProtocolVersion >= 3)
    11761185        UNREGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR);
    11771186    UNREGISTER_CALLBACK(GUEST_DND_GH_SND_DATA);
     
    12511260    REGISTER_CALLBACK(GUEST_DND_DISCONNECT);
    12521261    REGISTER_CALLBACK(GUEST_DND_GH_EVT_ERROR);
    1253     if (m_DataBase.uProtocolVersion >= 3)
     1262    if (m_pResp->m_uProtocolVersion >= 3)
    12541263        REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA_HDR);
    12551264    REGISTER_CALLBACK(GUEST_DND_GH_SND_DATA);
    12561265    REGISTER_CALLBACK(GUEST_DND_GH_SND_DIR);
    1257     if (m_DataBase.uProtocolVersion >= 2)
     1266    if (m_pResp->m_uProtocolVersion >= 2)
    12581267        REGISTER_CALLBACK(GUEST_DND_GH_SND_FILE_HDR);
    12591268    REGISTER_CALLBACK(GUEST_DND_GH_SND_FILE_DATA);
     
    12761285        GuestDnDMsg Msg;
    12771286        Msg.setType(HOST_DND_GH_EVT_DROPPED);
    1278         if (m_DataBase.uProtocolVersion >= 3)
     1287        if (m_pResp->m_uProtocolVersion >= 3)
    12791288            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    12801289        Msg.appendPointer((void*)pCtx->strFmtRecv.c_str(), (uint32_t)pCtx->strFmtRecv.length() + 1);
     
    15721581            AssertReturn(CB_MAGIC_DND_GH_SND_FILE_DATA == pCBData->hdr.uMagic, VERR_INVALID_PARAMETER);
    15731582
    1574             if (pThis->m_DataBase.uProtocolVersion <= 1)
     1583            if (pThis->m_pResp->m_uProtocolVersion <= 1)
    15751584            {
    15761585                /**
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r85681 r85739  
    154154    unconst(m_pGuest) = pGuest;
    155155
     156    /* Set the response we're going to use for this object.
     157     *
     158     * At the moment we only have one response total, as we
     159     * don't allow
     160     *      1) parallel transfers (multiple G->H at the same time)
     161     *  nor 2) mixed transfers (G->H + H->G at the same time).
     162     */
     163    m_pResp = GuestDnDInst()->response();
     164    AssertPtrReturn(m_pResp, VERR_INVALID_POINTER);
     165
    156166    /* Confirm a successful initialization when it's the case. */
    157167    autoInitSpan.setSucceeded();
     
    252262    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    253263
    254     return GuestDnDBase::i_getProtocolVersion(aProtocolVersion);
     264    *aProtocolVersion = m_pResp->m_uProtocolVersion;
     265
     266    return S_OK;
    255267#endif /* VBOX_WITH_DRAG_AND_DROP */
    256268}
     
    279291    AutoCaller autoCaller(this);
    280292    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    281 
    282     /* Determine guest DnD protocol to use. */
    283     GuestDnDBase::getProtocolVersion(&m_DataBase.uProtocolVersion);
    284293
    285294    /* Default action is ignoring. */
     
    324333        GuestDnDMsg Msg;
    325334        Msg.setType(HOST_DND_HG_EVT_ENTER);
    326         if (m_DataBase.uProtocolVersion >= 3)
     335        if (m_pResp->m_uProtocolVersion >= 3)
    327336            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    328337        Msg.appendUInt32(aScreenId);
     
    337346        if (RT_SUCCESS(rc))
    338347        {
    339             GuestDnDResponse *pResp = GuestDnDInst()->response();
    340             if (pResp && RT_SUCCESS(pResp->waitForGuestResponse()))
    341                 resAction = GuestDnD::toMainAction(pResp->getActionDefault());
     348            if (RT_SUCCESS(m_pResp->waitForGuestResponse()))
     349                resAction = GuestDnD::toMainAction(m_pResp->getActionDefault());
    342350        }
    343351    }
     
    402410        GuestDnDMsg Msg;
    403411        Msg.setType(HOST_DND_HG_EVT_MOVE);
    404         if (m_DataBase.uProtocolVersion >= 3)
     412        if (m_pResp->m_uProtocolVersion >= 3)
    405413            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    406414        Msg.appendUInt32(aScreenId);
     
    449457    GuestDnDMsg Msg;
    450458    Msg.setType(HOST_DND_HG_EVT_LEAVE);
    451     if (m_DataBase.uProtocolVersion >= 3)
     459    if (m_pResp->m_uProtocolVersion >= 3)
    452460        Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    453461
     
    525533        GuestDnDMsg Msg;
    526534        Msg.setType(HOST_DND_HG_EVT_DROPPED);
    527         if (m_DataBase.uProtocolVersion >= 3)
     535        if (m_pResp->m_uProtocolVersion >= 3)
    528536            Msg.appendUInt32(0); /** @todo ContextID not used yet. */
    529537        Msg.appendUInt32(aScreenId);
     
    844852    const char   *pcszFmt = pCtx->Meta.strFmt.c_str();
    845853
    846     LogFlowFunc(("uProto=%u, szFmt=%s, cbFmt=%RU32, cbData=%zu\n", m_DataBase.uProtocolVersion, pcszFmt, cbFmt, cbData));
     854    LogFlowFunc(("uProtoVer=%RU32, szFmt=%s, cbFmt=%RU32, cbData=%zu\n", m_pResp->m_uProtocolVersion, pcszFmt, cbFmt, cbData));
    847855
    848856    LogRel2(("DnD: Sending meta data to guest as '%s' (%zu bytes)\n", pcszFmt, cbData));
     
    862870        Msg.setType(HOST_DND_HG_SND_DATA);
    863871
    864         if (m_DataBase.uProtocolVersion < 3)
     872        if (m_pResp->m_uProtocolVersion < 3)
    865873        {
    866874            Msg.appendUInt32(pCtx->uScreenID);                                 /* uScreenId */
     
    910918    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    911919
    912     if (m_DataBase.uProtocolVersion < 3) /* Protocol < v3 did not support this, skip. */
     920    if (m_pResp->m_uProtocolVersion < 3) /* Protocol < v3 did not support this, skip. */
    913921        return VINF_SUCCESS;
    914922
     
    959967
    960968    pMsg->setType(HOST_DND_HG_SND_DIR);
    961     if (m_DataBase.uProtocolVersion >= 3)
     969    if (m_pResp->m_uProtocolVersion >= 3)
    962970        pMsg->appendUInt32(0); /** @todo ContextID not used yet. */
    963971    pMsg->appendString(pcszDstPath);                    /* path */
     
    10061014    if (RT_SUCCESS(rc))
    10071015    {
    1008         if (m_DataBase.uProtocolVersion >= 2)
     1016        if (m_pResp->m_uProtocolVersion >= 2)
    10091017        {
    10101018            if (!(pCtx->Transfer.fObjState & DND_OBJ_STATE_HAS_HDR))
     
    10881096    /* Protocol version 1 sends the file path *every* time with a new file chunk.
    10891097     * In protocol version 2 we only do this once with HOST_DND_HG_SND_FILE_HDR. */
    1090     if (m_DataBase.uProtocolVersion <= 1)
     1098    if (m_pResp->m_uProtocolVersion <= 1)
    10911099    {
    10921100        const size_t cchDstPath = RTStrNLen(pcszDstPath, RTPATH_MAX);
     
    10951103        pMsg->appendUInt32((uint32_t)cchDstPath + 1); /* cbName */
    10961104    }
    1097     else if (m_DataBase.uProtocolVersion >= 2)
     1105    else if (m_pResp->m_uProtocolVersion >= 2)
    10981106    {
    10991107        pMsg->appendUInt32(0);                        /** @todo ContextID not used yet. */
     
    11121120        LogFlowFunc(("cbBufe=%zu, cbRead=%RU32\n", cbBuf, cbRead));
    11131121
    1114         if (m_DataBase.uProtocolVersion <= 1)
     1122        if (m_pResp->m_uProtocolVersion <= 1)
    11151123        {
    11161124            pMsg->appendPointer(pvBuf, cbRead);                            /* pvData */
     
    11231131            pMsg->appendUInt32(cbRead);                                    /* cbData */
    11241132
    1125             if (m_DataBase.uProtocolVersion >= 3)
     1133            if (m_pResp->m_uProtocolVersion >= 3)
    11261134            {
    11271135                /** @todo Calculate checksum. */
     
    14151423    /* Host callbacks. */
    14161424    REGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
    1417     if (m_DataBase.uProtocolVersion >= 2)
     1425    if (m_pResp->m_uProtocolVersion >= 2)
    14181426        REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
    14191427    REGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
     
    14821490         * Send the data header first.
    14831491         */
    1484         if (m_DataBase.uProtocolVersion >= 3)
     1492        if (m_pResp->m_uProtocolVersion >= 3)
    14851493            rc = i_sendMetaDataHeader(pCtx);
    14861494
     
    15101518    /* Host callbacks. */
    15111519    UNREGISTER_CALLBACK(HOST_DND_HG_SND_DIR);
    1512     if (m_DataBase.uProtocolVersion >= 2)
     1520    if (m_pResp->m_uProtocolVersion >= 2)
    15131521        UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_HDR);
    15141522    UNREGISTER_CALLBACK(HOST_DND_HG_SND_FILE_DATA);
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