VirtualBox

Changeset 85021 in vbox


Ignore:
Timestamp:
Jul 1, 2020 11:42:30 AM (4 years ago)
Author:
vboxsync
Message:

DnD/HGCM: A bit of work on the protocol version code; don't use guest properties to figure out what protocol to use and rather ask the host service what it supports instead. This also needs proper feature flags support next.

Location:
trunk/src/VBox
Files:
2 edited

Legend:

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

    r84998 r85021  
    10481048    if (RT_FAILURE(rc))
    10491049        return rc;
    1050 
    1051     /* Set the default protocol version to use. */
     1050    Assert(pCtx->uClientID);
     1051
     1052    /* Set the default protocol version we would like to use. */
    10521053    pCtx->uProtocol = 3;
    1053     Assert(pCtx->uClientID);
    10541054
    10551055    /*
     
    10621062
    10631063    /*
    1064      * Check if the host is >= VBox 5.0 which in case supports GUEST_DND_CONNECT.
     1064     * Try sending the connect message to tell the protocol version to use.
     1065     * Note: This might fail when the Guest Additions run on an older VBox host (< VBox 5.0) which
     1066     *       does not implement this command.
    10651067     */
    1066     bool fSupportsConnectReq = false;
     1068    HGCMMsgConnect Msg;
     1069    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_CONNECT, 2);
     1070    /** @todo Context ID not used yet. */
     1071    Msg.u.v3.uContext.SetUInt32(0);
     1072    Msg.u.v3.uProtocol.SetUInt32(pCtx->uProtocol);
     1073    Msg.u.v3.uFlags.SetUInt32(0); /* Unused at the moment. */
     1074
     1075    rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
    10671076    if (RT_SUCCESS(rc))
    10681077    {
    1069         /* The guest property service might not be available. Not fatal. */
    1070         uint32_t uGuestPropSvcClientID;
    1071         rc2 = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
    1072         if (RT_SUCCESS(rc2))
    1073         {
    1074             char *pszHostVersion;
    1075             rc2 = VbglR3GuestPropReadValueAlloc(uGuestPropSvcClientID, "/VirtualBox/HostInfo/VBoxVer", &pszHostVersion);
    1076             if (RT_SUCCESS(rc2))
    1077             {
    1078                 fSupportsConnectReq = RTStrVersionCompare(pszHostVersion, "5.0") >= 0;
    1079                 LogFlowFunc(("pszHostVersion=%s, fSupportsConnectReq=%RTbool\n", pszHostVersion, fSupportsConnectReq));
    1080                 VbglR3GuestPropReadValueFree(pszHostVersion);
    1081             }
    1082 
    1083             VbglR3GuestPropDisconnect(uGuestPropSvcClientID);
    1084         }
    1085 
    1086         if (RT_FAILURE(rc2))
    1087             LogFlowFunc(("Retrieving host version failed with rc=%Rrc\n", rc2));
    1088     }
    1089 
    1090     if (fSupportsConnectReq)
    1091     {
    1092         /*
    1093          * Try sending the connect message to tell the protocol version to use.
    1094          * Note: This might fail when the Guest Additions run on an older VBox host (< VBox 5.0) which
    1095          *       does not implement this command.
    1096          */
    1097         HGCMMsgConnect Msg;
    1098         VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_CONNECT, 3);
    1099         /** @todo Context ID not used yet. */
    1100         Msg.u.v3.uContext.SetUInt32(0);
    1101         Msg.u.v3.uProtocol.SetUInt32(pCtx->uProtocol);
    1102         Msg.u.v3.uFlags.SetUInt32(0); /* Unused at the moment. */
    1103 
    1104         rc2 = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));
    1105         if (RT_FAILURE(rc2))
    1106             fSupportsConnectReq = false;
    1107 
    1108         LogFlowFunc(("Connection request ended with rc=%Rrc\n", rc2));
    1109     }
    1110 
    1111     if (fSupportsConnectReq)
    1112     {
     1078        /* Set the protocol version we're going to use as told by the host. */
     1079        rc = Msg.u.v3.uProtocol.GetUInt32(&pCtx->uProtocol); AssertRC(rc);
     1080
    11131081        pCtx->cbMaxChunkSize = _64K; /** @todo Use a scratch buffer on the heap? */
    11141082    }
    1115     else /* GUEST_DND_CONNECT not supported; the user needs to upgrade the host. */
    1116         rc = VERR_NOT_SUPPORTED;
     1083    else
     1084        pCtx->uProtocol = 0; /*  We're using protocol v0 (initial draft) as a fallback. */
     1085
     1086    /** @todo Implement protocol feature flags. */
    11171087
    11181088    LogFlowFunc(("uClient=%RU32, uProtocol=%RU32, rc=%Rrc\n", pCtx->uClientID, pCtx->uProtocol, rc));
  • trunk/src/VBox/HostServices/DragAndDrop/VBoxDragAndDropSvc.cpp

    r82968 r85021  
    489489                        rc = HGCMSvcGetU32(&paParms[idxProto + 1], &data.uFlags);
    490490                    if (RT_SUCCESS(rc))
     491                    {
     492                        unsigned uProtocolVer = 3; /* The protocol version we're going to use. */
     493
     494                        /* Make sure we're only setting a protocl version we're supporting on the host. */
     495                        if (data.uProtocol > uProtocolVer)
     496                            data.uProtocol = uProtocolVer;
     497
    491498                        pClient->SetProtocolVer(data.uProtocol);
    492                     if (RT_SUCCESS(rc))
    493                     {
     499
     500                        /* Return the highest protocol version we're supporting. */
     501                        paParms[idxProto].u.uint32 = data.uProtocol;
     502
    494503                        LogFlowFunc(("Client %RU32 is now using protocol v%RU32\n", pClient->GetClientID(), pClient->GetProtocolVer()));
    495504                        DO_HOST_CALLBACK();
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