VirtualBox

Ignore:
Timestamp:
Aug 12, 2020 12:24:30 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139856
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/HostServices/DragAndDrop/VBoxDragAndDropSvc.cpp

    r85681 r85712  
    5050{
    5151public:
     52
    5253    DragAndDropClient(uint32_t idClient)
    5354        : HGCM::Client(idClient)
     55        , fGuestFeatures0(VBOX_DND_GF_NONE)
     56        , fGuestFeatures1(VBOX_DND_GF_NONE)
    5457    {
    5558        RT_ZERO(m_SvcCtx);
     
    6265
    6366public:
     67
    6468    void disconnect(void) RT_NOEXCEPT;
     69
     70public:
     71
     72    /** Guest feature flags, VBOX_DND_GF_0_XXX. */
     73    uint64_t                fGuestFeatures0;
     74    /** Guest feature flags, VBOX_DND_GF_1_XXX. */
     75    uint64_t                fGuestFeatures1;
    6576};
    6677
     
    8899    int  clientConnect(uint32_t idClient, void *pvClient) RT_NOEXCEPT RT_OVERRIDE;
    89100    int  clientDisconnect(uint32_t idClient, void *pvClient) RT_NOEXCEPT RT_OVERRIDE;
     101    int  clientQueryFeatures(DragAndDropClient *pClient, VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) RT_NOEXCEPT;
     102    int  clientReportFeatures(DragAndDropClient *pClient, VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) RT_NOEXCEPT;
    90103    void guestCall(VBOXHGCMCALLHANDLE callHandle, uint32_t idClient, void *pvClient, uint32_t u32Function,
    91104                   uint32_t cParms, VBOXHGCMSVCPARM paParms[]) RT_NOEXCEPT RT_OVERRIDE;
     
    112125    /** Current drag and drop mode, VBOX_DRAG_AND_DROP_MODE_XXX. */
    113126    uint32_t                           m_u32Mode;
     127    /** Host feature mask (VBOX_DND_HF_0_XXX) for DND_GUEST_REPORT_FEATURES
     128     * and DND_GUEST_QUERY_FEATURES. */
     129    uint64_t                           m_fHostFeatures0;
    114130};
    115131
     
    166182    modeSet(VBOX_DRAG_AND_DROP_MODE_OFF);
    167183
     184    /* Set host features. */
     185    m_fHostFeatures0 = VBOX_DND_HF_NONE;
     186
    168187    int rc = VINF_SUCCESS;
    169188
     
    274293}
    275294
     295/**
     296 * Implements GUEST_DND_REPORT_FEATURES.
     297 *
     298 * @returns VBox status code.
     299 * @retval  VINF_HGCM_ASYNC_EXECUTE on success (we complete the message here).
     300 * @retval  VERR_ACCESS_DENIED if not master
     301 * @retval  VERR_INVALID_PARAMETER if bit 63 in the 2nd parameter isn't set.
     302 * @retval  VERR_WRONG_PARAMETER_COUNT
     303 *
     304 * @param   pClient     The client state.
     305 * @param   hCall       The client's call handle.
     306 * @param   cParms      Number of parameters.
     307 * @param   paParms     Array of parameters.
     308 */
     309int DragAndDropService::clientReportFeatures(DragAndDropClient *pClient,
     310                                             VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) RT_NOEXCEPT
     311{
     312    /*
     313     * Validate the request.
     314     */
     315    ASSERT_GUEST_RETURN(cParms == 2, VERR_WRONG_PARAMETER_COUNT);
     316    ASSERT_GUEST_RETURN(paParms[0].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_WRONG_PARAMETER_TYPE);
     317    uint64_t const fFeatures0 = paParms[0].u.uint64;
     318    ASSERT_GUEST_RETURN(paParms[1].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_WRONG_PARAMETER_TYPE);
     319    uint64_t const fFeatures1 = paParms[1].u.uint64;
     320    ASSERT_GUEST_RETURN(fFeatures1 & VBOX_DND_GF_1_MUST_BE_ONE, VERR_INVALID_PARAMETER);
     321
     322    /*
     323     * Do the work.
     324     */
     325    paParms[0].u.uint64 = m_fHostFeatures0;
     326    paParms[1].u.uint64 = 0;
     327
     328    int rc = pClient->Complete(hCall, VINF_SUCCESS);
     329    if (RT_SUCCESS(rc))
     330    {
     331        pClient->fGuestFeatures0 = fFeatures0;
     332        pClient->fGuestFeatures1 = fFeatures1;
     333        Log(("[Client %RU32] features: %#RX64 %#RX64\n", pClient->GetClientID(), fFeatures0, fFeatures1));
     334    }
     335    else
     336        LogFunc(("pfnCallComplete -> %Rrc\n", rc));
     337
     338    return VINF_HGCM_ASYNC_EXECUTE;
     339}
     340
     341/**
     342 * Implements GUEST_DND_QUERY_FEATURES.
     343 *
     344 * @returns VBox status code.
     345 * @retval  VINF_HGCM_ASYNC_EXECUTE on success (we complete the message here).
     346 * @retval  VERR_WRONG_PARAMETER_COUNT
     347 *
     348 * @param   pClient     The client state.
     349 * @param   hCall       The client's call handle.
     350 * @param   cParms      Number of parameters.
     351 * @param   paParms     Array of parameters.
     352 */
     353int DragAndDropService::clientQueryFeatures(DragAndDropClient *pClient,
     354                                            VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) RT_NOEXCEPT
     355{
     356    /*
     357     * Validate the request.
     358     */
     359    ASSERT_GUEST_RETURN(cParms == 2, VERR_WRONG_PARAMETER_COUNT);
     360    ASSERT_GUEST_RETURN(paParms[0].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_WRONG_PARAMETER_TYPE);
     361    ASSERT_GUEST_RETURN(paParms[1].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_WRONG_PARAMETER_TYPE);
     362    ASSERT_GUEST(paParms[1].u.uint64 & RT_BIT_64(63));
     363
     364    /*
     365     * Do the work.
     366     */
     367    paParms[0].u.uint64 = m_fHostFeatures0;
     368    paParms[1].u.uint64 = 0;
     369
     370    int rc = pClient->Complete(hCall, VINF_SUCCESS);
     371    if (RT_FAILURE(rc))
     372        LogFunc(("pfnCallComplete -> %Rrc\n", rc));
     373
     374    return VINF_HGCM_ASYNC_EXECUTE;
     375}
     376
    276377int DragAndDropService::modeSet(uint32_t u32Mode) RT_NOEXCEPT
    277378{
     
    327428        /* New since protocol v2. */
    328429        case GUEST_DND_CONNECT:
     430            RT_FALL_THROUGH();
     431        /* New since VBox 6.1.x. */
     432        case GUEST_DND_REPORT_FEATURES:
     433            RT_FALL_THROUGH();
     434        /* New since VBox 6.1.x. */
     435        case GUEST_DND_QUERY_FEATURES:
    329436        {
    330437            /*
    331              * Never block the initial connect call, as the clients do this when
     438             * Never block these calls, as the clients issues those when
    332439             * initializing and might get stuck if drag and drop is set to "disabled" at
    333440             * that time.
     
    524631                break;
    525632            }
     633            case GUEST_DND_REPORT_FEATURES:
     634            {
     635                LogFlowFunc(("GUEST_DND_REPORT_FEATURES\n"));
     636                rc = clientReportFeatures(pClient, callHandle, cParms, paParms);
     637                break;
     638            }
     639            case GUEST_DND_QUERY_FEATURES:
     640            {
     641                LogFlowFunc(("GUEST_DND_QUERY_FEATURES"));
     642                rc = clientQueryFeatures(pClient, callHandle, cParms, paParms);
     643                break;
     644            }
    526645            case GUEST_DND_HG_ACK_OP:
    527646            {
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