VirtualBox

Changeset 100204 in vbox for trunk/include


Ignore:
Timestamp:
Jun 19, 2023 9:11:37 AM (18 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Unified root list entry code to also use the generic list entry code, a lot of updates for the cross OS transfer handling code, more updates for HTTP server transfer handling.

This also changed the handling of how that transfers are being initiated, as we needed to have this for X11: Before, transfers were initiated as soon as on side announced the URI list format -- now we postpone initiating the transfer until the receiving side requests the data as URI list.

bugref:9437

Location:
trunk/include/VBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard-transfers.h

    r99966 r100204  
    4040# pragma once
    4141#endif
    42 
    43 #include <map>
    4442
    4543#include <iprt/assert.h>
     
    6765 */
    6866
    69 /** No Shared Clipboard listing feature flags defined. */
     67/** No Shared Clipboard list feature flags defined. */
    7068#define SHCL_TRANSFER_LIST_FEATURE_F_NONE            UINT32_C(0)
     69/** Is a root list. */
     70#define SHCL_TRANSFER_LIST_FEATURE_F_ROOT            RT_BIT(0)
    7171/** Shared Clipboard feature flags valid mask. */
    72 #define SHCL_TRANSFER_LIST_FEATURE_F_VALID_MASK      0x0
     72#define SHCL_TRANSFER_LIST_FEATURE_F_VALID_MASK      0x1
    7373
    7474/** Defines the maximum length (in chars) a Shared Clipboard transfer path can have. */
     
    8080/** Defines the default maximum object handles a Shared Clipboard transfer can have. */
    8181#define SHCL_TRANSFER_DEFAULT_MAX_OBJ_HANDLES   _4K
    82 /** Defines the default timeout (in ms) to use for clipboard operations. */
    83 #define SHCL_TIMEOUT_DEFAULT_MS                 RT_MS_30SEC
     82/** Defines the separator for the entries of an URI list (as a string). */
     83#define SHCL_TRANSFER_URI_LIST_SEP_STR          "\r\n"
    8484
    8585/**
     
    9292    /** The transfer has been initialized but is not running yet. */
    9393    SHCLTRANSFERSTATUS_INITIALIZED,
     94    /** The transfer has been uninitialized and is not usable anymore. */
     95    SHCLTRANSFERSTATUS_UNINITIALIZED,
    9496    /** The transfer is active and running. */
    9597    SHCLTRANSFERSTATUS_STARTED,
     
    100102    /** The transfer has been killed. */
    101103    SHCLTRANSFERSTATUS_KILLED,
    102     /** The transfer ran into an unrecoverable error. */
     104    /** The transfer ran into an unrecoverable error.
     105     *  This results in completely aborting the operation. */
    103106    SHCLTRANSFERSTATUS_ERROR,
    104107    /** The usual 32-bit hack. */
     
    401404typedef _SHCLLISTENTRY SHCLLISTENTRY;
    402405
    403 /** Defines a single root list entry. Currently the same as a regular list entry. */
    404 typedef SHCLLISTENTRY SHCLROOTLISTENTRY;
    405 /** Defines a pointer to a single root list entry. Currently the same as a regular list entry pointer. */
    406 typedef SHCLROOTLISTENTRY *PSHCLROOTLISTENTRY;
    407 
    408 /**
    409  * Structure for keeping Shared Clipboard root list headers.
    410  */
    411 typedef struct _SHCLROOTLISTHDR
    412 {
    413     /** Roots listing flags; unused at the moment. */
    414     uint32_t                fRoots;
    415     /** Number of root list entries. */
    416     uint32_t                cRoots;
    417 } SHCLROOTLISTHDR;
    418 /** Pointer to a Shared Clipboard root list header. */
    419 typedef SHCLROOTLISTHDR *PSHCLROOTLISTHDR;
    420 
    421 /**
    422  * Structure for maintaining a Shared Clipboard root list.
    423  */
    424 typedef struct _SHCLROOTLIST
    425 {
    426     /** Root list header. */
    427     SHCLROOTLISTHDR    Hdr;
    428     /** Root list entries. */
    429     SHCLROOTLISTENTRY *paEntries;
    430 } SHCLROOTLIST;
    431 /** Pointer to a Shared Clipboard root list. */
    432 typedef SHCLROOTLIST *PSHCLROOTLIST;
    433 
    434406/**
    435407 * Structure for maintaining Shared Clipboard list open parameters.
     
    458430    /** Feature flag(s) of type SHCL_TRANSFER_LIST_FEATURE_F_XXX. */
    459431    uint32_t fFeatures;
    460     /** Total objects returned. */
    461     uint64_t cTotalObjects;
     432    /** Total entries of the list. */
     433    uint64_t cEntries;
    462434    /** Total size (in bytes) returned. */
    463435    uint64_t cbTotalSize;
     
    467439
    468440/**
    469  * Structure for a Shared Clipboard list entry.
     441 * Structure for a generic Shared Clipboard list entry.
    470442 */
    471443typedef struct _SHCLLISTENTRY
    472444{
     445    /** List node. */
     446    RTLISTNODE Node;
    473447    /** Entry name. */
    474     char    *pszName;
     448    char      *pszName;
    475449    /** Size (in bytes) of entry name.
    476450     *  Includes terminator. */
    477     uint32_t cbName;
    478     /** Information flag(s). */
    479     uint32_t fInfo;
     451    uint32_t   cbName;
     452    /** Information flag(s). Of type VBOX_SHCL_INFO_FLAG_XXX. */
     453    uint32_t   fInfo;
    480454    /** Size (in bytes) of the actual list entry. */
    481     uint32_t cbInfo;
     455    uint32_t   cbInfo;
    482456    /** Data of the actual list entry. */
    483     void    *pvInfo;
     457    void      *pvInfo;
    484458} SHCLLISTENTRY;
    485459/** Pointer to a Shared Clipboard list entry. */
    486460typedef SHCLLISTENTRY *PSHCLLISTENTRY;
     461/** Pointer to a const Shared Clipboard list entry. */
     462typedef SHCLLISTENTRY *PCSHCLLISTENTRY;
    487463
    488464/** Maximum length (in UTF-8 characters) of a list entry name. Includes terminator. */
    489 #define SHCLLISTENTRY_MAX_NAME     RTPATH_MAX /** @todo Improve this to be more dynamic. */
    490 
    491 /**
    492  * Structure for maintaining a generic Shared Clipboard list.
     465#define SHCLLISTENTRY_MAX_NAME     1024
     466
     467/**
     468 * Structure for a generic Shared Clipboard list.
    493469 */
    494470typedef struct _SHCLLIST
    495471{
    496472    /** List header. */
    497     SHCLLISTHDR        Hdr;
    498     /** List entries. */
    499     SHCLROOTLISTENTRY *paEntries;
     473    SHCLLISTHDR    Hdr;
     474    /** List entries of type PSHCLLISTENTRY. */
     475    RTLISTANCHOR   lstEntries;
    500476} SHCLLIST;
    501 /** Pointer to a Shared Clipboard transfer transfer list. */
     477/** Pointer to a generic Shared Clipboard transfer transfer list. */
    502478typedef SHCLLIST *PSHCLLIST;
    503479
     
    637613
    638614/**
    639  * Structure for keeping a single transfer root list entry.
    640  */
    641 typedef struct _SHCLLISTROOT
    642 {
    643     /** The list node. */
    644     RTLISTNODE          Node;
    645     /** Absolute path of entry. */
    646     char               *pszPathAbs;
    647 } SHCLLISTROOT;
    648 /** Pointer to a Shared Clipboard transfer root list entry. */
    649 typedef SHCLLISTROOT *PSHCLLISTROOT;
    650 
    651 /**
    652615 * Structure for maintaining an Shared Clipboard transfer state.
    653616 * Everything in here will be part of a saved state (later).
     
    696659{
    697660    /**
    698      * Returns the root entries of a clipboard transfer.
     661     * Reads the clipboard transfer root list.
     662     *
     663     * Depending on the provider, this queries information for the root entries.
    699664     *
    700665     * @returns VBox status code.
    701666     * @param   pCtx                Provider context to use.
    702      * @param   ppRootList          Where to store the root list on success.
    703      */
    704     DECLCALLBACKMEMBER(int, pfnRootsGet,(PSHCLTXPROVIDERCTX pCtx, PSHCLROOTLIST *ppRootList));
     667     * @param   pRootList           Where to store the root list on success.
     668     */
     669    DECLCALLBACKMEMBER(int, pfnRootListRead,(PSHCLTXPROVIDERCTX pCtx));
    705670    /**
    706671     * Opens a transfer list.
     
    805770/** Queries (assigns) a Shared Clipboard provider interface. */
    806771#define SHCLTXPROVIDERIFACE_QUERY(a_Iface, a_Name) \
    807     a_Iface->pfnRootsGet       = a_Name ## RootsGet; \
     772    a_Iface->pfnRootListRead   = a_Name ## RootListRead; \
    808773    a_Iface->pfnListOpen       = a_Name ## ListOpen; \
    809774    a_Iface->pfnListClose      = a_Name ## ListClose; \
     
    822787
    823788/**
    824  * Structure for the Shared Clipboard transfer provider creation context.
    825  */
    826 typedef struct _SHCLTXPROVIDERCREATIONCTX
     789 * Structure for Shared Clipboard transfer provider.
     790 */
     791typedef struct _SHCLTXPROVIDER
    827792{
    828793    /** Specifies what the source of the provider is. */
    829794    SHCLSOURCE           enmSource;
    830     /** The provider interface table. */
     795    /** The provider interface table to use. */
    831796    SHCLTXPROVIDERIFACE  Interface;
    832797    /** User-provided callback data. */
     
    834799    /** Size (in bytes) of data at user pointer. */
    835800    size_t               cbUser;
    836 } SHCLTXPROVIDERCREATIONCTX;
    837 /** Pointer to a Shared Clipboard transfer provider creation context. */
    838 typedef SHCLTXPROVIDERCREATIONCTX *PSHCLTXPROVIDERCREATIONCTX;
     801} SHCLTXPROVIDER;
     802/** Pointer to Shared Clipboard transfer provider. */
     803typedef SHCLTXPROVIDER *PSHCLTXPROVIDER;
    839804
    840805/**
     
    856821 * Shared Clipboard transfer callback table.
    857822 *
    858  * All callbacks are optional and can provide additional information / feedback to a frontend.
     823 * All callbacks are optional (hence all returning void).
    859824 */
    860825typedef struct _SHCLTRANSFERCALLBACKTABLE
    861826{
    862827    /**
    863      * Called when the transfer gets initialized.
     828     * Called after the transfer got initialized.
    864829     *
    865830     * @param   pCbCtx              Pointer to callback context to use.
    866831     */
    867     DECLCALLBACKMEMBER(int,  pfnOnInitialize,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
    868     /**
    869      * Called before the transfer will be started.
     832    DECLCALLBACKMEMBER(void,  pfnOnInitialized,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
     833    /**
     834     * Called before the transfer gets destroys.
    870835     *
    871836     * @param   pCbCtx              Pointer to callback context to use.
    872837     */
    873     DECLCALLBACKMEMBER(int,  pfnOnStart,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
     838    DECLCALLBACKMEMBER(void,  pfnOnDestroy,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
     839    /**
     840     * Called after the transfer entered the started state.
     841     *
     842     * @param   pCbCtx              Pointer to callback context to use.
     843     */
     844    DECLCALLBACKMEMBER(void,  pfnOnStarted,(PSHCLTRANSFERCALLBACKCTX pCbCtx));
    874845    /**
    875846     * Called when the transfer has been complete.
     
    888859    DECLCALLBACKMEMBER(void, pfnOnError,(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcError));
    889860    /**
    890      * Called when transfer got registered to a transfer context.
     861     * Called after a transfer got registered to a transfer context.
    891862     *
    892863     * @param   pCbCtx              Pointer to callback context to use.
     
    895866    DECLCALLBACKMEMBER(void, pfnOnRegistered,(PSHCLTRANSFERCALLBACKCTX pCbCtx, PSHCLTRANSFERCTX pTransferCtx));
    896867    /**
    897      * Called when transfer got unregistered from a transfer context.
     868     * Called after a transfer got unregistered from a transfer context.
    898869     *
    899870     * @param   pCbCtx              Pointer to callback context to use.
     
    908879} SHCLTRANSFERCALLBACKTABLE;
    909880/** Pointer to a Shared Clipboard transfer callback table. */
    910 typedef SHCLTRANSFERCALLBACKTABLE *PSHCLTRANSFERCALLBACKTABLE;
     881typedef SHCLTRANSFERCALLBACKTABLE *PSHCLTRANSFERCALLBACKS;
    911882
    912883/**
     
    949920    /** The transfer's own event source. */
    950921    SHCLEVENTSOURCE           Events;
    951     /** Current number of concurrent list handles. */
     922    /** Current number of concurrent list handles in \a lstHandles. */
    952923    uint32_t                  cListHandles;
    953     /** Maximum number of concurrent list handles. */
     924    /** Maximum number of concurrent list handles allowed. */
    954925    uint32_t                  cMaxListHandles;
    955     /** Next upcoming list handle. */
     926    /** Next upcoming list handle. For book keeping. */
    956927    SHCLLISTHANDLE            uListHandleNext;
    957     /** List of all list handles elated to this transfer. */
    958     RTLISTANCHOR              lstList;
    959     /** Number of root entries in list. */
    960     uint64_t                  cRoots;
     928    /** List of all list handles related to this transfer. */
     929    RTLISTANCHOR              lstHandles;
    961930    /** List of root entries of this transfer. */
    962     RTLISTANCHOR              lstRoots;
    963     /** Current number of concurrent object handles. */
     931    SHCLLIST                  lstRoots;
     932    /** Current number of concurrent object handles. in \a lstObj. */
    964933    uint32_t                  cObjHandles;
    965934    /** Maximum number of concurrent object handles. */
    966935    uint32_t                  cMaxObjHandles;
    967     /** Next upcoming object handle. */
     936    /** Next upcoming object handle. For book keeping. */
    968937    SHCLOBJHANDLE             uObjHandleNext;
    969938    /** Map of all objects handles related to this transfer. */
     
    1006975#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP
    1007976/**
     977 * Enumeration for HTTP server status changes.
     978 *
     979 * Keep those as flags, so that we can wait for multiple statuses, if needed.
     980 */
     981typedef enum _SHCLHTTPSERVERSTATUS
     982{
     983    /** No status set yet. */
     984    SHCLHTTPSERVERSTATUS_NONE                  = 0x0,
     985    /** A new transfer got registered. */
     986    SHCLHTTPSERVERSTATUS_TRANSFER_REGISTERED   = 0x1,
     987    /** A new transfer got registered. */
     988    SHCLHTTPSERVERSTATUS_TRANSFER_UNREGISTERED = 0x2
     989} SHCLHTTPSERVERSTATUS;
     990
     991/**
    1008992 * Structure for keeping a Shared Clipboard HTTP server instance.
    1009993 */
     
    1011995{
    1012996    /** Critical section for serializing access. */
    1013     RTCRITSECT          CritSect;
     997    RTCRITSECT           CritSect;
     998    /** Status event for callers to wait for.
     999     *  Updates \a enmStatus. */
     1000    RTSEMEVENT           StatusEvent;
     1001    /** Current status. */
     1002    SHCLHTTPSERVERSTATUS enmStatus;
    10141003    /** Handle of the HTTP server instance. */
    1015     RTHTTPSERVER        hHTTPServer;
     1004    RTHTTPSERVER         hHTTPServer;
    10161005    /** Port number the HTTP server is running on. 0 if not running. */
    1017     uint16_t            uPort;
     1006    uint16_t             uPort;
    10181007    /** List of registered HTTP transfers. */
    1019     RTLISTANCHOR        lstTransfers;
     1008    RTLISTANCHOR         lstTransfers;
    10201009    /** Number of registered HTTP transfers. */
    1021     uint32_t            cTransfers;
     1010    uint32_t             cTransfers;
    10221011    /** Number of files served (via GET) so far.
    10231012     *  Only complete downloads count (i.e. no aborted). */
    1024     uint32_t            cDownloaded;
     1013    uint32_t             cDownloaded;
    10251014    /** Cached response data. */
    1026     RTHTTPSERVERRESP    Resp;
     1015    RTHTTPSERVERRESP     Resp;
    10271016} SHCLHTTPSERVER;
    10281017/** Pointer to Shared Clipboard HTTP server. */
     
    10681057 *  @{
    10691058 */
    1070 PSHCLTXPROVIDERIFACE VBClTransferQueryIfaceLocal(PSHCLTXPROVIDERIFACE pIface);
     1059PSHCLTXPROVIDERIFACE VBClTransferProviderLocalQueryInterface(PSHCLTXPROVIDER pProvider);
    10711060/** @} */
    10721061
     
    11041093int ShClTransferInit(PSHCLTRANSFER pTransfer, SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource);
    11051094int ShClTransferDestroy(PSHCLTRANSFER pTransfer);
     1095void ShClTransferReset(PSHCLTRANSFER pTransfer);
    11061096
    11071097int ShClTransferRun(PSHCLTRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser);
     
    11261116bool ShClTransferListHandleIsValid(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList);
    11271117
    1128 int ShClPathSanitizeFilename(char *pszPath, size_t cbPath);
    1129 int ShClPathSanitize(char *pszPath, size_t cbPath);
    1130 
    1131 PSHCLROOTLIST ShClTransferRootListAlloc(void);
    1132 void ShClTransferRootListFree(PSHCLROOTLIST pRootList);
    1133 
    1134 PSHCLROOTLISTHDR ShClTransferRootListHdrDup(PSHCLROOTLISTHDR pRoots);
    1135 int ShClTransferRootListHdrInit(PSHCLROOTLISTHDR pRoots);
    1136 void ShClTransferRootListHdrDestroy(PSHCLROOTLISTHDR pRoots);
    1137 
    1138 int ShClTransferRootListEntryCopy(PSHCLROOTLISTENTRY pDst, PSHCLROOTLISTENTRY pSrc);
    1139 int ShClTransferRootListEntryInit(PSHCLROOTLISTENTRY pRootListEntry);
    1140 void ShClTransferRootListEntryDestroy(PSHCLROOTLISTENTRY pRootListEntry);
    1141 PSHCLROOTLISTENTRY ShClTransferRootListEntryDup(PSHCLROOTLISTENTRY pRootListEntry);
     1118PSHCLLIST ShClTransferListAlloc(void);
     1119void ShClTransferListFree(PSHCLLIST pList);
     1120void ShClTransferListInit(PSHCLLIST pList);
     1121void ShClTransferListDestroy(PSHCLLIST pList);
     1122int ShClTransferListAddEntry(PSHCLLIST pList, PSHCLLISTENTRY pEntry, bool fAppend);
    11421123
    11431124int ShClTransferListHandleInfoInit(PSHCLLISTHANDLEINFO pInfo);
     
    11591140int ShClTransferListEntryAlloc(PSHCLLISTENTRY *ppListEntry);
    11601141void ShClTransferListEntryFree(PSHCLLISTENTRY pListEntry);
    1161 int ShClTransferListEntryCopy(PSHCLLISTENTRY pDst, PSHCLLISTENTRY pSrc);
    1162 PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry);
     1142int ShClTransferListEntryInitEx(PSHCLLISTENTRY pListEntry, uint32_t fInfo, const char *pszName, void *pvInfo, uint32_t cbInfo);
    11631143int ShClTransferListEntryInit(PSHCLLISTENTRY pListEntry);
    11641144void ShClTransferListEntryDestroy(PSHCLLISTENTRY pListEntry);
    11651145bool ShClTransferListEntryIsValid(PSHCLLISTENTRY pListEntry);
    1166 
    1167 void ShClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKTABLE pCallbacksDst, PSHCLTRANSFERCALLBACKTABLE pCallbacksSrc);
    1168 void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKTABLE pCallbacks);
    1169 int ShClTransferSetProviderIface(PSHCLTRANSFER pTransfer, PSHCLTXPROVIDERCREATIONCTX pCreationCtx);
    1170 int ShClTransferRootsSet(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots);
    1171 int ShClTransferRootsSetAsFile(PSHCLTRANSFER pTransfer, const char *pszFile);
    1172 void ShClTransferReset(PSHCLTRANSFER pTransfer);
    1173 
    1174 uint32_t ShClTransferRootsCount(PSHCLTRANSFER pTransfer);
    1175 int ShClTransferRootsEntry(PSHCLTRANSFER pTransfer, uint64_t uIndex, PSHCLROOTLISTENTRY pEntry);
    1176 int ShClTransferRootsGet(PSHCLTRANSFER pTransfer, PSHCLROOTLIST *ppRootList);
     1146int ShClTransferListEntryCopy(PSHCLLISTENTRY pDst, PSHCLLISTENTRY pSrc);
     1147PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry);
     1148
     1149void ShClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKS pCallbacksDst, PSHCLTRANSFERCALLBACKS pCallbacksSrc);
     1150void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks);
     1151int ShClTransferSetProvider(PSHCLTRANSFER pTransfer, PSHCLTXPROVIDER pProvider);
     1152
     1153int ShClTransferRootsInitFromStringList(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots);
     1154int ShClTransferRootsInitFromFile(PSHCLTRANSFER pTransfer, const char *pszFile);
     1155uint64_t ShClTransferRootsCount(PSHCLTRANSFER pTransfer);
     1156PCSHCLLISTENTRY ShClTransferRootsEntryGet(PSHCLTRANSFER pTransfer, uint64_t uIndex);
     1157int ShClTransferRootListRead(PSHCLTRANSFER pTransfer);
    11771158/** @} */
    11781159
     
    12011182 *  @{
    12021183 */
    1203 int ShClHttpTransferRegisterAndMaybeStart(PSHCLHTTPCONTEXT pCtx, PSHCLTRANSFER pTransfer);
    1204 int ShClHttpTransferUnregisterAndMaybeStop(PSHCLHTTPCONTEXT pCtx, PSHCLTRANSFER pTransfer);
     1184int ShClTransferHttpServerMaybeStart(PSHCLHTTPCONTEXT pCtx);
     1185int ShClTransferHttpServerMaybeStop(PSHCLHTTPCONTEXT pCtx);
    12051186/** @} */
    12061187
     
    12081189 *  @{
    12091190 */
    1210 int ShClTransferHttpServerCreate(PSHCLHTTPSERVER pSrv, unsigned cMaxAttempts, uint16_t *puPort);
    1211 int ShClTransferHttpServerCreateEx(PSHCLHTTPSERVER pSrv, uint16_t uPort);
     1191int ShClTransferHttpServerStart(PSHCLHTTPSERVER pSrv, unsigned cMaxAttempts, uint16_t *puPort);
     1192int ShClTransferHttpServerStartEx(PSHCLHTTPSERVER pSrv, uint16_t uPort);
    12121193int ShClTransferHttpServerDestroy(PSHCLHTTPSERVER pSrv);
    1213 void ShClTransferHttpServerInit(PSHCLHTTPSERVER pSrv);
     1194int ShClTransferHttpServerInit(PSHCLHTTPSERVER pSrv);
    12141195int ShClTransferHttpServerRegisterTransfer(PSHCLHTTPSERVER pSrv, PSHCLTRANSFER pTransfer);
    12151196int ShClTransferHttpServerUnregisterTransfer(PSHCLHTTPSERVER pSrv, PSHCLTRANSFER pTransfer);
    1216 bool ShClTransferHttpServerHasTransfer(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer);
     1197PSHCLTRANSFER ShClTransferHttpServerGetTransferFirst(PSHCLHTTPSERVER pSrv);
     1198bool ShClTransferHttpServerGetTransfer(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer);
    12171199uint16_t ShClTransferHttpServerGetPort(PSHCLHTTPSERVER pSrv);
    12181200uint32_t ShClTransferHttpServerGetTransferCount(PSHCLHTTPSERVER pSrv);
     
    12201202char *ShClTransferHttpServerGetUrlA(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer);
    12211203bool ShClTransferHttpServerIsRunning(PSHCLHTTPSERVER pSrv);
     1204int ShClTransferHttpServerWaitForStatusChange(PSHCLHTTPSERVER pSrv, SHCLHTTPSERVERSTATUS fStatus, RTMSINTERVAL msTimeout);
    12221205/** @} */
    12231206#endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP */
     
    12261209 *  @{
    12271210 */
     1211int ShClPathSanitizeFilename(char *pszPath, size_t cbPath);
     1212int ShClPathSanitize(char *pszPath, size_t cbPath);
    12281213const char *ShClTransferStatusToStr(SHCLTRANSFERSTATUS enmStatus);
    12291214int ShClTransferValidatePath(const char *pcszPath, bool fMustExist);
    1230 void ShClFsObjFromIPRT(PSHCLFSOBJINFO pDst, PCRTFSOBJINFO pSrc);
     1215int ShClFsObjInfoQuery(const char *pszPath, PSHCLFSOBJINFO pObjInfo);
     1216int ShClFsObjInfoFromIPRT(PSHCLFSOBJINFO pDst, PCRTFSOBJINFO pSrc);
    12311217/** @} */
    12321218
  • trunk/include/VBox/GuestHost/SharedClipboard-win.h

    r98103 r100204  
    4242#include <iprt/critsect.h>
    4343#include <iprt/types.h>
     44#include <iprt/req.h>
    4445#include <iprt/win/windows.h>
    4546
     
    109110    bool                   fCBChainPingInProcess;
    110111} SHCLWINAPIOLD, *PSHCLWINAPIOLD;
     112
     113/** Forward declaration for the Windows data object. */
     114class SharedClipboardWinDataObject;
    111115
    112116/**
     
    131135    /** Structure for maintaining the old clipboard API. */
    132136    SHCLWINAPIOLD      oldAPI;
     137    /** The "in-flight" data object for file transfers.
     138     *  This is the current data object which has been created and sent to the Windows clipboard.
     139     *  That way Windows knows that a potential file transfer is available, but the actual transfer
     140     *  hasn't been started yet.
     141     *  Can be NULL if currently not being used / no current "in-flight" transfer present. */
     142    SharedClipboardWinDataObject
     143                      *pDataObjInFlight;
     144    /** Request queue.
     145     *  Needed for processing HGCM requests within the HGCM (main) thread from the Windows event thread. */
     146    RTREQQUEUE         hReqQ;
    133147} SHCLWINCTX, *PSHCLWINCTX;
    134148
     
    154168
    155169#ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    156 int SharedClipboardWinGetRoots(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer);
    157 int SharedClipboardWinDropFilesToStringList(DROPFILES *pDropFiles, char **papszList, uint32_t *pcbList);
     170int SharedClipboardWinTransferGetRoots(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer);
     171int SharedClipboardWinTransferDropFilesToStringList(DROPFILES *pDropFiles, char **papszList, uint32_t *pcbList);
     172int SharedClipboardWinTransferGetRootsFromClipboard(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer);
     173int SharedClipboardWinTransferCreateAndSetDataObject(PSHCLWINCTX pWinCtx, PSHCLCONTEXT pCtx, PSHCLCALLBACKS pCallbacks);
    158174#endif
    159175
     
    188204        /** The object is uninitialized (not ready). */
    189205        Uninitialized = 0,
    190         /** The object is initialized and ready to use. */
     206        /** The object is initialized and ready to use.
     207         *  A transfer is *not* running yet! */
    191208        Initialized,
     209        /** Transfer is running. */
     210        Running,
    192211        /** The operation has been successfully completed. */
    193212        Completed,
     
    200219public:
    201220
    202     SharedClipboardWinDataObject(PSHCLTRANSFER pTransfer,
    203                                  LPFORMATETC pFormatEtc = NULL, LPSTGMEDIUM pStgMed = NULL, ULONG cFormats = 0);
     221    SharedClipboardWinDataObject(void);
    204222    virtual ~SharedClipboardWinDataObject(void);
     223
     224public:
     225
     226    int Init(PSHCLCONTEXT pCtx, LPFORMATETC pFormatEtc = NULL, LPSTGMEDIUM pStgMed = NULL, ULONG cFormats = 0);
     227    void Destroy(void);
     228
     229    void SetCallbacks(PSHCLCALLBACKS pCallbacks);
    205230
    206231public: /* IUnknown methods. */
     
    234259public:
    235260
    236     int Init(void);
    237     void OnTransferComplete(int rc = VINF_SUCCESS);
    238     void OnTransferCanceled();
     261    int SetAndStartTransfer(PSHCLTRANSFER pTransfer);
     262    int SetStatus(Status enmStatus, int rc = VINF_SUCCESS);
    239263
    240264public:
     
    257281    void registerFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL,
    258282                        LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL);
     283    int setStatusLocked(Status enmStatus, int rc = VINF_SUCCESS);
     284
    259285protected:
    260286
     
    265291    {
    266292        /** Relative path of the object. */
    267         Utf8Str       strPath;
     293        char         *pszPath;
    268294        /** Related (cached) object information. */
    269295        SHCLFSOBJINFO objInfo;
     
    273299    typedef std::vector<FSOBJENTRY> FsObjEntryList;
    274300
     301    /** Shared Clipboard context to use. */
     302    PSHCLCONTEXT                m_pCtx;
     303    /** Callbacks table to use. */
     304    SHCLCALLBACKS               m_Callbacks;
    275305    /** The object's current status. */
    276306    Status                      m_enmStatus;
     
    290320    /** List of (cached) file system objects. */
    291321    FsObjEntryList              m_lstEntries;
     322    /** Critical section to serialize access. */
     323    RTCRITSECT                  m_CritSect;
    292324    /** Whether the transfer thread is running. */
    293     bool                        m_fRunning;
     325    bool                        m_fThreadRunning;
    294326    /** Event being triggered when reading the transfer list been completed. */
    295327    RTSEMEVENT                  m_EventListComplete;
    296     /** Event being triggered when the transfer has been completed. */
    297     RTSEMEVENT                  m_EventTransferComplete;
     328    /** Event being triggered when the transfer status has been changed. */
     329    RTSEMEVENT                  m_EventStatusChanged;
    298330    /** Registered format for CFSTR_FILEDESCRIPTORA. */
    299331    UINT                        m_cfFileDescriptorA;
     
    310342public:
    311343
    312     SharedClipboardWinEnumFormatEtc(LPFORMATETC pFormatEtc, ULONG cFormats);
     344    SharedClipboardWinEnumFormatEtc(void);
    313345    virtual ~SharedClipboardWinEnumFormatEtc(void);
     346
     347public:
     348
     349    int Init(LPFORMATETC pFormatEtc, ULONG cFormats);
     350    void Destroy(void);
    314351
    315352public: /* IUnknown methods. */
  • trunk/include/VBox/GuestHost/SharedClipboard-x11.h

    r98103 r100204  
    4242#include <X11/Intrinsic.h>
    4343
     44#include <iprt/req.h>
    4445#include <iprt/thread.h>
    4546
     
    113114    /** Flag indicating that the thread is in a started state. */
    114115    bool             fThreadStarted;
     116    /** Request queue.
     117     *  Needed for processing HGCM requests within the HGCM (main) thread from
     118     *  the X11 event thread. */
     119    RTREQQUEUE       hReqQ;
    115120    /** The X Toolkit widget which we use as our clipboard client.  It is never made visible. */
    116121    Widget           pWidget;
     
    159164
    160165/**
    161  * Structure for keeping a X11 read data request.
    162  */
    163 typedef struct _SHCLX11READDATAREQ
    164 {
    165     /** Actual read request to handle. */
    166     CLIPREADCBREQ *pReq;
    167     /** Result code of the operation on completion. */
    168     int            rcCompletion;
    169 } SHCLX11READDATAREQ;
    170 /** Pointer to a send data request. */
    171 typedef SHCLX11READDATAREQ *PSHCLX11READDATAREQ;
     166 * Structure describing an X11 clipboard request.
     167 */
     168typedef struct _SHCLX11REQUEST
     169{
     170    /** The clipboard context this request is associated with. */
     171    SHCLX11CTX      *pCtx;
     172    /** Event associated to this request. */
     173    PSHCLEVENT       pEvent;
     174    union
     175    {
     176        /** Format announcement to X. */
     177        struct
     178        {
     179            /** VBox formats to announce. */
     180            SHCLFORMATS      fFormats;
     181        } Formats;
     182        /** Read request. */
     183        struct
     184        {
     185            /** The format VBox would like the data in. */
     186            SHCLFORMAT       uFmtVBox;
     187            /** The format we requested from X11. */
     188            SHCLX11FMTIDX    idxFmtX11;
     189            /** How much bytes to read at max. */
     190            uint32_t         cbMax;
     191        } Read;
     192    };
     193} SHCLX11REQUEST;
     194/** Pointer to an X11 clipboard request. */
     195typedef SHCLX11REQUEST *PSHCLX11REQUEST;
     196
     197/**
     198 * Structure describing an X11 clipboard response to an X11 clipboard request.
     199 */
     200typedef struct _SHCLX11RESPONSE
     201{
     202    int rc;
     203    struct
     204    {
     205        void    *pvData;
     206        uint32_t cbData;
     207    } Read;
     208} SHCLX11RESPONSE;
     209/** Pointer to an X11 clipboard response. */
     210typedef SHCLX11RESPONSE *PSHCLX11RESPONSE;
    172211
    173212/** @name Shared Clipboard APIs for X11.
     
    179218int ShClX11ThreadStartEx(PSHCLX11CTX pCtx, const char *pszName, bool fGrab);
    180219int ShClX11ThreadStop(PSHCLX11CTX pCtx);
    181 int ShClX11ReportFormatsToX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats);
    182 int ShClX11ReadDataFromX11(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq);
     220int ShClX11ReportFormatsToX11Async(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats);
     221int ShClX11ReadDataFromX11Async(PSHCLX11CTX pCtx, SHCLFORMAT uFmt, uint32_t cbData, PSHCLEVENT pEvent);
    183222void ShClX11SetCallbacks(PSHCLX11CTX pCtx, PSHCLCALLBACKS pCallbacks);
    184223/** @} */
  • trunk/include/VBox/GuestHost/SharedClipboard.h

    r98103 r100204  
    5555/** Shared Clipboard format is HTML. */
    5656#define VBOX_SHCL_FMT_HTML          RT_BIT(2)
    57 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    58 /** Shared Clipboard format is a transfer list. */
     57/** Shared Clipboard format is a transfer list.
     58 *
     59 *  When requesting (reading) data with this format, the following happens:
     60 *  - Acts as a beacon for transfer negotiation / handshake.
     61 *  - The receiving side (source) initializes a transfer locally.
     62 *  - The receiving side reports the transfer status (INIT) to the sending side (target).
     63 *  - The sending side proceeds initializing the transfer locally.
     64 *  - The sending side reports its transfer status (INIT) to the receiving side.
     65 *
     66 *  Note: When receiving an error via a transfer status, the transfer must be destroyed and
     67 *  is considered as being failed wholesale.
     68 *
     69 *  @since 7.1
     70 */
    5971# define VBOX_SHCL_FMT_URI_LIST     RT_BIT(3)
    60 #endif
    6172/** @}  */
    6273
     
    7182/** Pointer to a bit map of Shared Clipboard formats (VBOX_SHCL_FMT_XXX). */
    7283typedef SHCLFORMATS *PSHCLFORMATS;
     84
     85/** Defines the default timeout (in ms) to use for clipboard operations. */
     86#define SHCL_TIMEOUT_DEFAULT_MS                 RT_MS_30SEC
    7387
    7488
     
    193207 *  @{
    194208 */
     209int ShClPayloadInit(uint32_t uID, void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload);
    195210int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload);
    196211void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload);
     
    316331     *         Runs in Xt event thread for the X11 code.
    317332     *
    318      * @returns VBox status code. VERR_NO_DATA if no data available.
     333     * @returns VBox status code.
     334     * @retval  VERR_NO_DATA if no data available.
    319335     * @param   pCtx            Opaque context pointer for the glue code.
    320336     * @param   uFmt            The format in which the data should be transferred
     
    345361/** @} */
    346362
    347 /** Opaque request structure for X11 clipboard data.
    348  * @{ */
    349 struct CLIPREADCBREQ;
    350 typedef struct CLIPREADCBREQ CLIPREADCBREQ;
    351 /** @} */
    352 
    353363#endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */
    354364
  • trunk/include/VBox/HostServices/VBoxClipboardSvc.h

    r100021 r100204  
    798798
    799799/** No listing flags specified. */
    800 #define VBOX_SHCL_LIST_FLAG_NONE          0
     800#define VBOX_SHCL_LIST_F_NONE               0
    801801/** Only returns one entry per read. */
    802 #define VBOX_SHCL_LIST_FLAG_RETURN_ONE    RT_BIT(0)
     802#define VBOX_SHCL_LIST_F_RETURN_ONE         RT_BIT(0)
    803803/** Restarts reading a list from the beginning. */
    804 #define VBOX_SHCL_LIST_FLAG_RESTART       RT_BIT(1)
    805 
    806 #define VBOX_SHCL_LISTHDR_FLAG_NONE       0
     804#define VBOX_SHCL_LIST_F_RESTART            RT_BIT(1)
     805/** Listing flags valid mask. */
     806#define VBOX_SHCL_LIST_F_VALID_MASK         0x3
     807
     808/** No list header flags specified. */
     809#define VBOX_SHCL_LISTHDR_F_NONE            0
     810/** List header flags valid mask. */
     811#define VBOX_SHCL_LISTHDR_F_VALID_MASK      0x0
    807812
    808813/** No additional information provided. */
    809 #define VBOX_SHCL_INFO_FLAG_NONE          0
     814#define VBOX_SHCL_INFO_F_NONE               0
    810815/** Get object information of type SHCLFSOBJINFO. */
    811 #define VBOX_SHCL_INFO_FLAG_FSOBJINFO     RT_BIT(0)
     816#define VBOX_SHCL_INFO_F_FSOBJINFO          RT_BIT(0)
     817/** Info flags valid mask. */
     818#define VBOX_SHCL_INFO_F_VALID_MASK         0x1
    812819
    813820/**
     
    929936    /** uint32_t, in: VBOX_SHCL_INFO_FLAG_XXX. */
    930937    HGCMFunctionParameter fInfo;
    931     /** uint32_t, in: Index of root list entry to get (zero-based). */
     938    /** uint64_t, in: Index of root list entry to get (zero-based). */
    932939    HGCMFunctionParameter uIndex;
    933940} VBoxShClRootListEntryParms;
     
    957964    /** in/out: Request parameters. */
    958965    VBoxShClRootListEntryParms Parms;
    959     /** pointer, in/out: Entry name. */
     966    /** pointer, in/out: Entry name.
     967     *  Up to SHCLLISTENTRY_MAX_NAME. */
    960968    HGCMFunctionParameter      szName;
    961969    /** uint32_t, out: Bytes to be used for information/How many bytes were used.  */
  • trunk/include/VBox/VBoxGuestLib.h

    r99739 r100204  
    688688        struct
    689689        {
    690             /** ID of the trnasfer. */
     690            /** ID of the transfer. */
    691691            SHCLTRANSFERID     uID;
    692692            /** Transfer direction. */
    693693            SHCLTRANSFERDIR    enmDir;
    694             /** Additional reproting information. */
     694            /** Additional reporting information. */
    695695            SHCLTRANSFERREPORT Report;
    696696        } TransferStatus;
     
    717717VBGLR3DECL(int)     VbglR3ClipboardReportFeatures(uint32_t idClient, uint64_t fGuestFeatures, uint64_t *pfHostFeatures);
    718718VBGLR3DECL(int)     VbglR3ClipboardQueryFeatures(uint32_t idClient, uint64_t *pfHostFeatures);
     719VBGLR3DECL(int)     VbglR3ClipboardMsgPeek(PVBGLR3SHCLCMDCTX pCtx, uint32_t *pidMsg, uint32_t *pcParameters, uint64_t *pidRestoreCheck);
    719720VBGLR3DECL(int)     VbglR3ClipboardMsgPeekWait(PVBGLR3SHCLCMDCTX pCtx, uint32_t *pidMsg, uint32_t *pcParameters, uint64_t *pidRestoreCheck);
    720721VBGLR3DECL(int)     VbglR3ClipboardEventGetNext(uint32_t idMsg, uint32_t cParms, PVBGLR3SHCLCMDCTX pCtx, PVBGLR3CLIPBOARDEVENT pEvent);
     
    724725
    725726#  ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS
    726 VBGLR3DECL(void)    VbglR3ClipboardTransferSetCallbacks(PSHCLTRANSFERCALLBACKTABLE pCallbacks);
     727VBGLR3DECL(void)    VbglR3ClipboardTransferSetCallbacks(PSHCLTRANSFERCALLBACKS pCallbacks);
    727728VBGLR3DECL(int)     VbglR3ClipboardEventGetNextEx(uint32_t idMsg, uint32_t cParms, PVBGLR3SHCLCMDCTX pCtx, PSHCLTRANSFERCTX pTransferCtx, PVBGLR3CLIPBOARDEVENT pEvent);
    728729
    729730VBGLR3DECL(int)     VbglR3ClipboardTransferStatusReply(PVBGLR3SHCLCMDCTX pCtx, PSHCLTRANSFER pTransfer, SHCLTRANSFERSTATUS uStatus);
    730731
    731 VBGLR3DECL(int)     VbglR3ClipboardRootListRead(PVBGLR3SHCLCMDCTX pCtx, PSHCLROOTLIST *ppRootList);
     732VBGLR3DECL(int)     VbglR3ClipboardRootListRead(PVBGLR3SHCLCMDCTX pCtx, PSHCLLIST *ppRootList);
    732733
    733734VBGLR3DECL(int)     VbglR3ClipboardRootListHdrReadReq(PVBGLR3SHCLCMDCTX pCtx, uint32_t *pfRoots);
    734 VBGLR3DECL(int)     VbglR3ClipboardRootListHdrReadReply(PVBGLR3SHCLCMDCTX pCtx, PSHCLROOTLIST pRootList);
    735 VBGLR3DECL(int)     VbglR3ClipboardRootsWrite(PVBGLR3SHCLCMDCTX pCtx, PSHCLROOTLISTHDR pRoots);
     735VBGLR3DECL(int)     VbglR3ClipboardRootListHdrReadReply(PVBGLR3SHCLCMDCTX pCtx, PSHCLLIST pRootList);
     736VBGLR3DECL(int)     VbglR3ClipboardRootsWrite(PVBGLR3SHCLCMDCTX pCtx, PSHCLLISTHDR pRoots);
    736737
    737738VBGLR3DECL(int)     VbglR3ClipboardListOpenSend(PVBGLR3SHCLCMDCTX pCtx, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList);
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