- Timestamp:
- Sep 19, 2019 12:14:07 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-transfers.h
r80886 r80905 48 48 */ 49 49 50 /** No status set. */ 51 #define SHCLTRANSFERSTATUS_NONE 0 52 /** The transfer has been announced but is not running yet. */ 53 #define SHCLTRANSFERSTATUS_READY 1 54 /** The transfer is active and running. */ 55 #define SHCLTRANSFERSTATUS_STARTED 2 56 /** The transfer has been stopped. */ 57 #define SHCLTRANSFERSTATUS_STOPPED 3 58 /** The transfer has been canceled. */ 59 #define SHCLTRANSFERSTATUS_CANCELED 4 60 /** The transfer has been killed. */ 61 #define SHCLTRANSFERSTATUS_KILLED 5 62 /** The transfer ran into an unrecoverable error. */ 63 #define SHCLTRANSFERSTATUS_ERROR 6 50 /** 51 * Defines the transfer status codes. 52 */ 53 typedef enum 54 { 55 /** No status set. */ 56 SHCLTRANSFERSTATUS_NONE = 0, 57 /** The transfer has been initialized but is not running yet. */ 58 SHCLTRANSFERSTATUS_INITIALIZED, 59 /** The transfer is active and running. */ 60 SHCLTRANSFERSTATUS_STARTED, 61 /** The transfer has been stopped. */ 62 SHCLTRANSFERSTATUS_STOPPED, 63 /** The transfer has been canceled. */ 64 SHCLTRANSFERSTATUS_CANCELED, 65 /** The transfer has been killed. */ 66 SHCLTRANSFERSTATUS_KILLED, 67 /** The transfer ran into an unrecoverable error. */ 68 SHCLTRANSFERSTATUS_ERROR 69 } SHCLTRANSFERSTATUSENUM; 64 70 65 71 /** Defines a transfer status. */ … … 873 879 SHCLPROVIDERFUNCMEMBER(TRANSFEROPEN, pfnTransferOpen) 874 880 SHCLPROVIDERFUNCMEMBER(TRANSFERCLOSE, pfnTransferClose) 875 SHCLPROVIDERFUNCMEMBER(GETROOTS, pfn GetRoots)881 SHCLPROVIDERFUNCMEMBER(GETROOTS, pfnRootsGet) 876 882 SHCLPROVIDERFUNCMEMBER(LISTOPEN, pfnListOpen) 877 883 SHCLPROVIDERFUNCMEMBER(LISTCLOSE, pfnListClose) … … 913 919 } SHCLTRANSFERCALLBACKDATA, *PSHCLTRANSFERCALLBACKDATA; 914 920 915 #define SHCLTRANSFERCALLBACKDECLVOID(a_Name) \ 916 typedef DECLCALLBACK(void) RT_CONCAT(FNSHCLCALLBACK, a_Name)(PSHCLTRANSFERCALLBACKDATA pData); \ 917 typedef RT_CONCAT(FNSHCLCALLBACK, a_Name) RT_CONCAT(*PFNSHCLCALLBACK, a_Name); 918 919 #define SHCLTRANSFERCALLBACKDECL(a_Name, ...) \ 920 typedef DECLCALLBACK(void) RT_CONCAT(FNSHCLCALLBACK, a_Name)(PSHCLTRANSFERCALLBACKDATA pData, __VA_ARGS__); \ 921 #define SHCLTRANSFERCALLBACKDECL(a_Ret, a_Name, ...) \ 922 typedef DECLCALLBACK(a_Ret) RT_CONCAT(FNSHCLCALLBACK, a_Name)(PSHCLTRANSFERCALLBACKDATA pData, __VA_ARGS__); \ 921 923 typedef RT_CONCAT(FNSHCLCALLBACK, a_Name) RT_CONCAT(*PFNSHCLCALLBACK, a_Name); 922 924 … … 924 926 RT_CONCAT(PFNSHCLCALLBACK, a_Name) a_Member; 925 927 926 SHCLTRANSFERCALLBACKDECL VOID(TRANSFERPREPARE)927 SHCLTRANSFERCALLBACKDECL VOID(TRANSFERSTARTED)928 SHCLTRANSFERCALLBACKDECL VOID(LISTHEADERCOMPLETE)929 SHCLTRANSFERCALLBACKDECL VOID(LISTENTRYCOMPLETE)930 SHCLTRANSFERCALLBACKDECL (TRANSFERCOMPLETE, int rc)931 SHCLTRANSFERCALLBACKDECL VOID(TRANSFERCANCELED)932 SHCLTRANSFERCALLBACKDECL (TRANSFERERROR, int rc)928 SHCLTRANSFERCALLBACKDECL(int, TRANSFERINITIALIZE) 929 SHCLTRANSFERCALLBACKDECL(int, TRANSFERSTART) 930 SHCLTRANSFERCALLBACKDECL(void, LISTHEADERCOMPLETE) 931 SHCLTRANSFERCALLBACKDECL(void, LISTENTRYCOMPLETE) 932 SHCLTRANSFERCALLBACKDECL(void, TRANSFERCOMPLETE, int rc) 933 SHCLTRANSFERCALLBACKDECL(void, TRANSFERCANCELED) 934 SHCLTRANSFERCALLBACKDECL(void, TRANSFERERROR, int rc) 933 935 934 936 /** … … 938 940 typedef struct _SHCLTRANSFERCALLBACKS 939 941 { 940 /** Saved user pointer. */942 /** Saved user pointer. Optional and can be NULL. */ 941 943 void *pvUser; 942 /** Function pointer, called when the transfer is going to be prepared. */943 SHCLTRANSFERCALLBACKMEMBER(TRANSFER PREPARE, pfnTransferPrepare)944 /** Function pointer, called when the transfer has beenstarted. */945 SHCLTRANSFERCALLBACKMEMBER(TRANSFERSTART ED, pfnTransferStarted)944 /** Function pointer, called after the transfer has been initialized. */ 945 SHCLTRANSFERCALLBACKMEMBER(TRANSFERINITIALIZE, pfnTransferInitialize) 946 /** Function pointer, called before the transfer will be started. */ 947 SHCLTRANSFERCALLBACKMEMBER(TRANSFERSTART, pfnTransferStart) 946 948 /** Function pointer, called when reading / writing the list header is complete. */ 947 949 SHCLTRANSFERCALLBACKMEMBER(LISTHEADERCOMPLETE, pfnListHeaderComplete) … … 1079 1081 int SharedClipboardTransferClose(PSHCLTRANSFER pTransfer); 1080 1082 1081 int SharedClipboardTransferListOpen(PSHCLTRANSFER pTransfer, PSHCLLISTOPENPARMS pOpenParms, 1082 PSHCLLISTHANDLE phList); 1083 int SharedClipboardTransferListOpen(PSHCLTRANSFER pTransfer, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList); 1083 1084 int SharedClipboardTransferListClose(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList); 1084 int SharedClipboardTransferListGetHeader(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, 1085 PSHCLLISTHDR pHdr); 1086 PSHCLTRANSFEROBJ SharedClipboardTransferListGetObj(PSHCLTRANSFER pTransfer, 1087 SHCLLISTHANDLE hList, uint64_t uIdx); 1088 int SharedClipboardTransferListRead(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, 1089 PSHCLLISTENTRY pEntry); 1090 int SharedClipboardTransferListWrite(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, 1091 PSHCLLISTENTRY pEntry); 1085 int SharedClipboardTransferListGetHeader(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTHDR pHdr); 1086 PSHCLTRANSFEROBJ SharedClipboardTransferListGetObj(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, uint64_t uIdx); 1087 int SharedClipboardTransferListRead(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry); 1088 int SharedClipboardTransferListWrite(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList, PSHCLLISTENTRY pEntry); 1092 1089 bool SharedClipboardTransferListHandleIsValid(PSHCLTRANSFER pTransfer, SHCLLISTHANDLE hList); 1093 1090 1094 int SharedClipboardTransferPrepare(PSHCLTRANSFER pTransfer); 1095 int SharedClipboardTransferSetInterface(PSHCLTRANSFER pTransfer, 1096 PSHCLPROVIDERCREATIONCTX pCreationCtx); 1097 int SharedClipboardTransferSetRoots(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots); 1091 int SharedClipboardTransferSetInterface(PSHCLTRANSFER pTransfer, PSHCLPROVIDERCREATIONCTX pCreationCtx); 1092 int SharedClipboardTransferRootsSet(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots); 1098 1093 void SharedClipboardTransferReset(PSHCLTRANSFER pTransfer); 1099 1094 SharedClipboardArea *SharedClipboardTransferGetArea(PSHCLTRANSFER pTransfer); … … 1101 1096 uint32_t SharedClipboardTransferRootsCount(PSHCLTRANSFER pTransfer); 1102 1097 int SharedClipboardTransferRootsEntry(PSHCLTRANSFER pTransfer, uint64_t uIndex, PSHCLROOTLISTENTRY pEntry); 1103 int SharedClipboardTransferRoots AsList(PSHCLTRANSFER pTransfer, PSHCLROOTLIST *ppRootList);1098 int SharedClipboardTransferRootsGet(PSHCLTRANSFER pTransfer, PSHCLROOTLIST *ppRootList); 1104 1099 1105 1100 SHCLTRANSFERID SharedClipboardTransferGetID(PSHCLTRANSFER pTransfer); … … 1108 1103 int SharedClipboardTransferHandleReply(PSHCLTRANSFER pTransfer, PSHCLREPLY pReply); 1109 1104 int SharedClipboardTransferRun(PSHCLTRANSFER pTransfer, PFNRTTHREAD pfnThreadFunc, void *pvUser); 1105 int SharedClipboardTransferStart(PSHCLTRANSFER pTransfer); 1110 1106 void SharedClipboardTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKS pCallbacks); 1111 1107 … … 1133 1129 bool SharedClipboardMIMENeedsCache(const char *pcszFormat, size_t cchFormatMax); 1134 1130 1135 const char *VBoxShClTransferStatusToStr( uint32_t uStatus);1131 const char *VBoxShClTransferStatusToStr(SHCLTRANSFERSTATUS enmStatus); 1136 1132 1137 1133 #endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_transfers_h */ -
trunk/include/VBox/VBoxGuestLib.h
r80863 r80905 576 576 * @{ */ 577 577 578 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 579 /** 580 * Structure containing context parameters for Shared Clipboard transfers. 581 */ 582 typedef struct VBGLR3SHCLTRANSFERCMDCTX 583 { 584 /** Callback table to use for all transfers. */ 585 SHCLTRANSFERCALLBACKS Callbacks; 586 } VBGLR3SHCLTRANSFERCMDCTX, *PVBGLR3SHCLTRANSFERCMDCTX; 587 # endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 588 578 589 /** 579 590 * Structure containing the context required for … … 591 602 592 603 /** IN: HGCM client ID to use for communication. */ 593 uint32_t uClientID;604 uint32_t uClientID; 594 605 /** IN/OUT: Context ID to retrieve or to use. */ 595 uint32_t uContextID;606 uint32_t uContextID; 596 607 /** IN: Protocol version to use. */ 597 uint32_t uProtocolVer;608 uint32_t uProtocolVer; 598 609 /** IN: Protocol flags. Currently unused. */ 599 uint32_t uProtocolFlags;610 uint32_t uProtocolFlags; 600 611 /** IN: Maximum chunk size (in bytes). */ 601 uint32_t cbChunkSize;612 uint32_t cbChunkSize; 602 613 /** OUT: Number of parameters retrieved. */ 603 uint32_t uNumParms; 614 uint32_t uNumParms; 615 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 616 VBGLR3SHCLTRANSFERCMDCTX Transfers; 617 # endif 604 618 } VBGLR3SHCLCMDCTX, *PVBGLR3SHCLCMDCTX; 605 619 … … 613 627 VBGLR3CLIPBOARDEVENTTYPE_READ_DATA, 614 628 VBGLR3CLIPBOARDEVENTTYPE_QUIT, 615 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS629 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 616 630 /** Reports a transfer status to the guest. */ 617 631 VBGLR3CLIPBOARDEVENTTYPE_URI_TRANSFER_STATUS, 618 # endif632 # endif 619 633 /** Blow the type up to 32-bit. */ 620 634 VBGLR3CLIPBOARDEVENTTYPE_32BIT_HACK = 0x7fffffff … … 636 650 /** Reports that data needs to be read from the guest. */ 637 651 SHCLDATAREQ ReadData; 638 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS652 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 639 653 /** Reports a transfer status to the guest. */ 640 654 struct … … 647 661 SHCLTRANSFERREPORT Report; 648 662 } TransferStatus; 649 # endif663 # endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 650 664 } u; 651 665 } VBGLR3CLIPBOARDEVENT, *PVBGLR3CLIPBOARDEVENT; -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r80886 r80905 94 94 *********************************************************************************************************************************/ 95 95 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 96 static DECLCALLBACK(void) vboxClipboardTransferCompleteCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc); 97 static DECLCALLBACK(void) vboxClipboardTransferErrorCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc); 96 static DECLCALLBACK(int) vboxClipboardOnTransferStartCallback(PSHCLTRANSFERCALLBACKDATA pData); 97 static DECLCALLBACK(void) vboxClipboardOnTransferCompleteCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc); 98 static DECLCALLBACK(void) vboxClipboardOnTransferErrorCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc); 98 99 #endif 99 100 … … 183 184 } 184 185 185 static DECLCALLBACK(void) vboxClipboardTransferCompleteCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc) 186 { 187 RT_NOREF(rc); 188 189 LogFlowFunc(("pData=%p, rc=%Rrc\n", pData, rc)); 186 static DECLCALLBACK(int) vboxClipboardOnTransferStartCallback(PSHCLTRANSFERCALLBACKDATA pData) 187 { 188 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 189 AssertPtr(pCtx); 190 191 LogFlowFunc(("pCtx=%p\n", pCtx)); 192 193 int rc = SharedClipboardWinOpen(pCtx->Win.hWnd); 194 if (RT_SUCCESS(rc)) 195 { 196 PSHCLTRANSFER pTransfer; 197 rc = SharedClipboardTransferCreate(&pTransfer); 198 if (RT_SUCCESS(rc)) 199 rc = SharedClipboardTransferInit(pTransfer, 0 /* uID */, 200 SHCLTRANSFERDIR_WRITE, SHCLSOURCE_LOCAL); 201 if (RT_SUCCESS(rc)) 202 { 203 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 204 * presented as a IDataObject or IStream. */ 205 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 206 if (hClip) 207 { 208 HDROP hDrop = (HDROP)GlobalLock(hClip); 209 if (hDrop) 210 { 211 char *papszList = NULL; 212 uint32_t cbList; 213 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 214 215 GlobalUnlock(hClip); 216 217 if (RT_SUCCESS(rc)) 218 { 219 rc = SharedClipboardTransferRootsSet(pTransfer, 220 papszList, cbList + 1 /* Include termination */); 221 RTStrFree(papszList); 222 } 223 } 224 else 225 { 226 hClip = NULL; 227 } 228 } 229 } 230 231 SharedClipboardWinClose(); 232 } 233 234 LogFlowFuncLeaveRC(rc); 235 return rc; 236 } 237 238 static DECLCALLBACK(void) vboxClipboardOnTransferCompleteCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc) 239 { 240 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 241 AssertPtr(pCtx); 242 243 RT_NOREF(pCtx, rc); 244 245 LogFlowFunc(("pCtx=%p, rc=%Rrc\n", pCtx, rc)); 190 246 191 247 LogRel2(("Shared Clipboard: Transfer to destination complete\n")); … … 194 250 } 195 251 196 static DECLCALLBACK(void) vboxClipboardTransferErrorCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc) 197 { 198 RT_NOREF(rc); 199 200 LogFlowFunc(("pData=%p, rc=%Rrc\n", pData, rc)); 252 static DECLCALLBACK(void) vboxClipboardOnTransferErrorCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc) 253 { 254 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 255 AssertPtr(pCtx); 256 257 RT_NOREF(pCtx, rc); 258 259 LogFlowFunc(("pCtx=%p, rc=%Rrc\n", pCtx, rc)); 201 260 202 261 LogRel(("Shared Clipboard: Transfer to destination failed with %Rrc\n", rc)); … … 770 829 } 771 830 } 772 #if def VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS831 #if 0 773 832 else if (uFormat == VBOX_SHCL_FMT_URI_LIST) 774 833 { … … 979 1038 creationCtx.enmSource = SHCLSOURCE_REMOTE; 980 1039 981 creationCtx.Interface.pfn GetRoots= vboxClipboardTransferGetRoots;1040 creationCtx.Interface.pfnRootsGet = vboxClipboardTransferGetRoots; 982 1041 creationCtx.Interface.pfnListOpen = vboxClipboardTransferListOpen; 983 1042 creationCtx.Interface.pfnListClose = vboxClipboardTransferListClose; … … 1151 1210 } 1152 1211 else 1212 { 1153 1213 LogRel(("Shared Clipboard: Initialized OLE\n")); 1214 1215 /* Install callbacks. */ 1216 RT_ZERO(pCtx->CmdCtx.Transfers.Callbacks); 1217 1218 pCtx->CmdCtx.Transfers.Callbacks.pvUser = pCtx; /* Assign context as user-provided callback data. */ 1219 1220 pCtx->CmdCtx.Transfers.Callbacks.pfnTransferStart = vboxClipboardOnTransferStartCallback; 1221 pCtx->CmdCtx.Transfers.Callbacks.pfnTransferComplete = vboxClipboardOnTransferCompleteCallback; 1222 pCtx->CmdCtx.Transfers.Callbacks.pfnTransferError = vboxClipboardOnTransferErrorCallback; 1223 } 1154 1224 #endif 1155 1225 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r80886 r80905 1263 1263 if (RT_SUCCESS(rc)) 1264 1264 { 1265 SharedClipboardTransferSetCallbacks(pTransfer, &pCmdCtx->Transfers.Callbacks); 1266 1265 1267 rc = SharedClipboardTransferCtxTransferRegisterByIndex(pTransferCtx, pTransfer, uTransferID); 1266 1268 if (RT_SUCCESS(rc)) 1267 1269 { 1268 1270 rc = SharedClipboardTransferInit(pTransfer, uTransferID, enmDir, enmSource); 1269 if (RT_FAILURE(rc)) 1271 if (RT_SUCCESS(rc)) 1272 { 1273 rc = SharedClipboardTransferStart(pTransfer); 1274 } 1275 else 1270 1276 SharedClipboardTransferCtxTransferUnregister(pTransferCtx, uTransferID); 1271 1277 } … … 1359 1365 switch (transferReport.uStatus) 1360 1366 { 1361 case SHCLTRANSFERSTATUS_ READY:1367 case SHCLTRANSFERSTATUS_INITIALIZED: 1362 1368 RT_FALL_THROUGH(); 1363 1369 case SHCLTRANSFERSTATUS_STARTED: -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
r80885 r80905 335 335 { 336 336 PSHCLROOTLIST pRootList; 337 rc = SharedClipboardTransfer LTransferRootsAsList(pTransfer, &pRootList);337 rc = SharedClipboardTransferRootsGet(pTransfer, &pRootList); 338 338 if (RT_SUCCESS(rc)) 339 339 { … … 570 570 const bool fUnicode = pFormatEtc->cfFormat == m_cfFileDescriptorW; 571 571 572 LogFlowFunc(("FormatIndex_FileDescriptor%s\n", fUnicode ? "W" : "A")); 572 const uint32_t enmTransferStatus = SharedClipboardTransferGetStatus(m_pTransfer); 573 574 LogFlowFunc(("FormatIndex_FileDescriptor%s, transfer status is %s\n", 575 fUnicode ? "W" : "A", VBoxShClTransferStatusToStr(enmTransferStatus))); 573 576 574 577 int rc; 575 578 576 579 /* The caller can call GetData() several times, so make sure we don't do the same transfer multiple times. */ 577 if (SharedClipboardTransferGetStatus(m_pTransfer) == SHCLTRANSFERSTATUS_NONE) 578 { 579 rc = SharedClipboardTransferPrepare(m_pTransfer); 580 if (enmTransferStatus == SHCLTRANSFERSTATUS_INITIALIZED) 581 { 582 /* Start the transfer asynchronously in a separate thread. */ 583 rc = SharedClipboardTransferRun(m_pTransfer, &SharedClipboardWinDataObject::readThread, this); 580 584 if (RT_SUCCESS(rc)) 581 585 { 582 /* Start the transfer asynchronously in a separate thread. */ 583 rc = SharedClipboardTransferRun(m_pTransfer, &SharedClipboardWinDataObject::readThread, this); 586 /* Don't block for too long here, as this also will screw other apps running on the OS. */ 587 LogFunc(("Waiting for listing to arrive ...\n")); 588 rc = RTSemEventWait(m_EventListComplete, 30 * 1000 /* 30s timeout */); 584 589 if (RT_SUCCESS(rc)) 585 590 { 586 /* Don't block for too long here, as this also will screw other apps running on the OS. */ 587 LogFunc(("Waiting for listing to arrive ...\n")); 588 rc = RTSemEventWait(m_EventListComplete, 30 * 1000 /* 30s timeout */); 589 if (RT_SUCCESS(rc)) 590 { 591 LogFunc(("Listing complete\n")); 592 } 591 LogFunc(("Listing complete\n")); 593 592 } 594 593 } -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp
r80886 r80905 1157 1157 1158 1158 /** 1159 * Initializes a n Shared Clipboard transfer object.1159 * Initializes a shared Clipboard transfer object. 1160 1160 * 1161 1161 * @returns VBox status code. … … 1173 1173 1174 1174 int rc = SharedClipboardEventSourceCreate(&pTransfer->Events, pTransfer->State.uID); 1175 if (RT_SUCCESS(rc)) 1176 { 1177 pTransfer->State.enmStatus = SHCLTRANSFERSTATUS_INITIALIZED; /* Now we're ready to run. */ 1178 1179 if (pTransfer->Callbacks.pfnTransferInitialize) 1180 { 1181 SHCLTRANSFERCALLBACKDATA Data = { pTransfer, pTransfer->Callbacks.pvUser }; 1182 rc = pTransfer->Callbacks.pfnTransferInitialize(&Data); 1183 } 1184 } 1175 1185 1176 1186 LogFlowFuncLeaveRC(rc); … … 1644 1654 1645 1655 /** 1646 * Returns the current transfer object for a clipboardShared Clipboard transfer list.1656 * Returns the current transfer object for a Shared Clipboard transfer list. 1647 1657 * 1648 1658 * Currently not implemented and wil return NULL. … … 1853 1863 1854 1864 /** 1855 * Prepares everything needed for a read / write transfer to begin.1856 *1857 * @returns VBox status code.1858 * @param pTransfer Clipboard transfer to prepare.1859 */1860 int SharedClipboardTransferPrepare(PSHCLTRANSFER pTransfer)1861 {1862 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);1863 1864 LogFlowFuncEnter();1865 1866 int rc = VINF_SUCCESS;1867 1868 AssertMsgReturn(pTransfer->State.enmStatus == SHCLTRANSFERSTATUS_NONE,1869 ("Transfer has wrong state (%RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER);1870 1871 LogFlowFunc(("pTransfer=%p, enmDir=%RU32\n", pTransfer, pTransfer->State.enmDir));1872 1873 if (pTransfer->Callbacks.pfnTransferPrepare)1874 {1875 SHCLTRANSFERCALLBACKDATA callbackData = { pTransfer, pTransfer->Callbacks.pvUser };1876 pTransfer->Callbacks.pfnTransferPrepare(&callbackData);1877 }1878 1879 if (RT_SUCCESS(rc))1880 {1881 pTransfer->State.enmStatus = SHCLTRANSFERSTATUS_READY;1882 1883 /** @todo Add checksum support. */1884 }1885 1886 LogFlowFuncLeaveRC(rc);1887 return rc;1888 }1889 1890 /**1891 1865 * Sets the transfer provider interface for a given transfer. 1892 1866 * … … 1913 1887 LOG_IFACE_PTR(pfnTransferOpen); 1914 1888 LOG_IFACE_PTR(pfnTransferClose); 1915 LOG_IFACE_PTR(pfn GetRoots);1889 LOG_IFACE_PTR(pfnRootsGet); 1916 1890 LOG_IFACE_PTR(pfnListOpen); 1917 1891 LOG_IFACE_PTR(pfnListClose); … … 1928 1902 1929 1903 /** 1930 * Clears (resets) the root list of a n Shared Clipboard transfer.1904 * Clears (resets) the root list of a shared Clipboard transfer. 1931 1905 * 1932 1906 * @param pTransfer Transfer to clear transfer root list for. … … 1957 1931 1958 1932 /** 1959 * Sets transfer root list entries for a given transfer. 1960 * 1961 * @returns VBox status code. 1962 * @param pTransfer Transfer to set transfer list entries for. 1963 * @param pszRoots String list (separated by CRLF) of root entries to set. 1964 * All entries must have the same root path. 1965 * @param cbRoots Size (in bytes) of string list. 1966 */ 1967 int SharedClipboardTransferSetRoots(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots) 1968 { 1969 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 1970 AssertPtrReturn(pszRoots, VERR_INVALID_POINTER); 1971 AssertReturn(cbRoots, VERR_INVALID_PARAMETER); 1972 1973 if (!RTStrIsValidEncoding(pszRoots)) 1974 return VERR_INVALID_PARAMETER; 1975 1976 int rc = VINF_SUCCESS; 1933 * Resets a shared Clipboard transfer. 1934 * 1935 * @param pTransfer Clipboard transfer to reset. 1936 */ 1937 void SharedClipboardTransferReset(PSHCLTRANSFER pTransfer) 1938 { 1939 AssertPtrReturnVoid(pTransfer); 1940 1941 LogFlowFuncEnter(); 1977 1942 1978 1943 sharedClipboardTransferListRootsClear(pTransfer); 1979 1980 char *pszPathRootAbs = NULL; 1981 1982 RTCList<RTCString> lstRootEntries = RTCString(pszRoots, cbRoots - 1).split("\r\n"); 1983 for (size_t i = 0; i < lstRootEntries.size(); ++i) 1984 { 1985 PSHCLLISTROOT pListRoot = (PSHCLLISTROOT)RTMemAlloc(sizeof(SHCLLISTROOT)); 1986 AssertPtrBreakStmt(pListRoot, rc = VERR_NO_MEMORY); 1987 1988 pListRoot->pszPathAbs = RTStrDup(lstRootEntries.at(i).c_str()); 1989 AssertPtrBreakStmt(pListRoot->pszPathAbs, rc = VERR_NO_MEMORY); 1990 1991 if (!pszPathRootAbs) 1992 { 1993 pszPathRootAbs = RTStrDup(pListRoot->pszPathAbs); 1994 if (pszPathRootAbs) 1995 { 1996 RTPathStripFilename(pszPathRootAbs); 1997 LogFlowFunc(("pszPathRootAbs=%s\n", pszPathRootAbs)); 1998 } 1999 else 2000 rc = VERR_NO_MEMORY; 2001 } 2002 2003 if (RT_FAILURE(rc)) 2004 break; 2005 2006 /* Make sure all entries have the same root path. */ 2007 if (!RTStrStartsWith(pListRoot->pszPathAbs, pszPathRootAbs)) 2008 { 2009 rc = VERR_INVALID_PARAMETER; 2010 break; 2011 } 2012 2013 RTListAppend(&pTransfer->lstRoots, &pListRoot->Node); 2014 2015 pTransfer->cRoots++; 2016 } 2017 2018 /** @todo Entry rollback on failure? */ 2019 2020 if (RT_SUCCESS(rc)) 2021 { 2022 pTransfer->pszPathRootAbs = pszPathRootAbs; 2023 LogFlowFunc(("pszPathRootAbs=%s, cRoots=%zu\n", pTransfer->pszPathRootAbs, pTransfer->cRoots)); 2024 } 2025 2026 LogFlowFuncLeaveRC(rc); 2027 return rc; 2028 } 2029 2030 /** 2031 * Resets an clipboard Shared Clipboard transfer. 2032 * 2033 * @param pTransfer Clipboard transfer to reset. 2034 */ 2035 void SharedClipboardTransferReset(PSHCLTRANSFER pTransfer) 2036 { 2037 AssertPtrReturnVoid(pTransfer); 2038 2039 LogFlowFuncEnter(); 2040 2041 sharedClipboardTransferListRootsClear(pTransfer); 2042 } 2043 2044 /** 2045 * Returns the clipboard area for a clipboard Shared Clipboard transfer. 1944 } 1945 1946 /** 1947 * Returns the clipboard area for a Shared Clipboard transfer. 2046 1948 * 2047 1949 * @returns Current clipboard area, or NULL if none. … … 2075 1977 * @param uIdx Index of root list entry to return. 2076 1978 */ 2077 inline PSHCLLISTROOT sharedClipboardTransferRootsGet (PSHCLTRANSFER pTransfer, uint32_t uIdx)1979 inline PSHCLLISTROOT sharedClipboardTransferRootsGetInternal(PSHCLTRANSFER pTransfer, uint32_t uIdx) 2078 1980 { 2079 1981 if (uIdx >= pTransfer->cRoots) … … 2081 1983 2082 1984 PSHCLLISTROOT pIt = RTListGetFirst(&pTransfer->lstRoots, SHCLLISTROOT, Node); 2083 while (uIdx--) 1985 while (uIdx--) /** @todo Slow, but works for now. */ 2084 1986 pIt = RTListGetNext(&pTransfer->lstRoots, pIt, SHCLLISTROOT, Node); 2085 1987 … … 2096 1998 */ 2097 1999 int SharedClipboardTransferRootsEntry(PSHCLTRANSFER pTransfer, 2098 2000 uint64_t uIndex, PSHCLROOTLISTENTRY pEntry) 2099 2001 { 2100 2002 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); … … 2106 2008 int rc; 2107 2009 2108 PSHCLLISTROOT pRoot = sharedClipboardTransferRootsGet (pTransfer, uIndex);2010 PSHCLLISTROOT pRoot = sharedClipboardTransferRootsGetInternal(pTransfer, uIndex); 2109 2011 AssertPtrReturn(pRoot, VERR_INVALID_PARAMETER); 2110 2012 … … 2153 2055 2154 2056 /** 2155 * Returns the root entries of a n Shared Clipboard transfer.2057 * Returns the root entries of a shared Clipboard transfer. 2156 2058 * 2157 2059 * @returns VBox status code. … … 2159 2061 * @param ppRootList Where to store the root list on success. 2160 2062 */ 2161 int SharedClipboardTransferRoots AsList(PSHCLTRANSFER pTransfer, PSHCLROOTLIST *ppRootList)2063 int SharedClipboardTransferRootsGet(PSHCLTRANSFER pTransfer, PSHCLROOTLIST *ppRootList) 2162 2064 { 2163 2065 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); … … 2210 2112 else if (pTransfer->State.enmSource == SHCLSOURCE_REMOTE) 2211 2113 { 2212 if (pTransfer->ProviderIface.pfn GetRoots)2213 rc = pTransfer->ProviderIface.pfn GetRoots(&pTransfer->ProviderCtx, ppRootList);2114 if (pTransfer->ProviderIface.pfnRootsGet) 2115 rc = pTransfer->ProviderIface.pfnRootsGet(&pTransfer->ProviderCtx, ppRootList); 2214 2116 else 2215 2117 rc = VERR_NOT_SUPPORTED; … … 2220 2122 } 2221 2123 2124 2125 /** 2126 * Sets transfer root list entries for a given transfer. 2127 * 2128 * @returns VBox status code. 2129 * @param pTransfer Transfer to set transfer list entries for. 2130 * @param pszRoots String list (separated by CRLF) of root entries to set. 2131 * All entries must have the same root path. 2132 * @param cbRoots Size (in bytes) of string list. 2133 */ 2134 int SharedClipboardTransferRootsSet(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots) 2135 { 2136 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 2137 AssertPtrReturn(pszRoots, VERR_INVALID_POINTER); 2138 AssertReturn(cbRoots, VERR_INVALID_PARAMETER); 2139 2140 if (!RTStrIsValidEncoding(pszRoots)) 2141 return VERR_INVALID_PARAMETER; 2142 2143 int rc = VINF_SUCCESS; 2144 2145 sharedClipboardTransferListRootsClear(pTransfer); 2146 2147 char *pszPathRootAbs = NULL; 2148 2149 RTCList<RTCString> lstRootEntries = RTCString(pszRoots, cbRoots - 1).split("\r\n"); 2150 for (size_t i = 0; i < lstRootEntries.size(); ++i) 2151 { 2152 PSHCLLISTROOT pListRoot = (PSHCLLISTROOT)RTMemAlloc(sizeof(SHCLLISTROOT)); 2153 AssertPtrBreakStmt(pListRoot, rc = VERR_NO_MEMORY); 2154 2155 pListRoot->pszPathAbs = RTStrDup(lstRootEntries.at(i).c_str()); 2156 AssertPtrBreakStmt(pListRoot->pszPathAbs, rc = VERR_NO_MEMORY); 2157 2158 if (!pszPathRootAbs) 2159 { 2160 pszPathRootAbs = RTStrDup(pListRoot->pszPathAbs); 2161 if (pszPathRootAbs) 2162 { 2163 RTPathStripFilename(pszPathRootAbs); 2164 LogFlowFunc(("pszPathRootAbs=%s\n", pszPathRootAbs)); 2165 } 2166 else 2167 rc = VERR_NO_MEMORY; 2168 } 2169 2170 if (RT_FAILURE(rc)) 2171 break; 2172 2173 /* Make sure all entries have the same root path. */ 2174 if (!RTStrStartsWith(pListRoot->pszPathAbs, pszPathRootAbs)) 2175 { 2176 rc = VERR_INVALID_PARAMETER; 2177 break; 2178 } 2179 2180 RTListAppend(&pTransfer->lstRoots, &pListRoot->Node); 2181 2182 pTransfer->cRoots++; 2183 } 2184 2185 /** @todo Entry rollback on failure? */ 2186 2187 if (RT_SUCCESS(rc)) 2188 { 2189 pTransfer->pszPathRootAbs = pszPathRootAbs; 2190 LogFlowFunc(("pszPathRootAbs=%s, cRoots=%zu\n", pTransfer->pszPathRootAbs, pTransfer->cRoots)); 2191 } 2192 2193 LogFlowFuncLeaveRC(rc); 2194 return rc; 2195 } 2196 2222 2197 /** 2223 2198 * Returns the transfer's ID. … … 2260 2235 2261 2236 /** 2262 * Runs (starts) an Shared Clipboard transferthread.2237 * Starts (runs) a Shared Clipboard transfer in a dedicated thread. 2263 2238 * 2264 2239 * @returns VBox status code. … … 2271 2246 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 2272 2247 2273 AssertMsgReturn(pTransfer->State.enmStatus == SHCLTRANSFERSTATUS_READY, 2274 ("Wrong status (currently is %RU32)\n", pTransfer->State.enmStatus), VERR_WRONG_ORDER); 2275 2276 int rc = sharedClipboardTransferThreadCreate(pTransfer, pfnThreadFunc, pvUser); 2248 int rc = SharedClipboardTransferStart(pTransfer); 2249 if (RT_SUCCESS(rc)) 2250 rc = sharedClipboardTransferThreadCreate(pTransfer, pfnThreadFunc, pvUser); 2277 2251 2278 2252 LogFlowFuncLeaveRC(rc); … … 2281 2255 2282 2256 /** 2283 * Sets or unsets the callback table to be used for a clipboard Shared Clipboard transfer. 2257 * Starts an initialized transfer. 2258 * 2259 * @returns VBox status code. 2260 * @param pTransfer Clipboard transfer to start. 2261 */ 2262 int SharedClipboardTransferStart(PSHCLTRANSFER pTransfer) 2263 { 2264 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 2265 2266 /* Ready to start? */ 2267 AssertMsgReturn(pTransfer->State.enmStatus == SHCLTRANSFERSTATUS_INITIALIZED, 2268 ("Wrong status (currently is %s)\n", VBoxShClTransferStatusToStr(pTransfer->State.enmStatus)), 2269 VERR_WRONG_ORDER); 2270 2271 int rc; 2272 2273 if (pTransfer->Callbacks.pfnTransferStart) 2274 { 2275 SHCLTRANSFERCALLBACKDATA Data = { pTransfer, pTransfer->Callbacks.pvUser }; 2276 rc = pTransfer->Callbacks.pfnTransferStart(&Data); 2277 } 2278 else 2279 rc = VINF_SUCCESS; 2280 2281 /* Nothing else to do here right now. */ 2282 2283 LogFlowFuncLeaveRC(rc); 2284 return rc; 2285 } 2286 2287 /** 2288 * Sets or unsets the callback table to be used for a Shared Clipboard transfer. 2284 2289 * 2285 2290 * @returns VBox status code. … … 2299 2304 pTransfer->Callbacks.a_pfnCallback = pCallbacks->a_pfnCallback 2300 2305 2301 SET_CALLBACK(pfnTransfer Prepare);2302 SET_CALLBACK(pfnTransferStart ed);2306 SET_CALLBACK(pfnTransferInitialize); 2307 SET_CALLBACK(pfnTransferStart); 2303 2308 SET_CALLBACK(pfnListHeaderComplete); 2304 2309 SET_CALLBACK(pfnListEntryComplete); 2305 2310 SET_CALLBACK(pfnTransferCanceled); 2306 2311 SET_CALLBACK(pfnTransferError); 2307 SET_CALLBACK(pfnTransferStarted);2308 2312 2309 2313 #undef SET_CALLBACK … … 2313 2317 2314 2318 /** 2315 * Creates a thread for a clipboardShared Clipboard transfer.2319 * Creates a thread for a Shared Clipboard transfer. 2316 2320 * 2317 2321 * @returns VBox status code. … … 2347 2351 2348 2352 /** 2349 * Destroys a thread of a clipboardShared Clipboard transfer.2353 * Destroys a thread of a Shared Clipboard transfer. 2350 2354 * 2351 2355 * @returns VBox status code. … … 2374 2378 2375 2379 /** 2376 * Initializes a clipboardShared Clipboard transfer.2380 * Initializes a Shared Clipboard transfer. 2377 2381 * 2378 2382 * @returns VBox status code. … … 2402 2406 2403 2407 /** 2404 * Destroys a n Shared Clipboard transfer context context struct.2408 * Destroys a shared Clipboard transfer context context struct. 2405 2409 * 2406 2410 * @param pTransferCtx Transfer context to destroy. … … 2430 2434 2431 2435 /** 2432 * Resets a n clipboard Shared Clipboard transfer.2436 * Resets a shared Clipboard transfer. 2433 2437 * 2434 2438 * @param pTransferCtx Transfer context to reset. … … 2501 2505 2502 2506 /** 2503 * Registers a n Shared Clipboard transfer with a transfer context, i.e. allocates a transfer ID.2507 * Registers a shared Clipboard transfer with a transfer context, i.e. allocates a transfer ID. 2504 2508 * 2505 2509 * @return VBox status code. … … 2554 2558 2555 2559 /** 2556 * Registers a n Shared Clipboard transfer with a transfer contextby specifying an ID for the transfer.2560 * Registers a shared Clipboard transfer with a transfer contextby specifying an ID for the transfer. 2557 2561 * 2558 2562 * @return VBox status code. … … 2948 2952 * 2949 2953 * @returns Transfer status string name. 2950 * @param uStatusThe transfer status to translate.2951 */ 2952 const char *VBoxShClTransferStatusToStr( uint32_t uStatus)2953 { 2954 switch ( uStatus)2954 * @param enmStatus The transfer status to translate. 2955 */ 2956 const char *VBoxShClTransferStatusToStr(SHCLTRANSFERSTATUS enmStatus) 2957 { 2958 switch (enmStatus) 2955 2959 { 2956 2960 RT_CASE_RET_STR(SHCLTRANSFERSTATUS_NONE); 2957 RT_CASE_RET_STR(SHCLTRANSFERSTATUS_ READY);2961 RT_CASE_RET_STR(SHCLTRANSFERSTATUS_INITIALIZED); 2958 2962 RT_CASE_RET_STR(SHCLTRANSFERSTATUS_STARTED); 2959 2963 RT_CASE_RET_STR(SHCLTRANSFERSTATUS_STOPPED); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-transfers.cpp
r80883 r80905 90 90 91 91 HGCMSvcSetU32(&pMsgHdr->paParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 92 92 pCtx->pTransfer->State.uID, uEvent)); 93 93 HGCMSvcSetU32(&pMsgHdr->paParms[1], 0 /* fRoots */); 94 94 … … 644 644 LogFlowFuncLeaveRC(rc); 645 645 return rc; 646 }647 648 649 /*********************************************************************************************************************************650 * transfer callbacks *651 *********************************************************************************************************************************/652 653 DECLCALLBACK(void) VBoxSvcClipboardTransferPrepareCallback(PSHCLTRANSFERCALLBACKDATA pData)654 {655 RT_NOREF(pData);656 657 LogFlowFuncEnter();658 }659 660 DECLCALLBACK(void) VBoxSvcClipboardTransferCompleteCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc)661 {662 RT_NOREF(pData, rc);663 664 LogFlowFuncEnter();665 666 LogRel2(("Shared Clipboard: Transfer complete\n"));667 }668 669 DECLCALLBACK(void) VBoxSvcClipboardTransferCanceledCallback(PSHCLTRANSFERCALLBACKDATA pData)670 {671 LogFlowFuncEnter();672 673 RT_NOREF(pData);674 675 LogRel2(("Shared Clipboard: Transfer canceled\n"));676 }677 678 DECLCALLBACK(void) VBoxSvcClipboardTransferErrorCallback(PSHCLTRANSFERCALLBACKDATA pData, int rc)679 {680 LogFlowFuncEnter();681 682 RT_NOREF(pData, rc);683 684 LogRel(("Shared Clipboard: Transfer failed with %Rrc\n", rc));685 646 } 686 647 … … 1373 1334 if (enmDir == SHCLTRANSFERDIR_READ) 1374 1335 { 1375 creationCtx.Interface.pfn GetRoots= sharedClipboardSvcTransferGetRoots;1336 creationCtx.Interface.pfnRootsGet = sharedClipboardSvcTransferGetRoots; 1376 1337 creationCtx.Interface.pfnListHdrRead = sharedClipboardSvcTransferListHdrRead; 1377 1338 creationCtx.Interface.pfnListEntryRead = sharedClipboardSvcTransferListEntryRead; … … 2176 2137 creationCtx.Interface.pfnObjClose = sharedClipboardSvcTransferObjClose; 2177 2138 2178 creationCtx.Interface.pfn GetRoots= sharedClipboardSvcTransferGetRoots;2139 creationCtx.Interface.pfnRootsGet = sharedClipboardSvcTransferGetRoots; 2179 2140 creationCtx.Interface.pfnListHdrRead = sharedClipboardSvcTransferListHdrRead; 2180 2141 creationCtx.Interface.pfnListEntryRead = sharedClipboardSvcTransferListEntryRead; … … 2193 2154 creationCtx.enmSource = pClient->State.enmSource; 2194 2155 creationCtx.pvUser = pClient; 2195 2196 /* Register needed callbacks so that we can wait for the meta data to arrive here. */2197 SHCLTRANSFERCALLBACKS Callbacks;2198 RT_ZERO(Callbacks);2199 2200 Callbacks.pvUser = pClient;2201 2202 Callbacks.pfnTransferPrepare = VBoxSvcClipboardTransferPrepareCallback;2203 Callbacks.pfnTransferComplete = VBoxSvcClipboardTransferCompleteCallback;2204 Callbacks.pfnTransferCanceled = VBoxSvcClipboardTransferCanceledCallback;2205 Callbacks.pfnTransferError = VBoxSvcClipboardTransferErrorCallback;2206 2207 SharedClipboardTransferSetCallbacks(pTransfer, &Callbacks);2208 2156 2209 2157 uint32_t uTransferID = 0; … … 2223 2171 SHCLEVENTID uEvent; 2224 2172 rc = sharedClipboardSvcTransferSendStatus(pClient, pTransfer, 2225 SHCLTRANSFERSTATUS_ READY, VINF_SUCCESS,2173 SHCLTRANSFERSTATUS_INITIALIZED, VINF_SUCCESS, 2226 2174 &uEvent); 2227 2175 if (RT_SUCCESS(rc)) … … 2240 2188 Assert(pReply->uType == VBOX_SHCL_REPLYMSGTYPE_TRANSFER_STATUS); 2241 2189 2242 if (pReply->u.TransferStatus.uStatus )2190 if (pReply->u.TransferStatus.uStatus == SHCLTRANSFERSTATUS_STARTED) 2243 2191 { 2244 2192 LogRel2(("Shared Clipboard: Started transfer %RU32 on guest\n", pTransfer->State.uID));
Note:
See TracChangeset
for help on using the changeset viewer.