- Timestamp:
- Jan 10, 2024 5:11:28 PM (13 months ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-x11.h
r102468 r102822 249 249 int ShClX11ReadDataFromX11(PSHCLX11CTX pCtx, PSHCLEVENTSOURCE pEventSource, RTMSINTERVAL msTimeout, SHCLFORMAT uFmt, void *pvBuf, uint32_t cbBuf, uint32_t *pcbBuf); 250 250 void ShClX11SetCallbacks(PSHCLX11CTX pCtx, PSHCLCALLBACKS pCallbacks); 251 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 252 int ShClX11TransferConvertToX11(const char *pszSrc, size_t cbSrc, SHCLX11FMT enmFmtX11, void **ppvDst, size_t *pcbDst); 253 int ShClX11TransferConvertFromX11(const char *pvData, size_t cbData, char **ppszList, size_t *pcbList); 254 #endif 251 255 /** @} */ 252 256 -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp
r102821 r102822 1798 1798 if (RT_SUCCESS(rc)) 1799 1799 { 1800 if ( fmtX11 == SHCLX11FMT_URI_LIST_GNOME_COPIED_FILES 1801 /** @todo BUGBUG Ditto, see above. */ 1802 || fmtX11 == SHCLX11FMT_URI_LIST_MATE_COPIED_FILES 1803 || fmtX11 == SHCLX11FMT_URI_LIST_NAUTILUS_CLIPBOARD 1804 || fmtX11 == SHCLX11FMT_URI_LIST_KDE_CUTSELECTION) 1805 { 1806 /* Note: There must be *no* final new line ('\n') at the end, otherwise Nautilus will crash! */ 1807 char *pszData = NULL; 1808 1809 RTStrAPrintf(&pszData, "copy\n%s", (const char *)pv); 1810 1811 cb = strlen(pszData); 1812 pv = pszData; 1813 } 1814 else /* SHCLX11FMT_URI_LIST -> String only, w/o any special formatting. */ 1800 void *pvX11; 1801 size_t cbX11; 1802 rc = ShClX11TransferConvertToX11((const char *)pv, cb, fmtX11, &pvX11, &cbX11); 1803 if (RT_SUCCESS(rc)) 1815 1804 { 1816 char *pszData = NULL;1817 RTStrAPrintf(&pszData, "%s\n", (const char *)pv);1818 1819 cb = strlen(pszData) + 1;1820 pv = pszData;1821 }1822 1823 # ifdef DEBUG_andy1824 LogFlowFunc(("Data:\n%.*RhXd\n", cb, pv));1825 # endif1826 void *pvDst = (void *)XtMalloc(cb);1827 if (pvDst)1828 {1829 memcpy(pvDst, pv, cb);1830 1831 1805 *atomTypeReturn = *atomTarget; 1832 *pValReturn = (XtPointer)pv Dst;1833 *pcLenReturn = cb ;1806 *pValReturn = (XtPointer)pvX11; 1807 *pcLenReturn = cbX11; 1834 1808 *piFormatReturn = 8; 1835 1809 } 1836 else1837 rc = VERR_NO_MEMORY;1838 1810 } 1839 1811 … … 2038 2010 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 2039 2011 /** 2040 * Converts X11 data to a string list usable for HTTP transfers. 2012 * Converts transfer data to a format returned back to X11. 2013 * 2014 * @returns VBox status code. 2015 * @param pszSrc Transfer data to convert. 2016 * @param cbSrc Size of transfer data (in bytes) to convert. 2017 * @param enmFmtX11 X11 format to convert data to. 2018 * @param ppvDst Where to return converted data on success. Must be free'd with XtFree(). 2019 * @param pcbDst Where to return the bytes of the converted data on success. Optional. 2020 */ 2021 int ShClX11TransferConvertToX11(const char *pszSrc, size_t cbSrc, SHCLX11FMT enmFmtX11, void **ppvDst, size_t *pcbDst) 2022 { 2023 AssertPtrReturn(pszSrc, VERR_INVALID_POINTER); 2024 AssertReturn(cbSrc, VERR_INVALID_PARAMETER); 2025 AssertPtrReturn(ppvDst, VERR_INVALID_POINTER); 2026 /* pcbDst is optional. */ 2027 2028 int rc = VINF_SUCCESS; 2029 2030 char *pszDst = NULL; 2031 2032 # ifdef DEBUG_andy 2033 LogFlowFunc(("Src:\n%.*RhXd\n", cbSrc, pszSrc)); 2034 # endif 2035 2036 switch (enmFmtX11) 2037 { 2038 case SHCLX11FMT_URI_LIST_GNOME_COPIED_FILES: 2039 RT_FALL_THROUGH(); 2040 case SHCLX11FMT_URI_LIST_MATE_COPIED_FILES: 2041 RT_FALL_THROUGH(); 2042 case SHCLX11FMT_URI_LIST_NAUTILUS_CLIPBOARD: 2043 RT_FALL_THROUGH(); 2044 case SHCLX11FMT_URI_LIST_KDE_CUTSELECTION: 2045 { 2046 const char chSep = '\n'; /* Currently (?) all entries need to be separated by '\n'. */ 2047 2048 /* Note: There must be *no* final new line ('\n') at the end, otherwise Nautilus will crash! */ 2049 pszDst = RTStrAPrintf2("copy%c%s", chSep, pszSrc); 2050 if (!pszDst) 2051 rc = VERR_NO_MEMORY; 2052 break; 2053 } 2054 2055 case SHCLX11FMT_URI_LIST: 2056 { 2057 pszDst = RTStrDup(pszSrc); 2058 AssertPtrBreakStmt(pszDst, rc = VERR_NO_MEMORY); 2059 break; 2060 } 2061 2062 default: 2063 AssertFailed(); /* Most likely a bug in the code; let me know. */ 2064 break; 2065 } 2066 2067 if (RT_SUCCESS(rc)) 2068 { 2069 size_t const cbDst = RTStrNLen(pszDst, RTSTR_MAX); 2070 void *pvDst = (void *)XtMalloc(cbDst); 2071 if (pvDst) 2072 { 2073 memcpy(pvDst, pszDst, cbDst); 2074 # ifdef DEBUG_andy 2075 LogFlowFunc(("Dst:\n%.*RhXd\n", cbDst, pvDst)); 2076 # endif 2077 } 2078 else 2079 rc = VERR_NO_MEMORY; 2080 2081 if (pcbDst) 2082 *pcbDst = cbDst; 2083 *ppvDst = pvDst; 2084 2085 RTStrFree(pszDst); 2086 pszDst = NULL; 2087 } 2088 2089 LogFlowFuncLeaveRC(rc); 2090 return rc; 2091 } 2092 2093 /** 2094 * Converts X11 data to a string list usable for transfers. 2041 2095 * 2042 2096 * @returns VBox status code. … … 2048 2102 * Includes terminator. 2049 2103 */ 2050 int ShClX11Transfer HttpConvertFromX11(const char *pvData, size_t cbData, char **ppszList, size_t *pcbList)2104 int ShClX11TransferConvertFromX11(const char *pvData, size_t cbData, char **ppszList, size_t *pcbList) 2051 2105 { 2052 2106 AssertPtrReturn(pvData, VERR_INVALID_POINTER); … … 2297 2351 case SHCLX11FMT_URI_LIST_KDE_CUTSELECTION: 2298 2352 { 2299 rc = ShClX11Transfer HttpConvertFromX11((const char *)pvSrc, cbSrc, (char **)&pvDst, &cbDst);2353 rc = ShClX11TransferConvertFromX11((const char *)pvSrc, cbSrc, (char **)&pvDst, &cbDst); 2300 2354 break; 2301 2355 }
Note:
See TracChangeset
for help on using the changeset viewer.