Changeset 79672 in vbox
- Timestamp:
- Jul 10, 2019 1:02:50 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
include/VBox/GuestHost/SharedClipboard-uri.h (modified) (11 diffs)
-
include/VBox/HostServices/VBoxClipboardSvc.h (modified) (8 diffs)
-
include/VBox/VBoxGuestLib.h (modified) (1 diff)
-
src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp (modified) (4 diffs)
-
src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp (modified) (8 diffs)
-
src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp (modified) (1 diff)
-
src/VBox/GuestHost/SharedClipboard/clipboard-uri.cpp (modified) (22 diffs)
-
src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp (modified) (1 diff)
-
src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.cpp (modified) (5 diffs)
-
src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-uri.h
r79631 r79672 370 370 371 371 /** 372 * Structure for keeping Shared Clipboard list root entries. 373 */ 374 typedef struct _VBOXCLIPBOARDROOTS 375 { 376 /** Roots listing flags; unused at the moment. */ 377 uint32_t fRoots; 378 /** Boolean indicating that more root items are following. */ 379 bool fMore; 380 /** Number of root items in this message. */ 381 uint32_t cRoots; 382 /** Size (in bytes) of string list. */ 383 uint32_t cbRoots; 384 /** String list (separated with \r\n) containing the root items. */ 385 char *pszRoots; 386 } VBOXCLIPBOARDROOTS, *PVBOXCLIPBOARDROOTS; 387 388 /** 372 389 * Structure for maintaining Shared Clipboard list open paramters. 373 390 */ … … 408 425 typedef struct _VBOXCLIPBOARDLISTENTRY 409 426 { 427 /** Entry name. */ 428 char *pszName; 429 /** Size (in bytes) of entry name. */ 430 uint32_t cbName; 410 431 /** Information flag(s). */ 411 432 uint32_t fInfo; … … 415 436 void *pvInfo; 416 437 } VBOXCLIPBOARDLISTENTRY, *PVBOXCLIPBOARDLISTENTRY; 438 439 #define VBOXCLIPBOARDLISTENTRY_MAX_NAME RTPATH_MAX 417 440 418 441 /** … … 556 579 int SharedClipboardPathSanitize(char *pszPath, size_t cbPath); 557 580 581 PVBOXCLIPBOARDROOTS SharedClipboardURIRootsDup(PVBOXCLIPBOARDROOTS pRoots); 582 int SharedClipboardURIRootsInit(PVBOXCLIPBOARDROOTS pRoots); 583 void SharedClipboardURIRootsDestroy(PVBOXCLIPBOARDROOTS pRoots); 584 558 585 int SharedClipboardURIListHdrAlloc(PVBOXCLIPBOARDLISTHDR *ppListHdr); 559 586 void SharedClipboardURIListHdrFree(PVBOXCLIPBOARDLISTHDR pListHdr); … … 665 692 { 666 693 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_UNKNOWN, 694 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_GET_ROOTS, 667 695 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_OPEN, 668 696 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_LIST_CLOSE, … … 689 717 { 690 718 VBOXCLIPBOARDLISTOPENPARMS OpenParms; 691 RTFMODE fMode;719 RTFMODE fMode; 692 720 union 693 721 { … … 718 746 typedef std::map<SHAREDCLIPBOARDLISTHANDLE, SHAREDCLIPBOARDURILISTHANDLEINFO *> SharedClipboardURIListMap; 719 747 748 /** Map of URI object handles. 749 * The key specifies the object handle. */ 720 750 typedef std::map<SHAREDCLIPBOARDOBJHANDLE, SHAREDCLIPBOARDURILISTHANDLEINFO *> SharedClipboardURIObjMap; 751 752 /** List of URI list root entries. */ 753 typedef RTCList<RTCString> SharedClipboardURIListRootEntries; 721 754 722 755 /** … … 770 803 SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(TRANSFEROPEN) 771 804 SHAREDCLIPBOARDPROVIDERFUNCDECLVOID(TRANSFERCLOSE) 805 SHAREDCLIPBOARDPROVIDERFUNCDECL(GETROOTS, char **ppapszRoots, uint32_t *pcRoots) 772 806 SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTOPEN, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, PSHAREDCLIPBOARDLISTHANDLE phList) 773 807 SHAREDCLIPBOARDPROVIDERFUNCDECL(LISTCLOSE, SHAREDCLIPBOARDLISTHANDLE hList); … … 791 825 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(TRANSFEROPEN, pfnTransferOpen); 792 826 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(TRANSFERCLOSE, pfnTransferClose); 827 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(GETROOTS, pfnGetRoots); 793 828 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTOPEN, pfnListOpen); 794 829 SHAREDCLIPBOARDPROVIDERFUNCMEMBER(LISTCLOSE, pfnListClose); … … 907 942 /** Events related to this transfer. */ 908 943 SharedClipboardURITransferEventMap *pMapEvents; 944 /** Map of all lists related to this transfer. */ 909 945 SharedClipboardURIListMap *pMapLists; 946 /** List of root entries of this transfer. */ 947 SharedClipboardURIListRootEntries lstRootEntries; 948 /** Map of all objects related to this transfer. */ 910 949 SharedClipboardURIObjMap *pMapObj; 911 950 /** The transfer's own (local) area, if any (can be NULL if not needed). … … 970 1009 971 1010 int SharedClipboardURITransferPrepare(PSHAREDCLIPBOARDURITRANSFER pTransfer); 1011 int SharedClipboardURITransferSetData(PSHAREDCLIPBOARDURITRANSFER pTransfer, SharedClipboardURIListRootEntries *pEntries); 972 1012 int SharedClipboardURITransferSetInterface(PSHAREDCLIPBOARDURITRANSFER pTransfer, 973 1013 PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCreationCtx); 1014 int SharedClipboardURILTransferSetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, const char *papszRoots, size_t cbRoots); 974 1015 void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer); 975 1016 SharedClipboardArea *SharedClipboardURITransferGetArea(PSHAREDCLIPBOARDURITRANSFER pTransfer); 1017 int SharedClipboardURILTransferGetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, char **ppapszRoots, uint32_t *pcRoots); 976 1018 SHAREDCLIPBOARDSOURCE SharedClipboardURITransferGetSource(PSHAREDCLIPBOARDURITRANSFER pTransfer); 977 1019 SHAREDCLIPBOARDURITRANSFERSTATUS SharedClipboardURITransferGetStatus(PSHAREDCLIPBOARDURITRANSFER pTransfer); -
trunk/include/VBox/HostServices/VBoxClipboardSvc.h
r79630 r79672 75 75 /** Initiates a new transfer (read / write) on the guest side. */ 76 76 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_TRANSFER_START 50 77 /** Requests reading the root entries from the guest. */ 78 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOTS 51 77 79 /** Open an URI list on the guest side. */ 78 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_OPEN 5 180 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_OPEN 52 79 81 /** Closes a formerly opened URI list on the guest side. */ 80 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_CLOSE 5 282 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_CLOSE 53 81 83 /** Reads a list header from the guest. */ 82 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_READ 5 384 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_READ 54 83 85 /** Writes a list header to the guest. */ 84 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_WRITE 5 486 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_WRITE 55 85 87 /** Reads a list entry from the guest. */ 86 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ 5 588 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ 56 87 89 /** Writes a list entry to the guest. */ 88 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_WRITE 5 690 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_WRITE 57 89 91 /** Open an URI object on the guest side. */ 90 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_OPEN 5 792 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_OPEN 58 91 93 /** Closes a formerly opened URI object on the guest side. */ 92 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_CLOSE 5 894 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_CLOSE 59 93 95 /** Reads from an object on the guest side. */ 94 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_READ 5996 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_READ 60 95 97 /** Writes to an object on the guest side. */ 96 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_WRITE 6 098 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_WRITE 61 97 99 /** Indicates that the host has canceled a transfer. */ 98 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_CANCEL 6 1100 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_CANCEL 62 99 101 /** Indicates that the an unrecoverable error on the host occurred . */ 100 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ERROR 6 2102 #define VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ERROR 63 101 103 102 104 /* … … 129 131 * New since URI handling was implemented. */ 130 132 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_REPLY 9 133 /** Reports the available root entries of a transfer. 134 * New since URI handling was implemented. */ 135 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_ROOTS 10 131 136 /** Opens / gets a list handle from the host. 132 137 * New since URI handling was implemented. */ 133 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_OPEN 1 0138 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_OPEN 11 134 139 /** Closes a list handle from the host. 135 140 * New since URI handling was implemented. */ 136 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_CLOSE 1 1141 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_CLOSE 12 137 142 /** Reads a list header from the host. 138 143 * New since URI handling was implemented. */ 139 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_HDR_READ 1 2144 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_HDR_READ 13 140 145 /** Writes a list header to the host. 141 146 * New since URI handling was implemented. */ 142 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_HDR_WRITE 1 3147 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_HDR_WRITE 14 143 148 /** New since URI handling was implemented. */ 144 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_ENTRY_READ 1 4149 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_ENTRY_READ 15 145 150 /** New since URI handling was implemented. */ 146 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_ENTRY_WRITE 1 5151 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_ENTRY_WRITE 16 147 152 /** New since URI handling was implemented. */ 148 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_OPEN 1 6153 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_OPEN 17 149 154 /** New since URI handling was implemented. */ 150 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_CLOSE 1 7155 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_CLOSE 18 151 156 /** New since URI handling was implemented. */ 152 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_READ 1 8157 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_READ 19 153 158 /** New since URI handling was implemented. */ 154 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_WRITE 19159 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_OBJ_WRITE 20 155 160 /** Reports cancellation of the current operation to the host. 156 161 * New since URI handling was implemented. */ 157 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_CANCEL 2 0162 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_CANCEL 21 158 163 /** Reports an error to the host. 159 164 * New since URI handling was implemented. */ 160 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_ERROR 2 1165 #define VBOX_SHARED_CLIPBOARD_GUEST_FN_ERROR 22 161 166 162 167 /** … … 174 179 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_REPORT_FORMATS); 175 180 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_TRANSFER_START); 181 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOTS); 176 182 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_OPEN); 177 183 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_CLOSE); … … 208 214 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_GUEST_FN_STATUS); 209 215 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_GUEST_FN_REPLY); 216 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_GUEST_FN_ROOTS); 210 217 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_OPEN); 211 218 RT_CASE_RET_STR(VBOX_SHARED_CLIPBOARD_GUEST_FN_LIST_CLOSE); … … 328 335 #define VBOX_SHAREDCLIPBOARD_LISTHDR_FLAG_NONE 0 329 336 337 /** No additional information provided. */ 330 338 #define VBOX_SHAREDCLIPBOARD_INFO_FLAG_NONE 0 331 339 /** Get object information of type SHAREDCLIPBOARDFSOBJINFO. */ … … 362 370 VBGLIOCHGCMCALL hdr; 363 371 364 /** uint32_t, in: Context ID. Unused at the moment. */365 HGCMFunctionParameter uContext; 366 /** uint32_t, in: Message type of type VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_XXX. */372 /** uint32_t, out: Context ID. Unused at the moment. */ 373 HGCMFunctionParameter uContext; 374 /** uint32_t, out: Message type of type VBOX_SHAREDCLIPBOARD_REPLYMSGTYPE_XXX. */ 367 375 HGCMFunctionParameter enmType; 368 /** uint32_t, in: IPRT result of overall operation. */376 /** uint32_t, out: IPRT result of overall operation. */ 369 377 HGCMFunctionParameter rc; 370 /** uint32_t, in: Size of optional payload of this reply, based on the message type. */378 /** uint32_t, out: Size of optional payload of this reply, based on the message type. */ 371 379 HGCMFunctionParameter cbPayload; 372 /** pointer, in: Optional payload of this reply, based on the message type. */380 /** pointer, out: Optional payload of this reply, based on the message type. */ 373 381 HGCMFunctionParameter pvPayload; 374 382 union … … 388 396 389 397 /** 398 * Reads / Writes the roots list. 399 */ 400 typedef struct _VBoxClipboardRootsMsg 401 { 402 VBGLIOCHGCMCALL hdr; 403 404 /** uint32_t, in: Context ID. Unused at the moment. */ 405 HGCMFunctionParameter uContext; 406 /** uint32_t, in: Roots listing flags; unused at the moment. */ 407 HGCMFunctionParameter fRoots; 408 /** uint32_t, out: Boolean indicating that more root items are following 409 * (via another message). */ 410 HGCMFunctionParameter fMore; 411 /** uint32_t, out: Number of root items in this message. */ 412 HGCMFunctionParameter cRoots; 413 /** uin32_t, out: Size (in bytes) of string list. */ 414 HGCMFunctionParameter cbRoots; 415 /** pointer, out: string list (separated with \r\n) containing the root items. */ 416 HGCMFunctionParameter pvRoots; 417 } VBoxClipboardRootsMsg; 418 419 #define VBOX_SHARED_CLIPBOARD_CPARMS_ROOTS 6 420 421 /** 390 422 * Opens a list. 391 423 */ … … 500 532 VBGLIOCHGCMCALL hdr; 501 533 502 /** in : Request parameters. */534 /** in/out: Request parameters. */ 503 535 VBoxClipboardListEntryReqParms ReqParms; 536 /** pointer, in/out: Entry name. */ 537 HGCMFunctionParameter szName; 504 538 /** uint32_t, out: Bytes to be used for information/How many bytes were used. */ 505 539 HGCMFunctionParameter cbInfo; 506 /** pointer, out: Information to be set/get (SHAREDCLIPBOARDFSOBJINFO only currently).540 /** pointer, in/out: Information to be set/get (SHAREDCLIPBOARDFSOBJINFO only currently). 507 541 * Do not forget to set the SHAREDCLIPBOARDFSOBJINFO::Attr::enmAdditional for Get operation as well. */ 508 542 HGCMFunctionParameter pvInfo; 509 543 } VBoxClipboardListEntryMsg; 510 544 511 #define VBOX_SHARED_CLIPBOARD_CPARMS_LIST_ENTRY 5545 #define VBOX_SHARED_CLIPBOARD_CPARMS_LIST_ENTRY 6 512 546 513 547 typedef struct _VBoxClipboardObjOpenMsg -
trunk/include/VBox/VBoxGuestLib.h
r79630 r79672 625 625 626 626 VBGLR3DECL(int) VbglR3ClipboardTransferSendStatus(HGCMCLIENTID idClient, SHAREDCLIPBOARDURITRANSFERSTATUS uStatus); 627 628 VBGLR3DECL(int) VbglR3ClipboardRootsRecv(HGCMCLIENTID idClient, uint32_t *pfRoots); 629 VBGLR3DECL(int) VbglR3ClipboardRootsWrite(HGCMCLIENTID idClient, uint32_t cRoots, const char *papszList, uint32_t cbList); 627 630 628 631 VBGLR3DECL(int) VbglR3ClipboardListOpenSend(HGCMCLIENTID idClient, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, PSHAREDCLIPBOARDLISTHANDLE phList); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r79630 r79672 80 80 PVBOXCLIPBOARDCONTEXT pClipboardCtx; 81 81 PSHAREDCLIPBOARDURITRANSFER pTransfer; 82 char *papszURIList;83 uint32_t cbURIList;84 82 } VBOXCLIPBOARDURIWRITETHREADCTX, *PVBOXCLIPBOARDURIWRITETHREADCTX; 85 83 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ … … 156 154 VbglR3ClipboardDisconnect(uClientID); 157 155 } 158 159 if (pCtx->papszURIList)160 RTStrFree(pCtx->papszURIList);161 156 162 157 RTMemFree(pCtx); … … 787 782 if (RT_SUCCESS(rc)) 788 783 { 789 #if 0 790 SHAREDCLIPBOARDURITRANSFERCALLBACKS TransferCallbacks; 791 RT_ZERO(TransferCallbacks); 792 793 TransferCallbacks.pvUser = &pCtx->URI; 794 TransferCallbacks.pfnTransferComplete = vboxClipboardURITransferCompleteCallback; 795 TransferCallbacks.pfnTransferError = vboxClipboardURITransferErrorCallback; 796 797 SharedClipboardURITransferSetCallbacks(pTransfer, &TransferCallbacks); 798 799 SHAREDCLIPBOARDPROVIDERCREATIONCTX creationCtx; 800 RT_ZERO(creationCtx); 801 creationCtx.enmSource = SHAREDCLIPBOARDSOURCE_LOCAL; 802 803 RT_ZERO(creationCtx.Interface); 804 creationCtx.Interface.pfnListHdrWrite = vboxClipboardURIListHdrWrite; 805 creationCtx.Interface.pfnListEntryWrite = vboxClipboardURIListEntryWrite; 806 creationCtx.Interface.pfnObjOpen = vboxClipboardURIObjOpen; 807 creationCtx.Interface.pfnObjClose = vboxClipboardURIObjClose; 808 creationCtx.Interface.pfnObjWrite = vboxClipboardURIObjWrite; 809 810 creationCtx.pvUser = pCtx; 811 812 rc = SharedClipboardURITransferSetInterface(pTransfer, &creationCtx); 784 rc = SharedClipboardURICtxTransferAdd(&pCtx->URI, pTransfer); 813 785 if (RT_SUCCESS(rc)) 814 786 { 815 #endif 816 rc = SharedClipboardURICtxTransferAdd(&pCtx->URI, pTransfer); 817 if (RT_SUCCESS(rc)) 787 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 788 * presented as a IDataObject or IStream. */ 789 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 790 if (hClip) 818 791 { 819 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 820 * presented as a IDataObject or IStream. */ 821 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 822 if (hClip) 792 HDROP hDrop = (HDROP)GlobalLock(hClip); 793 if (hDrop) 823 794 { 824 HDROP hDrop = (HDROP)GlobalLock(hClip); 825 if (hDrop) 795 char *papszList; 796 uint32_t cbList; 797 rc = VBoxClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 798 799 GlobalUnlock(hClip); 800 801 if (RT_SUCCESS(rc)) 826 802 { 827 char *papszList; 828 uint32_t cbList; 829 rc = VBoxClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 803 rc = SharedClipboardURILTransferSetRoots(pTransfer, papszList, cbList); 830 804 if (RT_SUCCESS(rc)) 831 805 { … … 836 810 pThreadCtx->pClipboardCtx = pCtx; 837 811 pThreadCtx->pTransfer = pTransfer; 838 pThreadCtx->papszURIList = papszList; 839 pThreadCtx->cbURIList = cbList; 840 841 GlobalUnlock(hClip); 842 812 813 rc = SharedClipboardURITransferPrepare(pTransfer); 843 814 if (RT_SUCCESS(rc)) 844 815 { 845 rc = SharedClipboardURITransferPrepare(pTransfer); 846 if (RT_SUCCESS(rc)) 847 { 848 rc = SharedClipboardURITransferRun(pTransfer, vboxClipboardURIWriteThread, 849 pThreadCtx /* pvUser */); 850 /* pThreadCtx now is owned by vboxClipboardURIWriteThread(). */ 851 } 816 rc = SharedClipboardURITransferRun(pTransfer, vboxClipboardURIWriteThread, 817 pThreadCtx /* pvUser */); 818 /* pThreadCtx now is owned by vboxClipboardURIWriteThread(). */ 852 819 } 853 820 } 854 821 else 855 822 rc = VERR_NO_MEMORY; 856 857 if (RT_FAILURE(rc))858 {859 RTStrFree(papszList);860 }861 823 } 862 } 863 else 864 { 865 hClip = NULL; 824 825 if (papszList) 826 RTStrFree(papszList); 866 827 } 867 828 } 829 else 830 { 831 hClip = NULL; 832 } 868 833 } 869 //}834 } 870 835 } 871 836 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r79630 r79672 278 278 } 279 279 280 VBGLR3DECL(int) VbglR3ClipboardRootsRecv(HGCMCLIENTID idClient, PVBOXCLIPBOARDROOTS pRoots) 281 { 282 AssertPtrReturn(pRoots, VERR_INVALID_POINTER); 283 284 VBoxClipboardRootsMsg Msg; 285 RT_ZERO(Msg); 286 287 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, 288 VBOX_SHARED_CLIPBOARD_GUEST_FN_MSG_GET, VBOX_SHARED_CLIPBOARD_CPARMS_ROOTS); 289 290 Msg.uContext.SetUInt32(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOTS); 291 Msg.fRoots.SetUInt32(0); 292 Msg.fMore.SetUInt32(0); 293 Msg.cRoots.SetUInt32(0); 294 Msg.cbRoots.SetUInt32(pRoots->cbRoots); 295 Msg.pvRoots.SetPtr((void *)pRoots->pszRoots, pRoots->cbRoots); 296 297 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 298 if (RT_SUCCESS(rc)) 299 { 300 uint32_t fMore; 301 rc = Msg.fMore.GetUInt32(&fMore); AssertRC(rc); 302 if (RT_SUCCESS(rc)) 303 { 304 pRoots->fMore = RT_BOOL(fMore); 305 } 306 if (RT_SUCCESS(rc)) 307 rc = Msg.fRoots.GetUInt32(&pRoots->fRoots); AssertRC(rc); 308 if (RT_SUCCESS(rc)) 309 rc = Msg.cRoots.GetUInt32(&pRoots->cRoots); AssertRC(rc); 310 if (RT_SUCCESS(rc)) 311 rc = Msg.cbRoots.GetUInt32(&pRoots->cbRoots); AssertRC(rc); 312 } 313 314 LogFlowFuncLeaveRC(rc); 315 return rc; 316 } 317 318 VBGLR3DECL(int) VbglR3ClipboardRootsWrite(HGCMCLIENTID idClient, uint32_t cRoots, char *papszList, uint32_t cbList) 319 { 320 AssertPtrReturn(papszList, VERR_INVALID_POINTER); 321 AssertReturn(cbList, VERR_INVALID_PARAMETER); 322 323 VBoxClipboardRootsMsg Msg; 324 RT_ZERO(Msg); 325 326 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, 327 VBOX_SHARED_CLIPBOARD_GUEST_FN_ROOTS, VBOX_SHARED_CLIPBOARD_CPARMS_ROOTS); 328 329 Msg.uContext.SetUInt32(0); /** @todo Context ID not used yet. */ 330 Msg.fRoots.SetUInt32(0); 331 Msg.fMore.SetUInt32(0); 332 Msg.cRoots.SetUInt32(cRoots); 333 Msg.cbRoots.SetUInt32(cbList); 334 Msg.pvRoots.SetPtr(papszList, cbList); 335 336 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 337 338 LogFlowFuncLeaveRC(rc); 339 return rc; 340 } 341 280 342 VBGLR3DECL(int) VbglR3ClipboardListOpenSend(HGCMCLIENTID idClient, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, 281 343 PSHAREDCLIPBOARDLISTHANDLE phList) … … 512 574 Msg.ReqParms.fInfo.SetUInt32(0); 513 575 576 Msg.szName.SetPtr(pListEntry->pszName, pListEntry->cbName); 514 577 Msg.cbInfo.SetUInt32(0); 515 578 Msg.pvInfo.SetPtr(pListEntry->pvInfo, pListEntry->cbInfo); … … 567 630 Msg.ReqParms.fInfo.SetUInt32(pListEntry->fInfo); 568 631 632 Msg.szName.SetPtr(pListEntry->pszName, pListEntry->cbName); 569 633 Msg.cbInfo.SetUInt32(pListEntry->cbInfo); 570 634 Msg.pvInfo.SetPtr(pListEntry->pvInfo, pListEntry->cbInfo); … … 596 660 { 597 661 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 662 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOTS: 663 { 664 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOTS\n")); 665 666 VBOXCLIPBOARDROOTS Roots; 667 rc = SharedClipboardURIRootsInit(&Roots); 668 if (RT_SUCCESS(rc)) 669 { 670 rc = VbglR3ClipboardRootsRecv(idClient, &Roots); 671 if (RT_SUCCESS(rc)) 672 { 673 /** @todo Handle fFlags. */ 674 675 char *pszRoots = NULL; 676 uint32_t cRoots = 0; 677 rc = SharedClipboardURILTransferGetRoots(pTransfer, &pszRoots, &cRoots); 678 if (RT_SUCCESS(rc)) 679 { 680 /** @todo Split up transfers in _64K each. */ 681 682 rc = VbglR3ClipboardRootsWrite(idClient, cRoots, 683 pszRoots, pszRoots ? (uint32_t)strlen(pszRoots) : NULL); 684 } 685 } 686 } 687 688 break; 689 } 690 598 691 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_OPEN: 599 692 { … … 607 700 if (RT_SUCCESS(rc)) 608 701 { 702 LogFlowFunc(("pszPath=%s\n", openParmsList.pszPath)); 703 609 704 SHAREDCLIPBOARDLISTHANDLE hList = SHAREDCLIPBOARDLISTHANDLE_INVALID; 610 705 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); … … 613 708 int rc2 = VbglR3ClipboardListOpenReply(idClient, rc, hList); 614 709 AssertRC(rc2); 710 711 SharedClipboardURIListOpenParmsDestroy(&openParmsList); 615 712 } 616 617 SharedClipboardURIListOpenParmsDestroy(&openParmsList);618 713 } 714 619 715 break; 620 716 } … … 676 772 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ\n")); 677 773 678 VBOXCLIPBOARDLISTENTRY listEntry;679 rc = SharedClipboardURIListEntryInit(& listEntry);774 VBOXCLIPBOARDLISTENTRY entryList; 775 rc = SharedClipboardURIListEntryInit(&entryList); 680 776 if (RT_SUCCESS(rc)) 681 777 { … … 685 781 if (RT_SUCCESS(rc)) 686 782 { 687 rc = SharedClipboardURITransferListRead(pTransfer, hList, & listEntry);783 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList); 688 784 if (RT_SUCCESS(rc)) 689 785 { 690 rc = VbglR3ClipboardListEntryWrite(idClient, hList, &listEntry); 786 PSHAREDCLIPBOARDFSOBJINFO pObjInfo = (PSHAREDCLIPBOARDFSOBJINFO)entryList.pvInfo; 787 Assert(entryList.cbInfo == sizeof(SHAREDCLIPBOARDFSOBJINFO)); 788 789 LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject)); 790 791 rc = VbglR3ClipboardListEntryWrite(idClient, hList, &entryList); 691 792 } 692 793 } 693 794 694 SharedClipboardURIListEntryDestroy(& listEntry);795 SharedClipboardURIListEntryDestroy(&entryList); 695 796 } 696 797 -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
r79630 r79672 246 246 RTThreadUserSignal(RTThreadSelf()); 247 247 248 LogRel2(("Shared Clipboard: Calculating transfer ....\n")); 249 248 250 int rc = SharedClipboardURITransferOpen(pTransfer); 249 251 if (RT_SUCCESS(rc)) 250 252 { 251 VBOXCLIPBOARDLISTOPENPARMS openParmsList; 252 rc = SharedClipboardURIListOpenParmsInit(&openParmsList); 253 uint32_t cRoots; 254 char *pszRoots; 255 rc = SharedClipboardURILTransferGetRoots(pTransfer, &pszRoots, &cRoots); 253 256 if (RT_SUCCESS(rc)) 254 257 { 255 SHAREDCLIPBOARDLISTHANDLE hList; 256 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); 258 SharedClipboardURIListRootEntries lstRoots = RTCString(pszRoots, strlen(pszRoots)).split("\r\n"); 259 Assert(lstRoots.size() == cRoots); 260 261 LogFlowFunc(("cRoots=%zu\n", lstRoots.size())); 262 263 for (uint32_t i = 0; i < lstRoots.size(); i++) 264 { 265 VBOXCLIPBOARDLISTOPENPARMS openParmsList; 266 rc = SharedClipboardURIListOpenParmsInit(&openParmsList); 267 if (RT_SUCCESS(rc)) 268 { 269 LogFlowFunc(("pszRoot=%s\n", lstRoots[i].c_str())); 270 271 rc = RTStrCopy(openParmsList.pszPath, openParmsList.cbPath, lstRoots[i].c_str()); 272 if (RT_FAILURE(rc)) 273 break; 274 275 SHAREDCLIPBOARDLISTHANDLE hList; 276 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); 277 if (RT_SUCCESS(rc)) 278 { 279 LogFlowFunc(("hList=%RU64\n", hList)); 280 281 VBOXCLIPBOARDLISTHDR hdrList; 282 rc = SharedClipboardURITransferListGetHeader(pTransfer, hList, &hdrList); 283 if (RT_SUCCESS(rc)) 284 { 285 LogFlowFunc(("cTotalObjects=%RU64, cbTotalSize=%RU64\n\n", 286 hdrList.cTotalObjects, hdrList.cbTotalSize)); 287 288 for (uint64_t i = 0; i < hdrList.cTotalObjects; i++) 289 { 290 VBOXCLIPBOARDLISTENTRY entryList; 291 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList); 292 if (RT_SUCCESS(rc)) 293 { 294 PSHAREDCLIPBOARDFSOBJINFO pObjInfo = (PSHAREDCLIPBOARDFSOBJINFO)entryList.pvInfo; 295 Assert(entryList.cbInfo == sizeof(SHAREDCLIPBOARDFSOBJINFO)); 296 297 LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject)); 298 } 299 else 300 break; 301 302 if (pTransfer->Thread.fStop) 303 break; 304 } 305 } 306 307 SharedClipboardURITransferListClose(pTransfer, hList); 308 } 309 310 SharedClipboardURIListOpenParmsDestroy(&openParmsList); 311 } 312 313 if (RT_FAILURE(rc)) 314 break; 315 } 316 257 317 if (RT_SUCCESS(rc)) 258 318 { 259 LogFlowFunc(("hList=%RU64\n", hList)); 260 261 VBOXCLIPBOARDLISTHDR hdrList; 262 rc = SharedClipboardURITransferListGetHeader(pTransfer, hList, &hdrList); 263 if (RT_SUCCESS(rc)) 264 { 265 LogFlowFunc(("cTotalObjects=%RU64, cbTotalSize=%RU64\n\n", 266 hdrList.cTotalObjects, hdrList.cbTotalSize)); 267 268 for (uint64_t i = 0; i < hdrList.cTotalObjects; i++) 269 { 270 VBOXCLIPBOARDLISTENTRY entryList; 271 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList); 272 if (RT_SUCCESS(rc)) 273 { 274 } 275 else 276 break; 277 278 if (pTransfer->Thread.fStop) 279 break; 280 } 281 282 if (RT_SUCCESS(rc)) 283 { 284 /* 285 * Signal the "list complete" event so that this data object can return (valid) data via ::GetData(). 286 * This in turn then will create IStream instances (by the OS) for each file system object to handle. 287 */ 288 int rc2 = RTSemEventSignal(pThis->m_EventListComplete); 289 AssertRC(rc2); 290 291 LogFlowFunc(("Waiting for transfer to complete ...\n")); 292 293 /* Transferring stuff can take a while, so don't use any timeout here. */ 294 rc2 = RTSemEventWait(pThis->m_EventTransferComplete, RT_INDEFINITE_WAIT); 295 AssertRC(rc2); 296 } 297 } 298 299 SharedClipboardURITransferListClose(pTransfer, hList); 319 LogRel2(("Shared Clipboard: Calculation complete, starting transfer ...\n")); 320 321 /* 322 * Signal the "list complete" event so that this data object can return (valid) data via ::GetData(). 323 * This in turn then will create IStream instances (by the OS) for each file system object to handle. 324 */ 325 int rc2 = RTSemEventSignal(pThis->m_EventListComplete); 326 AssertRC(rc2); 327 328 LogFlowFunc(("Waiting for transfer to complete ...\n")); 329 330 /* Transferring stuff can take a while, so don't use any timeout here. */ 331 rc2 = RTSemEventWait(pThis->m_EventTransferComplete, RT_INDEFINITE_WAIT); 332 AssertRC(rc2); 300 333 } 301 334 302 SharedClipboardURIListOpenParmsDestroy(&openParmsList);335 RTStrFree(pszRoots); 303 336 } 304 337 -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-uri.cpp
r79630 r79672 37 37 38 38 39 int SharedClipboardURIRootsInit(PVBOXCLIPBOARDROOTS pRoots) 40 { 41 AssertPtrReturn(pRoots, VERR_INVALID_POINTER); 42 43 RT_BZERO(pRoots, sizeof(VBOXCLIPBOARDROOTS)); 44 45 const uint32_t cbRoots = _64K; 46 47 pRoots->pszRoots = RTStrAlloc(cbRoots); 48 if (!pRoots->pszRoots) 49 return VERR_NO_MEMORY; 50 51 pRoots->cbRoots = cbRoots; 52 53 return VINF_SUCCESS; 54 } 55 56 void SharedClipboardURIRootsDestroy(PVBOXCLIPBOARDROOTS pRoots) 57 { 58 if (!pRoots) 59 return; 60 61 if (pRoots->pszRoots) 62 RTStrFree(pRoots->pszRoots); 63 } 64 65 PVBOXCLIPBOARDROOTS SharedClipboardURIRootsDup(PVBOXCLIPBOARDROOTS pRoots) 66 { 67 AssertPtrReturn(pRoots, NULL); 68 69 int rc = VINF_SUCCESS; 70 71 PVBOXCLIPBOARDROOTS pRootsDup = (PVBOXCLIPBOARDROOTS)RTMemAlloc(sizeof(VBOXCLIPBOARDROOTS)); 72 if (pRootsDup) 73 { 74 *pRootsDup = *pRoots; 75 76 if (pRoots->pszRoots) 77 { 78 pRootsDup->pszRoots = RTStrDup(pRoots->pszRoots); 79 if (!pRootsDup->pszRoots) 80 rc = VERR_NO_MEMORY; 81 } 82 } 83 84 if (RT_FAILURE(rc)) 85 { 86 if (pRootsDup->pszRoots) 87 RTStrFree(pRootsDup->pszRoots); 88 89 RTMemFree(pRootsDup); 90 pRootsDup = NULL; 91 } 92 93 return pRootsDup; 94 } 95 39 96 /** 40 97 * Allocates a VBOXCLIPBOARDListHdr structure. … … 287 344 *pDst = *pSrc; 288 345 289 if (pSrc->pvInfo) 346 if (pSrc->pszName) 347 { 348 pDst->pszName = RTStrDup(pSrc->pszName); 349 if (!pDst->pszName) 350 rc = VERR_NO_MEMORY; 351 } 352 353 if ( RT_SUCCESS(rc) 354 && pSrc->pvInfo) 290 355 { 291 356 pDst->pvInfo = RTMemDup(pSrc->pvInfo, pSrc->cbInfo); … … 341 406 * Initializes a clipboard list entry structure. 342 407 * 343 * @param pListEntry clipboard list entry structure to initialize. 408 * @returns VBox status code. 409 * @param pListEntry Clipboard list entry structure to initialize. 344 410 */ 345 411 int SharedClipboardURIListEntryInit(PVBOXCLIPBOARDLISTENTRY pListEntry) … … 347 413 RT_BZERO(pListEntry, sizeof(VBOXCLIPBOARDLISTENTRY)); 348 414 415 pListEntry->pszName = RTStrAlloc(VBOXCLIPBOARDLISTENTRY_MAX_NAME); 416 if (!pListEntry->pszName) 417 return VERR_NO_MEMORY; 418 419 pListEntry->cbName = VBOXCLIPBOARDLISTENTRY_MAX_NAME; 420 349 421 return VINF_SUCCESS; 350 422 } … … 353 425 * Initializes a clipboard list entry structure. 354 426 * 355 * @param pListEntry clipboard list entry structure to destroy.427 * @param pListEntry Clipboard list entry structure to destroy. 356 428 */ 357 429 void SharedClipboardURIListEntryDestroy(PVBOXCLIPBOARDLISTENTRY pListEntry) … … 359 431 if (!pListEntry) 360 432 return; 433 434 if (pListEntry->pszName) 435 { 436 RTStrFree(pListEntry->pszName); 437 438 pListEntry->pszName = NULL; 439 pListEntry->cbName = 0; 440 } 361 441 362 442 if (pListEntry->pvInfo) … … 382 462 return true; /** @todo Implement this. */ 383 463 } 384 385 #if 0386 /**387 * Creates (allocates) and initializes a VBOXCLIPBOARDDIRDATA structure.388 *389 * @param ppDirData Where to return the created VBOXCLIPBOARDDIRDATA structure on success.390 */391 int SharedClipboardURIDirDataAlloc(PVBOXCLIPBOARDDIRDATA *ppDirData)392 {393 PVBOXCLIPBOARDDIRDATA pDirData = (PVBOXCLIPBOARDDIRDATA)RTMemAlloc(sizeof(VBOXCLIPBOARDDIRDATA));394 if (!pDirData)395 return VERR_NO_MEMORY;396 397 int rc = SharedClipboardURIDirDataInit(pDirData);398 if (RT_SUCCESS(rc))399 *ppDirData = pDirData;400 401 return rc;402 }403 404 /**405 * Frees a VBOXCLIPBOARDDIRDATA structure.406 *407 * @param pDirData Where to return the created VBOXCLIPBOARDDIRDATA structure on success.408 */409 void SharedClipboardURIDirDataFree(PVBOXCLIPBOARDDIRDATA pDirData)410 {411 if (!pDirData)412 return;413 414 SharedClipboardURIDirDataDestroy(pDirData);415 RTMemFree(pDirData);416 }417 418 /**419 * Initializes a VBOXCLIPBOARDDIRDATA structure.420 *421 * @param pDirData VBOXCLIPBOARDDIRDATA structure to initialize.422 */423 int SharedClipboardURIDirDataInit(PVBOXCLIPBOARDDIRDATA pDirData)424 {425 RT_BZERO(pDirData, sizeof(VBOXCLIPBOARDDIRDATA));426 427 return VINF_SUCCESS;428 }429 430 /**431 * Destroys a VBOXCLIPBOARDDIRDATA structure.432 *433 * @param pDirData VBOXCLIPBOARDDIRDATA structure to destroy.434 */435 void SharedClipboardURIDirDataDestroy(PVBOXCLIPBOARDDIRDATA pDirData)436 {437 if (!pDirData)438 return;439 440 if (pDirData->pszPath)441 {442 Assert(pDirData->cbPath);443 RTStrFree(pDirData->pszPath);444 pDirData->pszPath = NULL;445 }446 }447 448 /**449 * Duplicates (allocates) a VBOXCLIPBOARDDIRDATA structure.450 *451 * @returns Duplicated VBOXCLIPBOARDDIRDATA structure on success.452 * @param pDirData VBOXCLIPBOARDDIRDATA to duplicate.453 */454 PVBOXCLIPBOARDDIRDATA SharedClipboardURIDirDataDup(PVBOXCLIPBOARDDIRDATA pDirData)455 {456 AssertPtrReturn(pDirData, NULL);457 458 PVBOXCLIPBOARDDIRDATA pDirDataDup = (PVBOXCLIPBOARDDIRDATA)RTMemAllocZ(sizeof(VBOXCLIPBOARDDIRDATA));459 if (pDirDataDup)460 {461 *pDirDataDup = *pDirData;462 463 if (pDirData->pszPath)464 {465 pDirDataDup->pszPath = RTStrDup(pDirData->pszPath);466 if (pDirDataDup->pszPath)467 pDirDataDup->cbPath = pDirData->cbPath;468 }469 }470 471 return pDirDataDup;472 }473 474 /**475 * Returns whether given clipboard directory data is valid or not.476 *477 * @returns \c true if valid, \c false if not.478 * @param pDirData Clipboard directory data to validate.479 */480 bool SharedClipboardURIDirDataIsValid(PVBOXCLIPBOARDDIRDATA pDirData)481 {482 if ( !pDirData->cbPath483 || pDirData->cbPath > RTPATH_MAX)484 return false;485 486 if (!RTStrIsValidEncoding(pDirData->pszPath))487 return false;488 489 return true;490 }491 492 /**493 * Initializes a VBOXCLIPBOARDFILEHDR structure.494 *495 * @param pDirData VBOXCLIPBOARDFILEHDR structure to initialize.496 */497 int SharedClipboardURIFileHdrInit(PVBOXCLIPBOARDFILEHDR pFileHdr)498 {499 RT_BZERO(pFileHdr, sizeof(VBOXCLIPBOARDFILEHDR));500 501 return VINF_SUCCESS;502 }503 504 /**505 * Destroys a VBOXCLIPBOARDFILEHDR structure.506 *507 * @param pFileHdr VBOXCLIPBOARDFILEHDR structure to destroy.508 */509 void SharedClipboardURIFileHdrDestroy(PVBOXCLIPBOARDFILEHDR pFileHdr)510 {511 if (!pFileHdr)512 return;513 514 if (pFileHdr->pszFilePath)515 {516 Assert(pFileHdr->pszFilePath);517 RTStrFree(pFileHdr->pszFilePath);518 pFileHdr->pszFilePath = NULL;519 }520 }521 522 /**523 * Frees a VBOXCLIPBOARDFILEHDR structure.524 *525 * @param pFileHdr VBOXCLIPBOARDFILEHDR structure to free.526 */527 void SharedClipboardURIFileHdrFree(PVBOXCLIPBOARDFILEHDR pFileHdr)528 {529 if (!pFileHdr)530 return;531 532 SharedClipboardURIFileHdrDestroy(pFileHdr);533 534 RTMemFree(pFileHdr);535 pFileHdr = NULL;536 }537 538 /**539 * Duplicates (allocates) a VBOXCLIPBOARDFILEHDR structure.540 *541 * @returns Duplicated VBOXCLIPBOARDFILEHDR structure on success.542 * @param pFileHdr VBOXCLIPBOARDFILEHDR to duplicate.543 */544 PVBOXCLIPBOARDFILEHDR SharedClipboardURIFileHdrDup(PVBOXCLIPBOARDFILEHDR pFileHdr)545 {546 AssertPtrReturn(pFileHdr, NULL);547 548 PVBOXCLIPBOARDFILEHDR pFileHdrDup = (PVBOXCLIPBOARDFILEHDR)RTMemAllocZ(sizeof(VBOXCLIPBOARDFILEHDR));549 if (pFileHdrDup)550 {551 *pFileHdrDup = *pFileHdr;552 553 if (pFileHdr->pszFilePath)554 {555 pFileHdrDup->pszFilePath = RTStrDup(pFileHdr->pszFilePath);556 if (pFileHdrDup->pszFilePath)557 pFileHdrDup->cbFilePath = pFileHdrDup->cbFilePath;558 }559 }560 561 return pFileHdrDup;562 }563 564 /**565 * Returns whether a given clipboard file header is valid or not.566 *567 * @returns \c true if valid, \c false if not.568 * @param pFileHdr Clipboard file header to validate.569 * @param pListHdr Data header to use for validation.570 */571 bool SharedClipboardURIFileHdrIsValid(PVBOXCLIPBOARDFILEHDR pFileHdr, PVBOXCLIPBOARDLISTHDR pListHdr)572 {573 if ( !pFileHdr->cbFilePath574 || pFileHdr->cbFilePath > RTPATH_MAX)575 return false;576 577 if (!RTStrIsValidEncoding(pFileHdr->pszFilePath))578 return false;579 580 if (pFileHdr->cbSize > pListHdr->cbTotalSize)581 return false;582 583 return true;584 }585 586 /**587 * Destroys a VBOXCLIPBOARDFILEDATA structure.588 *589 * @param pFileData VBOXCLIPBOARDFILEDATA structure to destroy.590 */591 void SharedClipboardURIFileDataDestroy(PVBOXCLIPBOARDFILEDATA pFileData)592 {593 if (!pFileData)594 return;595 596 if (pFileData->pvData)597 {598 Assert(pFileData->cbData);599 RTMemFree(pFileData->pvData);600 pFileData->pvData = NULL;601 }602 }603 604 /**605 * Duplicates (allocates) a VBOXCLIPBOARDFILEDATA structure.606 *607 * @returns Duplicated VBOXCLIPBOARDFILEDATA structure on success.608 * @param pFileData VBOXCLIPBOARDFILEDATA to duplicate.609 */610 PVBOXCLIPBOARDFILEDATA SharedClipboardURIFileDataDup(PVBOXCLIPBOARDFILEDATA pFileData)611 {612 AssertPtrReturn(pFileData, NULL);613 614 PVBOXCLIPBOARDFILEDATA pFileDataDup = (PVBOXCLIPBOARDFILEDATA)RTMemAllocZ(sizeof(VBOXCLIPBOARDFILEDATA));615 if (pFileDataDup)616 {617 *pFileDataDup = *pFileData;618 619 if (pFileData->pvData)620 {621 pFileDataDup->pvData = RTMemDup(pFileData->pvData, pFileData->cbData);622 if (pFileDataDup->pvData)623 pFileDataDup->cbData = pFileDataDup->cbData;624 }625 626 if (pFileData->pvChecksum)627 {628 pFileDataDup->pvChecksum = RTMemDup(pFileData->pvChecksum, pFileData->cbChecksum);629 if (pFileDataDup->pvChecksum)630 pFileDataDup->cbChecksum = pFileData->cbChecksum;631 }632 }633 634 return pFileDataDup;635 }636 637 /**638 * Returns whether given clipboard file data is valid or not.639 *640 * @returns \c true if valid, \c false if not.641 * @param pFileData Clipboard file data to validate.642 * @param pListHdr Data header to use for validation.643 */644 bool SharedClipboardURIFileDataIsValid(PVBOXCLIPBOARDFILEDATA pFileData, PVBOXCLIPBOARDLISTHDR pListHdr)645 {646 RT_NOREF(pFileData, pListHdr);647 return true;648 }649 #endif650 464 651 465 /** … … 806 620 } 807 621 622 /** 623 * Creates a new list handle (local only). 624 * 625 * @returns New List handle on success, or SHAREDCLIPBOARDLISTHANDLE_INVALID on error. 626 * @param pTransfer URI clipboard transfer to create new list handle for. 627 */ 808 628 static SHAREDCLIPBOARDLISTHANDLE sharedClipboardURITransferListHandleNew(PSHAREDCLIPBOARDURITRANSFER pTransfer) 809 629 { … … 813 633 } 814 634 635 /** 636 * Opens a list. 637 * 638 * @returns VBox status code. 639 * @param pTransfer URI clipboard transfer to handle. 640 * @param pOpenParms List open parameters to use for opening. 641 * @param phList Where to store the List handle of opened list on success. 642 */ 815 643 int SharedClipboardURITransferListOpen(PSHAREDCLIPBOARDURITRANSFER pTransfer, PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, 816 644 PSHAREDCLIPBOARDLISTHANDLE phList) … … 830 658 if (pInfo) 831 659 { 832 if ( !pOpenParms->pszPath833 || !strlen(pOpenParms->pszPath))834 RTStrAPrintf(&pOpenParms->pszPath, "C:\\Temp"); /** @todo FIX !!!! */835 836 660 RTFSOBJINFO objInfo; 837 661 rc = RTPathQueryInfo(pOpenParms->pszPath, &objInfo, RTFSOBJATTRADD_NOTHING); … … 842 666 else if (RTFS_IS_FILE(objInfo.Attr.fMode)) 843 667 { 844 rc = RTFileOpen(&pInfo->u.Local.hFile, pOpenParms->pszPath, RTFILE_O_READ | RTFILE_O_DENY_WRITE); 668 rc = RTFileOpen(&pInfo->u.Local.hFile, pOpenParms->pszPath, 669 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE); 845 670 } 846 671 else if (RTFS_IS_SYMLINK(objInfo.Attr.fMode)) … … 902 727 } 903 728 729 /** 730 * Closes a list. 731 * 732 * @returns VBox status code. 733 * @param pTransfer URI clipboard transfer to handle. 734 * @param hList Handle of list to close. 735 */ 904 736 int SharedClipboardURITransferListClose(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList) 905 737 { … … 943 775 } 944 776 777 /** 778 * Adds a file to a list heaer. 779 * 780 * @returns VBox status code. 781 * @param pHdr List header to add file to. 782 * @param pszPath Path of file to add. 783 */ 945 784 static int sharedClipboardURITransferListHdrAddFile(PVBOXCLIPBOARDLISTHDR pHdr, const char *pszPath) 946 785 { … … 957 796 } 958 797 798 /** 799 * Builds a list header, internal version. 800 * 801 * @returns VBox status code. 802 * @param pHdr Where to store the build list header. 803 * @param pcszSrcPath Source path of list. 804 * @param pcszDstPath Destination path of list. 805 * @param pcszDstBase Destination base path. 806 * @param cchDstBase Number of charaters of destination base path. 807 */ 959 808 static int sharedClipboardURITransferListHdrFromDir(PVBOXCLIPBOARDLISTHDR pHdr, 960 809 const char *pcszSrcPath, const char *pcszDstPath, … … 1067 916 } 1068 917 918 /** 919 * Retrieves the header of a Shared Clipboard list. 920 * 921 * @returns VBox status code. 922 * @param pTransfer URI clipboard transfer to handle. 923 * @param hList Handle of list to get header for. 924 * @param pHdr Where to store the returned list header information. 925 */ 1069 926 int SharedClipboardURITransferListGetHeader(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList, 1070 927 PVBOXCLIPBOARDLISTHDR pHdr) … … 1174 1031 } 1175 1032 1033 /** 1034 * Reads a single Shared Clipboard list entry. 1035 * 1036 * @returns VBox status code. 1037 * @param pTransfer URI clipboard transfer to handle. 1038 * @param hList List handle of list to read from. 1039 * @param pEntry Where to store the read information. 1040 */ 1176 1041 int SharedClipboardURITransferListRead(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList, 1177 1042 PVBOXCLIPBOARDLISTENTRY pEntry) … … 1192 1057 AssertPtr(pInfo); 1193 1058 1059 LogFlowFunc(("\tfMode=%RU32, pszPath=%s\n", pInfo->fMode, pInfo->OpenParms.pszPath)); 1060 1194 1061 if (RTFS_IS_DIRECTORY(pInfo->fMode)) 1195 1062 { 1196 size_t cbDirEntry = 0; 1197 PRTDIRENTRYEX pDirEntry = NULL; 1198 rc = RTDirReadExA(pInfo->u.Local.hDirRoot, &pDirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK); 1199 if (RT_SUCCESS(rc)) 1063 for (;;) 1200 1064 { 1201 switch (pDirEntry->Info.Attr.fMode & RTFS_TYPE_MASK) 1065 bool fSkipEntry = false; /* Whether to skip an entry in the enumeration. */ 1066 1067 size_t cbDirEntry = 0; 1068 PRTDIRENTRYEX pDirEntry = NULL; 1069 rc = RTDirReadExA(pInfo->u.Local.hDirRoot, &pDirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK); 1070 if (RT_SUCCESS(rc)) 1202 1071 { 1203 case RTFS_TYPE_DIRECTORY:1072 switch (pDirEntry->Info.Attr.fMode & RTFS_TYPE_MASK) 1204 1073 { 1205 /* Skip "." and ".." entries. */ 1206 if (RTDirEntryExIsStdDotLink(pDirEntry)) 1074 case RTFS_TYPE_DIRECTORY: 1075 { 1076 LogFlowFunc(("Directory: %s\n", pDirEntry->szName)); 1077 1078 /* Skip "." and ".." entries. */ 1079 if (RTDirEntryExIsStdDotLink(pDirEntry)) 1080 fSkipEntry = true; 1081 1082 RT_FALL_THROUGH(); 1083 } 1084 1085 case RTFS_TYPE_FILE: 1086 { 1087 LogFlowFunc(("File: %s\n", pDirEntry->szName)); 1088 1089 pEntry->pvInfo = (PSHAREDCLIPBOARDFSOBJINFO)RTMemAlloc(sizeof(SHAREDCLIPBOARDFSOBJINFO)); 1090 if (pEntry->pvInfo) 1091 { 1092 rc = RTStrCopy(pEntry->pszName, pEntry->cbName, pDirEntry->szName); 1093 if (RT_SUCCESS(rc)) 1094 { 1095 SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &pDirEntry->Info); 1096 1097 pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO); 1098 pEntry->fInfo = VBOX_SHAREDCLIPBOARD_INFO_FLAG_FSOBJINFO; 1099 } 1100 } 1101 else 1102 rc = VERR_NO_MEMORY; 1207 1103 break; 1208 1209 RT_FALL_THROUGH(); 1104 } 1105 1106 case RTFS_TYPE_SYMLINK: 1107 { 1108 /** @todo Not implemented yet. */ 1109 break; 1110 } 1111 1112 default: 1113 break; 1210 1114 } 1211 1115 1212 case RTFS_TYPE_FILE: 1213 { 1214 pEntry->pvInfo = (PSHAREDCLIPBOARDFSOBJINFO)RTMemAlloc(sizeof(SHAREDCLIPBOARDFSOBJINFO)); 1215 if (pEntry->pvInfo) 1216 { 1217 SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &pDirEntry->Info); 1218 1219 pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO); 1220 pEntry->fInfo = 0; /** @todo Implement. */ 1221 } 1222 else 1223 rc = VERR_NO_MEMORY; 1224 break; 1225 } 1226 1227 case RTFS_TYPE_SYMLINK: 1228 { 1229 /** @todo Not implemented yet. */ 1230 break; 1231 } 1232 1233 default: 1234 break; 1116 RTDirReadExAFree(&pDirEntry, &cbDirEntry); 1235 1117 } 1236 1118 1237 RTDirReadExAFree(&pDirEntry, &cbDirEntry); 1119 if ( !fSkipEntry /* Do we have a valid entry? Bail out. */ 1120 || RT_FAILURE(rc)) 1121 { 1122 break; 1123 } 1238 1124 } 1239 1125 } 1240 1126 else if (RTFS_IS_FILE(pInfo->fMode)) 1241 1127 { 1128 LogFlowFunc(("\tSingle file: %s\n", pInfo->OpenParms.pszPath)); 1129 1242 1130 RTFSOBJINFO objInfo; 1243 1131 rc = RTFileQueryInfo(pInfo->u.Local.hFile, &objInfo, RTFSOBJATTRADD_NOTHING); … … 1247 1135 if (pEntry->pvInfo) 1248 1136 { 1249 SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &objInfo); 1250 1251 pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO); 1252 pEntry->fInfo = 0; /** @todo Implement. */ 1137 rc = RTStrCopy(pEntry->pszName, pEntry->cbName, pInfo->OpenParms.pszPath); 1138 if (RT_SUCCESS(rc)) 1139 { 1140 SharedClipboardFsObjFromIPRT(PSHAREDCLIPBOARDFSOBJINFO(pEntry->pvInfo), &objInfo); 1141 1142 pEntry->cbInfo = sizeof(SHAREDCLIPBOARDFSOBJINFO); 1143 pEntry->fInfo = VBOX_SHAREDCLIPBOARD_INFO_FLAG_FSOBJINFO; 1144 } 1253 1145 } 1254 1146 else … … 1294 1186 } 1295 1187 1188 /** 1189 * Returns whether a given list handle is valid or not. 1190 * 1191 * @returns \c true if list handle is valid, \c false if not. 1192 * @param pTransfer URI clipboard transfer to handle. 1193 * @param hList List handle to check. 1194 */ 1296 1195 bool SharedClipboardURITransferListHandleIsValid(PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDLISTHANDLE hList) 1297 1196 { … … 1373 1272 } 1374 1273 1274 int SharedClipboardURILTransferSetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, const char *pszRoots, size_t cbRoots) 1275 { 1276 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 1277 AssertPtrReturn(pszRoots, VERR_INVALID_POINTER); 1278 AssertReturn(cbRoots, VERR_INVALID_PARAMETER); 1279 1280 if (!RTStrIsValidEncoding(pszRoots)) 1281 return VERR_INVALID_PARAMETER; 1282 1283 int rc = VINF_SUCCESS; 1284 1285 pTransfer->lstRootEntries.clear(); 1286 1287 pTransfer->lstRootEntries = RTCString(pszRoots, cbRoots - 1).split("\r\n"); 1288 1289 LogFlowFunc(("cRoots=%RU32\n", pTransfer->lstRootEntries.size())); 1290 1291 LogFlowFuncLeaveRC(rc); 1292 return rc; 1293 } 1294 1375 1295 /** 1376 1296 * Resets an clipboard URI transfer. … … 1398 1318 1399 1319 return pTransfer->pArea; 1320 } 1321 1322 int SharedClipboardURILTransferGetRoots(PSHAREDCLIPBOARDURITRANSFER pTransfer, char **ppszRoots, uint32_t *pcRoots) 1323 { 1324 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 1325 AssertPtrReturn(ppszRoots, VERR_INVALID_POINTER); 1326 1327 int rc = VINF_SUCCESS; 1328 1329 if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_LOCAL) 1330 { 1331 char *pszRoots = NULL; 1332 1333 for (size_t i = 0; i < pTransfer->lstRootEntries.size(); ++i) 1334 { 1335 if (pszRoots) 1336 rc = RTStrAAppend(&pszRoots, "\r\n"); 1337 if (RT_SUCCESS(rc)) 1338 rc = RTStrAAppend(&pszRoots, pTransfer->lstRootEntries.at(i).c_str()); 1339 1340 if (RT_FAILURE(rc)) 1341 break; 1342 } 1343 1344 if (RT_SUCCESS(rc)) 1345 { 1346 LogFlowFunc(("Roots (%RU32):\n%s\n", pTransfer->lstRootEntries.size(), pszRoots)); 1347 1348 *ppszRoots = pszRoots; 1349 *pcRoots = (uint32_t)pTransfer->lstRootEntries.size(); 1350 } 1351 else 1352 { 1353 if (pszRoots) 1354 RTStrFree(pszRoots); 1355 } 1356 } 1357 else if (pTransfer->State.enmSource == SHAREDCLIPBOARDSOURCE_REMOTE) 1358 { 1359 if (pTransfer->ProviderIface.pfnGetRoots) 1360 rc = pTransfer->ProviderIface.pfnGetRoots(&pTransfer->ProviderCtx, ppszRoots, pcRoots); 1361 else 1362 rc = VERR_NOT_SUPPORTED; 1363 } 1364 1365 LogFlowFuncLeaveRC(rc); 1366 return rc; 1400 1367 } 1401 1368 … … 1537 1504 } 1538 1505 else 1539 rc = V ERR_ALREADY_EXISTS;1506 rc = VINF_SUCCESS; 1540 1507 1541 1508 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r79497 r79672 1030 1030 LogRel(("Shared Clipboard: Adding guest file '%s'\n", pszFileUtf8)); 1031 1031 1032 #if 0 1033 char *pszFileURI; 1034 uint32_t cchFileURI; 1035 rc = SharedClipboardMetaDataConvertToFormat(pszFileUtf8, strlen(pszFileUtf8), SHAREDCLIPBOARDMETADATAFMT_URI_LIST, 1036 (void **)&pszFileURI, &cchFileURI); 1037 if (RT_SUCCESS(rc)) 1038 { 1039 LogFlowFunc(("\tURI is: %s (%RU32)\n", pszFileURI, cchFileURI)); 1040 1041 rc = RTStrAAppendExN(&pszFiles, 1 /* cPairs */, pszFileURI, cchFileURI); 1042 if (RT_SUCCESS(rc)) 1043 cchFiles += cchFileURI; 1044 1045 RTStrFree(pszFileURI); 1046 } 1047 #endif 1032 rc = RTStrAAppendExN(&pszFiles, 1 /* cPairs */, pszFileUtf8, strlen(pszFileUtf8)); 1033 cchFiles += (uint32_t)strlen(pszFileUtf8); 1048 1034 } 1049 1035 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-uri.cpp
r79630 r79672 73 73 } 74 74 75 DECLCALLBACK(int) vboxSvcClipboardURIGetRoots(PSHAREDCLIPBOARDPROVIDERCTX pCtx, 76 char **ppapszRoots, uint32_t *pcRoots) 77 { 78 LogFlowFuncEnter(); 79 80 PVBOXCLIPBOARDCLIENT pClient = (PVBOXCLIPBOARDCLIENT)pCtx->pvUser; 81 AssertPtr(pClient); 82 83 int rc; 84 85 size_t cbRootsRecv = 0; 86 87 char *pszRoots = NULL; 88 uint32_t cRoots = 0; 89 90 /* There might be more than one message needed for retrieving all root items. */ 91 for (;;) 92 { 93 PVBOXCLIPBOARDCLIENTMSG pMsg = vboxSvcClipboardMsgAlloc(VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOTS, 94 VBOX_SHARED_CLIPBOARD_CPARMS_ROOTS); 95 if (pMsg) 96 { 97 HGCMSvcSetU32(&pMsg->m_paParms[0], 0 /* uContextID */); 98 HGCMSvcSetU32(&pMsg->m_paParms[1], 0 /* fRoots */); 99 HGCMSvcSetU32(&pMsg->m_paParms[2], 0 /* fMore */); 100 HGCMSvcSetU32(&pMsg->m_paParms[3], 0 /* cRoots */); 101 102 uint32_t cbData = _64K; 103 void *pvData = RTMemAlloc(cbData); 104 AssertPtrBreakStmt(pvData, rc = VERR_NO_MEMORY); 105 106 HGCMSvcSetU32(&pMsg->m_paParms[4], cbData); 107 HGCMSvcSetPv (&pMsg->m_paParms[5], pvData, cbData); 108 109 rc = vboxSvcClipboardMsgAdd(pClient->pData, pMsg, true /* fAppend */); 110 if (RT_SUCCESS(rc)) 111 { 112 int rc2 = SharedClipboardURITransferEventRegister(pCtx->pTransfer, 113 SHAREDCLIPBOARDURITRANSFEREVENTTYPE_GET_ROOTS); 114 AssertRC(rc2); 115 116 vboxSvcClipboardClientWakeup(pClient); 117 } 118 } 119 else 120 rc = VERR_NO_MEMORY; 121 122 if (RT_SUCCESS(rc)) 123 { 124 PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload; 125 rc = SharedClipboardURITransferEventWait(pCtx->pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_GET_ROOTS, 126 30 * 1000 /* Timeout in ms */, &pPayload); 127 if (RT_SUCCESS(rc)) 128 { 129 PVBOXCLIPBOARDROOTS pRoots = (PVBOXCLIPBOARDROOTS)pPayload->pvData; 130 Assert(pPayload->cbData == sizeof(VBOXCLIPBOARDROOTS)); 131 132 LogFlowFunc(("cbRoots=%RU32, fRoots=%RU32, fMore=%RTbool\n", pRoots->cbRoots, pRoots->fRoots, pRoots->fMore)); 133 134 if (!pRoots->cbRoots) 135 break; 136 AssertPtr(pRoots->pszRoots); 137 138 if (pszRoots == NULL) 139 pszRoots = (char *)RTMemDup((void *)pRoots->pszRoots, pRoots->cbRoots); 140 else 141 pszRoots = (char *)RTMemRealloc(pszRoots, cbRootsRecv + pRoots->cbRoots); 142 143 AssertPtrBreakStmt(pszRoots, rc = VERR_NO_MEMORY); 144 145 cbRootsRecv += pRoots->cbRoots; 146 147 if (cbRootsRecv > _32M) /* Don't allow more than 32MB root entries for now. */ 148 { 149 rc = VERR_ALLOCATION_TOO_BIG; /** @todo Find a better rc. */ 150 break; 151 } 152 153 cRoots += pRoots->cRoots; 154 155 const bool fDone = !RT_BOOL(pRoots->fMore); /* More root entries to be retrieved? Otherwise bail out. */ 156 157 SharedClipboardURITransferPayloadFree(pPayload); 158 159 if (fDone) 160 break; 161 } 162 } 163 164 if (RT_FAILURE(rc)) 165 break; 166 } 167 168 if (RT_SUCCESS(rc)) 169 { 170 LogFlowFunc(("cRoots=%RU32\n", cRoots)); 171 172 *ppapszRoots = pszRoots; 173 *pcRoots = cRoots; 174 } 175 else 176 { 177 RTMemFree(pszRoots); 178 pszRoots = NULL; 179 } 180 181 LogFlowFuncLeave(); 182 return rc; 183 } 184 75 185 DECLCALLBACK(int) vboxSvcClipboardURIListOpen(PSHAREDCLIPBOARDPROVIDERCTX pCtx, 76 186 PVBOXCLIPBOARDLISTOPENPARMS pOpenParms, PSHAREDCLIPBOARDLISTHANDLE phList) … … 403 513 break; 404 514 } 515 } 516 } 517 else 518 rc = VERR_INVALID_PARAMETER; 519 520 LogFlowFuncLeaveRC(rc); 521 return rc; 522 } 523 524 int VBoxSvcClipboardURIGetRoots(uint32_t cParms, VBOXHGCMSVCPARM paParms[], 525 PVBOXCLIPBOARDROOTS pRoots) 526 { 527 int rc; 528 529 if (cParms == VBOX_SHARED_CLIPBOARD_CPARMS_ROOTS) 530 { 531 /* Note: Context ID (paParms[0]) not used yet. */ 532 rc = HGCMSvcGetU32(&paParms[1], &pRoots->fRoots); 533 if (RT_SUCCESS(rc)) 534 { 535 uint32_t fMore; 536 rc = HGCMSvcGetU32(&paParms[2], &fMore); 537 if (RT_SUCCESS(rc)) 538 pRoots->fMore = RT_BOOL(fMore); 539 } 540 if (RT_SUCCESS(rc)) 541 rc = HGCMSvcGetU32(&paParms[3], &pRoots->cRoots); 542 if (RT_SUCCESS(rc)) 543 { 544 uint32_t cbRoots; 545 rc = HGCMSvcGetU32(&paParms[4], &cbRoots); 546 if (RT_SUCCESS(rc)) 547 rc = HGCMSvcGetPv(&paParms[5], (void **)&pRoots->pszRoots, &pRoots->cbRoots); 548 549 AssertReturn(cbRoots == pRoots->cbRoots, VERR_INVALID_PARAMETER); 405 550 } 406 551 } … … 582 727 rc = HGCMSvcGetU32(&paParms[2], &pListEntry->fInfo); 583 728 if (RT_SUCCESS(rc)) 584 rc = HGCMSvcGetU32(&paParms[3], &pListEntry->cbInfo); 585 if (RT_SUCCESS(rc)) 586 rc = HGCMSvcGetPv(&paParms[4], &pListEntry->pvInfo, &pListEntry->cbInfo); 729 rc = HGCMSvcGetPv(&paParms[3], (void **)&pListEntry->pszName, &pListEntry->cbName); 730 if (RT_SUCCESS(rc)) 731 { 732 uint32_t cbInfo; 733 rc = HGCMSvcGetU32(&paParms[4], &cbInfo); 734 if (RT_SUCCESS(rc)) 735 { 736 rc = HGCMSvcGetPv(&paParms[5], &pListEntry->pvInfo, &pListEntry->cbInfo); 737 AssertReturn(cbInfo == pListEntry->cbInfo, VERR_INVALID_PARAMETER); 738 } 739 } 587 740 588 741 if (RT_SUCCESS(rc)) … … 846 999 if (enmDir == SHAREDCLIPBOARDURITRANSFERDIR_READ) 847 1000 { 1001 creationCtx.Interface.pfnGetRoots = vboxSvcClipboardURIGetRoots; 848 1002 creationCtx.Interface.pfnListHdrRead = vboxSvcClipboardURIListHdrRead; 849 1003 creationCtx.Interface.pfnListEntryRead = vboxSvcClipboardURIListEntryRead; … … 921 1075 { 922 1076 rc = VBoxSvcClipboardURITransferHandleReply(pClient, pTransfer, cParms, paParms); 1077 break; 1078 } 1079 1080 case VBOX_SHARED_CLIPBOARD_GUEST_FN_ROOTS: 1081 { 1082 VBOXCLIPBOARDROOTS Roots; 1083 rc = VBoxSvcClipboardURIGetRoots(cParms, paParms, &Roots); 1084 if (RT_SUCCESS(rc)) 1085 { 1086 void *pvData = SharedClipboardURIRootsDup(&Roots); 1087 uint32_t cbData = sizeof(VBOXCLIPBOARDROOTS); 1088 1089 PSHAREDCLIPBOARDURITRANSFERPAYLOAD pPayload; 1090 rc = SharedClipboardURITransferPayloadAlloc(SHAREDCLIPBOARDURITRANSFEREVENTTYPE_GET_ROOTS, 1091 pvData, cbData, &pPayload); 1092 if (RT_SUCCESS(rc)) 1093 rc = SharedClipboardURITransferEventSignal(pTransfer, SHAREDCLIPBOARDURITRANSFEREVENTTYPE_GET_ROOTS, 1094 pPayload); 1095 } 923 1096 break; 924 1097 } -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r79632 r79672 507 507 * Return information about the first message if one is pending in the list. 508 508 */ 509 PVBOXCLIPBOARDCLIENTMSG pFirstMsg = pClient->pData->queueMsg.first(); 510 if (pFirstMsg) 511 { 512 LogFlowFunc(("First message is: %RU32 %s (%RU32 parms)\n", 513 pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg), pFirstMsg->m_cParms)); 514 515 ASSERT_GUEST_MSG_RETURN(pFirstMsg->m_uMsg == idMsgExpected || idMsgExpected == UINT32_MAX, 516 ("idMsg=%u (%s) cParms=%u, caller expected %u (%s) and %u\n", 517 pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg), pFirstMsg->m_uMsg, 518 idMsgExpected, VBoxSvcClipboardHostMsgToStr(idMsgExpected), cParms), 519 VERR_MISMATCH); 520 ASSERT_GUEST_MSG_RETURN(pFirstMsg->m_cParms == cParms, 521 ("idMsg=%u (%s) cParms=%u, caller expected %u (%s) and %u\n", 522 pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg), pFirstMsg->m_cParms, 523 idMsgExpected, VBoxSvcClipboardHostMsgToStr(idMsgExpected), cParms), 524 VERR_WRONG_PARAMETER_COUNT); 525 526 /* Check the parameter types. */ 527 for (uint32_t i = 0; i < cParms; i++) 528 ASSERT_GUEST_MSG_RETURN(pFirstMsg->m_paParms[i].type == paParms[i].type, 529 ("param #%u: type %u, caller expected %u (idMsg=%u %s)\n", i, pFirstMsg->m_paParms[i].type, 530 paParms[i].type, pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg)), 531 VERR_WRONG_PARAMETER_TYPE); 532 /* 533 * Copy out the parameters. 534 * 535 * No assertions on buffer overflows, and keep going till the end so we can 536 * communicate all the required buffer sizes. 537 */ 538 int rc = VINF_SUCCESS; 539 for (uint32_t i = 0; i < cParms; i++) 540 switch (pFirstMsg->m_paParms[i].type) 541 { 542 case VBOX_HGCM_SVC_PARM_32BIT: 543 paParms[i].u.uint32 = pFirstMsg->m_paParms[i].u.uint32; 544 break; 545 546 case VBOX_HGCM_SVC_PARM_64BIT: 547 paParms[i].u.uint64 = pFirstMsg->m_paParms[i].u.uint64; 548 break; 549 550 case VBOX_HGCM_SVC_PARM_PTR: 509 if (!pClient->pData->queueMsg.isEmpty()) 510 { 511 PVBOXCLIPBOARDCLIENTMSG pFirstMsg = pClient->pData->queueMsg.first(); 512 if (pFirstMsg) 513 { 514 LogFlowFunc(("First message is: %RU32 %s (%RU32 parms)\n", 515 pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg), pFirstMsg->m_cParms)); 516 517 ASSERT_GUEST_MSG_RETURN(pFirstMsg->m_uMsg == idMsgExpected || idMsgExpected == UINT32_MAX, 518 ("idMsg=%u (%s) cParms=%u, caller expected %u (%s) and %u\n", 519 pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg), pFirstMsg->m_cParms, 520 idMsgExpected, VBoxSvcClipboardHostMsgToStr(idMsgExpected), cParms), 521 VERR_MISMATCH); 522 ASSERT_GUEST_MSG_RETURN(pFirstMsg->m_cParms == cParms, 523 ("idMsg=%u (%s) cParms=%u, caller expected %u (%s) and %u\n", 524 pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg), pFirstMsg->m_cParms, 525 idMsgExpected, VBoxSvcClipboardHostMsgToStr(idMsgExpected), cParms), 526 VERR_WRONG_PARAMETER_COUNT); 527 528 /* Check the parameter types. */ 529 for (uint32_t i = 0; i < cParms; i++) 530 ASSERT_GUEST_MSG_RETURN(pFirstMsg->m_paParms[i].type == paParms[i].type, 531 ("param #%u: type %u, caller expected %u (idMsg=%u %s)\n", i, pFirstMsg->m_paParms[i].type, 532 paParms[i].type, pFirstMsg->m_uMsg, VBoxSvcClipboardHostMsgToStr(pFirstMsg->m_uMsg)), 533 VERR_WRONG_PARAMETER_TYPE); 534 /* 535 * Copy out the parameters. 536 * 537 * No assertions on buffer overflows, and keep going till the end so we can 538 * communicate all the required buffer sizes. 539 */ 540 int rc = VINF_SUCCESS; 541 for (uint32_t i = 0; i < cParms; i++) 542 switch (pFirstMsg->m_paParms[i].type) 551 543 { 552 uint32_t const cbSrc = pFirstMsg->m_paParms[i].u.pointer.size; 553 uint32_t const cbDst = paParms[i].u.pointer.size; 554 paParms[i].u.pointer.size = cbSrc; /** @todo Check if this is safe in other layers... 555 * Update: Safe, yes, but VMMDevHGCM doesn't pass it along. */ 556 if (cbSrc <= cbDst) 557 memcpy(paParms[i].u.pointer.addr, pFirstMsg->m_paParms[i].u.pointer.addr, cbSrc); 558 else 559 rc = VERR_BUFFER_OVERFLOW; 560 break; 544 case VBOX_HGCM_SVC_PARM_32BIT: 545 paParms[i].u.uint32 = pFirstMsg->m_paParms[i].u.uint32; 546 break; 547 548 case VBOX_HGCM_SVC_PARM_64BIT: 549 paParms[i].u.uint64 = pFirstMsg->m_paParms[i].u.uint64; 550 break; 551 552 case VBOX_HGCM_SVC_PARM_PTR: 553 { 554 uint32_t const cbSrc = pFirstMsg->m_paParms[i].u.pointer.size; 555 uint32_t const cbDst = paParms[i].u.pointer.size; 556 paParms[i].u.pointer.size = cbSrc; /** @todo Check if this is safe in other layers... 557 * Update: Safe, yes, but VMMDevHGCM doesn't pass it along. */ 558 if (cbSrc <= cbDst) 559 memcpy(paParms[i].u.pointer.addr, pFirstMsg->m_paParms[i].u.pointer.addr, cbSrc); 560 else 561 { 562 AssertMsgFailed(("#%u: cbSrc=%RU32 is bigger than cbDst=%RU32\n", i, cbSrc, cbDst)); 563 rc = VERR_BUFFER_OVERFLOW; 564 } 565 break; 566 } 567 568 default: 569 AssertMsgFailed(("#%u: %u\n", i, pFirstMsg->m_paParms[i].type)); 570 rc = VERR_INTERNAL_ERROR; 571 break; 561 572 } 562 563 default: 564 AssertMsgFailed(("#%u: %u\n", i, pFirstMsg->m_paParms[i].type)); 565 rc = VERR_INTERNAL_ERROR; 566 break; 573 if (RT_SUCCESS(rc)) 574 { 575 /* 576 * Complete the message and remove the pending message unless the 577 * guest raced us and cancelled this call in the meantime. 578 */ 579 AssertPtr(g_pHelpers); 580 rc = g_pHelpers->pfnCallComplete(hCall, rc); 581 582 LogFlowFunc(("[Client %RU32] pfnCallComplete -> %Rrc\n", pClient->uClientID, rc)); 583 584 if (rc != VERR_CANCELLED) 585 { 586 pClient->pData->queueMsg.removeFirst(); 587 vboxSvcClipboardMsgFree(pFirstMsg); 588 } 589 590 return VINF_HGCM_ASYNC_EXECUTE; /* The caller must not complete it. */ 567 591 } 568 if (RT_SUCCESS(rc)) 569 { 570 /* 571 * Complete the message and remove the pending message unless the 572 * guest raced us and cancelled this call in the meantime. 573 */ 574 AssertPtr(g_pHelpers); 575 rc = g_pHelpers->pfnCallComplete(hCall, rc); 576 577 LogFlowFunc(("[Client %RU32] pfnCallComplete -> %Rrc\n", pClient->uClientID, rc)); 578 579 if (rc != VERR_CANCELLED) 580 { 581 pClient->pData->queueMsg.removeFirst(); 582 vboxSvcClipboardMsgFree(pFirstMsg); 583 } 584 585 return VINF_HGCM_ASYNC_EXECUTE; /* The caller must not complete it. */ 592 593 LogFlowFunc(("[Client %RU32] Returning %Rrc\n", pClient->uClientID, rc)); 594 return rc; 586 595 } 587 588 LogFlowFunc(("[Client %RU32] Returning %Rrc\n", pClient->uClientID, rc));589 return rc;590 596 } 591 597 … … 1391 1397 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 1392 1398 rc = vboxSvcClipboardURIHandler(pClient, callHandle, u32Function, cParms, paParms, tsArrival); 1393 if (RT_SUCCESS(rc)) 1394 { 1395 /* The URI handler does deferring on its own. */ 1396 fDefer = true; 1397 } 1399 1400 /* The URI handler does deferring on its own, so never do any call completion here. */ 1401 fDefer = true; 1398 1402 #else 1399 1403 rc = VERR_NOT_IMPLEMENTED;
Note:
See TracChangeset
for help on using the changeset viewer.

