Changeset 100204 in vbox for trunk/include
- Timestamp:
- Jun 19, 2023 9:11:37 AM (18 months ago)
- Location:
- trunk/include/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-transfers.h
r99966 r100204 40 40 # pragma once 41 41 #endif 42 43 #include <map>44 42 45 43 #include <iprt/assert.h> … … 67 65 */ 68 66 69 /** No Shared Clipboard list ingfeature flags defined. */67 /** No Shared Clipboard list feature flags defined. */ 70 68 #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) 71 71 /** Shared Clipboard feature flags valid mask. */ 72 #define SHCL_TRANSFER_LIST_FEATURE_F_VALID_MASK 0x 072 #define SHCL_TRANSFER_LIST_FEATURE_F_VALID_MASK 0x1 73 73 74 74 /** Defines the maximum length (in chars) a Shared Clipboard transfer path can have. */ … … 80 80 /** Defines the default maximum object handles a Shared Clipboard transfer can have. */ 81 81 #define SHCL_TRANSFER_DEFAULT_MAX_OBJ_HANDLES _4K 82 /** Defines the default timeout (in ms) to use for clipboard operations. */83 #define SHCL_T IMEOUT_DEFAULT_MS RT_MS_30SEC82 /** Defines the separator for the entries of an URI list (as a string). */ 83 #define SHCL_TRANSFER_URI_LIST_SEP_STR "\r\n" 84 84 85 85 /** … … 92 92 /** The transfer has been initialized but is not running yet. */ 93 93 SHCLTRANSFERSTATUS_INITIALIZED, 94 /** The transfer has been uninitialized and is not usable anymore. */ 95 SHCLTRANSFERSTATUS_UNINITIALIZED, 94 96 /** The transfer is active and running. */ 95 97 SHCLTRANSFERSTATUS_STARTED, … … 100 102 /** The transfer has been killed. */ 101 103 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. */ 103 106 SHCLTRANSFERSTATUS_ERROR, 104 107 /** The usual 32-bit hack. */ … … 401 404 typedef _SHCLLISTENTRY SHCLLISTENTRY; 402 405 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 _SHCLROOTLISTHDR412 {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 _SHCLROOTLIST425 {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 434 406 /** 435 407 * Structure for maintaining Shared Clipboard list open parameters. … … 458 430 /** Feature flag(s) of type SHCL_TRANSFER_LIST_FEATURE_F_XXX. */ 459 431 uint32_t fFeatures; 460 /** Total objects returned. */461 uint64_t c TotalObjects;432 /** Total entries of the list. */ 433 uint64_t cEntries; 462 434 /** Total size (in bytes) returned. */ 463 435 uint64_t cbTotalSize; … … 467 439 468 440 /** 469 * Structure for a Shared Clipboard list entry.441 * Structure for a generic Shared Clipboard list entry. 470 442 */ 471 443 typedef struct _SHCLLISTENTRY 472 444 { 445 /** List node. */ 446 RTLISTNODE Node; 473 447 /** Entry name. */ 474 char *pszName;448 char *pszName; 475 449 /** Size (in bytes) of entry name. 476 450 * 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; 480 454 /** Size (in bytes) of the actual list entry. */ 481 uint32_t cbInfo;455 uint32_t cbInfo; 482 456 /** Data of the actual list entry. */ 483 void *pvInfo;457 void *pvInfo; 484 458 } SHCLLISTENTRY; 485 459 /** Pointer to a Shared Clipboard list entry. */ 486 460 typedef SHCLLISTENTRY *PSHCLLISTENTRY; 461 /** Pointer to a const Shared Clipboard list entry. */ 462 typedef SHCLLISTENTRY *PCSHCLLISTENTRY; 487 463 488 464 /** 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 maintaininga generic Shared Clipboard list.465 #define SHCLLISTENTRY_MAX_NAME 1024 466 467 /** 468 * Structure for a generic Shared Clipboard list. 493 469 */ 494 470 typedef struct _SHCLLIST 495 471 { 496 472 /** List header. */ 497 SHCLLISTHDR 498 /** List entries . */499 SHCLROOTLISTENTRY *paEntries;473 SHCLLISTHDR Hdr; 474 /** List entries of type PSHCLLISTENTRY. */ 475 RTLISTANCHOR lstEntries; 500 476 } SHCLLIST; 501 /** Pointer to a Shared Clipboard transfer transfer list. */477 /** Pointer to a generic Shared Clipboard transfer transfer list. */ 502 478 typedef SHCLLIST *PSHCLLIST; 503 479 … … 637 613 638 614 /** 639 * Structure for keeping a single transfer root list entry.640 */641 typedef struct _SHCLLISTROOT642 {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 /**652 615 * Structure for maintaining an Shared Clipboard transfer state. 653 616 * Everything in here will be part of a saved state (later). … … 696 659 { 697 660 /** 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. 699 664 * 700 665 * @returns VBox status code. 701 666 * @param pCtx Provider context to use. 702 * @param p pRootListWhere to store the root list on success.703 */ 704 DECLCALLBACKMEMBER(int, pfnRoot sGet,(PSHCLTXPROVIDERCTX pCtx, PSHCLROOTLIST *ppRootList));667 * @param pRootList Where to store the root list on success. 668 */ 669 DECLCALLBACKMEMBER(int, pfnRootListRead,(PSHCLTXPROVIDERCTX pCtx)); 705 670 /** 706 671 * Opens a transfer list. … … 805 770 /** Queries (assigns) a Shared Clipboard provider interface. */ 806 771 #define SHCLTXPROVIDERIFACE_QUERY(a_Iface, a_Name) \ 807 a_Iface->pfnRoot sGet = a_Name ## RootsGet; \772 a_Iface->pfnRootListRead = a_Name ## RootListRead; \ 808 773 a_Iface->pfnListOpen = a_Name ## ListOpen; \ 809 774 a_Iface->pfnListClose = a_Name ## ListClose; \ … … 822 787 823 788 /** 824 * Structure for the Shared Clipboard transfer provider creation context.825 */ 826 typedef struct _SHCLTXPROVIDER CREATIONCTX789 * Structure for Shared Clipboard transfer provider. 790 */ 791 typedef struct _SHCLTXPROVIDER 827 792 { 828 793 /** Specifies what the source of the provider is. */ 829 794 SHCLSOURCE enmSource; 830 /** The provider interface table . */795 /** The provider interface table to use. */ 831 796 SHCLTXPROVIDERIFACE Interface; 832 797 /** User-provided callback data. */ … … 834 799 /** Size (in bytes) of data at user pointer. */ 835 800 size_t cbUser; 836 } SHCLTXPROVIDER CREATIONCTX;837 /** Pointer to a Shared Clipboard transfer provider creation context. */838 typedef SHCLTXPROVIDER CREATIONCTX *PSHCLTXPROVIDERCREATIONCTX;801 } SHCLTXPROVIDER; 802 /** Pointer to Shared Clipboard transfer provider. */ 803 typedef SHCLTXPROVIDER *PSHCLTXPROVIDER; 839 804 840 805 /** … … 856 821 * Shared Clipboard transfer callback table. 857 822 * 858 * All callbacks are optional and can provide additional information / feedback to a frontend.823 * All callbacks are optional (hence all returning void). 859 824 */ 860 825 typedef struct _SHCLTRANSFERCALLBACKTABLE 861 826 { 862 827 /** 863 * Called when the transfer getsinitialized.828 * Called after the transfer got initialized. 864 829 * 865 830 * @param pCbCtx Pointer to callback context to use. 866 831 */ 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. 870 835 * 871 836 * @param pCbCtx Pointer to callback context to use. 872 837 */ 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)); 874 845 /** 875 846 * Called when the transfer has been complete. … … 888 859 DECLCALLBACKMEMBER(void, pfnOnError,(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcError)); 889 860 /** 890 * Called whentransfer got registered to a transfer context.861 * Called after a transfer got registered to a transfer context. 891 862 * 892 863 * @param pCbCtx Pointer to callback context to use. … … 895 866 DECLCALLBACKMEMBER(void, pfnOnRegistered,(PSHCLTRANSFERCALLBACKCTX pCbCtx, PSHCLTRANSFERCTX pTransferCtx)); 896 867 /** 897 * Called whentransfer got unregistered from a transfer context.868 * Called after a transfer got unregistered from a transfer context. 898 869 * 899 870 * @param pCbCtx Pointer to callback context to use. … … 908 879 } SHCLTRANSFERCALLBACKTABLE; 909 880 /** Pointer to a Shared Clipboard transfer callback table. */ 910 typedef SHCLTRANSFERCALLBACKTABLE *PSHCLTRANSFERCALLBACK TABLE;881 typedef SHCLTRANSFERCALLBACKTABLE *PSHCLTRANSFERCALLBACKS; 911 882 912 883 /** … … 949 920 /** The transfer's own event source. */ 950 921 SHCLEVENTSOURCE Events; 951 /** Current number of concurrent list handles . */922 /** Current number of concurrent list handles in \a lstHandles. */ 952 923 uint32_t cListHandles; 953 /** Maximum number of concurrent list handles . */924 /** Maximum number of concurrent list handles allowed. */ 954 925 uint32_t cMaxListHandles; 955 /** Next upcoming list handle. */926 /** Next upcoming list handle. For book keeping. */ 956 927 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; 961 930 /** List of root entries of this transfer. */ 962 RTLISTANCHORlstRoots;963 /** Current number of concurrent object handles. */931 SHCLLIST lstRoots; 932 /** Current number of concurrent object handles. in \a lstObj. */ 964 933 uint32_t cObjHandles; 965 934 /** Maximum number of concurrent object handles. */ 966 935 uint32_t cMaxObjHandles; 967 /** Next upcoming object handle. */936 /** Next upcoming object handle. For book keeping. */ 968 937 SHCLOBJHANDLE uObjHandleNext; 969 938 /** Map of all objects handles related to this transfer. */ … … 1006 975 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP 1007 976 /** 977 * Enumeration for HTTP server status changes. 978 * 979 * Keep those as flags, so that we can wait for multiple statuses, if needed. 980 */ 981 typedef 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 /** 1008 992 * Structure for keeping a Shared Clipboard HTTP server instance. 1009 993 */ … … 1011 995 { 1012 996 /** 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; 1014 1003 /** Handle of the HTTP server instance. */ 1015 RTHTTPSERVER hHTTPServer;1004 RTHTTPSERVER hHTTPServer; 1016 1005 /** Port number the HTTP server is running on. 0 if not running. */ 1017 uint16_t uPort;1006 uint16_t uPort; 1018 1007 /** List of registered HTTP transfers. */ 1019 RTLISTANCHOR lstTransfers;1008 RTLISTANCHOR lstTransfers; 1020 1009 /** Number of registered HTTP transfers. */ 1021 uint32_t cTransfers;1010 uint32_t cTransfers; 1022 1011 /** Number of files served (via GET) so far. 1023 1012 * Only complete downloads count (i.e. no aborted). */ 1024 uint32_t cDownloaded;1013 uint32_t cDownloaded; 1025 1014 /** Cached response data. */ 1026 RTHTTPSERVERRESP Resp;1015 RTHTTPSERVERRESP Resp; 1027 1016 } SHCLHTTPSERVER; 1028 1017 /** Pointer to Shared Clipboard HTTP server. */ … … 1068 1057 * @{ 1069 1058 */ 1070 PSHCLTXPROVIDERIFACE VBClTransfer QueryIfaceLocal(PSHCLTXPROVIDERIFACE pIface);1059 PSHCLTXPROVIDERIFACE VBClTransferProviderLocalQueryInterface(PSHCLTXPROVIDER pProvider); 1071 1060 /** @} */ 1072 1061 … … 1104 1093 int ShClTransferInit(PSHCLTRANSFER pTransfer, SHCLTRANSFERDIR enmDir, SHCLSOURCE enmSource); 1105 1094 int ShClTransferDestroy(PSHCLTRANSFER pTransfer); 1095 void ShClTransferReset(PSHCLTRANSFER pTransfer); 1106 1096 1107 1097 int ShClTransferRun(PSHCLTRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser); … … 1126 1116 bool ShClTransferListHandleIsValid(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList); 1127 1117 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); 1118 PSHCLLIST ShClTransferListAlloc(void); 1119 void ShClTransferListFree(PSHCLLIST pList); 1120 void ShClTransferListInit(PSHCLLIST pList); 1121 void ShClTransferListDestroy(PSHCLLIST pList); 1122 int ShClTransferListAddEntry(PSHCLLIST pList, PSHCLLISTENTRY pEntry, bool fAppend); 1142 1123 1143 1124 int ShClTransferListHandleInfoInit(PSHCLLISTHANDLEINFO pInfo); … … 1159 1140 int ShClTransferListEntryAlloc(PSHCLLISTENTRY *ppListEntry); 1160 1141 void ShClTransferListEntryFree(PSHCLLISTENTRY pListEntry); 1161 int ShClTransferListEntryCopy(PSHCLLISTENTRY pDst, PSHCLLISTENTRY pSrc); 1162 PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry); 1142 int ShClTransferListEntryInitEx(PSHCLLISTENTRY pListEntry, uint32_t fInfo, const char *pszName, void *pvInfo, uint32_t cbInfo); 1163 1143 int ShClTransferListEntryInit(PSHCLLISTENTRY pListEntry); 1164 1144 void ShClTransferListEntryDestroy(PSHCLLISTENTRY pListEntry); 1165 1145 bool 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); 1146 int ShClTransferListEntryCopy(PSHCLLISTENTRY pDst, PSHCLLISTENTRY pSrc); 1147 PSHCLLISTENTRY ShClTransferListEntryDup(PSHCLLISTENTRY pListEntry); 1148 1149 void ShClTransferCopyCallbacks(PSHCLTRANSFERCALLBACKS pCallbacksDst, PSHCLTRANSFERCALLBACKS pCallbacksSrc); 1150 void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks); 1151 int ShClTransferSetProvider(PSHCLTRANSFER pTransfer, PSHCLTXPROVIDER pProvider); 1152 1153 int ShClTransferRootsInitFromStringList(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots); 1154 int ShClTransferRootsInitFromFile(PSHCLTRANSFER pTransfer, const char *pszFile); 1155 uint64_t ShClTransferRootsCount(PSHCLTRANSFER pTransfer); 1156 PCSHCLLISTENTRY ShClTransferRootsEntryGet(PSHCLTRANSFER pTransfer, uint64_t uIndex); 1157 int ShClTransferRootListRead(PSHCLTRANSFER pTransfer); 1177 1158 /** @} */ 1178 1159 … … 1201 1182 * @{ 1202 1183 */ 1203 int ShCl HttpTransferRegisterAndMaybeStart(PSHCLHTTPCONTEXT pCtx, PSHCLTRANSFER pTransfer);1204 int ShCl HttpTransferUnregisterAndMaybeStop(PSHCLHTTPCONTEXT pCtx, PSHCLTRANSFER pTransfer);1184 int ShClTransferHttpServerMaybeStart(PSHCLHTTPCONTEXT pCtx); 1185 int ShClTransferHttpServerMaybeStop(PSHCLHTTPCONTEXT pCtx); 1205 1186 /** @} */ 1206 1187 … … 1208 1189 * @{ 1209 1190 */ 1210 int ShClTransferHttpServer Create(PSHCLHTTPSERVER pSrv, unsigned cMaxAttempts, uint16_t *puPort);1211 int ShClTransferHttpServer CreateEx(PSHCLHTTPSERVER pSrv, uint16_t uPort);1191 int ShClTransferHttpServerStart(PSHCLHTTPSERVER pSrv, unsigned cMaxAttempts, uint16_t *puPort); 1192 int ShClTransferHttpServerStartEx(PSHCLHTTPSERVER pSrv, uint16_t uPort); 1212 1193 int ShClTransferHttpServerDestroy(PSHCLHTTPSERVER pSrv); 1213 voidShClTransferHttpServerInit(PSHCLHTTPSERVER pSrv);1194 int ShClTransferHttpServerInit(PSHCLHTTPSERVER pSrv); 1214 1195 int ShClTransferHttpServerRegisterTransfer(PSHCLHTTPSERVER pSrv, PSHCLTRANSFER pTransfer); 1215 1196 int ShClTransferHttpServerUnregisterTransfer(PSHCLHTTPSERVER pSrv, PSHCLTRANSFER pTransfer); 1216 bool ShClTransferHttpServerHasTransfer(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer); 1197 PSHCLTRANSFER ShClTransferHttpServerGetTransferFirst(PSHCLHTTPSERVER pSrv); 1198 bool ShClTransferHttpServerGetTransfer(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer); 1217 1199 uint16_t ShClTransferHttpServerGetPort(PSHCLHTTPSERVER pSrv); 1218 1200 uint32_t ShClTransferHttpServerGetTransferCount(PSHCLHTTPSERVER pSrv); … … 1220 1202 char *ShClTransferHttpServerGetUrlA(PSHCLHTTPSERVER pSrv, SHCLTRANSFERID idTransfer); 1221 1203 bool ShClTransferHttpServerIsRunning(PSHCLHTTPSERVER pSrv); 1204 int ShClTransferHttpServerWaitForStatusChange(PSHCLHTTPSERVER pSrv, SHCLHTTPSERVERSTATUS fStatus, RTMSINTERVAL msTimeout); 1222 1205 /** @} */ 1223 1206 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS_HTTP */ … … 1226 1209 * @{ 1227 1210 */ 1211 int ShClPathSanitizeFilename(char *pszPath, size_t cbPath); 1212 int ShClPathSanitize(char *pszPath, size_t cbPath); 1228 1213 const char *ShClTransferStatusToStr(SHCLTRANSFERSTATUS enmStatus); 1229 1214 int ShClTransferValidatePath(const char *pcszPath, bool fMustExist); 1230 void ShClFsObjFromIPRT(PSHCLFSOBJINFO pDst, PCRTFSOBJINFO pSrc); 1215 int ShClFsObjInfoQuery(const char *pszPath, PSHCLFSOBJINFO pObjInfo); 1216 int ShClFsObjInfoFromIPRT(PSHCLFSOBJINFO pDst, PCRTFSOBJINFO pSrc); 1231 1217 /** @} */ 1232 1218 -
trunk/include/VBox/GuestHost/SharedClipboard-win.h
r98103 r100204 42 42 #include <iprt/critsect.h> 43 43 #include <iprt/types.h> 44 #include <iprt/req.h> 44 45 #include <iprt/win/windows.h> 45 46 … … 109 110 bool fCBChainPingInProcess; 110 111 } SHCLWINAPIOLD, *PSHCLWINAPIOLD; 112 113 /** Forward declaration for the Windows data object. */ 114 class SharedClipboardWinDataObject; 111 115 112 116 /** … … 131 135 /** Structure for maintaining the old clipboard API. */ 132 136 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; 133 147 } SHCLWINCTX, *PSHCLWINCTX; 134 148 … … 154 168 155 169 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 156 int SharedClipboardWinGetRoots(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer); 157 int SharedClipboardWinDropFilesToStringList(DROPFILES *pDropFiles, char **papszList, uint32_t *pcbList); 170 int SharedClipboardWinTransferGetRoots(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer); 171 int SharedClipboardWinTransferDropFilesToStringList(DROPFILES *pDropFiles, char **papszList, uint32_t *pcbList); 172 int SharedClipboardWinTransferGetRootsFromClipboard(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer); 173 int SharedClipboardWinTransferCreateAndSetDataObject(PSHCLWINCTX pWinCtx, PSHCLCONTEXT pCtx, PSHCLCALLBACKS pCallbacks); 158 174 #endif 159 175 … … 188 204 /** The object is uninitialized (not ready). */ 189 205 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! */ 191 208 Initialized, 209 /** Transfer is running. */ 210 Running, 192 211 /** The operation has been successfully completed. */ 193 212 Completed, … … 200 219 public: 201 220 202 SharedClipboardWinDataObject(PSHCLTRANSFER pTransfer, 203 LPFORMATETC pFormatEtc = NULL, LPSTGMEDIUM pStgMed = NULL, ULONG cFormats = 0); 221 SharedClipboardWinDataObject(void); 204 222 virtual ~SharedClipboardWinDataObject(void); 223 224 public: 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); 205 230 206 231 public: /* IUnknown methods. */ … … 234 259 public: 235 260 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); 239 263 240 264 public: … … 257 281 void registerFormat(LPFORMATETC pFormatEtc, CLIPFORMAT clipFormat, TYMED tyMed = TYMED_HGLOBAL, 258 282 LONG lindex = -1, DWORD dwAspect = DVASPECT_CONTENT, DVTARGETDEVICE *pTargetDevice = NULL); 283 int setStatusLocked(Status enmStatus, int rc = VINF_SUCCESS); 284 259 285 protected: 260 286 … … 265 291 { 266 292 /** Relative path of the object. */ 267 Utf8Str strPath;293 char *pszPath; 268 294 /** Related (cached) object information. */ 269 295 SHCLFSOBJINFO objInfo; … … 273 299 typedef std::vector<FSOBJENTRY> FsObjEntryList; 274 300 301 /** Shared Clipboard context to use. */ 302 PSHCLCONTEXT m_pCtx; 303 /** Callbacks table to use. */ 304 SHCLCALLBACKS m_Callbacks; 275 305 /** The object's current status. */ 276 306 Status m_enmStatus; … … 290 320 /** List of (cached) file system objects. */ 291 321 FsObjEntryList m_lstEntries; 322 /** Critical section to serialize access. */ 323 RTCRITSECT m_CritSect; 292 324 /** Whether the transfer thread is running. */ 293 bool m_f Running;325 bool m_fThreadRunning; 294 326 /** Event being triggered when reading the transfer list been completed. */ 295 327 RTSEMEVENT m_EventListComplete; 296 /** Event being triggered when the transfer has been completed. */297 RTSEMEVENT m_Event TransferComplete;328 /** Event being triggered when the transfer status has been changed. */ 329 RTSEMEVENT m_EventStatusChanged; 298 330 /** Registered format for CFSTR_FILEDESCRIPTORA. */ 299 331 UINT m_cfFileDescriptorA; … … 310 342 public: 311 343 312 SharedClipboardWinEnumFormatEtc( LPFORMATETC pFormatEtc, ULONG cFormats);344 SharedClipboardWinEnumFormatEtc(void); 313 345 virtual ~SharedClipboardWinEnumFormatEtc(void); 346 347 public: 348 349 int Init(LPFORMATETC pFormatEtc, ULONG cFormats); 350 void Destroy(void); 314 351 315 352 public: /* IUnknown methods. */ -
trunk/include/VBox/GuestHost/SharedClipboard-x11.h
r98103 r100204 42 42 #include <X11/Intrinsic.h> 43 43 44 #include <iprt/req.h> 44 45 #include <iprt/thread.h> 45 46 … … 113 114 /** Flag indicating that the thread is in a started state. */ 114 115 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; 115 120 /** The X Toolkit widget which we use as our clipboard client. It is never made visible. */ 116 121 Widget pWidget; … … 159 164 160 165 /** 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 */ 168 typedef 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. */ 195 typedef SHCLX11REQUEST *PSHCLX11REQUEST; 196 197 /** 198 * Structure describing an X11 clipboard response to an X11 clipboard request. 199 */ 200 typedef 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. */ 210 typedef SHCLX11RESPONSE *PSHCLX11RESPONSE; 172 211 173 212 /** @name Shared Clipboard APIs for X11. … … 179 218 int ShClX11ThreadStartEx(PSHCLX11CTX pCtx, const char *pszName, bool fGrab); 180 219 int ShClX11ThreadStop(PSHCLX11CTX pCtx); 181 int ShClX11ReportFormatsToX11 (PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats);182 int ShClX11ReadDataFromX11 (PSHCLX11CTX pCtx, SHCLFORMATS vboxFormat, CLIPREADCBREQ *pReq);220 int ShClX11ReportFormatsToX11Async(PSHCLX11CTX pCtx, SHCLFORMATS vboxFormats); 221 int ShClX11ReadDataFromX11Async(PSHCLX11CTX pCtx, SHCLFORMAT uFmt, uint32_t cbData, PSHCLEVENT pEvent); 183 222 void ShClX11SetCallbacks(PSHCLX11CTX pCtx, PSHCLCALLBACKS pCallbacks); 184 223 /** @} */ -
trunk/include/VBox/GuestHost/SharedClipboard.h
r98103 r100204 55 55 /** Shared Clipboard format is HTML. */ 56 56 #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 */ 59 71 # define VBOX_SHCL_FMT_URI_LIST RT_BIT(3) 60 #endif61 72 /** @} */ 62 73 … … 71 82 /** Pointer to a bit map of Shared Clipboard formats (VBOX_SHCL_FMT_XXX). */ 72 83 typedef SHCLFORMATS *PSHCLFORMATS; 84 85 /** Defines the default timeout (in ms) to use for clipboard operations. */ 86 #define SHCL_TIMEOUT_DEFAULT_MS RT_MS_30SEC 73 87 74 88 … … 193 207 * @{ 194 208 */ 209 int ShClPayloadInit(uint32_t uID, void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload); 195 210 int ShClPayloadAlloc(uint32_t uID, const void *pvData, uint32_t cbData, PSHCLEVENTPAYLOAD *ppPayload); 196 211 void ShClPayloadFree(PSHCLEVENTPAYLOAD pPayload); … … 316 331 * Runs in Xt event thread for the X11 code. 317 332 * 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. 319 335 * @param pCtx Opaque context pointer for the glue code. 320 336 * @param uFmt The format in which the data should be transferred … … 345 361 /** @} */ 346 362 347 /** Opaque request structure for X11 clipboard data.348 * @{ */349 struct CLIPREADCBREQ;350 typedef struct CLIPREADCBREQ CLIPREADCBREQ;351 /** @} */352 353 363 #endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_h */ 354 364 -
trunk/include/VBox/HostServices/VBoxClipboardSvc.h
r100021 r100204 798 798 799 799 /** No listing flags specified. */ 800 #define VBOX_SHCL_LIST_F LAG_NONE0800 #define VBOX_SHCL_LIST_F_NONE 0 801 801 /** Only returns one entry per read. */ 802 #define VBOX_SHCL_LIST_F LAG_RETURN_ONERT_BIT(0)802 #define VBOX_SHCL_LIST_F_RETURN_ONE RT_BIT(0) 803 803 /** 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 807 812 808 813 /** No additional information provided. */ 809 #define VBOX_SHCL_INFO_F LAG_NONE0814 #define VBOX_SHCL_INFO_F_NONE 0 810 815 /** 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 812 819 813 820 /** … … 929 936 /** uint32_t, in: VBOX_SHCL_INFO_FLAG_XXX. */ 930 937 HGCMFunctionParameter fInfo; 931 /** uint 32_t, in: Index of root list entry to get (zero-based). */938 /** uint64_t, in: Index of root list entry to get (zero-based). */ 932 939 HGCMFunctionParameter uIndex; 933 940 } VBoxShClRootListEntryParms; … … 957 964 /** in/out: Request parameters. */ 958 965 VBoxShClRootListEntryParms Parms; 959 /** pointer, in/out: Entry name. */ 966 /** pointer, in/out: Entry name. 967 * Up to SHCLLISTENTRY_MAX_NAME. */ 960 968 HGCMFunctionParameter szName; 961 969 /** uint32_t, out: Bytes to be used for information/How many bytes were used. */ -
trunk/include/VBox/VBoxGuestLib.h
r99739 r100204 688 688 struct 689 689 { 690 /** ID of the tr nasfer. */690 /** ID of the transfer. */ 691 691 SHCLTRANSFERID uID; 692 692 /** Transfer direction. */ 693 693 SHCLTRANSFERDIR enmDir; 694 /** Additional rep roting information. */694 /** Additional reporting information. */ 695 695 SHCLTRANSFERREPORT Report; 696 696 } TransferStatus; … … 717 717 VBGLR3DECL(int) VbglR3ClipboardReportFeatures(uint32_t idClient, uint64_t fGuestFeatures, uint64_t *pfHostFeatures); 718 718 VBGLR3DECL(int) VbglR3ClipboardQueryFeatures(uint32_t idClient, uint64_t *pfHostFeatures); 719 VBGLR3DECL(int) VbglR3ClipboardMsgPeek(PVBGLR3SHCLCMDCTX pCtx, uint32_t *pidMsg, uint32_t *pcParameters, uint64_t *pidRestoreCheck); 719 720 VBGLR3DECL(int) VbglR3ClipboardMsgPeekWait(PVBGLR3SHCLCMDCTX pCtx, uint32_t *pidMsg, uint32_t *pcParameters, uint64_t *pidRestoreCheck); 720 721 VBGLR3DECL(int) VbglR3ClipboardEventGetNext(uint32_t idMsg, uint32_t cParms, PVBGLR3SHCLCMDCTX pCtx, PVBGLR3CLIPBOARDEVENT pEvent); … … 724 725 725 726 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 726 VBGLR3DECL(void) VbglR3ClipboardTransferSetCallbacks(PSHCLTRANSFERCALLBACK TABLEpCallbacks);727 VBGLR3DECL(void) VbglR3ClipboardTransferSetCallbacks(PSHCLTRANSFERCALLBACKS pCallbacks); 727 728 VBGLR3DECL(int) VbglR3ClipboardEventGetNextEx(uint32_t idMsg, uint32_t cParms, PVBGLR3SHCLCMDCTX pCtx, PSHCLTRANSFERCTX pTransferCtx, PVBGLR3CLIPBOARDEVENT pEvent); 728 729 729 730 VBGLR3DECL(int) VbglR3ClipboardTransferStatusReply(PVBGLR3SHCLCMDCTX pCtx, PSHCLTRANSFER pTransfer, SHCLTRANSFERSTATUS uStatus); 730 731 731 VBGLR3DECL(int) VbglR3ClipboardRootListRead(PVBGLR3SHCLCMDCTX pCtx, PSHCL ROOTLIST *ppRootList);732 VBGLR3DECL(int) VbglR3ClipboardRootListRead(PVBGLR3SHCLCMDCTX pCtx, PSHCLLIST *ppRootList); 732 733 733 734 VBGLR3DECL(int) VbglR3ClipboardRootListHdrReadReq(PVBGLR3SHCLCMDCTX pCtx, uint32_t *pfRoots); 734 VBGLR3DECL(int) VbglR3ClipboardRootListHdrReadReply(PVBGLR3SHCLCMDCTX pCtx, PSHCL ROOTLIST pRootList);735 VBGLR3DECL(int) VbglR3ClipboardRootsWrite(PVBGLR3SHCLCMDCTX pCtx, PSHCL ROOTLISTHDR pRoots);735 VBGLR3DECL(int) VbglR3ClipboardRootListHdrReadReply(PVBGLR3SHCLCMDCTX pCtx, PSHCLLIST pRootList); 736 VBGLR3DECL(int) VbglR3ClipboardRootsWrite(PVBGLR3SHCLCMDCTX pCtx, PSHCLLISTHDR pRoots); 736 737 737 738 VBGLR3DECL(int) VbglR3ClipboardListOpenSend(PVBGLR3SHCLCMDCTX pCtx, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList);
Note:
See TracChangeset
for help on using the changeset viewer.