- Timestamp:
- Dec 10, 2020 10:01:11 AM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp
r86969 r87082 103 103 * @returns VBox status code. VERR_NO_DATA if no data available. 104 104 * @param pCtx Our context information. 105 * @param Format The format of the data being requested. 106 * @param ppv On success and if pcb > 0, this will point to a buffer 107 * to be freed with RTMemFree containing the data read. 108 * @param pcb On success, this contains the number of bytes of data returned. 109 */ 110 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb) 111 { 112 RT_NOREF(pCtx); 113 114 LogFlowFunc(("Format=0x%x\n", Format)); 105 * @param uFmt The format of the data being requested. 106 * @param ppv Returns an allocated buffer with data read from the host on success. 107 * Needs to be free'd with RTMemFree() by the caller. 108 * @param pcb Returns the amount of data read (in bytes) on success. 109 */ 110 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb) 111 { 112 LogFlowFunc(("pCtx=%p, uFmt=%#x\n", pCtx, uFmt)); 115 113 116 114 int rc = VINF_SUCCESS; 117 115 118 uint32_t cbRead = 0;119 120 116 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 121 if ( Format == VBOX_SHCL_FMT_URI_LIST)117 if (uFmt == VBOX_SHCL_FMT_URI_LIST) 122 118 { 123 119 //rc = VbglR3ClipboardRootListRead() 120 121 rc = VERR_NO_DATA; 124 122 } 125 123 else 126 124 #endif 127 125 { 126 uint32_t cbRead = 0; 127 128 128 uint32_t cbData = _4K; /** @todo Make this dynamic. */ 129 129 void *pvData = RTMemAlloc(cbData); 130 130 if (pvData) 131 131 { 132 rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, Format, pvData, cbData, &cbRead);132 rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, uFmt, pvData, cbData, &cbRead); 133 133 } 134 134 else … … 148 148 if (pvData) 149 149 { 150 rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, Format, pvData, cbData, &cbRead);150 rc = VbglR3ClipboardReadDataEx(&pCtx->CmdCtx, uFmt, pvData, cbData, &cbRead); 151 151 if (rc == VINF_BUFFER_OVERFLOW) 152 152 rc = VERR_BUFFER_OVERFLOW; … … 176 176 } 177 177 178 if (RT_FAILURE(rc)) 179 LogRel(("Requesting data in format %#x from host failed with %Rrc\n", uFmt, rc)); 180 178 181 LogFlowFuncLeaveRC(rc); 179 182 return rc; … … 201 204 RT_NOREF(pCtx); 202 205 203 LogFlowFunc((" Formats=0x%x\n", fFormats));206 LogFlowFunc(("fFormats=%#x\n", fFormats)); 204 207 205 208 int rc2 = VbglR3ClipboardReportFormats(pCtx->CmdCtx.idClient, fFormats); -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r87058 r87082 1386 1386 1387 1387 /** 1388 * This is a wrapper around ShClX11RequestDataForX11Callback that will cache the 1389 * data returned. 1388 * Helper for ShClX11RequestDataForX11Callback() that will cache the data returned. 1390 1389 * 1391 1390 * @returns VBox status code. VERR_NO_DATA if no data available. 1392 1391 * @param pCtx The X11 clipboard context to use. 1393 * @param FormatClipboard format to read data in.1394 * @param ppv Where to store the allocated read dataon success.1395 * Needs to be free'd by the caller.1396 * @param pcb Where to return the size (in bytes) of the allocated read dataon success.1397 */ 1398 static int clipReadVBoxShCl(PSHCLX11CTX pCtx, SHCLFORMAT Format,1399 void **ppv, uint32_t *pcb)1392 * @param uFmt Clipboard format to read data in. 1393 * @param ppv Returns an allocated buffer with data read on success. 1394 * Needs to be free'd with RTMemFree() by the caller. 1395 * @param pcb Returns the amount of data read (in bytes) on success. 1396 */ 1397 static int shClX11RequestDataForX11CallbackHelper(PSHCLX11CTX pCtx, SHCLFORMAT uFmt, 1398 void **ppv, uint32_t *pcb) 1400 1399 { 1401 1400 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 1403 1402 AssertPtrReturn(pcb, VERR_INVALID_POINTER); 1404 1403 1405 LogFlowFunc(("pCtx=%p, Format=%02X\n", pCtx, Format));1404 LogFlowFunc(("pCtx=%p, uFmt=%#x\n", pCtx, uFmt)); 1406 1405 1407 1406 int rc = VINF_SUCCESS; … … 1410 1409 uint32_t cb = 0; 1411 1410 1412 if ( Format == VBOX_SHCL_FMT_UNICODETEXT)1411 if (uFmt == VBOX_SHCL_FMT_UNICODETEXT) 1413 1412 { 1414 1413 if (pCtx->pvUnicodeCache == NULL) /** @todo r=andy Using string cache here? */ 1415 rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, Format,1414 rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, uFmt, 1416 1415 &pCtx->pvUnicodeCache, 1417 1416 &pCtx->cbUnicodeCache); … … 1429 1428 else 1430 1429 { 1431 rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, Format, &pv, &cb); 1430 rc = ShClX11RequestDataForX11Callback(pCtx->pFrontend, uFmt, &pv, &cb); 1431 } 1432 1433 1434 /* Safey net in case the callbacks above misbehave 1435 * (must return VERR_NO_DATA if no data available). */ 1436 if ( RT_SUCCESS(rc) 1437 && (pv == NULL || cb == 0)) 1438 { 1439 rc = VERR_NO_DATA; 1432 1440 } 1433 1441 … … 1585 1593 int *piFormatReturn) 1586 1594 { 1587 int rc = V INF_SUCCESS;1595 int rc = VERR_NOT_SUPPORTED; /* Play safe by default. */ 1588 1596 1589 1597 SHCLX11FMTIDX idxFmtX11 = clipFindX11FormatByAtom(pCtx, *atomTarget); … … 1601 1609 #endif 1602 1610 1603 if ( ((fmtX11 == SHCLX11FMT_UTF8) || (fmtX11 == SHCLX11FMT_TEXT)) 1611 void *pv = NULL; 1612 uint32_t cb = 0; 1613 1614 if ( ( (fmtX11 == SHCLX11FMT_UTF8) 1615 || (fmtX11 == SHCLX11FMT_TEXT) 1616 ) 1604 1617 && (pCtx->vboxFormats & VBOX_SHCL_FMT_UNICODETEXT)) 1605 1618 { 1606 void *pv = NULL; 1607 uint32_t cb = 0; 1608 rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_UNICODETEXT, &pv, &cb); 1609 if (RT_SUCCESS(rc) && (cb == 0)) 1610 rc = VERR_NO_DATA; 1611 1619 rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_UNICODETEXT, &pv, &cb); 1612 1620 if ( RT_SUCCESS(rc) 1613 1621 && ( (fmtX11 == SHCLX11FMT_UTF8) … … 1628 1636 && (pCtx->vboxFormats & VBOX_SHCL_FMT_BITMAP)) 1629 1637 { 1630 void *pv = NULL; 1631 uint32_t cb = 0; 1632 rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_BITMAP, &pv, &cb); 1633 if (RT_SUCCESS(rc) && (cb == 0)) 1634 rc = VERR_NO_DATA; 1635 if (RT_SUCCESS(rc) && (fmtX11 == SHCLX11FMT_BMP)) 1636 { 1637 /* Create a full BMP from it */ 1638 rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_BITMAP, &pv, &cb); 1639 if ( RT_SUCCESS(rc) 1640 && (fmtX11 == SHCLX11FMT_BMP)) 1641 { 1642 /* Create a full BMP from it. */ 1638 1643 rc = ShClDibToBmp(pv, cb, (void **)pValReturn, 1639 1644 (size_t *)pcLenReturn); 1640 1645 } 1641 else1642 rc = VERR_NOT_SUPPORTED;1643 1646 1644 1647 if (RT_SUCCESS(rc)) … … 1653 1656 && (pCtx->vboxFormats & VBOX_SHCL_FMT_HTML)) 1654 1657 { 1655 void *pv = NULL; 1656 uint32_t cb = 0; 1657 rc = clipReadVBoxShCl(pCtx, VBOX_SHCL_FMT_HTML, &pv, &cb); 1658 if (RT_SUCCESS(rc) && (cb == 0)) 1659 rc = VERR_NO_DATA; 1658 rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_HTML, &pv, &cb); 1660 1659 if (RT_SUCCESS(rc)) 1661 1660 { … … 1679 1678 } 1680 1679 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1681 else if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST) 1682 { 1683 switch (fmtX11) 1684 { 1685 case SHCLX11FMT_TEXT: 1686 RT_FALL_THROUGH(); 1687 case SHCLX11FMT_UTF8: 1688 RT_FALL_THROUGH(); 1689 case SHCLX11FMT_URI_LIST: 1680 else if (fmtX11 == SHCLX11FMT_URI_LIST) 1681 { 1682 if (pCtx->vboxFormats & VBOX_SHCL_FMT_URI_LIST) 1683 { 1684 rc = shClX11RequestDataForX11CallbackHelper(pCtx, VBOX_SHCL_FMT_URI_LIST, &pv, &cb); 1685 if (RT_SUCCESS(rc)) 1690 1686 { 1691 break; 1687 void *pvDst = (void *)XtMalloc(cb); 1688 if (pvDst) 1689 { 1690 memcpy(pvDst, pv, cb); 1691 1692 *atomTypeReturn = *atomTarget; 1693 *pValReturn = (XtPointer)pvDst; 1694 *pcLenReturn = cb; 1695 *piFormatReturn = 8; 1696 } 1697 else 1698 rc = VERR_NO_MEMORY; 1692 1699 } 1693 1694 default: 1695 rc = VERR_NOT_SUPPORTED; 1696 break; 1697 } 1700 } 1701 /* else not supported yet. */ 1698 1702 } 1699 1703 #endif … … 1704 1708 *pcLenReturn = 0; 1705 1709 *piFormatReturn = 0; 1706 1707 rc = VERR_NOT_SUPPORTED;1708 1710 } 1709 1711 -
trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11.cpp
r86737 r87082 120 120 121 121 /* Return the data in the simulated VBox clipboard. */ 122 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, uint32_t Format, void **ppv, uint32_t *pcb)123 { 124 RT_NOREF(pCtx, Format);122 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, uint32_t uFmt, void **ppv, uint32_t *pcb) 123 { 124 RT_NOREF(pCtx, uFmt); 125 125 *pcb = g_tst_cbDataVBox; 126 126 if (g_tst_pvDataVBox != NULL) … … 244 244 static uint32_t g_tst_uX11Formats = 0; 245 245 246 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS Formats)246 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats) 247 247 { 248 248 RT_NOREF(pCtx); 249 g_tst_uX11Formats = Formats;249 g_tst_uX11Formats = fFormats; 250 250 } 251 251 -
trunk/src/VBox/GuestHost/SharedClipboard/testcase/tstClipboardGH-X11Smoke.cpp
r82911 r87082 30 30 #include <VBox/GuestHost/clipboard-helper.h> 31 31 32 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT Format, void **ppv, uint32_t *pcb)32 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb) 33 33 { 34 RT_NOREF(pCtx, Format, ppv, pcb);34 RT_NOREF(pCtx, uFmt, ppv, pcb); 35 35 return VERR_NO_DATA; 36 36 } 37 37 38 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS Formats)38 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats) 39 39 { 40 RT_NOREF(pCtx, Formats);40 RT_NOREF(pCtx, fFormats); 41 41 } 42 42 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-x11.cpp
r86889 r87082 325 325 * Callback implementation for reading clipboard data from the guest. 326 326 * 327 * @note 327 * @note Runs in Xt event thread. 328 328 * 329 329 * @returns VBox status code. VERR_NO_DATA if no data available. 330 330 * @param pCtx Pointer to the host clipboard structure. 331 * @param fFormatThe format in which the data should be transferred331 * @param uFmt The format in which the data should be transferred 332 332 * (VBOX_SHCL_FMT_XXX). 333 * @param ppv On success and if pcb > 0, this will point to a buffer334 * to be freed with RTMemFree containing the data read.335 * @param pcb On success, this contains the number of bytes of data returned.336 */ 337 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT fFormat, void **ppv, uint32_t *pcb)338 { 339 LogFlowFunc(("pCtx=%p, Format=0x%x\n", pCtx, fFormat));333 * @param ppv Returns an allocated buffer with data read from the guest on success. 334 * Needs to be free'd with RTMemFree() by the caller. 335 * @param pcb Returns the amount of data read (in bytes) on success. 336 */ 337 DECLCALLBACK(int) ShClX11RequestDataForX11Callback(PSHCLCONTEXT pCtx, SHCLFORMAT uFmt, void **ppv, uint32_t *pcb) 338 { 339 LogFlowFunc(("pCtx=%p, uFmt=0x%x\n", pCtx, uFmt)); 340 340 341 341 if (pCtx->fShuttingDown) … … 349 349 350 350 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 351 if (fFormat == VBOX_SHCL_FMT_URI_LIST) 352 rc = VINF_SUCCESS; 351 if (uFmt == VBOX_SHCL_FMT_URI_LIST) 352 { 353 *ppv = NULL; 354 *pcb = 0; 355 356 rc = VERR_NO_DATA; 357 } 353 358 else 354 359 #endif … … 356 361 /* Request data from the guest. */ 357 362 SHCLEVENTID idEvent; 358 rc = ShClSvcGuestDataRequest(pCtx->pClient, fFormat, &idEvent);363 rc = ShClSvcGuestDataRequest(pCtx->pClient, uFmt, &idEvent); 359 364 if (RT_SUCCESS(rc)) 360 365 { … … 381 386 382 387 if (RT_FAILURE(rc)) 383 LogRel(("Shared Clipboard: Requesting data in format %#x for X11 host failed with %Rrc\n", fFormat, rc));388 LogRel(("Shared Clipboard: Requesting data in format %#x for X11 host failed with %Rrc\n", uFmt, rc)); 384 389 385 390 LogFlowFuncLeaveRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.