VirtualBox

Ignore:
Timestamp:
Aug 12, 2020 12:24:30 PM (4 years ago)
Author:
vboxsync
Message:

DnD: Added wire protocol support for querying and reporting guest / host features in host service and VbglR3. Untested.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDragAndDrop.cpp

    r85587 r85712  
    685685    AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER);
    686686
    687     Assert(pCtx->uProtocol >= 3); /* Only for protocol v3 and up. */
     687    Assert(pCtx->uProtocolDeprecated >= 3); /* Only for protocol v3 and up. */
    688688
    689689    HGCMMsgHGSendDataHdr Msg;
     
    10121012    Assert(pCtx->uClientID);
    10131013
    1014     /* Set the default protocol version we would like to use. */
    1015     pCtx->uProtocol = 3;
     1014    /* Set the default protocol version we would like to use.
     1015     * Deprecated since VBox 6.1.x, but let this set to 3 to (hopefully) not break things. */
     1016    pCtx->uProtocolDeprecated = 3;
     1017
     1018    pCtx->fHostFeatures  = VBOX_DND_HF_NONE;
     1019    pCtx->fGuestFeatures = VBOX_DND_GF_NONE;
    10161020
    10171021    /*
     
    10301034    HGCMMsgConnect Msg;
    10311035    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_CONNECT, 3);
    1032     /** @todo Context ID not used yet. */
    1033     Msg.u.v3.uContext.SetUInt32(0);
    1034     Msg.u.v3.uProtocol.SetUInt32(pCtx->uProtocol);
    1035     Msg.u.v3.uFlags.SetUInt32(0); /* Unused at the moment. */
     1036    Msg.u.v3.uContext.SetUInt32(0);                /** @todo Context ID not used yet. */
     1037    Msg.u.v3.uProtocol.SetUInt32(pCtx->uProtocolDeprecated); /* Deprecated since VBox 6.1.x. */
     1038    Msg.u.v3.uFlags.SetUInt32(0);                  /* Unused at the moment. */
    10361039
    10371040    rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
     
    10391042    {
    10401043        /* Set the protocol version we're going to use as told by the host. */
    1041         rc = Msg.u.v3.uProtocol.GetUInt32(&pCtx->uProtocol); AssertRC(rc);
     1044        rc = Msg.u.v3.uProtocol.GetUInt32(&pCtx->uProtocolDeprecated); AssertRC(rc);
     1045
     1046        /*
     1047         * Next is reporting our features.  If this fails, assume older host.
     1048         */
     1049        rc2 = VbglR3DnDReportFeatures(pCtx->uClientID, pCtx->fGuestFeatures, &pCtx->fHostFeatures);
     1050        if (RT_SUCCESS(rc2))
     1051        {
     1052            LogRel2(("DnD: Guest features: %#RX64 - Host features: %#RX64\n",
     1053                     pCtx->fGuestFeatures, pCtx->fHostFeatures));
     1054        }
     1055        else /* Failing here is not fatal; might be running with an older host. */
     1056        {
     1057            AssertLogRelMsg(rc2 == VERR_NOT_SUPPORTED || rc2 == VERR_NOT_IMPLEMENTED,
     1058                            ("Reporting features failed: %Rrc\n", rc2));
     1059        }
    10421060
    10431061        pCtx->cbMaxChunkSize = DND_DEFAULT_CHUNK_SIZE; /** @todo Use a scratch buffer on the heap? */
    10441062    }
    10451063    else
    1046         pCtx->uProtocol = 0; /*  We're using protocol v0 (initial draft) as a fallback. */
    1047 
    1048     /** @todo Implement protocol feature flags. */
    1049 
    1050     LogFlowFunc(("uClient=%RU32, uProtocol=%RU32, rc=%Rrc\n", pCtx->uClientID, pCtx->uProtocol, rc));
     1064        pCtx->uProtocolDeprecated = 0; /*  We're using protocol v0 (initial draft) as a fallback. */
     1065
     1066    LogFlowFunc(("uClient=%RU32, uProtocol=%RU32, rc=%Rrc\n", pCtx->uClientID, pCtx->uProtocolDeprecated, rc));
    10511067    return rc;
    10521068}
     
    10661082        pCtx->uClientID = 0;
    10671083    return rc;
     1084}
     1085
     1086/**
     1087 * Reports features to the host and retrieve host feature set.
     1088 *
     1089 * @returns VBox status code.
     1090 * @param   idClient        The client ID returned by VbglR3DnDConnect().
     1091 * @param   fGuestFeatures  Features to report, VBOX_DND_GF_XXX.
     1092 * @param   pfHostFeatures  Where to store the features VBOX_DND_HF_XXX.
     1093 */
     1094VBGLR3DECL(int) VbglR3DnDReportFeatures(uint32_t idClient, uint64_t fGuestFeatures, uint64_t *pfHostFeatures)
     1095{
     1096    int rc;
     1097    do
     1098    {
     1099        struct
     1100        {
     1101            VBGLIOCHGCMCALL         Hdr;
     1102            HGCMFunctionParameter   f64Features0;
     1103            HGCMFunctionParameter   f64Features1;
     1104        } Msg;
     1105        VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, GUEST_DND_REPORT_FEATURES, 2);
     1106        VbglHGCMParmUInt64Set(&Msg.f64Features0, fGuestFeatures);
     1107        VbglHGCMParmUInt64Set(&Msg.f64Features1, VBOX_DND_GF_1_MUST_BE_ONE);
     1108
     1109        rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg));
     1110        if (RT_SUCCESS(rc))
     1111        {
     1112            Assert(Msg.f64Features0.type == VMMDevHGCMParmType_64bit);
     1113            Assert(Msg.f64Features1.type == VMMDevHGCMParmType_64bit);
     1114            if (Msg.f64Features1.u.value64 & VBOX_DND_GF_1_MUST_BE_ONE)
     1115                rc = VERR_NOT_SUPPORTED;
     1116            else if (pfHostFeatures)
     1117                *pfHostFeatures = Msg.f64Features0.u.value64;
     1118            break;
     1119        }
     1120    } while (rc == VERR_INTERRUPTED);
     1121    return rc;
     1122
    10681123}
    10691124
Note: See TracChangeset for help on using the changeset viewer.

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