Changeset 82513 in vbox for trunk/src/VBox/HostServices/SharedClipboard
- Timestamp:
- Dec 9, 2019 1:21:55 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135366
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r82503 r82513 361 361 LogFunc(("SHCL_WIN_WM_REPORT_FORMATS: fFormats=0x%x\n", fFormats)); 362 362 363 if (fFormats == VBOX_SHCL_FMT_NONE) /* Could arrive with some older GA versions. */364 break; /** @todo r=bird: Old code would do EmptyClipboard() here. */365 366 363 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 367 364 if (fFormats & VBOX_SHCL_FMT_URI_LIST) -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r82506 r82513 57 57 * only supports a single simultaneous GET call from one client guest. 58 58 * 59 * The second guest message is VBOX_SHCL_GUEST_FN_ FORMATS_REPORT, which tells59 * The second guest message is VBOX_SHCL_GUEST_FN_REPORT_FORMATS, which tells 60 60 * the host that the guest has new clipboard data available. The third is 61 61 * VBOX_SHCL_GUEST_FN_DATA_READ, which asks the host to send its clipboard data … … 1290 1290 } 1291 1291 1292 1293 /** 1294 * Handles the VBOX_SHCL_GUEST_FN_REPORT_FORMATS message from the guest. 1295 */ 1296 static int shClSvcGuestReportFormats(PSHCLCLIENT pClient, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 1297 { 1298 /* 1299 * Check if the service mode allows this operation and whether the guest is 1300 * supposed to be reading from the host. 1301 */ 1302 uint32_t uMode = ShClSvcGetMode(); 1303 if ( uMode == VBOX_SHCL_MODE_BIDIRECTIONAL 1304 || uMode == VBOX_SHCL_MODE_GUEST_TO_HOST) 1305 { /* likely */ } 1306 else 1307 return VERR_ACCESS_DENIED; 1308 1309 /* 1310 * Digest parameters. 1311 */ 1312 ASSERT_GUEST_RETURN( cParms == VBOX_SHCL_CPARMS_REPORT_FORMATS 1313 || ( cParms == VBOX_SHCL_CPARMS_REPORT_FORMATS_61B 1314 && (pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)), 1315 VERR_WRONG_PARAMETER_COUNT); 1316 1317 uintptr_t iParm = 0; 1318 if (cParms == VBOX_SHCL_CPARMS_REPORT_FORMATS_61B) 1319 { 1320 ASSERT_GUEST_RETURN(paParms[iParm].type == VBOX_HGCM_SVC_PARM_64BIT, VERR_WRONG_PARAMETER_TYPE); 1321 /* no defined value, so just ignore it */ 1322 iParm++; 1323 } 1324 ASSERT_GUEST_RETURN(paParms[iParm].type == VBOX_HGCM_SVC_PARM_32BIT, VERR_WRONG_PARAMETER_TYPE); 1325 uint32_t const fFormats = paParms[iParm].u.uint32; 1326 iParm++; 1327 if (cParms == VBOX_SHCL_CPARMS_REPORT_FORMATS_61B) 1328 { 1329 ASSERT_GUEST_RETURN(paParms[iParm].type == VBOX_HGCM_SVC_PARM_32BIT, VERR_WRONG_PARAMETER_TYPE); 1330 ASSERT_GUEST_RETURN(paParms[iParm].u.uint32 == 0, VERR_INVALID_FLAGS); 1331 iParm++; 1332 } 1333 Assert(iParm == cParms); 1334 1335 /* 1336 * Report the formats. 1337 */ 1338 int rc = shClSvcSetSource(pClient, SHCLSOURCE_REMOTE); 1339 if (RT_SUCCESS(rc)) 1340 { 1341 if (g_ExtState.pfnExtension) 1342 { 1343 SHCLEXTPARMS parms; 1344 RT_ZERO(parms); 1345 parms.uFormat = fFormats; 1346 1347 g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, &parms, sizeof(parms)); 1348 } 1349 else 1350 { 1351 SHCLCLIENTCMDCTX CmdCtx; 1352 RT_ZERO(CmdCtx); 1353 1354 SHCLFORMATDATA FormatData; 1355 FormatData.fFlags = 0; 1356 FormatData.Formats = fFormats; 1357 rc = ShClSvcImplFormatAnnounce(pClient, &CmdCtx, &FormatData); 1358 } 1359 1360 /** @todo r=bird: I'm not sure if the guest should be automatically allowed 1361 * to write the host clipboard now. It would make more sense to disallow 1362 * host clipboard reads until the host reports formats. 1363 * 1364 * The writes should only really be allowed upon request from the host, 1365 * shouldn't they? (Though, I'm not sure, maybe there are situations 1366 * where the guest side will just want to push the content over 1367 * immediately while it's still available, I don't quite recall now... 1368 */ 1369 if (RT_SUCCESS(rc)) 1370 pClient->State.fFlags |= SHCLCLIENTSTATE_FLAGS_WRITE_ACTIVE; 1371 } 1372 1373 return rc; 1374 } 1375 1292 1376 /** 1293 1377 * Handles the VBOX_SHCL_GUEST_FN_DATA_READ message from the guest. … … 1749 1833 { 1750 1834 case VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD: 1751 {1752 1835 rc = shClSvcMsgGetOld(pClient, callHandle, cParms, paParms); 1753 1836 break; 1754 }1755 1837 1756 1838 case VBOX_SHCL_GUEST_FN_CONNECT: … … 1777 1859 rc = VINF_SUCCESS; 1778 1860 } 1779 1780 1861 break; 1781 1862 } 1782 1863 1783 1864 case VBOX_SHCL_GUEST_FN_REPORT_FEATURES: 1784 {1785 1865 rc = shClSvcClientReportFeatures(pClient, callHandle, cParms, paParms); 1786 1866 break; 1787 }1788 1867 1789 1868 case VBOX_SHCL_GUEST_FN_QUERY_FEATURES: 1790 {1791 1869 rc = shClSvcClientQueryFeatures(callHandle, cParms, paParms); 1792 1870 break; 1793 }1794 1871 1795 1872 case VBOX_SHCL_GUEST_FN_MSG_PEEK_NOWAIT: 1796 {1797 1873 rc = shClSvcMsgPeek(pClient, callHandle, cParms, paParms, false /*fWait*/); 1798 1874 break; 1799 }1800 1875 1801 1876 case VBOX_SHCL_GUEST_FN_MSG_PEEK_WAIT: 1802 {1803 1877 rc = shClSvcMsgPeek(pClient, callHandle, cParms, paParms, true /*fWait*/); 1804 1878 break; 1805 }1806 1879 1807 1880 case VBOX_SHCL_GUEST_FN_MSG_GET: 1808 {1809 1881 rc = shClSvcMsgGet(pClient, callHandle, cParms, paParms); 1810 1882 break; 1811 } 1812 1813 case VBOX_SHCL_GUEST_FN_FORMATS_REPORT: 1814 { 1815 uint32_t uFormats = 0; 1816 1817 if (!(pClient->State.fGuestFeatures0 & VBOX_SHCL_GF_0_CONTEXT_ID)) /* Legacy, Guest Additions < 6.1. */ 1818 { 1819 if (cParms != 1) 1820 { 1821 rc = VERR_INVALID_PARAMETER; 1822 } 1823 else if (paParms[0].type != VBOX_HGCM_SVC_PARM_32BIT) /* uFormats */ 1824 { 1825 rc = VERR_INVALID_PARAMETER; 1826 } 1827 else 1828 { 1829 rc = HGCMSvcGetU32(&paParms[0], &uFormats); 1830 } 1831 } 1832 else 1833 { 1834 if (cParms != 3) 1835 { 1836 rc = VERR_INVALID_PARAMETER; 1837 } 1838 else if ( paParms[0].type != VBOX_HGCM_SVC_PARM_64BIT /* uContextID */ 1839 || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT /* uFormats */ 1840 || paParms[2].type != VBOX_HGCM_SVC_PARM_32BIT) /* fFlags */ 1841 { 1842 rc = VERR_INVALID_PARAMETER; 1843 } 1844 else 1845 { 1846 rc = HGCMSvcGetU32(&paParms[1], &uFormats); 1847 1848 /** @todo Handle rest. */ 1849 } 1850 } 1851 1852 if (RT_SUCCESS(rc)) 1853 { 1854 if ( ShClSvcGetMode() != VBOX_SHCL_MODE_GUEST_TO_HOST 1855 && ShClSvcGetMode() != VBOX_SHCL_MODE_BIDIRECTIONAL) 1856 { 1857 rc = VERR_ACCESS_DENIED; 1858 } 1859 else if (uFormats != VBOX_SHCL_FMT_NONE) /* Only announce formats if we actually *have* formats to announce! */ 1860 { 1861 rc = shClSvcSetSource(pClient, SHCLSOURCE_REMOTE); 1862 if (RT_SUCCESS(rc)) 1863 { 1864 if (g_ExtState.pfnExtension) 1865 { 1866 SHCLEXTPARMS parms; 1867 RT_ZERO(parms); 1868 1869 parms.uFormat = uFormats; 1870 1871 g_ExtState.pfnExtension(g_ExtState.pvExtension, VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE, 1872 &parms, sizeof(parms)); 1873 } 1874 else 1875 { 1876 1877 SHCLCLIENTCMDCTX cmdCtx; 1878 RT_ZERO(cmdCtx); 1879 1880 SHCLFORMATDATA formatData; 1881 RT_ZERO(formatData); 1882 1883 formatData.Formats = uFormats; 1884 Assert(formatData.Formats != VBOX_SHCL_FMT_NONE); /* Sanity. */ 1885 1886 rc = ShClSvcImplFormatAnnounce(pClient, &cmdCtx, &formatData); 1887 } 1888 1889 /** @todo r=bird: I'm not sure if the guest should be automatically allowed 1890 * to write the host clipboard now. It would make more sense to disallow 1891 * host clipboard reads until the host reports formats. 1892 * 1893 * The writes should only really be allowed upon request from the host, 1894 * shouldn't they? (Though, I'm not sure, maybe there are situations 1895 * where the guest side will just want to push the content over 1896 * immediately while it's still available, I don't quite recall now... 1897 */ 1898 if (RT_SUCCESS(rc)) 1899 pClient->State.fFlags |= SHCLCLIENTSTATE_FLAGS_WRITE_ACTIVE; 1900 } 1901 } 1902 } 1903 1883 1884 case VBOX_SHCL_GUEST_FN_REPORT_FORMATS: 1885 rc = shClSvcGuestReportFormats(pClient, cParms, paParms); 1904 1886 break; 1905 }1906 1887 1907 1888 case VBOX_SHCL_GUEST_FN_DATA_READ:
Note:
See TracChangeset
for help on using the changeset viewer.