Changeset 78942 in vbox
- Timestamp:
- Jun 3, 2019 7:10:19 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-uri.h
r78897 r78942 38 38 #include <iprt/cpp/ministring.h> 39 39 40 #include <VBox/HostServices/VBoxClipboardSvc.h> 41 40 42 /** Clipboard area ID. A valid area is >= 1. 41 43 * If 0 is specified, the last (most recent) area is meant. … … 85 87 int OpenTemp(SHAREDCLIPBOARDAREAID uID = NIL_SHAREDCLIPBOARDAREAID, 86 88 SHAREDCLIPBOARDAREAFLAGS fFlags = SHAREDCLIPBOARDAREA_FLAGS_NONE); 87 SHAREDCLIPBOARDAREAID Get AreaID(void) const;89 SHAREDCLIPBOARDAREAID GetID(void) const; 88 90 const char *GetDirAbs(void) const; 89 91 uint32_t GetRefCount(void); … … 224 226 bool IsComplete(void) const; 225 227 bool IsOpen(void) const; 226 int Open(View enmView, uint64_t fOpen, RTFMODE fMode = 0); 227 int OpenEx(const RTCString &strPath, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0, SHAREDCLIPBOARDURIOBJECTFLAGS = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 228 int OpenDirectory(View enmView, uint32_t fCreate = 0, RTFMODE fMode = 0); 229 int OpenDirectoryEx(const RTCString &strPathAbs, View enmView, 230 uint32_t fCreate = 0, RTFMODE fMode = 0, 231 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 232 int OpenFile(View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0); 233 int OpenFileEx(const RTCString &strPathAbs, View enmView, 234 uint64_t fOpen = 0, RTFMODE fMode = 0, 235 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 228 236 int QueryInfo(View enmView); 229 237 int Read(void *pvBuf, size_t cbBuf, uint32_t *pcbRead); 230 238 void Reset(void); 239 int SetDirectoryData(const RTCString &strPathAbs, View enmView, uint32_t fOpen = 0, RTFMODE fMode = 0, 240 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 241 int SetFileData(const RTCString &strPathAbs, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0, 242 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 231 243 int Write(const void *pvBuf, size_t cbBuf, uint32_t *pcbWritten); 232 244 … … 238 250 239 251 void closeInternal(void); 252 int setDirectoryDataInternal(const RTCString &strPathAbs, View enmView, uint32_t fCreate = 0, RTFMODE fMode = 0, 253 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 254 int setFileDataInternal(const RTCString &strPathAbs, View enmView, uint64_t fOpen = 0, RTFMODE fMode = 0, 255 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 240 256 int queryInfoInternal(View enmView); 241 257 … … 250 266 /** Absolute path (base) for the target. */ 251 267 RTCString m_strTgtPathAbs; 268 /** Saved SHAREDCLIPBOARDURIOBJECT_FLAGS. */ 269 uint32_t m_fFlags; 270 /** Requested file mode. 271 * Note: The actual file mode of an opened file will be in objInfo. */ 272 RTFMODE m_fModeRequested; 252 273 253 274 /** Union containing data depending on the object's type. */ … … 262 283 /** File system object information of this file. */ 263 284 RTFSOBJINFO objInfo; 285 /** Requested file open flags. */ 286 uint32_t fOpenRequested; 264 287 /** Bytes to proces for reading/writing. */ 265 288 uint64_t cbToProcess; … … 273 296 /** File system object information of this directory. */ 274 297 RTFSOBJINFO objInfo; 298 /** Requested directory creation flags. */ 299 uint32_t fCreateRequested; 275 300 } Dir; 276 301 } u; … … 428 453 virtual int WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags = 0) = 0; 429 454 430 virtual int ReadData(void *pvBuf, size_t cbBuf, size_t *pcbRead /* = NULL */) = 0; 431 virtual int WriteData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten /* = NULL */) = 0; 455 int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData); 456 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData); 457 458 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr); 459 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr); 460 int ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData); 461 int WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData); 432 462 433 463 virtual void Reset(void) = 0; … … 466 496 int WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags = 0); 467 497 468 int ReadData(void *pvBuf, size_t cbBuf, size_t *pcbRead /* = NULL */); 469 int WriteData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten /* = NULL */); 498 int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData); 499 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData); 500 501 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr); 502 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr); 503 int ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData); 504 int WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData); 470 505 471 506 void Reset(void); … … 492 527 public: 493 528 494 int ReadMetaData(uint32_t fFlags = 0); 495 int WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags = 0); 496 497 int ReadData(void *pvBuf, size_t cbBuf, size_t *pcbRead /* = NULL */); 498 int WriteData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten /* = NULL */); 529 int ReadMetaData(uint32_t fFlags = 0); 530 int WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags = 0); 531 532 int ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData); 533 int WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData); 534 535 int ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr); 536 int WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr); 537 int ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData); 538 int WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData); 499 539 500 540 void Reset(void); -
trunk/include/VBox/VBoxGuestLib.h
r78897 r78942 610 610 VBGLR3DECL(int) VbglR3ClipboardWriteData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb); 611 611 # ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 612 VBGLR3DECL(int) VbglR3ClipboardReadDir(HGCMCLIENTID idClient, char *pszDirname, uint32_t cbDirname, uint32_t *pcbDirnameRecv, 613 uint32_t *pfMode); 614 VBGLR3DECL(int) VbglR3ClipboardWriteDir(HGCMCLIENTID idClient, const char *pszPath, uint32_t cbPath, uint32_t fMode); 615 VBGLR3DECL(int) VbglR3ClipboardReadFileHdr(HGCMCLIENTID idClient, char *pszFilename, uint32_t cbFilename, uint32_t *puFlags, 616 uint32_t *pfMode, uint64_t *pcbTotal); 617 VBGLR3DECL(int) VbglR3ClipboardWriteFileHdr(HGCMCLIENTID idClient, const char *pszFilename, uint32_t cbFilename, 618 uint32_t fFlags, uint32_t fMode, uint64_t cbTotal); 619 VBGLR3DECL(int) VbglR3ClipboardReadFileData(HGCMCLIENTID idClient, void *pvData, uint32_t cbData, uint32_t *pcbRead); 620 VBGLR3DECL(int) VbglR3ClipboardWriteFileData(HGCMCLIENTID idClient, void *pvData, uint32_t cbData, uint32_t *pcbWritten); 612 621 VBGLR3DECL(int) VbglR3ClipboardSendError(HGCMCLIENTID idClient, int rcErr); 613 622 # endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
r78809 r78942 57 57 VBoxTray_DEFS += VBOX_WITH_SHARED_CLIPBOARD_GUEST 58 58 VBoxTray_SOURCES += \ 59 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/Clipboard Cache.cpp \59 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardArea.cpp \ 60 60 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp \ 61 61 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardEnumFormatEtcImpl-win.cpp \ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r78897 r78942 72 72 73 73 74 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 75 /** 76 * Thread for transferring URI objects from guest to the host. 77 * For host to guest transfers we utilize our own IDataObject / IStream implementations. 78 * 79 * @returns VBox status code. 80 * @param hThread Thread handle. 81 * @param pvUser User arguments; is PVBOXCLIPBOARDWINCTX. 82 */ 83 static int vboxClipboardURIThread(RTTHREAD hThread, void *pvUser) 84 { 85 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 86 87 LogFlowFuncEnter(); 88 89 PVBOXCLIPBOARDWINCTX pWinCtx = (PVBOXCLIPBOARDWINCTX)pvUser; 90 AssertPtr(pWinCtx); 91 92 int rc = 0; 93 94 return rc; 95 } 96 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 74 97 75 98 static LRESULT vboxClipboardWinProcessMsg(PVBOXCLIPBOARDCONTEXT pCtx, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) … … 519 542 if (RT_SUCCESS(rc)) 520 543 { 521 rc = VbglR3ClipboardWriteData(pCtx->u32ClientID, uFormat, pszList, (uint32_t)cbList); 522 RTMemFree(pszList); 544 /* Spawn a worker thread, so that we don't block the window thread for too long. */ 545 rc = RTThreadCreate(&hThread, vboxClipboardURIThread, pWinCtx /* pvUser */, 546 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, 547 "vboxshclp"); 548 if (RT_SUCCESS(rc)) 549 { 550 int rc2 = RTThreadUserWait(hThread, 30 * 1000 /* Timeout in ms */); 551 AssertRC(rc2); 552 553 if (!pCtx->fStarted) /* Did the thread fail to start? */ 554 rc = VERR_GENERAL_FAILURE; /** @todo Find a better rc. */ 555 } 523 556 } 524 557 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r78897 r78942 52 52 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 53 53 static int vbglR3ClipboardWriteErrorInternal(HGCMCLIENTID idClient, int rcErr); 54 static int vbglR3ClipboardReadURIData(HGCMCLIENTID idClient, PVBOXCLIPBOARDDATAHDR pDataHdr);55 static int vbglR3ClipboardWriteURIData(HGCMCLIENTID idClient, const void *pvData, size_t cbData);56 54 #endif 57 55 … … 438 436 439 437 /** 440 * Utility function to reada directory entry from the host.438 * Reads a directory entry from the host. 441 439 * 442 440 * @returns IPRT status code. … … 447 445 * @param pfMode Where to store the directory creation mode. 448 446 */ 449 static int vbglR3ClipboardReadDir(HGCMCLIENTID idClient,450 char *pszDirname,451 uint32_t cbDirname,452 uint32_t *pcbDirnameRecv,453 uint32_t *pfMode)447 VBGLR3DECL(int) VbglR3ClipboardReadDir(HGCMCLIENTID idClient, 448 char *pszDirname, 449 uint32_t cbDirname, 450 uint32_t *pcbDirnameRecv, 451 uint32_t *pfMode) 454 452 { 455 453 AssertPtrReturn(pszDirname, VERR_INVALID_POINTER); … … 482 480 483 481 /** 484 * Utility function to receive a file header from the host. 482 * Writes a guest directory to the host. 483 * 484 * @returns IPRT status code. 485 * @param idClient The client id returned by VbglR3ClipboardConnect(). 486 * @param pszPath Directory path. 487 * @param cbPath Size (in bytes) of directory path. 488 * @param fMode File mode for directory (IPRT-style). 489 */ 490 VBGLR3DECL(int) VbglR3ClipboardWriteDir(HGCMCLIENTID idClient, 491 const char *pszPath, 492 uint32_t cbPath, 493 uint32_t fMode) 494 { 495 const size_t cchDir = strlen(pszPath); 496 497 if ( !cchDir 498 || cchDir > RTPATH_MAX 499 || cchDir != cbPath) /* UTF-8 */ 500 return VERR_INVALID_PARAMETER; 501 502 const uint32_t cbPathSz = (uint32_t)cchDir + 1; /* Include termination. */ 503 504 VBoxClipboardWriteDirMsg Msg; 505 RT_ZERO(Msg); 506 507 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR, VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_DIR); 508 /** @todo Context ID not used yet. */ 509 Msg.pvName.SetPtr((void *)pszPath, (uint32_t)cbPathSz); 510 Msg.cbName.SetUInt32(cbPathSz); 511 Msg.fMode.SetUInt32(fMode); 512 513 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 514 } 515 516 /** 517 * Receives a file header from the host. 485 518 * 486 519 * @returns IPRT status code. … … 492 525 * @param pcbTotal Where to store the file size (in bytes). 493 526 */ 494 static int vbglR3ClipboardReadFileHdr(HGCMCLIENTID idClient,495 char *pszFilename,496 uint32_t cbFilename,497 uint32_t *puFlags,498 uint32_t *pfMode,499 uint64_t *pcbTotal)527 VBGLR3DECL(int) VbglR3ClipboardReadFileHdr(HGCMCLIENTID idClient, 528 char *pszFilename, 529 uint32_t cbFilename, 530 uint32_t *puFlags, 531 uint32_t *pfMode, 532 uint64_t *pcbTotal) 500 533 { 501 534 AssertPtrReturn(pszFilename, VERR_INVALID_POINTER); … … 530 563 531 564 /** 532 * Utility function to receive a file data chunk from the host. 565 * Writes a file header from the guest to the host. 566 * 567 * @returns VBox status code. 568 * @param idClient The client id returned by VbglR3ClipboardConnect(). 569 * @param pszFilename File name this header belong to. 570 * @param cbFilename Size (in bytes) of file name. 571 * @param fFlags Transfer flags; not being used and will be ignored. 572 * @param fMode File mode. 573 * @param cbTotal File size (in bytes). 574 */ 575 VBGLR3DECL(int) VbglR3ClipboardWriteFileHdr(HGCMCLIENTID idClient, const char *pszFilename, uint32_t cbFilename, 576 uint32_t fFlags, uint32_t fMode, uint64_t cbTotal) 577 { 578 RT_NOREF(fFlags); 579 580 const size_t cchFile = strlen(pszFilename); 581 582 if ( !cchFile 583 || cchFile > RTPATH_MAX 584 || cchFile != cbFilename) 585 return VERR_INVALID_PARAMETER; 586 587 const uint32_t cbFileSz = (uint32_t)cchFile + 1; /* Include termination. */ 588 589 VBoxClipboardWriteFileHdrMsg MsgHdr; 590 RT_ZERO(MsgHdr); 591 592 VBGL_HGCM_HDR_INIT(&MsgHdr.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR, VBOX_SHARED_CLIPBOARD_CPARMS_READ_FILE_HDR); 593 MsgHdr.uContext.SetUInt32(0); /* Context ID; unused at the moment. */ 594 MsgHdr.pvName.SetPtr((void *)pszFilename, (uint32_t)(cbFileSz)); 595 MsgHdr.cbName.SetUInt32(cbFileSz); 596 MsgHdr.uFlags.SetUInt32(0); /* Flags; unused at the moment. */ 597 MsgHdr.fMode.SetUInt32(fMode); /* File mode */ 598 MsgHdr.cbTotal.SetUInt64(cbTotal); /* File size (in bytes). */ 599 600 return VbglR3HGCMCall(&MsgHdr.hdr, sizeof(MsgHdr)); 601 } 602 603 /** 604 * Reads a file data chunk from the host. 533 605 * 534 606 * @returns IPRT status code. … … 536 608 * @param pvData Where to store the file data chunk. 537 609 * @param cbData Size (in bytes) of where to store the data chunk. 538 * @param pcb DataRecv Size (in bytes) of the actual data chunk size received.539 */ 540 static int vbglR3ClipboardReadFileData(HGCMCLIENTID idClient,541 void *pvData,542 uint32_t cbData,543 uint32_t *pcbDataRecv)544 { 545 AssertPtrReturn(pvData, 546 AssertReturn(cbData, 547 AssertPtrReturn(pcb DataRecv,VERR_INVALID_POINTER);610 * @param pcbRead Size (in bytes) of the actual data chunk size read. 611 */ 612 VBGLR3DECL(int) VbglR3ClipboardReadFileData(HGCMCLIENTID idClient, 613 void *pvData, 614 uint32_t cbData, 615 uint32_t *pcbRead) 616 { 617 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 618 AssertReturn(cbData, VERR_INVALID_PARAMETER); 619 AssertPtrReturn(pcbRead, VERR_INVALID_POINTER); 548 620 549 621 VBoxClipboardReadFileDataMsg Msg; … … 562 634 { 563 635 /** @todo Context ID not used yet. */ 564 rc = Msg.cbData.GetUInt32(pcb DataRecv); AssertRC(rc);565 AssertReturn(cbData >= *pcb DataRecv, VERR_TOO_MUCH_DATA);636 rc = Msg.cbData.GetUInt32(pcbRead); AssertRC(rc); 637 AssertReturn(cbData >= *pcbRead, VERR_TOO_MUCH_DATA); 566 638 /** @todo Add checksum support. */ 567 639 } … … 570 642 } 571 643 644 /** 645 * Writes a file data chunk to the host. 646 * 647 * @returns VBox status code. 648 * @param idClient The client id returned by VbglR3ClipboardConnect(). 649 * @param pvData Data chunk to write. 650 * @param cbData Size (in bytes) of data chunk to write. 651 * @param pcbWritten Returns how many bytes written. 652 */ 653 VBGLR3DECL(int) VbglR3ClipboardWriteFileData(HGCMCLIENTID idClient, void *pvData, uint32_t cbData, uint32_t *pcbWritten) 654 { 655 AssertPtrReturn(pvData, VERR_INVALID_POINTER); 656 AssertReturn(cbData, VERR_INVALID_PARAMETER); 657 AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER); 658 659 VBoxClipboardWriteFileDataMsg MsgData; 660 RT_ZERO(MsgData); 661 662 VBGL_HGCM_HDR_INIT(&MsgData.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA, VBOX_SHARED_CLIPBOARD_CPARMS_READ_FILE_DATA); 663 MsgData.uContext.SetUInt32(0); /* Context ID; unused at the moment. */ 664 MsgData.pvData.SetPtr(pvData, cbData); 665 MsgData.cbData.SetUInt32(cbData); 666 MsgData.pvChecksum.SetPtr(NULL, 0); 667 MsgData.cbChecksum.SetUInt32(0); 668 669 int rc = VbglR3HGCMCall(&MsgData.hdr, sizeof(MsgData)); 670 if (RT_SUCCESS(rc)) 671 { 672 *pcbWritten = cbData; 673 } 674 675 return rc; 676 } 677 678 #if 0 572 679 /** 573 680 * Helper function for receiving URI data from the host. Do not call directly. … … 828 935 return 0; 829 936 } 937 #endif 830 938 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 831 939 … … 883 991 VBGLR3DECL(int) VbglR3ClipboardWriteData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb) 884 992 { 885 int rc; 886 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 887 if (fFormat == VBOX_SHARED_CLIPBOARD_FMT_URI_LIST) 888 { 889 rc = vbglR3ClipboardWriteURIData(idClient, pv, cb); 890 } 891 else 892 #else 893 RT_NOREF(fFormat); 894 #endif 895 rc = vbglR3ClipboardWriteDataRaw(idClient, fFormat, pv, cb); 896 993 int rc = vbglR3ClipboardWriteDataRaw(idClient, fFormat, pv, cb); 897 994 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 898 995 if (RT_FAILURE(rc)) … … 903 1000 } 904 1001 #endif 905 906 return rc;907 }908 909 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST910 /**911 * Utility function to write clipboard data from guest to the host.912 *913 * @returns IPRT status code.914 * @param idClient The client id returned by VbglR3ClipboardConnect().915 * @param pvData Data block to send.916 * @param cbData Size (in bytes) of data block to send.917 * @param pDataHdr Data header to use -- needed for accounting.918 */919 static int vbglR3ClipboardWriteDataInternal(HGCMCLIENTID idClient,920 void *pvData, uint64_t cbData, PVBOXCLIPBOARDDATAHDR pDataHdr)921 {922 AssertPtrReturn(pvData, VERR_INVALID_POINTER);923 AssertReturn(cbData, VERR_INVALID_PARAMETER);924 AssertPtrReturn(pDataHdr, VERR_INVALID_POINTER);925 926 VBoxClipboardWriteDataHdrMsg MsgHdr;927 RT_ZERO(MsgHdr);928 929 VBGL_HGCM_HDR_INIT(&MsgHdr.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_HDR, 12);930 MsgHdr.uContext.SetUInt32(0); /** @todo Not used yet. */931 MsgHdr.uFlags.SetUInt32(0); /** @todo Not used yet. */932 MsgHdr.uScreenId.SetUInt32(0); /** @todo Not used for guest->host (yet). */933 MsgHdr.cbTotal.SetUInt64(pDataHdr->cbTotal);934 MsgHdr.cbMeta.SetUInt32(pDataHdr->cbMeta);935 MsgHdr.pvMetaFmt.SetPtr(pDataHdr->pvMetaFmt, pDataHdr->cbMetaFmt);936 MsgHdr.cbMetaFmt.SetUInt32(pDataHdr->cbMetaFmt);937 MsgHdr.cObjects.SetUInt64(pDataHdr->cObjects);938 MsgHdr.enmCompression.SetUInt32(0); /** @todo Not used yet. */939 MsgHdr.enmChecksumType.SetUInt32(RTDIGESTTYPE_INVALID); /** @todo Not used yet. */940 MsgHdr.pvChecksum.SetPtr(NULL, 0); /** @todo Not used yet. */941 MsgHdr.cbChecksum.SetUInt32(0); /** @todo Not used yet. */942 943 int rc = VbglR3HGCMCall(&MsgHdr.hdr, sizeof(MsgHdr));944 945 LogFlowFunc(("cbTotal=%RU64, cbMeta=%RU32, cObjects=%RU64, rc=%Rrc\n",946 pDataHdr->cbTotal, pDataHdr->cbMeta, pDataHdr->cObjects, rc));947 948 if (RT_SUCCESS(rc))949 {950 VBoxClipboardWriteDataChunkMsg MsgData;951 RT_ZERO(MsgData);952 953 VBGL_HGCM_HDR_INIT(&MsgData.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA_CHUNK, 5);954 MsgData.uContext.SetUInt32(0); /** @todo Not used yet. */955 MsgData.pvChecksum.SetPtr(NULL, 0); /** @todo Not used yet. */956 MsgData.cbChecksum.SetUInt32(0); /** @todo Not used yet. */957 958 uint32_t cbCurChunk;959 const uint32_t cbMaxChunk = VBOX_SHARED_CLIPBOARD_MAX_CHUNK_SIZE;960 uint32_t cbSent = 0;961 962 HGCMFunctionParameter *pParm = &MsgData.pvData;963 964 while (cbSent < cbData)965 {966 cbCurChunk = RT_MIN(cbData - cbSent, cbMaxChunk);967 pParm->SetPtr(static_cast<uint8_t *>(pvData) + cbSent, cbCurChunk);968 969 MsgData.cbData.SetUInt32(cbCurChunk);970 971 rc = VbglR3HGCMCall(&MsgData.hdr, sizeof(MsgData));972 if (RT_FAILURE(rc))973 break;974 975 cbSent += cbCurChunk;976 }977 978 LogFlowFunc(("cbMaxChunk=%RU32, cbData=%RU64, cbSent=%RU32, rc=%Rrc\n",979 cbMaxChunk, cbData, cbSent, rc));980 981 if (RT_SUCCESS(rc))982 Assert(cbSent == cbData);983 }984 985 LogFlowFuncLeaveRC(rc);986 return rc;987 }988 989 /**990 * Utility function to write a guest directory to the host.991 *992 * @returns IPRT status code.993 * @param idClient The client id returned by VbglR3ClipboardConnect().994 * @param pObj URI object containing the directory to send.995 */996 static int vbglR3ClipboardWriteDir(HGCMCLIENTID idClient, SharedClipboardURIObject *pObj)997 {998 AssertPtrReturn(pObj, VERR_INVALID_POINTER);999 AssertReturn(pObj->GetType() == SharedClipboardURIObject::Type_Directory, VERR_INVALID_PARAMETER);1000 1001 RTCString strPath = pObj->GetDestPathAbs();1002 LogFlowFunc(("strDir=%s (%zu), fMode=0x%x\n",1003 strPath.c_str(), strPath.length(), pObj->GetMode()));1004 1005 if (strPath.length() > RTPATH_MAX)1006 return VERR_INVALID_PARAMETER;1007 1008 const uint32_t cbPath = (uint32_t)strPath.length() + 1; /* Include termination. */1009 1010 VBoxClipboardWriteDirMsg Msg;1011 RT_ZERO(Msg);1012 1013 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_DIR, 4);1014 /** @todo Context ID not used yet. */1015 Msg.pvName.SetPtr((void *)strPath.c_str(), (uint32_t)cbPath);1016 Msg.cbName.SetUInt32((uint32_t)cbPath);1017 Msg.fMode.SetUInt32(pObj->GetMode());1018 1019 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));1020 }1021 1022 /**1023 * Utility function to write a file from the guest to the host.1024 *1025 * @returns IPRT status code.1026 * @param idClient The client id returned by VbglR3ClipboardConnect().1027 * @param pObj URI object containing the file to send.1028 */1029 static int vbglR3ClipboardWriteFile(HGCMCLIENTID idClient, SharedClipboardURIObject *pObj)1030 {1031 AssertPtrReturn(pObj, VERR_INVALID_POINTER);1032 AssertReturn(pObj->GetType() == SharedClipboardURIObject::Type_File, VERR_INVALID_PARAMETER);1033 AssertReturn(pObj->IsOpen(), VERR_INVALID_STATE);1034 1035 uint32_t cbBuf = _64K; /** @todo Make this configurable? */1036 void *pvBuf = RTMemAlloc(cbBuf);1037 if (!pvBuf)1038 return VERR_NO_MEMORY;1039 1040 RTCString strPath = pObj->GetDestPathAbs();1041 1042 LogFlowFunc(("strFile=%s (%zu), cbSize=%RU64, fMode=0x%x\n", strPath.c_str(), strPath.length(),1043 pObj->GetSize(), pObj->GetMode()));1044 1045 VBoxClipboardWriteFileHdrMsg MsgHdr;1046 RT_ZERO(MsgHdr);1047 1048 VBGL_HGCM_HDR_INIT(&MsgHdr.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_HDR, 6);1049 MsgHdr.uContext.SetUInt32(0); /* Context ID; unused at the moment. */1050 MsgHdr.pvName.SetPtr((void *)strPath.c_str(), (uint32_t)(strPath.length() + 1));1051 MsgHdr.cbName.SetUInt32((uint32_t)(strPath.length() + 1));1052 MsgHdr.uFlags.SetUInt32(0); /* Flags; unused at the moment. */1053 MsgHdr.fMode.SetUInt32(pObj->GetMode()); /* File mode */1054 MsgHdr.cbTotal.SetUInt64(pObj->GetSize()); /* File size (in bytes). */1055 1056 int rc = VbglR3HGCMCall(&MsgHdr.hdr, sizeof(MsgHdr));1057 1058 LogFlowFunc(("Sending file header resulted in %Rrc\n", rc));1059 1060 if (RT_SUCCESS(rc))1061 {1062 /*1063 * Send the actual file data, chunk by chunk.1064 */1065 VBoxClipboardWriteFileDataMsg Msg;1066 RT_ZERO(Msg);1067 1068 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_FILE_DATA, 5);1069 Msg.uContext.SetUInt32(0);1070 Msg.pvChecksum.SetPtr(NULL, 0);1071 Msg.cbChecksum.SetUInt32(0);1072 1073 uint64_t cbToReadTotal = pObj->GetSize();1074 uint64_t cbWrittenTotal = 0;1075 while (cbToReadTotal)1076 {1077 uint32_t cbToRead = RT_MIN(cbToReadTotal, cbBuf);1078 uint32_t cbRead = 0;1079 if (cbToRead)1080 rc = pObj->Read(pvBuf, cbToRead, &cbRead);1081 1082 LogFlowFunc(("cbToReadTotal=%RU64, cbToRead=%RU32, cbRead=%RU32, rc=%Rrc\n",1083 cbToReadTotal, cbToRead, cbRead, rc));1084 1085 if ( RT_SUCCESS(rc)1086 && cbRead)1087 {1088 Msg.pvData.SetPtr(pvBuf, cbRead);1089 Msg.cbData.SetUInt32(cbRead);1090 /** @todo Calculate + set checksums. */1091 1092 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));1093 }1094 1095 if (RT_FAILURE(rc))1096 {1097 LogFlowFunc(("Reading failed with rc=%Rrc\n", rc));1098 break;1099 }1100 1101 Assert(cbRead <= cbToReadTotal);1102 cbToReadTotal -= cbRead;1103 cbWrittenTotal += cbRead;1104 1105 LogFlowFunc(("%RU64/%RU64 -- %RU8%%\n", cbWrittenTotal, pObj->GetSize(), cbWrittenTotal * 100 / pObj->GetSize()));1106 };1107 }1108 1109 RTMemFree(pvBuf);1110 1111 LogFlowFuncLeaveRC(rc);1112 return rc;1113 }1114 1115 /**1116 * Utility function to write an URI object from guest to the host.1117 *1118 * @returns IPRT status code.1119 * @param idClient The client id returned by VbglR3ClipboardConnect().1120 * @param pObj URI object to send from guest to the host.1121 */1122 static int vbglR3ClipboardWriteURIObject(HGCMCLIENTID idClient, SharedClipboardURIObject *pObj)1123 {1124 AssertPtrReturn(pObj, VERR_INVALID_POINTER);1125 1126 int rc;1127 1128 switch (pObj->GetType())1129 {1130 case SharedClipboardURIObject::Type_Directory:1131 rc = vbglR3ClipboardWriteDir(idClient, pObj);1132 break;1133 1134 case SharedClipboardURIObject::Type_File:1135 rc = vbglR3ClipboardWriteFile(idClient, pObj);1136 break;1137 1138 default:1139 AssertMsgFailed(("Object type %ld not implemented\n", pObj->GetType()));1140 rc = VERR_NOT_IMPLEMENTED;1141 break;1142 }1143 1144 return rc;1145 }1146 1147 /**1148 * Utility function to write URI data from guest to the host.1149 *1150 * @returns IPRT status code.1151 * @param idClient The client id returned by VbglR3ClipboardConnect().1152 * @param pvData Block to URI data to send.1153 * @param cbData Size (in bytes) of URI data to send.1154 */1155 static int vbglR3ClipboardWriteURIData(HGCMCLIENTID idClient, const void *pvData, size_t cbData)1156 {1157 AssertPtrReturn(pvData, VERR_INVALID_POINTER);1158 AssertReturn(cbData, VERR_INVALID_PARAMETER);1159 1160 RTCList<RTCString> lstPaths =1161 RTCString((const char *)pvData, cbData).split("\r\n");1162 1163 /** @todo Add symlink support (SHAREDCLIPBOARDURILIST_FLAGS_RESOLVE_SYMLINKS) here. */1164 /** @todo Add lazy loading (SHAREDCLIPBOARDURILIST_FLAGS_LAZY) here. */1165 uint32_t fFlags = SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN;1166 1167 SharedClipboardURIList lstURI;1168 int rc = lstURI.AppendURIPathsFromList(lstPaths, fFlags);1169 if (RT_SUCCESS(rc))1170 {1171 /*1172 * Send the (meta) data; in case of URIs it's the (non-recursive) file/directory1173 * URI list the host needs to know upfront to set up the Shared Clipboard operation.1174 */1175 RTCString strRootDest = lstURI.GetRootEntries();1176 if (strRootDest.isNotEmpty())1177 {1178 void *pvURIList = (void *)strRootDest.c_str(); /* URI root list. */1179 uint32_t cbURLIist = (uint32_t)strRootDest.length() + 1; /* Include string termination. */1180 1181 /* The total size also contains the size of the meta data. */1182 uint64_t cbTotal = cbURLIist;1183 cbTotal += lstURI.GetTotalBytes();1184 1185 /* We're going to send an URI list in text format. */1186 const char szMetaFmt[] = "text/uri-list";1187 const uint32_t cbMetaFmt = (uint32_t)strlen(szMetaFmt) + 1; /* Include termination. */1188 1189 VBOXCLIPBOARDDATAHDR dataHdr;1190 dataHdr.uFlags = 0; /* Flags not used yet. */1191 dataHdr.cbTotal = cbTotal;1192 dataHdr.cbMeta = cbURLIist;1193 dataHdr.pvMetaFmt = (void *)szMetaFmt;1194 dataHdr.cbMetaFmt = cbMetaFmt;1195 dataHdr.cObjects = lstURI.GetTotalCount();1196 1197 rc = vbglR3ClipboardWriteDataInternal(idClient,1198 pvURIList, cbURLIist, &dataHdr);1199 }1200 else1201 rc = VERR_INVALID_PARAMETER;1202 }1203 1204 if (RT_SUCCESS(rc))1205 {1206 while (!lstURI.IsEmpty())1207 {1208 SharedClipboardURIObject *pNextObj = lstURI.First();1209 1210 rc = vbglR3ClipboardWriteURIObject(idClient, pNextObj);1211 if (RT_FAILURE(rc))1212 break;1213 1214 lstURI.RemoveFirst();1215 }1216 }1217 1002 1218 1003 return rc; -
trunk/src/VBox/Additions/x11/VBoxClient/Makefile.kmk
r78725 r78942 107 107 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardURIObject.cpp \ 108 108 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardPath.cpp \ 109 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardProvider.cpp 109 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardProvider.cpp \ 110 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-VbglR3.cpp 110 111 ifdef VBOX_WITH_LIBFUSE_DISABLED 111 112 VBoxClient_SOURCES += \ -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardArea.cpp
r78941 r78942 196 196 { 197 197 char szID[8]; 198 rc= RTStrFormatU32(szID, sizeof(szID), uID, 10, 0, 0, 0);199 if ( RT_SUCCESS(rc))198 ssize_t cchID = RTStrFormatU32(szID, sizeof(szID), uID, 10, 0, 0, 0); 199 if (cchID) 200 200 { 201 201 rc = RTStrCat(pszPath, cbPath, szID); 202 202 } 203 else 204 rc = VERR_INVALID_PARAMETER; 203 205 } 204 206 } … … 214 216 } 215 217 216 SHAREDCLIPBOARDAREAID SharedClipboardArea::Get AreaID(void) const218 SHAREDCLIPBOARDAREAID SharedClipboardArea::GetID(void) const 217 219 { 218 220 return this->m_uID; -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-HostService.cpp
r78897 r78942 55 55 } 56 56 57 int SharedClipboardProvider HostService::ReadData(void *pvBuf, size_t cbBuf, size_t *pcbRead /* = NULL */)57 int SharedClipboardProviderVbglR3::ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData) 58 58 { 59 RT_NOREF(pvBuf, cbBuf, pcbRead); 60 return VERR_NOT_IMPLEMENTED; 59 RT_NOREF(pDirData); 60 61 LogFlowFuncEnter(); 62 63 int rc = VERR_NOT_IMPLEMENTED; 64 65 LogFlowFuncLeaveRC(rc); 66 return rc; 61 67 } 62 68 63 int SharedClipboardProvider HostService::WriteData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten /* = NULL */)69 int SharedClipboardProviderVbglR3::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData) 64 70 { 65 RT_NOREF(pvBuf, cbBuf, pcbWritten); 66 return VERR_NOT_IMPLEMENTED; 71 RT_NOREF(pDirData); 72 73 LogFlowFuncEnter(); 74 75 int rc = VERR_NOT_IMPLEMENTED; 76 77 LogFlowFuncLeaveRC(rc); 78 return rc; 79 } 80 81 int SharedClipboardProviderVbglR3::ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr) 82 { 83 RT_NOREF(pFileHdr); 84 85 LogFlowFuncEnter(); 86 87 int rc = VERR_NOT_IMPLEMENTED; 88 89 LogFlowFuncLeaveRC(rc); 90 return rc; 91 } 92 93 int SharedClipboardProviderVbglR3::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr) 94 { 95 RT_NOREF(pFileHdr); 96 97 LogFlowFuncEnter(); 98 99 int rc = VERR_NOT_IMPLEMENTED; 100 101 LogFlowFuncLeaveRC(rc); 102 return rc; 103 } 104 105 int SharedClipboardProviderVbglR3::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData) 106 { 107 RT_NOREF(pFileData); 108 109 LogFlowFuncEnter(); 110 111 int rc = VERR_NOT_IMPLEMENTED; 112 113 LogFlowFuncLeaveRC(rc); 114 return rc; 115 } 116 117 int SharedClipboardProviderVbglR3::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData) 118 { 119 RT_NOREF(pFileData); 120 121 LogFlowFuncEnter(); 122 123 int rc = VERR_NOT_IMPLEMENTED; 124 125 LogFlowFuncLeaveRC(rc); 126 return rc; 67 127 } 68 128 -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-VbglR3.cpp
r78897 r78942 82 82 } 83 83 84 int SharedClipboardProviderVbglR3::ReadData(void *pvBuf, size_t cbBuf, size_t *pcbRead /* = NULL */) 85 { 86 LogFlowFuncEnter(); 87 88 SharedClipboardURIObject *pObj = m_URIList.First(); 89 if (!pObj) 90 { 91 if (pcbRead) 92 *pcbRead = 0; 93 return VINF_SUCCESS; 94 } 95 96 size_t cbToRead = RT_MIN(cbBuf, RT_MIN(123, _4K)); 97 98 memset(pvBuf, 0x64, cbToRead); 99 100 *pcbRead = cbToRead; 101 102 if (pObj->IsComplete()) 103 { 104 m_URIList.RemoveFirst(); 105 pObj = NULL; 106 } 107 108 return VINF_SUCCESS; 109 } 110 111 int SharedClipboardProviderVbglR3::WriteData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten /* = NULL */) 112 { 113 RT_NOREF(pvBuf, cbBuf, pcbWritten); 114 return VERR_NOT_IMPLEMENTED; 84 int SharedClipboardProviderVbglR3::ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData) 85 { 86 LogFlowFuncEnter(); 87 88 int rc; 89 90 SharedClipboardURIObject *pObj = m_URIList.First(); 91 if (pObj) 92 { 93 rc = VbglR3ClipboardReadDir(m_uClientID, pDirData->pszPath, pDirData->cbPath, &pDirData->cbPath, &pDirData->fMode); 94 } 95 else 96 rc = VERR_WRONG_ORDER; 97 98 LogFlowFuncLeaveRC(rc); 99 return rc; 100 } 101 102 int SharedClipboardProviderVbglR3::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData) 103 { 104 LogFlowFuncEnter(); 105 106 int rc; 107 108 SharedClipboardURIObject *pObj = m_URIList.First(); 109 if (pObj) 110 { 111 rc = VbglR3ClipboardWriteDir(m_uClientID, pDirData->pszPath, pDirData->cbPath, pDirData->fMode); 112 } 113 else 114 rc = VERR_WRONG_ORDER; 115 116 LogFlowFuncLeaveRC(rc); 117 return rc; 118 } 119 120 int SharedClipboardProviderVbglR3::ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr) 121 { 122 LogFlowFuncEnter(); 123 124 int rc; 125 126 SharedClipboardURIObject *pObj = m_URIList.First(); 127 if (pObj) 128 { 129 rc = VbglR3ClipboardReadFileHdr(m_uClientID, pFileHdr->pszFilePath, pFileHdr->cbFilePath, 130 &pFileHdr->fFlags, &pFileHdr->fMode, &pFileHdr->cbSize); 131 if (RT_SUCCESS(rc)) 132 { 133 rc = pObj->SetFileData(pFileHdr->pszFilePath, SharedClipboardURIObject::View_Target, 134 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE, pFileHdr->fMode); 135 if (RT_SUCCESS(rc)) 136 rc = pObj->SetSize(pFileHdr->cbSize); 137 } 138 } 139 else 140 rc = VERR_WRONG_ORDER; 141 142 LogFlowFuncLeaveRC(rc); 143 return rc; 144 } 145 146 int SharedClipboardProviderVbglR3::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr) 147 { 148 LogFlowFuncEnter(); 149 150 int rc; 151 152 SharedClipboardURIObject *pObj = m_URIList.First(); 153 if (pObj) 154 { 155 rc = VbglR3ClipboardWriteFileHdr(m_uClientID, pFileHdr->pszFilePath, pFileHdr->cbFilePath, 156 pFileHdr->fFlags, pFileHdr->fMode, pFileHdr->cbSize); 157 } 158 else 159 rc = VERR_WRONG_ORDER; 160 161 LogFlowFuncLeaveRC(rc); 162 return rc; 163 } 164 165 int SharedClipboardProviderVbglR3::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData) 166 { 167 LogFlowFuncEnter(); 168 169 int rc; 170 171 SharedClipboardURIObject *pObj = m_URIList.First(); 172 if (pObj) 173 { 174 rc = VbglR3ClipboardReadFileData(m_uClientID, pFileData->pvData, pFileData->cbData, &pFileData->cbData); 175 } 176 else 177 rc = VERR_WRONG_ORDER; 178 179 LogFlowFuncLeaveRC(rc); 180 return rc; 181 } 182 183 int SharedClipboardProviderVbglR3::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData) 184 { 185 LogFlowFuncEnter(); 186 187 int rc; 188 189 SharedClipboardURIObject *pObj = m_URIList.First(); 190 if (pObj) 191 { 192 uint32_t cbWrittenIgnored; 193 rc = VbglR3ClipboardWriteFileData(m_uClientID, pFileData->pvData, pFileData->cbData, &cbWrittenIgnored); 194 } 195 else 196 rc = VERR_WRONG_ORDER; 197 198 LogFlowFuncLeaveRC(rc); 199 return rc; 115 200 } 116 201 117 202 void SharedClipboardProviderVbglR3::Reset(void) 118 203 { 119 } 120 204 LogFlowFuncEnter(); 205 206 m_URIList.Clear(); 207 208 /* Don't clear the refcount here. */ 209 } 210 -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardURIList.cpp
r78809 r78942 57 57 if (RT_SUCCESS(rc)) 58 58 { 59 try 60 { 61 if (RTFS_IS_FILE(objInfo.Attr.fMode)) 62 { 63 LogFlowFunc(("File '%s' -> '%s' (%RU64 bytes, file mode 0x%x)\n", 64 pcszSource, pcszTarget, (uint64_t)objInfo.cbObject, objInfo.Attr.fMode)); 65 66 SharedClipboardURIObject *pObjFile = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File, 67 pcszSource, pcszTarget); 68 if (pObjFile) 59 if (RTFS_IS_FILE(objInfo.Attr.fMode)) 60 { 61 LogFlowFunc(("File '%s' -> '%s' (%RU64 bytes, file mode 0x%x)\n", 62 pcszSource, pcszTarget, (uint64_t)objInfo.cbObject, objInfo.Attr.fMode)); 63 64 SharedClipboardURIObject *pObjFile = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File, 65 pcszSource, pcszTarget); 66 if (pObjFile) 67 { 68 /** @todo Add a standard fOpen mode for this list. */ 69 rc = pObjFile->OpenFile(SharedClipboardURIObject::View_Source, 70 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 71 if (RT_SUCCESS(rc)) 69 72 { 70 /** @todo Add a standard fOpen mode for this list. */ 71 rc = pObjFile->Open(SharedClipboardURIObject::View_Source, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 72 if (RT_SUCCESS(rc)) 73 { 74 rc = appendObject(pObjFile); 75 if (!(fFlags & SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN)) /* Shall we keep the file open while being added to this list? */ 76 pObjFile->Close(); 77 } 78 else 79 delete pObjFile; 73 rc = appendObject(pObjFile); 74 if (!(fFlags & SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN)) /* Shall we keep the file open while being added to this list? */ 75 pObjFile->Close(); 80 76 } 81 77 else 82 rc = VERR_NO_MEMORY; 83 } 84 else if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode)) 85 { 86 LogFlowFunc(("Directory '%s' -> '%s' (file mode 0x%x)\n", pcszSource, pcszTarget, objInfo.Attr.fMode)); 87 88 SharedClipboardURIObject *pObjDir = new SharedClipboardURIObject(SharedClipboardURIObject::Type_Directory, 89 pcszSource, pcszTarget); 90 if (pObjDir) 91 { 92 m_lstTree.append(pObjDir); 93 94 /** @todo Add SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN handling? */ 95 m_cTotal++; 96 } 97 else 98 rc = VERR_NO_MEMORY; 99 } 100 /* Note: Symlinks already should have been resolved at this point. */ 78 delete pObjFile; 79 } 101 80 else 102 rc = VERR_NOT_SUPPORTED; 103 } 104 catch (std::bad_alloc &) 105 { 106 rc = VERR_NO_MEMORY; 107 } 81 rc = VERR_NO_MEMORY; 82 } 83 else if (RTFS_IS_DIRECTORY(objInfo.Attr.fMode)) 84 { 85 LogFlowFunc(("Directory '%s' -> '%s' (file mode 0x%x)\n", pcszSource, pcszTarget, objInfo.Attr.fMode)); 86 87 SharedClipboardURIObject *pObjDir = new SharedClipboardURIObject(SharedClipboardURIObject::Type_Directory, 88 pcszSource, pcszTarget); 89 if (pObjDir) 90 { 91 m_lstTree.append(pObjDir); 92 93 /** @todo Add SHAREDCLIPBOARDURILIST_FLAGS_KEEP_OPEN handling? */ 94 m_cTotal++; 95 } 96 else 97 rc = VERR_NO_MEMORY; 98 } 99 /* Note: Symlinks already should have been resolved at this point. */ 100 else 101 rc = VERR_NOT_SUPPORTED; 108 102 } 109 103 … … 282 276 int SharedClipboardURIList::appendObject(SharedClipboardURIObject *pObject) 283 277 { 284 int rc; 285 286 try 287 { 288 m_lstTree.append(pObject); 289 m_lstRoot.append(pObject->GetSourcePathAbs());; 290 291 m_cTotal++; 292 m_cbTotal += pObject->GetSize(); 293 294 rc = VINF_SUCCESS; 295 } 296 catch (std::bad_alloc &) 297 { 298 rc = VERR_NO_MEMORY; 299 } 278 int rc = VINF_SUCCESS; 279 280 m_lstTree.append(pObject); 281 m_lstRoot.append(pObject->GetSourcePathAbs());; 282 283 m_cTotal++; 284 m_cbTotal += pObject->GetSize(); 300 285 301 286 LogFlowFuncLeaveRC(rc); … … 420 405 char *pszDstPath = &pszSrcPath[cchDstBase]; 421 406 422 try 423 { 424 m_lstRoot.append(pszDstPath); 425 426 LogFlowFunc(("pszSrcPath=%s, pszFileName=%s, pszRoot=%s\n", pszSrcPath, pszFileName, pszDstPath)); 427 rc = appendPathRecursive(pszSrcPath, pszSrcPath, pszSrcPath, cchDstBase, fFlags); 428 } 429 catch (std::bad_alloc &) 430 { 431 rc = VERR_NO_MEMORY; 432 } 407 m_lstRoot.append(pszDstPath); 408 409 LogFlowFunc(("pszSrcPath=%s, pszFileName=%s, pszRoot=%s\n", pszSrcPath, pszFileName, pszDstPath)); 410 rc = appendPathRecursive(pszSrcPath, pszSrcPath, pszSrcPath, cchDstBase, fFlags); 433 411 } 434 412 else … … 543 521 if (RT_SUCCESS(rc)) 544 522 { 545 try 546 { 547 m_lstRoot.append(pszFilePath); 548 m_cTotal++; 549 } 550 catch (std::bad_alloc &) 551 { 552 rc = VERR_NO_MEMORY; 553 } 523 m_lstRoot.append(pszFilePath); 524 m_cTotal++; 554 525 } 555 526 -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardURIObject.cpp
r78809 r78942 36 36 : m_enmType(Type_Unknown) 37 37 , m_enmView(View_Unknown) 38 , m_fFlags(SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE) 39 , m_fModeRequested(0) 38 40 { 39 41 RT_ZERO(u); … … 47 49 , m_strSrcPathAbs(strSrcPathAbs) 48 50 , m_strTgtPathAbs(strDstPathAbs) 51 , m_fFlags(SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE) 52 , m_fModeRequested(0) 49 53 { 50 54 RT_ZERO(u); … … 218 222 219 223 /** 220 * (Re-)Opens the object with a specific view, open and file mode. 224 * (Re-)Opens the object as a directory with a specific view, open and file mode. 225 * 226 * @return IPRT status code. 227 * @param enmView View to use for opening the object. 228 * @param fCreate Directory creation flags to use. 229 * @param fMode File mode to use. 230 */ 231 int SharedClipboardURIObject::OpenDirectory(View enmView, uint32_t fCreate /* = 0 */, RTFMODE fMode /* = 0 */) 232 { 233 return OpenDirectoryEx( enmView == View_Source 234 ? m_strSrcPathAbs : m_strTgtPathAbs 235 , enmView, fCreate, fMode, SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 236 } 237 238 /** 239 * Open the object as a file with a specific file type, and, depending on the type, specifying additional parameters. 240 * 241 * @return IPRT status code. 242 * @param strPathAbs Absolute path of the directory. 243 * @param enmView View of the object. 244 * @param fCreate Directory creation flags to use. 245 * @param fMode File mode to use; only valid for file objects. 246 * @param fFlags Additional Shared Clipboard URI object flags. 247 */ 248 int SharedClipboardURIObject::OpenDirectoryEx(const RTCString &strPathAbs, View enmView, 249 uint32_t fCreate /* = 0 */, RTFMODE fMode /* = 0 */, 250 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 251 { 252 AssertReturn(!(fFlags & ~SHAREDCLIPBOARDURIOBJECT_FLAGS_VALID_MASK), VERR_INVALID_FLAGS); 253 254 AssertMsgReturn(m_enmType == Type_Directory, ("Object is not a directory\n"), VERR_INVALID_STATE); 255 256 LogFlowThisFunc(("strPath=%s, enmView=%RU32, fCreate=0x%x, fMode=0x%x, fFlags=0x%x\n", 257 strPathAbs.c_str(), enmView, fCreate, fMode, fFlags)); 258 259 int rc = setDirectoryDataInternal(strPathAbs, enmView, fCreate, fMode, fFlags); 260 if (RT_SUCCESS(rc)) 261 { 262 rc = RTDirOpen(&u.Dir.hDir, strPathAbs.c_str()); 263 if (RT_SUCCESS(rc)) 264 rc = queryInfoInternal(enmView); 265 } 266 267 LogFlowFuncLeaveRC(rc); 268 return rc; 269 } 270 271 /** 272 * (Re-)Opens the object as a file with a specific view, open and file mode. 221 273 * 222 274 * @return IPRT status code. … … 225 277 * @param fMode File mode to use. 226 278 */ 227 int SharedClipboardURIObject::Open (View enmView, uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */)228 { 229 return Open Ex( enmView == View_Source230 ? m_strSrcPathAbs : m_strTgtPathAbs231 , enmView, fOpen, fMode, SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE);232 } 233 234 /** 235 * Open the objectwith a specific file type, and, depending on the type, specifying additional parameters.236 * 237 * @return IPRT status code. 238 * @param strPathAbs Absolute path of the object (file / directory / ...).279 int SharedClipboardURIObject::OpenFile(View enmView, uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */) 280 { 281 return OpenFileEx( enmView == View_Source 282 ? m_strSrcPathAbs : m_strTgtPathAbs 283 , enmView, fOpen, fMode, SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE); 284 } 285 286 /** 287 * Opens the object as a file with a specific file type, and, depending on the type, specifying additional parameters. 288 * 289 * @return IPRT status code. 290 * @param strPathAbs Absolute path of the file. 239 291 * @param enmView View of the object. 240 292 * @param fOpen Open mode to use; only valid for file objects. … … 242 294 * @param fFlags Additional Shared Clipboard URI object flags. 243 295 */ 244 int SharedClipboardURIObject::OpenEx(const RTCString &strPathAbs, View enmView, 245 uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */, SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 296 int SharedClipboardURIObject::OpenFileEx(const RTCString &strPathAbs, View enmView, 297 uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */, 298 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 246 299 { 247 300 AssertReturn(!(fFlags & ~SHAREDCLIPBOARDURIOBJECT_FLAGS_VALID_MASK), VERR_INVALID_FLAGS); 248 RT_NOREF1(fFlags); 249 250 int rc = VINF_SUCCESS; 251 252 switch (enmView) 253 { 254 case View_Source: 255 m_strSrcPathAbs = strPathAbs; 256 break; 257 258 case View_Target: 259 m_strTgtPathAbs = strPathAbs; 260 break; 261 262 default: 263 rc = VERR_NOT_IMPLEMENTED; 264 break; 265 } 266 267 if ( RT_SUCCESS(rc) 268 && fOpen) /* Opening mode specified? */ 269 { 270 LogFlowThisFunc(("strPath=%s, enmView=%RU32, fOpen=0x%x, fMode=0x%x, fFlags=0x%x\n", 271 strPathAbs.c_str(), enmView, fOpen, fMode, fFlags)); 272 switch (m_enmType) 273 { 274 case Type_File: 301 302 AssertMsgReturn(m_enmType == Type_File, ("Object is not a file\n"), VERR_INVALID_STATE); 303 304 LogFlowThisFunc(("strPath=%s, enmView=%RU32, fOpen=0x%x, fMode=0x%x, fFlags=0x%x\n", 305 strPathAbs.c_str(), enmView, fOpen, fMode, fFlags)); 306 307 int rc = setFileDataInternal(strPathAbs, enmView, fOpen, fMode, fFlags); 308 if (RT_SUCCESS(rc)) 309 { 310 if (fOpen) /* Opening mode specified? */ 311 { 312 /* 313 * Open files on the source with RTFILE_O_DENY_WRITE to prevent races 314 * where the OS writes to the file while the destination side transfers 315 * it over. 316 */ 317 LogFlowThisFunc(("Opening ...\n")); 318 rc = RTFileOpen(&u.File.hFile, strPathAbs.c_str(), fOpen); 319 if (RT_SUCCESS(rc)) 275 320 { 276 /* 277 * Open files on the source with RTFILE_O_DENY_WRITE to prevent races 278 * where the OS writes to the file while the destination side transfers 279 * it over. 280 */ 281 LogFlowThisFunc(("Opening ...\n")); 282 rc = RTFileOpen(&u.File.hFile, strPathAbs.c_str(), fOpen); 283 if (RT_SUCCESS(rc)) 321 if ( (fOpen & RTFILE_O_WRITE) /* Only set the file mode on write. */ 322 && fMode /* Some file mode to set specified? */) 284 323 { 285 if ( (fOpen & RTFILE_O_WRITE) /* Only set the file mode on write. */ 286 && fMode /* Some file mode to set specified? */) 287 { 288 rc = RTFileSetMode(u.File.hFile, fMode); 289 } 290 else if (fOpen & RTFILE_O_READ) 291 { 292 rc = queryInfoInternal(enmView); 293 } 324 rc = RTFileSetMode(u.File.hFile, fMode); 294 325 } 295 296 if (RT_SUCCESS(rc)) 326 else if (fOpen & RTFILE_O_READ) 297 327 { 298 LogFlowThisFunc(("File cbObject=%RU64, fMode=0x%x\n", 299 u.File.objInfo.cbObject, u.File.objInfo.Attr.fMode)); 300 u.File.cbToProcess = u.File.objInfo.cbObject; 301 u.File.cbProcessed = 0; 328 rc = queryInfoInternal(enmView); 302 329 } 303 304 break;305 330 } 306 307 case Type_Directory: 308 { 309 rc = RTDirOpen(&u.Dir.hDir, strPathAbs.c_str()); 310 if (RT_SUCCESS(rc)) 311 rc = queryInfoInternal(enmView); 312 break; 313 } 314 315 default: 316 rc = VERR_NOT_IMPLEMENTED; 317 break; 318 } 319 } 320 321 if (RT_SUCCESS(rc)) 322 { 323 m_enmView = enmView; 331 } 332 333 if (RT_SUCCESS(rc)) 334 { 335 LogFlowThisFunc(("File cbObject=%RU64, fMode=0x%x\n", 336 u.File.objInfo.cbObject, u.File.objInfo.Attr.fMode)); 337 u.File.cbToProcess = u.File.objInfo.cbObject; 338 u.File.cbProcessed = 0; 339 } 324 340 } 325 341 … … 384 400 /* static */ 385 401 int SharedClipboardURIObject::RebaseURIPath(RTCString &strPathAbs, 386 const RTCString &strBaseOld /* = "" */,387 const RTCString &strBaseNew /* = "" */)402 const RTCString &strBaseOld /* = "" */, 403 const RTCString &strBaseNew /* = "" */) 388 404 { 389 405 char *pszPath = RTUriFilePath(strPathAbs.c_str()); … … 451 467 /* pcbRead is optional. */ 452 468 453 AssertMsgReturn(m_enmView == View_Source, ("Cannot write to an object which is not in targetview\n"),469 AssertMsgReturn(m_enmView == View_Source, ("Cannot read from an object which is not in source view\n"), 454 470 VERR_INVALID_STATE); 455 471 … … 507 523 Close(); 508 524 509 m_enmType = Type_Unknown; 510 m_enmView = View_Unknown; 511 m_strSrcPathAbs = ""; 512 m_strTgtPathAbs = ""; 525 m_enmType = Type_Unknown; 526 m_enmView = View_Unknown; 527 m_fModeRequested = 0; 528 m_fFlags = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE; 529 m_strSrcPathAbs = ""; 530 m_strTgtPathAbs = ""; 513 531 514 532 RT_ZERO(u); 533 } 534 535 int SharedClipboardURIObject::setDirectoryDataInternal(const RTCString &strPathAbs, View enmView, uint32_t fCreate /* = 0 */, RTFMODE fMode /* = 0 */, 536 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 537 { 538 int rc = VINF_SUCCESS; 539 540 switch (enmView) 541 { 542 case View_Source: 543 m_strSrcPathAbs = strPathAbs; 544 break; 545 546 case View_Target: 547 m_strTgtPathAbs = strPathAbs; 548 break; 549 550 default: 551 rc = VERR_NOT_IMPLEMENTED; 552 break; 553 } 554 555 if (RT_FAILURE(rc)) 556 return rc; 557 558 m_fFlags = fFlags; 559 m_fModeRequested = fMode; 560 561 u.Dir.fCreateRequested = fCreate; 562 563 return rc; 564 } 565 566 int SharedClipboardURIObject::SetDirectoryData(const RTCString &strPathAbs, View enmView, uint32_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */, 567 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 568 { 569 return setDirectoryDataInternal(strPathAbs, enmView, fOpen, fMode, fFlags); 570 } 571 572 int SharedClipboardURIObject::setFileDataInternal(const RTCString &strPathAbs, View enmView, uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */, 573 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 574 { 575 int rc = VINF_SUCCESS; 576 577 switch (enmView) 578 { 579 case View_Source: 580 m_strSrcPathAbs = strPathAbs; 581 break; 582 583 case View_Target: 584 m_strTgtPathAbs = strPathAbs; 585 break; 586 587 default: 588 rc = VERR_NOT_IMPLEMENTED; 589 break; 590 } 591 592 if (RT_FAILURE(rc)) 593 return rc; 594 595 m_fFlags = fFlags; 596 m_fModeRequested = fMode; 597 598 u.File.fOpenRequested = fOpen; 599 600 return rc; 601 } 602 603 int SharedClipboardURIObject::SetFileData(const RTCString &strPathAbs, View enmView, uint64_t fOpen /* = 0 */, RTFMODE fMode /* = 0 */, 604 SHAREDCLIPBOARDURIOBJECTFLAGS fFlags /* = SHAREDCLIPBOARDURIOBJECT_FLAGS_NONE */) 605 { 606 return setFileDataInternal(strPathAbs, enmView, fOpen, fMode, fFlags); 515 607 } 516 608 -
trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk
r78897 r78942 48 48 VBoxSharedClipboardSvc-uri.cpp \ 49 49 VBoxSharedClipboardSvc-utils.cpp \ 50 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/Clipboard Cache.cpp \50 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardArea.cpp \ 51 51 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardMetaData.cpp \ 52 52 $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardPath.cpp \ -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
r78623 r78942 271 271 VBoxSvcClipboardUnlock(); 272 272 } 273 274 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 275 int VBoxClipboardSvcImplURIReadDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 276 { 277 RT_NOREF(pClientData, pDirData); 278 return VERR_NOT_IMPLEMENTED; 279 } 280 281 int VBoxClipboardSvcImplURIWriteDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 282 { 283 RT_NOREF(pClientData, pDirData); 284 return VERR_NOT_IMPLEMENTED; 285 } 286 287 int VBoxClipboardSvcImplURIReadFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 288 { 289 RT_NOREF(pClientData, pFileHdr); 290 return VERR_NOT_IMPLEMENTED; 291 } 292 293 int VBoxClipboardSvcImplURIWriteFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 294 { 295 RT_NOREF(pClientData, pFileHdr); 296 return VERR_NOT_IMPLEMENTED; 297 } 298 299 int VBoxClipboardSvcImplURIReadFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 300 { 301 RT_NOREF(pClientData, pFileData); 302 return VERR_NOT_IMPLEMENTED; 303 } 304 305 int VBoxClipboardSvcImplURIWriteFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 306 { 307 RT_NOREF(pClientData, pFileData); 308 return VERR_NOT_IMPLEMENTED; 309 } 310 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 311 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r78897 r78942 55 55 VBOXCLIPBOARDCLIENTSTATE *pState; 56 56 /** The transfer's own (local) area. 57 * The cache itself has a clipboard area ID assigned. */ 58 SharedClipboardArea Cache; 57 * The area itself has a clipboard ID assigned, which gets shared (maintained) across all 58 * VMs via VBoxSVC. */ 59 SharedClipboardArea Area; 59 60 /** The transfer's URI list, containing the fs object root entries. */ 60 61 SharedClipboardURIList List; … … 133 134 134 135 /* 135 * The service functions. Locking is between the service thread and the platform dependent windowsthread.136 * The service functions. Locking is between the service thread and the platform-dependent (window) thread. 136 137 */ 137 138 uint32_t vboxSvcClipboardGetMode(void); … … 141 142 int vboxSvcClipboardClientStateInit(PVBOXCLIPBOARDCLIENTSTATE pState, uint32_t uClientID); 142 143 void vboxSvcClipboardClientStateReset(PVBOXCLIPBOARDCLIENTSTATE pState); 144 145 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 146 void vboxClipboardSvcURIDirDataDestroy(PVBOXCLIPBOARDDIRDATA pDirData); 147 void vboxClipboardSvcURIFileHdrDestroy(PVBOXCLIPBOARDFILEHDR pFileHdr); 148 void vboxClipboardSvcURIFileDataDestroy(PVBOXCLIPBOARDFILEDATA pFileData); 149 #endif 143 150 144 151 /* … … 155 162 int VBoxClipboardSvcImplSync(PVBOXCLIPBOARDCLIENTDATA pClientData); 156 163 164 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 165 int VBoxClipboardSvcImplURIReadDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData); 166 int VBoxClipboardSvcImplURIWriteDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData); 167 int VBoxClipboardSvcImplURIReadFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr); 168 int VBoxClipboardSvcImplURIWriteFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr); 169 int VBoxClipboardSvcImplURIReadFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData); 170 int VBoxClipboardSvcImplURIWriteFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData); 171 #endif 172 157 173 /* Host unit testing interface */ 158 174 #ifdef UNIT_TEST -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.cpp
r78897 r78942 114 114 AssertPtrReturn(pState, VERR_INVALID_POINTER); 115 115 116 int rc = pTransfer-> Cache.OpenTemp(SHAREDCLIPBOARDAREA_FLAGS_NONE);116 int rc = pTransfer->Area.OpenTemp(SHAREDCLIPBOARDAREA_FLAGS_NONE); 117 117 if (RT_SUCCESS(rc)) 118 118 { … … 162 162 163 163 /* Do we need to detach from a previously attached clipboard area? */ 164 const SHAREDCLIPBOARDAREAID uAreaID = pTransfer-> Cache.GetAreaID();164 const SHAREDCLIPBOARDAREAID uAreaID = pTransfer->Area.GetID(); 165 165 if ( g_pfnExtension 166 166 && uAreaID != NIL_SHAREDCLIPBOARDAREAID) … … 179 179 } 180 180 181 rc2 = pTransfer->Cache.Rollback(); 182 AssertRC(rc2); 183 184 rc2 = pTransfer->Cache.Close(); 185 AssertRC(rc2); 181 /* ignore rc */ pTransfer->Area.Rollback(); 182 /* ignore rc */ pTransfer->Area.Close(); 186 183 187 184 SharedClipboardMetaDataDestroy(&pTransfer->Meta); 185 } 186 187 /** 188 * Destroys a VBOXCLIPBOARDDIRDATA structure. 189 * 190 * @param pDirData VBOXCLIPBOARDDIRDATA structure to destroy. 191 */ 192 void vboxClipboardSvcURIDirDataDestroy(PVBOXCLIPBOARDDIRDATA pDirData) 193 { 194 if (!pDirData) 195 return; 196 197 if (pDirData->pszPath) 198 { 199 Assert(pDirData->cbPath); 200 RTStrFree(pDirData->pszPath); 201 pDirData->pszPath = NULL; 202 } 203 } 204 205 /** 206 * Destroys a VBOXCLIPBOARDFILEHDR structure. 207 * 208 * @param pFileHdr VBOXCLIPBOARDFILEHDR structure to destroy. 209 */ 210 void vboxClipboardSvcURIFileHdrDestroy(PVBOXCLIPBOARDFILEHDR pFileHdr) 211 { 212 if (!pFileHdr) 213 return; 214 215 if (pFileHdr->pszFilePath) 216 { 217 Assert(pFileHdr->pszFilePath); 218 RTStrFree(pFileHdr->pszFilePath); 219 pFileHdr->pszFilePath = NULL; 220 } 221 } 222 223 /** 224 * Destroys a VBOXCLIPBOARDFILEDATA structure. 225 * 226 * @param pFileData VBOXCLIPBOARDFILEDATA structure to destroy. 227 */ 228 void vboxClipboardSvcURIFileDataDestroy(PVBOXCLIPBOARDFILEDATA pFileData) 229 { 230 if (!pFileData) 231 return; 232 233 if (pFileData->pvData) 234 { 235 Assert(pFileData->cbData); 236 RTMemFree(pFileData->pvData); 237 pFileData->pvData = NULL; 238 } 188 239 } 189 240 … … 265 316 } 266 317 318 if (!g_pfnExtension) 319 { 320 #ifdef DEBUG_andy 321 AssertPtr(g_pfnExtension); 322 #endif 323 LogFunc(("Invalid / no service extension set, skipping URI handling\n")); 324 rc = VERR_ACCESS_DENIED; 325 } 326 267 327 if (RT_FAILURE(rc)) 268 328 return rc; … … 279 339 if (cParms == VBOX_SHARED_CLIPBOARD_CPARMS_READ_DATA_HDR) 280 340 { 281 if (g_pfnExtension) 282 { 283 VBOXCLIPBOARDEXTAREAPARMS parms; 341 VBOXCLIPBOARDEXTAREAPARMS parms; 342 RT_ZERO(parms); 343 344 parms.uID = 0; /* 0 means most recent clipboard area. */ 345 346 /* The client now needs to attach to the most recent clipboard area 347 * to keep a reference to it. The host does the actual book keeping / cleanup then. 348 * 349 * This might fail if the host does not have a most recent clipboard area (yet). */ 350 rc = g_pfnExtension(g_pvExtension, VBOX_CLIPBOARD_EXT_FN_AREA_ATTACH, &parms, sizeof(parms)); 351 #ifdef LOG_ENABLED 352 AssertPtr(pTransfer->pState); 353 LogFlowFunc(("Attached client %RU32 to clipboard area %RU32 with rc=%Rrc\n", 354 pTransfer->pState->u32ClientID, parms.uID, rc)); 355 #endif 356 bool fDetach = false; 357 358 if (RT_SUCCESS(rc)) 359 { 360 // pTransfer->Area. parms.uID 361 362 /** @todo Detach if header / meta size is 0. */ 363 } 364 365 /* Do we need to detach again because we're done? */ 366 if (fDetach) 367 { 284 368 RT_ZERO(parms); 285 286 parms.uID = 0; /* 0 means most recent clipboard area. */ 287 288 /* The client now needs to attach to the most recent clipboard area 289 * to keep a reference to it. The host does the actual book keeping / cleanup then. */ 290 rc = g_pfnExtension(g_pvExtension, VBOX_CLIPBOARD_EXT_FN_AREA_ATTACH, &parms, sizeof(parms)); 369 parms.uID = pTransfer->Area.GetID(); 370 371 rc = g_pfnExtension(g_pvExtension, VBOX_CLIPBOARD_EXT_FN_AREA_DETACH, &parms, sizeof(parms)); 291 372 #ifdef LOG_ENABLED 292 373 AssertPtr(pTransfer->pState); 293 LogFlowFunc((" Attached client %RU32 from clipboard area %RU32 with rc=%Rrc\n",374 LogFlowFunc(("Detached client %RU32 from clipboard area %RU32 with rc=%Rrc\n", 294 375 pTransfer->pState->u32ClientID, parms.uID, rc)); 295 376 #endif 296 if (RT_SUCCESS(rc))297 {298 299 }300 301 /* Do we need to detach again because we're done? */302 if ( RT_SUCCESS(rc))303 {304 RT_ZERO(parms);305 parms.uID = pTransfer->Cache.GetAreaID();306 307 rc = g_pfnExtension(g_pvExtension, VBOX_CLIPBOARD_EXT_FN_AREA_DETACH, &parms, sizeof(parms));308 #ifdef LOG_ENABLED309 AssertPtr(pTransfer->pState);310 LogFlowFunc(("Detached client %RU32 from clipboard area %RU32 with rc=%Rrc\n",311 pTransfer->pState->u32ClientID, parms.uID, rc));312 #endif313 }314 377 } 315 378 } … … 357 420 rc = SharedClipboardMetaDataResize(&pTransfer->Meta, pTransfer->Hdr.cbMeta); 358 421 if (RT_SUCCESS(rc)) 422 { 359 423 pClientData->cTransfers++; 424 } 360 425 } 361 426 } … … 402 467 rc = pTransfer->List.SetFromURIData(pvMeta, cbMeta, SHAREDCLIPBOARDURILIST_FLAGS_NONE); 403 468 404 if ( RT_SUCCESS(rc) 405 && g_pfnExtension) 469 if (RT_SUCCESS(rc)) 406 470 { 407 471 VBOXCLIPBOARDEXTAREAPARMS parms; … … 431 495 { 432 496 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_DIR\n")); 433 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED); 497 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_READ_DIR 498 && pClientData->cTransfers) /* Some transfer in-flight? */ 499 { 500 VBOXCLIPBOARDDIRDATA data; 501 rc = VBoxClipboardSvcImplURIReadDir(pClientData, &data); 502 if (RT_SUCCESS(rc)) 503 { 504 /* Note: Context ID (paParms[0]) not used yet. */ 505 HGCMSvcSetPv (&paParms[1], data.pszPath, data.cbPath); 506 HGCMSvcSetU32(&paParms[2], data.cbPath); 507 HGCMSvcSetU32(&paParms[3], data.fMode); 508 509 vboxClipboardSvcURIDirDataDestroy(&data); 510 } 511 } 434 512 break; 435 513 } … … 460 538 if (RT_SUCCESS(rc)) 461 539 { 462 const char *pszCacheDir = pTransfer-> Cache.GetDirAbs();540 const char *pszCacheDir = pTransfer->Area.GetDirAbs(); 463 541 char *pszDir = RTPathJoinA(pszCacheDir, data.pszPath); 464 542 if (pszDir) … … 468 546 { 469 547 /* Add for having a proper rollback. */ 470 int rc2 = pTransfer-> Cache.AddDir(pszDir);548 int rc2 = pTransfer->Area.AddDir(pszDir); 471 549 AssertRC(rc2); 472 550 } … … 482 560 { 483 561 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_FILE_HDR\n")); 484 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED); 562 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_READ_FILE_HDR 563 && pClientData->cTransfers) /* Some transfer in-flight? */ 564 { 565 VBOXCLIPBOARDFILEHDR hdr; 566 rc = VBoxClipboardSvcImplURIReadFileHdr(pClientData, &hdr); 567 if (RT_SUCCESS(rc)) 568 { 569 /* Note: Context ID (paParms[0]) not used yet. */ 570 HGCMSvcSetPv (&paParms[1], hdr.pszFilePath, hdr.cbFilePath); 571 HGCMSvcSetU32(&paParms[2], hdr.cbFilePath); 572 HGCMSvcSetU32(&paParms[3], hdr.fFlags); 573 HGCMSvcSetU32(&paParms[4], hdr.fMode); 574 HGCMSvcSetU64(&paParms[5], hdr.cbSize); 575 576 vboxClipboardSvcURIFileHdrDestroy(&hdr); 577 } 578 } 485 579 break; 486 580 } … … 511 605 { 512 606 if (!VBoxSvcClipboardFileHdrIsValid(&data, &pTransfer->Hdr)) 607 { 513 608 rc = VERR_INVALID_PARAMETER; 514 515 if (pTransfer->ObjCtx.pObj == NULL)609 } 610 else 516 611 { 517 pTransfer->ObjCtx.pObj = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File); 518 if (!pTransfer->ObjCtx.pObj) /** @todo Can this throw? */ 519 rc = VERR_NO_MEMORY; 612 if (pTransfer->ObjCtx.pObj == NULL) 613 { 614 pTransfer->ObjCtx.pObj = new SharedClipboardURIObject(SharedClipboardURIObject::Type_File); 615 if (!pTransfer->ObjCtx.pObj) /** @todo Can this throw? */ 616 rc = VERR_NO_MEMORY; 617 } 618 else /* There still is another object being processed? */ 619 rc = VERR_WRONG_ORDER; 520 620 } 521 else /* There still is another object being processed? */ 522 rc = VERR_WRONG_ORDER; 523 } 524 525 if (RT_SUCCESS(rc)) 526 { 527 const char *pszCacheDir = pTransfer->Cache.GetDirAbs(); 621 } 622 623 if (RT_SUCCESS(rc)) 624 { 625 const char *pszCacheDir = pTransfer->Area.GetDirAbs(); 528 626 529 627 char pszPathAbs[RTPATH_MAX]; … … 537 635 538 636 /** @todo Add sparse file support based on fFlags? (Use Open(..., fFlags | SPARSE). */ 539 rc = pObj->Open Ex(pszPathAbs, SharedClipboardURIObject::View_Target,540 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE,541 (data.fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR);637 rc = pObj->OpenFileEx(pszPathAbs, SharedClipboardURIObject::View_Target, 638 RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE, 639 (data.fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR); 542 640 if (RT_SUCCESS(rc)) 543 641 { … … 558 656 559 657 /* Add for having a proper rollback. */ 560 int rc2 = pTransfer-> Cache.AddFile(pszPathAbs);658 int rc2 = pTransfer->Area.AddFile(pszPathAbs); 561 659 AssertRC(rc2); 562 660 } … … 573 671 { 574 672 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_FN_READ_FILE_DATA\n")); 575 AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED); 673 if ( cParms == VBOX_SHARED_CLIPBOARD_CPARMS_READ_FILE_DATA 674 && pClientData->cTransfers) /* Some transfer in-flight? */ 675 { 676 VBOXCLIPBOARDFILEDATA data; 677 rc = VBoxClipboardSvcImplURIReadFileData(pClientData, &data); 678 if (RT_SUCCESS(rc)) 679 { 680 /* Note: Context ID (paParms[0]) not used yet. */ 681 HGCMSvcSetPv (&paParms[1], data.pvData, data.cbData); 682 HGCMSvcSetU32(&paParms[2], data.cbData); 683 HGCMSvcSetPv (&paParms[3], data.pvChecksum, data.cbChecksum); 684 HGCMSvcSetU32(&paParms[4], data.cbChecksum); 685 686 vboxClipboardSvcURIFileDataDestroy(&data); 687 } 688 } 576 689 break; 577 690 } -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r78725 r78942 865 865 } 866 866 867 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 868 int VBoxClipboardSvcImplURIReadDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 869 { 870 RT_NOREF(pClientData, pDirData); 871 return VERR_NOT_IMPLEMENTED; 872 } 873 874 int VBoxClipboardSvcImplURIWriteDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 875 { 876 RT_NOREF(pClientData, pDirData); 877 return VERR_NOT_IMPLEMENTED; 878 } 879 880 int VBoxClipboardSvcImplURIReadFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 881 { 882 RT_NOREF(pClientData, pFileHdr); 883 return VERR_NOT_IMPLEMENTED; 884 } 885 886 int VBoxClipboardSvcImplURIWriteFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 887 { 888 RT_NOREF(pClientData, pFileHdr); 889 return VERR_NOT_IMPLEMENTED; 890 } 891 892 int VBoxClipboardSvcImplURIReadFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 893 { 894 RT_NOREF(pClientData, pFileData); 895 return VERR_NOT_IMPLEMENTED; 896 } 897 898 int VBoxClipboardSvcImplURIWriteFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 899 { 900 RT_NOREF(pClientData, pFileData); 901 return VERR_NOT_IMPLEMENTED; 902 } 903 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 904 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11-stubs.cpp
r78648 r78942 133 133 } 134 134 135 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 136 int VBoxClipboardSvcImplURIReadDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 137 { 138 RT_NOREF(pClientData, pDirData); 139 return VERR_NOT_IMPLEMENTED; 140 } 141 142 int VBoxClipboardSvcImplURIWriteDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 143 { 144 RT_NOREF(pClientData, pDirData); 145 return VERR_NOT_IMPLEMENTED; 146 } 147 148 int VBoxClipboardSvcImplURIReadFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 149 { 150 RT_NOREF(pClientData, pFileHdr); 151 return VERR_NOT_IMPLEMENTED; 152 } 153 154 int VBoxClipboardSvcImplURIWriteFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 155 { 156 RT_NOREF(pClientData, pFileHdr); 157 return VERR_NOT_IMPLEMENTED; 158 } 159 160 int VBoxClipboardSvcImplURIReadFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 161 { 162 RT_NOREF(pClientData, pFileData); 163 return VERR_NOT_IMPLEMENTED; 164 } 165 166 int VBoxClipboardSvcImplURIWriteFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 167 { 168 RT_NOREF(pClientData, pFileData); 169 return VERR_NOT_IMPLEMENTED; 170 } 171 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 172 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r78809 r78942 451 451 RTCritSectLeave(&pCtx->clipboardMutex); 452 452 } 453 454 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 455 int VBoxClipboardSvcImplURIReadDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 456 { 457 RT_NOREF(pClientData, pDirData); 458 return VERR_NOT_IMPLEMENTED; 459 } 460 461 int VBoxClipboardSvcImplURIWriteDir(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDDIRDATA pDirData) 462 { 463 RT_NOREF(pClientData, pDirData); 464 return VERR_NOT_IMPLEMENTED; 465 } 466 467 int VBoxClipboardSvcImplURIReadFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 468 { 469 RT_NOREF(pClientData, pFileHdr); 470 return VERR_NOT_IMPLEMENTED; 471 } 472 473 int VBoxClipboardSvcImplURIWriteFileHdr(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEHDR pFileHdr) 474 { 475 RT_NOREF(pClientData, pFileHdr); 476 return VERR_NOT_IMPLEMENTED; 477 } 478 479 int VBoxClipboardSvcImplURIReadFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 480 { 481 RT_NOREF(pClientData, pFileData); 482 return VERR_NOT_IMPLEMENTED; 483 } 484 485 int VBoxClipboardSvcImplURIWriteFileData(PVBOXCLIPBOARDCLIENTDATA pClientData, PVBOXCLIPBOARDFILEDATA pFileData) 486 { 487 RT_NOREF(pClientData, pFileData); 488 return VERR_NOT_IMPLEMENTED; 489 } 490 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 453 491 454 492 #ifdef TESTCASE -
trunk/src/VBox/Main/Makefile.kmk
r78898 r78942 688 688 689 689 ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 690 VBoxSVC_SOURCES += $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/Clipboard Cache.cpp690 VBoxSVC_SOURCES += $(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/ClipboardArea.cpp 691 691 endif 692 692 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r78897 r78942 175 175 176 176 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 177 int i_onClipboardAreaCreate(SharedClipboardAreaData &AreaData, uint32_t fFlags); 178 int i_onClipboardAreaDestroy(SharedClipboardAreaData &AreaData); 179 int i_onClipboardAreaRegister(const std::vector<com::Utf8Str> &aParms, ULONG *aID); 180 int i_onClipboardAreaUnregister(ULONG aID); 181 int i_onClipboardAreaAttach(ULONG aID); 182 int i_onClipboardAreaDetach(ULONG aID); 177 int i_clipboardAreaCreate(SharedClipboardAreaData &AreaData, uint32_t fFlags); 178 int i_clipboardAreaDestroy(SharedClipboardAreaData &AreaData); 179 180 HRESULT i_onClipboardAreaRegister(const std::vector<com::Utf8Str> &aParms, ULONG *aID); 181 HRESULT i_onClipboardAreaUnregister(ULONG aID); 182 HRESULT i_onClipboardAreaAttach(ULONG aID); 183 HRESULT i_onClipboardAreaDetach(ULONG aID); 183 184 ULONG i_onClipboardAreaGetMostRecent(void); 184 185 ULONG i_onClipboardAreaGetRefCount(ULONG aID); -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r78897 r78942 248 248 SharedClipboardData() 249 249 : uNextClipboardAreaID(0) 250 , uMaxClipboardAreas(32) { } 250 , uMaxClipboardAreas(32) 251 { 252 int rc2 = RTCritSectInit(&CritSect); 253 AssertRC(rc2); 254 } 255 256 virtual ~SharedClipboardData() 257 { 258 RTCritSectDelete(&CritSect); 259 } 251 260 252 261 /** Critical section to serialize access. */ … … 986 995 #endif 987 996 997 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 998 LogFlowThisFunc(("Destroying Shared Clipboard areas...\n")); 999 SharedClipboardAreaMap::iterator itArea = m->SharedClipboard.mapClipboardAreas.begin(); 1000 while (itArea != m->SharedClipboard.mapClipboardAreas.end()) 1001 { 1002 i_clipboardAreaDestroy(itArea->second); 1003 ++itArea; 1004 } 1005 m->SharedClipboard.mapClipboardAreas.clear(); 1006 #endif 1007 988 1008 LogFlowThisFunc(("Terminating the async event handler...\n")); 989 1009 if (m->threadAsyncEvent != NIL_RTTHREAD) … … 3333 3353 3334 3354 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 3335 int VirtualBox::i_ onClipboardAreaCreate(SharedClipboardAreaData &AreaData, uint32_t fFlags)3355 int VirtualBox::i_clipboardAreaCreate(SharedClipboardAreaData &AreaData, uint32_t fFlags) 3336 3356 { 3337 3357 RT_NOREF(fFlags); 3338 int rc = AreaData.Area.OpenTemp(AreaData.uID); 3339 LogFlowFunc(("uID=%RU32, rc=%Rrc\n", AreaData.uID, rc)); 3340 return rc; 3341 } 3342 3343 int VirtualBox::i_onClipboardAreaDestroy(SharedClipboardAreaData &AreaData) 3358 int vrc = AreaData.Area.OpenTemp(AreaData.uID); 3359 if (RT_SUCCESS(vrc)) 3360 { 3361 } 3362 LogFlowFunc(("uID=%RU32, rc=%Rrc\n", AreaData.uID, vrc)); 3363 return vrc; 3364 } 3365 3366 int VirtualBox::i_clipboardAreaDestroy(SharedClipboardAreaData &AreaData) 3344 3367 { 3345 3368 /** @todo Do we need a worker for this to not block here for too long? 3346 3369 * This could take a while to clean up huge areas ... */ 3347 int rc = AreaData.Area.Close();3348 LogFlowFunc(("uID=%RU32, rc=%Rrc\n", AreaData.uID, rc));3349 return rc;3350 } 3351 3352 intVirtualBox::i_onClipboardAreaRegister(const std::vector<com::Utf8Str> &aParms, ULONG *aID)3370 int vrc = AreaData.Area.Close(); 3371 LogFlowFunc(("uID=%RU32, rc=%Rrc\n", AreaData.uID, vrc)); 3372 return vrc; 3373 } 3374 3375 HRESULT VirtualBox::i_onClipboardAreaRegister(const std::vector<com::Utf8Str> &aParms, ULONG *aID) 3353 3376 { 3354 3377 RT_NOREF(aParms); 3355 int rc = RTCritSectEnter(&m->SharedClipboard.CritSect); 3356 if (RT_SUCCESS(rc)) 3378 3379 HRESULT rc = S_OK; 3380 3381 int vrc = RTCritSectEnter(&m->SharedClipboard.CritSect); 3382 if (RT_SUCCESS(vrc)) 3357 3383 { 3358 3384 try … … 3365 3391 AreaData.uID = uAreaID; 3366 3392 3367 rc = i_onClipboardAreaCreate(AreaData, 0 /* fFlags */);3368 if (RT_SUCCESS( rc))3393 vrc = i_clipboardAreaCreate(AreaData, 0 /* fFlags */); 3394 if (RT_SUCCESS(vrc)) 3369 3395 { 3370 3396 m->SharedClipboard.mapClipboardAreas[uAreaID] = AreaData; … … 3380 3406 } 3381 3407 else 3382 LogRel(("Clipboard: Failed to create new clipboard area %RU32, rc=%Rrc\n", uAreaID, rc)); 3408 rc = setError(E_FAIL, /** @todo Find a better rc. */ 3409 tr("Failed to create new clipboard area %RU32 (%Rrc)"), aID, vrc); 3383 3410 } 3384 3411 else 3385 3412 { 3386 LogThisFunc(("Maximum number of conucurrent clipboard areas reached (%RU32)\n",3387 m->SharedClipboard.uMaxClipboardAreas));3388 rc = VERR_TOO_MUCH_DATA; /** @todo Find a better rc. */3413 rc = setError(E_FAIL, /** @todo Find a better rc. */ 3414 tr("Maximum number of conucurrent clipboard areas reached (%RU32)"), 3415 m->SharedClipboard.uMaxClipboardAreas); 3389 3416 } 3390 3417 } 3391 3418 catch (std::bad_alloc &ba) 3392 3419 { 3393 rc = VERR_NO_MEMORY;3420 vrc = VERR_NO_MEMORY; 3394 3421 RT_NOREF(ba); 3395 3422 } … … 3397 3424 RTCritSectLeave(&m->SharedClipboard.CritSect); 3398 3425 } 3399 LogFlowThisFunc(("rc=%R rc\n", rc));3426 LogFlowThisFunc(("rc=%Rhrc\n", rc)); 3400 3427 return rc; 3401 3428 } 3402 3429 3403 intVirtualBox::i_onClipboardAreaUnregister(ULONG aID)3404 { 3405 RT_NOREF(aID);3406 3407 int rc = RTCritSectEnter(&m->SharedClipboard.CritSect);3408 if (RT_SUCCESS( rc))3430 HRESULT VirtualBox::i_onClipboardAreaUnregister(ULONG aID) 3431 { 3432 HRESULT rc = S_OK; 3433 3434 int vrc = RTCritSectEnter(&m->SharedClipboard.CritSect); 3435 if (RT_SUCCESS(vrc)) 3409 3436 { 3410 3437 SharedClipboardAreaMap::iterator itArea = m->SharedClipboard.mapClipboardAreas.find(aID); … … 3413 3440 if (itArea->second.Area.GetRefCount() == 0) 3414 3441 { 3415 rc = i_onClipboardAreaDestroy(itArea->second);3416 if (RT_SUCCESS( rc))3442 vrc = i_clipboardAreaDestroy(itArea->second); 3443 if (RT_SUCCESS(vrc)) 3417 3444 { 3418 3445 m->SharedClipboard.mapClipboardAreas.erase(itArea); … … 3420 3447 } 3421 3448 else 3422 rc = VERR_WRONG_ORDER; 3449 rc = setError(E_ACCESSDENIED, /** @todo Find a better rc. */ 3450 tr("Area with ID %RU32 still in used, cannot unregister"), aID); 3423 3451 } 3424 3452 else 3425 rc = VERR_NOT_FOUND; 3453 rc = setError(VBOX_E_OBJECT_NOT_FOUND, /** @todo Find a better rc. */ 3454 tr("Could not find a registered clipboard area with ID %RU32"), aID); 3455 3456 int vrc2 = RTCritSectLeave(&m->SharedClipboard.CritSect); 3457 AssertRC(vrc2); 3458 } 3459 LogFlowThisFunc(("aID=%RU32, rc=%Rhrc\n", aID, rc)); 3460 return rc; 3461 } 3462 3463 HRESULT VirtualBox::i_onClipboardAreaAttach(ULONG aID) 3464 { 3465 HRESULT rc = S_OK; 3466 3467 int vrc = RTCritSectEnter(&m->SharedClipboard.CritSect); 3468 if (RT_SUCCESS(vrc)) 3469 { 3470 SharedClipboardAreaMap::iterator itArea = m->SharedClipboard.mapClipboardAreas.find(aID); 3471 if (itArea != m->SharedClipboard.mapClipboardAreas.end()) 3472 { 3473 uint32_t cRefs = itArea->second.Area.AddRef(); 3474 LogFlowThisFunc(("aID=%RU32 -> cRefs=%RU32\n", aID, cRefs)); 3475 vrc = VINF_SUCCESS; 3476 } 3477 else 3478 rc = setError(VBOX_E_OBJECT_NOT_FOUND, /** @todo Find a better rc. */ 3479 tr("Could not find a registered clipboard area with ID %RU32"), aID); 3480 3481 int vrc2 = RTCritSectLeave(&m->SharedClipboard.CritSect); 3482 AssertRC(vrc2); 3483 } 3484 LogFlowThisFunc(("aID=%RU32, rc=%Rhrc\n", aID, rc)); 3485 return rc; 3486 } 3487 3488 HRESULT VirtualBox::i_onClipboardAreaDetach(ULONG aID) 3489 { 3490 HRESULT rc = S_OK; 3491 3492 int vrc = RTCritSectEnter(&m->SharedClipboard.CritSect); 3493 if (RT_SUCCESS(vrc)) 3494 { 3495 SharedClipboardAreaMap::iterator itArea = m->SharedClipboard.mapClipboardAreas.find(aID); 3496 if (itArea != m->SharedClipboard.mapClipboardAreas.end()) 3497 { 3498 uint32_t cRefs = itArea->second.Area.Release(); 3499 LogFlowThisFunc(("aID=%RU32 -> cRefs=%RU32\n", aID, cRefs)); 3500 vrc = VINF_SUCCESS; 3501 } 3502 else 3503 rc = setError(VBOX_E_OBJECT_NOT_FOUND, /** @todo Find a better rc. */ 3504 tr("Could not find a registered clipboard area with ID %RU32"), aID); 3426 3505 3427 3506 int rc2 = RTCritSectLeave(&m->SharedClipboard.CritSect); 3428 3507 AssertRC(rc2); 3429 3508 } 3430 LogFlowThisFunc(("aID=%RU32, rc=%R rc\n", aID, rc));3509 LogFlowThisFunc(("aID=%RU32, rc=%Rhrc\n", aID, rc)); 3431 3510 return rc; 3432 3511 } 3433 3512 3434 int VirtualBox::i_onClipboardAreaAttach(ULONG aID)3435 {3436 int rc = RTCritSectEnter(&m->SharedClipboard.CritSect);3437 if (RT_SUCCESS(rc))3438 {3439 SharedClipboardAreaMap::iterator itArea = m->SharedClipboard.mapClipboardAreas.find(aID);3440 if (itArea != m->SharedClipboard.mapClipboardAreas.end())3441 {3442 uint32_t cRefs = itArea->second.Area.AddRef();3443 LogFlowThisFunc(("aID=%RU32 -> cRefs=%RU32\n", aID, cRefs));3444 rc = VINF_SUCCESS;3445 }3446 else3447 rc = VERR_NOT_FOUND;3448 3449 int rc2 = RTCritSectLeave(&m->SharedClipboard.CritSect);3450 AssertRC(rc2);3451 }3452 LogFlowThisFunc(("aID=%RU32, rc=%Rrc\n", aID, rc));3453 return rc;3454 }3455 3456 int VirtualBox::i_onClipboardAreaDetach(ULONG aID)3457 {3458 int rc = RTCritSectEnter(&m->SharedClipboard.CritSect);3459 if (RT_SUCCESS(rc))3460 {3461 SharedClipboardAreaMap::iterator itArea = m->SharedClipboard.mapClipboardAreas.find(aID);3462 if (itArea != m->SharedClipboard.mapClipboardAreas.end())3463 {3464 uint32_t cRefs = itArea->second.Area.Release();3465 LogFlowThisFunc(("aID=%RU32 -> cRefs=%RU32\n", aID, cRefs));3466 rc = VINF_SUCCESS;3467 }3468 else3469 rc = VERR_NOT_FOUND;3470 3471 int rc2 = RTCritSectLeave(&m->SharedClipboard.CritSect);3472 AssertRC(rc2);3473 }3474 LogFlowThisFunc(("aID=%RU32, rc=%Rrc\n", aID, rc));3475 return rc;3476 }3477 3478 3513 ULONG VirtualBox::i_onClipboardAreaGetMostRecent(void) 3479 3514 { 3480 3515 ULONG aID = 0; 3481 int rc2 = RTCritSectEnter(&m->SharedClipboard.CritSect);3482 if (RT_SUCCESS( rc2))3516 int vrc2 = RTCritSectEnter(&m->SharedClipboard.CritSect); 3517 if (RT_SUCCESS(vrc2)) 3483 3518 { 3484 3519 aID = m->SharedClipboard.uNextClipboardAreaID 3485 3520 ? m->SharedClipboard.uNextClipboardAreaID - 1 : 0; 3486 3521 3487 rc2 = RTCritSectLeave(&m->SharedClipboard.CritSect);3488 AssertRC( rc2);3522 vrc2 = RTCritSectLeave(&m->SharedClipboard.CritSect); 3523 AssertRC(vrc2); 3489 3524 } 3490 3525 LogFlowThisFunc(("aID=%RU32\n", aID));
Note:
See TracChangeset
for help on using the changeset viewer.