Changeset 58312 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Oct 19, 2015 4:23:50 PM (9 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxUtils.h
r58311 r58312 152 152 public: 153 153 154 /** Proxy states. */ 155 enum ProxyState 156 { 157 ProxyState_Disabled, 158 ProxyState_Enabled, 159 ProxyState_Auto 160 }; 161 154 162 /** Constructs object which parses passed @a strProxySettings. */ 155 163 UIProxyManager(const QString &strProxySettings = QString()) 156 : m_ fProxyEnabled(false)164 : m_enmProxyState(ProxyState_Auto) 157 165 , m_fAuthEnabled(false) 158 166 { … … 164 172 /* Parse proxy state, host and port: */ 165 173 if (proxySettings.size() > 0) 166 m_ fProxyEnabled = proxySettings[0] == "proxyEnabled";174 m_enmProxyState = proxyStateFromString(proxySettings[0]); 167 175 if (proxySettings.size() > 1) 168 176 m_strProxyHost = proxySettings[1]; … … 184 192 /* Serialize settings: */ 185 193 QString strResult; 186 if (m_ fProxyEnabled|| !m_strProxyHost.isEmpty() || !m_strProxyPort.isEmpty() ||194 if (m_enmProxyState != ProxyState_Auto || !m_strProxyHost.isEmpty() || !m_strProxyPort.isEmpty() || 187 195 m_fAuthEnabled || !m_strAuthLogin.isEmpty() || !m_strAuthPassword.isEmpty()) 188 196 { 189 197 QStringList proxySettings; 190 proxySettings << QString(m_fProxyEnabled ? "proxyEnabled" : "proxyDisabled");198 proxySettings << proxyStateToString(m_enmProxyState); 191 199 proxySettings << m_strProxyHost; 192 200 proxySettings << m_strProxyPort; … … 199 207 } 200 208 201 /** Returns whether the proxy is enabled. */202 bool proxyEnabled() const { return m_fProxyEnabled; }209 /** Returns the proxy state. */ 210 ProxyState proxyState() const { return m_enmProxyState; } 203 211 /** Returns the proxy host. */ 204 212 const QString& proxyHost() const { return m_strProxyHost; } … … 213 221 const QString& authPassword() const { return m_strAuthPassword; } 214 222 215 /** Defines whether the proxy is @a fEnabled. */216 void setProxy Enabled(bool fEnabled) { m_fProxyEnabled = fEnabled; }223 /** Defines the proxy @a enmState. */ 224 void setProxyState(ProxyState enmState) { m_enmProxyState = enmState; } 217 225 /** Defines the proxy @a strHost. */ 218 226 void setProxyHost(const QString &strHost) { m_strProxyHost = strHost; } … … 229 237 private: 230 238 231 /** Holds whether the proxy is enabled. */ 232 bool m_fProxyEnabled; 239 /** Converts passed @a state to corresponding #QString. */ 240 static QString proxyStateToString(ProxyState state) 241 { 242 switch (state) 243 { 244 case ProxyState_Disabled: return QString("ProxyDisabled"); 245 case ProxyState_Enabled: return QString("ProxyEnabled"); 246 case ProxyState_Auto: break; 247 } 248 return QString("ProxyAuto"); 249 } 250 251 /** Converts passed @a strState to corresponding #ProxyState. */ 252 static ProxyState proxyStateFromString(const QString &strState) 253 { 254 /* Compose the map of known states: */ 255 QMap<QString, ProxyState> states; 256 states["ProxyDisabled"] = ProxyState_Disabled; // New since VBox 5.0 257 states["proxyEnabled"] = ProxyState_Enabled; // Old since VBox 4.1 258 states["ProxyEnabled"] = ProxyState_Enabled; // New since VBox 5.0 259 /* Return one of registered or 'Auto' by default: */ 260 return states.value(strState, ProxyState_Auto); 261 } 262 263 /** Holds the proxy state. */ 264 ProxyState m_enmProxyState; 233 265 /** Holds the proxy host. */ 234 266 QString m_strProxyHost; -
trunk/src/VBox/Frontends/VirtualBox/src/net/UINetworkReply.cpp
r58266 r58312 383 383 384 384 #ifndef VBOX_GUI_IN_TST_SSL_CERT_DOWNLOADS 385 /* Get the proxy manager: */385 /* Get the proxy-manager: */ 386 386 UIProxyManager proxyManager(vboxGlobal().settings().proxySettings()); 387 387 388 /* If the specific proxy settings aren't enabled, we'll use the 389 system default proxy. Otherwise assume it's configured. */ 390 if (proxyManager.proxyEnabled()) 391 return RTHttpSetProxy(m_hHttp, 392 proxyManager.proxyHost().toUtf8().constData(), 393 proxyManager.proxyPort().toUInt(), 394 NULL /* pszProxyUser */, NULL /* pszProxyPwd */); 395 396 /** @todo This should be some kind of tristate: 397 * - system configured proxy ("proxyDisabled" as well as default "") 398 * - user configured proxy ("proxyEnabled"). 399 * - user configured "no proxy" (currently missing). 400 * In the two last cases, call RTHttpSetProxy. 401 * 402 * Alternatively, we could opt not to give the user a way of doing "no proxy", 403 * that would require no real changes to the visible GUI... Just a thought. 404 */ 405 #endif 388 /* If the specific proxy settings are enabled, we'll use them 389 * unless user disabled that functionality manually. */ 390 switch (proxyManager.proxyState()) 391 { 392 case UIProxyManager::ProxyState_Enabled: 393 return RTHttpSetProxy(m_hHttp, 394 proxyManager.proxyHost().toUtf8().constData(), 395 proxyManager.proxyPort().toUInt(), 396 NULL /* pszProxyUser */, NULL /* pszProxyPwd */); 397 case UIProxyManager::ProxyState_Disabled: 398 return VINF_SUCCESS; 399 default: 400 break; 401 } 402 #endif /* VBOX_GUI_IN_TST_SSL_CERT_DOWNLOADS */ 403 404 /* By default, use system proxy: */ 406 405 return RTHttpUseSystemProxySettings(m_hHttp); 407 406 } … … 532 531 if (RT_SUCCESS(rc)) 533 532 { 534 m_reply = QByteArray((char*)pvResponse, cbResponse);533 m_reply = QByteArray((char*)pvResponse, (int)cbResponse); 535 534 RTHttpFreeResponse(pvResponse); 536 535 } … … 559 558 if (RT_SUCCESS(rc)) 560 559 { 561 m_reply = QByteArray((char*)pvResponse, cbResponse);560 m_reply = QByteArray((char*)pvResponse, (int)cbResponse); 562 561 RTHttpFreeResponse(pvResponse); 563 562 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.cpp
r52730 r58312 38 38 39 39 /* Setup widgets: */ 40 QButtonGroup *pButtonGroup = new QButtonGroup(this); 41 pButtonGroup->addButton(m_pRadioProxyAuto); 42 pButtonGroup->addButton(m_pRadioProxyDisabled); 43 pButtonGroup->addButton(m_pRadioProxyEnabled); 40 44 m_pPortEditor->setFixedWidthByText(QString().fill('0', 6)); 41 45 m_pHostEditor->setValidator(new QRegExpValidator(QRegExp("\\S+"), m_pHostEditor)); … … 43 47 44 48 /* Setup connections: */ 45 connect( m_pCheckboxProxy, SIGNAL(toggled(bool)), this, SLOT(sltProxyToggled()));49 connect(pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltProxyToggled())); 46 50 connect(m_pHostEditor, SIGNAL(textEdited(const QString&)), this, SLOT(revalidate())); 47 51 connect(m_pPortEditor, SIGNAL(textEdited(const QString&)), this, SLOT(revalidate())); … … 60 64 /* Load to cache: */ 61 65 UIProxyManager proxyManager(m_settings.proxySettings()); 62 m_cache.m_ fProxyEnabled = proxyManager.proxyEnabled();66 m_cache.m_enmProxyState = proxyManager.proxyState(); 63 67 m_cache.m_strProxyHost = proxyManager.proxyHost(); 64 68 m_cache.m_strProxyPort = proxyManager.proxyPort(); … … 73 77 { 74 78 /* Fetch from cache: */ 75 m_pCheckboxProxy->setChecked(m_cache.m_fProxyEnabled); 79 switch (m_cache.m_enmProxyState) 80 { 81 case UIProxyManager::ProxyState_Auto: m_pRadioProxyAuto->setChecked(true); break; 82 case UIProxyManager::ProxyState_Disabled: m_pRadioProxyDisabled->setChecked(true); break; 83 case UIProxyManager::ProxyState_Enabled: m_pRadioProxyEnabled->setChecked(true); break; 84 } 76 85 m_pHostEditor->setText(m_cache.m_strProxyHost); 77 86 m_pPortEditor->setText(m_cache.m_strProxyPort); … … 87 96 { 88 97 /* Upload to cache: */ 89 m_cache.m_fProxyEnabled = m_pCheckboxProxy->isChecked(); 98 m_cache.m_enmProxyState = m_pRadioProxyEnabled->isChecked() ? UIProxyManager::ProxyState_Enabled : 99 m_pRadioProxyDisabled->isChecked() ? UIProxyManager::ProxyState_Disabled : 100 UIProxyManager::ProxyState_Auto; 90 101 m_cache.m_strProxyHost = m_pHostEditor->text(); 91 102 m_cache.m_strProxyPort = m_pPortEditor->text(); … … 100 111 101 112 UIProxyManager proxyManager; 102 proxyManager.setProxy Enabled(m_cache.m_fProxyEnabled);113 proxyManager.setProxyState(m_cache.m_enmProxyState); 103 114 proxyManager.setProxyHost(m_cache.m_strProxyHost); 104 115 proxyManager.setProxyPort(m_cache.m_strProxyPort); … … 112 123 { 113 124 /* Pass if proxy is disabled: */ 114 if (!m_p CheckboxProxy->isChecked())125 if (!m_pRadioProxyEnabled->isChecked()) 115 126 return true; 116 127 … … 146 157 { 147 158 /* Configure navigation: */ 148 setTabOrder(pWidget, m_pCheckboxProxy); 149 setTabOrder(m_pCheckboxProxy, m_pHostEditor); 159 setTabOrder(pWidget, m_pRadioProxyAuto); 160 setTabOrder(m_pRadioProxyAuto, m_pRadioProxyDisabled); 161 setTabOrder(m_pRadioProxyDisabled, m_pRadioProxyEnabled); 162 setTabOrder(m_pRadioProxyEnabled, m_pHostEditor); 150 163 setTabOrder(m_pHostEditor, m_pPortEditor); 151 164 } … … 160 173 { 161 174 /* Update widgets availability: */ 162 m_pContainerProxy->setEnabled(m_p CheckboxProxy->isChecked());175 m_pContainerProxy->setEnabled(m_pRadioProxyEnabled->isChecked()); 163 176 164 177 /* Revalidate: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.h
r55401 r58312 20 20 21 21 /* Local includes */ 22 #include "VBoxUtils.h" 22 23 #include "UISettingsPage.h" 23 24 #include "UIGlobalSettingsProxy.gen.h" … … 27 28 { 28 29 UISettingsCacheGlobalProxy() 29 : m_ fProxyEnabled(false)30 : m_enmProxyState(UIProxyManager::ProxyState_Auto) 30 31 {} 31 bool m_fProxyEnabled;32 UIProxyManager::ProxyState m_enmProxyState; 32 33 QString m_strProxyHost; 33 34 QString m_strProxyPort; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsProxy.ui
r56153 r58312 20 20 </property> 21 21 <item row="0" column="0" colspan="2"> 22 <widget class="Q CheckBox" name="m_pCheckboxProxy">22 <widget class="QRadioButton" name="m_pRadioProxyAuto"> 23 23 <property name="whatsThis"> 24 <string>When ch ecked, VirtualBox will use the proxy settings suppliedfor tasks like downloading Guest Additions from the network or checking for updates.</string>24 <string>When chosen, VirtualBox will try to auto-detect host proxy settings for tasks like downloading Guest Additions from the network or checking for updates.</string> 25 25 </property> 26 26 <property name="text"> 27 <string>& Enable Proxy</string>27 <string>&Auto-detect Host Proxy Settings</string> 28 28 </property> 29 29 </widget> 30 30 </item> 31 <item row="1" column="0"> 31 <item row="1" column="0" colspan="2"> 32 <widget class="QRadioButton" name="m_pRadioProxyDisabled"> 33 <property name="whatsThis"> 34 <string>When chosen, VirtualBox will use direct Internet connection for tasks like downloading Guest Additions from the network or checking for updates.</string> 35 </property> 36 <property name="text"> 37 <string>&Direct Connection to the Internet</string> 38 </property> 39 </widget> 40 </item> 41 <item row="2" column="0" colspan="2"> 42 <widget class="QRadioButton" name="m_pRadioProxyEnabled"> 43 <property name="whatsThis"> 44 <string>When chosen, VirtualBox will use the proxy settings supplied for tasks like downloading Guest Additions from the network or checking for updates.</string> 45 </property> 46 <property name="text"> 47 <string>&Manual Proxy Configuration</string> 48 </property> 49 </widget> 50 </item> 51 <item row="3" column="0"> 32 52 <spacer> 33 53 <property name="orientation"> … … 45 65 </spacer> 46 66 </item> 47 <item row=" 1" column="1" colspan="2">67 <item row="3" column="1"> 48 68 <widget class="QWidget" name="m_pContainerProxy"> 49 69 <property name="sizePolicy"> … … 100 120 </widget> 101 121 </item> 102 <item row=" 2" column="0" colspan="3">122 <item row="4" column="0" colspan="2"> 103 123 <spacer> 104 124 <property name="orientation">
Note:
See TracChangeset
for help on using the changeset viewer.