VirtualBox

儲存庫 vbox 的更動 79366


忽略:
時間撮記:
2019-6-26 下午03:59:30 (5 年 以前)
作者:
vboxsync
訊息:

Shared Clipboard/URI: Update.

位置:
trunk
檔案:
修改 10 筆資料

圖例:

未更動
新增
刪除
  • trunk/include/VBox/GuestHost/SharedClipboard-uri.h

    r79350 r79366  
    536536    SHAREDCLIPBOARDURITRANSFERDIR_WRITE,
    537537    /** The usual 32-bit hack. */
    538     SHAREDCLIPBOARDURITRANSFERDIR__32BIT_HACK = 0x7fffffff
     538    SHAREDCLIPBOARDURITRANSFERDIR_32BIT_HACK = 0x7fffffff
    539539} SHAREDCLIPBOARDURITRANSFERDIR;
    540540
     
    560560    SHAREDCLIPBOARDURITRANSFERSTATUS_NONE = 0,
    561561    /** The transfer has been announced but is not running yet. */
    562     SHAREDCLIPBOARDURITRANSFERSTATUS_ANNOUNCED,
     562    SHAREDCLIPBOARDURITRANSFERSTATUS_READY,
    563563    /** The transfer is active and running. */
    564     SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING
     564    SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING,
     565    /** The usual 32-bit hack. */
     566    SHAREDCLIPBOARDURITRANSFERSTATUS_32BIT_HACK = 0x7fffffff
    565567} SHAREDCLIPBOARDURITRANSFERSTATUS;
     568
     569typedef struct _SHAREDCLIPBOARDURITRANSFERPAYLOAD
     570{
     571    uint32_t uID;
     572    void    *pvData;
     573    uint32_t cbData;
     574} SHAREDCLIPBOARDURITRANSFERPAYLOAD, *PSHAREDCLIPBOARDURITRANSFERPAYLOAD;
     575
     576typedef struct _SHAREDCLIPBOARDURITRANSFEREVENT
     577{
     578    RTSEMEVENT                         hEventSem;
     579    PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload;
     580} SHAREDCLIPBOARDURITRANSFEREVENT, *PSHAREDCLIPBOARDURITRANSFEREVENT;
     581
     582typedef enum _SHAREDCLIPBOARDURITRANSFEREVENTTYPE
     583{
     584    SHAREDCLIPBOARDURITRANSFEREVENTTYPE_UNKNOWN,
     585    SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_HDR,
     586    SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_CHUNK,
     587    /** Marks the end of the event list. */
     588    SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LAST,
     589    /** The usual 32-bit hack. */
     590    SHAREDCLIPBOARDURITRANSFEREVENTTYPE_32BIT_HACK = 0x7fffffff
     591} SHAREDCLIPBOARDURITRANSFEREVENTTYPE;
     592
     593typedef std::map<uint32_t, SHAREDCLIPBOARDURITRANSFEREVENT *> SharedClipboardURITransferEventMap;
     594
     595typedef struct _SHAREDCLIPBOARDURITRANSFEREVENTS
     596{
     597    SharedClipboardURITransferEventMap *pMap;
     598} SHAREDCLIPBOARDURITRANSFEREVENTS, *PSHAREDCLIPBOARDURITRANSFEREVENTS;
    566599
    567600/**
     
    593626typedef struct _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER;
    594627
     628/**
     629 * Structure maintaining URI clipboard provider context data.
     630 * This is handed in to the provider implementation callbacks.
     631 */
    595632typedef struct _SHAREDCLIPBOARDPROVIDERCTX
    596633{
     634    /** Pointer to the related URI transfer. */
    597635    PSHAREDCLIPBOARDURITRANSFER pTransfer;
     636    /** User-defined data pointer. Can be NULL if not needed. */
    598637    void                       *pvUser;
    599638} SHAREDCLIPBOARDPROVIDERCTX, *PSHAREDCLIPBOARDPROVIDERCTX;
    600639
     640/** Defines an URI clipboard provider function declaration with additional parameters. */
    601641#define SHAREDCLIPBOARDPROVIDERFUNCDECL(a_Name, ...) \
    602642    typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX, __VA_ARGS__); \
    603643    typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
    604644
     645/** Defines an URI clipboard provider function declaration (no additional parameters). */
    605646#define SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(a_Name) \
    606647    typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX); \
    607648    typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
    608649
     650/** Declares a URI clipboard provider function member. */
    609651#define SHAREDCLIPBOARDPROVIDERFUNCMEMBER(a_Name, a_Member) \
    610652    RT_CONCAT(PFNSHAREDCLIPBOARDPROVIDER, a_Name) a_Member;
     
    624666SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(RESET)
    625667
     668/**
     669 * Shared Clipboard URI provider interface table.
     670 */
    626671typedef struct _SHAREDCLIPBOARDPROVIDERINTERFACE
    627672{
     
    648693    /** Specifies what the source of the provider is. */
    649694    SHAREDCLIPBOARDSOURCE             enmSource;
     695    /** The provider interface table. */
    650696    SHAREDCLIPBOARDPROVIDERINTERFACE  Interface;
     697    /** Provider callback data. */
    651698    void                             *pvUser;
    652     union
    653     {
    654         struct
    655         {
    656             /** HGCM client ID to use. */
    657             uint32_t uClientID;
    658         } VbglR3;
    659         struct
    660         {
    661             SharedClipboardArea *pArea;
    662         } HostService;
    663     } u;
    664699} SHAREDCLIPBOARDPROVIDERCREATIONCTX, *PSHAREDCLIPBOARDPROVIDERCREATIONCTX;
    665700
     
    693728} SHAREDCLIPBOARDPROVIDERWRITEPARMS, *PSHAREDCLIPBOARDPROVIDERWRITEPARMS;
    694729
    695 #if 0
    696 /**
    697  * Interface class acting as a lightweight proxy for abstracting reading / writing clipboard data.
    698  *
    699  * This is needed because various implementations can run on the host *or* on the guest side,
    700  * requiring different methods for handling the actual data.
    701  */
    702 class SharedClipboardProvider
    703 {
    704 
    705 public:
    706 
    707     static SharedClipboardProvider *Create(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx);
    708 
    709     virtual ~SharedClipboardProvider(void);
    710 
    711 public:
    712 
    713     uint32_t AddRef(void);
    714     uint32_t Release(void);
    715 
    716 public:
    717 
    718     void SetCallbacks(PSHAREDCLIPBOARDPROVIDERCALLBACKS pCallbacks);
    719 
    720 public: /* Interface to be implemented. */
    721 
    722     virtual int Prepare(void);
    723 
    724     virtual int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
    725     virtual int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
    726 
    727     virtual int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
    728                               uint32_t *pcbRead = NULL);
    729     virtual int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
    730                                uint32_t *pcbWritten = NULL);
    731 
    732     virtual int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);
    733     virtual int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
    734 
    735     virtual int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);
    736     virtual int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
    737 
    738     virtual int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);
    739     virtual int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);
    740 
    741     virtual void Reset(void);
    742 
    743 public: /* Optional callback handling. */
    744 
    745     /*virtual int SetCallbacks();*/
    746 
    747     virtual int OnRead(PSHAREDCLIPBOARDPROVIDERREADPARMS pParms);
    748     virtual int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);
    749 
    750 protected:
    751 
    752     SharedClipboardProvider(void);
    753 
    754 protected:
    755 
    756     /**
    757      * Structure for maintaining an internal event.
    758      */
    759     struct Event
    760     {
    761         Event(uint32_t uMsg);
    762         virtual ~Event();
    763 
    764         void *DataAdopt(void);
    765         uint32_t DataSize(void);
    766         void *DataRaw(void);
    767         void Reset(void);
    768         int SetData(const void *pvData, uint32_t cbData);
    769         int Wait(RTMSINTERVAL uTimeoutMs);
    770 
    771         /** The event's associated message ID (guest function number). */
    772         uint32_t    mMsg;
    773         /** The event's own event semaphore. */
    774         RTSEMEVENT  mEvent;
    775         /** User-provided data buffer associated to this event. Optional. */
    776         void       *mpvData;
    777         /** Size (in bytes) of user-provided data buffer associated to this event. */
    778         uint32_t    mcbData;
    779     };
    780 
    781     /** Map of events; the key is the guest function number (VBOX_SHARED_CLIPBOARD_GUEST_FN_XXX). */
    782     typedef std::map<uint32_t, Event *> EventMap;
    783 
    784     int eventRegister(uint32_t uMsg);
    785     int eventUnregister(uint32_t uMsg);
    786     int eventUnregisterAll(void);
    787     int eventSignal(uint32_t uMsg);
    788     int eventWait(uint32_t uMsg, PFNSSHAREDCLIPBOARDPROVIDERCALLBACK pfnCallback, RTMSINTERVAL uTimeoutMs,
    789                   void **ppvData, uint32_t *pcbData = NULL);
    790     SharedClipboardProvider::Event *eventGet(uint32_t uMsg);
    791 
    792 protected:
    793 
    794     /** Number of references to this instance. */
    795     volatile uint32_t                m_cRefs;
    796     /** The provider's transfer direction. */
    797     SHAREDCLIPBOARDURITRANSFERDIR    m_enmDir;
    798     /** The provider's callback table. */
    799     SHAREDCLIPBOARDPROVIDERCALLBACKS m_Callbacks;
    800     /** Default timeout (in ms) for waiting for events. */
    801     RTMSINTERVAL                     m_uTimeoutMs;
    802     /** Map of (internal) events to provide asynchronous reads / writes. */
    803     EventMap                         m_mapEvents;
    804 };
    805 
    806 /**
    807  * Shared Clipboard provider implementation for VbglR3 (guest side).
    808  */
    809 class SharedClipboardProviderVbglR3 : protected SharedClipboardProvider
    810 {
    811     friend class SharedClipboardProvider;
    812 
    813 public:
    814 
    815     virtual ~SharedClipboardProviderVbglR3(void);
    816 
    817 public:
    818 
    819     int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
    820     int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
    821 
    822     int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
    823                       uint32_t *pcbRead = NULL);
    824     int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
    825                        uint32_t *pcbWritten = NULL);
    826 
    827     int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);
    828     int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
    829 
    830     int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);
    831     int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
    832 
    833     int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);
    834     int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);
    835 
    836     void Reset(void);
    837 
    838 protected:
    839 
    840     SharedClipboardProviderVbglR3(uint32_t uClientID);
    841 
    842     /** HGCM client ID to use. */
    843     uint32_t m_uClientID;
    844 };
    845 
    846 #ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST
    847 /**
    848  * Shared Clipboard provider implementation for host service (host side).
    849  */
    850 class SharedClipboardProviderHostService : protected SharedClipboardProvider
    851 {
    852     friend class SharedClipboardProvider;
    853 
    854 public:
    855 
    856     virtual ~SharedClipboardProviderHostService();
    857 
    858 public:
    859 
    860     int Prepare(void);
    861 
    862     int ReadDataHdr(PVBOXCLIPBOARDDATAHDR *ppDataHdr);
    863     int WriteDataHdr(const PVBOXCLIPBOARDDATAHDR pDataHdr);
    864 
    865     int ReadDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
    866                       uint32_t *pcbRead = NULL);
    867     int WriteDataChunk(const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags = 0,
    868                        uint32_t *pcbWritten = NULL);
    869 
    870     int ReadDirectory(PVBOXCLIPBOARDDIRDATA *ppDirData);
    871     int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData);
    872 
    873     int ReadFileHdr(PVBOXCLIPBOARDFILEHDR *ppFileHdr);
    874     int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr);
    875 
    876     int ReadFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbRead = NULL);
    877     int WriteFileData(void *pvData, uint32_t cbData, uint32_t fFlags = 0, uint32_t *pcbWritten = NULL);
    878 
    879     void Reset(void);
    880 
    881 public:
    882 
    883     int OnWrite(PSHAREDCLIPBOARDPROVIDERWRITEPARMS pParms);
    884 
    885 protected:
    886 
    887     SharedClipboardProviderHostService(SharedClipboardArea *pArea);
    888 
    889 protected:
    890 
    891     /** Pointer to associated clipboard area. */
    892     SharedClipboardArea            *m_pArea;
    893 };
    894 #endif /* VBOX_WITH_SHARED_CLIPBOARD_HOST */
    895 #endif
    896 
    897730struct _SHAREDCLIPBOARDURITRANSFER;
    898731typedef _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER;
     
    922755SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERPREPARE)
    923756SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERSTARTED)
    924 SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATAHDRCOMPLETE)
     757SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATAHEADERCOMPLETE)
    925758SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATACHUNKCOMPLETE)
     759SHAREDCLIPBOARDTRANSFERCALLBACKDECL    (TRANSFERCOMPLETE, int rc)
    926760SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERCANCELED)
    927 SHAREDCLIPBOARDTRANSFERCALLBACKDECL    (TRANSFERCOMPLETE, int rc)
    928761SHAREDCLIPBOARDTRANSFERCALLBACKDECL    (TRANSFERERROR, int rc)
    929762
     
    941774    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERSTARTED, pfnTransferStarted);
    942775    /** Function pointer, called when reading / writing the meta data header is complete. */
    943     SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATAHDRCOMPLETE, pfnDataHeaderComplete);
     776    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATAHEADERCOMPLETE, pfnDataHeaderComplete);
    944777    /** Function pointer, called when reading / writing the meta data is complete. */
    945778    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATACHUNKCOMPLETE, pfnDataComplete);
     
    979812    /** The transfer's state (for SSM, later). */
    980813    SHAREDCLIPBOARDURITRANSFERSTATE     State;
     814    SHAREDCLIPBOARDURITRANSFEREVENTS    Events;
    981815    /** The transfer's own (local) area, if any (can be NULL if not needed).
    982816     *  The area itself has a clipboard area ID assigned.
     
    1005839    /** Critical section for serializing access. */
    1006840    RTCRITSECT                  CritSect;
    1007     /** List of active transfers.
    1008      *  Use a list or something lateron. */
    1009     RTLISTANCHOR                List;
     841    /** List of transfers. */
     842     RTLISTANCHOR                List;
    1010843    /** Number of running (concurrent) transfers.
    1011844     *  At the moment we only support only one transfer per client at a time. */
     
    1014847     *  At the moment we only support only one transfer per client at a time. */
    1015848    uint32_t                    cMaxRunning;
    1016 #ifdef DEBUG
    1017     uint32_t                    cTransfer;
    1018 #endif
     849    /** Number of total transfers (in list). */
     850    uint32_t                    cTransfers;
    1019851} SHAREDCLIPBOARDURICTX, *PSHAREDCLIPBOARDURICTX;
    1020852
     
    1040872void SharedClipboardURITransferSetCallbacks(PSHAREDCLIPBOARDURITRANSFER pTransfer,
    1041873                                            PSHAREDCLIPBOARDURITRANSFERCALLBACKS pCallbacks);
    1042 int SharedClipboardURITransferSetDataHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATAHDR pDataHdr);
    1043 int SharedClipboardURITransferSetDataChunk(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATACHUNK pDataChunk);
     874
     875int SharedClipboardURITransferPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
     876                                           PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload);
     877void SharedClipboardURITransferPayloadFree(PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload);
     878
     879int SharedClipboardURITransferEventRegister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID);
     880int SharedClipboardURITransferEventUnregister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID);
     881int SharedClipboardURITransferEventWait(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, RTMSINTERVAL uTimeoutMs,
     882                                        PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload);
     883int SharedClipboardURITransferEventSignal(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload);
    1044884
    1045885int SharedClipboardURITransferMetaDataAdd(PSHAREDCLIPBOARDURITRANSFER pTransfer, const void *pvMeta, uint32_t cbMeta);
     
    1059899PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx);
    1060900uint32_t SharedClipboardURICtxGetRunningTransfers(PSHAREDCLIPBOARDURICTX pURI);
     901uint32_t SharedClipboardURICtxGetTotalTransfers(PSHAREDCLIPBOARDURICTX pURI);
    1061902void SharedClipboardURICtxTransfersCleanup(PSHAREDCLIPBOARDURICTX pURI);
    1062903bool SharedClipboardURICtxTransfersMaximumReached(PSHAREDCLIPBOARDURICTX pURI);
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r79347 r79366  
    596596
    597597                        PSHAREDCLIPBOARDURITRANSFER pTransfer;
    598                         rc = SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR_READ, &pTransfer);
     598                        rc = SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR_READ,
     599                                                              SHAREDCLIPBOARDSOURCE_REMOTE,
     600                                                              &pTransfer);
    599601                        if (RT_SUCCESS(rc))
    600602                        {
     
    620622
    621623                            creationCtx.pvUser = pCtx;
    622 
    623                             creationCtx.u.VbglR3.uClientID = pCtx->u32ClientID;
    624624
    625625                            rc = SharedClipboardURITransferProviderCreate(pTransfer, &creationCtx);
     
    728728
    729729                    PSHAREDCLIPBOARDURITRANSFER pTransfer;
    730                     rc = SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR_WRITE, &pTransfer);
     730                    rc = SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR_WRITE,
     731                                                          SHAREDCLIPBOARDSOURCE_LOCAL,
     732                                                          &pTransfer);
    731733                    if (RT_SUCCESS(rc))
    732734                    {
     
    743745                        RT_ZERO(creationCtx);
    744746                        creationCtx.enmSource          = SHAREDCLIPBOARDSOURCE_LOCAL;
    745                         creationCtx.u.VbglR3.uClientID = pCtx->u32ClientID;
     747
     748                        RT_ZERO(creationCtx.Interface);
     749                        creationCtx.Interface.pfnWriteDataHdr   = vboxClipboardURIWriteDataHdr;
     750                        creationCtx.Interface.pfnWriteDataChunk = vboxClipboardURIWriteDataChunk;
     751                        creationCtx.Interface.pfnWriteDirectory = vboxClipboardURIWriteDir;
     752                        creationCtx.Interface.pfnWriteFileHdr   = vboxClipboardURIWriteFileHdr;
     753                        creationCtx.Interface.pfnWriteFileData  = vboxClipboardURIWriteFileData;
     754
     755                        creationCtx.pvUser = pCtx;
    746756
    747757                        rc = SharedClipboardURITransferProviderCreate(pTransfer, &creationCtx);
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp

    r79347 r79366  
    421421                    }
    422422                }
     423
     424                if (RT_FAILURE(rc))
     425                    LogRel(("Shared Clipboard: Data object unable to receive meta data, rc=%Rrc\n", rc));
    423426            }
    424427            break;
  • trunk/src/VBox/GuestHost/SharedClipboard/ClipboardURIList.cpp

    r79276 r79366  
    487487    AssertReturn(!(fFlags & ~SHAREDCLIPBOARDURILIST_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
    488488
    489     if (!RTStrIsValidEncoding(static_cast<const char *>(pvData)))
    490         return VERR_INVALID_PARAMETER;
    491 
    492489    RTCList<RTCString> lstURI =
    493490        RTCString(static_cast<const char *>(pvData), cbData - 1).split("\r\n");
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-uri.cpp

    r79347 r79366  
    2020
    2121#include <iprt/path.h>
     22#include <iprt/semaphore.h>
    2223
    2324#include <VBox/err.h>
     
    3637
    3738
     39/**
     40 * Allocates a VBOXCLIPBOARDDATAHDR structure.
     41 *
     42 * @returns VBox status code.
     43 * @param   ppDataChunk         Where to store the allocated VBOXCLIPBOARDDATAHDR structure on success.
     44 */
    3845int SharedClipboardURIDataHdrAlloc(PVBOXCLIPBOARDDATAHDR *ppDataHdr)
    3946{
     
    4855        {
    4956            char *pszFmt = NULL;
    50             rc = RTStrAAppend(&pszFmt, "VBoxShClURIList");
     57            rc = RTStrAAppend(&pszFmt, "VBoxShClURIList"); /** @todo Make this more flexible. Later. */
    5158            if (RT_SUCCESS(rc))
    5259            {
     
    245252
    246253/**
     254 * Duplicates (allocates) a VBOXCLIPBOARDDATACHUNK structure.
     255 *
     256 * @returns Duplicated VBOXCLIPBOARDDATACHUNK structure on success.
     257 * @param   pDataChunk          VBOXCLIPBOARDDATACHUNK to duplicate.
     258 */
     259PVBOXCLIPBOARDDATACHUNK SharedClipboardURIDataChunkDup(PVBOXCLIPBOARDDATACHUNK pDataChunk)
     260{
     261    AssertPtrReturn(pDataChunk, NULL);
     262
     263    PVBOXCLIPBOARDDATACHUNK pDataChunkDup = (PVBOXCLIPBOARDDATACHUNK)RTMemAlloc(sizeof(VBOXCLIPBOARDDATACHUNK));
     264    if (pDataChunkDup)
     265    {
     266        *pDataChunkDup = *pDataChunk;
     267
     268        if (pDataChunk->pvData)
     269        {
     270            pDataChunkDup->pvData = RTMemDup(pDataChunk->pvData, pDataChunk->cbData);
     271            pDataChunkDup->cbData = pDataChunk->cbData;
     272        }
     273
     274        if (pDataChunk->pvChecksum)
     275        {
     276            pDataChunkDup->pvChecksum = RTMemDup(pDataChunk->pvChecksum, pDataChunk->cbChecksum);
     277            pDataChunkDup->cbChecksum = pDataChunk->cbChecksum;
     278        }
     279    }
     280
     281    return pDataChunkDup;
     282}
     283
     284/**
    247285 * Initializes a VBOXCLIPBOARDDATACHUNK structure.
    248286 *
     
    662700
    663701    pTransfer->pURIList = new SharedClipboardURIList();
    664     if (!pTransfer->pURIList)
     702    if (pTransfer->pURIList)
     703    {
     704        pTransfer->Events.pMap = new SharedClipboardURITransferEventMap();
     705        if (pTransfer->Events.pMap)
     706        {
     707            rc = SharedClipboardURIObjCtxInit(&pTransfer->State.ObjCtx);
     708            if (RT_SUCCESS(rc))
     709            {
     710                *ppTransfer = pTransfer;
     711            }
     712        }
     713        else
     714            rc = VERR_NO_MEMORY;
     715    }
     716    else
     717        rc = VERR_NO_MEMORY;
     718
     719    if (RT_FAILURE(rc))
    665720    {
    666721        RTMemFree(pTransfer);
    667         return VERR_NO_MEMORY;
    668     }
    669 
    670     rc = SharedClipboardURIObjCtxInit(&pTransfer->State.ObjCtx);
    671     if (RT_SUCCESS(rc))
    672     {
    673         *ppTransfer = pTransfer;
    674722    }
    675723
     
    704752    }
    705753
     754    if (pTransfer->Events.pMap)
     755    {
     756        delete pTransfer->Events.pMap;
     757        pTransfer->Events.pMap = NULL;
     758    }
     759
    706760    SharedClipboardURIObjCtxDestroy(&pTransfer->State.ObjCtx);
    707761
     
    727781
    728782    int rc = VINF_SUCCESS;
     783
     784    AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_NONE,
     785                    ("Transfer has wrong state (%RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER);
    729786
    730787    LogFlowFunc(("pTransfer=%p, enmDir=%RU32\n", pTransfer, pTransfer->State.enmDir));
     
    798855    if (RT_SUCCESS(rc))
    799856    {
     857        pTransfer->State.enmStatus = SHAREDCLIPBOARDURITRANSFERSTATUS_READY;
     858
    800859        /** @todo Add checksum support. */
    801860    }
     
    10051064}
    10061065
    1007 int SharedClipboardURITransferSetDataHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATAHDR pDataHdr)
    1008 {
    1009     AssertReturn(pTransfer->State.pHeader == NULL, VERR_WRONG_ORDER);
    1010 
    1011     LogFlowFuncEnter();
    1012 
     1066int SharedClipboardURITransferPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData,
     1067                                           PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload)
     1068{
     1069    PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload =
     1070        (PSHAREDCLIPBOARDURITRANSFERPAYLOAD)RTMemAlloc(sizeof(SHAREDCLIPBOARDURITRANSFERPAYLOAD));
     1071    if (!pPayload)
     1072        return VERR_NO_MEMORY;
     1073
     1074    pPayload->pvData = RTMemAlloc(cbData);
     1075    if (pPayload->pvData)
     1076    {
     1077        memcpy(pPayload->pvData, pvData, cbData);
     1078
     1079        pPayload->cbData = cbData;
     1080        pPayload->uID    = uID;
     1081
     1082        *ppPayload = pPayload;
     1083
     1084        return VINF_SUCCESS;
     1085    }
     1086
     1087    RTMemFree(pPayload);
     1088    return VERR_NO_MEMORY;
     1089}
     1090
     1091void SharedClipboardURITransferPayloadFree(PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload)
     1092{
     1093    if (!pPayload)
     1094        return;
     1095
     1096    if (pPayload->pvData)
     1097    {
     1098        Assert(pPayload->cbData);
     1099        RTMemFree(pPayload->pvData);
     1100        pPayload->pvData = NULL;
     1101    }
     1102
     1103    pPayload->cbData = 0;
     1104
     1105    RTMemFree(pPayload);
     1106    pPayload = NULL;
     1107}
     1108
     1109int SharedClipboardURITransferEventRegister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID)
     1110{
    10131111    int rc;
    10141112
    1015     pTransfer->State.pHeader = SharedClipboardURIDataHdrDup(pDataHdr);
    1016     if (pTransfer->State.pHeader)
    1017     {
    1018         LogFlowFunc(("Meta data size is %RU32, total size is %RU64, %RU64 objects\n",
    1019                      pTransfer->State.pHeader->cbMeta, pTransfer->State.pHeader->cbTotal,
    1020                      pTransfer->State.pHeader->cObjects));
     1113    SharedClipboardURITransferEventMap::iterator itEvent = pTransfer->Events.pMap->find(uID);
     1114    if (itEvent == pTransfer->Events.pMap->end())
     1115    {
     1116        PSHAREDCLIPBOARDURITRANSFEREVENT pEvent
     1117            = (PSHAREDCLIPBOARDURITRANSFEREVENT)RTMemAllocZ(sizeof(SHAREDCLIPBOARDURITRANSFEREVENT));
     1118        if (pEvent)
     1119        {
     1120            rc = RTSemEventCreate(&pEvent->hEventSem);
     1121            if (RT_SUCCESS(rc))
     1122            {
     1123                pTransfer->Events.pMap->insert(std::pair<uint32_t, PSHAREDCLIPBOARDURITRANSFEREVENT>(uID, pEvent)); /** @todo Can this throw? */
     1124            }
     1125        }
     1126        else
     1127            rc = VERR_NO_MEMORY;
     1128    }
     1129    else
     1130        rc = VERR_ALREADY_EXISTS;
     1131
     1132    LogFlowFuncLeaveRC(rc);
     1133    return rc;
     1134}
     1135
     1136int SharedClipboardURITransferEventUnregister(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID)
     1137{
     1138    int rc;
     1139
     1140    SharedClipboardURITransferEventMap::const_iterator itEvent = pTransfer->Events.pMap->find(uID);
     1141    if (itEvent != pTransfer->Events.pMap->end())
     1142    {
     1143        SharedClipboardURITransferPayloadFree(itEvent->second->pPayload);
     1144
     1145        RTSemEventDestroy(itEvent->second->hEventSem);
     1146
     1147        RTMemFree(itEvent->second);
     1148
     1149        pTransfer->Events.pMap->erase(itEvent);
    10211150
    10221151        rc = VINF_SUCCESS;
    1023 
    1024         if (pTransfer->Callbacks.pfnDataHeaderComplete)
    1025         {
    1026             SHAREDCLIPBOARDURITRANSFERCALLBACKDATA callbackData = { pTransfer, pTransfer->Callbacks.pvUser };
    1027             pTransfer->Callbacks.pfnDataHeaderComplete(&callbackData);
    1028         }
    10291152    }
    10301153    else
    1031         rc = VERR_NO_MEMORY;
    1032 
    1033     LogFlowFuncLeaveRC(rc);
    1034     return rc;
    1035 }
    1036 
    1037 int SharedClipboardURITransferSetDataChunk(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATACHUNK pDataChunk)
    1038 {
    1039     LogFlowFuncEnter();
    1040 
    1041     AssertPtrReturn(pTransfer->State.pHeader, VERR_WRONG_ORDER);
    1042 
    1043     int rc = SharedClipboardURITransferMetaDataAdd(pTransfer, pDataChunk->pvData, pDataChunk->cbData);
     1154        rc = VERR_NOT_FOUND;
     1155
     1156    LogFlowFuncLeaveRC(rc);
     1157    return rc;
     1158}
     1159
     1160int SharedClipboardURITransferEventWait(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID, RTMSINTERVAL uTimeoutMs,
     1161                                        PSHAREDCLIPBOARDURITRANSFERPAYLOAD *ppPayload)
     1162{
     1163    LogFlowFuncEnter();
     1164
     1165    int rc;
     1166
     1167    SharedClipboardURITransferEventMap::const_iterator itEvent = pTransfer->Events.pMap->find(uID);
     1168    if (itEvent != pTransfer->Events.pMap->end())
     1169    {
     1170        rc = RTSemEventWait(itEvent->second->hEventSem, uTimeoutMs);
     1171        if (RT_SUCCESS(rc))
     1172        {
     1173            *ppPayload = itEvent->second->pPayload;
     1174
     1175            itEvent->second->pPayload = NULL;
     1176        }
     1177    }
     1178    else
     1179        rc = VERR_NOT_FOUND;
     1180
     1181    LogFlowFuncLeaveRC(rc);
     1182    return rc;
     1183}
     1184
     1185int SharedClipboardURITransferEventSignal(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint32_t uID,
     1186                                          PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload)
     1187{
     1188    int rc;
     1189
     1190    SharedClipboardURITransferEventMap::const_iterator itEvent = pTransfer->Events.pMap->find(uID);
     1191    if (itEvent != pTransfer->Events.pMap->end())
     1192    {
     1193        Assert(itEvent->second->pPayload == NULL);
     1194
     1195        itEvent->second->pPayload = pPayload;
     1196
     1197        rc = RTSemEventSignal(itEvent->second->hEventSem);
     1198    }
     1199    else
     1200        rc = VERR_NOT_FOUND;
    10441201
    10451202    LogFlowFuncLeaveRC(rc);
     
    11171274    LogFlowFuncEnter();
    11181275
    1119     AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING,
    1120                     ("Transfer already is running\n"), VERR_WRONG_ORDER);
     1276    AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_READY,
     1277                    ("Read transfer has wrong state (%RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER);
    11211278
    11221279    pTransfer->State.enmStatus = SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING;
     
    11661323
    11671324    PVBOXCLIPBOARDDIRDATA pDirData;
     1325    AssertPtr(pTransfer->ProviderIface.pfnReadDirectory);
    11681326    int rc = pTransfer->ProviderIface.pfnReadDirectory(&pTransfer->ProviderCtx, &pDirData);
    11691327    if (RT_SUCCESS(rc))
     
    11851343
    11861344    PVBOXCLIPBOARDFILEHDR pFileHdr;
     1345    AssertPtr(pTransfer->ProviderIface.pfnReadFileHdr);
    11871346    int rc = pTransfer->ProviderIface.pfnReadFileHdr(&pTransfer->ProviderCtx, &pFileHdr);
    11881347    if (RT_SUCCESS(rc))
     
    11961355        while (cbToRead)
    11971356        {
     1357            AssertPtr(pTransfer->ProviderIface.pfnReadFileData);
    11981358            rc = pTransfer->ProviderIface.pfnReadFileData(&pTransfer->ProviderCtx,
    11991359                                                          pvBuf, cbBuf, 0 /* fFlags */, &cbRead);
     
    12231383
    12241384    PVBOXCLIPBOARDOBJHDR pObjHdr;
     1385    AssertPtr(pTransfer->ProviderIface.pfnReadObjHdr);
    12251386    int rc = pTransfer->ProviderIface.pfnReadObjHdr(&pTransfer->ProviderCtx, &pObjHdr);
    12261387    if (RT_SUCCESS(rc))
     
    13851546    LogFlowFunc(("pvMeta=%p, cbMeta=%RU32\n", pvMeta, cbMeta));
    13861547
     1548    AssertPtrReturn(pTransfer->State.pHeader, VERR_WRONG_ORDER); /* Header must be present. */
     1549    AssertReturn(SharedClipboardMetaDataGetUsed(pTransfer->State.pMeta) + cbMeta <= pTransfer->State.pHeader->cbMeta,
     1550                 VERR_BUFFER_OVERFLOW);
     1551
    13871552    int rc = SharedClipboardMetaDataAdd(pTransfer->State.pMeta, pvMeta, cbMeta);
    13881553
     
    14461611    uint32_t cbReadTotal = 0;
    14471612
     1613    AssertPtr(pTransfer->ProviderIface.pfnReadDataHdr);
    14481614    int rc = pTransfer->ProviderIface.pfnReadDataHdr(&pTransfer->ProviderCtx, &pTransfer->State.pHeader);
    14491615    if (RT_SUCCESS(rc))
    14501616    {
    1451         uint32_t cbMeta = _4K; /** @todo Improve. */
    1452         void    *pvMeta = RTMemAlloc(cbMeta);
     1617        if (pTransfer->Callbacks.pfnDataHeaderComplete)
     1618        {
     1619            SHAREDCLIPBOARDURITRANSFERCALLBACKDATA callbackData = { pTransfer, pTransfer->Callbacks.pvUser };
     1620            pTransfer->Callbacks.pfnDataHeaderComplete(&callbackData);
     1621        }
     1622
     1623        uint32_t cbMetaToRead = pTransfer->State.pHeader->cbMeta;
     1624
     1625        uint32_t cbMeta = cbMetaToRead;
     1626        void    *pvMeta = RTMemAlloc(cbMetaToRead);
    14531627
    14541628        if (pvMeta)
    14551629        {
    14561630            AssertPtr(pTransfer->State.pHeader);
    1457             uint32_t cbMetaToRead = pTransfer->State.pHeader->cbMeta;
    14581631            while (cbMetaToRead)
    14591632            {
     1633                const uint32_t cbToRead = RT_MIN(cbMetaToRead, cbMeta);
     1634
    14601635                uint32_t cbMetaRead;
     1636                AssertPtr(pTransfer->ProviderIface.pfnReadDataChunk);
    14611637                rc = pTransfer->ProviderIface.pfnReadDataChunk(&pTransfer->ProviderCtx,
    1462                                                                pTransfer->State.pHeader, pvMeta, cbMeta, 0 /* fFlags */,
    1463                                                                &cbMetaRead);
     1638                                                               pTransfer->State.pHeader, pvMeta, cbToRead,
     1639                                                               0 /* fFlags */, &cbMetaRead);
    14641640                if (RT_SUCCESS(rc))
    1465                     rc = sharedClipboardURITransferMetaDataAddInternal(pTransfer, pvMeta, cbMeta);
     1641                    rc = SharedClipboardURITransferMetaDataAdd(pTransfer, pvMeta, cbMetaRead);
    14661642
    14671643                if (RT_FAILURE(rc))
     
    14711647                cbMetaToRead -= cbMetaRead;
    14721648
    1473                 cbReadTotal += cbReadTotal;
     1649                cbReadTotal += cbMetaRead;
    14741650            }
    14751651
     
    14781654            if (RT_SUCCESS(rc))
    14791655            {
     1656                rc = pTransfer->pURIList->SetFromURIData(SharedClipboardMetaDataMutableRaw(pTransfer->State.pMeta),
     1657                                                         SharedClipboardMetaDataGetUsed(pTransfer->State.pMeta),
     1658                                                         SHAREDCLIPBOARDURILIST_FLAGS_NONE);
     1659                if (   RT_SUCCESS(rc)
     1660                    && pTransfer->Callbacks.pfnDataComplete)
     1661                {
     1662                    SHAREDCLIPBOARDURITRANSFERCALLBACKDATA callbackData = { pTransfer, pTransfer->Callbacks.pvUser };
     1663                    pTransfer->Callbacks.pfnDataComplete(&callbackData);
     1664                }
     1665
    14801666                if (pcbRead)
    14811667                    *pcbRead = cbReadTotal;
     
    15091695    uint32_t cbWrittenTotal = 0;
    15101696
     1697    AssertPtr(pTransfer->ProviderIface.pfnWriteDataHdr);
    15111698    int rc = pTransfer->ProviderIface.pfnWriteDataHdr(&pTransfer->ProviderCtx, pTransfer->State.pHeader);
    15121699    if (RT_SUCCESS(rc))
     
    15191706        {
    15201707            uint32_t cbMetaWritten;
     1708            AssertPtr(pTransfer->ProviderIface.pfnWriteDataChunk);
    15211709            rc = pTransfer->ProviderIface.pfnWriteDataChunk(&pTransfer->ProviderCtx, pTransfer->State.pHeader,
    15221710                                                            (uint8_t *)pTransfer->State.pMeta->pvMeta + cbWrittenTotal,
     
    15841772                dirData.cbPath  = (uint32_t)strlen(dirData.pszPath);
    15851773
     1774                AssertPtr(pTransfer->ProviderIface.pfnWriteDirectory);
    15861775                rc = pTransfer->ProviderIface.pfnWriteDirectory(&pTransfer->ProviderCtx, &dirData);
    15871776
     
    16081797                fileHdr.fMode       = pObj->GetMode();
    16091798
     1799                AssertPtr(pTransfer->ProviderIface.pfnWriteFileHdr);
    16101800                rc = pTransfer->ProviderIface.pfnWriteFileHdr(&pTransfer->ProviderCtx, &fileHdr);
    16111801                SharedClipboardURIFileHdrDestroy(&fileHdr);
     
    16261816                    {
    16271817                        uint32_t cbToRead = cbRead;
     1818                        AssertPtr(pTransfer->ProviderIface.pfnWriteFileData);
    16281819                        rc = pTransfer->ProviderIface.pfnWriteFileData(&pTransfer->ProviderCtx,
    16291820                                                                       pvData, cbToRead, 0 /* fFlags */, &cbRead);
     
    17051896    LogFlowFuncEnter();
    17061897
    1707     AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING,
    1708                     ("Transfer already is running\n"), VERR_WRONG_ORDER);
     1898    AssertMsgReturn(pTransfer->State.enmStatus == SHAREDCLIPBOARDURITRANSFERSTATUS_READY,
     1899                    ("Write transfer has wrong state (%RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER);
    17091900
    17101901    pTransfer->State.enmStatus = SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING;
     
    17941985    }
    17951986
    1796     pURI->cRunning  = 0;
    1797 #ifdef DEBUG
    1798     pURI->cTransfer = 0;
    1799 #endif
     1987    pURI->cRunning   = 0;
     1988    pURI->cTransfers = 0;
    18001989}
    18011990
     
    18352024    RTListAppend(&pURI->List, &pTransfer->Node);
    18362025
    1837 #ifdef DEBUG
    1838     pURI->cTransfer++;
    1839     LogFlowFunc(("cTransfers=%RU32, cRunning=%RU32\n", pURI->cTransfer, pURI->cRunning));
    1840 #endif
     2026    pURI->cTransfers++;
     2027    LogFlowFunc(("cTransfers=%RU32, cRunning=%RU32\n", pURI->cTransfers, pURI->cRunning));
    18412028
    18422029    return VINF_SUCCESS;
     
    18962083 * Returns the number of running URI transfers.
    18972084 *
    1898  * @returns VBox status code.
     2085 * @returns Number of running transfers.
    18992086 * @param   pURI                URI clipboard context to return number for.
    19002087 */
     
    19032090    AssertPtrReturn(pURI, 0);
    19042091    return pURI->cRunning;
     2092}
     2093
     2094/**
     2095 * Returns the number of total URI transfers.
     2096 *
     2097 * @returns Number of total transfers.
     2098 * @param   pURI                URI clipboard context to return number for.
     2099 */
     2100uint32_t SharedClipboardURICtxGetTotalTransfers(PSHAREDCLIPBOARDURICTX pURI)
     2101{
     2102    AssertPtrReturn(pURI, 0);
     2103    return pURI->cTransfers;
    19052104}
    19062105
     
    19262125            RTListNodeRemove(&pTransfer->Node);
    19272126
    1928 #ifdef DEBUG
    1929             Assert(pURI->cTransfer);
    1930             pURI->cTransfer--;
    1931 
    1932             LogFlowFunc(("cTransfers=%RU32\n", pURI->cTransfer));
    1933 #endif
     2127            Assert(pURI->cTransfers);
     2128            pURI->cTransfers--;
     2129
     2130            LogFlowFunc(("cTransfers=%RU32\n", pURI->cTransfers));
    19342131        }
    19352132    }
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp

    r79351 r79366  
    852852    int rc;
    853853
    854     if (pTransfer->pvUser)
    855     {
    856         Assert(pTransfer->cbUser == sizeof(SharedClipboardWinURITransferCtx));
    857         SharedClipboardWinURITransferCtx *pWinURITransferCtx = (SharedClipboardWinURITransferCtx *)pTransfer->pvUser;
    858         Assert(pWinURITransferCtx);
    859 
    860         if (pWinURITransferCtx->pDataObj)
    861             delete pWinURITransferCtx->pDataObj;
    862     }
     854    AssertReturn(pTransfer->pvUser == NULL, VERR_WRONG_ORDER);
    863855
    864856    SharedClipboardWinURITransferCtx *pWinURITransferCtx = new SharedClipboardWinURITransferCtx();
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h

    r79347 r79366  
    2929#include <VBox/GuestHost/SharedClipboard.h>
    3030#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     31# include <iprt/semaphore.h>
    3132# include <VBox/GuestHost/SharedClipboard-uri.h>
    3233#endif
     
    4344
    4445struct VBOXCLIPBOARDCLIENTSTATE;
    45 
    46 /**
    47  * Structure for maintaining a single URI transfer.
    48  * A transfer can contain one or multiple files / directories.
    49  */
    50 typedef struct _VBOXCLIPBOARDCLIENTURITRANSFER
    51 {
    52     /** Node for keeping this transfer in a RTList. */
    53     RTLISTNODE                     Node;
    54     /** Pointer to the client state (parent). */
    55     VBOXCLIPBOARDCLIENTSTATE      *pState;
    56     /** The transfer's own (local) area.
    57      *  The area itself has a clipboard area ID assigned, which gets shared (maintained / locked) across all
    58      *  VMs via VBoxSVC. */
    59     SharedClipboardArea            Area;
    60     /** The transfer's URI list, containing the fs object root entries. */
    61     SharedClipboardURIList         List;
    62     /** Current object being handled. */
    63     VBOXCLIPBOARDCLIENTURIOBJCTX   ObjCtx;
    64     /** The transfer header, needed for verification and accounting. */
    65     VBOXCLIPBOARDDATAHDR           Hdr;
    66     /** Intermediate meta data object. */
    67     SHAREDCLIPBOARDMETADATA        Meta;
    68 } VBOXCLIPBOARDCLIENTURITRANSFER, *PVBOXCLIPBOARDCLIENTURITRANSFER;
    6946#endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
    7047
     
    162139
    163140#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
     141int VBoxSvcClipboardProviderImplURIReadDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDATAHDR *ppDataHdr);
     142int VBoxSvcClipboardProviderImplURIWriteDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr);
     143int VBoxSvcClipboardProviderImplURIReadDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbRead);
     144int VBoxSvcClipboardProviderImplURIWriteDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbWritten);
     145int VBoxSvcClipboardProviderImplURIReadDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDIRDATA *ppDirData);
     146int VBoxSvcClipboardProviderImplURIWriteDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDIRDATA pDirData);
     147int VBoxSvcClipboardProviderImplURIReadFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDFILEHDR *ppFileHdr);
     148int VBoxSvcClipboardProviderImplURIWriteFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDFILEHDR pFileHdr);
     149int VBoxSvcClipboardProviderImplURIReadFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbRead);
     150int VBoxSvcClipboardProviderImplURIWriteFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbWritten);
     151
     152DECLCALLBACK(void) VBoxSvcClipboardURITransferPrepareCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
     153DECLCALLBACK(void) VBoxSvcClipboardURIDataHeaderCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
     154DECLCALLBACK(void) VBoxSvcClipboardURIDataCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
     155DECLCALLBACK(void) VBoxSvcClipboardURITransferCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
     156DECLCALLBACK(void) VBoxSvcClipboardURITransferCanceledCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
     157DECLCALLBACK(void) VBoxSvcClipboardURITransferErrorCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
     158
    164159int VBoxClipboardSvcImplURITransferCreate(PVBOXCLIPBOARDCLIENTDATA pClientData, PSHAREDCLIPBOARDURITRANSFER pTransfer);
    165160int VBoxClipboardSvcImplURITransferDestroy(PVBOXCLIPBOARDCLIENTDATA pClientData, PSHAREDCLIPBOARDURITRANSFER pTransfer);
    166161
    167 int VBoxClipboardSvcImplURIReadDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDATAHDR *ppDataHdr);
    168 int VBoxClipboardSvcImplURIWriteDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr);
    169 int VBoxClipboardSvcImplURIReadDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbRead);
    170 int VBoxClipboardSvcImplURIWriteDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbWritten);
    171 
    172 int VBoxClipboardSvcImplURIReadDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDIRDATA *ppDirData);
    173 int VBoxClipboardSvcImplURIWriteDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDIRDATA pDirData);
    174 
    175 int VBoxClipboardSvcImplURIReadFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDFILEHDR *ppFileHdr);
    176 int VBoxClipboardSvcImplURIWriteFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDFILEHDR pFileHdr);
    177 int VBoxClipboardSvcImplURIReadFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbRead);
    178 int VBoxClipboardSvcImplURIWriteFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbWritten);
     162void VBoxClipboardSvcImplURIOnDataHeaderComplete(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
    179163#endif
    180164
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.cpp

    r79347 r79366  
    4343
    4444
    45 static DECLCALLBACK(int) vboxSvcClipboardURIProviderImplReadDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx,
    46                                                                     PVBOXCLIPBOARDDATAHDR *ppDataHdr)
    47 {
    48     RT_NOREF(pCtx, ppDataHdr);
     45/*********************************************************************************************************************************
     46*   Provider implementation                                                                                                                    *
     47*********************************************************************************************************************************/
     48
     49int VBoxSvcClipboardProviderImplURIReadDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDATAHDR *ppDataHdr)
     50{
     51    LogFlowFuncEnter();
     52
     53    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pCtx->pvUser;
     54    AssertPtr(pClientData);
     55
     56    PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload;
     57    int rc = SharedClipboardURITransferEventWait(pCtx->pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_HDR,
     58                                                 30 * 1000 /* Timeout in ms */, &pPayload);
     59    if (RT_SUCCESS(rc))
     60    {
     61        Assert(pPayload->cbData == sizeof(VBOXCLIPBOARDDATAHDR));
     62        *ppDataHdr = (PVBOXCLIPBOARDDATAHDR)pPayload->pvData;
     63
     64        RTMemFree(pPayload);
     65    }
     66
     67    LogFlowFuncLeaveRC(rc);
     68    return rc;
     69}
     70
     71int VBoxSvcClipboardProviderImplURIWriteDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr)
     72{
     73    RT_NOREF(pCtx, pDataHdr);
     74
     75    LogFlowFuncEnter();
     76
    4977    return VERR_NOT_IMPLEMENTED;
    5078}
    5179
    52 static DECLCALLBACK(int) vboxSvcClipboardURIProviderImplReadObjHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx,
    53                                                                    PVBOXCLIPBOARDDATAHDR *ppDataHdr)
    54 {
    55     RT_NOREF(pCtx, ppDataHdr);
     80int VBoxSvcClipboardProviderImplURIReadDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr,
     81                                                 void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbRead)
     82{
     83    RT_NOREF(pDataHdr, fFlags);
     84
     85    LogFlowFuncEnter();
     86
     87    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pCtx->pvUser;
     88    AssertPtr(pClientData);
     89
     90    PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload;
     91    int rc = SharedClipboardURITransferEventWait(pCtx->pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_CHUNK,
     92                                                 30 * 1000 /* Timeout in ms */, &pPayload);
     93    if (RT_SUCCESS(rc))
     94    {
     95        Assert(pPayload->cbData == sizeof(VBOXCLIPBOARDDATACHUNK));
     96
     97        const uint32_t cbToRead = RT_MIN(cbChunk, pPayload->cbData);
     98
     99        memcpy(pvChunk, pPayload->pvData, cbToRead);
     100
     101        SharedClipboardURITransferPayloadFree(pPayload);
     102
     103        if (pcbRead)
     104            *pcbRead = cbToRead;
     105    }
     106
     107    LogFlowFuncLeaveRC(rc);
     108    return rc;
     109}
     110
     111int VBoxSvcClipboardProviderImplURIWriteDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr,
     112                                                  const void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbWritten)
     113{
     114    RT_NOREF(pCtx, pDataHdr, pvChunk, cbChunk, fFlags, pcbWritten);
     115
     116    LogFlowFuncEnter();
     117
    56118    return VERR_NOT_IMPLEMENTED;
    57119}
    58120
    59 static DECLCALLBACK(int) vboxSvcClipboardURIProviderImplReadDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx,
    60                                                                 PVBOXCLIPBOARDDIRDATA *ppDirData)
     121int VBoxSvcClipboardProviderImplURIReadDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDIRDATA *ppDirData)
    61122{
    62123    RT_NOREF(pCtx, ppDirData);
     124
     125    LogFlowFuncEnter();
     126
    63127    return VERR_NOT_IMPLEMENTED;
    64128}
    65129
    66 static DECLCALLBACK(int) vboxSvcClipboardURIProviderImplReadFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx,
    67                                                                     PVBOXCLIPBOARDFILEHDR *ppFileHdr)
     130int VBoxSvcClipboardProviderImplURIWriteDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDIRDATA pDirData)
     131{
     132    RT_NOREF(pCtx, pDirData);
     133
     134    LogFlowFuncEnter();
     135
     136    return VERR_NOT_IMPLEMENTED;
     137}
     138
     139int VBoxSvcClipboardProviderImplURIReadFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDFILEHDR *ppFileHdr)
    68140{
    69141    RT_NOREF(pCtx, ppFileHdr);
     142
     143    LogFlowFuncEnter();
     144
    70145    return VERR_NOT_IMPLEMENTED;
    71146}
    72147
    73 static DECLCALLBACK(int) vboxSvcClipboardURIProviderImplReadFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtX,
    74                                                                      void *pvData, uint32_t cbData, uint32_t fFlags,
    75                                                                      uint32_t *pcbRead)
    76 {
    77 #if 0
    78     const PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pCtx->pvUser;
    79 
    80     return pObjCtx->pObj->Read(pvBuf, cbBuf, pcbWritten);
    81 #endif
    82 
    83     RT_NOREF(pCtX, pvData, cbData, fFlags, pcbRead);
     148int VBoxSvcClipboardProviderImplURIWriteFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDFILEHDR pFileHdr)
     149{
     150    RT_NOREF(pCtx, pFileHdr);
     151
     152    LogFlowFuncEnter();
     153
    84154    return VERR_NOT_IMPLEMENTED;
    85155}
    86156
    87 #if 0
    88 int vboxSvcClipboardURIAnnounce(uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    89 {
    90     Provider.pfnReadDataHdr    = vboxSvcClipboardURIProviderImplReadDataHdr;
    91     Provider.pfnReadDataChunk  = vboxSvcClipboardURIProviderImplReadDataChunk;
    92     Provider.pfnReadDir        = vboxSvcClipboardURIProviderImplReadDir;
    93     Provider.pfnReadFileHdr    = vboxSvcClipboardURIProviderImplReadFileHdr;
    94     Provider.pfnReadFileData   = vboxSvcClipboardURIProviderImplReadFileData;
    95 
    96     Provider.pvUser =
    97 
    98     SharedClipboardURITransferSetProvider(&Provider);
    99 
    100     return rc;
    101 }
    102 #endif
     157int VBoxSvcClipboardProviderImplURIReadFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags,
     158                                                uint32_t *pcbRead)
     159{
     160    RT_NOREF(pCtx, pvData, cbData, fFlags, pcbRead);
     161
     162    LogFlowFuncEnter();
     163
     164    return VERR_NOT_IMPLEMENTED;
     165}
     166
     167int VBoxSvcClipboardProviderImplURIWriteFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags,
     168                                                 uint32_t *pcbWritten)
     169{
     170    RT_NOREF(pCtx, pvData, cbData, fFlags, pcbWritten);
     171
     172    LogFlowFuncEnter();
     173
     174    return VERR_NOT_IMPLEMENTED;
     175}
     176
     177/*********************************************************************************************************************************
     178*   URI callbacks                                                                                                                    *
     179*********************************************************************************************************************************/
     180
     181DECLCALLBACK(void) VBoxSvcClipboardURITransferPrepareCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
     182{
     183    LogFlowFuncEnter();
     184
     185    LogFlowFuncEnter();
     186
     187    AssertPtrReturnVoid(pData);
     188
     189    PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pData->pvUser;
     190    AssertPtrReturnVoid(pClientData);
     191
     192    /* Tell the guest that it can start sending URI data. */
     193    int rc2 = vboxSvcClipboardReportMsg(pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
     194                                        VBOX_SHARED_CLIPBOARD_FMT_URI_LIST);
     195    AssertRC(rc2);
     196
     197    rc2 = SharedClipboardURITransferEventRegister(pData->pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_HDR);
     198    AssertRC(rc2);
     199    rc2 = SharedClipboardURITransferEventRegister(pData->pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_CHUNK);
     200    AssertRC(rc2);
     201}
     202
     203DECLCALLBACK(void) VBoxSvcClipboardURIDataHeaderCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
     204{
     205    LogFlowFuncEnter();
     206
     207    RT_NOREF(pData);
     208}
     209
     210DECLCALLBACK(void) VBoxSvcClipboardURIDataCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
     211{
     212    LogFlowFuncEnter();
     213
     214    VBoxClipboardSvcImplURIOnDataHeaderComplete(pData);
     215}
     216
     217DECLCALLBACK(void) VBoxSvcClipboardURITransferCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc)
     218{
     219    LogFlowFuncEnter();
     220
     221    RT_NOREF(pData, rc);
     222
     223    LogRel2(("Shared Clipboard: Transfer complete\n"));
     224}
     225
     226DECLCALLBACK(void) VBoxSvcClipboardURITransferCanceledCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
     227{
     228    LogFlowFuncEnter();
     229
     230    RT_NOREF(pData);
     231
     232    LogRel2(("Shared Clipboard: Transfer canceled\n"));
     233}
     234
     235DECLCALLBACK(void) VBoxSvcClipboardURITransferErrorCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc)
     236{
     237    LogFlowFuncEnter();
     238
     239    RT_NOREF(pData, rc);
     240
     241    LogRel(("Shared Clipboard: Transfer failed with %Rrc\n", rc));
     242}
    103243
    104244/**
     
    497637    }
    498638
    499     if (!SharedClipboardURICtxGetRunningTransfers(&pClientData->URI))
    500     {
    501         LogFunc(("No running transfers found\n"));
     639    if (!SharedClipboardURICtxGetTotalTransfers(&pClientData->URI))
     640    {
     641        LogFunc(("No transfers found\n"));
    502642        return VERR_WRONG_ORDER;
    503643    }
     
    534674            rc = SharedClipboardURIDataHdrInit(&dataHdr);
    535675            if (RT_SUCCESS(rc))
     676            {
    536677                rc = VBoxSvcClipboardURIGetDataHdr(cParms, paParms, &dataHdr);
    537             /*if (RT_SUCCESS(rc))
    538                 rc = SharedClipboardURITransferSetDataHeader(&dataHdr);*/
     678                if (RT_SUCCESS(rc))
     679                {
     680                    void    *pvData = SharedClipboardURIDataHdrDup(&dataHdr);
     681                    uint32_t cbData = sizeof(VBOXCLIPBOARDDATAHDR);
     682
     683                    PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload;
     684                    rc = SharedClipboardURITransferPayloadAlloc(SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_HDR,
     685                                                                pvData, cbData, &pPayload);
     686                    if (RT_SUCCESS(rc))
     687                    {
     688                        rc = SharedClipboardURITransferEventSignal(pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_HDR,
     689                                                                   pPayload);
     690                    }
     691                }
     692            }
    539693            break;
    540694        }
     
    553707            rc = SharedClipboardURIDataChunkInit(&dataChunk);
    554708            if (RT_SUCCESS(rc))
     709            {
    555710                rc = VBoxSvcClipboardURIGetDataChunk(cParms, paParms, &dataChunk);
    556     #if 0
    557             if (RT_SUCCESS(rc))
    558             {
    559                 VBOXCLIPBOARDTRANSFEREVENT Event = { &dataChunk, sizeof(dataChunk) };
    560                 rc = SharedClipboardURITransferSendEvent(WRITE_DATA_CHUNK, &Event);
     711                if (RT_SUCCESS(rc))
     712                {
     713                    void    *pvData = SharedClipboardURIDataChunkDup(&dataChunk);
     714                    uint32_t cbData = sizeof(VBOXCLIPBOARDDATACHUNK);
     715
     716                    PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload;
     717                    rc = SharedClipboardURITransferPayloadAlloc(SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_CHUNK,
     718                                                                pvData, cbData, &pPayload);
     719                    if (RT_SUCCESS(rc))
     720                    {
     721                        rc = SharedClipboardURITransferEventSignal(pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_METADATA_CHUNK,
     722                                                                   pPayload);
     723                    }
     724
     725                }
    561726            }
    562         #endif
    563727            break;
    564728        }
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp

    r79347 r79366  
    138138    Assert(pCtx->pClientData->State.data.pv == NULL && pCtx->pClientData->State.data.cb == 0 && pCtx->pClientData->State.data.u32Format == 0);
    139139
    140     LogFlowFunc(("fFormat=%02X\n", fFormat));
     140    LogFlowFunc(("fFormat=%02X, uTimeoutMs=%RU32\n", fFormat, uTimeoutMs));
    141141
    142142    int rc = vboxSvcClipboardReportMsg(pCtx->pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA, fFormat);
     
    770770
    771771#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    772 DECLCALLBACK(void) vboxClipboardSvcWinURITransferPrepareCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
    773 {
    774     LogFlowFuncEnter();
    775 
    776     AssertPtrReturnVoid(pData);
    777 
    778     PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pData->pvUser;
    779     AssertPtrReturnVoid(pClientData);
    780 
    781     /* Tell the guest that it can start sending URI data. */
    782     int rc2 = vboxSvcClipboardReportMsg(pClientData, VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA,
    783                                         VBOX_SHARED_CLIPBOARD_FMT_URI_LIST);
    784     AssertRC(rc2);
    785 }
    786 
    787 DECLCALLBACK(void) vboxClipboardSvcWinURIDataCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
     772void VBoxClipboardSvcImplURIOnDataHeaderComplete(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData)
    788773{
    789774    LogFlowFuncEnter();
     
    804789int VBoxClipboardSvcImplURITransferCreate(PVBOXCLIPBOARDCLIENTDATA pClientData, PSHAREDCLIPBOARDURITRANSFER pTransfer)
    805790{
     791    RT_NOREF(pClientData, pTransfer);
     792
    806793    LogFlowFuncEnter();
    807794
    808     /* Register needed callbacks so that we can wait for the meta data to arrive here. */
    809     SHAREDCLIPBOARDURITRANSFERCALLBACKS Callbacks;
    810     RT_ZERO(Callbacks);
    811 
    812     Callbacks.pvUser              = pClientData;
    813     Callbacks.pfnTransferPrepare  = vboxClipboardSvcWinURITransferPrepareCallback;
    814 
    815     SharedClipboardURITransferSetCallbacks(pTransfer, &Callbacks);
    816 
    817795    return VINF_SUCCESS;
    818796}
     
    826804    return VINF_SUCCESS;
    827805}
    828 
    829 int VBoxClipboardSvcImplURIReadDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDATAHDR *ppDataHdr)
    830 {
    831     RT_NOREF(ppDataHdr);
    832 
    833     LogFlowFuncEnter();
    834 
    835     PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pCtx->pvUser;
    836     AssertPtr(pClientData);
    837 
    838 
    839     return VERR_NOT_IMPLEMENTED;
    840 }
    841 
    842 int VBoxClipboardSvcImplURIWriteDataHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr)
    843 {
    844     RT_NOREF(pCtx, pDataHdr);
    845     return VERR_NOT_IMPLEMENTED;
    846 }
    847 
    848 int VBoxClipboardSvcImplURIReadDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr,
    849                                          void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbRead)
    850 {
    851     RT_NOREF(pCtx, pDataHdr, pvChunk, cbChunk, fFlags, pcbRead);
    852     return VERR_NOT_IMPLEMENTED;
    853 }
    854 
    855 int VBoxClipboardSvcImplURIWriteDataChunk(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDATAHDR pDataHdr,
    856                                           const void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbWritten)
    857 {
    858     RT_NOREF(pCtx, pDataHdr, pvChunk, cbChunk, fFlags, pcbWritten);
    859     return VERR_NOT_IMPLEMENTED;
    860 }
    861 
    862 int VBoxClipboardSvcImplURIReadDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDDIRDATA *ppDirData)
    863 {
    864     RT_NOREF(pCtx, ppDirData);
    865     return VERR_NOT_IMPLEMENTED;
    866 }
    867 
    868 int VBoxClipboardSvcImplURIWriteDir(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDDIRDATA pDirData)
    869 {
    870     RT_NOREF(pCtx, pDirData);
    871     return VERR_NOT_IMPLEMENTED;
    872 }
    873 
    874 int VBoxClipboardSvcImplURIReadFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, PVBOXCLIPBOARDFILEHDR *ppFileHdr)
    875 {
    876     RT_NOREF(pCtx, ppFileHdr);
    877     return VERR_NOT_IMPLEMENTED;
    878 }
    879 
    880 int VBoxClipboardSvcImplURIWriteFileHdr(PSHAREDCLIPBOARDPROVIDERCTX pCtx, const PVBOXCLIPBOARDFILEHDR pFileHdr)
    881 {
    882     RT_NOREF(pCtx, pFileHdr);
    883     return VERR_NOT_IMPLEMENTED;
    884 }
    885 
    886 int VBoxClipboardSvcImplURIReadFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags,
    887                                         uint32_t *pcbRead)
    888 {
    889     RT_NOREF(pCtx, pvData, cbData, fFlags, pcbRead);
    890     return VERR_NOT_IMPLEMENTED;
    891 }
    892 
    893 int VBoxClipboardSvcImplURIWriteFileData(PSHAREDCLIPBOARDPROVIDERCTX pCtx, void *pvData, uint32_t cbData, uint32_t fFlags,
    894                                          uint32_t *pcbWritten)
    895 {
    896     RT_NOREF(pCtx, pvData, cbData, fFlags, pcbWritten);
    897     return VERR_NOT_IMPLEMENTED;
    898 }
    899806#endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */
    900807
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r79347 r79366  
    677677
    678678                                        RT_ZERO(creationCtx.Interface);
    679                                         creationCtx.Interface.pfnReadDataHdr    = VBoxClipboardSvcImplURIReadDataHdr;
    680                                         creationCtx.Interface.pfnReadDataChunk  = VBoxClipboardSvcImplURIReadDataChunk;
    681                                         creationCtx.Interface.pfnReadDirectory  = VBoxClipboardSvcImplURIReadDir;
    682                                         creationCtx.Interface.pfnReadFileHdr    = VBoxClipboardSvcImplURIReadFileHdr;
    683                                         creationCtx.Interface.pfnReadFileData   = VBoxClipboardSvcImplURIReadFileData;
    684 
    685                                         creationCtx.Interface.pfnWriteDataHdr    = VBoxClipboardSvcImplURIWriteDataHdr;
    686                                         creationCtx.Interface.pfnWriteDataChunk  = VBoxClipboardSvcImplURIWriteDataChunk;
    687                                         creationCtx.Interface.pfnWriteDirectory  = VBoxClipboardSvcImplURIWriteDir;
    688                                         creationCtx.Interface.pfnWriteFileHdr    = VBoxClipboardSvcImplURIWriteFileHdr;
    689                                         creationCtx.Interface.pfnWriteFileData   = VBoxClipboardSvcImplURIWriteFileData;
     679                                        creationCtx.Interface.pfnReadDataHdr    = VBoxSvcClipboardProviderImplURIReadDataHdr;
     680                                        creationCtx.Interface.pfnReadDataChunk  = VBoxSvcClipboardProviderImplURIReadDataChunk;
     681                                        creationCtx.Interface.pfnReadDirectory  = VBoxSvcClipboardProviderImplURIReadDir;
     682                                        creationCtx.Interface.pfnReadFileHdr    = VBoxSvcClipboardProviderImplURIReadFileHdr;
     683                                        creationCtx.Interface.pfnReadFileData   = VBoxSvcClipboardProviderImplURIReadFileData;
    690684
    691685                                        creationCtx.pvUser = pClientData;
    692686
    693                                         creationCtx.u.HostService.pArea = pTransfer->pArea;
     687                                        /* Register needed callbacks so that we can wait for the meta data to arrive here. */
     688                                        SHAREDCLIPBOARDURITRANSFERCALLBACKS Callbacks;
     689                                        RT_ZERO(Callbacks);
     690
     691                                        Callbacks.pvUser                = pClientData;
     692
     693                                        Callbacks.pfnTransferPrepare    = VBoxSvcClipboardURITransferPrepareCallback;
     694                                        Callbacks.pfnDataHeaderComplete = VBoxSvcClipboardURIDataHeaderCompleteCallback;
     695                                        Callbacks.pfnDataComplete       = VBoxSvcClipboardURIDataCompleteCallback;
     696                                        Callbacks.pfnTransferComplete   = VBoxSvcClipboardURITransferCompleteCallback;
     697                                        Callbacks.pfnTransferCanceled   = VBoxSvcClipboardURITransferCanceledCallback;
     698                                        Callbacks.pfnTransferError      = VBoxSvcClipboardURITransferErrorCallback;
     699
     700                                        SharedClipboardURITransferSetCallbacks(pTransfer, &Callbacks);
    694701
    695702                                        rc = SharedClipboardURITransferProviderCreate(pTransfer, &creationCtx);
     
    790797                                    RT_ZERO(creationCtx.Interface);
    791798
    792                                     creationCtx.Interface.pfnReadDataHdr    = VBoxClipboardSvcImplURIReadDataHdr;
    793                                     creationCtx.Interface.pfnReadDataChunk  = VBoxClipboardSvcImplURIReadDataChunk;
    794                                     creationCtx.Interface.pfnReadDirectory  = VBoxClipboardSvcImplURIReadDir;
    795                                     creationCtx.Interface.pfnReadFileHdr    = VBoxClipboardSvcImplURIReadFileHdr;
    796                                     creationCtx.Interface.pfnReadFileData   = VBoxClipboardSvcImplURIReadFileData;
    797 
    798                                     creationCtx.Interface.pfnWriteDataHdr    = VBoxClipboardSvcImplURIWriteDataHdr;
    799                                     creationCtx.Interface.pfnWriteDataChunk  = VBoxClipboardSvcImplURIWriteDataChunk;
    800                                     creationCtx.Interface.pfnWriteDirectory  = VBoxClipboardSvcImplURIWriteDir;
    801                                     creationCtx.Interface.pfnWriteFileHdr    = VBoxClipboardSvcImplURIWriteFileHdr;
    802                                     creationCtx.Interface.pfnWriteFileData   = VBoxClipboardSvcImplURIWriteFileData;
     799                                    creationCtx.Interface.pfnWriteDataHdr    = VBoxSvcClipboardProviderImplURIWriteDataHdr;
     800                                    creationCtx.Interface.pfnWriteDataChunk  = VBoxSvcClipboardProviderImplURIWriteDataChunk;
     801                                    creationCtx.Interface.pfnWriteDirectory  = VBoxSvcClipboardProviderImplURIWriteDir;
     802                                    creationCtx.Interface.pfnWriteFileHdr    = VBoxSvcClipboardProviderImplURIWriteFileHdr;
     803                                    creationCtx.Interface.pfnWriteFileData   = VBoxSvcClipboardProviderImplURIWriteFileData;
    803804
    804805                                    creationCtx.pvUser = pClientData;
    805 
    806                                     creationCtx.u.HostService.pArea = pTransfer->pArea;
    807806
    808807                                    rc = SharedClipboardURITransferProviderCreate(pTransfer, &creationCtx);
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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