- Timestamp:
- Sep 20, 2019 10:27:30 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-transfers.h
r80907 r80918 1106 1106 1107 1107 SHCLTRANSFERID SharedClipboardTransferGetID(PSHCLTRANSFER pTransfer); 1108 SHCLTRANSFERDIR SharedClipboardTransferGetDir(PSHCLTRANSFER pTransfer); 1108 1109 SHCLSOURCE SharedClipboardTransferGetSource(PSHCLTRANSFER pTransfer); 1109 1110 SHCLTRANSFERSTATUS SharedClipboardTransferGetStatus(PSHCLTRANSFER pTransfer); … … 1125 1126 uint32_t SharedClipboardTransferCtxGetRunningTransfers(PSHCLTRANSFERCTX pTransferCtx); 1126 1127 uint32_t SharedClipboardTransferCtxGetTotalTransfers(PSHCLTRANSFERCTX pTransferCtx); 1127 void SharedClipboardTransferCtx TransfersCleanup(PSHCLTRANSFERCTX pTransferCtx);1128 void SharedClipboardTransferCtxCleanup(PSHCLTRANSFERCTX pTransferCtx); 1128 1129 bool SharedClipboardTransferCtxTransfersMaximumReached(PSHCLTRANSFERCTX pTransferCtx); 1129 1130 int SharedClipboardTransferCtxTransferRegister(PSHCLTRANSFERCTX pTransferCtx, PSHCLTRANSFER pTransfer, uint32_t *pidTransfer); -
trunk/include/VBox/HostServices/VBoxClipboardSvc.h
r80907 r80918 102 102 */ 103 103 /** Asks the client to quit / terminate. */ 104 #define VBOX_SHCL_HOST_MSG_QUIT 1104 #define VBOX_SHCL_HOST_MSG_QUIT 1 105 105 /** Reads (simple) data from the guest. */ 106 #define VBOX_SHCL_HOST_MSG_READ_DATA 2106 #define VBOX_SHCL_HOST_MSG_READ_DATA 2 107 107 /** Reports available clipboard format from host to the guest. 108 108 * Formerly known as VBOX_SHCL_HOST_MSG_REPORT_FORMATS. */ 109 #define VBOX_SHCL_HOST_MSG_FORMATS_REPORT 3109 #define VBOX_SHCL_HOST_MSG_FORMATS_REPORT 3 110 110 111 111 /** Sends a transfer status to the guest side. */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r80907 r80918 101 101 102 102 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 103 #if 0104 static DECLCALLBACK(int) vboxClipboardTransferWriteThread(RTTHREAD ThreadSelf, void *pvUser)105 {106 RT_NOREF(ThreadSelf);107 108 LogFlowFuncEnter();109 110 PSHCLWRITETHREADCTX pCtx = (PSHCLWRITETHREADCTX)pvUser;111 AssertPtr(pCtx);112 113 PSHCLTRANSFER pTransfer = pCtx->pTransfer;114 AssertPtr(pTransfer);115 116 pTransfer->Thread.fStarted = true;117 118 RTThreadUserSignal(RTThreadSelf());119 120 VBGLR3SHCLCMDCTX cmdCtx;121 int rc = VbglR3ClipboardConnectEx(&cmdCtx);122 if (RT_SUCCESS(rc))123 {124 rc = VbglR3ClipboardTransferSendStatus(&cmdCtx, pTransfer, SHCLTRANSFERSTATUS_RUNNING);125 if (RT_SUCCESS(rc))126 {127 bool fTerminate = false;128 unsigned cErrors = 0;129 130 for (;;)131 {132 PVBGLR3CLIPBOARDEVENT pEvent = NULL;133 rc = VbglR3ClipboardEventGetNext(&cmdCtx, &pEvent);134 if (RT_SUCCESS(rc))135 {136 /* Nothing to do in here right now. */137 138 VbglR3ClipboardEventFree(pEvent);139 }140 141 if (fTerminate)142 break;143 144 if (RT_FAILURE(rc))145 {146 if (cErrors++ >= 3)147 break;148 RTThreadSleep(1000);149 }150 }151 }152 153 VbglR3ClipboardDisconnectEx(&cmdCtx);154 }155 156 RTMemFree(pCtx);157 158 LogFlowFuncLeaveRC(rc);159 return rc;160 }161 #endif162 163 103 /** 164 104 * Cleanup helper function for transfer callbacks. … … 196 136 LogFlowFunc(("pCtx=%p\n", pCtx)); 197 137 198 int rc = SharedClipboardWinOpen(pCtx->Win.hWnd); 199 if (RT_SUCCESS(rc)) 200 { 201 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 202 * presented as a IDataObject or IStream. */ 203 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 204 if (hClip) 138 PSHCLTRANSFER pTransfer = pData->pTransfer; 139 AssertPtr(pTransfer); 140 141 int rc; 142 143 /* The guest wants to write local data to the host? */ 144 if (SharedClipboardTransferGetDir(pTransfer) == SHCLTRANSFERDIR_WRITE) 145 { 146 Assert(SharedClipboardTransferGetSource(pTransfer) == SHCLSOURCE_LOCAL); /* Sanity. */ 147 148 rc = SharedClipboardWinOpen(pCtx->Win.hWnd); 149 if (RT_SUCCESS(rc)) 205 150 { 206 HDROP hDrop = (HDROP)GlobalLock(hClip); 207 if (hDrop) 151 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 152 * presented as a IDataObject or IStream. */ 153 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 154 if (hClip) 208 155 { 209 char *papszList = NULL; 210 uint32_t cbList; 211 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 212 213 GlobalUnlock(hClip); 214 215 if (RT_SUCCESS(rc)) 156 HDROP hDrop = (HDROP)GlobalLock(hClip); 157 if (hDrop) 216 158 { 217 rc = SharedClipboardTransferRootsSet(pData->pTransfer, 218 papszList, cbList + 1 /* Include termination */); 219 RTStrFree(papszList); 159 char *papszList = NULL; 160 uint32_t cbList; 161 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 162 163 GlobalUnlock(hClip); 164 165 if (RT_SUCCESS(rc)) 166 { 167 rc = SharedClipboardTransferRootsSet(pTransfer, 168 papszList, cbList + 1 /* Include termination */); 169 RTStrFree(papszList); 170 } 220 171 } 172 else 173 LogRel(("Shared Clipboard: Unable to lock clipboard data, last error: %ld\n", GetLastError())); 221 174 } 222 175 else 223 { 224 hClip = NULL; 225 } 176 LogRel(("Shared Clipboard: Unable to retrieve clipboard data from clipboard (CF_HDROP), last error: %ld\n", 177 GetLastError())); 178 179 SharedClipboardWinClose(); 226 180 } 227 228 SharedClipboardWinClose(); 229 } 181 } 182 /* The guest wants to read data from a remote source. */ 183 else if (SharedClipboardTransferGetDir(pTransfer) == SHCLTRANSFERDIR_READ) 184 { 185 Assert(SharedClipboardTransferGetSource(pTransfer) == SHCLSOURCE_REMOTE); /* Sanity. */ 186 187 rc = SharedClipboardWinTransferCreate(&pCtx->Win, pTransfer); 188 } 189 else 190 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); 230 191 231 192 LogFlowFuncLeaveRC(rc); … … 475 436 { 476 437 const HWND hWndClipboardOwner = GetClipboardOwner(); 438 439 LogFunc(("WM_CLIPBOARDUPDATE: hWndOldClipboardOwner=%p, hWndNewClipboardOwner=%p\n", 440 pWinCtx->hWndClipboardOwnerUs, hWndClipboardOwner)); 441 477 442 if (pWinCtx->hWndClipboardOwnerUs != hWndClipboardOwner) 478 443 { 479 LogFunc(("WM_CLIPBOARDUPDATE: hWndOldClipboardOwner=%p, hWndNewClipboardOwner=%p\n",480 pWinCtx->hWndClipboardOwnerUs, hWndClipboardOwner));481 482 444 /* Clipboard was updated by another application. 483 445 * Report available formats to the host. */ … … 716 678 LogFunc(("VBOX_SHCL_FMT_URI_LIST\n")); 717 679 718 PSHCLTRANSFER pTransfer = SharedClipboardTransferCtxGetTransfer(&pCtx->TransferCtx, 0); /** @todo FIX !!! */ 719 if (pTransfer) 720 { 721 rc = SharedClipboardWinTransferCreate(pWinCtx, pTransfer); 722 723 /* Note: The actual requesting + retrieving of data will be done in the IDataObject implementation 724 (ClipboardDataObjectImpl::GetData()). */ 725 } 726 else 727 AssertFailedStmt(rc = VERR_NOT_FOUND); 728 729 /* Note: SharedClipboardWinTransferCreate() takes care of closing the clipboard. */ 680 /* 681 * Creating and starting the actual transfer will be done in vbglR3ClipboardTransferStart() as soon 682 * as the host announces the start of the transfer via a VBOX_SHCL_HOST_MSG_TRANSFER_STATUS message. 683 * Transfers always are controlled and initiated on the host side! 684 * 685 * So don't announce the transfer to the OS here yet. 686 */ 730 687 } 731 688 else … … 733 690 #endif 734 691 rc = SharedClipboardWinAnnounceFormats(pWinCtx, fFormats); 735 736 SharedClipboardWinClose();737 692 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 738 693 } 739 694 #endif 695 SharedClipboardWinClose(); 740 696 } 741 697 } … … 826 782 } 827 783 } 828 #if 0829 else if (uFormat == VBOX_SHCL_FMT_URI_LIST)830 {831 LogFunc(("cTransfersRunning=%RU32\n", SharedClipboardTransferCtxGetRunningTransfers(&pCtx->TransferCtx)));832 833 int rc = SharedClipboardWinOpen(hwnd);834 if (RT_SUCCESS(rc))835 {836 PSHCLTRANSFER pTransfer;837 rc = SharedClipboardTransferCreate(&pTransfer);838 if (RT_SUCCESS(rc))839 rc = SharedClipboardTransferInit(pTransfer, 0 /* uID */,840 SHCLTRANSFERDIR_WRITE, SHCLSOURCE_LOCAL);841 if (RT_SUCCESS(rc))842 {843 /* The data data in CF_HDROP format, as the files are locally present and don't need to be844 * presented as a IDataObject or IStream. */845 HANDLE hClip = hClip = GetClipboardData(CF_HDROP);846 if (hClip)847 {848 HDROP hDrop = (HDROP)GlobalLock(hClip);849 if (hDrop)850 {851 char *papszList;852 uint32_t cbList;853 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList);854 855 GlobalUnlock(hClip);856 857 if (RT_SUCCESS(rc))858 {859 rc = SharedClipboardTransferSetRoots(pTransfer,860 papszList, cbList + 1 /* Include termination */);861 if (RT_SUCCESS(rc))862 {863 PSHCLWRITETHREADCTX pThreadCtx864 = (PSHCLWRITETHREADCTX)RTMemAllocZ(sizeof(SHCLWRITETHREADCTX));865 if (pThreadCtx)866 {867 pThreadCtx->pClipboardCtx = pCtx;868 pThreadCtx->pTransfer = pTransfer;869 870 rc = SharedClipboardTransferPrepare(pTransfer);871 if (RT_SUCCESS(rc))872 {873 rc = SharedClipboardTransferCtxTransferRegister(&pCtx->TransferCtx, pTransfer,874 NULL /* puTransferID */);875 #if 0876 if (RT_SUCCESS(rc))877 {878 rc = SharedClipboardTransferRun(pTransfer, vboxClipboardTransferWriteThread,879 pThreadCtx /* pvUser */);880 /* pThreadCtx now is owned by vboxClipboardTransferWriteThread(). */881 }882 #endif883 }884 }885 else886 rc = VERR_NO_MEMORY;887 }888 889 if (papszList)890 RTStrFree(papszList);891 }892 }893 else894 {895 hClip = NULL;896 }897 }898 }899 900 SharedClipboardWinClose();901 }902 903 if (RT_FAILURE(rc))904 LogFunc(("SHCL_WIN_WM_READ_DATA: Failed with rc=%Rrc\n", rc));905 }906 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */907 908 784 if (hClip == NULL) 909 785 { … … 932 808 933 809 #if 0 934 /* The host wants to read transfer data. */935 case VBOX_CLIPBOARD_WM_URI_START_READ:936 {937 LogFunc(("VBOX_CLIPBOARD_WM_URI_START_READ: cTransfersRunning=%RU32\n",938 SharedClipboardTransferCtxGetRunningTransfers(&pCtx->URI)));939 940 int rc = SharedClipboardWinOpen(hwnd);941 if (RT_SUCCESS(rc))942 {943 PSHCLTRANSFER pTransfer;944 rc = SharedClipboardTransferCreate(SHCLTRANSFERDIR_WRITE,945 SHCLSOURCE_LOCAL,946 &pTransfer);947 if (RT_SUCCESS(rc))948 {949 rc = SharedClipboardTransferCtxTransferAdd(&pCtx->URI, pTransfer);950 if (RT_SUCCESS(rc))951 {952 /* The data data in CF_HDROP format, as the files are locally present and don't need to be953 * presented as a IDataObject or IStream. */954 HANDLE hClip = hClip = GetClipboardData(CF_HDROP);955 if (hClip)956 {957 HDROP hDrop = (HDROP)GlobalLock(hClip);958 if (hDrop)959 {960 char *papszList;961 uint32_t cbList;962 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList);963 964 GlobalUnlock(hClip);965 966 if (RT_SUCCESS(rc))967 {968 rc = SharedClipboardTransferSetRoots(pTransfer,969 papszList, cbList + 1 /* Include termination */);970 if (RT_SUCCESS(rc))971 {972 PSHCLWRITETHREADCTX pThreadCtx973 = (PSHCLWRITETHREADCTX)RTMemAllocZ(sizeof(SHCLWRITETHREADCTX));974 if (pThreadCtx)975 {976 pThreadCtx->pClipboardCtx = pCtx;977 pThreadCtx->pTransfer = pTransfer;978 979 rc = SharedClipboardTransferPrepare(pTransfer);980 if (RT_SUCCESS(rc))981 {982 rc = SharedClipboardTransferRun(pTransfer, vboxClipboardTransferWriteThread,983 pThreadCtx /* pvUser */);984 /* pThreadCtx now is owned by vboxClipboardTransferWriteThread(). */985 }986 }987 else988 rc = VERR_NO_MEMORY;989 }990 991 if (papszList)992 RTStrFree(papszList);993 }994 }995 else996 {997 hClip = NULL;998 }999 }1000 }1001 }1002 1003 SharedClipboardWinClose();1004 }1005 1006 if (RT_FAILURE(rc))1007 LogFunc(("VBOX_CLIPBOARD_WM_URI_START_READ: Failed with rc=%Rrc\n", rc));1008 break;1009 }1010 1011 810 /* The host wants to write transfer data. */ 1012 811 case VBOX_CLIPBOARD_WM_URI_START_WRITE: … … 1203 1002 if (FAILED(hr)) 1204 1003 { 1205 LogRel(("Shared Clipboard: Initializing OLE failed (%Rhrc) -- file transfers unavailable\n" ));1004 LogRel(("Shared Clipboard: Initializing OLE failed (%Rhrc) -- file transfers unavailable\n", hr)); 1206 1005 /* Not critical, the rest of the clipboard might work. */ 1207 1006 } … … 1253 1052 AssertPtr(pInstance); 1254 1053 LogFlowFunc(("pInstance=%p\n", pInstance)); 1054 1055 HRESULT hr = OleInitialize(NULL); 1056 if (FAILED(hr)) 1057 { 1058 LogRel(("Shared Clipboard: Initializing OLE in worker thread failed (%Rhrc) -- file transfers unavailable\n", hr)); 1059 /* Not critical, the rest of the clipboard might work. */ 1060 } 1255 1061 1256 1062 /* … … 1403 1209 } 1404 1210 1211 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1212 OleSetClipboard(NULL); /* Make sure to flush the clipboard on destruction. */ 1213 OleUninitialize(); 1214 #endif 1215 1405 1216 LogFlowFuncLeaveRC(rc); 1406 1217 return rc; -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r80907 r80918 118 118 LogFlowFunc(("uProtocolVer=%RU32, cbChunkSize=%RU32\n", pCtx->uProtocolVer, pCtx->cbChunkSize)); 119 119 120 LogRel (("Shared Clipboard: Client %RU32 connected, using protocol v%RU32 (cbChunkSize=%RU32\n)",121 pCtx->uClientID, pCtx->uProtocolVer, pCtx->cbChunkSize));120 LogRel2(("Shared Clipboard: Client %RU32 connected, using protocol v%RU32 (cbChunkSize=%RU32)\n", 121 pCtx->uClientID, pCtx->uProtocolVer, pCtx->cbChunkSize)); 122 122 123 123 } … … 1287 1287 *ppTransfer = pTransfer; 1288 1288 1289 LogRel2(("Shared Clipboard: Transfer ID=%RU16 successfully started\n", uTransferID)); 1289 LogRel2(("Shared Clipboard: Transfer ID=%RU16 (%s %s) successfully started\n", 1290 uTransferID, 1291 enmDir == SHCLTRANSFERDIR_READ ? "reading from" : "writing to", 1292 enmSource == SHCLSOURCE_LOCAL ? "local" : "remote")); 1290 1293 } 1291 1294 else … … 1373 1376 case SHCLTRANSFERSTATUS_STARTED: 1374 1377 { 1375 SHCLSOURCE enmSource = enmDir == SHCLTRANSFERDIR_READ 1376 ? SHCLSOURCE_LOCAL 1377 : SHCLSOURCE_REMOTE; 1378 SHCLSOURCE enmSource = SHCLSOURCE_INVALID; 1379 1380 /* The host announces the transfer direction from its point of view, so inverse the direction here. */ 1381 if (enmDir == SHCLTRANSFERDIR_WRITE) 1382 { 1383 enmDir = SHCLTRANSFERDIR_READ; 1384 enmSource = SHCLSOURCE_REMOTE; 1385 } 1386 else if (enmDir == SHCLTRANSFERDIR_READ) 1387 { 1388 enmDir = SHCLTRANSFERDIR_WRITE; 1389 enmSource = SHCLSOURCE_LOCAL; 1390 } 1391 else 1392 AssertFailedBreakStmt(rc = VERR_INVALID_PARAMETER); 1378 1393 1379 1394 rc = vbglR3ClipboardTransferStart(pCmdCtx, pTransferCtx, uTransferID, -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp
r80907 r80918 2210 2210 2211 2211 /** 2212 * Returns the transfer's direction. 2213 * 2214 * @returns The transfer's direction. 2215 * @param pTransfer Clipboard transfer to return direction for. 2216 */ 2217 SHCLTRANSFERDIR SharedClipboardTransferGetDir(PSHCLTRANSFER pTransfer) 2218 { 2219 AssertPtrReturn(pTransfer, SHCLTRANSFERDIR_UNKNOWN); 2220 2221 return pTransfer->State.enmDir; 2222 } 2223 2224 /** 2212 2225 * Returns the transfer's source. 2213 2226 * … … 2388 2401 AssertPtrReturn(pTransferCtx, VERR_INVALID_POINTER); 2389 2402 2390 LogFlowFunc((" %p\n", pTransferCtx));2403 LogFlowFunc(("pTransferCtx=%p\n", pTransferCtx)); 2391 2404 2392 2405 int rc = RTCritSectInit(&pTransferCtx->CritSect); … … 2415 2428 AssertPtrReturnVoid(pTransferCtx); 2416 2429 2417 LogFlowFunc((" %p\n", pTransferCtx));2430 LogFlowFunc(("pTransferCtx=%p\n", pTransferCtx)); 2418 2431 2419 2432 RTCritSectDelete(&pTransferCtx->CritSect); … … 2623 2636 * @param pTransferCtx Transfer context to cleanup transfers for. 2624 2637 */ 2625 void SharedClipboardTransferCtx TransfersCleanup(PSHCLTRANSFERCTX pTransferCtx)2638 void SharedClipboardTransferCtxCleanup(PSHCLTRANSFERCTX pTransferCtx) 2626 2639 { 2627 2640 AssertPtrReturnVoid(pTransferCtx); 2628 2641 2629 LogFlowFunc(("cTransfers=%RU32, cRunning=%RU32\n", pTransferCtx->cTransfers, pTransferCtx->cRunning)); 2642 LogFlowFunc(("pTransferCtx=%p, cTransfers=%RU32, cRunning=%RU32\n", 2643 pTransferCtx, pTransferCtx->cTransfers, pTransferCtx->cRunning)); 2630 2644 2631 2645 /* Remove all transfers which are not in a running state (e.g. only announced). */ -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r80862 r80918 99 99 int rc; 100 100 101 LogFlowFuncEnter();102 103 101 const BOOL fRc = CloseClipboard(); 104 102 if (RT_UNLIKELY(!fRc)) … … 118 116 rc = VINF_SUCCESS; 119 117 118 LogFlowFuncLeaveRC(rc); 120 119 return rc; 121 120 } -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-transfers.cpp
r80907 r80918 2110 2110 LogFlowFuncEnter(); 2111 2111 2112 SharedClipboardTransferCtx TransfersCleanup(&pClient->TransferCtx);2112 SharedClipboardTransferCtxCleanup(&pClient->TransferCtx); 2113 2113 2114 2114 int rc; -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r80907 r80918 869 869 870 870 HGCMSvcSetU32(&pMsgReadData->paParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 871 871 pClient->Events.uID, uEvent)); 872 872 HGCMSvcSetU32(&pMsgReadData->paParms[1], pDataReq->uFmt); 873 873 HGCMSvcSetU32(&pMsgReadData->paParms[2], pClient->State.cbChunkSize); … … 940 940 941 941 HGCMSvcSetU32(&pMsg->paParms[0], VBOX_SHCL_CONTEXTID_MAKE(pClient->State.uSessionID, 942 942 pClient->Events.uID, uEvent)); 943 943 HGCMSvcSetU32(&pMsg->paParms[1], pFormats->uFormats); 944 944 HGCMSvcSetU32(&pMsg->paParms[2], 0 /* fFlags */); … … 946 946 rc = sharedClipboardSvcMsgAdd(pClient, pMsg, true /* fAppend */); 947 947 if (RT_SUCCESS(rc)) 948 rc = sharedClipboardSvcClientWakeup(pClient); 948 { 949 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 950 if (pFormats->uFormats & VBOX_SHCL_FMT_URI_LIST) 951 { 952 rc = sharedClipboardSvcTransferStart(pClient, SHCLTRANSFERDIR_WRITE, SHCLSOURCE_LOCAL, 953 NULL /* pTransfer */); 954 if (RT_FAILURE(rc)) 955 LogRel(("Shared Clipboard: Initializing host write transfer failed with %Rrc\n", rc)); 956 } 957 #endif 958 if (RT_SUCCESS(rc)) 959 rc = sharedClipboardSvcClientWakeup(pClient); 960 } 949 961 } 950 962 else … … 1367 1379 if (RT_SUCCESS(rc)) 1368 1380 { 1369 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1370 if (uFormat == VBOX_SHCL_FMT_URI_LIST) 1381 void *pv; 1382 uint32_t cb; 1383 rc = HGCMSvcGetBuf(&paParms[1], &pv, &cb); 1384 if (RT_SUCCESS(rc)) 1371 1385 { 1372 rc = sharedClipboardSvcTransferStart(pClient, SHCLTRANSFERDIR_WRITE, SHCLSOURCE_LOCAL, 1373 NULL /* pTransfer */); 1374 if (RT_FAILURE(rc)) 1375 LogRel(("Shared Clipboard: Initializing host write transfer failed with %Rrc\n", rc)); 1376 } 1377 else 1378 { 1379 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 1380 void *pv; 1381 uint32_t cb; 1382 rc = HGCMSvcGetBuf(&paParms[1], &pv, &cb); 1386 uint32_t cbActual = 0; 1387 1388 /* If there is a service extension active, try reading data from it first. */ 1389 if (g_ExtState.pfnExtension) 1390 { 1391 SHCLEXTPARMS parms; 1392 RT_ZERO(parms); 1393 1394 parms.uFormat = uFormat; 1395 parms.u.pvData = pv; 1396 parms.cbData = cb; 1397 1398 g_ExtState.fReadingData = true; 1399 1400 /* Read clipboard data from the extension. */ 1401 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_DATA_READ, 1402 &parms, sizeof(parms)); 1403 1404 LogFlowFunc(("g_ExtState.fDelayedAnnouncement=%RTbool, g_ExtState.uDelayedFormats=0x%x\n", 1405 g_ExtState.fDelayedAnnouncement, g_ExtState.uDelayedFormats)); 1406 1407 /* Did the extension send the clipboard formats yet? 1408 * Otherwise, do this now. */ 1409 if (g_ExtState.fDelayedAnnouncement) 1410 { 1411 SHCLFORMATDATA formatData; 1412 RT_ZERO(formatData); 1413 1414 formatData.uFormats = g_ExtState.uDelayedFormats; 1415 1416 int rc2 = sharedClipboardSvcFormatsReport(pClient, &formatData); 1417 AssertRC(rc2); 1418 1419 g_ExtState.fDelayedAnnouncement = false; 1420 g_ExtState.uDelayedFormats = 0; 1421 } 1422 1423 g_ExtState.fReadingData = false; 1424 1425 if (RT_SUCCESS(rc)) 1426 { 1427 cbActual = parms.cbData; 1428 } 1429 } 1430 1431 /* Note: The host clipboard *always* has precedence over the service extension above, 1432 * so data which has been read above might get overridden by the host clipboard eventually. */ 1433 1434 SHCLCLIENTCMDCTX cmdCtx; 1435 RT_ZERO(cmdCtx); 1436 1437 /* Release any other pending read, as we only 1438 * support one pending read at one time. */ 1383 1439 if (RT_SUCCESS(rc)) 1384 1440 { 1385 uint32_t cbActual = 0; 1386 1387 /* If there is a service extension active, try reading data from it first. */ 1388 if (g_ExtState.pfnExtension) 1389 { 1390 SHCLEXTPARMS parms; 1391 RT_ZERO(parms); 1392 1393 parms.uFormat = uFormat; 1394 parms.u.pvData = pv; 1395 parms.cbData = cb; 1396 1397 g_ExtState.fReadingData = true; 1398 1399 /* Read clipboard data from the extension. */ 1400 rc = g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_DATA_READ, 1401 &parms, sizeof(parms)); 1402 1403 LogFlowFunc(("g_ExtState.fDelayedAnnouncement=%RTbool, g_ExtState.uDelayedFormats=0x%x\n", 1404 g_ExtState.fDelayedAnnouncement, g_ExtState.uDelayedFormats)); 1405 1406 /* Did the extension send the clipboard formats yet? 1407 * Otherwise, do this now. */ 1408 if (g_ExtState.fDelayedAnnouncement) 1409 { 1410 SHCLFORMATDATA formatData; 1411 RT_ZERO(formatData); 1412 1413 formatData.uFormats = g_ExtState.uDelayedFormats; 1414 1415 int rc2 = sharedClipboardSvcFormatsReport(pClient, &formatData); 1416 AssertRC(rc2); 1417 1418 g_ExtState.fDelayedAnnouncement = false; 1419 g_ExtState.uDelayedFormats = 0; 1420 } 1421 1422 g_ExtState.fReadingData = false; 1423 1424 if (RT_SUCCESS(rc)) 1425 { 1426 cbActual = parms.cbData; 1427 } 1428 } 1429 1430 /* Note: The host clipboard *always* has precedence over the service extension above, 1431 * so data which has been read above might get overridden by the host clipboard eventually. */ 1432 1433 SHCLCLIENTCMDCTX cmdCtx; 1434 RT_ZERO(cmdCtx); 1435 1436 /* Release any other pending read, as we only 1437 * support one pending read at one time. */ 1441 SHCLDATABLOCK dataBlock; 1442 RT_ZERO(dataBlock); 1443 1444 dataBlock.pvData = pv; 1445 dataBlock.cbData = cb; 1446 dataBlock.uFormat = uFormat; 1447 1448 rc = SharedClipboardSvcImplReadData(pClient, &cmdCtx, &dataBlock, &cbActual); 1438 1449 if (RT_SUCCESS(rc)) 1439 { 1440 SHCLDATABLOCK dataBlock; 1441 RT_ZERO(dataBlock); 1442 1443 dataBlock.pvData = pv; 1444 dataBlock.cbData = cb; 1445 dataBlock.uFormat = uFormat; 1446 1447 rc = SharedClipboardSvcImplReadData(pClient, &cmdCtx, &dataBlock, &cbActual); 1448 if (RT_SUCCESS(rc)) 1449 HGCMSvcSetU32(&paParms[2], cbActual); 1450 } 1450 HGCMSvcSetU32(&paParms[2], cbActual); 1451 1451 } 1452 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS1453 1452 } 1454 #endif1455 1453 } 1456 1454 }
Note:
See TracChangeset
for help on using the changeset viewer.