VirtualBox

Changeset 78580 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 18, 2019 3:38:45 PM (6 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Renaming (+ build fix).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard.h

    r78579 r78580  
    2727#include <VBox/GuestHost/SharedClipboard.h>
    2828
    29 typedef struct _VBOXCLIPBOARDCLIENTDATA
     29typedef struct _VBOXCLIPBOARDSVCCTX
    3030{
    31     struct _VBOXCLIPBOARDCLIENTDATA *pNext;
    32     struct _VBOXCLIPBOARDCLIENTDATA *pPrev;
     31    struct _VBOXCLIPBOARDSVCCTX *pNext;
     32    struct _VBOXCLIPBOARDSVCCTX *pPrev;
    3333
    3434    VBOXCLIPBOARDCONTEXT *pCtx;
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp

    r78579 r78580  
    6363static int vboxClipboardChanged(VBOXCLIPBOARDCONTEXT *pCtx)
    6464{
    65     if (pCtx->pClient == NULL)
     65    if (pCtx->pSvcCtx == NULL)
    6666        return VINF_SUCCESS;
    6767
     
    7272    if (RT_SUCCESS(rc) && fChanged)
    7373    {
    74         vboxSvcClipboardReportMsg(pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, fFormats);
     74        vboxSvcClipboardReportMsg(pCtx->pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, fFormats);
    7575        Log(("vboxClipboardChanged fFormats %02X\n", fFormats));
    7676    }
     
    157157    destroyPasteboard(&g_ctx.pasteboard);
    158158    g_ctx.thread = NIL_RTTHREAD;
    159     g_ctx.pClient = NULL;
     159    g_ctx.pSvcCtx = NULL;
    160160}
    161161
     
    163163 * Enable the shared clipboard - called by the hgcm clipboard subsystem.
    164164 *
    165  * @param   pClient Structure containing context information about the guest system
     165 * @param   pSvcCtx Structure containing context information about the guest system
    166166 * @param   fHeadless Whether headless.
    167167 * @returns RT status code
     
    170170{
    171171    NOREF(fHeadless);
    172     if (g_ctx.pClient != NULL)
     172    if (g_ctx.pSvcCtx != NULL)
    173173    {
    174174        /* One client only. */
     
    178178    VBoxSvcClipboardLock();
    179179
    180     pClient->pCtx = &g_ctx;
    181     pClient->pCtx->pClient = pClient;
     180    pSvcCtx->pCtx = &g_ctx;
     181    pSvcCtx->pCtx->pSvcCtx = pSvcCtx;
    182182
    183183    /* Initially sync the host clipboard content with the client. */
    184     int rc = VBoxClipboardSvcImplSync(pClient);
     184    int rc = VBoxClipboardSvcImplSync(pSvcCtx);
    185185
    186186    VBoxSvcClipboardUnlock();
     
    196196    /* Sync the host clipboard content with the client. */
    197197    VBoxSvcClipboardLock();
    198     int rc = vboxClipboardChanged(pClient->pCtx);
     198    int rc = vboxClipboardChanged(pSvcCtx->pCtx);
    199199    VBoxSvcClipboardUnlock();
    200200
     
    210210
    211211    VBoxSvcClipboardLock();
    212     pClient->pCtx->pClient = NULL;
     212    pSvcCtx->pCtx->pSvcCtx = NULL;
    213213    VBoxSvcClipboardUnlock();
    214214}
     
    218218 * subsystem.
    219219 *
    220  * @param pClient    Context data for the guest system
     220 * @param pSvcCtx    Context data for the guest system
    221221 * @param u32Formats Clipboard formats the guest is offering
    222222 */
     
    230230    }
    231231
    232     vboxSvcClipboardReportMsg(pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Formats);
     232    vboxSvcClipboardReportMsg(pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Formats);
    233233}
    234234
     
    236236 * Called by the HGCM clipboard subsystem when the guest wants to read the host clipboard.
    237237 *
    238  * @param pClient   Context information about the guest VM
     238 * @param pSvcCtx   Context information about the guest VM
    239239 * @param u32Format The format that the guest would like to receive the data in
    240240 * @param pv        Where to write the data to
     
    249249    /* Default to no data available. */
    250250    *pcbActual = 0;
    251     int rc = readFromPasteboard(pClient->pCtx->pasteboard, u32Format, pv, cb, pcbActual);
     251    int rc = readFromPasteboard(pSvcCtx->pCtx->pasteboard, u32Format, pv, cb, pcbActual);
    252252
    253253    VBoxSvcClipboardUnlock();
     
    258258 * Called by the HGCM clipboard subsystem when we have requested data and that data arrives.
    259259 *
    260  * @param pClient   Context information about the guest VM
     260 * @param pSvcCtx   Context information about the guest VM
    261261 * @param pv        Buffer to which the data was written
    262262 * @param cb        The size of the data written
     
    267267    VBoxSvcClipboardLock();
    268268
    269     writeToPasteboard(pClient->pCtx->pasteboard, pv, cb, u32Format);
    270 
    271     VBoxSvcClipboardUnlock();
    272 }
     269    writeToPasteboard(pSvcCtx->pCtx->pasteboard, pv, cb, u32Format);
     270
     271    VBoxSvcClipboardUnlock();
     272}
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r78579 r78580  
    6161    RTSEMEVENT               hRenderEvent;
    6262    /** Structure for keeping and communicating with client data (from the guest). */
    63     PVBOXCLIPBOARDSVCCTX    pClient;
     63    PVBOXCLIPBOARDSVCCTX     pSvcCtx;
    6464    /** Windows-specific context data. */
    6565    VBOXCLIPBOARDWINCTX      Win;
     
    160160static int vboxClipboardReadDataFromClient(VBOXCLIPBOARDCONTEXT *pCtx, VBOXCLIPBOARDFORMAT fFormat)
    161161{
    162     Assert(pCtx->pClient);
     162    Assert(pCtx->pSvcCtx);
    163163    Assert(pCtx->hRenderEvent);
    164     Assert(pCtx->pClient->data.pv == NULL && pCtx->pClient->data.cb == 0 && pCtx->pClient->data.u32Format == 0);
     164    Assert(pCtx->pSvcCtx->data.pv == NULL && pCtx->pSvcCtx->data.cb == 0 && pCtx->pSvcCtx->data.u32Format == 0);
    165165
    166166    LogFlowFunc(("fFormat=%02X\n", fFormat));
    167167
    168     vboxSvcClipboardReportMsg(pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, fFormat);
     168    vboxSvcClipboardReportMsg(pCtx->pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, fFormat);
    169169
    170170    return RTSemEventWait(pCtx->hRenderEvent, 30 * 1000 /* Timeout in ms */);
     
    289289
    290290            if (   fFormat       == VBOX_SHARED_CLIPBOARD_FMT_NONE
    291                 || pCtx->pClient == NULL)
     291                || pCtx->pSvcCtx == NULL)
    292292            {
    293293                /* Unsupported clipboard format is requested. */
     
    300300
    301301                LogFunc(("vboxClipboardReadDataFromClient rc = %Rrc, pv %p, cb %d, u32Format %d\n",
    302                           rc, pCtx->pClient->data.pv, pCtx->pClient->data.cb, pCtx->pClient->data.u32Format));
     302                          rc, pCtx->pSvcCtx->data.pv, pCtx->pSvcCtx->data.cb, pCtx->pSvcCtx->data.u32Format));
    303303
    304304                if (   RT_SUCCESS (rc)
    305                     && pCtx->pClient->data.pv != NULL
    306                     && pCtx->pClient->data.cb > 0
    307                     && pCtx->pClient->data.u32Format == fFormat)
    308                 {
    309                     HANDLE hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, pCtx->pClient->data.cb);
     305                    && pCtx->pSvcCtx->data.pv != NULL
     306                    && pCtx->pSvcCtx->data.cb > 0
     307                    && pCtx->pSvcCtx->data.u32Format == fFormat)
     308                {
     309                    HANDLE hMem = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, pCtx->pSvcCtx->data.cb);
    310310
    311311                    LogFunc(("hMem %p\n", hMem));
     
    321321                            LogFunc(("WM_RENDERFORMAT setting data\n"));
    322322
    323                             if (pCtx->pClient->data.pv)
     323                            if (pCtx->pSvcCtx->data.pv)
    324324                            {
    325                                 memcpy(pMem, pCtx->pClient->data.pv, pCtx->pClient->data.cb);
    326 
    327                                 RTMemFree(pCtx->pClient->data.pv);
    328                                 pCtx->pClient->data.pv        = NULL;
     325                                memcpy(pMem, pCtx->pSvcCtx->data.pv, pCtx->pSvcCtx->data.cb);
     326
     327                                RTMemFree(pCtx->pSvcCtx->data.pv);
     328                                pCtx->pSvcCtx->data.pv        = NULL;
    329329                            }
    330330
    331                             pCtx->pClient->data.cb        = 0;
    332                             pCtx->pClient->data.u32Format = 0;
     331                            pCtx->pSvcCtx->data.cb        = 0;
     332                            pCtx->pSvcCtx->data.u32Format = 0;
    333333
    334334                            /* The memory must be unlocked before inserting to the Clipboard. */
     
    353353                }
    354354
    355                 RTMemFree(pCtx->pClient->data.pv);
    356                 pCtx->pClient->data.pv        = NULL;
    357                 pCtx->pClient->data.cb        = 0;
    358                 pCtx->pClient->data.u32Format = 0;
     355                RTMemFree(pCtx->pSvcCtx->data.pv);
     356                pCtx->pSvcCtx->data.pv        = NULL;
     357                pCtx->pSvcCtx->data.cb        = 0;
     358                pCtx->pSvcCtx->data.u32Format = 0;
    359359
    360360                /* Something went wrong. */
     
    380380        case VBOX_CLIPBOARD_WM_SET_FORMATS:
    381381        {
    382             if (   pCtx->pClient == NULL
    383                 || pCtx->pClient->fHostMsgFormats)
     382            if (   pCtx->pSvcCtx == NULL
     383                || pCtx->pSvcCtx->fHostMsgFormats)
    384384            {
    385385                /* Host has pending formats message. Ignore the guest announcement,
     
    545545    int rc;
    546546
    547     if (pCtx->pClient)
     547    if (pCtx->pSvcCtx)
    548548    {
    549549        uint32_t uFormats;
    550550        rc = VBoxClipboardWinGetFormats(&pCtx->Win, &uFormats);
    551551        if (RT_SUCCESS(rc))
    552             vboxSvcClipboardReportMsg(pCtx->pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, uFormats);
     552            vboxSvcClipboardReportMsg(pCtx->pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, uFormats);
    553553    }
    554554    else /* If we don't have any client data (yet), bail out. */
     
    608608    LogFlowFuncEnter();
    609609
    610     if (g_ctx.pClient != NULL)
     610    if (g_ctx.pSvcCtx != NULL)
    611611    {
    612612        /* One client only. */
     
    614614    }
    615615
    616     pClient->pCtx = &g_ctx;
    617 
    618     pClient->pCtx->pClient = pClient;
     616    pSvcCtx->pCtx = &g_ctx;
     617
     618    pSvcCtx->pCtx->pSvcCtx = pSvcCtx;
    619619
    620620    /* Sync the host clipboard content with the client. */
    621     VBoxClipboardSvcImplSync(pClient);
     621    VBoxClipboardSvcImplSync(pSvcCtx);
    622622
    623623    return VINF_SUCCESS;
     
    627627{
    628628    /* Sync the host clipboard content with the client. */
    629     return vboxClipboardWinSyncInternal(pClient->pCtx);
     629    return vboxClipboardWinSyncInternal(pSvcCtx->pCtx);
    630630}
    631631
    632632void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX pSvcCtx)
    633633{
    634     RT_NOREF(pClient);
     634    RT_NOREF(pSvcCtx);
    635635
    636636    LogFlowFuncEnter();
    637637
    638     g_ctx.pClient = NULL;
     638    g_ctx.pSvcCtx = NULL;
    639639}
    640640
    641641void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats)
    642642{
    643     AssertPtrReturnVoid(pClient);
    644     AssertPtrReturnVoid(pClient->pCtx);
     643    AssertPtrReturnVoid(pSvcCtx);
     644    AssertPtrReturnVoid(pSvcCtx->pCtx);
    645645
    646646    /*
    647647     * The guest announces formats. Forward to the window thread.
    648648     */
    649     PostMessage(pClient->pCtx->Win.hWnd, WM_USER, 0, u32Formats);
     649    PostMessage(pSvcCtx->pCtx->Win.hWnd, WM_USER, 0, u32Formats);
    650650}
    651651
     
    684684int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual)
    685685{
    686     AssertPtrReturn(pClient,       VERR_INVALID_POINTER);
    687     AssertPtrReturn(pClient->pCtx, VERR_INVALID_POINTER);
     686    AssertPtrReturn(pSvcCtx,       VERR_INVALID_POINTER);
     687    AssertPtrReturn(pSvcCtx->pCtx, VERR_INVALID_POINTER);
    688688
    689689    LogFlowFunc(("u32Format=%02X\n", u32Format));
     
    691691    HANDLE hClip = NULL;
    692692
    693     const PVBOXCLIPBOARDWINCTX pWinCtx = &pClient->pCtx->Win;
     693    const PVBOXCLIPBOARDWINCTX pWinCtx = &pSvcCtx->pCtx->Win;
    694694
    695695    /*
     
    823823     * The guest returns data that was requested in the WM_RENDERFORMAT handler.
    824824     */
    825     Assert(pClient->data.pv == NULL && pClient->data.cb == 0 && pClient->data.u32Format == 0);
     825    Assert(pSvcCtx->data.pv == NULL && pSvcCtx->data.cb == 0 && pSvcCtx->data.u32Format == 0);
    826826
    827827    vboxClipboardDump(pv, cb, u32Format);
     
    841841                if (pszResult != NULL && cbResult != 0)
    842842                {
    843                     pClient->data.pv        = pszResult;
    844                     pClient->data.cb        = cbResult;
    845                     pClient->data.u32Format = u32Format;
     843                    pSvcCtx->data.pv        = pszResult;
     844                    pSvcCtx->data.cb        = cbResult;
     845                    pSvcCtx->data.u32Format = u32Format;
    846846                }
    847847            }
     
    849849        else
    850850        {
    851             pClient->data.pv = RTMemDup(pv, cb);
    852             if (pClient->data.pv)
    853             {
    854                 pClient->data.cb = cb;
    855                 pClient->data.u32Format = u32Format;
    856             }
    857         }
    858     }
    859 
    860     AssertPtr(pClient->pCtx);
    861     int rc = RTSemEventSignal(pClient->pCtx->hRenderEvent);
     851            pSvcCtx->data.pv = RTMemDup(pv, cb);
     852            if (pSvcCtx->data.pv)
     853            {
     854                pSvcCtx->data.cb = cb;
     855                pSvcCtx->data.u32Format = u32Format;
     856            }
     857        }
     858    }
     859
     860    AssertPtr(pSvcCtx->pCtx);
     861    int rc = RTSemEventSignal(pSvcCtx->pCtx->hRenderEvent);
    862862    AssertRC(rc);
    863863
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11-stubs.cpp

    r78579 r78580  
    5555  * Enable the shared clipboard - called by the hgcm clipboard subsystem.
    5656  *
    57   * @param   pClient    Structure containing context information about the guest system
     57  * @param   pSvcCtx    Structure containing context information about the guest system
    5858  * @param   fHeadless  Whether headless.
    5959  * @returns RT status code
     
    6161int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX pSvcCtx, bool fHeadless)
    6262{
    63     RT_NOREF(pClient, fHeadless);
     63    RT_NOREF(pSvcCtx, fHeadless);
    6464    LogFlowFunc(("called, returning VINF_SUCCESS.\n"));
    6565    return VINF_SUCCESS;
     
    7070 * after a save and restore of the guest.
    7171 */
    72 int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX /* pClient */)
     72int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX /* pSvcCtx */)
    7373{
    7474    LogFlowFunc(("called, returning VINF_SUCCESS.\n"));
     
    7979 * Shut down the shared clipboard subsystem and "disconnect" the guest.
    8080 *
    81  * @param   pClient    Structure containing context information about the guest system
     81 * @param   pSvcCtx    Structure containing context information about the guest system
    8282 */
    8383void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX pSvcCtx)
    8484{
    85     RT_NOREF(pClient);
     85    RT_NOREF(pSvcCtx);
    8686    LogFlowFunc(("called, returning.\n"));
    8787}
     
    9191 * subsystem.
    9292 *
    93  * @param pClient    Context data for the guest system
     93 * @param pSvcCtx    Context data for the guest system
    9494 * @param u32Formats Clipboard formats the guest is offering
    9595 */
    9696void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats)
    9797{
    98     RT_NOREF(pClient, u32Formats);
     98    RT_NOREF(pSvcCtx, u32Formats);
    9999    LogFlowFunc(("called, returning.\n"));
    100100}
     
    103103 * Called by the HGCM clipboard subsystem when the guest wants to read the host clipboard.
    104104 *
    105  * @param pClient   Context information about the guest VM
     105 * @param pSvcCtx   Context information about the guest VM
    106106 * @param u32Format The format that the guest would like to receive the data in
    107107 * @param pv        Where to write the data to
     
    112112                          void *pv, uint32_t cb, uint32_t *pcbActual)
    113113{
    114     RT_NOREF(pClient, u32Format, pv, cb);
     114    RT_NOREF(pSvcCtx, u32Format, pv, cb);
    115115    LogFlowFunc(("called, returning VINF_SUCCESS.\n"));
    116116    /* No data available. */
     
    122122 * Called by the HGCM clipboard subsystem when we have requested data and that data arrives.
    123123 *
    124  * @param pClient   Context information about the guest VM
     124 * @param pSvcCtx   Context information about the guest VM
    125125 * @param pv        Buffer to which the data was written
    126126 * @param cb        The size of the data written
     
    130130                            uint32_t u32Format)
    131131{
    132     RT_NOREF(pClient, pv, cb, u32Format);
     132    RT_NOREF(pSvcCtx, pv, cb, u32Format);
    133133    LogFlowFunc(("called, returning.\n"));
    134134}
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r78579 r78580  
    7676{
    7777    LogRelFlowFunc(("called.  pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats));
    78     vboxSvcClipboardReportMsg(pCtx->pClient,
     78    vboxSvcClipboardReportMsg(pCtx->pSvcCtx,
    7979                              VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS,
    8080                              u32Formats);
     
    123123        {
    124124            pCtx->pBackend = pBackend;
    125             pClient->pCtx = pCtx;
    126             pCtx->pClient = pClient;
     125            pSvcCtx->pCtx = pCtx;
     126            pCtx->pSvcCtx = pSvcCtx;
    127127            rc = ClipStartX11(pBackend, true /* grab shared clipboard */);
    128128        }
     
    149149     * there is data in the host clipboard it will automatically be sent to
    150150     * the guest when the clipboard starts up. */
    151     vboxSvcClipboardReportMsg(pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, 0);
     151    vboxSvcClipboardReportMsg(pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, 0);
    152152    /** @todo r=andy Check rc code. */
    153153    return VINF_SUCCESS;
     
    163163
    164164    LogRel(("Stopping the host clipboard service\n"));
    165     VBOXCLIPBOARDCONTEXT *pCtx = pClient->pCtx;
     165    VBOXCLIPBOARDCONTEXT *pCtx = pSvcCtx->pCtx;
    166166    /* Drop the reference to the client, in case it is still there.  This
    167167     * will cause any outstanding clipboard data requests from X11 to fail
     
    169169    pCtx->fShuttingDown = true;
    170170    /* If there is a currently pending request, release it immediately. */
    171     VBoxClipboardSvcImplWriteData(pClient, NULL, 0, 0);
     171    VBoxClipboardSvcImplWriteData(pSvcCtx, NULL, 0, 0);
    172172    int rc = ClipStopX11(pCtx->pBackend);
    173173    /** @todo handle this slightly more reasonably, or be really sure
     
    185185 * VBox is taking possession of the shared clipboard.
    186186 *
    187  * @param pClient    Context data for the guest system
     187 * @param pSvcCtx    Context data for the guest system
    188188 * @param u32Formats Clipboard formats the guest is offering
    189189 * @note  Host glue code
     
    191191void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats)
    192192{
    193     LogRelFlowFunc(("called.  pClient=%p, u32Formats=%02X\n", pClient, u32Formats));
    194 
    195     ClipAnnounceFormatToX11(pClient->pCtx->pBackend, u32Formats);
     193    LogRelFlowFunc(("called.  pSvcCtx=%p, u32Formats=%02X\n", pSvcCtx, u32Formats));
     194
     195    ClipAnnounceFormatToX11(pSvcCtx->pCtx->pBackend, u32Formats);
    196196}
    197197
     
    214214 *          asynchronously
    215215 * @returns iprt status code on failure
    216  * @param  pClient   Context information about the guest VM
     216 * @param  pSvcCtx   Context information about the guest VM
    217217 * @param  u32Format The format that the guest would like to receive the data in
    218218 * @param  pv        Where to write the data to
     
    229229                          uint32_t *pcbActual)
    230230{
    231     LogRelFlowFunc(("pClient=%p, u32Format=%02X, pv=%p, cb=%u, pcbActual=%p",
    232                     pClient, u32Format, pv, cb, pcbActual));
     231    LogRelFlowFunc(("pSvcCtx=%p, u32Format=%02X, pv=%p, cb=%u, pcbActual=%p",
     232                    pSvcCtx, u32Format, pv, cb, pcbActual));
    233233
    234234    int rc = VINF_SUCCESS;
     
    241241        pReq->cb = cb;
    242242        pReq->pcbActual = pcbActual;
    243         rc = ClipRequestDataFromX11(pClient->pCtx->pBackend, u32Format, pReq);
     243        rc = ClipRequestDataFromX11(pSvcCtx->pCtx->pBackend, u32Format, pReq);
    244244        if (RT_SUCCESS(rc))
    245245            rc = VINF_HGCM_ASYNC_EXECUTE;
     
    269269    RTMemFree(pReq);
    270270
    271     vboxSvcClipboardCompleteReadData(pCtx->pClient, rc, cb);
     271    vboxSvcClipboardCompleteReadData(pCtx->pSvcCtx, rc, cb);
    272272}
    273273
     
    295295
    296296    /* Request data from VBox */
    297     vboxSvcClipboardReportMsg(pCtx->pClient,
     297    vboxSvcClipboardReportMsg(pCtx->pSvcCtx,
    298298                              VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
    299299                              u32Format);
     
    393393 * Called when we have requested data from VBox and that data has arrived.
    394394 *
    395  * @param  pClient   Context information about the guest VM
     395 * @param  pSvcCtx   Context information about the guest VM
    396396 * @param  pv        Buffer to which the data was written
    397397 * @param  cb        The size of the data written
     
    402402                            void *pv, uint32_t cb, uint32_t u32Format)
    403403{
    404     LogRelFlowFunc(("called.  pClient=%p, pv=%p (%.*ls), cb=%u, u32Format=%02X\n",
    405                     pClient, pv, cb / 2, pv, cb, u32Format));
    406 
    407     VBOXCLIPBOARDCONTEXT *pCtx = pClient->pCtx;
     404    LogRelFlowFunc(("called.  pSvcCtx=%p, pv=%p (%.*ls), cb=%u, u32Format=%02X\n",
     405                    pSvcCtx, pv, cb / 2, pv, cb, u32Format));
     406
     407    VBOXCLIPBOARDCONTEXT *pCtx = pSvcCtx->pCtx;
    408408
    409409    /* Grab the mutex and check whether there is a pending request for data. */
     
    466466{
    467467    RT_NOREF(u32Formats);
    468     CLIPBACKEND *pBackend = pClient->pCtx->pBackend;
     468    CLIPBACKEND *pBackend = pSvcCtx->pCtx->pBackend;
    469469
    470470    if ((u32Msg == VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA)
    471471        && !pBackend->writeData.timeout)
    472         VBoxClipboardSvcImplWriteData(pClient, pBackend->writeData.pv,
     472        VBoxClipboardSvcImplWriteData(pSvcCtx, pBackend->writeData.pv,
    473473                               pBackend->writeData.cb,
    474474                               pBackend->writeData.format);
     
    479479void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, int rc, uint32_t cbActual)
    480480{
    481     CLIPBACKEND *pBackend = pClient->pCtx->pBackend;
     481    CLIPBACKEND *pBackend = pSvcCtx->pCtx->pBackend;
    482482    pBackend->completeRead.rc = rc;
    483483    pBackend->completeRead.cbActual = cbActual;
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r78579 r78580  
    102102static void *g_pvExtension;
    103103
    104 static PVBOXCLIPBOARDSVCCTX g_pClient;
     104static PVBOXCLIPBOARDSVCCTX g_pSvcCtx;
    105105
    106106/* Serialization of data reading and format announcements from the RDP client. */
     
    203203{
    204204    /* Message priority is taken into account. */
    205     if (pClient->fHostMsgQuit)
     205    if (pSvcCtx->fHostMsgQuit)
    206206    {
    207207        LogFlowFunc(("vboxSvcClipboardReturnMsg: Quit\n"));
    208208        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT);
    209209        VBoxHGCMParmUInt32Set(&paParms[1], 0);
    210         pClient->fHostMsgQuit = false;
    211     }
    212     else if (pClient->fHostMsgReadData)
     210        pSvcCtx->fHostMsgQuit = false;
     211    }
     212    else if (pSvcCtx->fHostMsgReadData)
    213213    {
    214214        uint32_t fFormat = 0;
    215215
    216         LogFlowFunc(("vboxSvcClipboardReturnMsg: ReadData %02X\n", pClient->u32RequestedFormat));
    217         if (pClient->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     216        LogFlowFunc(("vboxSvcClipboardReturnMsg: ReadData %02X\n", pSvcCtx->u32RequestedFormat));
     217        if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
    218218            fFormat = VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
    219         else if (pClient->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
     219        else if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
    220220            fFormat = VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
    221         else if (pClient->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_HTML)
     221        else if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_HTML)
    222222            fFormat = VBOX_SHARED_CLIPBOARD_FMT_HTML;
    223223#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    224         else if (pClient->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_URI_LIST)
     224        else if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_URI_LIST)
    225225            fFormat = VBOX_SHARED_CLIPBOARD_FMT_URI_LIST;
    226226#endif
     
    228228        {
    229229            LogRel2(("Clipboard: Unsupported format from guest (0x%x), skipping\n", fFormat));
    230             pClient->u32RequestedFormat = 0;
     230            pSvcCtx->u32RequestedFormat = 0;
    231231        }
    232         pClient->u32RequestedFormat &= ~fFormat;
     232        pSvcCtx->u32RequestedFormat &= ~fFormat;
    233233        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
    234234        VBoxHGCMParmUInt32Set(&paParms[1], fFormat);
    235         if (pClient->u32RequestedFormat == 0)
    236             pClient->fHostMsgReadData = false;
    237     }
    238     else if (pClient->fHostMsgFormats)
    239     {
    240         LogFlowFunc(("vboxSvcClipboardReturnMsg: Formats %02X\n", pClient->u32AvailableFormats));
     235        if (pSvcCtx->u32RequestedFormat == 0)
     236            pSvcCtx->fHostMsgReadData = false;
     237    }
     238    else if (pSvcCtx->fHostMsgFormats)
     239    {
     240        LogFlowFunc(("vboxSvcClipboardReturnMsg: Formats %02X\n", pSvcCtx->u32AvailableFormats));
    241241        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS);
    242         VBoxHGCMParmUInt32Set(&paParms[1], pClient->u32AvailableFormats);
    243         pClient->fHostMsgFormats = false;
     242        VBoxHGCMParmUInt32Set(&paParms[1], pSvcCtx->u32AvailableFormats);
     243        pSvcCtx->fHostMsgFormats = false;
    244244    }
    245245    else
     
    256256void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Msg, uint32_t u32Formats)
    257257{
    258     AssertPtrReturnVoid(pClient);
     258    AssertPtrReturnVoid(pSvcCtx);
    259259
    260260    if (VBoxSvcClipboardLock())
     
    265265            {
    266266                LogFlowFunc(("Quit\n"));
    267                 pClient->fHostMsgQuit = true;
     267                pSvcCtx->fHostMsgQuit = true;
    268268            } break;
    269269            case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA:
     
    277277
    278278                LogFlowFunc(("ReadData %02X\n", u32Formats));
    279                 pClient->u32RequestedFormat = u32Formats;
    280                 pClient->fHostMsgReadData = true;
     279                pSvcCtx->u32RequestedFormat = u32Formats;
     280                pSvcCtx->fHostMsgReadData = true;
    281281            } break;
    282282            case VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS:
     
    290290
    291291                LogFlowFunc(("Formats %02X\n", u32Formats));
    292                 pClient->u32AvailableFormats = u32Formats;
    293                 pClient->fHostMsgFormats = true;
     292                pSvcCtx->u32AvailableFormats = u32Formats;
     293                pSvcCtx->fHostMsgFormats = true;
    294294            } break;
    295295            default:
     
    300300        }
    301301
    302         if (pClient->fAsync)
     302        if (pSvcCtx->fAsync)
    303303        {
    304304            /* The client waits for a response. */
    305             bool fMessageReturned = vboxSvcClipboardReturnMsg(pClient, pClient->async.paParms);
     305            bool fMessageReturned = vboxSvcClipboardReturnMsg(pSvcCtx, pSvcCtx->async.paParms);
    306306
    307307            /* Make a copy of the handle. */
    308             VBOXHGCMCALLHANDLE callHandle = pClient->async.callHandle;
     308            VBOXHGCMCALLHANDLE callHandle = pSvcCtx->async.callHandle;
    309309
    310310            if (fMessageReturned)
    311311            {
    312312                /* There is a response. */
    313                 pClient->fAsync = false;
     313                pSvcCtx->fAsync = false;
    314314            }
    315315
     
    370370    LogFunc(("u32ClientID = %d\n", u32ClientID));
    371371
    372     vboxSvcClipboardReportMsg(pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
    373 
    374     vboxSvcClipboardCompleteReadData(pClient, VERR_NO_DATA, 0);
    375 
    376     VBoxClipboardSvcImplDisconnect(pClient);
    377 
    378     memset(pClient, 0, sizeof(*pClient));
    379 
    380     g_pClient = NULL;
     372    vboxSvcClipboardReportMsg(pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
     373
     374    vboxSvcClipboardCompleteReadData(pSvcCtx, VERR_NO_DATA, 0);
     375
     376    VBoxClipboardSvcImplDisconnect(pSvcCtx);
     377
     378    memset(pSvcCtx, 0, sizeof(*pSvcCtx));
     379
     380    g_pSvcCtx = NULL;
    381381
    382382    return VINF_SUCCESS;
     
    391391
    392392    /* If there is already a client connected then we want to release it first. */
    393     if (g_pClient != NULL)
    394     {
    395         uint32_t u32OldClientID = g_pClient->u32ClientID;
    396 
    397         svcDisconnect(NULL, u32OldClientID, g_pClient);
     393    if (g_pSvcCtx != NULL)
     394    {
     395        uint32_t u32OldClientID = g_pSvcCtx->u32ClientID;
     396
     397        svcDisconnect(NULL, u32OldClientID, g_pSvcCtx);
    398398        /* And free the resources in the hgcm subsystem. */
    399399        g_pHelpers->pfnDisconnectClient(g_pHelpers->pvInstance, u32OldClientID);
     
    401401
    402402    /* Register the client. */
    403     memset(pClient, 0, sizeof(*pClient));
    404 
    405     pClient->u32ClientID = u32ClientID;
    406 
    407     rc = VBoxClipboardSvcImplConnect(pClient, VBoxSvcClipboardGetHeadless());
     403    memset(pSvcCtx, 0, sizeof(*pSvcCtx));
     404
     405    pSvcCtx->u32ClientID = u32ClientID;
     406
     407    rc = VBoxClipboardSvcImplConnect(pSvcCtx, VBoxSvcClipboardGetHeadless());
    408408
    409409    if (RT_SUCCESS(rc))
    410410    {
    411         g_pClient = pClient;
     411        g_pSvcCtx = pSvcCtx;
    412412    }
    413413
     
    467467                if (VBoxSvcClipboardLock())
    468468                {
    469                     bool fMessageReturned = vboxSvcClipboardReturnMsg (pClient, paParms);
     469                    bool fMessageReturned = vboxSvcClipboardReturnMsg (pSvcCtx, paParms);
    470470
    471471                    if (fMessageReturned)
    472472                    {
    473473                        /* Just return to the caller. */
    474                         pClient->fAsync = false;
     474                        pSvcCtx->fAsync = false;
    475475                    }
    476476                    else
     
    479479                        fAsynchronousProcessing = true;
    480480
    481                         pClient->fAsync           = true;
    482                         pClient->async.callHandle = callHandle;
    483                         pClient->async.paParms    = paParms;
     481                        pSvcCtx->fAsync           = true;
     482                        pSvcCtx->async.callHandle = callHandle;
     483                        pSvcCtx->async.paParms    = paParms;
    484484
    485485                        LogFunc(("async.\n"));
     
    534534                    else
    535535                    {
    536                         VBoxClipboardSvcImplFormatAnnounce (pClient, u32Formats);
     536                        VBoxClipboardSvcImplFormatAnnounce (pSvcCtx, u32Formats);
    537537                    }
    538538                }
     
    592592                            if (g_fDelayedAnnouncement)
    593593                            {
    594                                 vboxSvcClipboardReportMsg (g_pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, g_u32DelayedFormats);
     594                                vboxSvcClipboardReportMsg (g_pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, g_u32DelayedFormats);
    595595                                g_fDelayedAnnouncement = false;
    596596                                g_u32DelayedFormats = 0;
     
    607607                            /* Release any other pending read, as we only
    608608                             * support one pending read at one time. */
    609                             vboxSvcClipboardCompleteReadData(pClient, VERR_NO_DATA, 0);
    610                             rc = VBoxClipboardSvcImplReadData (pClient, u32Format, pv, cb, &cbActual);
     609                            vboxSvcClipboardCompleteReadData(pSvcCtx, VERR_NO_DATA, 0);
     610                            rc = VBoxClipboardSvcImplReadData (pSvcCtx, u32Format, pv, cb, &cbActual);
    611611                        }
    612612
     
    618618                            if (VBoxSvcClipboardLock())
    619619                            {
    620                                 pClient->asyncRead.callHandle = callHandle;
    621                                 pClient->asyncRead.paParms    = paParms;
    622                                 pClient->fReadPending         = true;
     620                                pSvcCtx->asyncRead.callHandle = callHandle;
     621                                pSvcCtx->asyncRead.paParms    = paParms;
     622                                pSvcCtx->fReadPending         = true;
    623623                                fAsynchronousProcessing = true;
    624624                                VBoxSvcClipboardUnlock();
     
    684684                        else
    685685                        {
    686                             VBoxClipboardSvcImplWriteData (pClient, pv, cb, u32Format);
     686                            VBoxClipboardSvcImplWriteData (pSvcCtx, pv, cb, u32Format);
    687687                        }
    688688                    }
     
    720720    if (VBoxSvcClipboardLock())  /* if not can we do anything useful? */
    721721    {
    722         callHandle   = pClient->asyncRead.callHandle;
    723         paParms      = pClient->asyncRead.paParms;
    724         fReadPending = pClient->fReadPending;
    725         pClient->fReadPending = false;
     722        callHandle   = pSvcCtx->asyncRead.callHandle;
     723        paParms      = pSvcCtx->asyncRead.paParms;
     724        fReadPending = pSvcCtx->fReadPending;
     725        pSvcCtx->fReadPending = false;
    726726        VBoxSvcClipboardUnlock();
    727727    }
     
    831831       with the high bit set. */
    832832    SSMR3PutU32(pSSM, UINT32_C(0x80000002));
    833     int rc = SSMR3PutStructEx(pSSM, pClient, sizeof(*pClient), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
     833    int rc = SSMR3PutStructEx(pSSM, pSvcCtx, sizeof(*pSvcCtx), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
    834834    AssertRCReturn(rc, rc);
    835835
     
    894894
    895895    /* Existing client can not be in async state yet. */
    896     Assert(!pClient->fAsync);
     896    Assert(!pSvcCtx->fAsync);
    897897
    898898    /* Save the client ID for data validation. */
    899899    /** @todo isn't this the same as u32ClientID? Playing safe for now... */
    900     uint32_t const u32ClientIDOld = pClient->u32ClientID;
     900    uint32_t const u32ClientIDOld = pSvcCtx->u32ClientID;
    901901
    902902    /* Restore the client data. */
     
    906906    if (lenOrVer == UINT32_C(0x80000002))
    907907    {
    908         rc = SSMR3GetStructEx(pSSM, pClient, sizeof(*pClient), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
     908        rc = SSMR3GetStructEx(pSSM, pSvcCtx, sizeof(*pSvcCtx), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
    909909        AssertRCReturn(rc, rc);
    910910    }
     
    937937        AssertRCReturn(rc, rc);
    938938
    939         pClient->fHostMsgQuit       = savedState.fHostMsgQuit;
    940         pClient->fHostMsgReadData   = savedState.fHostMsgReadData;
    941         pClient->fHostMsgFormats    = savedState.fHostMsgFormats;
    942         pClient->u32RequestedFormat = savedState.u32RequestedFormat;
     939        pSvcCtx->fHostMsgQuit       = savedState.fHostMsgQuit;
     940        pSvcCtx->fHostMsgReadData   = savedState.fHostMsgReadData;
     941        pSvcCtx->fHostMsgFormats    = savedState.fHostMsgFormats;
     942        pSvcCtx->u32RequestedFormat = savedState.u32RequestedFormat;
    943943    }
    944944    else
     
    949949
    950950    /* Verify the client ID. */
    951     if (pClient->u32ClientID != u32ClientIDOld)
    952     {
    953         LogFunc(("Client ID mismatch: expected %d, got %d\n", u32ClientIDOld, pClient->u32ClientID));
    954         pClient->u32ClientID = u32ClientIDOld;
     951    if (pSvcCtx->u32ClientID != u32ClientIDOld)
     952    {
     953        LogFunc(("Client ID mismatch: expected %d, got %d\n", u32ClientIDOld, pSvcCtx->u32ClientID));
     954        pSvcCtx->u32ClientID = u32ClientIDOld;
    955955        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    956956    }
    957957
    958958    /* Actual host data are to be reported to guest (SYNC). */
    959     VBoxClipboardSvcImplSync(pClient);
     959    VBoxClipboardSvcImplSync(pSvcCtx);
    960960
    961961#else  /* UNIT_TEST*/
     
    968968{
    969969    RT_NOREF2(pvData, cbData);
    970     if (g_pClient != NULL)
     970    if (g_pSvcCtx != NULL)
    971971    {
    972972        switch (u32Function)
     
    982982                else
    983983                {
    984                     vboxSvcClipboardReportMsg (g_pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, u32Format);
     984                    vboxSvcClipboardReportMsg (g_pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, u32Format);
    985985                }
    986986            } break;
     
    988988            case VBOX_CLIPBOARD_EXT_FN_DATA_READ:
    989989            {
    990                 vboxSvcClipboardReportMsg (g_pClient, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format);
     990                vboxSvcClipboardReportMsg (g_pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format);
    991991            } break;
    992992
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp

    r78579 r78580  
    275275int VBoxClipboardSvcImplInit() { return VINF_SUCCESS; }
    276276void VBoxClipboardSvcImplDestroy() { }
    277 void VBoxClipboardSvcImplDisconnect(_VBOXCLIPBOARDCLIENTDATA *) { AssertFailed(); }
    278 int VBoxClipboardSvcImplConnect(_VBOXCLIPBOARDCLIENTDATA *, bool)
     277void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX) { AssertFailed(); }
     278int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX, bool)
    279279{ AssertFailed(); return VERR_WRONG_ORDER; }
    280 void VBoxClipboardSvcImplFormatAnnounce(_VBOXCLIPBOARDCLIENTDATA *, unsigned int)
     280void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX, unsigned int)
    281281{ AssertFailed(); }
    282 int VBoxClipboardSvcImplReadData(_VBOXCLIPBOARDCLIENTDATA *, unsigned int, void *, unsigned int, unsigned int *)
     282int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX, unsigned int, void *, unsigned int, unsigned int *)
    283283{ AssertFailed(); return VERR_WRONG_ORDER; }
    284 void VBoxClipboardSvcImplWriteData(_VBOXCLIPBOARDCLIENTDATA *, void *, unsigned int, unsigned int) { AssertFailed(); }
    285 int VBoxClipboardSvcImplSync(_VBOXCLIPBOARDCLIENTDATA *)
     284void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDSVCCTX, void *, unsigned int, unsigned int) { AssertFailed(); }
     285int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX)
    286286{ AssertFailed(); return VERR_WRONG_ORDER; }
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