VirtualBox

Changeset 81559 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Oct 28, 2019 10:09:35 AM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard: Got rid of the protocol version in VBOX_SHCL_GUEST_FN_CONNECT and internals; instead use the get / query features bit field.

Location:
trunk/src/VBox/HostServices/SharedClipboard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r81451 r81559  
    8888    /** The client's session ID. */
    8989    SHCLSESSIONID           uSessionID;
    90     /** Optional protocol version the client uses. Set to 0 by default. */
    91     uint32_t                uProtocolVer;
    9290    /** Guest feature flags, VBOX_SHCL_GF_0_XXX. */
    9391    uint64_t                fGuestFeatures0;
     
    9694    /** Maximum chunk size to use for data transfers. Set to _64K by default. */
    9795    uint32_t                cbChunkSize;
     96    /** Where the transfer sources its data from. */
    9897    SHCLSOURCE              enmSource;
    9998    /** The client's transfers state. */
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r81460 r81559  
    422422 * Sets the VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD return parameters.
    423423 *
    424  * This function does the necessary translation between the legacy protocol (v0) and the new protocols (>= v1),
     424 * This function does the necessary translation between the legacy protocol (<= VBox 6.0) and the new protocols (>= VBox 6.1),
    425425 * as messages are always stored as >= v1 messages in the message queue.
    426426 *
     
    11131113
    11141114    SHCLEVENTID uEvent;
    1115     if (pClient->State.uProtocolVer == 0)
    1116     {
    1117         /* Protocol v0 did not have any context ID handling, so we ASSUME that the last event registered
     1115    if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy */
     1116    {
     1117        /* Older Guest Additions (<= VBox 6.0) did not have any context ID handling, so we ASSUME that the last event registered
    11181118         * is the one we want to handle (as this all was a synchronous protocol anyway). */
    11191119        uEvent = ShClEventGetLast(&pClient->Events);
     
    12041204    RT_ZERO(cmdCtx);
    12051205
    1206     if (pClient->State.uProtocolVer == 0) /* Legacy protocol */
     1206    if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy */
    12071207    {
    12081208        if (cParms < 2)
     
    14311431    AssertPtr(pClient);
    14321432
    1433     LogFunc(("u32ClientID=%RU32 (proto %RU32), fn=%RU32 (%s), cParms=%RU32, paParms=%p\n",
    1434              u32ClientID, pClient->State.uProtocolVer, u32Function, ShClGuestMsgToStr(u32Function), cParms, paParms));
     1433    LogFunc(("u32ClientID=%RU32, fn=%RU32 (%s), cParms=%RU32, paParms=%p\n",
     1434             u32ClientID, u32Function, ShClGuestMsgToStr(u32Function), cParms, paParms));
    14351435
    14361436#ifdef DEBUG
     
    14581458                rc = VERR_INVALID_PARAMETER;
    14591459            }
    1460             else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT  /* uProtocolVer */
    1461                      || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT  /* uProtocolFlags */
    1462                      || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT  /* cbChunkSize */
    1463                      || paParms[3].type != VBOX_HGCM_SVC_PARM_32BIT  /* enmCompression */
    1464                      || paParms[4].type != VBOX_HGCM_SVC_PARM_32BIT) /* enmChecksumType */
     1460            else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT  /* cbChunkSize */
     1461                     || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT  /* enmCompression */
     1462                     || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT) /* enmChecksumType */
    14651463            {
    14661464                rc = VERR_INVALID_PARAMETER;
     
    14721470            else
    14731471            {
    1474                 /* Update the protocol version and tell the guest. */
    1475                 pClient->State.uProtocolVer = 1;
    1476 
    1477                 LogFlowFunc(("Now using protocol v%RU32\n", pClient->State.uProtocolVer));
    1478 
    1479                 HGCMSvcSetU32(&paParms[0], pClient->State.uProtocolVer);
    1480                 HGCMSvcSetU32(&paParms[1], 0 /* Procotol flags, not used yet */);
    1481                 HGCMSvcSetU32(&paParms[2], pClient->State.cbChunkSize);
    1482                 HGCMSvcSetU32(&paParms[3], 0 /* Compression type, not used yet */);
    1483                 HGCMSvcSetU32(&paParms[4], 0 /* Checksum type, not used yet */);
     1472                /* Report back supported chunk size to the guest. */
     1473                HGCMSvcSetU32(&paParms[0], _64K); /* Chunk size */ /** @todo Make chunk size dynamic. */
    14841474
    14851475                rc = VINF_SUCCESS;
     
    15231513            uint32_t uFormats = 0;
    15241514
    1525             if (pClient->State.uProtocolVer == 0)
     1515            if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy */
    15261516            {
    15271517                if (cParms != 1)
     
    17991789    LogFlowFuncEnter();
    18001790
    1801     pClientState->uProtocolVer    = 0;
    18021791    pClientState->fGuestFeatures0 = VBOX_SHCL_GF_NONE;
    18031792    pClientState->fGuestFeatures1 = VBOX_SHCL_GF_NONE;
     
    19001889static SSMFIELD const s_aShClSSMClientState[] =
    19011890{
    1902     SSMFIELD_ENTRY(SHCLCLIENTSTATE, uProtocolVer),
    1903     SSMFIELD_ENTRY(SHCLCLIENTSTATE, cbChunkSize),
    1904     SSMFIELD_ENTRY(SHCLCLIENTSTATE, enmSource),
     1891    /** Note: Saving the session ID not necessary, as they're not persistent across state save/restore. */
     1892    SSMFIELD_ENTRY    (SHCLCLIENTSTATE, fGuestFeatures0),
     1893    SSMFIELD_ENTRY    (SHCLCLIENTSTATE, fGuestFeatures1),
     1894    SSMFIELD_ENTRY    (SHCLCLIENTSTATE, cbChunkSize),
     1895    SSMFIELD_ENTRY    (SHCLCLIENTSTATE, enmSource),
    19051896    SSMFIELD_ENTRY_TERM()
    19061897};
     
    19091900 * SSM descriptor table for the SHCLCLIENTURISTATE structure.
    19101901 */
    1911 static SSMFIELD const s_aShClSSMClientURIState[] =
     1902static SSMFIELD const s_aShClSSMClientTransferState[] =
    19121903{
    19131904    SSMFIELD_ENTRY(SHCLCLIENTTRANSFERSTATE, enmTransferDir),
     
    19381929static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
    19391930{
    1940     RT_NOREF(u32ClientID);
     1931    LogFlowFuncEnter();
    19411932
    19421933#ifndef UNIT_TEST
     
    19471938     * Pending requests, if any, will be completed in svcDisconnect.
    19481939     */
     1940    RT_NOREF(u32ClientID);
    19491941    LogFunc(("u32ClientID=%RU32\n", u32ClientID));
    19501942
     
    19581950    AssertRCReturn(rc, rc);
    19591951
    1960     rc = SSMR3PutStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientURIState[0], NULL);
     1952    rc = SSMR3PutStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientTransferState[0], NULL);
    19611953    AssertRCReturn(rc, rc);
    19621954
     
    20262018static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
    20272019{
     2020    LogFlowFuncEnter();
     2021
    20282022#ifndef UNIT_TEST
     2023
    20292024    RT_NOREF(u32ClientID, uVersion);
    2030 
    2031     LogFunc(("u32ClientID=%RU32\n", u32ClientID));
    20322025
    20332026    PSHCLCLIENT pClient = (PSHCLCLIENT)pvClient;
     
    20382031    int rc = SSMR3GetU32(pSSM, &lenOrVer);
    20392032    AssertRCReturn(rc, rc);
     2033
     2034    LogFunc(("u32ClientID=%RU32, lenOrVer=%#RX64\n", u32ClientID, lenOrVer));
     2035
    20402036    if (lenOrVer == VBOX_SHCL_SSM_VER_0)
    20412037    {
     
    20442040    else if (lenOrVer == VBOX_SHCL_SSM_VER_1)
    20452041    {
    2046         rc = SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /*fFlags*/, &s_aShClSSMClientState[0], NULL);
     2042        rc = SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */,
     2043                              &s_aShClSSMClientState[0], NULL);
    20472044        AssertRCReturn(rc, rc);
    20482045
    2049         rc = SSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientURIState[0], NULL);
     2046        rc = SSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /* fFlags */,
     2047                              &s_aShClSSMClientTransferState[0], NULL);
    20502048        AssertRCReturn(rc, rc);
    20512049
     
    21922190    int rc = VINF_SUCCESS;
    21932191
    2194     LogFlowFunc(("ptable=%p\n", pTable));
    2195 
    2196     if (!pTable)
     2192    LogFlowFunc(("pTable=%p\n", pTable));
     2193
     2194    if (!VALID_PTR(pTable))
    21972195    {
    21982196        rc = VERR_INVALID_PARAMETER;
     
    22002198    else
    22012199    {
    2202         LogFunc(("ptable->cbSize = %d, ptable->u32Version = 0x%08X\n", pTable->cbSize, pTable->u32Version));
     2200        LogFunc(("pTable->cbSize = %d, ptable->u32Version = 0x%08X\n", pTable->cbSize, pTable->u32Version));
    22032201
    22042202        if (   pTable->cbSize     != sizeof (VBOXHGCMSVCFNTABLE)
    22052203            || pTable->u32Version != VBOX_HGCM_SVC_VERSION)
    22062204        {
    2207             rc = VERR_INVALID_PARAMETER;
     2205            rc = VERR_VERSION_MISMATCH;
    22082206        }
    22092207        else
     
    22132211            pTable->cbClient = sizeof(SHCLCLIENT);
    22142212
    2215             pTable->pfnUnload     = svcUnload;
    2216             pTable->pfnConnect    = svcConnect;
    2217             pTable->pfnDisconnect = svcDisconnect;
    2218             pTable->pfnCall       = svcCall;
    2219             pTable->pfnHostCall   = svcHostCall;
    2220             pTable->pfnSaveState  = svcSaveState;
    2221             pTable->pfnLoadState  = svcLoadState;
    2222             pTable->pfnRegisterExtension  = svcRegisterExtension;
    2223             pTable->pfnNotify     = NULL;
    2224             pTable->pvService     = NULL;
     2213            pTable->pfnUnload            = svcUnload;
     2214            pTable->pfnConnect           = svcConnect;
     2215            pTable->pfnDisconnect        = svcDisconnect;
     2216            pTable->pfnCall              = svcCall;
     2217            pTable->pfnHostCall          = svcHostCall;
     2218            pTable->pfnSaveState         = svcSaveState;
     2219            pTable->pfnLoadState         = svcLoadState;
     2220            pTable->pfnRegisterExtension = svcRegisterExtension;
     2221            pTable->pfnNotify            = NULL;
     2222            pTable->pvService            = NULL;
    22252223
    22262224            /* Service specific initialization. */
     
    22292227    }
    22302228
     2229    LogFlowFunc(("Returning %Rrc\n", rc));
    22312230    return rc;
    22322231}
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