Changeset 74431 in vbox for trunk/src/VBox/Main/xml
- Timestamp:
- Sep 24, 2018 9:16:17 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 125272
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r73768 r74431 79 79 #include <iprt/ldr.h> 80 80 #include <iprt/base64.h> 81 #include <iprt/uri.h> 81 82 #include <iprt/cpp/lock.h> 82 83 … … 1579 1580 * Constructor. Needs to set sane defaults which stand the test of time. 1580 1581 */ 1581 SystemProperties::SystemProperties() : 1582 ulLogHistoryCount(3), 1583 fExclusiveHwVirt(true) 1582 SystemProperties::SystemProperties() 1583 : uLogHistoryCount(3) 1584 , uProxyMode(ProxyMode_System) 1585 , fExclusiveHwVirt(true) 1584 1586 { 1585 1587 #if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) … … 1867 1869 1868 1870 /** 1871 * Converts old style Proxy settings from ExtraData/UI section. 1872 * 1873 * Saves proxy settings directly to systemProperties structure. 1874 * 1875 * @returns true if conversion was successfull, false if not. 1876 * @param strUIProxySettings The GUI settings string to convert. 1877 */ 1878 bool MainConfigFile::convertGuiProxySettings(const com::Utf8Str &strUIProxySettings) 1879 { 1880 /* 1881 * Possible variants: 1882 * - "ProxyAuto,proxyserver.url,1080,authDisabled,," 1883 * - "ProxyDisabled,proxyserver.url,1080,authDisabled,," 1884 * - "ProxyEnabled,proxyserver.url,1080,authDisabled,," 1885 * 1886 * Note! We only need to bother with the first three fields as the last 1887 * three was never really used or ever actually passed to the HTTP 1888 * client code. 1889 */ 1890 /* First field: The proxy mode. */ 1891 const char *psz = RTStrStripL(strUIProxySettings.c_str()); 1892 static const struct { const char *psz; size_t cch; ProxyMode_T enmMode; } s_aModes[] = 1893 { 1894 { RT_STR_TUPLE("ProxyAuto"), ProxyMode_System }, 1895 { RT_STR_TUPLE("ProxyDisabled"), ProxyMode_NoProxy }, 1896 { RT_STR_TUPLE("ProxyEnabled"), ProxyMode_Manual }, 1897 }; 1898 for (size_t i = 0; i < RT_ELEMENTS(s_aModes); i++) 1899 if (RTStrNICmpAscii(psz, s_aModes[i].psz, s_aModes[i].cch) == 0) 1900 { 1901 systemProperties.uProxyMode = s_aModes[i].enmMode; 1902 psz = RTStrStripL(psz + s_aModes[i].cch); 1903 if (*psz == ',') 1904 { 1905 /* Second field: The proxy host, possibly fully fledged proxy URL. */ 1906 psz = RTStrStripL(psz + 1); 1907 if (*psz != '\0' && *psz != ',') 1908 { 1909 const char *pszEnd = strchr(psz, ','); 1910 size_t cchHost = pszEnd ? pszEnd - psz : strlen(psz); 1911 while (cchHost > 0 && RT_C_IS_SPACE(psz[cchHost - 1])) 1912 cchHost--; 1913 systemProperties.strProxyUrl.assign(psz, cchHost); 1914 if (systemProperties.strProxyUrl.find("://") == RTCString::npos) 1915 systemProperties.strProxyUrl.replace(0, 0, "http://"); 1916 1917 /* Third field: The proxy port. Defaulted to 1080 for all proxies. 1918 The new settings has type specific default ports. */ 1919 uint16_t uPort = 1080; 1920 if (pszEnd) 1921 { 1922 int rc = RTStrToUInt16Ex(RTStrStripL(pszEnd + 1), NULL, 10, &uPort); 1923 if (RT_FAILURE(rc)) 1924 uPort = 1080; 1925 } 1926 RTURIPARSED Parsed; 1927 int rc = RTUriParse(systemProperties.strProxyUrl.c_str(), &Parsed); 1928 if (RT_SUCCESS(rc)) 1929 { 1930 if (Parsed.uAuthorityPort == UINT32_MAX) 1931 systemProperties.strProxyUrl.appendPrintf(systemProperties.strProxyUrl.endsWith(":") 1932 ? "%u" : ":%u", uPort); 1933 } 1934 else 1935 { 1936 LogRelFunc(("Dropping invalid proxy URL for %u: %s\n", 1937 systemProperties.uProxyMode, systemProperties.strProxyUrl.c_str())); 1938 systemProperties.strProxyUrl.setNull(); 1939 } 1940 } 1941 /* else: don't bother with the rest if we haven't got a host. */ 1942 } 1943 if ( systemProperties.strProxyUrl.isEmpty() 1944 && systemProperties.uProxyMode == ProxyMode_Manual) 1945 { 1946 systemProperties.uProxyMode = ProxyMode_System; 1947 return false; 1948 } 1949 return true; 1950 } 1951 LogRelFunc(("Unknown proxy type: %s\n", psz)); 1952 return false; 1953 } 1954 1955 /** 1869 1956 * Constructor. 1870 1957 * … … 1888 1975 xml::NodesLoop nlRootChildren(*m->pelmRoot); 1889 1976 const xml::ElementNode *pelmRootChild; 1977 bool fCopyProxySettingsFromExtraData = false; 1890 1978 while ((pelmRootChild = nlRootChildren.forAllNodes())) 1891 1979 { … … 1906 1994 pelmGlobalChild->getAttributeValue("webServiceAuthLibrary", systemProperties.strWebServiceAuthLibrary); 1907 1995 pelmGlobalChild->getAttributeValue("defaultVRDEExtPack", systemProperties.strDefaultVRDEExtPack); 1908 pelmGlobalChild->getAttributeValue("LogHistoryCount", systemProperties.u lLogHistoryCount);1996 pelmGlobalChild->getAttributeValue("LogHistoryCount", systemProperties.uLogHistoryCount); 1909 1997 pelmGlobalChild->getAttributeValue("autostartDatabasePath", systemProperties.strAutostartDatabasePath); 1910 1998 pelmGlobalChild->getAttributeValue("defaultFrontend", systemProperties.strDefaultFrontend); 1911 1999 pelmGlobalChild->getAttributeValue("exclusiveHwVirt", systemProperties.fExclusiveHwVirt); 2000 if (!pelmGlobalChild->getAttributeValue("proxyMode", systemProperties.uProxyMode)) 2001 fCopyProxySettingsFromExtraData = true; 2002 pelmGlobalChild->getAttributeValue("proxyUrl", systemProperties.strProxyUrl); 1912 2003 } 1913 2004 else if (pelmGlobalChild->nameEquals("ExtraData")) … … 1941 2032 } 1942 2033 2034 if (fCopyProxySettingsFromExtraData) 2035 for (StringsMap::const_iterator it = mapExtraDataItems.begin(); it != mapExtraDataItems.end(); ++it) 2036 if (it->first.equals("GUI/ProxySettings")) 2037 { 2038 convertGuiProxySettings(it->second); 2039 break; 2040 } 2041 1943 2042 clearDocument(); 1944 2043 } … … 2141 2240 if (systemProperties.strDefaultVRDEExtPack.length()) 2142 2241 pelmSysProps->setAttribute("defaultVRDEExtPack", systemProperties.strDefaultVRDEExtPack); 2143 pelmSysProps->setAttribute("LogHistoryCount", systemProperties.u lLogHistoryCount);2242 pelmSysProps->setAttribute("LogHistoryCount", systemProperties.uLogHistoryCount); 2144 2243 if (systemProperties.strAutostartDatabasePath.length()) 2145 2244 pelmSysProps->setAttribute("autostartDatabasePath", systemProperties.strAutostartDatabasePath); 2146 2245 if (systemProperties.strDefaultFrontend.length()) 2147 2246 pelmSysProps->setAttribute("defaultFrontend", systemProperties.strDefaultFrontend); 2247 if (systemProperties.strProxyUrl.length()) 2248 pelmSysProps->setAttribute("proxyUrl", systemProperties.strProxyUrl); 2249 pelmSysProps->setAttribute("proxyMode", systemProperties.uProxyMode); 2148 2250 pelmSysProps->setAttribute("exclusiveHwVirt", systemProperties.fExclusiveHwVirt); 2149 2251
Note:
See TracChangeset
for help on using the changeset viewer.