VirtualBox

Changeset 79366 in vbox for trunk/include


Ignore:
Timestamp:
Jun 26, 2019 3:59:30 PM (6 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Update.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
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