Changeset 82513 in vbox
- Timestamp:
- Dec 9, 2019 1:21:55 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard.h
r82493 r82513 94 94 /** 95 95 * Shared Clipboard formats specification. 96 * @todo r=bird: Pointless as we don't have any fFlags defined, so, unless 97 * someone can give me a plausible scenario where we will need flags here, 98 * this structure will be eliminated. 96 99 */ 97 100 typedef struct SHCLFORMATDATA -
trunk/include/VBox/HostServices/VBoxClipboardSvc.h
r82506 r82513 282 282 #define VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD 1 283 283 /** Sends a list of available formats to the host. 284 * Formely known as VBOX_SHCL_GUEST_FN_REPORT_FORMATS. */ 285 #define VBOX_SHCL_GUEST_FN_FORMATS_REPORT 2 284 * 285 * This function takes a single parameter, a 32-bit set of formats 286 * (VBOX_SHCL_FMT_XXX), this can be zero if the clipboard is empty or previously 287 * reported formats are no longer avaible (logout, shutdown, whatever). 288 * 289 * There was a period during 6.1 development where it would take three 290 * parameters, a 64-bit context ID preceeded the formats and a 32-bit MBZ flags 291 * parameter was appended. This is still accepted, though deprecated. 292 * 293 * @returns May return informational statuses indicating partial success, just 294 * ignore it. 295 * @retval VINF_SUCCESS on success. 296 * @retval VERR_INVALID_CLIENT_ID 297 * @retval VERR_WRONG_PARAMETER_COUNT 298 * @retval VERR_WRONG_PARAMETER_TYPE 299 * @retval VERR_NOT_SUPPORTED if all the formats are unsupported, host 300 * clipboard will be empty. 301 */ 302 #define VBOX_SHCL_GUEST_FN_REPORT_FORMATS 2 286 303 /** Reads data in specified format from the host. 287 304 * … … 671 688 #define VBOX_SHCL_CPARMS_CONNECT 3 672 689 690 /** @name VBOX_SHCL_GUEST_FN_REPORT_FORMATS 691 * @{ */ 692 /** VBOX_SHCL_GUEST_FN_REPORT_FORMATS parameters. */ 693 typedef struct VBoxShClParmReportFormats 694 { 695 /** uint32_t, int: Zero or more VBOX_SHCL_FMT_XXX bits. */ 696 HGCMFunctionParameter f32Formats; 697 } VBoxShClParmReportFormats; 698 699 #define VBOX_SHCL_CPARMS_REPORT_FORMATS 1 /**< The parameter count for VBOX_SHCL_GUEST_FN_REPORT_FORMATS. */ 700 #define VBOX_SHCL_CPARMS_REPORT_FORMATS_61B 3 /**< The 6.1 dev cycle variant, see VBOX_SHCL_GUEST_FN_REPORT_FORMATS. */ 701 /** @} */ 673 702 /** 674 703 * Reports available formats. … … 732 761 733 762 #define VBOX_SHCL_CPARMS_DATA_READ 3 /**< The parameter count for VBOX_SHCL_GUEST_FN_DATA_READ. */ 734 #define VBOX_SHCL_CPARMS_DATA_READ_61B 5 /**< The 6.1 dev cycle variant, see VBOX_SHCL_GUEST_FN_DATA_READ. 763 #define VBOX_SHCL_CPARMS_DATA_READ_61B 5 /**< The 6.1 dev cycle variant, see VBOX_SHCL_GUEST_FN_DATA_READ. */ 735 764 /** @} */ 736 765 -
trunk/include/VBox/VBoxGuestLib.h
r82505 r82513 678 678 VBGLR3DECL(int) VbglR3ClipboardWriteData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb); 679 679 VBGLR3DECL(int) VbglR3ClipboardWriteDataEx(PVBGLR3SHCLCMDCTX pCtx, PSHCLDATABLOCK pData); 680 VBGLR3DECL(int) VbglR3ClipboardFormatsReportEx(PVBGLR3SHCLCMDCTX pCtx, PSHCLFORMATDATA pFormats); 681 VBGLR3DECL(int) VbglR3ClipboardFormatsReport(HGCMCLIENTID idClient, uint32_t fFormats); 680 VBGLR3DECL(int) VbglR3ClipboardReportFormats(HGCMCLIENTID idClient, uint32_t fFormats); 682 681 683 682 VBGLR3DECL(int) VbglR3ClipboardConnectEx(PVBGLR3SHCLCMDCTX pCtx); -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r82507 r82513 256 256 if (RT_SUCCESS(rc)) 257 257 { 258 LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats 0x%x\n", Formats.Formats));259 rc = VbglR3Clipboard FormatsReportEx(&pCtx->CmdCtx, &Formats);258 LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats %#x\n", Formats.Formats)); 259 rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.uClientID, Formats.Formats); 260 260 } 261 261 } … … 301 301 SHCLFORMATDATA Formats; 302 302 rc = SharedClipboardWinGetFormats(pWinCtx, &Formats); 303 if ( RT_SUCCESS(rc)303 if ( RT_SUCCESS(rc) 304 304 && Formats.Formats != VBOX_SHCL_FMT_NONE) 305 { 306 rc = VbglR3ClipboardFormatsReportEx(&pCtx->CmdCtx, &Formats); 307 } 305 rc = VbglR3ClipboardReportFormats(pCtx->CmdCtx.uClientID, Formats.Formats); 308 306 } 309 307 else -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r82506 r82513 2315 2315 * Reports (advertises) guest clipboard formats to the host. 2316 2316 * 2317 * @returns VBox status code.2318 * @param pCtx The command context returned by VbglR3ClipboardConnectEx().2319 * @param pFormats The formats to report.2320 */2321 VBGLR3DECL(int) VbglR3ClipboardFormatsReportEx(PVBGLR3SHCLCMDCTX pCtx, PSHCLFORMATDATA pFormats)2322 {2323 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);2324 AssertPtrReturn(pFormats, VERR_INVALID_POINTER);2325 2326 VBoxShClFormatsMsg Msg;2327 2328 int rc;2329 2330 LogFlowFunc(("uFormats=0x%x\n", pFormats->Formats));2331 2332 if (pCtx->fUseLegacyProtocol)2333 {2334 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_FORMATS_REPORT, 1);2335 Msg.u.v0.uFormats.SetUInt32(pFormats->Formats);2336 2337 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v0));2338 }2339 else2340 {2341 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHCL_GUEST_FN_FORMATS_REPORT, 3);2342 2343 Msg.u.v1.uContext.SetUInt64(pCtx->uContextID);2344 Msg.u.v1.uFormats.SetUInt32(pFormats->Formats);2345 Msg.u.v1.fFlags.SetUInt32(pFormats->fFlags);2346 2347 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v1));2348 }2349 2350 LogFlowFuncLeaveRC(rc);2351 return rc;2352 }2353 2354 /**2355 * Reports (advertises) guest clipboard formats to the host.2356 *2357 2317 * Legacy function, do not use anymore. 2358 2318 * … … 2361 2321 * @param fFormats The formats to report. 2362 2322 */ 2363 VBGLR3DECL(int) VbglR3ClipboardFormatsReport(HGCMCLIENTID idClient, uint32_t fFormats) 2364 { 2365 AssertReturn(idClient, VERR_INVALID_PARAMETER); 2366 AssertReturn(fFormats, VERR_INVALID_PARAMETER); 2367 2368 VBoxShClFormatsMsg Msg; 2369 2370 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHCL_GUEST_FN_FORMATS_REPORT, 1); 2371 VbglHGCMParmUInt32Set(&Msg.u.v0.uFormats, fFormats); 2372 2373 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg.hdr) + sizeof(Msg.u.v0)); 2323 VBGLR3DECL(int) VbglR3ClipboardReportFormats(HGCMCLIENTID idClient, uint32_t fFormats) 2324 { 2325 struct 2326 { 2327 VBGLIOCHGCMCALL Hdr; 2328 VBoxShClParmReportFormats Parms; 2329 } Msg; 2330 2331 VBGL_HGCM_HDR_INIT(&Msg.Hdr, idClient, VBOX_SHCL_GUEST_FN_REPORT_FORMATS, VBOX_SHCL_CPARMS_REPORT_FORMATS); 2332 VbglHGCMParmUInt32Set(&Msg.Parms.f32Formats, fFormats); 2333 2334 int rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg)); 2374 2335 2375 2336 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/Additions/x11/VBoxClient/clipboard.cpp
r82480 r82513 175 175 * Tell the host that new clipboard formats are available. 176 176 * 177 * @param pCtxOur context information.178 * @param FormatsThe formats to report.179 */ 180 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS Formats)177 * @param pCtx Our context information. 178 * @param fFormats The formats to report. 179 */ 180 DECLCALLBACK(void) ShClX11ReportFormatsCallback(PSHCLCONTEXT pCtx, SHCLFORMATS fFormats) 181 181 { 182 182 RT_NOREF(pCtx); 183 183 184 LogFlowFunc(("Formats=0x%x\n", Formats)); 185 186 SHCLFORMATDATA formatData; 187 RT_ZERO(formatData); 188 189 formatData.Formats = Formats; 190 191 int rc2 = VbglR3ClipboardFormatsReportEx(&pCtx->CmdCtx, &formatData); 184 LogFlowFunc(("Formats=0x%x\n", fFormats)); 185 186 int rc2 = VbglR3ClipboardReportFormats(pCtx->CmdCtx.uClientID, fFormats); 192 187 RT_NOREF(rc2); 193 188 LogFlowFuncLeaveRC(rc2); -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp
r82498 r82513 894 894 { 895 895 RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_GET_HOST_MSG_OLD); 896 RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_ FORMATS_REPORT);896 RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_REPORT_FORMATS); 897 897 RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_DATA_READ); 898 898 RT_CASE_RET_STR(VBOX_SHCL_GUEST_FN_DATA_WRITE); -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r82510 r82513 126 126 int SharedClipboardWinClear(void) 127 127 { 128 int rc;129 130 128 LogFlowFuncEnter(); 131 132 const BOOL fRc = EmptyClipboard(); 133 if (RT_UNLIKELY(!fRc)) 134 { 135 const DWORD dwLastErr = GetLastError(); 136 if (dwLastErr == ERROR_CLIPBOARD_NOT_OPEN) 137 rc = VERR_INVALID_STATE; 138 else 139 rc = RTErrConvertFromWin32(dwLastErr); 140 141 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr)); 142 } 143 else 144 rc = VINF_SUCCESS; 145 129 if (EmptyClipboard()) 130 return VINF_SUCCESS; 131 132 const DWORD dwLastErr = GetLastError(); 133 AssertReturn(dwLastErr != ERROR_CLIPBOARD_NOT_OPEN, VERR_INVALID_STATE); 134 135 int rc = RTErrConvertFromWin32(dwLastErr); 136 LogFunc(("Failed with %Rrc (0x%x)\n", rc, dwLastErr)); 146 137 return rc; 147 138 } -
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.