Changeset 78648 in vbox for trunk/src/VBox
- Timestamp:
- May 22, 2019 9:30:34 AM (6 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardURIList.cpp
r78390 r78648 62 62 pcszSource, pcszTarget, (uint64_t)objInfo.cbObject, objInfo.Attr.fMode)); 63 63 64 SharedClipboardURIObject *pObjFile = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File, pcszSource, pcszTarget); 64 SharedClipboardURIObject *pObjFile = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File, 65 pcszSource, pcszTarget); 65 66 if (pObjFile) 66 67 { … … 87 88 LogFlowFunc(("Directory '%s' -> '%s' (file mode 0x%x)\n", pcszSource, pcszTarget, objInfo.Attr.fMode)); 88 89 89 SharedClipboardURIObject *pObjDir = new SharedClipboardURIObject(SharedClipboardURIObject::Type_Directory, pcszSource, pcszTarget); 90 SharedClipboardURIObject *pObjDir = new SharedClipboardURIObject(SharedClipboardURIObject::Type_Directory, 91 pcszSource, pcszTarget); 90 92 if (pObjDir) 91 93 { … … 108 110 109 111 int SharedClipboardURIList::appendPathRecursive(const char *pcszSrcPath, 110 const char *pcszDstPath, const char *pcszDstBase, size_t cchDstBase,111 SHAREDCLIPBOARDURILISTFLAGS fFlags)112 const char *pcszDstPath, const char *pcszDstBase, size_t cchDstBase, 113 SHAREDCLIPBOARDURILISTFLAGS fFlags) 112 114 { 113 115 AssertPtrReturn(pcszSrcPath, VERR_INVALID_POINTER); … … 304 306 305 307 int SharedClipboardURIList::AppendNativePathsFromList(const char *pszNativePaths, size_t cbNativePaths, 306 SHAREDCLIPBOARDURILISTFLAGS fFlags)308 SHAREDCLIPBOARDURILISTFLAGS fFlags) 307 309 { 308 310 AssertPtrReturn(pszNativePaths, VERR_INVALID_POINTER); … … 315 317 316 318 int SharedClipboardURIList::AppendNativePathsFromList(const RTCList<RTCString> &lstNativePaths, 317 SHAREDCLIPBOARDURILISTFLAGS fFlags)319 SHAREDCLIPBOARDURILISTFLAGS fFlags) 318 320 { 319 321 int rc = VINF_SUCCESS; … … 405 407 406 408 int SharedClipboardURIList::AppendURIPathsFromList(const char *pszURIPaths, size_t cbURIPaths, 407 SHAREDCLIPBOARDURILISTFLAGS fFlags)409 SHAREDCLIPBOARDURILISTFLAGS fFlags) 408 410 { 409 411 AssertPtrReturn(pszURIPaths, VERR_INVALID_POINTER); … … 416 418 417 419 int SharedClipboardURIList::AppendURIPathsFromList(const RTCList<RTCString> &lstURI, 418 SHAREDCLIPBOARDURILISTFLAGS fFlags)420 SHAREDCLIPBOARDURILISTFLAGS fFlags) 419 421 { 420 422 int rc = VINF_SUCCESS; … … 514 516 515 517 RTCString SharedClipboardURIList::GetRootEntries(const RTCString &strPathBase /* = "" */, 516 const RTCString &strSeparator /* = "\r\n" */) const518 const RTCString &strSeparator /* = "\r\n" */) const 517 519 { 518 520 RTCString strRet; -
trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk
r78501 r78648 46 46 VBoxSharedClipboard_SOURCES += \ 47 47 VBoxSharedClipboardSvc-uri.cpp \ 48 VBoxSharedClipboardSvc-utils.cpp \ 49 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardCache.cpp \ 50 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardMetaData.cpp \ 48 51 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardPath.cpp \ 49 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardCache.cpp \50 52 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardURIList.cpp \ 51 53 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardURIObject.cpp -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r78618 r78648 22 22 #endif 23 23 24 #include <iprt/list.h> 25 24 26 #include <VBox/hgcmsvc.h> 25 27 #include <VBox/log.h> … … 31 33 32 34 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 33 typedef struct _VBOXCLIPBOARDCLIENTURIDATA 35 /** 36 * Structure for handling a single URI object context. 37 */ 38 typedef struct _VBOXCLIPBOARDCLIENTURIOBJCTX 34 39 { 35 SharedClipboardCache Cache; 36 } VBOXCLIPBOARDCLIENTURIDATA, *PVBOXCLIPBOARDCLIENTURIDATA; 40 /** Pointer to current object being processed. */ 41 SharedClipboardURIObject *pObj; 42 } VBOXCLIPBOARDCLIENTURIOBJCTX, *PVBOXCLIPBOARDCLIENTURIOBJCTX; 43 44 /** 45 * Structure for maintaining a single URI transfer. 46 * A transfer can contain one or multiple files / directories. 47 */ 48 typedef struct _VBOXCLIPBOARDCLIENTURITRANSFER 49 { 50 /** Node for keeping this transfer in a RTList. */ 51 RTLISTNODE Node; 52 /** The transfer's own (local) cache. */ 53 SharedClipboardCache Cache; 54 /** The transfer's URI list, containing the fs object root entries. */ 55 SharedClipboardURIList List; 56 /** Current object being handled. */ 57 VBOXCLIPBOARDCLIENTURIOBJCTX ObjCtx; 58 /** The transfer header, needed for verification and accounting. */ 59 VBOXCLIPBOARDDATAHDR Hdr; 60 /** Intermediate meta data object. */ 61 SHAREDCLIPBOARDMETADATA Meta; 62 } VBOXCLIPBOARDCLIENTURITRANSFER, *PVBOXCLIPBOARDCLIENTURITRANSFER; 37 63 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 38 64 … … 87 113 { 88 114 /** General client state data. */ 89 VBOXCLIPBOARDCLIENTSTATE State;115 VBOXCLIPBOARDCLIENTSTATE State; 90 116 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 91 /** Data related to URI handling. */ 92 VBOXCLIPBOARDCLIENTURIDATA URI; 117 /** List of concurrent transfers. 118 * At the moment we only support one transfer at a time (per client). */ 119 RTLISTANCHOR TransferList; 120 /** Data related to URI transfer handling. */ 121 VBOXCLIPBOARDCLIENTURITRANSFER Transfer; 122 /** Number of concurrent transfers. 123 * At the moment we only support one transfer at a time (per client). */ 124 uint32_t cTransfers; 93 125 #endif 94 126 } VBOXCLIPBOARDCLIENTDATA, *PVBOXCLIPBOARDCLIENTDATA; -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.cpp
r78618 r78648 23 23 #include <VBox/HostServices/VBoxClipboardSvc.h> 24 24 25 #include <iprt/dir.h> 26 #include <iprt/file.h> 27 #include <iprt/path.h> 28 25 29 #include "VBoxSharedClipboardSvc-internal.h" 26 30 #include "VBoxSharedClipboardSvc-uri.h" 27 31 28 32 29 int vboxClipboardSvcURICreate(PVBOXCLIPBOARDCLIENTURIDATA pURIData, uint32_t uClientID) 30 { 31 RT_NOREF(pURIData, uClientID); 32 33 int rc = pURIData->Cache.OpenTemp(SHAREDCLIPBOARDCACHE_FLAGS_NONE); 33 /** 34 * Initializes an URI object context. 35 * 36 * @returns VBox status code. 37 * @param pObjCtx URI object context to initialize. 38 */ 39 int vboxClipboardSvcURIObjCtxInit(PVBOXCLIPBOARDCLIENTURIOBJCTX pObjCtx) 40 { 41 AssertPtrReturn(pObjCtx, VERR_INVALID_POINTER); 42 43 pObjCtx->pObj = NULL; 44 45 return VINF_SUCCESS; 46 } 47 48 /** 49 * Uninitializes an URI object context. 50 * 51 * @param pObjCtx URI object context to uninitialize. 52 */ 53 void vboxClipboardSvcURIObjCtxUninit(PVBOXCLIPBOARDCLIENTURIOBJCTX pObjCtx) 54 { 55 AssertPtrReturnVoid(pObjCtx); 56 57 if (pObjCtx->pObj) 58 { 59 pObjCtx->pObj->Close(); 60 delete pObjCtx->pObj; 61 } 62 63 pObjCtx->pObj = NULL; 64 } 65 66 /** 67 * Returns the URI object context's URI object. 68 * 69 * @returns Pointer to the URI object context's URI object. 70 * @param pObjCtx URI object context to return the URI object for. 71 */ 72 SharedClipboardURIObject *vboxClipboardSvcURIObjCtxGetObj(PVBOXCLIPBOARDCLIENTURIOBJCTX pObjCtx) 73 { 74 AssertPtrReturn(pObjCtx, NULL); 75 return pObjCtx->pObj; 76 } 77 78 /** 79 * Returns if an URI object context is valid or not. 80 * 81 * @returns \c true if valid, \c false if not. 82 * @param pObjCtx URI object context to check. 83 */ 84 bool vboxClipboardSvcURIObjCtxIsValid(PVBOXCLIPBOARDCLIENTURIOBJCTX pObjCtx) 85 { 86 return ( pObjCtx 87 && pObjCtx->pObj 88 && pObjCtx->pObj->IsComplete() == false 89 && pObjCtx->pObj->IsOpen()); 90 } 91 92 /** 93 * Creates a URI transfer object. 94 * 95 * @returns VBox status code. 96 * @param pTransfer Transfer object to destroy. 97 * @param uClientID Client ID to assign to the transfer object. 98 */ 99 int vboxClipboardSvcURITransferCreate(PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer, uint32_t uClientID) 100 { 101 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 102 RT_NOREF(uClientID); 103 104 int rc = pTransfer->Cache.OpenTemp(SHAREDCLIPBOARDCACHE_FLAGS_NONE); 34 105 if (RT_SUCCESS(rc)) 35 106 { 107 rc = SharedClipboardMetaDataInit(&pTransfer->Meta); 108 if (RT_SUCCESS(rc)) 109 vboxClipboardSvcURIObjCtxInit(&pTransfer->ObjCtx); 36 110 } 37 111 … … 39 113 } 40 114 41 void vboxClipboardSvcURIDestroy(PVBOXCLIPBOARDCLIENTURIDATA pURIData) 42 { 43 int rc = pURIData->Cache.Rollback(); 44 if (RT_SUCCESS(rc)) 45 rc = pURIData->Cache.Close(); 46 } 47 115 /** 116 * Destroys a URI transfer object. 117 * 118 * @param pTransfer Transfer object to destroy. 119 */ 120 void vboxClipboardSvcURITransferDestroy(PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer) 121 { 122 AssertPtrReturnVoid(pTransfer); 123 124 vboxClipboardSvcURITransferReset(pTransfer); 125 126 int rc2 = pTransfer->Cache.Close(); 127 AssertRC(rc2); 128 } 129 130 /** 131 * Resets a URI transfer object. 132 * 133 * @param pTransfer Transfer object to reset. 134 */ 135 void vboxClipboardSvcURITransferReset(PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer) 136 { 137 AssertPtrReturnVoid(pTransfer); 138 139 vboxClipboardSvcURIObjCtxUninit(&pTransfer->ObjCtx); 140 141 int rc2 = pTransfer->Cache.Rollback(); 142 AssertRC(rc2); 143 144 SharedClipboardMetaDataDestroy(&pTransfer->Meta); 145 } 146 147 /** 148 * URI client (guest) handler for the Shared Clipboard host service. 149 * 150 * @returns VBox status code. 151 * @param u32ClientID Client ID of the client which called this handler. 152 * @param pvClient Pointer to client-specific data block. 153 * @param u32Function Function number being called. 154 * @param cParms Number of function parameters supplied. 155 * @param paParms Array function parameters supplied. 156 * @param tsArrival Timestamp of arrival. 157 * @param pfAsync Returns \c true if the response needs to be being asynchronous or \c false if not, 158 */ 48 159 int vboxClipboardSvcURIHandler(uint32_t u32ClientID, 49 160 void *pvClient, … … 54 165 bool *pfAsync) 55 166 { 56 RT_NOREF(u32ClientID, pvClient, paParms, tsArrival, pfAsync); 57 58 PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient; 59 RT_NOREF(pClientData); 167 RT_NOREF(u32ClientID, paParms, tsArrival, pfAsync); 168 169 const PVBOXCLIPBOARDCLIENTDATA pClientData = (PVBOXCLIPBOARDCLIENTDATA)pvClient; 60 170 61 171 /* Check if we've the right mode set. */ … … 111 221 return rc; 112 222 223 const PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer = &pClientData->Transfer; 224 113 225 rc = VERR_INVALID_PARAMETER; /* Play safe. */ 114 226 … … 125 237 { 126 238 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR\n")); 127 if (cParms == 12) 128 { 129 VBOXCLIPBOARDCBWRITEDATAHDRDATA data; 239 if (cParms == VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_DATA_HDR) 240 { 241 if (pClientData->cTransfers == 0) /* At the moment we only support on transfer per client at a time. */ 242 { 243 RT_ZERO(pTransfer->Hdr); 244 /* Note: Context ID (paParms[0]) not used yet. */ 245 rc = HGCMSvcGetU32(&paParms[1], &pTransfer->Hdr.uFlags); 246 if (RT_SUCCESS(rc)) 247 rc = HGCMSvcGetU32(&paParms[2], &pTransfer->Hdr.uScreenId); 248 if (RT_SUCCESS(rc)) 249 rc = HGCMSvcGetU64(&paParms[3], &pTransfer->Hdr.cbTotal); 250 if (RT_SUCCESS(rc)) 251 rc = HGCMSvcGetU32(&paParms[4], &pTransfer->Hdr.cbMeta); 252 if (RT_SUCCESS(rc)) 253 rc = HGCMSvcGetPv(&paParms[5], &pTransfer->Hdr.pvMetaFmt, &pTransfer->Hdr.cbMetaFmt); 254 if (RT_SUCCESS(rc)) 255 rc = HGCMSvcGetU32(&paParms[6], &pTransfer->Hdr.cbMetaFmt); 256 if (RT_SUCCESS(rc)) 257 rc = HGCMSvcGetU64(&paParms[7], &pTransfer->Hdr.cObjects); 258 if (RT_SUCCESS(rc)) 259 rc = HGCMSvcGetU32(&paParms[8], &pTransfer->Hdr.enmCompression); 260 if (RT_SUCCESS(rc)) 261 rc = HGCMSvcGetU32(&paParms[9], (uint32_t *)&pTransfer->Hdr.enmChecksumType); 262 if (RT_SUCCESS(rc)) 263 rc = HGCMSvcGetPv(&paParms[10], &pTransfer->Hdr.pvChecksum, &pTransfer->Hdr.cbChecksum); 264 if (RT_SUCCESS(rc)) 265 rc = HGCMSvcGetU32(&paParms[11], &pTransfer->Hdr.cbChecksum); 266 267 LogFlowFunc(("fFlags=0x%x, cbTotalSize=%RU64, cObj=%RU64\n", 268 pTransfer->Hdr.uFlags, pTransfer->Hdr.cbTotal, pTransfer->Hdr.cObjects)); 269 270 if (RT_SUCCESS(rc)) 271 { 272 /** @todo Validate pvMetaFmt + cbMetaFmt. */ 273 /** @todo Validate checksum. */ 274 rc = SharedClipboardMetaDataResize(&pTransfer->Meta, pTransfer->Hdr.cbMeta); 275 if (RT_SUCCESS(rc)) 276 pClientData->cTransfers++; 277 } 278 } 279 else 280 LogFunc(("Another transfer in progress, cTransfers=%RU32\n", pClientData->cTransfers)); 281 } 282 283 break; 284 } 285 286 case VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK: 287 { 288 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK\n")); 289 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_DATA_CHUNK 290 && pClientData->cTransfers) /* Some transfer in-flight? */ 291 { 292 VBOXCLIPBOARDDATACHUNK data; 130 293 RT_ZERO(data); 131 data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_DATA_HDR; 132 rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID); 133 if (RT_SUCCESS(rc)) 134 rc = HGCMSvcGetU32(&paParms[1], &data.data.uFlags); 135 if (RT_SUCCESS(rc)) 136 rc = HGCMSvcGetU32(&paParms[2], &data.data.uScreenId); 137 if (RT_SUCCESS(rc)) 138 rc = HGCMSvcGetU64(&paParms[3], &data.data.cbTotal); 139 if (RT_SUCCESS(rc)) 140 rc = HGCMSvcGetU32(&paParms[4], &data.data.cbMeta); 141 if (RT_SUCCESS(rc)) 142 rc = HGCMSvcGetPv(&paParms[5], &data.data.pvMetaFmt, &data.data.cbMetaFmt); 143 if (RT_SUCCESS(rc)) 144 rc = HGCMSvcGetU32(&paParms[6], &data.data.cbMetaFmt); 145 if (RT_SUCCESS(rc)) 146 rc = HGCMSvcGetU64(&paParms[7], &data.data.cObjects); 147 if (RT_SUCCESS(rc)) 148 rc = HGCMSvcGetU32(&paParms[8], &data.data.enmCompression); 149 if (RT_SUCCESS(rc)) 150 rc = HGCMSvcGetU32(&paParms[9], (uint32_t *)&data.data.enmChecksumType); 151 if (RT_SUCCESS(rc)) 152 rc = HGCMSvcGetPv(&paParms[10], &data.data.pvChecksum, &data.data.cbChecksum); 153 if (RT_SUCCESS(rc)) 154 rc = HGCMSvcGetU32(&paParms[11], &data.data.cbChecksum); 155 156 LogFlowFunc(("fFlags=0x%x, cbTotalSize=%RU64, cObj=%RU64\n", 157 data.data.uFlags, data.data.cbTotal, data.data.cObjects)); 158 } 159 160 break; 161 } 162 163 case VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK: 164 { 165 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK\n")); 166 if (cParms == 5) 167 { 168 VBOXCLIPBOARDCBDATADATA data; 169 RT_ZERO(data); 170 data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_DATA_CHUNK; 171 rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID); 172 if (RT_SUCCESS(rc)) 173 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.data.pvData, &data.data.cbData); 174 if (RT_SUCCESS(rc)) 175 rc = HGCMSvcGetU32(&paParms[2], &data.data.cbData); 176 if (RT_SUCCESS(rc)) 177 rc = HGCMSvcGetPv(&paParms[3], (void**)&data.data.pvChecksum, &data.data.cbChecksum); 178 if (RT_SUCCESS(rc)) 179 rc = HGCMSvcGetU32(&paParms[4], &data.data.cbChecksum); 294 /* Note: Context ID (paParms[0]) not used yet. */ 295 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pvData, &data.cbData); 296 if (RT_SUCCESS(rc)) 297 rc = HGCMSvcGetU32(&paParms[2], &data.cbData); 298 if (RT_SUCCESS(rc)) 299 rc = HGCMSvcGetPv(&paParms[3], (void**)&data.pvChecksum, &data.cbChecksum); 300 if (RT_SUCCESS(rc)) 301 rc = HGCMSvcGetU32(&paParms[4], &data.cbChecksum); 302 303 if (RT_SUCCESS(rc)) 304 { 305 if (!VBoxSvcClipboardDataChunkIsValid(&data)) 306 rc = VERR_INVALID_PARAMETER; 307 } 308 309 if (RT_SUCCESS(rc)) 310 { 311 /** @todo Validate checksum. */ 312 rc = SharedClipboardMetaDataAdd(&pTransfer->Meta, data.pvData, data.cbData); 313 if ( RT_SUCCESS(rc) 314 && SharedClipboardMetaDataGetUsed(&pTransfer->Meta) == pTransfer->Hdr.cbMeta) /* Meta data transfer complete? */ 315 { 316 rc = pTransfer->List.SetFromURIData(SharedClipboardMetaDataRaw(&pTransfer->Meta), 317 SharedClipboardMetaDataGetSize(&pTransfer->Meta), 318 SHAREDCLIPBOARDURILIST_FLAGS_NONE); 319 320 /* We're done processing the meta data, so just destroy it. */ 321 SharedClipboardMetaDataDestroy(&pTransfer->Meta); 322 323 /* 324 * As we now have valid meta data, other parties can now acquire those and 325 * request additional data as well. 326 * 327 * In case of file data, receiving and requesting now depends on the speed of 328 * the actual source and target, i.e. the source might not be finished yet in receiving 329 * the current object, while the target already requests (and maybe waits) for the data to arrive. 330 */ 331 } 332 } 180 333 } 181 334 break; … … 192 345 { 193 346 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR\n")); 194 if (cParms == 4) 195 { 196 VBOXCLIPBOARDCBWRITEDIRDATA data; 347 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_DIR 348 && pClientData->cTransfers) /* Some transfer in-flight? */ 349 { 350 VBOXCLIPBOARDDIRDATA data; 197 351 RT_ZERO(data); 198 data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_DIR; 199 200 rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID); 201 if (RT_SUCCESS(rc)) 202 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pszPath, &data.cbPath); 352 /* Note: Context ID (paParms[0]) not used yet. */ 353 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pszPath, &data.cbPath); 203 354 if (RT_SUCCESS(rc)) 204 355 rc = HGCMSvcGetU32(&paParms[2], &data.cbPath); 205 356 if (RT_SUCCESS(rc)) 206 357 rc = HGCMSvcGetU32(&paParms[3], &data.fMode); 358 359 LogFlowFunc(("pszPath=%s, cbPath=%RU32, fMode=0x%x\n", data.pszPath, data.cbPath, data.fMode)); 360 361 if (RT_SUCCESS(rc)) 362 { 363 if (!VBoxSvcClipboardDirDataIsValid(&data)) 364 rc = VERR_INVALID_PARAMETER; 365 } 366 367 if (RT_SUCCESS(rc)) 368 { 369 const char *pszCacheDir = pTransfer->Cache.GetDirAbs(); 370 char *pszDir = RTPathJoinA(pszCacheDir, data.pszPath); 371 if (pszDir) 372 { 373 rc = RTDirCreateFullPath(pszDir, data.fMode); 374 if (RT_SUCCESS(rc)) 375 { 376 /* Add for having a proper rollback. */ 377 int rc2 = pTransfer->Cache.AddDir(pszDir); 378 AssertRC(rc2); 379 } 380 } 381 else 382 rc = VERR_NO_MEMORY; 383 } 207 384 } 208 385 break; … … 219 396 { 220 397 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR\n")); 221 if (cParms == 6) 222 { 223 VBOXCLIPBOARDCBWRITEFILEHDRDATA data; 398 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_FILE_HDR 399 && pClientData->cTransfers) /* Some transfer in-flight? */ 400 { 401 VBOXCLIPBOARDFILEHDR data; 224 402 RT_ZERO(data); 225 data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_FILE_HDR; 226 227 rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID); 228 if (RT_SUCCESS(rc)) 229 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pszFilePath, &data.cbFilePath); 403 /* Note: Context ID (paParms[0]) not used yet. */ 404 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pszFilePath, &data.cbFilePath); 230 405 if (RT_SUCCESS(rc)) 231 406 rc = HGCMSvcGetU32(&paParms[2], &data.cbFilePath); … … 239 414 LogFlowFunc(("pszPath=%s, cbPath=%RU32, fMode=0x%x, cbSize=%RU64\n", 240 415 data.pszFilePath, data.cbFilePath, data.fMode, data.cbSize)); 416 417 if (RT_SUCCESS(rc)) 418 { 419 if (!VBoxSvcClipboardFileHdrIsValid(&data, &pTransfer->Hdr)) 420 rc = VERR_INVALID_PARAMETER; 421 422 if (pTransfer->ObjCtx.pObj == NULL) 423 { 424 pTransfer->ObjCtx.pObj = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File); 425 if (!pTransfer->ObjCtx.pObj) /** @todo Can this throw? */ 426 rc = VERR_NO_MEMORY; 427 } 428 else /* There still is another object being processed? */ 429 rc = VERR_WRONG_ORDER; 430 } 431 432 if (RT_SUCCESS(rc)) 433 { 434 const char *pszCacheDir = pTransfer->Cache.GetDirAbs(); 435 436 char pszPathAbs[RTPATH_MAX]; 437 rc = RTPathJoin(pszPathAbs, sizeof(pszPathAbs), pszCacheDir, data.pszFilePath); 438 if (RT_SUCCESS(rc)) 439 { 440 rc = SharedClipboardPathSanitize(pszPathAbs, sizeof(pszPathAbs)); 441 if (RT_SUCCESS(rc)) 442 { 443 SharedClipboardURIObject *pObj = vboxClipboardSvcURIObjCtxGetObj(&pTransfer->ObjCtx); 444 445 /** @todo Add sparse file support based on fFlags? (Use Open(..., fFlags | SPARSE). */ 446 rc = pObj->OpenEx(pszPathAbs, SharedClipboardURIObject::View_Target, 447 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE, 448 (data.fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR); 449 if (RT_SUCCESS(rc)) 450 { 451 rc = pObj->SetSize(data.cbSize); 452 453 /** @todo Unescape path before printing. */ 454 LogRel2(("Clipboard: Transferring guest file '%s' to host (%RU64 bytes, mode 0x%x)\n", 455 pObj->GetDestPathAbs().c_str(), pObj->GetSize(), pObj->GetMode())); 456 457 if (pObj->IsComplete()) /* 0-byte file? We're done already. */ 458 { 459 /** @todo Sanitize path. */ 460 LogRel2(("Clipboard: Transferring guest file '%s' (0 bytes) to host complete\n", 461 pObj->GetDestPathAbs().c_str())); 462 463 vboxClipboardSvcURIObjCtxUninit(&pTransfer->ObjCtx); 464 } 465 466 /* Add for having a proper rollback. */ 467 int rc2 = pTransfer->Cache.AddFile(pszPathAbs); 468 AssertRC(rc2); 469 } 470 else 471 LogRel(("Clipboard: Error opening/creating guest file '%s' on host, rc=%Rrc\n", pszPathAbs, rc)); 472 } 473 } 474 } 241 475 } 242 476 break; … … 253 487 { 254 488 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA\n")); 255 if (cParms == 5) 256 { 257 VBOXCLIPBOARDCBWRITEFILEDATADATA data; 489 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_FILE_DATA 490 && pClientData->cTransfers) /* Some transfer in-flight? */ 491 { 492 VBOXCLIPBOARDFILEDATA data; 258 493 RT_ZERO(data); 259 data.hdr.uMagic = CB_MAGIC_CLIPBOARD_WRITE_FILE_DATA; 260 261 rc = HGCMSvcGetU32(&paParms[0], &data.hdr.uContextID); 262 if (RT_SUCCESS(rc)) 263 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pvData, &data.cbData); 494 /* Note: Context ID (paParms[0]) not used yet. */ 495 rc = HGCMSvcGetPv(&paParms[1], (void**)&data.pvData, &data.cbData); 264 496 if (RT_SUCCESS(rc)) 265 497 rc = HGCMSvcGetU32(&paParms[2], &data.cbData); … … 270 502 271 503 LogFlowFunc(("pvData=0x%p, cbData=%RU32\n", data.pvData, data.cbData)); 504 505 if (RT_SUCCESS(rc)) 506 { 507 if (!VBoxSvcClipboardFileDataIsValid(&data, &pTransfer->Hdr)) 508 rc = VERR_INVALID_PARAMETER; 509 510 if (!vboxClipboardSvcURIObjCtxIsValid(&pTransfer->ObjCtx)) 511 rc = VERR_WRONG_ORDER; 512 } 513 514 if (RT_SUCCESS(rc)) 515 { 516 SharedClipboardURIObject *pObj = vboxClipboardSvcURIObjCtxGetObj(&pTransfer->ObjCtx); 517 518 uint32_t cbWritten; 519 rc = pObj->Write(data.pvData, data.cbData, &cbWritten); 520 if (RT_SUCCESS(rc)) 521 { 522 Assert(cbWritten <= data.cbData); 523 if (cbWritten < data.cbData) 524 { 525 /** @todo What to do when the host's disk is full? */ 526 rc = VERR_DISK_FULL; 527 } 528 529 if ( pObj->IsComplete() 530 || RT_FAILURE(rc)) 531 vboxClipboardSvcURIObjCtxUninit(&pTransfer->ObjCtx); 532 } 533 else 534 LogRel(("Clipboard: Error writing guest file data for '%s', rc=%Rrc\n", pObj->GetDestPathAbs().c_str(), rc)); 535 } 272 536 } 273 537 break; … … 289 553 } 290 554 555 #ifdef DEBUG_andy 556 AssertRC(rc); 557 #endif 291 558 return rc; 292 559 } 293 560 561 /** 562 * URI host handler for the Shared Clipboard host service. 563 * 564 * @returns VBox status code. 565 * @param u32Function Function number being called. 566 * @param cParms Number of function parameters supplied. 567 * @param paParms Array function parameters supplied. 568 */ 294 569 int vboxClipboardSvcURIHostHandler(uint32_t u32Function, 295 570 uint32_t cParms, -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.h
r78618 r78648 22 22 #endif 23 23 24 int vboxClipboardSvcURICreate(PVBOXCLIPBOARDCLIENTURIDATA pURIData); 25 void vboxClipboardSvcURIDestroy(PVBOXCLIPBOARDCLIENTURIDATA pURIData); 24 int vboxClipboardSvcURITransferCreate(PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer); 25 void vboxClipboardSvcURITransferDestroy(PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer); 26 void vboxClipboardSvcURITransferReset(PVBOXCLIPBOARDCLIENTURITRANSFER pTransfer); 27 26 28 int vboxClipboardSvcURIHandler(uint32_t u32ClientID, void *pvClient, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival, bool *pfAsync); 27 29 int vboxClipboardSvcURIHostHandler(uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11-stubs.cpp
r78623 r78648 109 109 */ 110 110 int VBoxClipboardSvcImplReadData(PVBOXCLIPBOARDCLIENTDATA pClientData, uint32_t u32Format, 111 void *pv, uint32_t cb, uint32_t *pcbActual)111 void *pv, uint32_t cb, uint32_t *pcbActual) 112 112 { 113 113 RT_NOREF(pClientData, u32Format, pv, cb); … … 127 127 */ 128 128 void VBoxClipboardSvcImplWriteData(PVBOXCLIPBOARDCLIENTDATA pClientData, void *pv, uint32_t cb, 129 uint32_t u32Format)129 uint32_t u32Format) 130 130 { 131 131 RT_NOREF(pClientData, pv, cb, u32Format); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r78618 r78648 375 375 376 376 #ifdef VBOX_VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 377 vboxClipboardSvcURI Destroy(&pClientData->URI);377 vboxClipboardSvcURITransferDestroy(&pClientData->Transfer); 378 378 #endif 379 379 … … 408 408 #ifdef VBOX_VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 409 409 if (RT_SUCCESS(rc)) 410 rc = vboxClipboardSvcURICreate(&pClientData->URI); 410 { 411 rc = vboxClipboardSvcURITransferCreate(&pClientData->Transfer); 412 if (RT_SUCCESS(rc)) 413 { 414 pClientData->cTransfers = 0; 415 } 416 } 411 417 #endif 412 418
Note:
See TracChangeset
for help on using the changeset viewer.