Changeset 105634 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Aug 9, 2024 8:59:25 AM (9 months ago)
- svn:sync-xref-src-repo-rev:
- 164323
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r105630 r105634 1498 1498 1499 1499 /** 1500 * Reports clipboard formats to the guest. 1501 * 1502 * @note Host backend callers must check if it's active (use 1503 * ShClSvcIsBackendActive) before calling to prevent mixing up the 1504 * VRDE clipboard. 1505 * 1506 * @returns VBox status code. 1507 * @param pClient Client to report clipboard formats to. 1508 * @param fFormats The formats to report (VBOX_SHCL_FMT_XXX), zero 1509 * is okay (empty the clipboard). 1510 * 1511 * @thread Backend thread. 1512 */ 1513 int ShClSvcReportFormats(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 1514 { 1515 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1516 1517 LogFlowFunc(("fFormats=%#x\n", fFormats)); 1518 1519 /* 1520 * Check if the service mode allows this operation and whether the guest is 1521 * supposed to be reading from the host. Otherwise, silently ignore reporting 1522 * formats and return VINF_SUCCESS in order to do not trigger client 1523 * termination in svcConnect(). 1524 */ 1525 uint32_t uMode = ShClSvcGetMode(); 1526 if ( uMode == VBOX_SHCL_MODE_BIDIRECTIONAL 1527 || uMode == VBOX_SHCL_MODE_HOST_TO_GUEST) 1528 { /* likely */ } 1529 else 1530 return VINF_SUCCESS; 1531 1500 * Handles clipboard formats. 1501 * 1502 * @returns The new Shared Clipboard formats. 1503 * @param fHostToGuest Reporting direction. 1504 * \c true from host -> guest. 1505 * \c false from guest -> host. 1506 * @param pClient Pointer to client instance. 1507 * @param fFormats Reported clipboard formats. 1508 */ 1509 static SHCLFORMATS shClSvcHandleFormats(bool fHostToGuest, PSHCLCLIENT pClient, SHCLFORMATS fFormats) 1510 { 1532 1511 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1533 1512 bool fSkipTransfers = false; … … 1539 1518 if (s_uTransfersBitchedNotEnabled++ < 32) 1540 1519 { 1541 LogRel(("Shared Clipboard: File transfers are disabled , skipping reporting those to the guest\n"));1520 LogRel(("Shared Clipboard: File transfers are disabled on host, skipping reporting those to the guest\n")); 1542 1521 fSkipTransfers = true; 1543 1522 } … … 1558 1537 fFormats &= ~VBOX_SHCL_FMT_URI_LIST; 1559 1538 } 1560 #endif 1561 1562 #ifdef LOG_ENABLED 1539 #else 1540 RT_NOREF(pClient); 1541 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 1542 1563 1543 char *pszFmts = ShClFormatsToStrA(fFormats); 1564 AssertPtrReturn(pszFmts, VERR_NO_MEMORY); 1565 LogRel2(("Shared Clipboard: Reporting formats '%s' to guest\n", pszFmts)); 1566 RTStrFree(pszFmts); 1567 #endif 1544 if (pszFmts) 1545 { 1546 LogRel2(("Shared Clipboard: %s reported formats '%s' to %s\n", 1547 fHostToGuest ? "Host" : "Guest", 1548 pszFmts, 1549 fHostToGuest ? "guest" : "host")); 1550 RTStrFree(pszFmts); 1551 } 1552 1553 return fFormats; 1554 } 1555 1556 /** 1557 * Reports clipboard formats to the guest. 1558 * 1559 * @note Host backend callers must check if it's active (use 1560 * ShClSvcIsBackendActive) before calling to prevent mixing up the 1561 * VRDE clipboard. 1562 * 1563 * @returns VBox status code. 1564 * @param pClient Client to report clipboard formats to. 1565 * @param fFormats The formats to report (VBOX_SHCL_FMT_XXX), zero 1566 * is okay (empty the clipboard). 1567 * 1568 * @thread Backend thread. 1569 */ 1570 int ShClSvcReportFormats(PSHCLCLIENT pClient, SHCLFORMATS fFormats) 1571 { 1572 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1573 1574 LogFlowFunc(("fFormats=%#x\n", fFormats)); 1575 1576 /* 1577 * Check if the service mode allows this operation and whether the guest is 1578 * supposed to be reading from the host. Otherwise, silently ignore reporting 1579 * formats and return VINF_SUCCESS in order to do not trigger client 1580 * termination in svcConnect(). 1581 */ 1582 uint32_t uMode = ShClSvcGetMode(); 1583 if ( uMode == VBOX_SHCL_MODE_BIDIRECTIONAL 1584 || uMode == VBOX_SHCL_MODE_HOST_TO_GUEST) 1585 { /* likely */ } 1586 else 1587 return VINF_SUCCESS; 1588 1589 fFormats = shClSvcHandleFormats(true /* fHostToGuest */, pClient, fFormats); 1568 1590 1569 1591 int rc; … … 1652 1674 } 1653 1675 ASSERT_GUEST_RETURN(paParms[iParm].type == VBOX_HGCM_SVC_PARM_32BIT, VERR_WRONG_PARAMETER_TYPE); 1654 uint32_t constfFormats = paParms[iParm].u.uint32;1676 uint32_t fFormats = paParms[iParm].u.uint32; 1655 1677 iParm++; 1656 1678 if (cParms == VBOX_SHCL_CPARMS_REPORT_FORMATS_61B) … … 1676 1698 else 1677 1699 { 1700 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1701 fFormats = shClSvcHandleFormats(false /* fHostToGuest */, pClient, fFormats); 1702 #endif 1678 1703 rc = RTCritSectEnter(&g_CritSect); 1679 1704 if (RT_SUCCESS(rc)) … … 1694 1719 if (rc == VERR_NOT_SUPPORTED) 1695 1720 { 1696 #ifdef LOG_ENABLED1697 char *pszFmts = ShClFormatsToStrA(fFormats);1698 if (pszFmts)1699 {1700 LogRel2(("Shared Clipboard: Guest reported formats '%s' to host\n", pszFmts));1701 RTStrFree(pszFmts);1702 }1703 #endif1704 1721 rc = ShClBackendReportFormats(&g_ShClBackend, pClient, fFormats); 1705 1722 if (RT_FAILURE(rc))
Note:
See TracChangeset
for help on using the changeset viewer.