VirtualBox

Changeset 78618 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 21, 2019 8:36:42 AM (6 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Update.

Location:
trunk/src/VBox
Files:
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/Makefile.kmk

    r78307 r78618  
    111111        $(if $(VBOX_WITH_GUEST_PROPS),VBOX_WITH_GUEST_PROPS,) \
    112112        $(if $(VBOX_WITH_SHARED_CLIPBOARD),VBOX_WITH_SHARED_CLIPBOARD,) \
     113    $(if $(VBOX_WITH_SHARED_CLIPBOARD_URI_LIST),VBOX_WITH_SHARED_CLIPBOARD_URI_LIST,) \
    113114        $(if $(VBOX_WITH_SHARED_FOLDERS),VBOX_WITH_SHARED_FOLDERS,) \
    114115        $(if $(VBOX_WITH_GUEST_CONTROL),VBOX_WITH_GUEST_CONTROL,)
     
    118119        VBoxGuestR3LibAutoLogon.cpp \
    119120        VBoxGuestR3LibBalloon.cpp \
    120         VBoxGuestR3LibClipboard.cpp \
    121121        VBoxGuestR3LibCoreDump.cpp \
    122122        VBoxGuestR3LibCpuHotPlug.cpp \
     
    146146        VBoxGuestR3LibHostVersion.cpp
    147147endif
     148ifdef VBOX_WITH_SHARED_CLIPBOARD
     149 VBoxGuestR3Lib_SOURCES   += \
     150        VBoxGuestR3LibClipboard.cpp
     151endif
    148152ifdef VBOX_WITH_SHARED_FOLDERS
    149153 VBoxGuestR3Lib_SOURCES   += \
     
    160164 VBoxGuestR3Lib_SOURCES   += \
    161165        VBoxGuestR3LibDragAndDrop.cpp
    162 endif
    163 ifdef VBOX_WITH_SHARED_CLIPBOARD
    164  VBoxGuestR3Lib_DEFS      += \
    165         $(if $(VBOX_WITH_SHARED_CLIPBOARD_URI_LIST),VBOX_WITH_SHARED_CLIPBOARD_URI_LIST,)
    166166endif
    167167
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardCache.cpp

    r78581 r78618  
    252252}
    253253
    254 int SharedClipboardCache::Reset(bool fRemoveDropDir)
     254int SharedClipboardCache::Reset(bool fDeleteContent)
    255255{
    256256    int rc = closeInternal();
    257257    if (RT_SUCCESS(rc))
    258258    {
    259         if (fRemoveDropDir)
     259        if (fDeleteContent)
    260260        {
    261261            rc = Rollback();
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp

    r78580 r78618  
    4444    PasteboardRef pasteboard;
    4545
    46     PVBOXCLIPBOARDSVCCTX pSvcCtx;
     46    PVBOXCLIPBOARDCLIENTDATA pClientData;
    4747};
    4848
     
    6363static int vboxClipboardChanged(VBOXCLIPBOARDCONTEXT *pCtx)
    6464{
    65     if (pCtx->pSvcCtx == NULL)
     65    if (pCtx->pClientData == NULL)
    6666        return VINF_SUCCESS;
    6767
     
    7272    if (RT_SUCCESS(rc) && fChanged)
    7373    {
    74         vboxSvcClipboardReportMsg(pCtx->pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, fFormats);
     74        vboxSvcClipboardReportMsg(pCtx->pClientData, 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.pSvcCtx = NULL;
     159    g_ctx.pClientData = NULL;
    160160}
    161161
     
    163163 * Enable the shared clipboard - called by the hgcm clipboard subsystem.
    164164 *
    165  * @param   pSvcCtx Structure containing context information about the guest system
    166  * @param   fHeadless Whether headless.
     165 * @param   pClientData Structure containing context information about the guest system
     166 * @param   fHeadless   Whether headless.
    167167 * @returns RT status code
    168168 */
    169 int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX pSvcCtx, bool fHeadless)
     169int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA pClientData, bool fHeadless)
    170170{
    171171    NOREF(fHeadless);
    172     if (g_ctx.pSvcCtx != NULL)
     172    if (g_ctx.pClientData != NULL)
    173173    {
    174174        /* One client only. */
     
    178178    VBoxSvcClipboardLock();
    179179
    180     pSvcCtx->pCtx = &g_ctx;
    181     pSvcCtx->pCtx->pSvcCtx = pSvcCtx;
     180    pClientData->State.pCtx = &g_ctx;
     181    pClientData->State.pCtx->pClientData = pClientData;
    182182
    183183    /* Initially sync the host clipboard content with the client. */
    184     int rc = VBoxClipboardSvcImplSync(pSvcCtx);
     184    int rc = VBoxClipboardSvcImplSync(pClientData);
    185185
    186186    VBoxSvcClipboardUnlock();
     
    192192 * after a save and restore of the guest.
    193193 */
    194 int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX pSvcCtx)
     194int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA pClientData)
    195195{
    196196    /* Sync the host clipboard content with the client. */
    197197    VBoxSvcClipboardLock();
    198     int rc = vboxClipboardChanged(pSvcCtx->pCtx);
     198    int rc = vboxClipboardChanged(pClientData->State.pCtx);
    199199    VBoxSvcClipboardUnlock();
    200200
     
    205205 * Shut down the shared clipboard subsystem and "disconnect" the guest.
    206206 */
    207 void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX pSvcCtx)
     207void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA pClientData)
    208208{
    209209    Log(("vboxClipboardDisconnect\n"));
    210210
    211211    VBoxSvcClipboardLock();
    212     pSvcCtx->pCtx->pSvcCtx = NULL;
     212    pClientData->State.pCtx->pClientData = NULL;
    213213    VBoxSvcClipboardUnlock();
    214214}
     
    218218 * subsystem.
    219219 *
    220  * @param pSvcCtx    Context data for the guest system
    221  * @param u32Formats Clipboard formats the guest is offering
    222  */
    223 void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats)
     220 * @param pClientData    Context data for the guest system
     221 * @param u32Formats     Clipboard formats the guest is offering
     222 */
     223void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Formats)
    224224{
    225225    Log(("vboxClipboardFormatAnnounce u32Formats %02X\n", u32Formats));
     
    230230    }
    231231
    232     vboxSvcClipboardReportMsg(pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Formats);
     232    vboxSvcClipboardReportMsg(pClientData, 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 pSvcCtx   Context information about the guest VM
    239  * @param u32Format The format that the guest would like to receive the data in
    240  * @param pv        Where to write the data to
    241  * @param cb        The size of the buffer to write the data to
    242  * @param pcbActual Where to write the actual size of the written data
    243  */
    244 int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Format,
     238 * @param pClientData   Context information about the guest VM
     239 * @param u32Format     The format that the guest would like to receive the data in
     240 * @param pv            Where to write the data to
     241 * @param cb            The size of the buffer to write the data to
     242 * @param pcbActual     Where to write the actual size of the written data
     243 */
     244int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Format,
    245245                          void *pv, uint32_t cb, uint32_t *pcbActual)
    246246{
     
    249249    /* Default to no data available. */
    250250    *pcbActual = 0;
    251     int rc = readFromPasteboard(pSvcCtx->pCtx->pasteboard, u32Format, pv, cb, pcbActual);
     251    int rc = readFromPasteboard(pClientData->State.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 pSvcCtx   Context information about the guest VM
    261  * @param pv        Buffer to which the data was written
    262  * @param cb        The size of the data written
    263  * @param u32Format The format of the data written
    264  */
    265 void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDSVCCTX pSvcCtx, void *pv, uint32_t cb, uint32_t u32Format)
    266 {
    267     VBoxSvcClipboardLock();
    268 
    269     writeToPasteboard(pSvcCtx->pCtx->pasteboard, pv, cb, u32Format);
    270 
    271     VBoxSvcClipboardUnlock();
    272 }
     260 * @param pClientData   Context information about the guest VM
     261 * @param pv            Buffer to which the data was written
     262 * @param cb            The size of the data written
     263 * @param u32Format     The format of the data written
     264 */
     265void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData, void *pv, uint32_t cb, uint32_t u32Format)
     266{
     267    VBoxSvcClipboardLock();
     268
     269    writeToPasteboard(pClientData->State.pCtx->pasteboard, pv, cb, u32Format);
     270
     271    VBoxSvcClipboardUnlock();
     272}
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r78617 r78618  
    1616 */
    1717
    18 #ifndef VBOX_INCLUDED_SRC_SharedClipboard_VBoxClipboard_h
    19 #define VBOX_INCLUDED_SRC_SharedClipboard_VBoxClipboard_h
     18#ifndef VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h
     19#define VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2626
    2727#include <VBox/GuestHost/SharedClipboard.h>
     28#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     29# include <VBox/GuestHost/SharedClipboard-uri.h>
     30#endif
    2831
    29 typedef struct _VBOXCLIPBOARDSVCCTX
     32#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     33typedef struct _VBOXCLIPBOARDCLIENTURIDATA
    3034{
    31     struct _VBOXCLIPBOARDSVCCTX *pNext;
    32     struct _VBOXCLIPBOARDSVCCTX *pPrev;
     35    SharedClipboardCache        Cache;
     36} VBOXCLIPBOARDCLIENTURIDATA, *PVBOXCLIPBOARDCLIENTURIDATA;
     37#endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
     38
     39/**
     40 * Structure for keeping generic client state data within the Shared Clipboard host service.
     41 * This structure needs to be serializable by SSM.
     42 */
     43typedef struct _VBOXCLIPBOARDCLIENTSTATE
     44{
     45    struct _VBOXCLIPBOARDCLIENTSTATE *pNext;
     46    struct _VBOXCLIPBOARDCLIENTSTATE *pPrev;
    3347
    3448    VBOXCLIPBOARDCONTEXT *pCtx;
     
    6579    uint32_t u32AvailableFormats;
    6680    uint32_t u32RequestedFormat;
     81} VBOXCLIPBOARDCLIENTSTATE, *PVBOXCLIPBOARDCLIENTSTATE;
    6782
    68 } VBOXCLIPBOARDSVCCTX, *PVBOXCLIPBOARDSVCCTX;
     83/**
     84 * Structure for keeping a HGCM client state within the Shared Clipboard host service.
     85 */
     86typedef struct _VBOXCLIPBOARDCLIENTDATA
     87{
     88    /** General client state data. */
     89    VBOXCLIPBOARDCLIENTSTATE   State;
     90#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     91    /** Data related to URI handling. */
     92    VBOXCLIPBOARDCLIENTURIDATA URI;
     93#endif
     94} VBOXCLIPBOARDCLIENTDATA, *PVBOXCLIPBOARDCLIENTDATA;
    6995
    7096/*
    7197 * The service functions. Locking is between the service thread and the platform dependent windows thread.
    7298 */
    73 void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Msg, uint32_t u32Formats);
    74 void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, int rc, uint32_t cbActual);
     99uint32_t vboxSvcClipboardGetMode(void);
     100void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Msg, uint32_t u32Formats);
     101void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, int rc, uint32_t cbActual);
    75102
    76103/*
     
    80107void VBoxClipboardSvcImplDestroy(void);
    81108
    82 int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX pSvcCtx, bool fHeadless);
    83 void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX pSvcCtx);
    84 void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats);
    85 int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual);
    86 void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDSVCCTX pSvcCtx, void *pv, uint32_t cb, uint32_t u32Format);
    87 int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX pSvcCtx);
     109int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA pClientData, bool fHeadless);
     110void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA pClientData);
     111void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Formats);
     112int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual);
     113void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData, void *pv, uint32_t cb, uint32_t u32Format);
     114int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA pClientData);
    88115
    89116/* Host unit testing interface */
     
    92119#endif
    93120
    94 #endif /* !VBOX_INCLUDED_SRC_SharedClipboard_VBoxClipboard_h */
     121#endif /* !VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_internal_h */
    95122
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.cpp

    r78501 r78618  
    2323#include <VBox/HostServices/VBoxClipboardSvc.h>
    2424
     25#include "VBoxSharedClipboardSvc-internal.h"
    2526#include "VBoxSharedClipboardSvc-uri.h"
    2627
     28
     29int vboxClipboardSvcURICreate(PVBOXCLIPBOARDCLIENTURIDATA pURIData, uint32_t uClientID)
     30{
     31    RT_NOREF(pURIData, uClientID);
     32
     33    int rc = pURIData->Cache.OpenTemp(SHAREDCLIPBOARDCACHE_FLAGS_NONE);
     34    if (RT_SUCCESS(rc))
     35    {
     36    }
     37
     38    return rc;
     39}
     40
     41void vboxClipboardSvcURIDestroy(PVBOXCLIPBOARDCLIENTURIDATA pURIData)
     42{
     43    int rc = pURIData->Cache.Rollback();
     44    if (RT_SUCCESS(rc))
     45        rc = pURIData->Cache.Close();
     46}
    2747
    2848int vboxClipboardSvcURIHandler(uint32_t u32ClientID,
     
    3454                               bool *pfAsync)
    3555{
    36     RT_NOREF(u32ClientID, pvClient, u32Function, cParms, paParms, tsArrival, pfAsync);
    37 
    38     return VINF_SUCCESS;
     56    RT_NOREF(u32ClientID, pvClient, paParms, tsArrival, pfAsync);
     57
     58    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient;
     59    RT_NOREF(pClientData);
     60
     61    /* Check if we've the right mode set. */
     62    int rc = VERR_ACCESS_DENIED; /* Play safe. */
     63
     64    switch (u32Function)
     65    {
     66        case VBOX_SHARED_CLIPBOARD_FN_READ_DATA_HDR:
     67            RT_FALL_THROUGH();
     68        case VBOX_SHARED_CLIPBOARD_FN_READ_DIR:
     69            RT_FALL_THROUGH();
     70        case VBOX_SHARED_CLIPBOARD_FN_READ_FILE_HDR:
     71            RT_FALL_THROUGH();
     72        case VBOX_SHARED_CLIPBOARD_FN_READ_FILE_DATA:
     73        {
     74            if (   vboxSvcClipboardGetMode() == VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
     75                || vboxSvcClipboardGetMode() == VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     76            {
     77                rc = VINF_SUCCESS;
     78            }
     79
     80            if (RT_FAILURE(rc))
     81                LogFunc(("Guest -> Host Shared Clipboard mode disabled, ignoring request\n"));
     82            break;
     83        }
     84
     85        case VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR:
     86            RT_FALL_THROUGH();
     87        case VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR:
     88            RT_FALL_THROUGH();
     89        case VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA:
     90            RT_FALL_THROUGH();
     91        case VBOX_SHARED_CLIPBOARD_FN_WRITE_CANCEL:
     92            RT_FALL_THROUGH();
     93        case VBOX_SHARED_CLIPBOARD_FN_WRITE_ERROR:
     94        {
     95            if (   vboxSvcClipboardGetMode() == VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST
     96                || vboxSvcClipboardGetMode() == VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     97            {
     98                rc = VINF_SUCCESS;
     99            }
     100
     101            if (RT_FAILURE(rc))
     102                LogFunc(("Clipboard: Host -> Guest Shared Clipboard mode disabled, ignoring request\n"));
     103            break;
     104        }
     105
     106        default:
     107            break;
     108    }
     109
     110    if (RT_FAILURE(rc))
     111        return rc;
     112
     113    rc = VERR_INVALID_PARAMETER; /* Play safe. */
     114
     115    switch (u32Function)
     116    {
     117        case VBOX_SHARED_CLIPBOARD_FN_READ_DATA_HDR:
     118        {
     119            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_DATA_HDR\n"));
     120            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     121            break;
     122        }
     123
     124        case VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR:
     125        {
     126            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR\n"));
     127            if (cParms == 12)
     128            {
     129                VBOXCLIPBOARDCBWRITEDATAHDRDATA data;
     130                RT_ZERO(data);
     131                data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_DATA_HDR;
     132                rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID);
     133                if (RT_SUCCESS(rc))
     134                    rc = HGCMSvcGetU32(&paParms[1], &data.data.uFlags);
     135                if (RT_SUCCESS(rc))
     136                    rc = HGCMSvcGetU32(&paParms[2], &data.data.uScreenId);
     137                if (RT_SUCCESS(rc))
     138                    rc = HGCMSvcGetU64(&paParms[3], &data.data.cbTotal);
     139                if (RT_SUCCESS(rc))
     140                    rc = HGCMSvcGetU32(&paParms[4], &data.data.cbMeta);
     141                if (RT_SUCCESS(rc))
     142                    rc = HGCMSvcGetPv(&paParms[5], &data.data.pvMetaFmt, &data.data.cbMetaFmt);
     143                if (RT_SUCCESS(rc))
     144                    rc = HGCMSvcGetU32(&paParms[6], &data.data.cbMetaFmt);
     145                if (RT_SUCCESS(rc))
     146                    rc = HGCMSvcGetU64(&paParms[7], &data.data.cObjects);
     147                if (RT_SUCCESS(rc))
     148                    rc = HGCMSvcGetU32(&paParms[8], &data.data.enmCompression);
     149                if (RT_SUCCESS(rc))
     150                    rc = HGCMSvcGetU32(&paParms[9], (uint32_t *)&data.data.enmChecksumType);
     151                if (RT_SUCCESS(rc))
     152                    rc = HGCMSvcGetPv(&paParms[10], &data.data.pvChecksum, &data.data.cbChecksum);
     153                if (RT_SUCCESS(rc))
     154                    rc = HGCMSvcGetU32(&paParms[11], &data.data.cbChecksum);
     155
     156                LogFlowFunc(("fFlags=0x%x, cbTotalSize=%RU64, cObj=%RU64\n",
     157                             data.data.uFlags, data.data.cbTotal, data.data.cObjects));
     158            }
     159
     160            break;
     161        }
     162
     163        case VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK:
     164        {
     165            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK\n"));
     166            if (cParms == 5)
     167            {
     168                VBOXCLIPBOARDCBDATADATA data;
     169                RT_ZERO(data);
     170                data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_DATA_CHUNK;
     171                rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID);
     172                if (RT_SUCCESS(rc))
     173                    rc = HGCMSvcGetPv(&paParms[1], (void**)&data.data.pvData, &data.data.cbData);
     174                if (RT_SUCCESS(rc))
     175                    rc = HGCMSvcGetU32(&paParms[2], &data.data.cbData);
     176                if (RT_SUCCESS(rc))
     177                    rc = HGCMSvcGetPv(&paParms[3], (void**)&data.data.pvChecksum, &data.data.cbChecksum);
     178                if (RT_SUCCESS(rc))
     179                    rc = HGCMSvcGetU32(&paParms[4], &data.data.cbChecksum);
     180            }
     181            break;
     182        }
     183
     184        case VBOX_SHARED_CLIPBOARD_FN_READ_DIR:
     185        {
     186            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_DIR\n"));
     187            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     188            break;
     189        }
     190
     191        case VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR:
     192        {
     193            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR\n"));
     194            if (cParms == 4)
     195            {
     196                VBOXCLIPBOARDCBWRITEDIRDATA data;
     197                RT_ZERO(data);
     198                data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_DIR;
     199
     200                rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID);
     201                if (RT_SUCCESS(rc))
     202                    rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pszPath, &data.cbPath);
     203                if (RT_SUCCESS(rc))
     204                    rc = HGCMSvcGetU32(&paParms[2], &data.cbPath);
     205                if (RT_SUCCESS(rc))
     206                    rc = HGCMSvcGetU32(&paParms[3], &data.fMode);
     207            }
     208            break;
     209        }
     210
     211        case VBOX_SHARED_CLIPBOARD_FN_READ_FILE_HDR:
     212        {
     213            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_FILE_HDR\n"));
     214            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     215            break;
     216        }
     217
     218        case VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR:
     219        {
     220            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR\n"));
     221            if (cParms == 6)
     222            {
     223                VBOXCLIPBOARDCBWRITEFILEHDRDATA data;
     224                RT_ZERO(data);
     225                data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_FILE_HDR;
     226
     227                rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID);
     228                if (RT_SUCCESS(rc))
     229                    rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pszFilePath, &data.cbFilePath);
     230                if (RT_SUCCESS(rc))
     231                    rc = HGCMSvcGetU32(&paParms[2], &data.cbFilePath);
     232                if (RT_SUCCESS(rc))
     233                    rc = HGCMSvcGetU32(&paParms[3], &data.fFlags);
     234                if (RT_SUCCESS(rc))
     235                    rc = HGCMSvcGetU32(&paParms[4], &data.fMode);
     236                if (RT_SUCCESS(rc))
     237                    rc = HGCMSvcGetU64(&paParms[5], &data.cbSize);
     238
     239                LogFlowFunc(("pszPath=%s, cbPath=%RU32, fMode=0x%x, cbSize=%RU64\n",
     240                             data.pszFilePath, data.cbFilePath, data.fMode, data.cbSize));
     241            }
     242            break;
     243        }
     244
     245        case VBOX_SHARED_CLIPBOARD_FN_READ_FILE_DATA:
     246        {
     247            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_FILE_DATA\n"));
     248            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     249            break;
     250        }
     251
     252        case VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA:
     253        {
     254            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA\n"));
     255            if (cParms == 5)
     256            {
     257                VBOXCLIPBOARDCBWRITEFILEDATADATA data;
     258                RT_ZERO(data);
     259                data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_FILE_DATA;
     260
     261                rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID);
     262                if (RT_SUCCESS(rc))
     263                    rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pvData, &data.cbData);
     264                if (RT_SUCCESS(rc))
     265                    rc = HGCMSvcGetU32(&paParms[2], &data.cbData);
     266                if (RT_SUCCESS(rc))
     267                    rc = HGCMSvcGetPv(&paParms[3], (void**)&data.pvChecksum, &data.cbChecksum);
     268                if (RT_SUCCESS(rc))
     269                    rc = HGCMSvcGetU32(&paParms[4], &data.cbChecksum);
     270
     271                LogFlowFunc(("pvData=0x%p, cbData=%RU32\n", data.pvData, data.cbData));
     272            }
     273            break;
     274        }
     275
     276        case VBOX_SHARED_CLIPBOARD_FN_WRITE_CANCEL:
     277            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_CANCEL\n"));
     278            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     279            break;
     280
     281        case VBOX_SHARED_CLIPBOARD_FN_WRITE_ERROR:
     282            LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_ERROR\n"));
     283            AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     284            break;
     285
     286        default:
     287            AssertMsgFailed(("Not implemented\n"));
     288            break;
     289    }
     290
     291    return rc;
    39292}
    40293
     
    43296                                   VBOXHGCMSVCPARM paParms[])
    44297{
    45     RT_NOREF(u32Function, cParms, paParms);
    46 
    47     return VINF_SUCCESS;
     298    RT_NOREF(cParms, paParms);
     299
     300    int rc = VERR_INVALID_PARAMETER; /* Play safe. */
     301
     302    switch (u32Function)
     303    {
     304        case VBOX_SHARED_CLIPBOARD_HOST_FN_CANCEL:
     305            break;
     306
     307        case VBOX_SHARED_CLIPBOARD_HOST_FN_ERROR:
     308            break;
     309
     310        default:
     311            AssertMsgFailed(("Not implemented\n"));
     312            break;
     313
     314    }
     315
     316    return rc;
    48317}
    49318
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.h

    r78501 r78618  
    2222#endif
    2323
    24 int vboxClipboardSvcURIHandler(uint32_t u32ClientID,
    25                                void *pvClient,
    26                                uint32_t u32Function,
    27                                 uint32_t cParms,
    28                                VBOXHGCMSVCPARM paParms[],
    29                                uint64_t tsArrival,
    30                                bool *pfAsync);
    31 
    32 int vboxClipboardSvcURIHostHandler(uint32_t u32Function,
    33                                    uint32_t cParms,
    34                                    VBOXHGCMSVCPARM paParms[]);
     24int vboxClipboardSvcURICreate(PVBOXCLIPBOARDCLIENTURIDATA pURIData);
     25void vboxClipboardSvcURIDestroy(PVBOXCLIPBOARDCLIENTURIDATA pURIData);
     26int vboxClipboardSvcURIHandler(uint32_t u32ClientID, void *pvClient, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival, bool *pfAsync);
     27int vboxClipboardSvcURIHostHandler(uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    3528
    3629#endif /* !VBOX_INCLUDED_SRC_SharedClipboard_VBoxSharedClipboardSvc_uri_h */
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

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

    r78580 r78618  
    5555  * Enable the shared clipboard - called by the hgcm clipboard subsystem.
    5656  *
    57   * @param   pSvcCtx    Structure containing context information about the guest system
    58   * @param   fHeadless  Whether headless.
     57  * @param   pClientData    Structure containing context information about the guest system
     58  * @param   fHeadless      Whether headless.
    5959  * @returns RT status code
    6060  */
    61 int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX pSvcCtx, bool fHeadless)
     61int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA pClientData, bool fHeadless)
    6262{
    63     RT_NOREF(pSvcCtx, fHeadless);
     63    RT_NOREF(pClientData, 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 /* pSvcCtx */)
     72int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA /* pClientData */)
    7373{
    7474    LogFlowFunc(("called, returning VINF_SUCCESS.\n"));
     
    7979 * Shut down the shared clipboard subsystem and "disconnect" the guest.
    8080 *
    81  * @param   pSvcCtx    Structure containing context information about the guest system
     81 * @param   pClientData    Structure containing context information about the guest system
    8282 */
    83 void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX pSvcCtx)
     83void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA pClientData)
    8484{
    85     RT_NOREF(pSvcCtx);
     85    RT_NOREF(pClientData);
    8686    LogFlowFunc(("called, returning.\n"));
    8787}
     
    9191 * subsystem.
    9292 *
    93  * @param pSvcCtx    Context data for the guest system
     93 * @param pClientData    Context data for the guest system
    9494 * @param u32Formats Clipboard formats the guest is offering
    9595 */
    96 void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats)
     96void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Formats)
    9797{
    98     RT_NOREF(pSvcCtx, u32Formats);
     98    RT_NOREF(pClientData, 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 pSvcCtx   Context information about the guest VM
    106  * @param u32Format The format that the guest would like to receive the data in
    107  * @param pv        Where to write the data to
    108  * @param cb        The size of the buffer to write the data to
    109  * @param pcbActual Where to write the actual size of the written data
     105 * @param pClientData   Context information about the guest VM
     106 * @param u32Format     The format that the guest would like to receive the data in
     107 * @param pv            Where to write the data to
     108 * @param cb            The size of the buffer to write the data to
     109 * @param pcbActual     Where to write the actual size of the written data
    110110 */
    111 int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Format,
     111int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Format,
    112112                          void *pv, uint32_t cb, uint32_t *pcbActual)
    113113{
    114     RT_NOREF(pSvcCtx, u32Format, pv, cb);
     114    RT_NOREF(pClientData, 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 pSvcCtx   Context information about the guest VM
    125  * @param pv        Buffer to which the data was written
    126  * @param cb        The size of the data written
    127  * @param u32Format The format of the data written
     124 * @param pClientData   Context information about the guest VM
     125 * @param pv            Buffer to which the data was written
     126 * @param cb            The size of the data written
     127 * @param u32Format     The format of the data written
    128128 */
    129 void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDSVCCTX pSvcCtx, void *pv, uint32_t cb,
     129void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData, void *pv, uint32_t cb,
    130130                            uint32_t u32Format)
    131131{
    132     RT_NOREF(pSvcCtx, pv, cb, u32Format);
     132    RT_NOREF(pClientData, pv, cb, u32Format);
    133133    LogFlowFunc(("called, returning.\n"));
    134134}
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp

    r78582 r78618  
    3232#include <VBox/err.h>
    3333
    34 #include "VBoxClipboard.h"
     34#include "VBoxSharedClipboardSvc-internal.h"
    3535
    3636
     
    5959    CLIPBACKEND *pBackend;
    6060    /** Pointer to the VBox host client data structure. */
    61     PVBOXCLIPBOARDSVCCTX pSvcCtx;
     61    PVBOXCLIPBOARDCLIENTDATA pClientData;
    6262    /** We set this when we start shutting down as a hint not to post any new
    6363     * requests. */
     
    7575void ClipReportX11Formats(VBOXCLIPBOARDCONTEXT *pCtx, uint32_t u32Formats)
    7676{
    77     LogRelFlowFunc(("called.  pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats));
    78     vboxSvcClipboardReportMsg(pCtx->pSvcCtx,
    79                               VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS,
    80                               u32Formats);
     77    LogFlowFunc(("pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats));
     78
     79    vboxSvcClipboardReportMsg(pCtx->pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, u32Formats);
    8180}
    8281
     
    105104 *        the clipboard and leave ownership to X11.
    106105 */
    107 int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX pSvcCtx, bool fHeadless)
     106int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA pClientData, bool fHeadless)
    108107{
    109108    int rc = VINF_SUCCESS;
    110     CLIPBACKEND *pBackend = NULL;
    111109
    112110    LogRel(("Starting host clipboard service\n"));
    113     VBOXCLIPBOARDCONTEXT *pCtx = (VBOXCLIPBOARDCONTEXT *)RTMemAllocZ(sizeof(VBOXCLIPBOARDCONTEXT));
     111
     112    PVBOXCLIPBOARDCONTEXT pCtx = (PVBOXCLIPBOARDCONTEXT)RTMemAllocZ(sizeof(VBOXCLIPBOARDCONTEXT));
    114113    if (!pCtx)
     114    {
    115115        rc = VERR_NO_MEMORY;
     116    }
    116117    else
    117118    {
    118119        RTCritSectInit(&pCtx->clipboardMutex);
    119         pBackend = ClipConstructX11(pCtx, fHeadless);
    120         if (pBackend == NULL)
     120        CLIPBACKEND *pBackend = ClipConstructX11(pCtx, fHeadless);
     121        if (!pBackend)
     122        {
    121123            rc = VERR_NO_MEMORY;
     124        }
    122125        else
    123126        {
    124127            pCtx->pBackend = pBackend;
    125             pSvcCtx->pCtx = pCtx;
    126             pCtx->pSvcCtx = pSvcCtx;
     128            pClientData->State.pCtx = pCtx;
     129            pCtx->pClientData = pClientData;
     130
    127131            rc = ClipStartX11(pBackend, true /* grab shared clipboard */);
     132            if (RT_FAILURE(rc))
     133                ClipDestructX11(pBackend);
    128134        }
     135
    129136        if (RT_FAILURE(rc))
     137        {
    130138            RTCritSectDelete(&pCtx->clipboardMutex);
    131     }
     139            RTMemFree(pCtx);
     140        }
     141    }
     142
    132143    if (RT_FAILURE(rc))
    133     {
    134         RTMemFree(pCtx);
    135         LogRel(("Failed to initialise the shared clipboard\n"));
    136     }
    137     LogRelFlowFunc(("returning %Rrc\n", rc));
     144        LogRel(("Failed to initialize the Shared Clipboard host service, rc=%Rrc\n", rc));
     145
     146    LogFlowFunc(("returning %Rrc\n", rc));
    138147    return rc;
    139148}
     
    144153 * @note  Host glue code
    145154 */
    146 int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX pSvcCtx)
     155int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA pClientData)
    147156{
    148157    /* Tell the guest we have no data in case X11 is not available.  If
    149158     * there is data in the host clipboard it will automatically be sent to
    150159     * the guest when the clipboard starts up. */
    151     vboxSvcClipboardReportMsg(pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, 0);
    152     /** @todo r=andy Check rc code. */
    153     return VINF_SUCCESS;
     160    vboxSvcClipboardReportMsg(pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, 0);
     161
     162    return VINF_SUCCESS; /** @todo r=andy Check rc code. */
    154163}
    155164
     
    158167 * @note  Host glue code
    159168 */
    160 void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX pSvcCtx)
    161 {
    162     LogRelFlow(("vboxClipboardDisconnect\n"));
     169void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA pClientData)
     170{
     171    LogFlowFuncEnter();
    163172
    164173    LogRel(("Stopping the host clipboard service\n"));
    165     VBOXCLIPBOARDCONTEXT *pCtx = pSvcCtx->pCtx;
     174
     175    PVBOXCLIPBOARDCONTEXT pCtx = pClientData->State.pCtx;
     176
    166177    /* Drop the reference to the client, in case it is still there.  This
    167178     * will cause any outstanding clipboard data requests from X11 to fail
    168179     * immediately. */
    169180    pCtx->fShuttingDown = true;
     181
    170182    /* If there is a currently pending request, release it immediately. */
    171     VBoxClipboardSvcImplWriteData(pSvcCtx, NULL, 0, 0);
     183    VBoxClipboardSvcImplWriteData(pClientData, NULL, 0, 0);
     184
    172185    int rc = ClipStopX11(pCtx->pBackend);
    173186    /** @todo handle this slightly more reasonably, or be really sure
    174187     *        it won't go wrong. */
    175188    AssertRC(rc);
     189
    176190    if (RT_SUCCESS(rc))  /* And if not? */
    177191    {
     
    185199 * VBox is taking possession of the shared clipboard.
    186200 *
    187  * @param pSvcCtx    Context data for the guest system
     201 * @param pClientData    Context data for the guest system
    188202 * @param u32Formats Clipboard formats the guest is offering
    189203 * @note  Host glue code
    190204 */
    191 void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Formats)
    192 {
    193     LogRelFlowFunc(("called.  pSvcCtx=%p, u32Formats=%02X\n", pSvcCtx, u32Formats));
    194 
    195     ClipAnnounceFormatToX11(pSvcCtx->pCtx->pBackend, u32Formats);
     205void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Formats)
     206{
     207    LogFlowFunc(("pClientData=%p, u32Formats=%02X\n", pClientData, u32Formats));
     208
     209    ClipAnnounceFormatToX11(pClientData->State.pCtx->pBackend, u32Formats);
    196210}
    197211
     
    214228 *          asynchronously
    215229 * @returns iprt status code on failure
    216  * @param  pSvcCtx   Context information about the guest VM
    217  * @param  u32Format The format that the guest would like to receive the data in
    218  * @param  pv        Where to write the data to
    219  * @param  cb        The size of the buffer to write the data to
     230 * @param  pClientData   Context information about the guest VM
     231 * @param  u32Format     The format that the guest would like to receive the data in
     232 * @param  pv            Where to write the data to
     233 * @param  cb            The size of the buffer to write the data to
    220234 * @param  pcbActual Where to write the actual size of the written data
     235 *
    221236 * @note   We always fail or complete asynchronously
    222237 * @note   On success allocates a CLIPREADCBREQ structure which must be
     
    225240 *
    226241 */
    227 int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx,
    228                           uint32_t u32Format, void *pv, uint32_t cb,
    229                           uint32_t *pcbActual)
    230 {
    231     LogRelFlowFunc(("pSvcCtx=%p, u32Format=%02X, pv=%p, cb=%u, pcbActual=%p",
    232                     pSvcCtx, u32Format, pv, cb, pcbActual));
     242int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData,
     243                          uint32_t u32Format, void *pv, uint32_t cb, uint32_t *pcbActual)
     244{
     245    LogFlowFunc(("pClientData=%p, u32Format=%02X, pv=%p, cb=%u, pcbActual=%p\n",
     246                 pClientData, u32Format, pv, cb, pcbActual));
    233247
    234248    int rc = VINF_SUCCESS;
    235249    CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)RTMemAlloc(sizeof(CLIPREADCBREQ));
    236250    if (!pReq)
     251    {
    237252        rc = VERR_NO_MEMORY;
     253    }
    238254    else
    239255    {
     
    241257        pReq->cb = cb;
    242258        pReq->pcbActual = pcbActual;
    243         rc = ClipRequestDataFromX11(pSvcCtx->pCtx->pBackend, u32Format, pReq);
     259        rc = ClipRequestDataFromX11(pClientData->State.pCtx->pBackend, u32Format, pReq);
    244260        if (RT_SUCCESS(rc))
    245261            rc = VINF_HGCM_ASYNC_EXECUTE;
    246262    }
    247     LogRelFlowFunc(("returning %Rrc\n", rc));
     263
     264    LogFlowFuncLeaveRC(rc);
    248265    return rc;
    249266}
     
    269286    RTMemFree(pReq);
    270287
    271     vboxSvcClipboardCompleteReadData(pCtx->pSvcCtx, rc, cb);
     288    vboxSvcClipboardCompleteReadData(pCtx->pClientData, rc, cb);
    272289}
    273290
     
    292309    int rc = VINF_SUCCESS;
    293310
    294     LogRelFlowFunc(("pCtx=%p, pReq=%p, u32Format=%02X\n", pCtx, pReq, u32Format));
     311    LogFlowFunc(("pCtx=%p, pReq=%p, u32Format=%02X\n", pCtx, pReq, u32Format));
    295312
    296313    /* Request data from VBox */
    297     vboxSvcClipboardReportMsg(pCtx->pSvcCtx,
     314    vboxSvcClipboardReportMsg(pCtx->pClientData,
    298315                              VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
    299316                              u32Format);
     
    302319     */
    303320    rc = RTSemEventWait(pReq->finished, CLIPBOARD_TIMEOUT);
     321
    304322    /* If the request hasn't yet completed then we cancel it.  We use
    305323     * the critical section to prevent these operations colliding. */
    306324    RTCritSectEnter(&pCtx->clipboardMutex);
     325
    307326    /* The data may have arrived between the semaphore timing out and
    308327     * our grabbing the mutex. */
     
    312331        pCtx->pReq = NULL;
    313332    Assert(pCtx->pReq == NULL);
     333
    314334    RTCritSectLeave(&pCtx->clipboardMutex);
     335
    315336    if (RT_SUCCESS(rc) && (pReq->pv == NULL))
    316337        rc = VERR_NO_DATA;
    317     LogRelFlowFunc(("returning %Rrc\n", rc));
     338
     339    LogFlowFuncLeaveRC(rc);
    318340    return rc;
    319341}
     
    325347    int rc = VINF_SUCCESS;
    326348
    327     LogRelFlowFunc(("pCtx=%p, pReq=%p, u32Format=%02X\n", pCtx, pReq, u32Format));
     349    LogFlowFunc(("pCtx=%p, pReq=%p, u32Format=%02X\n", pCtx, pReq, u32Format));
    328350
    329351    /* Start by "posting" the request for the next invocation of
    330352     * vboxClipboardWriteData. */
    331353    RTCritSectEnter(&pCtx->clipboardMutex);
     354
    332355    if (pCtx->pReq != NULL)
    333356    {
     
    339362    else
    340363        pCtx->pReq = pReq;
     364
    341365    RTCritSectLeave(&pCtx->clipboardMutex);
     366
    342367    if (RT_SUCCESS(rc))
    343368        rc = clipWaitForDataFromVBox(pCtx, pReq, u32Format);
    344     LogRelFlowFunc(("returning %Rrc\n", rc));
     369
     370    LogFlowFuncLeaveRC(rc);
    345371    return rc;
    346372}
     
    361387    VBOXCLIPBOARDREQFROMVBOX request = { NULL, 0, 0, NIL_RTSEMEVENT };
    362388
    363     LogRelFlowFunc(("pCtx=%p, u32Format=%02X, ppv=%p, pcb=%p\n", pCtx, u32Format, ppv, pcb));
     389    LogFlowFunc(("pCtx=%p, u32Format=%02X, ppv=%p, pcb=%p\n", pCtx, u32Format, ppv, pcb));
    364390
    365391    if (pCtx->fShuttingDown)
    366392    {
    367393        /* The shared clipboard is disconnecting. */
    368         LogRelFunc(("host requested guest clipboard data after guest had disconnected.\n"));
     394        LogRel(("Clipboard: Host requested guest clipboard data after guest had disconnected\n"));
    369395        return VERR_WRONG_ORDER;
    370396    }
     397
    371398    int rc = RTSemEventCreate(&request.finished);
    372399    if (RT_SUCCESS(rc))
     
    382409    }
    383410
    384     LogRelFlowFunc(("returning %Rrc\n", rc));
    385 
    386     if (RT_SUCCESS(rc))
    387         LogRelFlowFunc(("*ppv=%.*ls, *pcb=%u\n",*pcb / 2,*ppv,*pcb));
    388 
     411    LogFlowFuncLeaveRC(rc);
    389412    return rc;
    390413}
     
    393416 * Called when we have requested data from VBox and that data has arrived.
    394417 *
    395  * @param  pSvcCtx   Context information about the guest VM
    396  * @param  pv        Buffer to which the data was written
    397  * @param  cb        The size of the data written
    398  * @param  u32Format The format of the data written
     418 * @param  pClientData   Context information about the guest VM
     419 * @param  pv            Buffer to which the data was written
     420 * @param  cb            The size of the data written
     421 * @param  u32Format     The format of the data written
    399422 * @note   Host glue code
    400423 */
    401 void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDSVCCTX pSvcCtx,
    402                             void *pv, uint32_t cb, uint32_t u32Format)
    403 {
    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;
     424void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData,
     425                                   void *pv, uint32_t cb, uint32_t u32Format)
     426{
     427    LogFlowFunc(("pClientData=%p, pv=%p (%.*ls), cb=%u, u32Format=%02X\n", pClientData, pv, cb / 2, pv, cb, u32Format));
     428
     429    VBOXCLIPBOARDCONTEXT *pCtx = pClientData->State.pCtx;
    408430
    409431    /* Grab the mutex and check whether there is a pending request for data. */
     
    463485};
    464486
    465 void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Msg, uint32_t u32Formats)
     487void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Msg, uint32_t u32Formats)
    466488{
    467489    RT_NOREF(u32Formats);
    468     CLIPBACKEND *pBackend = pSvcCtx->pCtx->pBackend;
     490    CLIPBACKEND *pBackend = pClientData->State.pCtx->pBackend;
    469491
    470492    if ((u32Msg == VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA)
    471493        && !pBackend->writeData.timeout)
    472         VBoxClipboardSvcImplWriteData(pSvcCtx, pBackend->writeData.pv,
     494        VBoxClipboardSvcImplWriteData(pClientData, pBackend->writeData.pv,
    473495                               pBackend->writeData.cb,
    474496                               pBackend->writeData.format);
     
    477499}
    478500
    479 void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, int rc, uint32_t cbActual)
    480 {
    481     CLIPBACKEND *pBackend = pSvcCtx->pCtx->pBackend;
     501void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, int rc, uint32_t cbActual)
     502{
     503    CLIPBACKEND *pBackend = pClientData->State.pCtx->pBackend;
    482504    pBackend->completeRead.rc = rc;
    483505    pBackend->completeRead.cbActual = cbActual;
     
    523545int main()
    524546{
    525     VBOXCLIPBOARDSVCCTX client;
     547    VBOXCLIPBOARDCLIENTDATA client;
    526548    unsigned cErrors = 0;
    527549    int rc = RTR3InitExeNoArguments(0);
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r78581 r78618  
    8585#include <VBox/vmm/ssm.h>
    8686
    87 #include "VBoxClipboard.h"
     87#include "VBoxSharedClipboardSvc-internal.h"
    8888#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    8989# include "VBoxSharedClipboardSvc-uri.h"
     
    9696static PVBOXHGCMSVCHELPERS g_pHelpers;
    9797
    98 static RTCRITSECT critsect;
    99 static uint32_t g_u32Mode;
     98static RTCRITSECT g_CritSect;
     99static uint32_t g_uMode;
    100100
    101101static PFNHGCMSVCEXT g_pfnExtension;
    102102static void *g_pvExtension;
    103103
    104 static PVBOXCLIPBOARDSVCCTX g_pSvcCtx;
     104static PVBOXCLIPBOARDCLIENTDATA g_pClientData;
    105105
    106106/* Serialization of data reading and format announcements from the RDP client. */
     
    151151}
    152152
    153 
    154 static uint32_t vboxSvcClipboardMode(void)
    155 {
    156     return g_u32Mode;
     153uint32_t vboxSvcClipboardGetMode(void)
     154{
     155    return g_uMode;
    157156}
    158157
     
    161160uint32_t TestClipSvcGetMode(void)
    162161{
    163     return vboxSvcClipboardMode();
     162    return vboxSvcClipboardGetMode();
    164163}
    165164#endif
     
    179178        case VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST:
    180179        case VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL:
    181             g_u32Mode = u32Mode;
     180            g_uMode = u32Mode;
    182181            break;
    183182
    184183        default:
    185             g_u32Mode = VBOX_SHARED_CLIPBOARD_MODE_OFF;
     184            g_uMode = VBOX_SHARED_CLIPBOARD_MODE_OFF;
    186185    }
    187186}
     
    189188bool VBoxSvcClipboardLock(void)
    190189{
    191     return RT_SUCCESS(RTCritSectEnter(&critsect));
     190    return RT_SUCCESS(RTCritSectEnter(&g_CritSect));
    192191}
    193192
    194193void VBoxSvcClipboardUnlock(void)
    195194{
    196     RTCritSectLeave(&critsect);
     195    int rc2 = RTCritSectLeave(&g_CritSect);
     196    AssertRC(rc2);
    197197}
    198198
     
    200200 * Executed under the clipboard lock.
    201201 */
    202 static bool vboxSvcClipboardReturnMsg(PVBOXCLIPBOARDSVCCTX pSvcCtx, VBOXHGCMSVCPARM paParms[])
     202static bool vboxSvcClipboardReturnMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, VBOXHGCMSVCPARM paParms[])
    203203{
    204204    /* Message priority is taken into account. */
    205     if (pSvcCtx->fHostMsgQuit)
     205    if (pClientData->State.fHostMsgQuit)
    206206    {
    207207        LogFlowFunc(("vboxSvcClipboardReturnMsg: Quit\n"));
    208208        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT);
    209209        VBoxHGCMParmUInt32Set(&paParms[1], 0);
    210         pSvcCtx->fHostMsgQuit = false;
    211     }
    212     else if (pSvcCtx->fHostMsgReadData)
     210        pClientData->State.fHostMsgQuit = false;
     211    }
     212    else if (pClientData->State.fHostMsgReadData)
    213213    {
    214214        uint32_t fFormat = 0;
    215215
    216         LogFlowFunc(("vboxSvcClipboardReturnMsg: ReadData %02X\n", pSvcCtx->u32RequestedFormat));
    217         if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
     216        LogFlowFunc(("vboxSvcClipboardReturnMsg: ReadData %02X\n", pClientData->State.u32RequestedFormat));
     217        if (pClientData->State.u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
    218218            fFormat = VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT;
    219         else if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
     219        else if (pClientData->State.u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
    220220            fFormat = VBOX_SHARED_CLIPBOARD_FMT_BITMAP;
    221         else if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_HTML)
     221        else if (pClientData->State.u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_HTML)
    222222            fFormat = VBOX_SHARED_CLIPBOARD_FMT_HTML;
    223223#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    224         else if (pSvcCtx->u32RequestedFormat & VBOX_SHARED_CLIPBOARD_FMT_URI_LIST)
     224        else if (pClientData->State.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             pSvcCtx->u32RequestedFormat = 0;
     230            pClientData->State.u32RequestedFormat = 0;
    231231        }
    232         pSvcCtx->u32RequestedFormat &= ~fFormat;
     232        pClientData->State.u32RequestedFormat &= ~fFormat;
    233233        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA);
    234234        VBoxHGCMParmUInt32Set(&paParms[1], fFormat);
    235         if (pSvcCtx->u32RequestedFormat == 0)
    236             pSvcCtx->fHostMsgReadData = false;
    237     }
    238     else if (pSvcCtx->fHostMsgFormats)
    239     {
    240         LogFlowFunc(("vboxSvcClipboardReturnMsg: Formats %02X\n", pSvcCtx->u32AvailableFormats));
     235        if (pClientData->State.u32RequestedFormat == 0)
     236            pClientData->State.fHostMsgReadData = false;
     237    }
     238    else if (pClientData->State.fHostMsgFormats)
     239    {
     240        LogFlowFunc(("vboxSvcClipboardReturnMsg: Formats %02X\n", pClientData->State.u32AvailableFormats));
    241241        VBoxHGCMParmUInt32Set(&paParms[0], VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS);
    242         VBoxHGCMParmUInt32Set(&paParms[1], pSvcCtx->u32AvailableFormats);
    243         pSvcCtx->fHostMsgFormats = false;
     242        VBoxHGCMParmUInt32Set(&paParms[1], pClientData->State.u32AvailableFormats);
     243        pClientData->State.fHostMsgFormats = false;
    244244    }
    245245    else
     
    254254}
    255255
    256 void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDSVCCTX pSvcCtx, uint32_t u32Msg, uint32_t u32Formats)
    257 {
    258     AssertPtrReturnVoid(pSvcCtx);
     256void vboxSvcClipboardReportMsg(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Msg, uint32_t u32Formats)
     257{
     258    AssertPtrReturnVoid(pClientData);
    259259
    260260    if (VBoxSvcClipboardLock())
     
    265265            {
    266266                LogFlowFunc(("Quit\n"));
    267                 pSvcCtx->fHostMsgQuit = true;
     267                pClientData->State.fHostMsgQuit = true;
    268268            } break;
    269269            case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA:
    270270            {
    271                 if (   vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
    272                     && vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     271                if (   vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
     272                    && vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
    273273                {
    274274                    /* Skip the message. */
     
    277277
    278278                LogFlowFunc(("ReadData %02X\n", u32Formats));
    279                 pSvcCtx->u32RequestedFormat = u32Formats;
    280                 pSvcCtx->fHostMsgReadData = true;
     279                pClientData->State.u32RequestedFormat = u32Formats;
     280                pClientData->State.fHostMsgReadData = true;
    281281            } break;
    282282            case VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS:
    283283            {
    284                 if (   vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST
    285                     && vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     284                if (   vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST
     285                    && vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
    286286                {
    287287                    /* Skip the message. */
     
    290290
    291291                LogFlowFunc(("Formats %02X\n", u32Formats));
    292                 pSvcCtx->u32AvailableFormats = u32Formats;
    293                 pSvcCtx->fHostMsgFormats = true;
     292                pClientData->State.u32AvailableFormats = u32Formats;
     293                pClientData->State.fHostMsgFormats = true;
    294294            } break;
    295295            default:
     
    300300        }
    301301
    302         if (pSvcCtx->fAsync)
     302        if (pClientData->State.fAsync)
    303303        {
    304304            /* The client waits for a response. */
    305             bool fMessageReturned = vboxSvcClipboardReturnMsg(pSvcCtx, pSvcCtx->async.paParms);
     305            bool fMessageReturned = vboxSvcClipboardReturnMsg(pClientData, pClientData->State.async.paParms);
    306306
    307307            /* Make a copy of the handle. */
    308             VBOXHGCMCALLHANDLE callHandle = pSvcCtx->async.callHandle;
     308            VBOXHGCMCALLHANDLE callHandle = pClientData->State.async.callHandle;
    309309
    310310            if (fMessageReturned)
    311311            {
    312312                /* There is a response. */
    313                 pSvcCtx->fAsync = false;
     313                pClientData->State.fAsync = false;
    314314            }
    315315
     
    331331static int svcInit(void)
    332332{
    333     int rc = RTCritSectInit(&critsect);
     333    int rc = RTCritSectInit(&g_CritSect);
    334334
    335335    if (RT_SUCCESS(rc))
     
    344344        if (RT_FAILURE(rc))
    345345        {
    346             RTCritSectDelete(&critsect);
     346            RTCritSectDelete(&g_CritSect);
    347347        }
    348348    }
     
    354354{
    355355    VBoxClipboardSvcImplDestroy();
    356     RTCritSectDelete(&critsect);
     356    RTCritSectDelete(&g_CritSect);
    357357    return VINF_SUCCESS;
    358358}
     
    366366    RT_NOREF(u32ClientID);
    367367
    368     PVBOXCLIPBOARDSVCCTX pSvcCtx = (PVBOXCLIPBOARDSVCCTX)pvClient;
     368    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient;
    369369
    370370    LogFunc(("u32ClientID = %d\n", u32ClientID));
    371371
    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;
     372    vboxSvcClipboardReportMsg(pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_QUIT, 0);
     373
     374    vboxSvcClipboardCompleteReadData(pClientData, VERR_NO_DATA, 0);
     375
     376#ifdef VBOX_VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     377    vboxClipboardSvcURIDestroy(&pClientData->URI);
     378#endif
     379
     380    VBoxClipboardSvcImplDisconnect(pClientData);
     381
     382    g_pClientData = NULL;
    381383
    382384    return VINF_SUCCESS;
     
    386388{
    387389    RT_NOREF(fRequestor, fRestoring);
    388     PVBOXCLIPBOARDSVCCTX pSvcCtx = (PVBOXCLIPBOARDSVCCTX)pvClient;
    389 
    390     int rc = VINF_SUCCESS;
     390    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient;
    391391
    392392    /* If there is already a client connected then we want to release it first. */
    393     if (g_pSvcCtx != NULL)
    394     {
    395         uint32_t u32OldClientID = g_pSvcCtx->u32ClientID;
    396 
    397         svcDisconnect(NULL, u32OldClientID, g_pSvcCtx);
     393    if (g_pClientData != NULL)
     394    {
     395        uint32_t u32OldClientID = g_pClientData->State.u32ClientID;
     396
     397        svcDisconnect(NULL, u32OldClientID, g_pClientData);
     398
    398399        /* And free the resources in the hgcm subsystem. */
    399400        g_pHelpers->pfnDisconnectClient(g_pHelpers->pvInstance, u32OldClientID);
    400401    }
    401402
    402     /* Register the client. */
    403     memset(pSvcCtx, 0, sizeof(*pSvcCtx));
    404 
    405     pSvcCtx->u32ClientID = u32ClientID;
    406 
    407     rc = VBoxClipboardSvcImplConnect(pSvcCtx, VBoxSvcClipboardGetHeadless());
    408 
     403    /* Register the client.
     404     * Note: Do *not* memset the struct, as it contains classes (for caching). */
     405    pClientData->State.u32ClientID = u32ClientID;
     406
     407    int rc = VBoxClipboardSvcImplConnect(pClientData, VBoxSvcClipboardGetHeadless());
     408#ifdef VBOX_VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    409409    if (RT_SUCCESS(rc))
    410     {
    411         g_pSvcCtx = pSvcCtx;
     410        rc = vboxClipboardSvcURICreate(&pClientData->URI);
     411#endif
     412
     413    if (RT_SUCCESS(rc))
     414    {
     415        g_pClientData = pClientData;
    412416    }
    413417
     
    431435             u32ClientID, u32Function, cParms, paParms));
    432436
    433     PVBOXCLIPBOARDSVCCTX pSvcCtx = (PVBOXCLIPBOARDSVCCTX)pvClient;
     437    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient;
    434438
    435439    bool fAsynchronousProcessing = false;
     
    467471                if (VBoxSvcClipboardLock())
    468472                {
    469                     bool fMessageReturned = vboxSvcClipboardReturnMsg (pSvcCtx, paParms);
     473                    bool fMessageReturned = vboxSvcClipboardReturnMsg (pClientData, paParms);
    470474
    471475                    if (fMessageReturned)
    472476                    {
    473477                        /* Just return to the caller. */
    474                         pSvcCtx->fAsync = false;
     478                        pClientData->State.fAsync = false;
    475479                    }
    476480                    else
     
    479483                        fAsynchronousProcessing = true;
    480484
    481                         pSvcCtx->fAsync           = true;
    482                         pSvcCtx->async.callHandle = callHandle;
    483                         pSvcCtx->async.paParms    = paParms;
     485                        pClientData->State.fAsync           = true;
     486                        pClientData->State.async.callHandle = callHandle;
     487                        pClientData->State.async.paParms    = paParms;
    484488
    485489                        LogFunc(("async.\n"));
     
    517521                if (RT_SUCCESS (rc))
    518522                {
    519                     if (   vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
    520                         && vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     523                    if (   vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
     524                        && vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
    521525                    {
    522526                        rc = VERR_NOT_SUPPORTED;
     
    534538                    else
    535539                    {
    536                         VBoxClipboardSvcImplFormatAnnounce (pSvcCtx, u32Formats);
     540                        VBoxClipboardSvcImplFormatAnnounce (pClientData, u32Formats);
    537541                    }
    538542                }
     
    570574                    if (RT_SUCCESS (rc))
    571575                    {
    572                         if (   vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST
    573                             && vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     576                        if (   vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_HOST_TO_GUEST
     577                            && vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
    574578                        {
    575579                            rc = VERR_NOT_SUPPORTED;
     
    592596                            if (g_fDelayedAnnouncement)
    593597                            {
    594                                 vboxSvcClipboardReportMsg (g_pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, g_u32DelayedFormats);
     598                                vboxSvcClipboardReportMsg (g_pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, g_u32DelayedFormats);
    595599                                g_fDelayedAnnouncement = false;
    596600                                g_u32DelayedFormats = 0;
     
    607611                            /* Release any other pending read, as we only
    608612                             * support one pending read at one time. */
    609                             vboxSvcClipboardCompleteReadData(pSvcCtx, VERR_NO_DATA, 0);
    610                             rc = VBoxClipboardSvcImplReadData (pSvcCtx, u32Format, pv, cb, &cbActual);
     613                            vboxSvcClipboardCompleteReadData(pClientData, VERR_NO_DATA, 0);
     614                            rc = VBoxClipboardSvcImplReadData (pClientData, u32Format, pv, cb, &cbActual);
    611615                        }
    612616
     
    618622                            if (VBoxSvcClipboardLock())
    619623                            {
    620                                 pSvcCtx->asyncRead.callHandle = callHandle;
    621                                 pSvcCtx->asyncRead.paParms    = paParms;
    622                                 pSvcCtx->fReadPending         = true;
     624                                pClientData->State.asyncRead.callHandle = callHandle;
     625                                pClientData->State.asyncRead.paParms    = paParms;
     626                                pClientData->State.fReadPending         = true;
    623627                                fAsynchronousProcessing = true;
    624628                                VBoxSvcClipboardUnlock();
     
    665669                    if (RT_SUCCESS (rc))
    666670                    {
    667                         if (   vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
    668                             && vboxSvcClipboardMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
     671                        if (   vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_GUEST_TO_HOST
     672                            && vboxSvcClipboardGetMode () != VBOX_SHARED_CLIPBOARD_MODE_BIDIRECTIONAL)
    669673                        {
    670674                            rc = VERR_NOT_SUPPORTED;
     
    684688                        else
    685689                        {
    686                             VBoxClipboardSvcImplWriteData (pSvcCtx, pv, cb, u32Format);
     690                            VBoxClipboardSvcImplWriteData (pClientData, pv, cb, u32Format);
    687691                        }
    688692                    }
     
    713717 * then complete it, otherwise return.  See the protocol description in the
    714718 * shared clipboard module description. */
    715 void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDSVCCTX pSvcCtx, int rc, uint32_t cbActual)
     719void vboxSvcClipboardCompleteReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, int rc, uint32_t cbActual)
    716720{
    717721    VBOXHGCMCALLHANDLE callHandle = NULL;
     
    720724    if (VBoxSvcClipboardLock())  /* if not can we do anything useful? */
    721725    {
    722         callHandle   = pSvcCtx->asyncRead.callHandle;
    723         paParms      = pSvcCtx->asyncRead.paParms;
    724         fReadPending = pSvcCtx->fReadPending;
    725         pSvcCtx->fReadPending = false;
     726        callHandle   = pClientData->State.asyncRead.callHandle;
     727        paParms      = pClientData->State.asyncRead.paParms;
     728        fReadPending = pClientData->State.fReadPending;
     729        pClientData->State.fReadPending = false;
    726730        VBoxSvcClipboardUnlock();
    727731    }
     
    804808static SSMFIELD const g_aClipboardClientDataFields[] =
    805809{
    806     SSMFIELD_ENTRY(VBOXCLIPBOARDSVCCTX, u32ClientID),  /* for validation purposes */
    807     SSMFIELD_ENTRY(VBOXCLIPBOARDSVCCTX, fHostMsgQuit),
    808     SSMFIELD_ENTRY(VBOXCLIPBOARDSVCCTX, fHostMsgReadData),
    809     SSMFIELD_ENTRY(VBOXCLIPBOARDSVCCTX, fHostMsgFormats),
    810     SSMFIELD_ENTRY(VBOXCLIPBOARDSVCCTX, u32RequestedFormat),
     810    SSMFIELD_ENTRY(VBOXCLIPBOARDCLIENTSTATE, u32ClientID),  /* for validation purposes */
     811    SSMFIELD_ENTRY(VBOXCLIPBOARDCLIENTSTATE, fHostMsgQuit),
     812    SSMFIELD_ENTRY(VBOXCLIPBOARDCLIENTSTATE, fHostMsgReadData),
     813    SSMFIELD_ENTRY(VBOXCLIPBOARDCLIENTSTATE, fHostMsgFormats),
     814    SSMFIELD_ENTRY(VBOXCLIPBOARDCLIENTSTATE, u32RequestedFormat),
    811815    SSMFIELD_ENTRY_TERM()
    812816};
     
    826830    LogFunc(("u32ClientID = %d\n", u32ClientID));
    827831
    828     PVBOXCLIPBOARDSVCCTX pSvcCtx = (PVBOXCLIPBOARDSVCCTX)pvClient;
     832    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient;
    829833
    830834    /* This field used to be the length. We're using it as a version field
    831835       with the high bit set. */
    832836    SSMR3PutU32(pSSM, UINT32_C(0x80000002));
    833     int rc = SSMR3PutStructEx(pSSM, pSvcCtx, sizeof(*pSvcCtx), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
     837    int rc = SSMR3PutStructEx(pSSM, pClientData, sizeof(*pClientData), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
    834838    AssertRCReturn(rc, rc);
    835839
     
    840844}
    841845
    842 /**
    843  * This structure corresponds to the original layout of the
    844  * VBOXCLIPBOARDCLIENTDATA structure.  As the structure was saved as a whole
    845  * when saving state, we need to remember it forever in order to preserve
    846  * compatibility.
    847  *
    848  * (Starting with 3.1 this is no longer used.)
    849  *
    850  * @remarks Putting this outside svcLoadState to avoid visibility warning caused
    851  *          by -Wattributes.
    852  */
    853 typedef struct CLIPSAVEDSTATEDATA
    854 {
    855     struct CLIPSAVEDSTATEDATA *pNext;
    856     struct CLIPSAVEDSTATEDATA *pPrev;
    857 
    858     VBOXCLIPBOARDCONTEXT *pCtx;
    859 
    860     uint32_t u32ClientID;
    861 
    862     bool fAsync: 1; /* Guest is waiting for a message. */
    863 
    864     bool fHostMsgQuit: 1;
    865     bool fHostMsgReadData: 1;
    866     bool fHostMsgFormats: 1;
    867 
    868     struct
    869     {
    870         VBOXHGCMCALLHANDLE callHandle;
    871         VBOXHGCMSVCPARM *paParms;
    872     } async;
    873 
    874     struct
    875     {
    876         void *pv;
    877         uint32_t cb;
    878         uint32_t u32Format;
    879     } data;
    880 
    881     uint32_t u32AvailableFormats;
    882     uint32_t u32RequestedFormat;
    883 
    884 } CLIPSAVEDSTATEDATA;
    885 
    886846static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
    887847{
     
    891851    LogFunc(("u32ClientID = %d\n", u32ClientID));
    892852
    893     PVBOXCLIPBOARDSVCCTX pSvcCtx = (PVBOXCLIPBOARDSVCCTX)pvClient;
     853    PVBOXCLIPBOARDCLIENTDATA pClientData   = (PVBOXCLIPBOARDCLIENTDATA)pvClient;
     854    AssertPtr(pClientData);
    894855
    895856    /* Existing client can not be in async state yet. */
    896     Assert(!pSvcCtx->fAsync);
     857    Assert(!pClientData->State.fAsync);
    897858
    898859    /* Save the client ID for data validation. */
    899860    /** @todo isn't this the same as u32ClientID? Playing safe for now... */
    900     uint32_t const u32ClientIDOld = pSvcCtx->u32ClientID;
     861    uint32_t const u32ClientIDOld = pClientData->State.u32ClientID;
    901862
    902863    /* Restore the client data. */
     
    906867    if (lenOrVer == UINT32_C(0x80000002))
    907868    {
    908         rc = SSMR3GetStructEx(pSSM, pSvcCtx, sizeof(*pSvcCtx), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
     869        rc = SSMR3GetStructEx(pSSM, pClientData, sizeof(*pClientData), 0 /*fFlags*/, &g_aClipboardClientDataFields[0], NULL);
    909870        AssertRCReturn(rc, rc);
    910     }
    911     else if (lenOrVer == (SSMR3HandleHostBits(pSSM) == 64 ? 72U : 48U))
    912     {
    913         /**
    914          * SSM descriptor table for the CLIPSAVEDSTATEDATA structure.
    915          */
    916         static SSMFIELD const s_aClipSavedStateDataFields30[] =
    917         {
    918             SSMFIELD_ENTRY_IGN_HCPTR(       CLIPSAVEDSTATEDATA, pNext),
    919             SSMFIELD_ENTRY_IGN_HCPTR(       CLIPSAVEDSTATEDATA, pPrev),
    920             SSMFIELD_ENTRY_IGN_HCPTR(       CLIPSAVEDSTATEDATA, pCtx),
    921             SSMFIELD_ENTRY(                 CLIPSAVEDSTATEDATA, u32ClientID),
    922             SSMFIELD_ENTRY_CUSTOM(fMsgQuit + fMsgReadData + fMsgFormats, RT_UOFFSETOF(CLIPSAVEDSTATEDATA, u32ClientID) + 4, 4),
    923             SSMFIELD_ENTRY_IGN_HCPTR(       CLIPSAVEDSTATEDATA, async.callHandle),
    924             SSMFIELD_ENTRY_IGN_HCPTR(       CLIPSAVEDSTATEDATA, async.paParms),
    925             SSMFIELD_ENTRY_IGNORE(          CLIPSAVEDSTATEDATA, data.pv),
    926             SSMFIELD_ENTRY_IGNORE(          CLIPSAVEDSTATEDATA, data.cb),
    927             SSMFIELD_ENTRY_IGNORE(          CLIPSAVEDSTATEDATA, data.u32Format),
    928             SSMFIELD_ENTRY_IGNORE(          CLIPSAVEDSTATEDATA, u32AvailableFormats),
    929             SSMFIELD_ENTRY(                 CLIPSAVEDSTATEDATA, u32RequestedFormat),
    930             SSMFIELD_ENTRY_TERM()
    931         };
    932 
    933         CLIPSAVEDSTATEDATA savedState;
    934         RT_ZERO(savedState);
    935         rc = SSMR3GetStructEx(pSSM, &savedState, sizeof(savedState), SSMSTRUCT_FLAGS_MEM_BAND_AID,
    936                               &s_aClipSavedStateDataFields30[0], NULL);
    937         AssertRCReturn(rc, rc);
    938 
    939         pSvcCtx->fHostMsgQuit       = savedState.fHostMsgQuit;
    940         pSvcCtx->fHostMsgReadData   = savedState.fHostMsgReadData;
    941         pSvcCtx->fHostMsgFormats    = savedState.fHostMsgFormats;
    942         pSvcCtx->u32RequestedFormat = savedState.u32RequestedFormat;
    943871    }
    944872    else
     
    949877
    950878    /* Verify the client ID. */
    951     if (pSvcCtx->u32ClientID != u32ClientIDOld)
    952     {
    953         LogFunc(("Client ID mismatch: expected %d, got %d\n", u32ClientIDOld, pSvcCtx->u32ClientID));
    954         pSvcCtx->u32ClientID = u32ClientIDOld;
     879    if (pClientData->State.u32ClientID != u32ClientIDOld)
     880    {
     881        LogFunc(("Client ID mismatch: expected %d, got %d\n", u32ClientIDOld, pClientData->State.u32ClientID));
     882        pClientData->State.u32ClientID = u32ClientIDOld;
    955883        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
    956884    }
    957885
    958886    /* Actual host data are to be reported to guest (SYNC). */
    959     VBoxClipboardSvcImplSync(pSvcCtx);
     887    VBoxClipboardSvcImplSync(pClientData);
    960888
    961889#else  /* UNIT_TEST*/
     
    968896{
    969897    RT_NOREF2(pvData, cbData);
    970     if (g_pSvcCtx != NULL)
     898    if (g_pClientData != NULL)
    971899    {
    972900        switch (u32Function)
     
    982910                else
    983911                {
    984                     vboxSvcClipboardReportMsg (g_pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, u32Format);
     912                    vboxSvcClipboardReportMsg(g_pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS, u32Format);
    985913                }
    986914            } break;
     
    988916            case VBOX_CLIPBOARD_EXT_FN_DATA_READ:
    989917            {
    990                 vboxSvcClipboardReportMsg (g_pSvcCtx, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format);
     918                vboxSvcClipboardReportMsg(g_pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, u32Format);
    991919            } break;
    992920
     
    1030958}
    1031959
    1032 extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable)
     960extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad(VBOXHGCMSVCFNTABLE *ptable)
    1033961{
    1034962    int rc = VINF_SUCCESS;
     
    1053981            g_pHelpers = ptable->pHelpers;
    1054982
    1055             ptable->cbClient = sizeof(VBOXCLIPBOARDSVCCTX);
     983            ptable->cbClient = sizeof(VBOXCLIPBOARDCLIENTDATA);
    1056984
    1057985            ptable->pfnUnload     = svcUnload;
  • trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp

    r78580 r78618  
    2626extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable);
    2727
    28 static VBOXCLIPBOARDSVCCTX g_Client;
     28static VBOXCLIPBOARDCLIENTDATA g_Client;
    2929static VBOXHGCMSVCHELPERS g_Helpers = { NULL };
    3030
     
    275275int VBoxClipboardSvcImplInit() { return VINF_SUCCESS; }
    276276void VBoxClipboardSvcImplDestroy() { }
    277 void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDSVCCTX) { AssertFailed(); }
    278 int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDSVCCTX, bool)
     277void VBoxClipboardSvcImplDisconnect(PVBOXCLIPBOARDCLIENTDATA) { AssertFailed(); }
     278int VBoxClipboardSvcImplConnect(PVBOXCLIPBOARDCLIENTDATA, bool)
    279279{ AssertFailed(); return VERR_WRONG_ORDER; }
    280 void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDSVCCTX, unsigned int)
     280void VBoxClipboardSvcImplFormatAnnounce(PVBOXCLIPBOARDCLIENTDATA, unsigned int)
    281281{ AssertFailed(); }
    282 int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDSVCCTX, unsigned int, void *, unsigned int, unsigned int *)
     282int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA, unsigned int, void *, unsigned int, unsigned int *)
    283283{ AssertFailed(); return VERR_WRONG_ORDER; }
    284 void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDSVCCTX, void *, unsigned int, unsigned int) { AssertFailed(); }
    285 int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDSVCCTX)
     284void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA, void *, unsigned int, unsigned int) { AssertFailed(); }
     285int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA)
    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