Changeset 81746 in vbox for trunk/src/VBox
- Timestamp:
- Nov 8, 2019 8:28:06 AM (5 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-darwin.cpp
r81451 r81746 76 76 formatData.uFormats = fFormats; 77 77 78 rc = shClSvcFormatsReport(pCtx->pClient, &formatData);78 rc = ShClSvcFormatsReport(pCtx->pClient, &formatData); 79 79 } 80 80 … … 223 223 dataReq.cbSize = _64K; /** @todo Make this more dynamic. */ 224 224 225 return shClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */);225 return ShClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */); 226 226 } 227 227 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r81559 r81746 179 179 } SHCLEXTSTATE, *PSHCLEXTSTATE; 180 180 181 /*182 * The service functions. Locking is between the service thread and the platform-dependent (window) thread.183 */184 int shClSvcDataReadRequest(PSHCLCLIENT pClient, PSHCLDATAREQ pDataReq, PSHCLEVENTID puEvent);185 int shClSvcDataReadSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, PSHCLDATABLOCK pData);186 int shClSvcFormatsReport(PSHCLCLIENT pClient, PSHCLFORMATDATA pFormats);187 188 181 int shClSvcSetSource(PSHCLCLIENT pClient, SHCLSOURCE enmSource); 189 182 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r81451 r81746 179 179 180 180 SHCLEVENTID uEvent = 0; 181 int rc = shClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent);181 int rc = ShClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent); 182 182 if (RT_SUCCESS(rc)) 183 183 { … … 591 591 && Formats.uFormats != VBOX_SHCL_FMT_NONE) 592 592 { 593 rc = shClSvcFormatsReport(pCtx->pClient, &Formats);593 rc = ShClSvcFormatsReport(pCtx->pClient, &Formats); 594 594 } 595 595 } … … 864 864 LogFlowFuncEnter(); 865 865 866 int rc = shClSvcDataReadSignal(pClient, pCmdCtx, pData);866 int rc = ShClSvcDataReadSignal(pClient, pCmdCtx, pData); 867 867 868 868 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r81699 r81746 50 50 CLIPBACKEND *pBackend; 51 51 /** Pointer to the VBox host client data structure. */ 52 PSHCLCLIENT pClient;52 PSHCLCLIENT pClient; 53 53 /** We set this when we start shutting down as a hint not to post any new 54 54 * requests. */ … … 56 56 }; 57 57 58 59 /**60 * Report formats available in the X11 clipboard to VBox.61 * @param pCtx Opaque context pointer for the glue code.62 * @param u32Formats The formats available.63 */64 DECLCALLBACK(void) ClipReportX11FormatsCallback(SHCLCONTEXT *pCtx, uint32_t u32Formats)65 {66 LogFlowFunc(("pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats));67 68 if (u32Formats == VBOX_SHCL_FMT_NONE) /* No formats to report? Bail out early. */69 return;70 71 SHCLFORMATDATA formatData;72 RT_ZERO(formatData);73 74 formatData.uFormats = u32Formats;75 76 int rc = shClSvcFormatsReport(pCtx->pClient, &formatData);77 RT_NOREF(rc);78 79 LogFlowFuncLeaveRC(rc);80 }81 58 82 59 int ShClSvcImplInit(void) … … 144 121 formatData.uFormats = VBOX_SHCL_FMT_NONE; 145 122 146 return shClSvcFormatsReport(pClient, &formatData);123 return ShClSvcFormatsReport(pClient, &formatData); 147 124 } 148 125 … … 193 170 struct _CLIPREADCBREQ 194 171 { 195 /** Where to write the returned data to. Weak pointer!*/172 /** User-supplied data pointer, based on the request type. */ 196 173 void *pv; 197 /** The size of the buffer in pv. */174 /** The size (in bytes) of the the user-supplied pointer in pv. */ 198 175 uint32_t cb; 199 176 /** The actual size of the data written. */ 200 177 uint32_t *pcbActual; 201 178 /** The request's event ID. */ 202 SHCLEVENTID uEvent;179 SHCLEVENTID uEvent; 203 180 }; 204 181 … … 229 206 pReq->uEvent = uEvent; 230 207 231 rc = ClipRequestDataFromX11(pClient->State.pCtx->pBackend, pData->uFormat, pReq);208 rc = ShClEventRegister(&pClient->Events, uEvent); 232 209 if (RT_SUCCESS(rc)) 233 210 { 234 rc = ShClEventRegister(&pClient->Events, uEvent);211 rc = ClipRequestDataFromX11(pClient->State.pCtx->pBackend, pData->uFormat, pReq); 235 212 if (RT_SUCCESS(rc)) 236 213 { … … 244 221 Assert(pData->cbData == pPayload->cbData); /* Sanity. */ 245 222 } 246 247 ShClEventUnregister(&pClient->Events, uEvent);248 223 } 224 225 ShClEventUnregister(&pClient->Events, uEvent); 249 226 } 250 227 } … … 266 243 pClient, pData->pvData, pData->cbData, pData->uFormat)); 267 244 268 int rc = shClSvcDataReadSignal(pClient, pCmdCtx, pData); 269 270 LogFlowFuncLeaveRC(rc); 271 return rc; 245 int rc = ShClSvcDataReadSignal(pClient, pCmdCtx, pData); 246 247 LogFlowFuncLeaveRC(rc); 248 return rc; 249 } 250 251 /** 252 * Reports formats available in the X11 clipboard to VBox. 253 * 254 * @note Runs in Xt event thread. 255 * 256 * @param pCtx Opaque context pointer for the glue code. 257 * @param u32Formats The formats available. 258 */ 259 DECLCALLBACK(void) ClipReportX11FormatsCallback(PSHCLCONTEXT pCtx, uint32_t u32Formats) 260 { 261 LogFlowFunc(("pCtx=%p, u32Formats=%02X\n", pCtx, u32Formats)); 262 263 if (u32Formats == VBOX_SHCL_FMT_NONE) /* No formats to report? Bail out early. */ 264 return; 265 266 SHCLFORMATDATA formatData; 267 RT_ZERO(formatData); 268 269 formatData.uFormats = u32Formats; 270 271 int rc = ShClSvcFormatsReport(pCtx->pClient, &formatData); 272 RT_NOREF(rc); 273 274 LogFlowFuncLeaveRC(rc); 272 275 } 273 276 … … 276 279 * The data should be written to the buffer provided in the initial request. 277 280 * 281 * @note Runs in Xt event thread. 282 * 278 283 * @param pCtx Request context information. 279 * @param rc 280 * @param pReq Request .281 * @param pv Address .282 * @param cb Size .284 * @param rcCompletion The completion status of the request. 285 * @param pReq Request to complete. 286 * @param pv Address of data from completed request. Optional. 287 * @param cb Size (in bytes) of data from completed request. Optional. 283 288 * 284 289 * @todo Change this to deal with the buffer issues rather than offloading them onto the caller. 285 290 */ 286 void ClipRequestFromX11CompleteCallback(SHCLCONTEXT *pCtx, int rc, 287 CLIPREADCBREQ *pReq, void *pv, uint32_t cb) 288 { 289 AssertMsgRC(rc, ("Clipboard data completion from X11 failed with %Rrc\n", rc)); 290 291 PSHCLEVENTPAYLOAD pPayload; 292 int rc2 = ShClPayloadAlloc(pReq->uEvent, pv, cb, &pPayload); 293 if (RT_SUCCESS(rc2)) 291 DECLCALLBACK(void) ClipRequestFromX11CompleteCallback(PSHCLCONTEXT pCtx, int rcCompletion, 292 CLIPREADCBREQ *pReq, void *pv, uint32_t cb) 293 { 294 RT_NOREF(rcCompletion); 295 296 LogFlowFunc(("rcCompletion=%Rrc, pReq=%p, pv=%p, cb=%RU32, uEvent=%RU32\n", rcCompletion, pReq, pv, cb, pReq->uEvent)); 297 298 AssertMsgRC(rcCompletion, ("Clipboard data completion from X11 failed with %Rrc\n", rcCompletion)); 299 300 if (pReq->uEvent != NIL_SHCLEVENTID) 301 { 302 int rc2; 303 304 PSHCLEVENTPAYLOAD pPayload = NULL; 305 if (pv && cb) 306 { 307 rc2 = ShClPayloadAlloc(pReq->uEvent, pv, cb, &pPayload); 308 AssertRC(rc2); 309 } 310 294 311 rc2 = ShClEventSignal(&pCtx->pClient->Events, pReq->uEvent, pPayload); 295 296 AssertRC(rc);312 AssertRC(rc2); 313 } 297 314 298 315 RTMemFree(pReq); … … 302 319 * Reads clipboard data from the guest and passes it to the X11 clipboard. 303 320 * 304 * @param pCtx Pointer to the host clipboard structure 321 * @note Runs in Xt event thread. 322 * 323 * @param pCtx Pointer to the host clipboard structure. 305 324 * @param u32Format The format in which the data should be transferred 306 325 * @param ppv On success and if pcb > 0, this will point to a buffer 307 326 * to be freed with RTMemFree containing the data read. 308 327 * @param pcb On success, this contains the number of bytes of data 309 * returned 310 * @note Host glue code. 311 */ 312 DECLCALLBACK(int) ClipRequestDataForX11Callback(SHCLCONTEXT *pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb) 328 * returned. 329 */ 330 DECLCALLBACK(int) ClipRequestDataForX11Callback(PSHCLCONTEXT pCtx, uint32_t u32Format, void **ppv, uint32_t *pcb) 313 331 { 314 332 LogFlowFunc(("pCtx=%p, u32Format=%02X, ppv=%p\n", pCtx, u32Format, ppv)); … … 329 347 330 348 SHCLEVENTID uEvent; 331 int rc = shClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent);349 int rc = ShClSvcDataReadRequest(pCtx->pClient, &dataReq, &uEvent); 332 350 if (RT_SUCCESS(rc)) 333 351 { … … 373 391 int ShClSvcImplTransferGetRoots(PSHCLCLIENT pClient, PSHCLTRANSFER pTransfer) 374 392 { 375 RT_NOREF(pClient, pTransfer); 376 377 int rc = VINF_SUCCESS; 393 LogFlowFuncEnter(); 394 395 int rc; 396 397 CLIPREADCBREQ *pReq = (CLIPREADCBREQ *)RTMemAllocZ(sizeof(CLIPREADCBREQ)); 398 if (pReq) 399 { 400 pReq->pv = pTransfer; 401 pReq->cb = sizeof(SHCLTRANSFER); 402 pReq->uEvent = NIL_SHCLEVENTID; /* No event handling needed. */ 403 404 #if 0 405 SHCLEVENTID uEvent = ShClEventIDGenerate(&pClient->Events); 406 407 rc = ShClEventRegister(&pClient->Events, uEvent); 408 if (RT_SUCCESS(rc)) 409 { 410 #endif 411 rc = ClipRequestDataFromX11(pClient->State.pCtx->pBackend, VBOX_SHCL_FMT_URI_LIST, pReq); 412 #if 0 413 if (RT_SUCCESS(rc)) 414 { 415 /* X supplies the data asynchronously, so we need to wait for data to arrive first. */ 416 rc = ShClEventWait(&pClient->Events, uEvent, 30 * 1000, NULL /* pPayload */); 417 } 418 419 ShClEventUnregister(&pClient->Events, uEvent); 420 } 421 #endif 422 } 423 else 424 rc = VERR_NO_MEMORY; 378 425 379 426 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r81699 r81746 1061 1061 * @param puEvent Event ID for waiting for new data. Optional. 1062 1062 */ 1063 int shClSvcDataReadRequest(PSHCLCLIENT pClient, PSHCLDATAREQ pDataReq,1063 int ShClSvcDataReadRequest(PSHCLCLIENT pClient, PSHCLDATAREQ pDataReq, 1064 1064 PSHCLEVENTID puEvent) 1065 1065 { … … 1067 1067 AssertPtrReturn(pDataReq, VERR_INVALID_POINTER); 1068 1068 /* puEvent is optional. */ 1069 1070 LogFlowFuncEnter(); 1069 1071 1070 1072 int rc; … … 1105 1107 } 1106 1108 1107 int shClSvcDataReadSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx,1109 int ShClSvcDataReadSignal(PSHCLCLIENT pClient, PSHCLCLIENTCMDCTX pCmdCtx, 1108 1110 PSHCLDATABLOCK pData) 1109 1111 { … … 1112 1114 AssertPtrReturn(pData, VERR_INVALID_POINTER); 1113 1115 1116 LogFlowFuncEnter(); 1117 1114 1118 SHCLEVENTID uEvent; 1115 1119 if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy */ … … 1139 1143 } 1140 1144 1141 int shClSvcFormatsReport(PSHCLCLIENT pClient, PSHCLFORMATDATA pFormats)1145 int ShClSvcFormatsReport(PSHCLCLIENT pClient, PSHCLFORMATDATA pFormats) 1142 1146 { 1143 1147 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1144 1148 AssertPtrReturn(pFormats, VERR_INVALID_POINTER); 1149 1150 LogFlowFuncEnter(); 1145 1151 1146 1152 int rc; … … 1650 1656 Assert(formatData.uFormats != VBOX_SHCL_FMT_NONE); /* There better is *any* format here now. */ 1651 1657 1652 int rc2 = shClSvcFormatsReport(pClient, &formatData);1658 int rc2 = ShClSvcFormatsReport(pClient, &formatData); 1653 1659 AssertRC(rc2); 1654 1660 … … 2128 2134 formatData.uFormats = u32Format; 2129 2135 2130 rc = shClSvcFormatsReport(pClient, &formatData);2136 rc = ShClSvcFormatsReport(pClient, &formatData); 2131 2137 } 2132 2138 … … 2143 2149 dataReq.cbSize = _64K; /** @todo Make this more dynamic. */ 2144 2150 2145 rc = shClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */);2151 rc = ShClSvcDataReadRequest(pClient, &dataReq, NULL /* puEvent */); 2146 2152 break; 2147 2153 }
Note:
See TracChangeset
for help on using the changeset viewer.