- Timestamp:
- Jan 10, 2024 1:44:29 PM (13 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard.h
r100566 r102815 264 264 */ 265 265 /** 266 * A single Shared CLipboard cache entry. 266 * A single Shared Clipboard cache entry. 267 * 268 * One entry marks exactly one clipboard format at a time. 267 269 */ 268 270 typedef struct _SHCLCACHEENTRY … … 297 299 PSHCLCACHEENTRY ShClCacheGet(PSHCLCACHE pCache, SHCLFORMAT uFmt); 298 300 int ShClCacheSet(PSHCLCACHE pCache, SHCLFORMAT uFmt, const void *pvData, size_t cbData); 301 int ShClCacheSetMultiple(PSHCLCACHE pCache, SHCLFORMATS uFmts, const void *pvData, size_t cbData); 299 302 /** @} */ 300 303 -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
r100641 r102815 1454 1454 1455 1455 /** 1456 * Sets data to cache for a specific clipboard format .1456 * Sets data to cache for a specific clipboard format, internal version. 1457 1457 * 1458 1458 * @returns VBox status code. … … 1462 1462 * @param cbData Size (in bytes) of data to set. 1463 1463 */ 1464 DECLINLINE(int) shClCacheSet(PSHCLCACHE pCache, SHCLFORMAT uFmt, const void *pvData, size_t cbData) 1465 { 1466 AssertReturn(uFmt < VBOX_SHCL_FMT_MAX, VERR_INVALID_PARAMETER); 1467 AssertReturn(shClCacheEntryIsValid(&pCache->aEntries[uFmt]) == false, VERR_ALREADY_EXISTS); 1468 1469 return shClCacheEntryInit(&pCache->aEntries[uFmt], pvData, cbData); 1470 } 1471 1472 /** 1473 * Sets data to cache for a specific clipboard format. 1474 * 1475 * @returns VBox status code. 1476 * @param pCache Cache to set data for. 1477 * @param uFmt Clipboard format to set data for. 1478 * @param pvData Data to set. 1479 * @param cbData Size (in bytes) of data to set. 1480 */ 1464 1481 int ShClCacheSet(PSHCLCACHE pCache, SHCLFORMAT uFmt, const void *pvData, size_t cbData) 1465 1482 { … … 1470 1487 1471 1488 AssertReturn(cbData, VERR_INVALID_PARAMETER); 1472 AssertReturn(uFmt < VBOX_SHCL_FMT_MAX, VERR_INVALID_PARAMETER); 1473 AssertReturn(shClCacheEntryIsValid(&pCache->aEntries[uFmt]) == false, VERR_ALREADY_EXISTS); 1474 1475 return shClCacheEntryInit(&pCache->aEntries[uFmt], pvData, cbData); 1476 } 1477 1489 1490 return shClCacheSet(pCache, uFmt, pvData, cbData); 1491 } 1492 1493 /** 1494 * Sets data to cache for multiple clipboard formats. 1495 * 1496 * Will bail out if a given format cannot be handled with the data given. 1497 * 1498 * @returns VBox status code. 1499 * @param pCache Cache to set data for. 1500 * @param uFmt Clipboard format to set data for. 1501 * @param pvData Data to set. 1502 * @param cbData Size (in bytes) of data to set. 1503 */ 1504 int ShClCacheSetMultiple(PSHCLCACHE pCache, SHCLFORMATS uFmts, const void *pvData, size_t cbData) 1505 { 1506 AssertPtrReturn(pCache, VERR_INVALID_POINTER); 1507 1508 if (!pvData) /* Nothing to cache? */ 1509 return VINF_SUCCESS; 1510 1511 AssertReturn(cbData, VERR_INVALID_PARAMETER); 1512 1513 int rc = VINF_SUCCESS; 1514 1515 SHCLFORMATS uFmtsLeft = uFmts; 1516 while (uFmtsLeft) 1517 { 1518 SHCLFORMAT uFmt = VBOX_SHCL_FMT_NONE; 1519 void *pvConv = NULL; 1520 size_t cbConv = 0; 1521 if (uFmtsLeft & VBOX_SHCL_FMT_UNICODETEXT) 1522 { 1523 uFmt = VBOX_SHCL_FMT_UNICODETEXT; 1524 1525 rc = RTStrValidateEncoding((const char *)pvData); 1526 if (RT_SUCCESS(rc)) 1527 { 1528 rc = RTStrToUtf16((const char *)pvData, (PRTUTF16 *)&pvConv); 1529 if (RT_SUCCESS(rc)) 1530 cbConv = (RTUtf16Len((const PRTUTF16)pvConv) + 1) * sizeof(RTUTF16); 1531 } 1532 else if (!RTUtf16ValidateEncoding((const PRTUTF16)pvData)) 1533 { 1534 AssertFailedBreakStmt(rc = VERR_INVALID_PARAMETER); 1535 } 1536 } 1537 else if (uFmtsLeft & VBOX_SHCL_FMT_BITMAP) 1538 uFmt = VBOX_SHCL_FMT_BITMAP; 1539 else if (uFmtsLeft & VBOX_SHCL_FMT_HTML) 1540 uFmt = VBOX_SHCL_FMT_HTML; 1541 else if (uFmtsLeft & VBOX_SHCL_FMT_URI_LIST) 1542 uFmt = VBOX_SHCL_FMT_URI_LIST; 1543 else 1544 AssertFailedBreakStmt(rc = VERR_NOT_SUPPORTED); 1545 1546 uFmtsLeft &= ~uFmt; /* Remove from list. */ 1547 Assert(RT_VALID_PTR(pvConv) || cbConv == 0); /* Sanity. */ 1548 1549 if (RT_SUCCESS(rc)) 1550 rc = shClCacheSet(pCache, uFmt, 1551 pvConv ? pvConv : pvData, 1552 cbConv ? cbConv : cbData); 1553 RTMemFree(pvConv); 1554 AssertRCBreak(rc); 1555 } 1556 1557 return rc; 1558 } 1559
Note:
See TracChangeset
for help on using the changeset viewer.