Guest User

Untitled

a guest
Jul 14th, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. Index: src/vidalia/config/NetworkPage.cpp
  2. ===================================================================
  3. --- src/vidalia/config/NetworkPage.cpp (revision 4140)
  4. +++ src/vidalia/config/NetworkPage.cpp (working copy)
  5. @@ -58,12 +58,6 @@
  6. ui.lineProxyAddress->setValidator(new DomainValidator(this));
  7. ui.lineProxyPort->setValidator(new QIntValidator(1, 65535, this));
  8.  
  9. - ui.cmboProxyType->insertItem(NetworkSettings::Socks4Proxy, tr("SOCKS 4"));
  10. - ui.cmboProxyType->insertItem(NetworkSettings::Socks5Proxy, tr("SOCKS 5"));
  11. - ui.cmboProxyType->insertItem(NetworkSettings::HttpProxy, tr("HTTP"));
  12. - ui.cmboProxyType->insertItem(NetworkSettings::HttpHttpsProxy,
  13. - tr("HTTP / HTTPS"));
  14. -
  15. vApp->createShortcut(QKeySequence(QKeySequence::Copy),
  16. ui.listBridges, this,
  17. SLOT(copySelectedBridgesToClipboard()));
  18. @@ -294,9 +288,13 @@
  19.  
  20. user = ui.lineProxyUsername->text();
  21. pass = ui.lineProxyPassword->text();
  22. -
  23. - int type = ui.cmboProxyType->currentIndex();
  24. +
  25. + QVariant data;
  26. + int type;
  27.  
  28. + data = ui.cmboProxyType->itemData(ui.cmboProxyType->currentIndex());
  29. + Q_ASSERT(data.isValid());
  30. + type = data.toInt();
  31. Q_ASSERT(type >= NetworkSettings::ProxyTypeMin &&
  32. type <= NetworkSettings::ProxyTypeMax);
  33. proxy = static_cast<NetworkSettings::ProxyType>(type);
  34. @@ -335,10 +333,11 @@
  35. {
  36. NetworkSettings settings(Vidalia::torControl());
  37. QStringList reachablePortStrings;
  38. + NetworkSettings::ProxyType proxyType;
  39.  
  40. /* Load proxy settings */
  41. - ui.chkUseProxy->setChecked(settings.getProxyType() != NetworkSettings::NoProxy);
  42. - ui.cmboProxyType->setCurrentIndex(settings.getProxyType());
  43. + proxyType = settings.getProxyType();
  44. + ui.chkUseProxy->setChecked(proxyType != NetworkSettings::NoProxy);
  45. QStringList proxy = settings.getProxyAddress().split(":");
  46. if (proxy.size() >= 1)
  47. ui.lineProxyAddress->setText(proxy.at(0));
  48. @@ -347,6 +346,26 @@
  49. ui.lineProxyUsername->setText(settings.getProxyUsername());
  50. ui.lineProxyPassword->setText(settings.getProxyPassword());
  51.  
  52. + /* SOCKS options are only available on Tor >= 0.2.2.1-alpha, so don't show
  53. + * them if Tor is running and its version is less than that. */
  54. + ui.cmboProxyType->clear();
  55. + if (!vApp->torControl()->isRunning()
  56. + || vApp->torControl()->getTorVersion() >= 0x020201) {
  57. + ui.cmboProxyType->addItem(tr("SOCKS 4"), NetworkSettings::Socks4Proxy);
  58. + ui.cmboProxyType->addItem(tr("SOCKS 5"), NetworkSettings::Socks5Proxy);
  59. + } else if (proxyType == NetworkSettings::Socks4Proxy
  60. + || proxyType == NetworkSettings::Socks5Proxy) {
  61. + /* Disable proxy if the settings include a SOCKS proxy and our version of
  62. + * Tor is not compatible. */
  63. + proxyType = NetworkSettings::NoProxy;
  64. + ui.chkUseProxy->setChecked(false);
  65. + }
  66. + ui.cmboProxyType->addItem(tr("HTTP"), NetworkSettings::HttpProxy);
  67. + ui.cmboProxyType->addItem(tr("HTTP / HTTPS"),
  68. + NetworkSettings::HttpHttpsProxy);
  69. +
  70. + ui.cmboProxyType->setCurrentIndex(ui.cmboProxyType->findData(proxyType));
  71. +
  72. /* Load firewall settings */
  73. ui.chkFascistFirewall->setChecked(settings.getFascistFirewall());
  74. QList<quint16> reachablePorts = settings.getReachablePorts();
  75. @@ -448,7 +467,10 @@
  76. void
  77. NetworkPage::proxyTypeChanged(int selection)
  78. {
  79. - if (selection == NetworkSettings::Socks4Proxy) {
  80. + QVariant data = ui.cmboProxyType->itemData(selection);
  81. +
  82. + if (data.isValid()
  83. + && data.toInt() == NetworkSettings::Socks4Proxy) {
  84. ui.lineProxyUsername->setEnabled(false);
  85. ui.lineProxyPassword->setEnabled(false);
  86. } else {
Add Comment
Please, Sign In to add comment