VirtualBox

Changeset 83624 in vbox for trunk


Ignore:
Timestamp:
Apr 8, 2020 4:29:25 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137054
Message:

SharedClipboard: Eliminated SHCLFORMATDATA and did some minor darwin cleanups. bugref:9620

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard-win.h

    r82968 r83624  
    135135
    136136SHCLFORMAT SharedClipboardWinClipboardFormatToVBox(UINT uFormat);
    137 int SharedClipboardWinGetFormats(PSHCLWINCTX pCtx, PSHCLFORMATDATA pFormats);
     137int SharedClipboardWinGetFormats(PSHCLWINCTX pCtx, PSHCLFORMATS pfFormats);
    138138
    139139#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
  • trunk/include/VBox/GuestHost/SharedClipboard.h

    r82880 r83624  
    7676/** Pointer to a shared clipboard data request. */
    7777typedef SHCLDATAREQ *PSHCLDATAREQ;
    78 
    79 /**
    80  * Shared Clipboard formats specification.
    81  * @todo r=bird: Pointless as we don't have any fFlags defined, so, unless
    82  *       someone can give me a plausible scenario where we will need flags here,
    83  *       this structure will be eliminated.
    84  */
    85 typedef struct SHCLFORMATDATA
    86 {
    87     /** Available format(s) as bit map. */
    88     SHCLFORMATS Formats;
    89     /** Formats flags. Currently unused. */
    90     uint32_t    fFlags;
    91 } SHCLFORMATDATA;
    92 /** Pointer to a shared clipboard formats specification. */
    93 typedef SHCLFORMATDATA *PSHCLFORMATDATA;
    9478
    9579/**
  • trunk/include/VBox/VBoxGuestLib.h

    r83142 r83624  
    656656    {
    657657        /** Reports available formats from the host. */
    658         SHCLFORMATDATA       ReportedFormats;
     658        SHCLFORMATS          fReportedFormats;
    659659        /** Reports that data needs to be read from the guest. */
    660660        SHCLFORMAT           fReadData;
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r82968 r83624  
    256256                    /* Clipboard was updated by another application.
    257257                     * Report available formats to the host. */
    258                     SHCLFORMATDATA Formats;
    259                     int rc = SharedClipboardWinGetFormats(pWinCtx, &Formats);
     258                    SHCLFORMATS fFormats;
     259                    int rc = SharedClipboardWinGetFormats(pWinCtx, &fFormats);
    260260                    if (RT_SUCCESS(rc))
    261261                    {
    262                         LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats %#x\n", Formats.Formats));
    263                         rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, Formats.Formats);
     262                        LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats %#x\n", fFormats));
     263                        rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, fFormats);
    264264                    }
    265265                }
     
    303303                    /* Clipboard was updated by another application. */
    304304                    /* WM_DRAWCLIPBOARD always expects a return code of 0, so don't change "rc" here. */
    305                     SHCLFORMATDATA Formats;
    306                     rc = SharedClipboardWinGetFormats(pWinCtx, &Formats);
     305                    SHCLFORMATS fFormats;
     306                    rc = SharedClipboardWinGetFormats(pWinCtx, &fFormats);
    307307                    if (   RT_SUCCESS(rc)
    308                         && Formats.Formats != VBOX_SHCL_FMT_NONE)
    309                         rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, Formats.Formats);
     308                        && fFormats != VBOX_SHCL_FMT_NONE)
     309                        rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, fFormats);
    310310                }
    311311                else
     
    506506            Assert(pEvent->enmType == VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS);
    507507
    508             const SHCLFORMATS fFormats = pEvent->u.ReportedFormats.Formats;
     508            const SHCLFORMATS fFormats = pEvent->u.fReportedFormats;
    509509
    510510            if (fFormats != VBOX_SHCL_FMT_NONE) /* Could arrive with some older GA versions. */
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp

    r82880 r83624  
    253253 *
    254254 * @returns VBox status code.
    255  * @param   pCtx                Shared Clipboard command context to use for the connection.
    256  * @param   pFormats            Where to store the received formats from the host.
    257  */
    258 static int vbglR3ClipboardFormatsReportRecv(PVBGLR3SHCLCMDCTX pCtx, PSHCLFORMATDATA pFormats)
    259 {
    260     AssertPtrReturn(pCtx,     VERR_INVALID_POINTER);
    261     AssertPtrReturn(pFormats, VERR_INVALID_POINTER);
    262 
    263     pFormats->fFlags = 0;
    264     pFormats->Formats = 0;
     255 * @param   pCtx        Shared Clipboard command context to use for the
     256 *                      connection.
     257 * @param   pfFormats   Where to store the received formats from the host.
     258 */
     259static int vbglR3ClipboardFormatsReportRecv(PVBGLR3SHCLCMDCTX pCtx, PSHCLFORMATS pfFormats)
     260{
     261    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     262    AssertPtrReturn(pfFormats, VERR_INVALID_POINTER);
     263
     264    *pfFormats = 0;
    265265
    266266    struct
     
    278278    if (RT_SUCCESS(rc))
    279279    {
    280         rc = Msg.f32Formats.GetUInt32(&pFormats->Formats);
     280        rc = Msg.f32Formats.GetUInt32(pfFormats);
    281281        AssertRC(rc);
    282282    }
     
    23322332            case VBOX_SHCL_HOST_MSG_FORMATS_REPORT:
    23332333                pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS;
    2334                 pEvent->u.ReportedFormats.Formats = cParms;
     2334                pEvent->u.fReportedFormats = cParms;
    23352335                break;
    23362336
     
    23722372            case VBOX_SHCL_HOST_MSG_FORMATS_REPORT:
    23732373            {
    2374                 rc = vbglR3ClipboardFormatsReportRecv(pCtx, &pEvent->u.ReportedFormats);
     2374                rc = vbglR3ClipboardFormatsReportRecv(pCtx, &pEvent->u.fReportedFormats);
    23752375                if (RT_SUCCESS(rc))
    23762376                    pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS;
     
    24322432            case VBOX_SHCL_HOST_MSG_FORMATS_REPORT:
    24332433                pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS;
    2434                 pEvent->u.ReportedFormats.Formats = cParms;
     2434                pEvent->u.fReportedFormats = cParms;
    24352435                break;
    24362436
  • trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp

    r83184 r83624  
    303303                case VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS:
    304304                {
    305                     ShClX11ReportFormatsToX11(&g_Ctx.X11, pEvent->u.ReportedFormats.Formats);
     305                    ShClX11ReportFormatsToX11(&g_Ctx.X11, pEvent->u.fReportedFormats);
    306306                    break;
    307307                }
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp

    r82968 r83624  
    420420 * @returns VBox status code.
    421421 * @param   pCtx                Windows clipboard context to retrieve formats for.
    422  * @param   pFormats            Where to store the retrieved formats.
    423  */
    424 int SharedClipboardWinGetFormats(PSHCLWINCTX pCtx, PSHCLFORMATDATA pFormats)
    425 {
    426     AssertPtrReturn(pCtx,     VERR_INVALID_POINTER);
    427     AssertPtrReturn(pFormats, VERR_INVALID_POINTER);
     422 * @param   pfFormats           Where to store the retrieved formats.
     423 */
     424int SharedClipboardWinGetFormats(PSHCLWINCTX pCtx, PSHCLFORMATS pfFormats)
     425{
     426    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     427    AssertPtrReturn(pfFormats, VERR_INVALID_POINTER);
    428428
    429429    SHCLFORMATS fFormats = VBOX_SHCL_FMT_NONE;
     
    439439        int rc2 = SharedClipboardWinClose();
    440440        AssertRC(rc2);
    441     }
    442 
    443     if (RT_FAILURE(rc))
    444     {
    445         LogFunc(("Failed with rc=%Rrc\n", rc));
     441        LogFlowFunc(("fFormats=%#x\n", fFormats));
    446442    }
    447443    else
    448     {
    449         LogFlowFunc(("fFormats=0x%08X\n", fFormats));
    450 
    451         pFormats->Formats = fFormats;
    452         pFormats->fFlags   = 0; /** @todo Handle flags. */
    453     }
    454 
     444        LogFunc(("Failed with rc=%Rrc (fFormats=%#x)\n", rc, fFormats));
     445
     446    *pfFormats = fFormats;
    455447    return rc;
    456448}
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp

    r82968 r83624  
    3535*********************************************************************************************************************************/
    3636/** Global clipboard context information */
    37 struct SHCLCONTEXT
    38 {
    39     /** We have a separate thread to poll for new clipboard content */
    40     RTTHREAD                thread;
     37typedef struct SHCLCONTEXT
     38{
     39    /** We have a separate thread to poll for new clipboard content. */
     40    RTTHREAD                hThread;
     41    /** Termination indicator.   */
    4142    bool volatile           fTerminate;
    4243    /** The reference to the current pasteboard */
    43     PasteboardRef           pasteboard;
    44     PSHCLCLIENT    pClient;
    45 };
     44    PasteboardRef           hPasteboard;
     45    /** Shared clipboard client. */
     46    PSHCLCLIENT             pClient;
     47} SHCLCONTEXT;
    4648
    4749
     
    6769    bool fChanged = false;
    6870    /* Retrieve the formats currently in the clipboard and supported by vbox */
    69     int rc = queryNewPasteboardFormats(pCtx->pasteboard, &fFormats, &fChanged);
     71    int rc = queryNewPasteboardFormats(pCtx->hPasteboard, &fFormats, &fChanged);
    7072    if (   RT_SUCCESS(rc)
    7173        && fChanged)
     
    7779
    7880/**
    79  * The poller thread.
     81 * @callback_method_impl{FNRTTHREAD, The poller thread.
    8082 *
    81  * This thread will check for the arrival of new data on the clipboard.
    82  *
    83  * @returns VINF_SUCCESS (not used).
    84  * @param   ThreadSelf  Our thread handle.
    85  * @param   pvUser      Pointer to the SHCLCONTEXT structure.
    86  *
    87  */
    88 static int vboxClipboardThread(RTTHREAD ThreadSelf, void *pvUser)
    89 {
     83 * This thread will check for the arrival of new data on the clipboard.}
     84 */
     85static DECLCALLBACK(int) vboxClipboardThread(RTTHREAD ThreadSelf, void *pvUser)
     86{
     87    SHCLCONTEXT *pCtx = (SHCLCONTEXT *)pvUser;
     88    AssertPtr(pCtx);
    9089    LogFlowFuncEnter();
    91 
    92     AssertPtrReturn(pvUser, VERR_INVALID_PARAMETER);
    93     SHCLCONTEXT *pCtx = (SHCLCONTEXT *)pvUser;
    9490
    9591    while (!pCtx->fTerminate)
     
    114110    g_ctx.fTerminate = false;
    115111
    116     int rc = initPasteboard(&g_ctx.pasteboard);
     112    int rc = initPasteboard(&g_ctx.hPasteboard);
    117113    AssertRCReturn(rc, rc);
    118114
    119     rc = RTThreadCreate(&g_ctx.thread, vboxClipboardThread, &g_ctx, 0,
     115    rc = RTThreadCreate(&g_ctx.hThread, vboxClipboardThread, &g_ctx, 0,
    120116                        RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLIP");
    121117    if (RT_FAILURE(rc))
    122118    {
    123         g_ctx.thread = NIL_RTTHREAD;
    124         destroyPasteboard(&g_ctx.pasteboard);
     119        g_ctx.hThread = NIL_RTTHREAD;
     120        destroyPasteboard(&g_ctx.hPasteboard);
    125121    }
    126122
     
    134130     */
    135131    ASMAtomicWriteBool(&g_ctx.fTerminate, true);
    136     int rc = RTThreadUserSignal(g_ctx.thread);
     132    int rc = RTThreadUserSignal(g_ctx.hThread);
    137133    AssertRC(rc);
    138     rc = RTThreadWait(g_ctx.thread, RT_INDEFINITE_WAIT, NULL);
     134    rc = RTThreadWait(g_ctx.hThread, RT_INDEFINITE_WAIT, NULL);
    139135    AssertRC(rc);
    140136
    141137    /*
    142      * Destroy the pasteboard and uninitialize the global context record.
     138     * Destroy the hPasteboard and uninitialize the global context record.
    143139     */
    144     destroyPasteboard(&g_ctx.pasteboard);
    145     g_ctx.thread = NIL_RTTHREAD;
     140    destroyPasteboard(&g_ctx.hPasteboard);
     141    g_ctx.hThread = NIL_RTTHREAD;
    146142    g_ctx.pClient = NULL;
    147143}
     
    190186}
    191187
    192 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient,
    193                               PSHCLCLIENTCMDCTX pCmdCtx, PSHCLFORMATDATA pFormats)
    194 {
    195     RT_NOREF(pCmdCtx);
    196 
    197     LogFlowFunc(("uFormats=%02X\n", pFormats->Formats));
    198 
    199     if (pFormats->Formats == VBOX_SHCL_FMT_NONE)
     188int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats)
     189{
     190    LogFlowFunc(("fFormats=%02X\n", fFormats));
     191
     192    if (fFormats == VBOX_SHCL_FMT_NONE)
    200193    {
    201194        /* This is just an automatism, not a genuine announcement */
     
    204197
    205198#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    206     if (pFormats->Formats & VBOX_SHCL_FMT_URI_LIST) /* No transfer support yet. */
     199    if (fFormats & VBOX_SHCL_FMT_URI_LIST) /* No transfer support yet. */
    207200        return VINF_SUCCESS;
    208201#endif
    209202
    210     return ShClSvcDataReadRequest(pClient, pFormats->Formats, NULL /* pidEvent */);
    211 }
    212 
    213 int ShClSvcImplReadData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx,
    214                         SHCLFORMAT uFormat, void *pvData, uint32_t cbData, uint32_t *pcbActual)
     203    return ShClSvcDataReadRequest(pClient, fFormats, NULL /* pidEvent */);
     204}
     205
     206int ShClSvcImplReadData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT fFormat,
     207                        void *pvData, uint32_t cbData, uint32_t *pcbActual)
    215208{
    216209    RT_NOREF(pCmdCtx);
     
    221214    *pcbActual = 0;
    222215
    223     int rc = readFromPasteboard(pClient->State.pCtx->pasteboard,
    224                                 uFormat, pvData, cbData, pcbActual);
    225 
    226     ShClSvcUnlock();
    227 
    228     return rc;
    229 }
    230 
    231 int ShClSvcImplWriteData(PSHCLCLIENT pClient,
    232                          PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT uFormat, void *pvData, uint32_t cbData)
     216    int rc = readFromPasteboard(pClient->State.pCtx->hPasteboard, fFormat, pvData, cbData, pcbActual);
     217
     218    ShClSvcUnlock();
     219
     220    return rc;
     221}
     222
     223int ShClSvcImplWriteData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT fFormat, void *pvData, uint32_t cbData)
    233224{
    234225    RT_NOREF(pCmdCtx);
     
    236227    ShClSvcLock();
    237228
    238     writeToPasteboard(pClient->State.pCtx->pasteboard, pvData, cbData, uFormat);
     229    writeToPasteboard(pClient->State.pCtx->hPasteboard, pvData, cbData, fFormat);
    239230
    240231    ShClSvcUnlock();
     
    244235
    245236#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
     237
    246238int ShClSvcImplTransferReadDir(PSHCLCLIENT pClient, PSHCLDIRDATA pDirData)
    247239{
     
    279271    return VERR_NOT_IMPLEMENTED;
    280272}
     273
    281274#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */
    282275
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r82889 r83624  
    282282 * @returns VBox status code.
    283283 * @param   pClient             Shared Clipboard client context.
    284  * @param   pCmdCtx             Shared Clipboard command context.
    285  * @param   pFormats            Announced formats from the guest.
    286  */
    287 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, PSHCLFORMATDATA pFormats);
     284 * @param   fFormats            The announced formats from the guest,
     285 *                              VBOX_SHCL_FMT_XXX.
     286 */
     287int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats);
    288288/** @todo Document: Can return VINF_HGCM_ASYNC_EXECUTE to defer returning read data.*/
    289289/**
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r82893 r83624  
    573573    if (pCtx->pClient)
    574574    {
    575         SHCLFORMATDATA Formats;
    576         RT_ZERO(Formats);
    577 
    578         rc = SharedClipboardWinGetFormats(&pCtx->Win, &Formats);
     575        SHCLFORMATS fFormats = 0;
     576        rc = SharedClipboardWinGetFormats(&pCtx->Win, &fFormats);
    579577        if (   RT_SUCCESS(rc)
    580             && Formats.Formats != VBOX_SHCL_FMT_NONE) /** @todo r=bird: BUGBUG: revisit this. */
    581             rc = ShClSvcHostReportFormats(pCtx->pClient, Formats.Formats);
     578            && fFormats != VBOX_SHCL_FMT_NONE) /** @todo r=bird: BUGBUG: revisit this. */
     579            rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats);
    582580    }
    583581    else /* If we don't have any client data (yet), bail out. */
     
    696694}
    697695
    698 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx,
    699                               PSHCLFORMATDATA pFormats)
     696int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats)
    700697{
    701698    AssertPtrReturn(pClient, VERR_INVALID_POINTER);
    702     RT_NOREF(pCmdCtx);
    703 
    704     int rc;
    705699
    706700    PSHCLCONTEXT pCtx = pClient->State.pCtx;
    707701    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    708702
    709     LogFlowFunc(("uFormats=0x%x, hWnd=%p\n", pFormats->Formats, pCtx->Win.hWnd));
     703    LogFlowFunc(("fFormats=0x%x, hWnd=%p\n", fFormats, pCtx->Win.hWnd));
    710704
    711705    /*
     
    713707     */
    714708    PostMessage(pCtx->Win.hWnd, SHCL_WIN_WM_REPORT_FORMATS,
    715                 0 /* wParam */, pFormats->Formats /* lParam */);
    716 
    717     rc = VINF_SUCCESS;
    718 
    719     LogFlowFuncLeaveRC(rc);
    720     return rc;
     709                0 /* wParam */, fFormats /* lParam */);
     710
     711
     712    LogFlowFuncLeaveRC(VINF_SUCCESS);
     713    return VINF_SUCCESS;
    721714}
    722715
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r82893 r83624  
    146146}
    147147
    148 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx,
    149                               PSHCLFORMATDATA pFormats)
    150 {
    151     RT_NOREF(pCmdCtx);
    152 
    153     int rc = ShClX11ReportFormatsToX11(&pClient->State.pCtx->X11, pFormats->Formats);
     148int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats)
     149{
     150    int rc = ShClX11ReportFormatsToX11(&pClient->State.pCtx->X11, fFormats);
    154151
    155152    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r83621 r83624  
    14641464            }
    14651465            else
    1466             {
    1467                 SHCLCLIENTCMDCTX CmdCtx;
    1468                 RT_ZERO(CmdCtx);
    1469 
    1470                 SHCLFORMATDATA FormatData;
    1471                 FormatData.fFlags  = 0;
    1472                 FormatData.Formats = fFormats;
    1473                 rc = ShClSvcImplFormatAnnounce(pClient, &CmdCtx, &FormatData);
    1474             }
     1466                rc = ShClSvcImplFormatAnnounce(pClient, fFormats);
    14751467        }
    14761468    }
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp

    r82892 r83624  
    312312int ShClSvcImplDisconnect(PSHCLCLIENT) { return VINF_SUCCESS; }
    313313int ShClSvcImplConnect(PSHCLCLIENT, bool) { return VINF_SUCCESS; }
    314 int ShClSvcImplFormatAnnounce(PSHCLCLIENT, PSHCLCLIENTCMDCTX, PSHCLFORMATDATA) { AssertFailed(); return VINF_SUCCESS; }
     314int ShClSvcImplFormatAnnounce(PSHCLCLIENT, SHCLFORMATS) { AssertFailed(); return VINF_SUCCESS; }
    315315int ShClSvcImplReadData(PSHCLCLIENT, PSHCLCLIENTCMDCTX, SHCLFORMAT, void *, uint32_t, unsigned int *) { AssertFailed(); return VERR_WRONG_ORDER; }
    316316int ShClSvcImplWriteData(PSHCLCLIENT, PSHCLCLIENTCMDCTX, SHCLFORMAT, void *, uint32_t) { AssertFailed(); return VINF_SUCCESS; }
Note: See TracChangeset for help on using the changeset viewer.

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