Changeset 83624 in vbox for trunk/src/VBox/HostServices/SharedClipboard
- Timestamp:
- Apr 8, 2020 4:29:25 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137054
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
r82968 r83624 35 35 *********************************************************************************************************************************/ 36 36 /** Global clipboard context information */ 37 struct SHCLCONTEXT 38 { 39 /** We have a separate thread to poll for new clipboard content */ 40 RTTHREAD thread; 37 typedef struct SHCLCONTEXT 38 { 39 /** We have a separate thread to poll for new clipboard content. */ 40 RTTHREAD hThread; 41 /** Termination indicator. */ 41 42 bool volatile fTerminate; 42 43 /** The reference to the current pasteboard */ 43 PasteboardRef pasteboard; 44 PSHCLCLIENT pClient; 45 }; 44 PasteboardRef hPasteboard; 45 /** Shared clipboard client. */ 46 PSHCLCLIENT pClient; 47 } SHCLCONTEXT; 46 48 47 49 … … 67 69 bool fChanged = false; 68 70 /* Retrieve the formats currently in the clipboard and supported by vbox */ 69 int rc = queryNewPasteboardFormats(pCtx-> pasteboard, &fFormats, &fChanged);71 int rc = queryNewPasteboardFormats(pCtx->hPasteboard, &fFormats, &fChanged); 70 72 if ( RT_SUCCESS(rc) 71 73 && fChanged) … … 77 79 78 80 /** 79 * The poller thread.81 * @callback_method_impl{FNRTTHREAD, The poller thread. 80 82 * 81 * This thread will check for the arrival of new data on the clipboard. 82 * 83 * @returns VINF_SUCCESS (not used). 84 * @param ThreadSelf Our thread handle. 85 * @param pvUser Pointer to the SHCLCONTEXT structure. 86 * 87 */ 88 static int vboxClipboardThread(RTTHREAD ThreadSelf, void *pvUser) 89 { 83 * This thread will check for the arrival of new data on the clipboard.} 84 */ 85 static DECLCALLBACK(int) vboxClipboardThread(RTTHREAD ThreadSelf, void *pvUser) 86 { 87 SHCLCONTEXT *pCtx = (SHCLCONTEXT *)pvUser; 88 AssertPtr(pCtx); 90 89 LogFlowFuncEnter(); 91 92 AssertPtrReturn(pvUser, VERR_INVALID_PARAMETER);93 SHCLCONTEXT *pCtx = (SHCLCONTEXT *)pvUser;94 90 95 91 while (!pCtx->fTerminate) … … 114 110 g_ctx.fTerminate = false; 115 111 116 int rc = initPasteboard(&g_ctx. pasteboard);112 int rc = initPasteboard(&g_ctx.hPasteboard); 117 113 AssertRCReturn(rc, rc); 118 114 119 rc = RTThreadCreate(&g_ctx. thread, vboxClipboardThread, &g_ctx, 0,115 rc = RTThreadCreate(&g_ctx.hThread, vboxClipboardThread, &g_ctx, 0, 120 116 RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLIP"); 121 117 if (RT_FAILURE(rc)) 122 118 { 123 g_ctx. thread = NIL_RTTHREAD;124 destroyPasteboard(&g_ctx. pasteboard);119 g_ctx.hThread = NIL_RTTHREAD; 120 destroyPasteboard(&g_ctx.hPasteboard); 125 121 } 126 122 … … 134 130 */ 135 131 ASMAtomicWriteBool(&g_ctx.fTerminate, true); 136 int rc = RTThreadUserSignal(g_ctx. thread);132 int rc = RTThreadUserSignal(g_ctx.hThread); 137 133 AssertRC(rc); 138 rc = RTThreadWait(g_ctx. thread, RT_INDEFINITE_WAIT, NULL);134 rc = RTThreadWait(g_ctx.hThread, RT_INDEFINITE_WAIT, NULL); 139 135 AssertRC(rc); 140 136 141 137 /* 142 * Destroy the pasteboard and uninitialize the global context record.138 * Destroy the hPasteboard and uninitialize the global context record. 143 139 */ 144 destroyPasteboard(&g_ctx. pasteboard);145 g_ctx. thread = NIL_RTTHREAD;140 destroyPasteboard(&g_ctx.hPasteboard); 141 g_ctx.hThread = NIL_RTTHREAD; 146 142 g_ctx.pClient = NULL; 147 143 } … … 190 186 } 191 187 192 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, 193 PSHCLCLIENTCMDCTX pCmdCtx, PSHCLFORMATDATA pFormats) 194 { 195 RT_NOREF(pCmdCtx); 196 197 LogFlowFunc(("uFormats=%02X\n", pFormats->Formats)); 198 199 if (pFormats->Formats == VBOX_SHCL_FMT_NONE) 188 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 189 { 190 LogFlowFunc(("fFormats=%02X\n", fFormats)); 191 192 if (fFormats == VBOX_SHCL_FMT_NONE) 200 193 { 201 194 /* This is just an automatism, not a genuine announcement */ … … 204 197 205 198 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 206 if ( pFormats->Formats & VBOX_SHCL_FMT_URI_LIST) /* No transfer support yet. */199 if (fFormats & VBOX_SHCL_FMT_URI_LIST) /* No transfer support yet. */ 207 200 return VINF_SUCCESS; 208 201 #endif 209 202 210 return ShClSvcDataReadRequest(pClient, pFormats->Formats, NULL /* pidEvent */);211 } 212 213 int ShClSvcImplReadData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, 214 SHCLFORMAT uFormat,void *pvData, uint32_t cbData, uint32_t *pcbActual)203 return ShClSvcDataReadRequest(pClient, fFormats, NULL /* pidEvent */); 204 } 205 206 int ShClSvcImplReadData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT fFormat, 207 void *pvData, uint32_t cbData, uint32_t *pcbActual) 215 208 { 216 209 RT_NOREF(pCmdCtx); … … 221 214 *pcbActual = 0; 222 215 223 int rc = readFromPasteboard(pClient->State.pCtx->pasteboard, 224 uFormat, pvData, cbData, pcbActual); 225 226 ShClSvcUnlock(); 227 228 return rc; 229 } 230 231 int ShClSvcImplWriteData(PSHCLCLIENT pClient, 232 PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT uFormat, void *pvData, uint32_t cbData) 216 int rc = readFromPasteboard(pClient->State.pCtx->hPasteboard, fFormat, pvData, cbData, pcbActual); 217 218 ShClSvcUnlock(); 219 220 return rc; 221 } 222 223 int ShClSvcImplWriteData(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, SHCLFORMAT fFormat, void *pvData, uint32_t cbData) 233 224 { 234 225 RT_NOREF(pCmdCtx); … … 236 227 ShClSvcLock(); 237 228 238 writeToPasteboard(pClient->State.pCtx-> pasteboard, pvData, cbData, uFormat);229 writeToPasteboard(pClient->State.pCtx->hPasteboard, pvData, cbData, fFormat); 239 230 240 231 ShClSvcUnlock(); … … 244 235 245 236 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 237 246 238 int ShClSvcImplTransferReadDir(PSHCLCLIENT pClient, PSHCLDIRDATA pDirData) 247 239 { … … 279 271 return VERR_NOT_IMPLEMENTED; 280 272 } 273 281 274 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 282 275 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r82889 r83624 282 282 * @returns VBox status code. 283 283 * @param pClient Shared Clipboard client context. 284 * @param pCmdCtx Shared Clipboard command context.285 * @param pFormats Announced formats from the guest.286 */ 287 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, PSHCLFORMATDATA pFormats);284 * @param fFormats The announced formats from the guest, 285 * VBOX_SHCL_FMT_XXX. 286 */ 287 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats); 288 288 /** @todo Document: Can return VINF_HGCM_ASYNC_EXECUTE to defer returning read data.*/ 289 289 /** -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r82893 r83624 573 573 if (pCtx->pClient) 574 574 { 575 SHCLFORMATDATA Formats; 576 RT_ZERO(Formats); 577 578 rc = SharedClipboardWinGetFormats(&pCtx->Win, &Formats); 575 SHCLFORMATS fFormats = 0; 576 rc = SharedClipboardWinGetFormats(&pCtx->Win, &fFormats); 579 577 if ( RT_SUCCESS(rc) 580 && Formats.Formats != VBOX_SHCL_FMT_NONE) /** @todo r=bird: BUGBUG: revisit this. */581 rc = ShClSvcHostReportFormats(pCtx->pClient, Formats.Formats);578 && fFormats != VBOX_SHCL_FMT_NONE) /** @todo r=bird: BUGBUG: revisit this. */ 579 rc = ShClSvcHostReportFormats(pCtx->pClient, fFormats); 582 580 } 583 581 else /* If we don't have any client data (yet), bail out. */ … … 696 694 } 697 695 698 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, 699 PSHCLFORMATDATA pFormats) 696 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 700 697 { 701 698 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 702 RT_NOREF(pCmdCtx);703 704 int rc;705 699 706 700 PSHCLCONTEXT pCtx = pClient->State.pCtx; 707 701 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 708 702 709 LogFlowFunc((" uFormats=0x%x, hWnd=%p\n", pFormats->Formats, pCtx->Win.hWnd));703 LogFlowFunc(("fFormats=0x%x, hWnd=%p\n", fFormats, pCtx->Win.hWnd)); 710 704 711 705 /* … … 713 707 */ 714 708 PostMessage(pCtx->Win.hWnd, SHCL_WIN_WM_REPORT_FORMATS, 715 0 /* wParam */, pFormats->Formats /* lParam */); 716 717 rc = VINF_SUCCESS; 718 719 LogFlowFuncLeaveRC(rc); 720 return rc; 709 0 /* wParam */, fFormats /* lParam */); 710 711 712 LogFlowFuncLeaveRC(VINF_SUCCESS); 713 return VINF_SUCCESS; 721 714 } 722 715 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r82893 r83624 146 146 } 147 147 148 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, 149 PSHCLFORMATDATA pFormats) 150 { 151 RT_NOREF(pCmdCtx); 152 153 int rc = ShClX11ReportFormatsToX11(&pClient->State.pCtx->X11, pFormats->Formats); 148 int ShClSvcImplFormatAnnounce(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 149 { 150 int rc = ShClX11ReportFormatsToX11(&pClient->State.pCtx->X11, fFormats); 154 151 155 152 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r83621 r83624 1464 1464 } 1465 1465 else 1466 { 1467 SHCLCLIENTCMDCTX CmdCtx; 1468 RT_ZERO(CmdCtx); 1469 1470 SHCLFORMATDATA FormatData; 1471 FormatData.fFlags = 0; 1472 FormatData.Formats = fFormats; 1473 rc = ShClSvcImplFormatAnnounce(pClient, &CmdCtx, &FormatData); 1474 } 1466 rc = ShClSvcImplFormatAnnounce(pClient, fFormats); 1475 1467 } 1476 1468 } -
trunk/src/VBox/HostServices/SharedClipboard/testcase/tstClipboardServiceHost.cpp
r82892 r83624 312 312 int ShClSvcImplDisconnect(PSHCLCLIENT) { return VINF_SUCCESS; } 313 313 int ShClSvcImplConnect(PSHCLCLIENT, bool) { return VINF_SUCCESS; } 314 int ShClSvcImplFormatAnnounce(PSHCLCLIENT, PSHCLCLIENTCMDCTX, PSHCLFORMATDATA) { AssertFailed(); return VINF_SUCCESS; }314 int ShClSvcImplFormatAnnounce(PSHCLCLIENT, SHCLFORMATS) { AssertFailed(); return VINF_SUCCESS; } 315 315 int ShClSvcImplReadData(PSHCLCLIENT, PSHCLCLIENTCMDCTX, SHCLFORMAT, void *, uint32_t, unsigned int *) { AssertFailed(); return VERR_WRONG_ORDER; } 316 316 int ShClSvcImplWriteData(PSHCLCLIENT, PSHCLCLIENTCMDCTX, SHCLFORMAT, void *, uint32_t) { AssertFailed(); return VINF_SUCCESS; }
Note:
See TracChangeset
for help on using the changeset viewer.