Changeset 87611 in vbox
- Timestamp:
- Feb 4, 2021 4:31:28 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-transfers.h
r87452 r87611 612 612 /** 613 613 * Shared Clipboard transfer provider interface table. 614 * 615 * A transfer provider inteface implementation realizes all low level functions 616 * needed for making a Shared Clipboard transfer happen. 614 617 */ 615 618 typedef struct _SHCLTXPROVIDERIFACE 616 619 { 617 /** Called when the transfer gets initialized. */618 DECLCALLBACKMEMBER(int, pfnInitialize,(PSHCLTXPROVIDERCTX pCtx));619 /** Called before the transfer will be started. */620 DECLCALLBACKMEMBER(int, pfnStart,(PSHCLTXPROVIDERCTX pCtx));621 /** Called when the transfer has been complete. */622 DECLCALLBACKMEMBER(void, pfnCompleted,(PSHCLTXPROVIDERCTX pCtx, int rc));623 /** Called when the transfer has been canceled. */624 DECLCALLBACKMEMBER(void, pfnCanceled,(PSHCLTXPROVIDERCTX pCtx));625 /** Called when transfer resulted in an unrecoverable error. */626 DECLCALLBACKMEMBER(void, pfnError,(PSHCLTXPROVIDERCTX pCtx, int rc));627 /** Called when transfer got registered to a transfer context. */628 DECLCALLBACKMEMBER(void, pfnRegistered,(PSHCLTXPROVIDERCTX pCtx, PSHCLTRANSFERCTX pTransferCtx));629 /** Called when transfer got unregistered from a transfer context. */630 DECLCALLBACKMEMBER(void, pfnUnregistered,(PSHCLTXPROVIDERCTX pCtx, PSHCLTRANSFERCTX pTransferCtx));631 632 620 DECLCALLBACKMEMBER(int, pfnRootsGet,(PSHCLTXPROVIDERCTX pCtx, PSHCLROOTLIST *ppRootList)); 633 621 DECLCALLBACKMEMBER(int, pfnListOpen,(PSHCLTXPROVIDERCTX pCtx, PSHCLLISTOPENPARMS pOpenParms, PSHCLLISTHANDLE phList)); … … 661 649 662 650 /** 651 * Structure maintaining clipboard transfer callback context data. 652 */ 653 typedef struct _SHCLTRANSFERCALLBACKCTX 654 { 655 /** Pointer to the related Shared Clipboard transfer. */ 656 PSHCLTRANSFER pTransfer; 657 /** User-defined data pointer. Can be NULL if not needed. */ 658 void *pvUser; 659 /** Size (in bytes) of data at user pointer. */ 660 size_t cbUser; 661 } SHCLTRANSFERCALLBACKCTX, *PSHCLTRANSFERCALLBACKCTX; 662 663 /** 664 * Shared Clipboard transfer callback table. 665 * 666 * All callbacks are optional and can provide additional information / feedback to a frontend. 667 */ 668 typedef struct _SHCLTRANSFERCALLBACKTABLE 669 { 670 /** 671 * Called when the transfer gets initialized. 672 * 673 * @param pCbCtx Pointer to callback context to use. 674 */ 675 DECLCALLBACKMEMBER(int, pfnOnInitialize,(PSHCLTRANSFERCALLBACKCTX pCbCtx)); 676 /** 677 * Called before the transfer will be started. 678 * 679 * @param pCbCtx Pointer to callback context to use. 680 */ 681 DECLCALLBACKMEMBER(int, pfnOnStart,(PSHCLTRANSFERCALLBACKCTX pCbCtx)); 682 /** 683 * Called when the transfer has been complete. 684 * 685 * @param pCbCtx Pointer to callback context to use. 686 * @param rcCompletion Completion result. 687 * VERR_CANCELED if transfer has been canceled. 688 */ 689 DECLCALLBACKMEMBER(void, pfnOnCompleted,(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcCompletion)); 690 /** 691 * Called when transfer resulted in an unrecoverable error. 692 * 693 * @param pCbCtx Pointer to callback context to use. 694 * @param rcError Error reason, IPRT-style. 695 */ 696 DECLCALLBACKMEMBER(void, pfnOnError,(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcError)); 697 /** 698 * Called when transfer got registered to a transfer context. 699 * 700 * @param pCbCtx Pointer to callback context to use. 701 * @param pTransferCtx Transfer context transfer was registered to. 702 */ 703 DECLCALLBACKMEMBER(void, pfnOnRegistered,(PSHCLTRANSFERCALLBACKCTX pCbCtx, PSHCLTRANSFERCTX pTransferCtx)); 704 /** 705 * Called when transfer got unregistered from a transfer context. 706 * 707 * @param pCbCtx Pointer to callback context to use. 708 * @param pTransferCtx Transfer context transfer was unregistered from. 709 */ 710 DECLCALLBACKMEMBER(void, pfnOnUnregistered,(PSHCLTRANSFERCALLBACKCTX pCbCtx, PSHCLTRANSFERCTX pTransferCtx)); 711 712 /** User-provided callback data. Can be NULL if not used. */ 713 void *pvUser; 714 /** Size (in bytes) of data pointer at \a pvUser. */ 715 size_t cbUser; 716 } SHCLTRANSFERCALLBACKTABLE, *PSHCLTRANSFERCALLBACKTABLE; 717 718 /** 663 719 * Structure for thread-related members for a single Shared Clipboard transfer. 664 720 */ … … 684 740 { 685 741 /** The node member for using this struct in a RTList. */ 686 RTLISTNODE Node;742 RTLISTNODE Node; 687 743 /** The transfer's state (for SSM, later). */ 688 SHCLTRANSFERSTATE State;744 SHCLTRANSFERSTATE State; 689 745 /** Absolute path to root entries. */ 690 char *pszPathRootAbs;746 char *pszPathRootAbs; 691 747 /** Timeout (in ms) for waiting of events. Default is 30s. */ 692 RTMSINTERVAL uTimeoutMs;748 RTMSINTERVAL uTimeoutMs; 693 749 /** Maximum data chunk size (in bytes) to transfer. Default is 64K. */ 694 uint32_t cbMaxChunkSize;750 uint32_t cbMaxChunkSize; 695 751 /** The transfer's own event source. */ 696 SHCLEVENTSOURCE Events;752 SHCLEVENTSOURCE Events; 697 753 /** Current number of concurrent list handles. */ 698 uint32_t cListHandles;754 uint32_t cListHandles; 699 755 /** Maximum number of concurrent list handles. */ 700 uint32_t cMaxListHandles;756 uint32_t cMaxListHandles; 701 757 /** Next upcoming list handle. */ 702 SHCLLISTHANDLE uListHandleNext;758 SHCLLISTHANDLE uListHandleNext; 703 759 /** List of all list handles elated to this transfer. */ 704 RTLISTANCHOR lstList;760 RTLISTANCHOR lstList; 705 761 /** Number of root entries in list. */ 706 uint64_t cRoots;762 uint64_t cRoots; 707 763 /** List of root entries of this transfer. */ 708 RTLISTANCHOR lstRoots;764 RTLISTANCHOR lstRoots; 709 765 /** Current number of concurrent object handles. */ 710 uint32_t cObjHandles;766 uint32_t cObjHandles; 711 767 /** Maximum number of concurrent object handles. */ 712 uint32_t cMaxObjHandles;768 uint32_t cMaxObjHandles; 713 769 /** Next upcoming object handle. */ 714 SHCLOBJHANDLE uObjHandleNext;770 SHCLOBJHANDLE uObjHandleNext; 715 771 /** Map of all objects handles related to this transfer. */ 716 RTLISTANCHOR lstObj;772 RTLISTANCHOR lstObj; 717 773 /** The transfer's own provider context. */ 718 SHCLTXPROVIDERCTX ProviderCtx;774 SHCLTXPROVIDERCTX ProviderCtx; 719 775 /** The transfer's provider interface. */ 720 SHCLTXPROVIDERIFACE ProviderIface; 776 SHCLTXPROVIDERIFACE ProviderIface; 777 /** The transfer's callback context. */ 778 SHCLTRANSFERCALLBACKCTX CallbackCtx; 779 /** The transfer's callback table. */ 780 SHCLTRANSFERCALLBACKTABLE Callbacks; 721 781 /** Opaque pointer to implementation-specific parameters. */ 722 void *pvUser;782 void *pvUser; 723 783 /** Size (in bytes) of implementation-specific parameters. */ 724 size_t cbUser;784 size_t cbUser; 725 785 /** Contains thread-related attributes. */ 726 SHCLTRANSFERTHREAD Thread;786 SHCLTRANSFERTHREAD Thread; 727 787 /** Critical section for serializing access. */ 728 RTCRITSECT CritSect;788 RTCRITSECT CritSect; 729 789 } SHCLTRANSFER, *PSHCLTRANSFER; 730 790 … … 863 923 bool ShClTransferListEntryIsValid(PSHCLLISTENTRY pListEntry); 864 924 925 void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, PSHCLTRANSFERCALLBACKTABLE pCallbacks); 865 926 int ShClTransferSetProviderIface(PSHCLTRANSFER pTransfer, PSHCLTXPROVIDERCREATIONCTX pCreationCtx); 866 927 int ShClTransferRootsSet(PSHCLTRANSFER pTransfer, const char *pszRoots, size_t cbRoots); -
trunk/include/VBox/VBoxGuestLib.h
r87452 r87611 589 589 * This is set by VbglR3ClipboardConnectEx(). */ 590 590 uint32_t cbMaxChunkSize; 591 /** Optional callbacks to invoke. */ 592 SHCLTRANSFERCALLBACKTABLE Callbacks; 591 593 } VBGLR3SHCLTRANSFERCTX; 592 594 /** Pointer to a Shared Clipboard transfer context. */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r87452 r87611 97 97 * Cleanup helper function for transfer callbacks. 98 98 * 99 * @param pData Callback data to cleanup. 99 * @param pTransferCtx Pointer to transfer context that the transfer contains. 100 * @param pTransfer Pointer to transfer to cleanup. 100 101 */ 101 static void vboxClipboardTransferCallbackCleanup(PSHCLT XPROVIDERCTX pCtx)102 static void vboxClipboardTransferCallbackCleanup(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer) 102 103 { 103 104 LogFlowFuncEnter(); 104 105 105 PSHCLTRANSFERCTX pCtx = (PSHCLTRANSFERCTX)pData->pvUser; 106 AssertPtr(pCtx); 107 108 PSHCLTRANSFER pTransfer = pData->pTransfer; 109 AssertPtr(pTransfer); 106 if (!pTransferCtx || !pTransfer) 107 return; 110 108 111 109 if (pTransfer->pvUser) /* SharedClipboardWinTransferCtx */ … … 115 113 } 116 114 117 int rc2 = ShClTransferCtxTransferUnregister(p Ctx, pTransfer->State.uID);115 int rc2 = ShClTransferCtxTransferUnregister(pTransferCtx, pTransfer->State.uID); 118 116 AssertRC(rc2); 119 117 … … 124 122 } 125 123 126 static DECLCALLBACK(int) vboxClipboardOnTransferInitCallback(PSHCLTXPROVIDERCTX pCtx) 127 { 128 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 124 /** @copydoc SHCLTRANSFERCALLBACKTABLE::pfnOnInitialize */ 125 static DECLCALLBACK(int) vboxClipboardOnTransferInitCallback(PSHCLTRANSFERCALLBACKCTX pCbCtx) 126 { 127 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pCbCtx->pvUser; 129 128 AssertPtr(pCtx); 130 129 131 130 LogFlowFunc(("pCtx=%p\n", pCtx)); 132 131 133 RT_NOREF(p Data, pCtx);132 RT_NOREF(pCtx); 134 133 135 134 return VINF_SUCCESS; 136 135 } 137 136 138 static DECLCALLBACK(int) vboxClipboardOnTransferStartCallback(PSHCLTXPROVIDERCTX pCtx) 139 { 140 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 137 /** @copydoc SHCLTRANSFERCALLBACKTABLE::pfnOnStart */ 138 static DECLCALLBACK(int) vboxClipboardOnTransferStartCallback(PSHCLTRANSFERCALLBACKCTX pCbCtx) 139 { 140 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pCbCtx->pvUser; 141 141 AssertPtr(pCtx); 142 Assert(pData->cbUser == sizeof(SHCLCONTEXT)); 143 144 PSHCLTRANSFER pTransfer = pData->pTransfer; 142 143 PSHCLTRANSFER pTransfer = pCbCtx->pTransfer; 145 144 AssertPtr(pTransfer); 146 145 … … 192 191 } 193 192 194 static DECLCALLBACK(void) vboxClipboardOnTransferCompleteCallback(PSHCLTXPROVIDERCTX pCtx, int rc) 195 { 196 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 193 /** @copydoc SHCLTRANSFERCALLBACKTABLE::pfnOnCompleted */ 194 static DECLCALLBACK(void) vboxClipboardOnTransferCompletedCallback(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcCompletion) 195 { 196 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pCbCtx->pvUser; 197 197 AssertPtr(pCtx); 198 198 199 RT_NOREF(pCtx, rc); 200 201 LogFlowFunc(("pCtx=%p, rc=%Rrc\n", pCtx, rc)); 202 203 LogRel2(("Shared Clipboard: Transfer to destination complete\n")); 204 205 vboxClipboardTransferCallbackCleanup(pData); 206 } 207 208 static DECLCALLBACK(void) vboxClipboardOnTransferErrorCallback(PSHCLTXPROVIDERCTX pCtx, int rc) 209 { 210 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pData->pvUser; 199 LogRel2(("Shared Clipboard: Transfer to destination %s\n", 200 rcCompletion == VERR_CANCELLED ? "canceled" : "complete")); 201 202 vboxClipboardTransferCallbackCleanup(&pCtx->TransferCtx, pCbCtx->pTransfer); 203 } 204 205 /** @copydoc SHCLTRANSFERCALLBACKTABLE::pfnOnError */ 206 static DECLCALLBACK(void) vboxClipboardOnTransferErrorCallback(PSHCLTRANSFERCALLBACKCTX pCbCtx, int rcError) 207 { 208 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pCbCtx->pvUser; 211 209 AssertPtr(pCtx); 212 210 213 RT_NOREF(pCtx, rc); 214 215 LogFlowFunc(("pCtx=%p, rc=%Rrc\n", pCtx, rc)); 216 217 LogRel(("Shared Clipboard: Transfer to destination failed with %Rrc\n", rc)); 218 219 vboxClipboardTransferCallbackCleanup(pData); 211 LogRel(("Shared Clipboard: Transfer to destination failed with %Rrc\n", rcError)); 212 213 vboxClipboardTransferCallbackCleanup(&pCtx->TransferCtx, pCbCtx->pTransfer); 220 214 } 221 215 … … 883 877 884 878 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 885 /* Install callbacks. */ 879 /* 880 * Set callbacks. 881 * Those will be registered within VbglR3 when a new transfer gets initialized. 882 */ 886 883 RT_ZERO(pCtx->CmdCtx.Transfers.Callbacks); 887 884 … … 889 886 pCtx->CmdCtx.Transfers.Callbacks.cbUser = sizeof(SHCLCONTEXT); 890 887 891 pCtx->CmdCtx.Transfers.Callbacks.pfn TransferInitialize = vboxClipboardOnTransferInitCallback;892 pCtx->CmdCtx.Transfers.Callbacks.pfn TransferStart = vboxClipboardOnTransferStartCallback;893 pCtx->CmdCtx.Transfers.Callbacks.pfn TransferComplete = vboxClipboardOnTransferCompleteCallback;894 pCtx->CmdCtx.Transfers.Callbacks.pfn TransferError = vboxClipboardOnTransferErrorCallback;888 pCtx->CmdCtx.Transfers.Callbacks.pfnOnInitialize = vboxClipboardOnTransferInitCallback; 889 pCtx->CmdCtx.Transfers.Callbacks.pfnOnStart = vboxClipboardOnTransferStartCallback; 890 pCtx->CmdCtx.Transfers.Callbacks.pfnOnCompleted = vboxClipboardOnTransferCompletedCallback; 891 pCtx->CmdCtx.Transfers.Callbacks.pfnOnError = vboxClipboardOnTransferErrorCallback; 895 892 #endif 896 893 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r87452 r87611 1803 1803 if (RT_SUCCESS(rc)) 1804 1804 { 1805 ShClTransferSetCallbacks(pTransfer, &pCmdCtx->Transfers.Callbacks); 1806 1805 1807 rc = ShClTransferInit(pTransfer, enmDir, enmSource); 1806 1808 if (RT_SUCCESS(rc)) -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
r87452 r87611 353 353 354 354 PSHCLROOTLIST pRootList; 355 rc = ShClTransferRootsGet(pTransfer, &pRootList);355 int rc = ShClTransferRootsGet(pTransfer, &pRootList); 356 356 if (RT_SUCCESS(rc)) 357 357 { … … 967 967 logFormat(pFormatEtc->cfFormat); 968 968 } 969 -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp
r87452 r87611 1267 1267 pTransfer->uObjHandleNext = 1; 1268 1268 1269 if (pTransfer-> ProviderIface.pfnInitialize)1270 rc = pTransfer-> ProviderIface.pfnInitialize(&pTransfer->ProviderCtx);1269 if (pTransfer->Callbacks.pfnOnInitialize) 1270 rc = pTransfer->Callbacks.pfnOnInitialize(&pTransfer->CallbackCtx); 1271 1271 } 1272 1272 … … 2016 2016 2017 2017 /** 2018 * Sets or unsets the callback table to be used for a Shared Clipboard transfer. 2019 * 2020 * @returns VBox status code. 2021 * @param pTransfer Clipboard transfer to set callbacks for. 2022 * @param pCallbacks Pointer to callback table to set. 2023 */ 2024 void ShClTransferSetCallbacks(PSHCLTRANSFER pTransfer, 2025 PSHCLTRANSFERCALLBACKTABLE pCallbacks) 2026 { 2027 AssertPtrReturnVoid(pTransfer); 2028 AssertPtrReturnVoid(pCallbacks); 2029 2030 LogFlowFunc(("pCallbacks=%p\n", pCallbacks)); 2031 2032 #define SET_CALLBACK(a_pfnCallback) \ 2033 if (pCallbacks->a_pfnCallback) \ 2034 pTransfer->Callbacks.a_pfnCallback = pCallbacks->a_pfnCallback 2035 2036 SET_CALLBACK(pfnOnInitialize); 2037 SET_CALLBACK(pfnOnStart); 2038 SET_CALLBACK(pfnOnCompleted); 2039 SET_CALLBACK(pfnOnError); 2040 SET_CALLBACK(pfnOnRegistered); 2041 SET_CALLBACK(pfnOnUnregistered); 2042 2043 #undef SET_CALLBACK 2044 2045 pTransfer->Callbacks.pvUser = pCallbacks->pvUser; 2046 pTransfer->Callbacks.cbUser = pCallbacks->cbUser; 2047 } 2048 2049 /** 2018 2050 * Sets the transfer provider interface for a given transfer. 2019 2051 * … … 2484 2516 int rc; 2485 2517 2486 if (pTransfer-> ProviderIface.pfnStart)2487 { 2488 rc = pTransfer-> ProviderIface.pfnStart(&pTransfer->ProviderCtx);2518 if (pTransfer->Callbacks.pfnOnStart) 2519 { 2520 rc = pTransfer->Callbacks.pfnOnStart(&pTransfer->CallbackCtx); 2489 2521 } 2490 2522 else … … 2788 2820 pTransferCtx->cTransfers++; 2789 2821 2790 if (pTransfer-> ProviderIface.pfnRegistered)2791 pTransfer-> ProviderIface.pfnRegistered(&pTransfer->ProviderCtx, pTransferCtx);2822 if (pTransfer->Callbacks.pfnOnRegistered) 2823 pTransfer->Callbacks.pfnOnRegistered(&pTransfer->CallbackCtx, pTransferCtx); 2792 2824 2793 2825 if (pidTransfer) … … 2820 2852 pTransfer->State.uID = idTransfer; 2821 2853 2822 if (pTransfer-> ProviderIface.pfnRegistered)2823 pTransfer-> ProviderIface.pfnRegistered(&pTransfer->ProviderCtx, pTransferCtx);2854 if (pTransfer->Callbacks.pfnOnRegistered) 2855 pTransfer->Callbacks.pfnOnRegistered(&pTransfer->CallbackCtx, pTransferCtx); 2824 2856 2825 2857 pTransferCtx->cTransfers++; … … 2849 2881 Assert(pTransferCtx->cTransfers >= pTransferCtx->cRunning); 2850 2882 2851 if (pTransfer-> ProviderIface.pfnUnregistered)2852 pTransfer-> ProviderIface.pfnUnregistered(&pTransfer->ProviderCtx, pTransferCtx);2883 if (pTransfer->Callbacks.pfnOnUnregistered) 2884 pTransfer->Callbacks.pfnOnUnregistered(&pTransfer->CallbackCtx, pTransferCtx); 2853 2885 2854 2886 LogFlowFunc(("Now %RU32 transfers left\n", pTransferCtx->cTransfers));
Note:
See TracChangeset
for help on using the changeset viewer.