VirtualBox

Changeset 79347 in vbox for trunk/include


Ignore:
Timestamp:
Jun 26, 2019 9:15:29 AM (6 years ago)
Author:
vboxsync
Message:

Shared Clipboard/URI: Update.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:mergeinfo
      •  

        old new  
        99/branches/VBox-5.1:112367,115992,116543,116550,116568,116573
        1010/branches/VBox-5.2:119536,120083,120099,120213,120221,120239,123597-123598,123600-123601,123755,124260,124263,124271,124273,124277-124279,124284-124286,124288-124290,125768,125779-125780,125812
        11 /branches/VBox-6.0:130474-130475,130477,130479
         11/branches/VBox-6.0:130474-130475,130477,130479,131352
        1212/branches/aeichner/vbox-chromium-cleanup:129816,129818-129851,129853-129861,129871-129872,129876,129880,129882,130013-130015,130036,130094-130095
        1313/branches/andy/draganddrop:90781-91268
  • trunk/include/VBox/GuestHost/SharedClipboard-uri.h

    r79299 r79347  
    6161#define SHAREDCLIPBOARDAREA_OPEN_FLAGS_VALID_MASK         0x1
    6262
    63 /**
    64  * Class for maintaining a Shared Clipboard area
    65  * on the host or guest. This will contain all received files & directories
    66  * for a single Shared Clipboard operation.
    67  *
    68  * In case of a failed Shared Clipboard operation this class can also
    69  * perform a gentle rollback if required.
    70  */
    71 class SharedClipboardArea
    72 {
    73 public:
    74 
    75     SharedClipboardArea(void);
    76     SharedClipboardArea(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
    77                         SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
    78     virtual ~SharedClipboardArea(void);
    79 
    80 public:
    81 
    82     uint32_t AddRef(void);
    83     uint32_t Release(void);
    84 
    85     int Lock(void);
    86     int Unlock(void);
    87 
    88     int AddFile(const char *pszFile);
    89     int AddDir(const char *pszDir);
    90     int Close(void);
    91     bool IsOpen(void) const;
    92     int OpenEx(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
    93                SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
    94     int OpenTemp(SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
    95                  SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
    96     SHAREDCLIPBOARDAREAID GetID(void) const;
    97     const char *GetDirAbs(void) const;
    98     uint32_t GetRefCount(void);
    99     int Reopen(void);
    100     int Reset(bool fDeleteContent);
    101     int Rollback(void);
    102 
    103 public:
    104 
    105     static int PathConstruct(const char *pszBase, SHAREDCLIPBOARDAREAID uID, char *pszPath, size_t cbPath);
    106 
    107 protected:
    108 
    109     int initInternal(void);
    110     int destroyInternal(void);
    111     int closeInternal(void);
    112 
    113 protected:
    114 
    115     /** Creation timestamp (in ms). */
    116     uint64_t                     m_tsCreatedMs;
    117     /** Number of references to this instance. */
    118     volatile uint32_t            m_cRefs;
    119     /** Critical section for serializing access. */
    120     RTCRITSECT                   m_CritSect;
    121     /** Open flags. */
    122     uint32_t                     m_fOpen;
    123     /** Directory handle for drop directory. */
    124     RTDIR                        m_hDir;
    125     /** Absolute path to drop directory. */
    126     RTCString                    m_strPathAbs;
    127     /** List for holding created directories in the case of a rollback. */
    128     RTCList<RTCString>           m_lstDirs;
    129     /** List for holding created files in the case of a rollback. */
    130     RTCList<RTCString>           m_lstFiles;
    131     /** Associated clipboard area ID. */
    132     SHAREDCLIPBOARDAREAID        m_uID;
    133 };
    134 
    135 int SharedClipboardPathSanitizeFilename(char *pszPath, size_t cbPath);
    136 int SharedClipboardPathSanitize(char *pszPath, size_t cbPath);
    137 
    13863/** SharedClipboardURIObject flags. */
    13964typedef uint32_t SHAREDCLIPBOARDURIOBJECTFLAGS;
     
    16691        /** The usual 32-bit hack. */
    16792        Type_32Bit_Hack = 0x7fffffff
     93    };
     94
     95    enum Storage
     96    {
     97        Storage_Unknown = 0,
     98        Storage_Local,
     99        Storage_Temporary,
     100        /** The usual 32-bit hack. */
     101        Storage_32Bit_Hack = 0x7fffffff
    168102    };
    169103
     
    269203    /** The object's view. */
    270204    View      m_enmView;
     205    /** Where the object is being stored to. */
     206    Storage   m_enmStorage;
    271207    /** Absolute path (base) for the source. */
    272208    RTCString m_strSrcPathAbs;
     
    309245};
    310246
     247/**
     248 * Enumeration for specifying a clipboard area object type.
     249 */
     250typedef enum _SHAREDCLIPBOARDAREAOBJTYPE
     251{
     252    /** Unknown object type; do not use. */
     253    SHAREDCLIPBOARDAREAOBJTYPE_UNKNOWN = 0,
     254    /** Object is a directory. */
     255    SHAREDCLIPBOARDAREAOBJTYPE_DIR,
     256    /** Object is a file. */
     257    SHAREDCLIPBOARDAREAOBJTYPE_FILE,
     258    /** The usual 32-bit hack. */
     259    SHAREDCLIPBOARDAREAOBJTYPE__32Bit_Hack = 0x7fffffff
     260} SHAREDCLIPBOARDAREAOBJTYPE;
     261
     262/** Defines a clipboard area object state. */
     263typedef uint32_t SHAREDCLIPBOARDAREAOBJSTATE;
     264
     265/** No object state set. */
     266#define SHAREDCLIPBOARDAREAOBJSTATE_NONE                0
     267/** The object is considered as being complete (e.g. serialized). */
     268#define SHAREDCLIPBOARDAREAOBJSTATE_COMPLETE            RT_BIT(0)
     269
     270/**
     271 * Lightweight structure to keep a clipboard area object's state.
     272 *
     273 * Note: We don't want to use the ClipboardURIObject class here, as this
     274 *       is too heavy for this purpose.
     275 */
     276typedef struct _SHAREDCLIPBOARDAREAOBJ
     277{
     278    SHAREDCLIPBOARDAREAOBJTYPE  enmType;
     279    SHAREDCLIPBOARDAREAOBJSTATE fState;
     280} SHAREDCLIPBOARDAREAOBJ, *PSHAREDCLIPBOARDAREAOBJ;
     281
     282/**
     283 * Class for maintaining a Shared Clipboard area
     284 * on the host or guest. This will contain all received files & directories
     285 * for a single Shared Clipboard operation.
     286 *
     287 * In case of a failed Shared Clipboard operation this class can also
     288 * perform a gentle rollback if required.
     289 */
     290class SharedClipboardArea
     291{
     292public:
     293
     294    SharedClipboardArea(void);
     295    SharedClipboardArea(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
     296                        SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
     297    virtual ~SharedClipboardArea(void);
     298
     299public:
     300
     301    uint32_t AddRef(void);
     302    uint32_t Release(void);
     303
     304    int Lock(void);
     305    int Unlock(void);
     306
     307    int AddObject(const char *pszPath, const SHAREDCLIPBOARDAREAOBJ &Obj);
     308    int GetObject(const char *pszPath, PSHAREDCLIPBOARDAREAOBJ pObj);
     309
     310    int Close(void);
     311    bool IsOpen(void) const;
     312    int OpenEx(const char *pszPath, SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
     313               SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
     314    int OpenTemp(SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID,
     315                 SHAREDCLIPBOARDAREAOPENFLAGS fFlags = SHAREDCLIPBOARDAREA_OPEN_FLAGS_NONE);
     316    SHAREDCLIPBOARDAREAID GetID(void) const;
     317    const char *GetDirAbs(void) const;
     318    uint32_t GetRefCount(void);
     319    int Reopen(void);
     320    int Reset(bool fDeleteContent);
     321    int Rollback(void);
     322
     323public:
     324
     325    static int PathConstruct(const char *pszBase, SHAREDCLIPBOARDAREAID uID, char *pszPath, size_t cbPath);
     326
     327protected:
     328
     329    int initInternal(void);
     330    int destroyInternal(void);
     331    int closeInternal(void);
     332
     333protected:
     334
     335    typedef std::map<RTCString, SHAREDCLIPBOARDAREAOBJ> SharedClipboardAreaFsObjMap;
     336
     337    /** Creation timestamp (in ms). */
     338    uint64_t                     m_tsCreatedMs;
     339    /** Number of references to this instance. */
     340    volatile uint32_t            m_cRefs;
     341    /** Critical section for serializing access. */
     342    RTCRITSECT                   m_CritSect;
     343    /** Open flags. */
     344    uint32_t                     m_fOpen;
     345    /** Directory handle for root clipboard directory. */
     346    RTDIR                        m_hDir;
     347    /** Absolute path to root clipboard directory. */
     348    RTCString                    m_strPathAbs;
     349    /** List for holding created directories in the case of a rollback. */
     350    SharedClipboardAreaFsObjMap  m_mapObj;
     351    /** Associated clipboard area ID. */
     352    SHAREDCLIPBOARDAREAID        m_uID;
     353};
     354
     355int SharedClipboardPathSanitizeFilename(char *pszPath, size_t cbPath);
     356int SharedClipboardPathSanitize(char *pszPath, size_t cbPath);
     357
    311358/** SharedClipboardURIList flags. */
    312359typedef uint32_t SHAREDCLIPBOARDURILISTFLAGS;
     
    408455int SharedClipboardURIFileHdrInit(PVBOXCLIPBOARDFILEHDR pFileHdr);
    409456void SharedClipboardURIFileHdrDestroy(PVBOXCLIPBOARDFILEHDR pFileHdr);
     457void SharedClipboardURIFileHdrFree(PVBOXCLIPBOARDFILEHDR pFileHdr);
    410458PVBOXCLIPBOARDFILEHDR SharedClipboardURIFileHdrDup(PVBOXCLIPBOARDFILEHDR pFileHdr);
    411459bool SharedClipboardURIFileHdrIsValid(PVBOXCLIPBOARDFILEHDR pFileHdr, PVBOXCLIPBOARDDATAHDR pDataHdr);
     
    457505    /** How many bytes are being used in the meta data block. */
    458506    uint32_t                    cbUsed;
     507    /** Current reading offset (in bytes). */
     508    uint32_t                    cbOffRead;
    459509} SHAREDCLIPBOARDMETADATA, *PSHAREDCLIPBOARDMETADATA;
    460510
    461511int SharedClipboardMetaDataInit(PSHAREDCLIPBOARDMETADATA pMeta, SHAREDCLIPBOARDMETADATAFMT enmFmt);
    462512void SharedClipboardMetaDataDestroy(PSHAREDCLIPBOARDMETADATA pMeta);
     513void SharedClipboardMetaDataFree(PSHAREDCLIPBOARDMETADATA pMeta);
    463514int SharedClipboardMetaDataAdd(PSHAREDCLIPBOARDMETADATA pMeta, const void *pvDataAdd, uint32_t cbDataAdd);
    464515int SharedClipboardMetaDataConvertToFormat(const void *pvData, size_t cbData, SHAREDCLIPBOARDMETADATAFMT enmFmt,
    465516                                           void **ppvData, uint32_t *pcbData);
     517int SharedClipboardMetaDataRead(PSHAREDCLIPBOARDMETADATA pMeta, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
    466518int SharedClipboardMetaDataResize(PSHAREDCLIPBOARDMETADATA pMeta, uint32_t cbNewSize);
    467519size_t SharedClipboardMetaDataGetFree(PSHAREDCLIPBOARDMETADATA pMeta);
     
    486538} SHAREDCLIPBOARDURITRANSFERDIR;
    487539
     540struct _SHAREDCLIPBOARDURITRANSFER;
     541typedef struct _SHAREDCLIPBOARDURITRANSFER SHAREDCLIPBOARDURITRANSFER;
     542
     543/**
     544 * Structure for handling a single URI object context.
     545 */
     546typedef struct _SHAREDCLIPBOARDCLIENTURIOBJCTX
     547{
     548    SHAREDCLIPBOARDURITRANSFER    *pTransfer;
     549    /** Pointer to current object being processed. */
     550    SharedClipboardURIObject      *pObj;
     551} SHAREDCLIPBOARDCLIENTURIOBJCTX, *PSHAREDCLIPBOARDCLIENTURIOBJCTX;
     552
     553/**
     554 * Enumeration specifying an URI transfer status.
     555 */
     556typedef enum SHAREDCLIPBOARDURITRANSFERSTATUS
     557{
     558    /** No status set. */
     559    SHAREDCLIPBOARDURITRANSFERSTATUS_NONE = 0,
     560    /** The transfer has been announced but is not running yet. */
     561    SHAREDCLIPBOARDURITRANSFERSTATUS_ANNOUNCED,
     562    /** The transfer is active and running. */
     563    SHAREDCLIPBOARDURITRANSFERSTATUS_RUNNING
     564};
     565
     566/**
     567 * Enumeration to specify the Shared Clipboard URI source type.
     568 */
     569typedef enum SHAREDCLIPBOARDSOURCE
     570{
     571    /** Invalid source type. */
     572    SHAREDCLIPBOARDSOURCE_INVALID = 0,
     573    /** Source is local. */
     574    SHAREDCLIPBOARDSOURCE_LOCAL,
     575    /** Source is remote. */
     576    SHAREDCLIPBOARDSOURCE_REMOTE,
     577    /** The usual 32-bit hack. */
     578    SHAREDCLIPBOARDSOURCE_32Bit_Hack = 0x7fffffff
     579} SHAREDCLIPBOARDSOURCE;
     580
    488581/**
    489582 * Structure for maintaining an URI transfer state.
     
    492585typedef struct _SHAREDCLIPBOARDURITRANSFERSTATE
    493586{
     587    /** The transfer's current status. */
     588    SHAREDCLIPBOARDURITRANSFERSTATUS    enmStatus;
    494589    /** The transfer's direction. */
    495     SHAREDCLIPBOARDURITRANSFERDIR enmDir;
     590    SHAREDCLIPBOARDURITRANSFERDIR       enmDir;
     591    /** The transfer's source. */
     592    SHAREDCLIPBOARDSOURCE               enmSource;
     593    bool                                fHostMsgSendHeader;
    496594    /** The transfer's cached data header.
    497595     *  Can be NULL if no header has been received yet. */
    498     PVBOXCLIPBOARDDATAHDR         pHeader;
     596    PVBOXCLIPBOARDDATAHDR               pHeader;
     597    bool                                fHostMsgSendMetaDataHdr;
     598    bool                                fHostMsgSendMetaDataChunk;
    499599    /** The transfer's cached meta data.
    500600     *  Can be NULL if no meta data has been received yet. */
    501     PSHAREDCLIPBOARDMETADATA      pMeta;
     601    PSHAREDCLIPBOARDMETADATA            pMeta;
     602    /** Context of current object being handled. */
     603    SHAREDCLIPBOARDCLIENTURIOBJCTX      ObjCtx;
    502604} SHAREDCLIPBOARDURITRANSFERSTATE, *PSHAREDCLIPBOARDURITRANSFERSTATE;
    503605
    504 /**
    505  * Enumeration to specify the Shared Clipboard URI provider source type.
    506  */
    507 typedef enum SHAREDCLIPBOARDURIPROVIDERSOURCE
    508 {
    509     /** Invalid source type. */
    510     SHAREDCLIPBOARDURIPROVIDERSOURCE_INVALID = 0,
    511     /** Source is VbglR3. */
    512     SHAREDCLIPBOARDURIPROVIDERSOURCE_VBGLR3,
    513     /** Source is the host service. */
    514     SHAREDCLIPBOARDURIPROVIDERSOURCE_HOSTSERVICE
    515 } SHAREDCLIPBOARDURIPROVIDERSOURCE;
    516 
    517 class SharedClipboardProvider;
    518 
    519 /**
    520  * Structure for storing clipboard provider callback data.
    521  */
    522 typedef struct _SHAREDCLIPBOARDPROVIDERCALLBACKDATA
    523 {
    524     /** Pointer to related clipboard provider ("this"). */
    525     SharedClipboardProvider    *pProvider;
    526     /** Saved user pointer. */
     606struct _SHAREDCLIPBOARDURITRANSFER;
     607typedef struct _SHAREDCLIPBOARDURITRANSFER *PSHAREDCLIPBOARDURITRANSFER;
     608
     609typedef struct _SHAREDCLIPBOARDPROVIDERCTX
     610{
     611    PSHAREDCLIPBOARDURITRANSFER pTransfer;
    527612    void                       *pvUser;
    528 } SHAREDCLIPBOARDPROVIDERCALLBACKDATA, *PSHAREDCLIPBOARDPROVIDERCALLBACKDATA;
    529 
    530 /** Callback functopn for the Shared Clipboard provider. */
    531 typedef DECLCALLBACK(int) FNSSHAREDCLIPBOARDPROVIDERCALLBACK(PSHAREDCLIPBOARDPROVIDERCALLBACKDATA pData);
    532 /** Pointer to a FNSSHAREDCLIPBOARDPROVIDERCALLBACK function. */
    533 typedef FNSSHAREDCLIPBOARDPROVIDERCALLBACK *PFNSSHAREDCLIPBOARDPROVIDERCALLBACK;
    534 
    535 /**
    536  * Structure acting as a function callback table for clipboard providers.
    537  * All callbacks are optional and therefore can be NULL.
    538  */
    539 typedef struct _SHAREDCLIPBOARDPROVIDERCALLBACKS
    540 {
    541     /** Saved user pointer. Will be passed to the callback (if needed). */
    542     void                                    *pvUser;
    543     /** Function pointer, called when reading the (meta) data header. */
    544     PFNSSHAREDCLIPBOARDPROVIDERCALLBACK      pfnReadDataHdr;
    545     /** Function pointer, called when reading a (meta) data chunk. */
    546     PFNSSHAREDCLIPBOARDPROVIDERCALLBACK      pfnReadDataChunk;
    547 } SHAREDCLIPBOARDPROVIDERCALLBACKS, *PSHAREDCLIPBOARDPROVIDERCALLBACKS;
     613} SHAREDCLIPBOARDPROVIDERCTX, *PSHAREDCLIPBOARDPROVIDERCTX;
     614
     615#define SHAREDCLIPBOARDPROVIDERFUNCDECL(a_Name, ...) \
     616    typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX, __VA_ARGS__); \
     617    typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
     618
     619#define SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(a_Name) \
     620    typedef DECLCALLBACK(int) RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name)(PSHAREDCLIPBOARDPROVIDERCTX); \
     621    typedef RT_CONCAT(FNSHAREDCLIPBOARDPROVIDER, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDPROVIDER, a_Name);
     622
     623#define SHAREDCLIPBOARDPROVIDERFUNCMEMBER(a_Name, a_Member) \
     624    RT_CONCAT(PFNSHAREDCLIPBOARDPROVIDER, a_Name) a_Member;
     625
     626SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(PREPARE)
     627SHAREDCLIPBOARDPROVIDERFUNCDECL(READDATAHDR, PVBOXCLIPBOARDDATAHDR *ppDataHdr)
     628SHAREDCLIPBOARDPROVIDERFUNCDECL(WRITEDATAHDR, const PVBOXCLIPBOARDDATAHDR pDataHdr)
     629SHAREDCLIPBOARDPROVIDERFUNCDECL(READDATACHUNK, const PVBOXCLIPBOARDDATAHDR pDataHdr, void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbRead)
     630SHAREDCLIPBOARDPROVIDERFUNCDECL(WRITEDATACHUNK, const PVBOXCLIPBOARDDATAHDR pDataHdr, const void *pvChunk, uint32_t cbChunk, uint32_t fFlags, uint32_t *pcbWritten)
     631SHAREDCLIPBOARDPROVIDERFUNCDECL(READOBJHDR, PVBOXCLIPBOARDOBJHDR *ppObjHdr)
     632SHAREDCLIPBOARDPROVIDERFUNCDECL(READDIRECTORY, PVBOXCLIPBOARDDIRDATA *ppDirData)
     633SHAREDCLIPBOARDPROVIDERFUNCDECL(WRITEDIRECTORY, const PVBOXCLIPBOARDDIRDATA pDirData)
     634SHAREDCLIPBOARDPROVIDERFUNCDECL(READFILEHDR, PVBOXCLIPBOARDFILEHDR *ppFileHdr);
     635SHAREDCLIPBOARDPROVIDERFUNCDECL(WRITEFILEHDR, const PVBOXCLIPBOARDFILEHDR pFileHdr);
     636SHAREDCLIPBOARDPROVIDERFUNCDECL(READFILEDATA, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbRead)
     637SHAREDCLIPBOARDPROVIDERFUNCDECL(WRITEFILEDATA, void *pvData, uint32_t cbData, uint32_t fFlags, uint32_t *pcbWritten)
     638SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(RESET)
     639
     640typedef struct _SHAREDCLIPBOARDPROVIDERINTERFACE
     641{
     642    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(PREPARE, pfnPrepare);
     643    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(READDATAHDR, pfnReadDataHdr);
     644    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(WRITEDATAHDR, pfnWriteDataHdr);
     645    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(WRITEDATACHUNK, pfnWriteDataChunk);
     646    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(READDATACHUNK, pfnReadDataChunk);
     647    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(READOBJHDR, pfnReadObjHdr);
     648    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(READDIRECTORY, pfnReadDirectory);
     649    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(WRITEDIRECTORY, pfnWriteDirectory);
     650    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(READFILEHDR, pfnReadFileHdr);
     651    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(WRITEFILEHDR, pfnWriteFileHdr);
     652    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(READFILEDATA, pfnReadFileData);
     653    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(WRITEFILEDATA, pfnWriteFileData);
     654    SHAREDCLIPBOARDPROVIDERFUNCMEMBER(RESET, pfnReset);
     655} SHAREDCLIPBOARDPROVIDERINTERFACE, *PSHAREDCLIPBOARDPROVIDERINTERFACE;
    548656
    549657/**
     
    553661{
    554662    /** Specifies what the source of the provider is. */
    555     SHAREDCLIPBOARDURIPROVIDERSOURCE  enmSource;
    556     /** Specifies whether the provider will read or write data. */
    557     SHAREDCLIPBOARDURITRANSFERDIR     enmDir;
    558     /** Optional callback table; can be NULL if not needed. */
    559     PSHAREDCLIPBOARDPROVIDERCALLBACKS pCallbacks;
     663    SHAREDCLIPBOARDSOURCE             enmSource;
     664    SHAREDCLIPBOARDPROVIDERINTERFACE  Interface;
     665    void                             *pvUser;
    560666    union
    561667    {
     
    601707} SHAREDCLIPBOARDPROVIDERWRITEPARMS, *PSHAREDCLIPBOARDPROVIDERWRITEPARMS;
    602708
     709#if 0
    603710/**
    604711 * Interface class acting as a lightweight proxy for abstracting reading / writing clipboard data.
     
    800907};
    801908#endif /* VBOX_WITH_SHARED_CLIPBOARD_HOST */
     909#endif
    802910
    803911struct _SHAREDCLIPBOARDURITRANSFER;
     
    815923} SHAREDCLIPBOARDURITRANSFERCALLBACKDATA, *PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA;
    816924
    817 typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERSTARTED(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
    818 /** Pointer to a FNSHAREDCLIPBOARDURITRANSFERSTARTED function. */
    819 typedef FNSHAREDCLIPBOARDURITRANSFERSTARTED *PFNSHAREDCLIPBOARDURITRANSFERSTARTED;
    820 
    821 typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERPREPARE(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
    822 /** Pointer to a FNSHAREDCLIPBOARDURITRANSFERPREPARE function. */
    823 typedef FNSHAREDCLIPBOARDURITRANSFERPREPARE *PFNSHAREDCLIPBOARDURITRANSFERPREPARE;
    824 
    825 typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURIMETADATACOMPLETE(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
    826 /** Pointer to a FNSHAREDCLIPBOARDURIMETADATACOMPLETE function. */
    827 typedef FNSHAREDCLIPBOARDURIMETADATACOMPLETE *PFNSHAREDCLIPBOARDURIMETADATACOMPLETE;
    828 
    829 typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERCANCELED(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
    830 /** Pointer to a FNSHAREDCLIPBOARDURITRANSFERCANCELED function. */
    831 typedef FNSHAREDCLIPBOARDURITRANSFERCANCELED *PFNSHAREDCLIPBOARDURITRANSFERCANCELED;
    832 
    833 typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERCOMPLETE(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
    834 /** Pointer to a FNSHAREDCLIPBOARDURITRANSFERCOMPLETE function. */
    835 typedef FNSHAREDCLIPBOARDURITRANSFERCOMPLETE *PFNSHAREDCLIPBOARDURITRANSFERCOMPLETE;
    836 
    837 typedef DECLCALLBACK(void) FNSHAREDCLIPBOARDURITRANSFERERROR(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, int rc);
    838 /** Pointer to a FNSHAREDCLIPBOARDURITRANSFERERROR function. */
    839 typedef FNSHAREDCLIPBOARDURITRANSFERERROR *PFNSHAREDCLIPBOARDURITRANSFERERROR;
     925#define SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(a_Name) \
     926    typedef DECLCALLBACK(void) RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name)(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData); \
     927    typedef RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDCALLBACK, a_Name);
     928
     929#define SHAREDCLIPBOARDTRANSFERCALLBACKDECL(a_Name, ...) \
     930    typedef DECLCALLBACK(void) RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name)(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData, __VA_ARGS__); \
     931    typedef RT_CONCAT(FNSHAREDCLIPBOARDCALLBACK, a_Name) RT_CONCAT(*PFNSHAREDCLIPBOARDCALLBACK, a_Name);
     932
     933#define SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(a_Name, a_Member) \
     934    RT_CONCAT(PFNSHAREDCLIPBOARDCALLBACK, a_Name) a_Member;
     935
     936SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERPREPARE)
     937SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERSTARTED)
     938SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATAHDRCOMPLETE)
     939SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(DATACHUNKCOMPLETE)
     940SHAREDCLIPBOARDTRANSFERCALLBACKDECLVOID(TRANSFERCANCELED)
     941SHAREDCLIPBOARDTRANSFERCALLBACKDECL    (TRANSFERCOMPLETE, int rc)
     942SHAREDCLIPBOARDTRANSFERCALLBACKDECL    (TRANSFERERROR, int rc)
    840943
    841944/**
     
    846949{
    847950    /** Saved user pointer. */
    848     void                                 *pvUser;
     951    void                                  *pvUser;
    849952    /** Function pointer, called when the transfer is going to be prepared. */
    850     PFNSHAREDCLIPBOARDURITRANSFERPREPARE  pfnTransferPrepare;
     953    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERPREPARE, pfnTransferPrepare);
    851954    /** Function pointer, called when the transfer has been started. */
    852     PFNSHAREDCLIPBOARDURITRANSFERSTARTED  pfnTransferStarted;
    853     /** Function pointer, called when reading / writing meta data is complete. */
    854     PFNSHAREDCLIPBOARDURIMETADATACOMPLETE pfnMetaDataComplete;
     955    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERSTARTED, pfnTransferStarted);
     956    /** Function pointer, called when reading / writing the meta data header is complete. */
     957    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATAHDRCOMPLETE, pfnDataHeaderComplete);
     958    /** Function pointer, called when reading / writing the meta data is complete. */
     959    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(DATACHUNKCOMPLETE, pfnDataComplete);
    855960    /** Function pointer, called when the transfer is complete. */
    856     PFNSHAREDCLIPBOARDURITRANSFERCOMPLETE pfnTransferComplete;
     961    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERCOMPLETE, pfnTransferComplete);
    857962    /** Function pointer, called when the transfer has been canceled. */
    858     PFNSHAREDCLIPBOARDURITRANSFERCANCELED pfnTransferCanceled;
     963    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERCANCELED, pfnTransferCanceled);
    859964    /** Function pointer, called when transfer resulted in an unrecoverable error. */
    860     PFNSHAREDCLIPBOARDURITRANSFERERROR    pfnTransferError;
     965    SHAREDCLIPBOARDTRANSFERCALLBACKMEMBER(TRANSFERERROR, pfnTransferError);
    861966} SHAREDCLIPBOARDURITRANSFERCALLBACKS, *PSHAREDCLIPBOARDURITRANSFERCALLBACKS;
    862967
     
    874979    volatile bool               fCancelled;
    875980} SHAREDCLIPBOARDURITRANSFERTHREAD, *PSHAREDCLIPBOARDURITRANSFERTHREAD;
    876 
    877 /**
    878  * Structure for handling a single URI object context.
    879  */
    880 typedef struct _SHAREDCLIPBOARDCLIENTURIOBJCTX
    881 {
    882     /** Pointer to current object being processed. */
    883     SharedClipboardURIObject      *pObj;
    884 } SHAREDCLIPBOARDCLIENTURIOBJCTX, *PSHAREDCLIPBOARDCLIENTURIOBJCTX;
    885981
    886982/**
     
    903999    /** The URI list for this transfer. */
    9041000    SharedClipboardURIList             *pURIList;
    905     /** Context of current object being handled. */
    906     SHAREDCLIPBOARDCLIENTURIOBJCTX      ObjCtx;
    907     /** The Shared Clipboard provider in charge for this transfer. */
    908     SharedClipboardProvider            *pProvider;
     1001    SHAREDCLIPBOARDPROVIDERCTX          ProviderCtx;
     1002    /** The transfer's provider interface. */
     1003    SHAREDCLIPBOARDPROVIDERINTERFACE    ProviderIface;
     1004    /** The transfer's (optional) callback table. */
     1005    SHAREDCLIPBOARDURITRANSFERCALLBACKS Callbacks;
    9091006    /** Opaque pointer to implementation-specific parameters. */
    9101007    void                               *pvUser;
     
    9131010    /** Contains thread-related attributes. */
    9141011    SHAREDCLIPBOARDURITRANSFERTHREAD    Thread;
    915     /** (Optional) callbacks related to this transfer. */
    916     SHAREDCLIPBOARDURITRANSFERCALLBACKS Callbacks;
    9171012} SHAREDCLIPBOARDURITRANSFER, *PSHAREDCLIPBOARDURITRANSFER;
    9181013
     
    9271022     *  Use a list or something lateron. */
    9281023    RTLISTANCHOR                List;
    929     /** Number of concurrent transfers.
     1024    /** Number of running (concurrent) transfers.
    9301025     *  At the moment we only support only one transfer per client at a time. */
    931     uint32_t                    cTransfers;
    932     /** Maximum Number of concurrent transfers.
     1026    uint32_t                    cRunning;
     1027    /** Maximum Number of running (concurrent) transfers.
    9331028     *  At the moment we only support only one transfer per client at a time. */
    934     uint32_t                    cMaxTransfers;
     1029    uint32_t                    cMaxRunning;
     1030#ifdef DEBUG
     1031    uint32_t                    cTransfer;
     1032#endif
    9351033} SHAREDCLIPBOARDURICTX, *PSHAREDCLIPBOARDURICTX;
    9361034
     
    9401038bool SharedClipboardURIObjCtxIsValid(PSHAREDCLIPBOARDCLIENTURIOBJCTX pObjCtx);
    9411039
    942 int SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR enmDir, PSHAREDCLIPBOARDURITRANSFER *ppTransfer);
     1040int SharedClipboardURITransferCreate(SHAREDCLIPBOARDURITRANSFERDIR enmDir, SHAREDCLIPBOARDSOURCE enmSource, PSHAREDCLIPBOARDURITRANSFER *ppTransfer);
    9431041int SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9441042int SharedClipboardURITransferPrepare(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9451043int SharedClipboardURITransferProviderCreate(PSHAREDCLIPBOARDURITRANSFER pTransfer,
    946                                              PSHAREDCLIPBOARDPROVIDERCREATIONCTX pProviderCtx);
     1044                                             PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCreationCtx);
    9471045void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9481046SharedClipboardArea *SharedClipboardURITransferGetArea(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9491047PSHAREDCLIPBOARDCLIENTURIOBJCTX SharedClipboardURITransferGetCurrentObjCtx(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9501048const SharedClipboardURIObject *SharedClipboardURITransferGetCurrentObject(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    951 SharedClipboardProvider *SharedClipboardURITransferGetProvider(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9521049SharedClipboardURIList *SharedClipboardURITransferGetList(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9531050SharedClipboardURIObject *SharedClipboardURITransferGetObject(PSHAREDCLIPBOARDURITRANSFER pTransfer, uint64_t uIdx);
     1051SHAREDCLIPBOARDSOURCE SharedClipboardURITransferGetSource(PSHAREDCLIPBOARDURITRANSFER pTransfer);
     1052SHAREDCLIPBOARDURITRANSFERSTATUS SharedClipboardURITransferGetStatus(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9541053int SharedClipboardURITransferRun(PSHAREDCLIPBOARDURITRANSFER pTransfer, bool fAsync);
    9551054void SharedClipboardURITransferSetCallbacks(PSHAREDCLIPBOARDURITRANSFER pTransfer,
    9561055                                            PSHAREDCLIPBOARDURITRANSFERCALLBACKS pCallbacks);
     1056int SharedClipboardURITransferSetDataHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATAHDR pDataHdr);
     1057int SharedClipboardURITransferSetDataChunk(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDDATACHUNK pDataChunk);
    9571058
    9581059int SharedClipboardURITransferMetaDataAdd(PSHAREDCLIPBOARDURITRANSFER pTransfer, const void *pvMeta, uint32_t cbMeta);
     
    9711072void SharedClipboardURICtxReset(PSHAREDCLIPBOARDURICTX pURI);
    9721073PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx);
    973 uint32_t SharedClipboardURICtxGetActiveTransfers(PSHAREDCLIPBOARDURICTX pURI);
    974 bool SharedClipboardURICtxMaximumTransfersReached(PSHAREDCLIPBOARDURICTX pURI);
     1074uint32_t SharedClipboardURICtxGetRunningTransfers(PSHAREDCLIPBOARDURICTX pURI);
     1075void SharedClipboardURICtxTransfersCleanup(PSHAREDCLIPBOARDURICTX pURI);
     1076bool SharedClipboardURICtxTransfersMaximumReached(PSHAREDCLIPBOARDURICTX pURI);
    9751077int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
    9761078int SharedClipboardURICtxTransferRemove(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer);
  • trunk/include/VBox/GuestHost/SharedClipboard-win.h

    r79299 r79347  
    137137int VBoxClipboardWinAnnounceFormats(PVBOXCLIPBOARDWINCTX pWinCtx, VBOXCLIPBOARDFORMATS fFormats);
    138138#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    139 int VBoxClipboardWinURIAnnounce(PVBOXCLIPBOARDWINCTX pWinCtx, PSHAREDCLIPBOARDURICTX pURICtx,
    140                                 PSHAREDCLIPBOARDURITRANSFER pTransfer);
     139int VBoxClipboardWinURITransferCreate(PVBOXCLIPBOARDWINCTX pWinCtx, PSHAREDCLIPBOARDURITRANSFER pTransfer);
     140void VBoxClipboardWinURITransferDestroy(PVBOXCLIPBOARDWINCTX pWinCtx, PSHAREDCLIPBOARDURITRANSFER pTransfer);
    141141#endif
    142142
     
    204204
    205205    int Init(void);
     206    void OnMetaDataComplete(PSHAREDCLIPBOARDURITRANSFER pTransfer);
    206207    void OnTransferComplete(int rc = VINF_SUCCESS);
    207208    void OnTransferCanceled();
     
    222223    void registerFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL,
    223224                        LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL);
    224 
    225 protected: /* URI transfer callbacks */
    226 
    227     static DECLCALLBACK(void) onMetaDataCompleteCallback(PSHAREDCLIPBOARDURITRANSFERCALLBACKDATA pData);
    228 
    229225protected:
    230226
  • trunk/include/VBox/HostServices/VBoxClipboardSvc.h

    r79299 r79347  
    402402} VBOXCLIPBOARDDATACHUNK, *PVBOXCLIPBOARDDATACHUNK;
    403403
     404typedef struct _VBOXCLIPBOARDOBJHDR
     405{
     406    uint32_t                    enmType;
     407} VBOXCLIPBOARDOBJHDR, *PVBOXCLIPBOARDOBJHDR;
     408
    404409typedef struct _VBOXCLIPBOARDDIRDATA
    405410{
     
    448453
    449454#ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST
    450 int VBoxSvcClipboardURIReadDataHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATAHDR pDataHdr);
    451 int VBoxSvcClipboardURIWriteDataHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATAHDR pDataHdr);
    452 int VBoxSvcClipboardURIReadDataChunk(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATACHUNK pDataChunk);
    453 int VBoxSvcClipboardURIWriteDataChunk(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATACHUNK pDataChunk);
    454 int VBoxSvcClipboardURIReadDir(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDIRDATA pDirData);
    455 int VBoxSvcClipboardURIWriteDir(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDIRDATA pDirData);
    456 int VBoxSvcClipboardURIReadFileHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEHDR pFileHdr);
    457 int VBoxSvcClipboardURIWriteFileHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEHDR pFileHdr);
    458 int VBoxSvcClipboardURIReadFileData(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEDATA pFileData);
    459 int VBoxSvcClipboardURIWriteFileData(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEDATA pFileData);
     455int VBoxSvcClipboardURIGetDataHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATAHDR pDataHdr);
     456int VBoxSvcClipboardURISetDataHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATAHDR pDataHdr);
     457int VBoxSvcClipboardURISetDataChunk(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATACHUNK pDataChunk);
     458int VBoxSvcClipboardURISetDataChunk(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDATACHUNK pDataChunk);
     459int VBoxSvcClipboardURIGetDir(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDIRDATA pDirData);
     460int VBoxSvcClipboardURISetDir(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDDIRDATA pDirData);
     461int VBoxSvcClipboardURIGetFileHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEHDR pFileHdr);
     462int VBoxSvcClipboardURISetFileHdr(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEHDR pFileHdr);
     463int VBoxSvcClipboardURIGetFileData(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEDATA pFileData);
     464int VBoxSvcClipboardURISetFileData(uint32_t cParms, VBOXHGCMSVCPARM paParms[], PVBOXCLIPBOARDFILEDATA pFileData);
    460465#endif
    461466
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