VirtualBox

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


Ignore:
Timestamp:
Jul 19, 2023 4:06:24 PM (17 months ago)
Author:
vboxsync
Message:

Shared Clipboard/VRDE: Integrated the logic of ShClSvcIsBackendActive() in ShClSvcReportFormats(), so that the specific backends don't need to be in charge for that anymore. Renamed VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE -> VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST to emphasize its usage. Added VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_GUEST; see comment for details.

The whole concept of VRDE being a (one and only) service extension nowadays isn't optimal anymore and needs to be replaced with a more generic mechanism, which is out of this scope for this task. So just adapt this as needed and keep the current way.

bugref:9437

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp

    r100646 r100655  
    9494                                       &fFormats, &fChanged);
    9595    if (   RT_SUCCESS(rc)
    96         && fChanged
    97         && ShClSvcIsBackendActive())
     96        && fChanged)
    9897        rc = ShClSvcReportFormats(pCtx->pClient, fFormats);
    9998
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r100646 r100655  
    319319bool ShClSvcLock(void);
    320320void ShClSvcUnlock(void);
    321 
    322 /**
    323  * Checks if the backend is active (@c true), or if VRDE is in control of
    324  * the host side.
    325  */
    326 DECLINLINE(bool) ShClSvcIsBackendActive(void)
    327 {
    328     return g_ExtState.pfnExtension == NULL;
    329 }
    330321/** @} */
    331322
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r100646 r100655  
    789789        SHCLFORMATS fFormats = 0;
    790790        rc = SharedClipboardWinGetFormats(&pCtx->Win, &fFormats);
    791         if (   RT_SUCCESS(rc)
    792             && fFormats != VBOX_SHCL_FMT_NONE /** @todo r=bird: BUGBUG: revisit this. */
    793             && ShClSvcIsBackendActive())
     791        if (RT_SUCCESS(rc))
    794792            rc = ShClSvcReportFormats(pCtx->pClient, fFormats);
    795793    }
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r100646 r100655  
    220220     * there is data in the host clipboard it will automatically be sent to
    221221     * the guest when the clipboard starts up. */
    222     if (ShClSvcIsBackendActive())
    223         return ShClSvcReportFormats(pClient, VBOX_SHCL_FMT_NONE);
    224     return VINF_SUCCESS;
     222    return ShClSvcReportFormats(pClient, VBOX_SHCL_FMT_NONE);
    225223}
    226224
     
    369367    AssertPtr(pClient);
    370368
    371     rc = RTCritSectEnter(&pClient->CritSect);
    372     if (RT_SUCCESS(rc))
    373     {
    374         if (ShClSvcIsBackendActive())
    375         {
    376             /** @todo r=bird: BUGBUG: Revisit this   */
    377             if (fFormats != VBOX_SHCL_FMT_NONE) /* No formats to report? */
    378             {
    379                 rc = ShClSvcReportFormats(pCtx->pClient, fFormats);
    380             }
    381         }
    382 
    383         RTCritSectLeave(&pClient->CritSect);
    384     }
     369    rc = ShClSvcReportFormats(pCtx->pClient, fFormats);
    385370
    386371    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r100646 r100655  
    14731473 * Reports clipboard formats to the guest.
    14741474 *
    1475  * @note    Host backend callers must check if it's active (use
    1476  *          ShClSvcIsBackendActive) before calling to prevent mixing up the
    1477  *          VRDE clipboard.
    1478  *
    14791475 * @returns VBox status code.
    14801476 * @param   pClient             Client to report clipboard formats to.
    1481  * @param   fFormats            The formats to report (VBOX_SHCL_FMT_XXX), zero
    1482  *                              is okay (empty the clipboard).
    1483  *
     1477 * @param   fFormats            The formats to report (VBOX_SHCL_FMT_XXX).
     1478 *                              VBOX_SHCL_FMT_NONE will empty (clear) the clipboard.
    14841479 * @thread  Backend thread.
    14851480 */
    14861481int ShClSvcReportFormats(PSHCLCLIENT pClient, SHCLFORMATS fFormats)
    14871482{
    1488     LogFlowFuncEnter();
     1483    AssertPtrReturn(pClient, VERR_INVALID_POINTER);
     1484
     1485    LogFlowFunc(("fFormats=%#x\n", fFormats));
    14891486
    14901487    /*
     
    15011498        return VINF_SUCCESS;
    15021499
    1503     AssertPtrReturn(pClient, VERR_INVALID_POINTER);
    1504 
    1505     LogFlowFunc(("fFormats=%#x\n", fFormats));
    1506 
    15071500#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    15081501    bool fSkipTransfers = false;
     
    15291522#endif
    15301523
     1524    int rc;
     1525
     1526    /*
     1527     * Check if the HGCM callback can handle this first.
     1528     * This is needed in order to not mess up the clipboard if VRDE is active, for example.
     1529     */
     1530    if (g_ExtState.pfnExtension) /* Extension set? */
     1531    {
     1532        SHCLEXTPARMS parms;
     1533        RT_ZERO(parms);
     1534
     1535        parms.u.ReportFormats.uFormats = fFormats;
     1536
     1537        rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_GUEST, &parms, sizeof(parms));
     1538        if (rc == VERR_NOT_SUPPORTED)
     1539        {
     1540            /* Not handled by the extension, continue below. */
     1541        }
     1542        else /* Handled by the extension, bail out. */
     1543            return rc;
     1544    }
     1545
    15311546    /*
    15321547     * Allocate a message, populate parameters and post it to the client.
    15331548     */
    1534     int rc;
    15351549    PSHCLCLIENTMSG pMsg = shClSvcMsgAlloc(pClient, VBOX_SHCL_HOST_MSG_FORMATS_REPORT, 2);
    15361550    if (pMsg)
     
    15391553        HGCMSvcSetU32(&pMsg->aParms[1], fFormats);
    15401554
    1541         RTCritSectEnter(&pClient->CritSect);
     1555        shClSvcClientLock(pClient);
     1556
    15421557        rc = shClSvcMsgAddAndWakeupClient(pClient, pMsg);
    1543         RTCritSectLeave(&pClient->CritSect);
     1558
     1559        shClSvcClientUnlock(pClient);
    15441560    }
    15451561    else
     
    16201636                parms.u.ReportFormats.uFormats = fFormats;
    16211637
    1622                 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, &parms, sizeof(parms));
     1638                rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST, &parms, sizeof(parms));
    16231639            }
    16241640            else
     
    27302746        switch (u32Function)
    27312747        {
    2732             /* The service extension announces formats to the guest. */
    2733             case VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE:
     2748            /* The service extension announces formats to the host. */
     2749            case VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST:
    27342750            {
    2735                 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE: g_ExtState.fReadingData=%RTbool\n", g_ExtState.fReadingData));
     2751                LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_FORMAT_REPORT_TO_HOST: g_ExtState.fReadingData=%RTbool\n", g_ExtState.fReadingData));
    27362752                if (!g_ExtState.fReadingData)
    27372753                    rc = ShClSvcReportFormats(pClient, u32Format);
     
    27752791            }
    27762792
    2777             /** @todo BUGBUG Why no VBOX_CLIPBOARD_EXT_FN_DATA_WRITE here? */
    2778 
    27792793            default:
    27802794                /* Just skip other messages. */
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