Changeset 20551 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Jun 14, 2009 4:31:50 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 48555
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/x11-clipboard.cpp
r19875 r20551 197 197 } 198 198 199 /** Structure describing a request for clipoard data from the guest. */ 200 struct _CLIPREADCBREQ 201 { 202 /** Where to write the returned data to. */ 203 void *pv; 204 /** The size of the buffer in pv */ 205 uint32_t cb; 206 /** The actual size of the data written */ 207 uint32_t *pcbActual; 208 }; 209 199 210 /** 200 211 * Called when VBox wants to read the X11 clipboard. … … 210 221 * @param pcbActual Where to write the actual size of the written data 211 222 * @note We always fail or complete asynchronously 212 * @note On success allocates a CLIPREAD X11CBCONTEXTstructure which must be223 * @note On success allocates a CLIPREADCBREQ structure which must be 213 224 * freed in ClipCompleteDataRequestFromX11 when it is called back from 214 225 * the backend code. … … 222 233 pClient, u32Format, pv, cb, pcbActual)); 223 234 224 int rc = ClipRequestDataFromX11(pClient->pCtx->pBackend, u32Format, pv, 225 cb); 226 if (RT_SUCCESS(rc)) 227 rc = VINF_HGCM_ASYNC_EXECUTE; 235 int rc = VINF_SUCCESS; 236 CLIPREADCBREQ *pReq = (CLIPREADCBREQ *) RTMemAlloc(sizeof(CLIPREADCBREQ)); 237 if (!pReq) 238 rc = VERR_NO_MEMORY; 239 else 240 { 241 pReq->pv = pv; 242 pReq->cb = cb; 243 pReq->pcbActual = pcbActual; 244 rc = ClipRequestDataFromX11(pClient->pCtx->pBackend, u32Format, pReq); 245 if (RT_SUCCESS(rc)) 246 rc = VINF_HGCM_ASYNC_EXECUTE; 247 } 228 248 LogFlowFunc(("returning %Rrc\n", rc)); 229 249 return rc; … … 242 262 */ 243 263 void ClipCompleteDataRequestFromX11(VBOXCLIPBOARDCONTEXT *pCtx, int rc, 244 uint32_t cbActual) 245 { 246 vboxSvcClipboardCompleteReadData(pCtx->pClient, rc, cbActual); 264 CLIPREADCBREQ *pReq, void *pv, 265 uint32_t cb) 266 { 267 if (cb <= pReq->cb) 268 memcpy(pReq->pv, pv, cb); 269 RTMemFree(pReq); 270 vboxSvcClipboardCompleteReadData(pCtx->pClient, rc, cb); 247 271 } 248 272 … … 410 434 { 411 435 uint32_t format; 412 void *pv;413 uint32_t cb;414 436 int rc; 437 CLIPREADCBREQ *pReq; 415 438 } readData; 416 439 struct _COMPLETEREAD … … 478 501 479 502 extern int ClipRequestDataFromX11(CLIPBACKEND *pBackend, uint32_t u32Format, 480 void *pv, uint32_t cb)503 CLIPREADCBREQ *pReq) 481 504 { 482 505 pBackend->readData.format = u32Format; 483 pBackend->readData.pv = pv; 484 pBackend->readData.cb = cb; 506 pBackend->readData.pReq = pReq; 485 507 return pBackend->readData.rc; 486 508 } … … 518 540 if ( pBackend->readData.format != 519 541 VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT 520 || pBackend->readData.pv != &u32Dummy 521 || pBackend->readData.cb != 42) 542 || pBackend->readData.pReq->pv != &u32Dummy 543 || pBackend->readData.pReq->cb != 42 544 || pBackend->readData.pReq->pcbActual != &u32Dummy) 522 545 { 523 RTPrintf(TEST_NAME ": format=%u, pv=%p, cb=%u\n", 524 pBackend->readData.format, pBackend->readData.pv, 525 pBackend->readData.cb); 546 RTPrintf(TEST_NAME ": format=%u, pReq->pv=%p, pReq->cb=%u, pReq->pcbActual=%p\n", 547 pBackend->readData.format, pBackend->readData.pReq->pv, 548 pBackend->readData.pReq->cb, 549 pBackend->readData.pReq->pcbActual); 526 550 ++cErrors; 527 551 } 528 552 else 529 553 { 530 ClipCompleteDataRequestFromX11(client.pCtx, VERR_NO_DATA, 43); 554 ClipCompleteDataRequestFromX11(client.pCtx, VERR_NO_DATA, 555 pBackend->readData.pReq, NULL, 43); 531 556 if ( pBackend->completeRead.rc != VERR_NO_DATA 532 557 || pBackend->completeRead.cbActual != 43)
Note:
See TracChangeset
for help on using the changeset viewer.