Changeset 87082 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Dec 10, 2020 10:01:11 AM (4 years ago)
- Location:
- trunk/src/VBox/GuestHost/SharedClipboard
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.