[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r4140: Add support in the Network settings page for configuring the (in vidalia/trunk: . src/vidalia/config)



Author: edmanm
Date: 2009-10-03 17:49:21 -0400 (Sat, 03 Oct 2009)
New Revision: 4140

Modified:
   vidalia/trunk/CHANGELOG
   vidalia/trunk/src/vidalia/config/NetworkPage.cpp
   vidalia/trunk/src/vidalia/config/NetworkPage.h
   vidalia/trunk/src/vidalia/config/NetworkPage.ui
   vidalia/trunk/src/vidalia/config/NetworkSettings.cpp
   vidalia/trunk/src/vidalia/config/NetworkSettings.h
Log:

Add support in the Network settings page for configuring the Socks4Proxy and
Socks5Proxy* options that were added in Tor 0.2.2.1-alpha. Patch from
Christopher Davis.


Modified: vidalia/trunk/CHANGELOG
===================================================================
--- vidalia/trunk/CHANGELOG	2009-10-02 09:39:32 UTC (rev 4139)
+++ vidalia/trunk/CHANGELOG	2009-10-03 21:49:21 UTC (rev 4140)
@@ -1,4 +1,7 @@
 0.2.5   xx-xxx-2009
+  o Add support in the Network settings page for configuring the
+    Socks4Proxy and Socks5Proxy* options that were added in
+    Tor 0.2.2.1-alpha. Patch from Christopher Davis.
   o Add ports 7000 and 7001 to the list of ports excluded by the IRC
     category in the exit policy configuration tab. (Ticket #517)
   o Add a context menu for highlighted event items in the "Basic" message

Modified: vidalia/trunk/src/vidalia/config/NetworkPage.cpp
===================================================================
--- vidalia/trunk/src/vidalia/config/NetworkPage.cpp	2009-10-02 09:39:32 UTC (rev 4139)
+++ vidalia/trunk/src/vidalia/config/NetworkPage.cpp	2009-10-03 21:49:21 UTC (rev 4140)
@@ -52,10 +52,18 @@
   connect(ui.lblHelpFindBridges, SIGNAL(linkActivated(QString)),
           this, SLOT(onLinkActivated(QString)));
   connect(ui.btnFindBridges, SIGNAL(clicked()), this, SLOT(findBridges()));
+  connect(ui.cmboProxyType, SIGNAL(currentIndexChanged(int)),
+          this, SLOT(proxyTypeChanged(int)));
 
-  ui.lineHttpProxyAddress->setValidator(new DomainValidator(this));
-  ui.lineHttpProxyPort->setValidator(new QIntValidator(1, 65535, this));
+  ui.lineProxyAddress->setValidator(new DomainValidator(this));
+  ui.lineProxyPort->setValidator(new QIntValidator(1, 65535, this));
 
+  ui.cmboProxyType->insertItem(NetworkSettings::Socks4Proxy, tr("SOCKS 4"));
+  ui.cmboProxyType->insertItem(NetworkSettings::Socks5Proxy, tr("SOCKS 5"));
+  ui.cmboProxyType->insertItem(NetworkSettings::HttpProxy, tr("HTTP"));
+  ui.cmboProxyType->insertItem(NetworkSettings::HttpHttpsProxy,
+                               tr("HTTP / HTTPS"));
+
   vApp->createShortcut(QKeySequence(QKeySequence::Copy),
                        ui.listBridges, this,
                        SLOT(copySelectedBridgesToClipboard()));
@@ -250,17 +258,25 @@
 NetworkPage::save(QString &errmsg)
 {
   NetworkSettings settings(Vidalia::torControl());
+  QString addr;
+  QString user, pass;
+  NetworkSettings::ProxyType proxy = NetworkSettings::NoProxy;
   QStringList bridgeList;
   QList<quint16> reachablePorts;
   bool ok;
   
-  if (ui.chkUseProxy->isChecked()
-        && (ui.lineHttpProxyAddress->text().isEmpty()
-            || ui.lineHttpProxyPort->text().isEmpty())) {
-    errmsg = tr("You must specify both an IP address or hostname and a "
-                "port number to configure Tor to use a proxy to access "
-                "the Internet.");
-    return false;
+  if (ui.chkUseProxy->isChecked()) {
+    if (ui.lineProxyAddress->text().isEmpty()
+          || ui.lineProxyPort->text().isEmpty()) {
+      errmsg = tr("You must specify both an IP address or hostname and a "
+                  "port number to configure Tor to use a proxy to access "
+                  "the Internet.");
+      return false;
+    }
+    if (ui.cmboProxyType->currentIndex() < 0) {
+      errmsg = tr("You must select the proxy type.");
+      return false;
+    }
   }
   if (ui.chkFascistFirewall->isChecked()
         && ui.lineReachablePorts->text().isEmpty()) {
@@ -269,32 +285,28 @@
     return false;
   }
 
-  /* Save the HTTP/HTTPS proxy settings */
-  settings.setUseHttpProxy(ui.chkUseProxy->isChecked());
-  settings.setUseHttpsProxy(ui.chkProxyUseHttps->isChecked());
-  if (!ui.lineHttpProxyAddress->text().isEmpty()) {
-    QString proxy = ui.lineHttpProxyAddress->text();
-    if (!ui.lineHttpProxyPort->text().isEmpty())
-      proxy += ":" + ui.lineHttpProxyPort->text();
+  if (ui.chkUseProxy->isChecked()) {
+    if (!ui.lineProxyAddress->text().isEmpty()) {
+      addr = ui.lineProxyAddress->text();
+      if (!ui.lineProxyPort->text().isEmpty())
+        addr += ":" + ui.lineProxyPort->text();
+    }
 
-    settings.setHttpProxy(proxy);
-    settings.setHttpsProxy(proxy);
-  } else {
-    settings.setHttpProxy("");
-    settings.setHttpsProxy("");
+    user = ui.lineProxyUsername->text();
+    pass = ui.lineProxyPassword->text();
+  
+    int type = ui.cmboProxyType->currentIndex();
+
+    Q_ASSERT(type >= NetworkSettings::ProxyTypeMin &&
+             type <= NetworkSettings::ProxyTypeMax);
+    proxy = static_cast<NetworkSettings::ProxyType>(type);
   }
 
-  if (!ui.lineHttpProxyUsername->text().isEmpty() ||
-      !ui.lineHttpProxyPassword->text().isEmpty()) {
-    QString auth = ui.lineHttpProxyUsername->text() + ":" +
-                   ui.lineHttpProxyPassword->text();
-    settings.setHttpProxyAuthenticator(auth);
-    settings.setHttpsProxyAuthenticator(auth);
-  } else {
-    settings.setHttpProxyAuthenticator("");
-    settings.setHttpsProxyAuthenticator("");
-  }
-  
+  settings.setProxyType(proxy);
+  settings.setProxyAddress(addr);
+  settings.setProxyUsername(user);
+  settings.setProxyPassword(pass);
+ 
   /* Save the reachable port settings */
   settings.setFascistFirewall(ui.chkFascistFirewall->isChecked());
   foreach (QString portString,
@@ -324,19 +336,16 @@
   NetworkSettings settings(Vidalia::torControl());
   QStringList reachablePortStrings;
 
-  /* Load HTTP/HTTPS proxy settings */
-  ui.chkUseProxy->setChecked(settings.getUseHttpProxy());
-  ui.chkProxyUseHttps->setChecked(settings.getUseHttpsProxy());
-  QStringList proxy = settings.getHttpProxy().split(":");
-  QStringList proxyAuth = settings.getHttpProxyAuthenticator().split(":");
+  /* Load proxy settings */
+  ui.chkUseProxy->setChecked(settings.getProxyType() != NetworkSettings::NoProxy);
+  ui.cmboProxyType->setCurrentIndex(settings.getProxyType());
+  QStringList proxy = settings.getProxyAddress().split(":");
   if (proxy.size() >= 1)
-    ui.lineHttpProxyAddress->setText(proxy.at(0));
+    ui.lineProxyAddress->setText(proxy.at(0));
   if (proxy.size() >= 2)
-    ui.lineHttpProxyPort->setText(proxy.at(1));
-  if (proxyAuth.size() >= 1)  
-    ui.lineHttpProxyUsername->setText(proxyAuth.at(0));
-  if (proxyAuth.size() >= 2)
-    ui.lineHttpProxyPassword->setText(proxyAuth.at(1));
+    ui.lineProxyPort->setText(proxy.at(1));
+  ui.lineProxyUsername->setText(settings.getProxyUsername());
+  ui.lineProxyPassword->setText(settings.getProxyPassword());
 
   /* Load firewall settings */
   ui.chkFascistFirewall->setChecked(settings.getFascistFirewall());
@@ -388,11 +397,12 @@
 void
 NetworkPage::startBridgeRequest()
 { 
-  if (ui.chkUseProxy->isChecked() && ui.chkProxyUseHttps->isChecked()) {
-    _bridgeDownloader->setProxy(ui.lineHttpProxyAddress->text(),
-                                ui.lineHttpProxyPort->text().toUInt(),
-                                ui.lineHttpProxyUsername->text(),
-                                ui.lineHttpProxyPassword->text());
+  if (ui.chkUseProxy->isChecked() &&
+     ui.cmboProxyType->currentIndex() == NetworkSettings::HttpHttpsProxy) {
+    _bridgeDownloader->setProxy(ui.lineProxyAddress->text(),
+                                ui.lineProxyPort->text().toUInt(),
+                                ui.lineProxyUsername->text(),
+                                ui.lineProxyPassword->text());
   }
 
   _bridgeDownloader->downloadBridges(BridgeDownloader::DownloadMethodHttps);
@@ -433,3 +443,17 @@
   }
 }
 
+/** Disable proxy username and password fields when the user wants to use
+ * a SOCKS 4 proxy. */
+void
+NetworkPage::proxyTypeChanged(int selection)
+{
+  if (selection == NetworkSettings::Socks4Proxy) {
+    ui.lineProxyUsername->setEnabled(false);
+    ui.lineProxyPassword->setEnabled(false);
+  } else {
+    ui.lineProxyUsername->setEnabled(true);
+    ui.lineProxyPassword->setEnabled(true);
+  }
+}
+

Modified: vidalia/trunk/src/vidalia/config/NetworkPage.h
===================================================================
--- vidalia/trunk/src/vidalia/config/NetworkPage.h	2009-10-02 09:39:32 UTC (rev 4139)
+++ vidalia/trunk/src/vidalia/config/NetworkPage.h	2009-10-03 21:49:21 UTC (rev 4140)
@@ -77,6 +77,10 @@
    * received. */
   void bridgeRequestFinished(const QStringList &bridges);
 
+  /** Disable proxy username and password fields when the user wants to use
+   * a SOCKS 4 proxy. */
+  void proxyTypeChanged(int selection);
+
 private:
   /** Verifies that <b>bridge</b> is a valid bridge identifier and places a 
    * normalized identifier in <b>out</b>. The normalized identifier will have

Modified: vidalia/trunk/src/vidalia/config/NetworkPage.ui
===================================================================
--- vidalia/trunk/src/vidalia/config/NetworkPage.ui	2009-10-02 09:39:32 UTC (rev 4139)
+++ vidalia/trunk/src/vidalia/config/NetworkPage.ui	2009-10-03 21:49:21 UTC (rev 4140)
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>NetworkPage</class>
- <widget class="QWidget" name="NetworkPage" >
-  <property name="geometry" >
+ <widget class="QWidget" name="NetworkPage">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
@@ -9,152 +10,145 @@
     <height>659</height>
    </rect>
   </property>
-  <property name="contextMenuPolicy" >
+  <property name="contextMenuPolicy">
    <enum>Qt::NoContextMenu</enum>
   </property>
-  <layout class="QVBoxLayout" >
-   <property name="spacing" >
+  <layout class="QVBoxLayout">
+   <property name="spacing">
     <number>6</number>
    </property>
-   <property name="margin" >
+   <property name="margin">
     <number>9</number>
    </property>
    <item>
-    <widget class="QCheckBox" name="chkUseProxy" >
-     <property name="toolTip" >
+    <widget class="QCheckBox" name="chkUseProxy">
+     <property name="toolTip">
       <string>Check if your local network requires a proxy to access the Internet</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>I use a proxy to access the Internet</string>
      </property>
-     <property name="checked" >
+     <property name="checked">
       <bool>true</bool>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="grpProxySettings" >
-     <property name="sizePolicy" >
-      <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+    <widget class="QGroupBox" name="grpProxySettings">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
-     <property name="minimumSize" >
+     <property name="minimumSize">
       <size>
        <width>0</width>
        <height>136</height>
       </size>
      </property>
-     <property name="maximumSize" >
+     <property name="maximumSize">
       <size>
        <width>16777215</width>
        <height>136</height>
       </size>
      </property>
-     <property name="title" >
+     <property name="title">
       <string>Proxy Settings</string>
      </property>
-     <layout class="QGridLayout" >
-      <property name="margin" >
+     <layout class="QGridLayout">
+      <property name="margin">
        <number>9</number>
       </property>
-      <property name="spacing" >
+      <property name="spacing">
        <number>6</number>
       </property>
-      <item row="0" column="0" >
-       <widget class="QLabel" name="lblHttpProxyAddress" >
-        <property name="text" >
-         <string>HTTP Proxy:</string>
+      <item row="0" column="0">
+       <widget class="QLabel" name="lblProxyAddress">
+        <property name="text">
+         <string>Address:</string>
         </property>
-        <property name="alignment" >
+        <property name="alignment">
          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
         </property>
        </widget>
       </item>
-      <item row="1" column="0" >
-       <widget class="QLabel" name="lblHttpProxyUsername" >
-        <property name="text" >
-         <string>Username:</string>
-        </property>
-        <property name="alignment" >
-         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1" colspan="3" >
-       <widget class="QCheckBox" name="chkProxyUseHttps" >
-        <property name="text" >
-         <string>Use this proxy for HTTPS also</string>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="1" colspan="4" >
-       <layout class="QHBoxLayout" >
-        <property name="spacing" >
+      <item row="0" column="1" colspan="2">
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
-        <property name="margin" >
+        <property name="margin">
          <number>0</number>
         </property>
         <item>
-         <widget class="QLineEdit" name="lineHttpProxyUsername" />
+         <widget class="QLineEdit" name="lineProxyAddress"/>
         </item>
         <item>
-         <widget class="QLabel" name="lblHttpProxyPassword" >
-          <property name="text" >
-           <string>Password:</string>
+         <widget class="QLabel" name="lblProxyPort">
+          <property name="text">
+           <string>Port:</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QLineEdit" name="lineHttpProxyPassword" >
-          <property name="echoMode" >
-           <enum>QLineEdit::Password</enum>
+         <widget class="QLineEdit" name="lineProxyPort">
+          <property name="maximumSize">
+           <size>
+            <width>75</width>
+            <height>16777215</height>
+           </size>
           </property>
+          <property name="maxLength">
+           <number>5</number>
+          </property>
          </widget>
         </item>
        </layout>
       </item>
-      <item row="0" column="1" colspan="4" >
-       <layout class="QHBoxLayout" >
-        <property name="spacing" >
+      <item row="1" column="0">
+       <widget class="QLabel" name="lblProxyUsername">
+        <property name="text">
+         <string>Username:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" colspan="2">
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
-        <property name="margin" >
+        <property name="margin">
          <number>0</number>
         </property>
         <item>
-         <widget class="QLineEdit" name="lineHttpProxyAddress" />
+         <widget class="QLineEdit" name="lineProxyUsername"/>
         </item>
         <item>
-         <widget class="QLabel" name="lblHttpProxyPort" >
-          <property name="text" >
-           <string>Port:</string>
+         <widget class="QLabel" name="lblProxyPassword">
+          <property name="text">
+           <string>Password:</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QLineEdit" name="lineHttpProxyPort" >
-          <property name="maximumSize" >
-           <size>
-            <width>75</width>
-            <height>16777215</height>
-           </size>
+         <widget class="QLineEdit" name="lineProxyPassword">
+          <property name="echoMode">
+           <enum>QLineEdit::Password</enum>
           </property>
-          <property name="maxLength" >
-           <number>5</number>
-          </property>
          </widget>
         </item>
        </layout>
       </item>
-      <item row="1" column="4" >
+      <item row="1" column="2">
        <spacer>
-        <property name="orientation" >
+        <property name="orientation">
          <enum>Qt::Horizontal</enum>
         </property>
-        <property name="sizeHint" >
+        <property name="sizeHint" stdset="0">
          <size>
           <width>40</width>
           <height>20</height>
@@ -162,62 +156,75 @@
         </property>
        </spacer>
       </item>
+      <item row="2" column="0">
+       <widget class="QLabel" name="lblProxyType">
+        <property name="text">
+         <string>Type:</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QComboBox" name="cmboProxyType"/>
+      </item>
      </layout>
     </widget>
    </item>
    <item>
-    <widget class="QCheckBox" name="chkFascistFirewall" >
-     <property name="contextMenuPolicy" >
+    <widget class="QCheckBox" name="chkFascistFirewall">
+     <property name="contextMenuPolicy">
       <enum>Qt::NoContextMenu</enum>
      </property>
-     <property name="toolTip" >
+     <property name="toolTip">
       <string>Check to only connect to relays using ports allowed by your firewall</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>My firewall only lets me connect to certain ports</string>
      </property>
-     <property name="checked" >
+     <property name="checked">
       <bool>true</bool>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="grpFirewallSettings" >
-     <property name="sizePolicy" >
-      <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+    <widget class="QGroupBox" name="grpFirewallSettings">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
-     <property name="minimumSize" >
+     <property name="minimumSize">
       <size>
        <width>0</width>
        <height>75</height>
       </size>
      </property>
-     <property name="title" >
+     <property name="title">
       <string>Firewall Settings</string>
      </property>
-     <layout class="QHBoxLayout" >
-      <property name="spacing" >
+     <layout class="QHBoxLayout">
+      <property name="spacing">
        <number>6</number>
       </property>
-      <property name="margin" >
+      <property name="margin">
        <number>9</number>
       </property>
       <item>
-       <widget class="QLabel" name="lblReachablePorts" >
-        <property name="text" >
+       <widget class="QLabel" name="lblReachablePorts">
+        <property name="text">
          <string>Allowed Ports:</string>
         </property>
        </widget>
       </item>
       <item>
-       <widget class="QLineEdit" name="lineReachablePorts" >
-        <property name="inputMask" >
+       <widget class="QLineEdit" name="lineReachablePorts">
+        <property name="inputMask">
          <string/>
         </property>
-        <property name="text" >
+        <property name="text">
          <string>80, 443</string>
         </property>
        </widget>
@@ -226,63 +233,63 @@
     </widget>
    </item>
    <item>
-    <widget class="QCheckBox" name="chkUseBridges" >
-     <property name="toolTip" >
+    <widget class="QCheckBox" name="chkUseBridges">
+     <property name="toolTip">
       <string>Check to encrypt directory requests and, optionally, use bridge relays to access the Tor network</string>
      </property>
-     <property name="text" >
+     <property name="text">
       <string>My ISP blocks connections to the Tor network</string>
      </property>
-     <property name="checked" >
+     <property name="checked">
       <bool>true</bool>
      </property>
     </widget>
    </item>
    <item>
-    <widget class="QGroupBox" name="grpBridgeSettings" >
-     <property name="sizePolicy" >
-      <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+    <widget class="QGroupBox" name="grpBridgeSettings">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
        <horstretch>0</horstretch>
        <verstretch>0</verstretch>
       </sizepolicy>
      </property>
-     <property name="minimumSize" >
+     <property name="minimumSize">
       <size>
        <width>0</width>
        <height>200</height>
       </size>
      </property>
-     <property name="title" >
+     <property name="title">
       <string>Bridge Settings</string>
      </property>
-     <layout class="QVBoxLayout" >
-      <property name="spacing" >
+     <layout class="QVBoxLayout">
+      <property name="spacing">
        <number>6</number>
       </property>
-      <property name="margin" >
+      <property name="margin">
        <number>9</number>
       </property>
       <item>
-       <layout class="QHBoxLayout" >
-        <property name="spacing" >
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
-        <property name="margin" >
+        <property name="margin">
          <number>0</number>
         </property>
         <item>
-         <widget class="QLabel" name="lblAddBridge" >
-          <property name="text" >
+         <widget class="QLabel" name="lblAddBridge">
+          <property name="text">
            <string>Add a Bridge:</string>
           </property>
          </widget>
         </item>
         <item>
          <spacer>
-          <property name="orientation" >
+          <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
-          <property name="sizeHint" >
+          <property name="sizeHint" stdset="0">
            <size>
             <width>40</width>
             <height>20</height>
@@ -293,34 +300,34 @@
        </layout>
       </item>
       <item>
-       <layout class="QHBoxLayout" >
-        <property name="spacing" >
+       <layout class="QHBoxLayout">
+        <property name="spacing">
          <number>6</number>
         </property>
-        <property name="margin" >
+        <property name="margin">
          <number>0</number>
         </property>
         <item>
-         <layout class="QVBoxLayout" >
-          <property name="spacing" >
+         <layout class="QVBoxLayout">
+          <property name="spacing">
            <number>6</number>
           </property>
-          <property name="margin" >
+          <property name="margin">
            <number>0</number>
           </property>
           <item>
-           <widget class="QLineEdit" name="lineBridge" >
-            <property name="maxLength" >
+           <widget class="QLineEdit" name="lineBridge">
+            <property name="maxLength">
              <number>100</number>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QListWidget" name="listBridges" >
-            <property name="contextMenuPolicy" >
+           <widget class="QListWidget" name="listBridges">
+            <property name="contextMenuPolicy">
              <enum>Qt::CustomContextMenu</enum>
             </property>
-            <property name="selectionMode" >
+            <property name="selectionMode">
              <enum>QAbstractItemView::ExtendedSelection</enum>
             </property>
            </widget>
@@ -328,64 +335,64 @@
          </layout>
         </item>
         <item>
-         <layout class="QVBoxLayout" >
-          <property name="spacing" >
+         <layout class="QVBoxLayout">
+          <property name="spacing">
            <number>6</number>
           </property>
-          <property name="margin" >
+          <property name="margin">
            <number>0</number>
           </property>
           <item>
-           <widget class="QToolButton" name="btnAddBridge" >
-            <property name="text" >
+           <widget class="QToolButton" name="btnAddBridge">
+            <property name="text">
              <string/>
             </property>
-            <property name="icon" >
-             <iconset resource="../res/vidalia.qrc" >
+            <property name="icon">
+             <iconset resource="../res/vidalia.qrc">
               <normaloff>:/images/22x22/list-add.png</normaloff>:/images/22x22/list-add.png</iconset>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QToolButton" name="btnRemoveBridge" >
-            <property name="enabled" >
+           <widget class="QToolButton" name="btnRemoveBridge">
+            <property name="enabled">
              <bool>false</bool>
             </property>
-            <property name="toolTip" >
+            <property name="toolTip">
              <string>Remove the selected bridges from the list</string>
             </property>
-            <property name="text" >
+            <property name="text">
              <string/>
             </property>
-            <property name="icon" >
-             <iconset resource="../res/vidalia.qrc" >
+            <property name="icon">
+             <iconset resource="../res/vidalia.qrc">
               <normaloff>:/images/22x22/list-remove.png</normaloff>:/images/22x22/list-remove.png</iconset>
             </property>
            </widget>
           </item>
           <item>
-           <widget class="QToolButton" name="btnCopyBridge" >
-            <property name="enabled" >
+           <widget class="QToolButton" name="btnCopyBridge">
+            <property name="enabled">
              <bool>false</bool>
             </property>
-            <property name="toolTip" >
+            <property name="toolTip">
              <string>Copy the selected bridges to the clipboard</string>
             </property>
-            <property name="text" >
+            <property name="text">
              <string/>
             </property>
-            <property name="icon" >
-             <iconset resource="../res/vidalia.qrc" >
+            <property name="icon">
+             <iconset resource="../res/vidalia.qrc">
               <normaloff>:/images/22x22/edit-copy.png</normaloff>:/images/22x22/edit-copy.png</iconset>
             </property>
            </widget>
           </item>
           <item>
            <spacer>
-            <property name="orientation" >
+            <property name="orientation">
              <enum>Qt::Vertical</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0">
              <size>
               <width>20</width>
               <height>40</height>
@@ -398,30 +405,30 @@
        </layout>
       </item>
       <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_3" >
+       <layout class="QHBoxLayout" name="horizontalLayout_3">
         <item>
-         <widget class="QPushButton" name="btnFindBridges" >
-          <property name="text" >
+         <widget class="QPushButton" name="btnFindBridges">
+          <property name="text">
            <string>Find Bridges Now</string>
           </property>
          </widget>
         </item>
         <item>
-         <widget class="QLabel" name="lblHelpFindBridges" >
-          <property name="cursor" >
+         <widget class="QLabel" name="lblHelpFindBridges">
+          <property name="cursor">
            <cursorShape>PointingHandCursor</cursorShape>
           </property>
-          <property name="text" >
-           <string>&lt;a href="bridges.finding">How else can I find bridges?&lt;/a></string>
+          <property name="text">
+           <string>&lt;a href=&quot;bridges.finding&quot;&gt;How else can I find bridges?&lt;/a&gt;</string>
           </property>
          </widget>
         </item>
         <item>
-         <spacer name="horizontalSpacer" >
-          <property name="orientation" >
+         <spacer name="horizontalSpacer">
+          <property name="orientation">
            <enum>Qt::Horizontal</enum>
           </property>
-          <property name="sizeHint" >
+          <property name="sizeHint" stdset="0">
            <size>
             <width>40</width>
             <height>20</height>
@@ -436,10 +443,10 @@
    </item>
    <item>
     <spacer>
-     <property name="orientation" >
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
        <height>40</height>
@@ -451,11 +458,10 @@
  </widget>
  <tabstops>
   <tabstop>chkUseProxy</tabstop>
-  <tabstop>lineHttpProxyAddress</tabstop>
-  <tabstop>lineHttpProxyPort</tabstop>
-  <tabstop>lineHttpProxyUsername</tabstop>
-  <tabstop>lineHttpProxyPassword</tabstop>
-  <tabstop>chkProxyUseHttps</tabstop>
+  <tabstop>lineProxyAddress</tabstop>
+  <tabstop>lineProxyPort</tabstop>
+  <tabstop>lineProxyUsername</tabstop>
+  <tabstop>lineProxyPassword</tabstop>
   <tabstop>chkFascistFirewall</tabstop>
   <tabstop>lineReachablePorts</tabstop>
   <tabstop>chkUseBridges</tabstop>
@@ -466,7 +472,7 @@
   <tabstop>listBridges</tabstop>
  </tabstops>
  <resources>
-  <include location="../res/vidalia.qrc" />
+  <include location="../res/vidalia.qrc"/>
  </resources>
  <connections>
   <connection>
@@ -475,11 +481,11 @@
    <receiver>grpFirewallSettings</receiver>
    <slot>setVisible(bool)</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>222</x>
      <y>21</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>222</x>
      <y>82</y>
     </hint>
@@ -491,11 +497,11 @@
    <receiver>grpProxySettings</receiver>
    <slot>setVisible(bool)</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>222</x>
      <y>143</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>222</x>
      <y>216</y>
     </hint>
@@ -507,11 +513,11 @@
    <receiver>grpBridgeSettings</receiver>
    <slot>setVisible(bool)</slot>
    <hints>
-    <hint type="sourcelabel" >
+    <hint type="sourcelabel">
      <x>283</x>
      <y>302</y>
     </hint>
-    <hint type="destinationlabel" >
+    <hint type="destinationlabel">
      <x>283</x>
      <y>419</y>
     </hint>

Modified: vidalia/trunk/src/vidalia/config/NetworkSettings.cpp
===================================================================
--- vidalia/trunk/src/vidalia/config/NetworkSettings.cpp	2009-10-02 09:39:32 UTC (rev 4139)
+++ vidalia/trunk/src/vidalia/config/NetworkSettings.cpp	2009-10-03 21:49:21 UTC (rev 4140)
@@ -18,12 +18,23 @@
 
 #define SETTING_FASCIST_FIREWALL    "FascistFirewall"
 #define SETTING_REACHABLE_ADDRESSES "ReachableAddresses"
-#define SETTING_USE_HTTP_PROXY      "UseHttpProxy"
+
+/* Vidalia-specific proxy options */
+#define SETTING_PROXY_TYPE          "ProxyType"
+#define SETTING_PROXY_ADDRESS       "ProxyAddress"
+#define SETTING_PROXY_USERNAME      "ProxyUsername"
+#define SETTING_PROXY_PASSWORD      "ProxyPassword"
+
+/* Tor's proxy options */
 #define SETTING_HTTP_PROXY          "HttpProxy"
 #define SETTING_HTTP_PROXY_AUTH     "HttpProxyAuthenticator"
-#define SETTING_USE_HTTPS_PROXY     "UseHttpsProxy"
 #define SETTING_HTTPS_PROXY         "HttpsProxy"
 #define SETTING_HTTPS_PROXY_AUTH    "HttpsProxyAuthenticator"
+#define SETTING_SOCKS4_PROXY        "Socks4Proxy"
+#define SETTING_SOCKS5_PROXY        "Socks5Proxy"
+#define SETTING_SOCKS5_USERNAME     "Socks5ProxyUsername"
+#define SETTING_SOCKS5_PASSWORD     "Socks5ProxyPassword"
+
 #define SETTING_USE_BRIDGES         "UseBridges"
 #define SETTING_BRIDGE_LIST         "Bridge"
 #define SETTING_UPDATE_BRIDGES      "UpdateBridgesFromAuthority"
@@ -35,12 +46,10 @@
 NetworkSettings::NetworkSettings(TorControl *torControl)
 : AbstractTorSettings("Network", torControl)
 {
-  setDefault(SETTING_USE_HTTP_PROXY,    false);
-  setDefault(SETTING_HTTP_PROXY,        "");
-  setDefault(SETTING_HTTP_PROXY_AUTH,   "");
-  setDefault(SETTING_USE_HTTPS_PROXY,   true);
-  setDefault(SETTING_HTTPS_PROXY,       "");
-  setDefault(SETTING_HTTPS_PROXY_AUTH,  "");
+  setDefault(SETTING_PROXY_TYPE,        NoProxy);
+  setDefault(SETTING_PROXY_ADDRESS,     "");
+  setDefault(SETTING_PROXY_USERNAME,    "");
+  setDefault(SETTING_PROXY_PASSWORD,    "");
   setDefault(SETTING_USE_BRIDGES,       false);
   setDefault(SETTING_BRIDGE_LIST,       QStringList());
   setDefault(SETTING_FASCIST_FIREWALL,  false);
@@ -61,21 +70,48 @@
   conf.insert(SETTING_REACHABLE_ADDRESSES,
     (getFascistFirewall() ? 
       localValue(SETTING_REACHABLE_ADDRESSES).toStringList().join(",") : ""));
+ 
+  QString socks4, socks5, http, https;
+  QString addr, user, pass, auth;
 
-  if (getUseHttpProxy())
-    conf.insert(SETTING_HTTP_PROXY, localValue(SETTING_HTTP_PROXY).toString());
-  else
-    conf.insert(SETTING_HTTP_PROXY,  "");
-  conf.insert(SETTING_HTTP_PROXY_AUTH,
-              localValue(SETTING_HTTP_PROXY_AUTH).toString());
+  addr = localValue(SETTING_PROXY_ADDRESS).toString();
+  user = localValue(SETTING_PROXY_USERNAME).toString();
+  pass = localValue(SETTING_PROXY_PASSWORD).toString();
 
-  if (getUseHttpProxy() && getUseHttpsProxy())
-    conf.insert(SETTING_HTTPS_PROXY, localValue(SETTING_HTTPS_PROXY).toString());
-  else
-    conf.insert(SETTING_HTTPS_PROXY, "");
-  conf.insert(SETTING_HTTPS_PROXY_AUTH,
-              localValue(SETTING_HTTPS_PROXY_AUTH).toString());
+  if (!user.isEmpty() || !pass.isEmpty())
+    auth = QString("%1:%2").arg(user).arg(pass);
+ 
+  switch (getProxyType()) {
+    case NoProxy:
+      break;
+    case Socks4Proxy:
+      socks4 = addr;
+      break;
+    case Socks5Proxy:
+      socks5 = addr;
+      break;
+    case HttpProxy:
+      http = addr;
+      break;
+    case HttpHttpsProxy:
+      http = addr;
+      https = http;
+      break;
+  }
 
+  if (torVersion >= 0x020201) {
+    /* SOCKS support was implemented in 0.2.2.1 */
+    conf.insert(SETTING_SOCKS4_PROXY, socks4);
+    conf.insert(SETTING_SOCKS5_PROXY, socks5);
+    conf.insert(SETTING_SOCKS5_USERNAME, user);
+    conf.insert(SETTING_SOCKS5_PASSWORD, pass);
+  }
+
+  conf.insert(SETTING_HTTP_PROXY, http);
+  conf.insert(SETTING_HTTPS_PROXY, https);
+  conf.insert(SETTING_HTTP_PROXY_AUTH, auth);
+  conf.insert(SETTING_HTTPS_PROXY_AUTH, auth);
+
   if (getUseBridges()) {
     /* We want to always enable TunnelDirConns and friends when using
      * bridge relays. */
@@ -159,108 +195,64 @@
   }
 }
 
-/** Returns true if Tor should make all its directory requests through a
- * proxy. */
-bool
-NetworkSettings::getUseHttpProxy()
+/** Returns the proxy type Tor is using, or NoProxy if it makes direct
+ * connections. */ 
+NetworkSettings::ProxyType
+NetworkSettings::getProxyType()
 {
-  return localValue(SETTING_USE_HTTP_PROXY).toBool();
+  QString type = value(SETTING_PROXY_TYPE).toString();
+  return proxyTypeFromString(type);
 }
 
-/** Sets to <b>useHttpProxy</b> whether Tor should make all its directory
- * requests through the proxy specified to setHttpProxy().
- * \sa setHttpProxy() */
+/** Set the type of proxy Tor should use to <b>type</b>. */
 void
-NetworkSettings::setUseHttpProxy(bool useHttpProxy)
+NetworkSettings::setProxyType(ProxyType type)
 {
-  setValue(SETTING_USE_HTTP_PROXY, useHttpProxy);
+  setValue(SETTING_PROXY_TYPE, proxyTypeToString(type));
 }
 
-/** Returns the proxy used for making Tor's directory requests, in the form
- * of <i>host[:port]</i>. */
+/** Returns the address of the proxy server Tor makes connections through. */
 QString
-NetworkSettings::getHttpProxy()
+NetworkSettings::getProxyAddress()
 {
-  return value(SETTING_HTTP_PROXY).toString();
+  return value(SETTING_PROXY_ADDRESS).toString();
 }
 
-/** Sets the proxy used for making Tor's directory requests. <b>proxy</b>
- * should be in the form <i>host[:port]</i>. If <i>:port</i> is not
- * specified, then Tor will use its default of port 80. */
+/** Sets the proxy address and port to <b>addr</b>. */
 void
-NetworkSettings::setHttpProxy(const QString &proxy)
+NetworkSettings::setProxyAddress(const QString &addr)
 {
-  setValue(SETTING_HTTP_PROXY, proxy);
+  setValue(SETTING_PROXY_ADDRESS, addr);
 }
 
-/** Returns the authentication information Tor should use to authenticate to
- * an Http proxy. The returned value is in the form 
- * <i>username:password</i>. */
+/** Returns the username used to login to the proxy server. */
 QString
-NetworkSettings::getHttpProxyAuthenticator()
+NetworkSettings::getProxyUsername()
 {
-  return value(SETTING_HTTP_PROXY_AUTH).toString();
+  return value(SETTING_PROXY_USERNAME).toString();
 }
 
-/** Sets the authentication information required by an Http proxy.
- * <b>authenticator</b> should be in the form <i>username:password</i>. */
+/** Sets the proxy server username to <b>user</b>. */ 
 void
-NetworkSettings::setHttpProxyAuthenticator(const QString &auth)
+NetworkSettings::setProxyUsername(const QString &user)
 {
-  setValue(SETTING_HTTP_PROXY_AUTH, auth);
+  setValue(SETTING_PROXY_USERNAME, user);
 }
 
-/** Returns true if Tor should make all its OR connections through a
- * proxy. */
-bool
-NetworkSettings::getUseHttpsProxy()
-{
-  return localValue(SETTING_USE_HTTPS_PROXY).toBool();
-}
-
-/** Sets to <b>useHttpsProxy</b> whether Tor should make all its OR
- * connections through the proxy specified to setHttpsProxy().
- * \sa setHttpsProxy() */
-void
-NetworkSettings::setUseHttpsProxy(bool useHttpsProxy)
-{
-  setValue(SETTING_USE_HTTPS_PROXY, useHttpsProxy);
-}
-
-/** Returns the proxy used for making Tor's OR connections, in the form
- * of <i>host[:port]</i>. */
+/** Returns the password used to login to the proxy server. */
 QString
-NetworkSettings::getHttpsProxy()
+NetworkSettings::getProxyPassword()
 {
-  return value(SETTING_HTTPS_PROXY).toString();
+  return value(SETTING_PROXY_PASSWORD).toString();
 }
 
-/** Sets the proxy used for making Tor's OR connections. <b>proxy</b>
- * should be in the form <i>host[:port]</i>. If <i>:port</i> is not
- * specified, then Tor will use its default of port 443. */
+/** Sets the proxy server password to <b>pass</b>. */ 
 void
-NetworkSettings::setHttpsProxy(const QString &proxy)
+NetworkSettings::setProxyPassword(const QString &pass)
 {
-  setValue(SETTING_HTTPS_PROXY, proxy);
+  setValue(SETTING_PROXY_PASSWORD, pass);
 }
 
-/** Returns the authentication information Tor should use to authenticate to
- * an Https proxy. The returned value is in the form 
- * <i>username:password</i>. */
-QString
-NetworkSettings::getHttpsProxyAuthenticator()
-{
-  return value(SETTING_HTTPS_PROXY_AUTH).toString();
-}
-
-/** Sets the authentication information required by an Https proxy.
- * <b>authenticator</b> should be in the form <i>username:password</i>. */
-void
-NetworkSettings::setHttpsProxyAuthenticator(const QString &auth)
-{
-  setValue(SETTING_HTTPS_PROXY_AUTH, auth);
-}
-
 /** Returns true if Tor should try to use bridge nodes to access the Tor
  * network. */
 bool
@@ -299,3 +291,50 @@
   return value(SETTING_TUNNEL_DIR_CONNS).toBool();
 }
 
+/** Converts the ProxyType <b>type</b> to a string to store in the
+ * configuration file. */
+QString
+NetworkSettings::proxyTypeToString(ProxyType type)
+{
+  QString ret;
+
+  switch (type) {
+    case Socks4Proxy:
+      ret = "socks4";
+      break;
+    case Socks5Proxy:
+      ret = "socks5";
+      break;
+    case HttpProxy:
+      ret = "http";
+      break;
+    case HttpHttpsProxy:
+      ret = "httphttps";
+      break;
+    case NoProxy:
+    default:
+      ret = "none";
+      break;
+  }
+
+  return ret;
+}
+
+/** Converts the proxy type string <b>type</b> to its ProxyType counterpart. */
+NetworkSettings::ProxyType
+NetworkSettings::proxyTypeFromString(const QString &type)
+{
+  QString str = type.toLower();
+  
+  if (str == "socks4")
+    return Socks4Proxy;
+  if (str == "socks5")
+    return Socks5Proxy;
+  if (str == "http")
+    return HttpProxy;
+  if (str == "httphttps")
+    return HttpHttpsProxy;
+
+  return NoProxy;
+}
+

Modified: vidalia/trunk/src/vidalia/config/NetworkSettings.h
===================================================================
--- vidalia/trunk/src/vidalia/config/NetworkSettings.h	2009-10-02 09:39:32 UTC (rev 4139)
+++ vidalia/trunk/src/vidalia/config/NetworkSettings.h	2009-10-03 21:49:21 UTC (rev 4140)
@@ -28,6 +28,18 @@
   Q_OBJECT
 
 public:
+  enum ProxyType
+  {
+    ProxyTypeMin = -1,
+    NoProxy = -1, /**< Have Tor connect directly to the Internet. */
+    Socks4Proxy = 0, /**< Use a SOCKS 4 proxy for OR connections. */
+    Socks5Proxy = 1, /**< Use a SOCKS 5 proxy for OR connections. */
+    HttpProxy = 2, /**< Use an HTTP proxy for non-tunneled dir fetches. */
+    HttpHttpsProxy = 3, /**< Use HTTP proxy for both dir and OR connections. */
+    ProxyTypeMax = 3
+  };
+
+public:
   /** Default constructor. */
   NetworkSettings(TorControl *torControl);
 
@@ -50,53 +62,26 @@
    * <b>reachablePorts</b>. */
   void setReachablePorts(const QList<quint16> &reachablePorts);
 
-  /** Returns true if Tor should make all its directory requests through a
-   * proxy. */
-  bool getUseHttpProxy();
-  /** Sets to <b>useHttpProxy</b> whether Tor should make all its directory
-   * requests through the proxy specified to setHttpProxy()
-   * \sa setHttpProxy() */
-  void setUseHttpProxy(bool useHttpProxy);
-  
-  /** Returns the proxy used for making Tor's directory requests, in the form
-   * of <i>host[:port]</i>. */
-  QString getHttpProxy();
-  /** Sets the proxy used for making Tor's directory requests. <b>proxy</b>
-   * should be in the form <i>host[:port]</i>. If <i>:port</i> is not
-   * specified, then Tor will use its default of port 80. */
-  void setHttpProxy(const QString &proxy);
+  /** Returns the proxy type Tor is using, or NoProxy if it makes direct
+   * connections. */ 
+  ProxyType getProxyType();
+  /** Set the type of proxy Tor should use to <b>type</b>. */
+  void setProxyType(ProxyType type);
 
-  /** Returns the authentication information Tor should use to authenticate to
-   * an Http proxy. The returned value is in the form 
-   * <i>username:password</i>. */
-  QString getHttpProxyAuthenticator();
-  /** Sets the authentication information required by an Http proxy.
-   * <b>authenticator</b> should be in the form <i>username:password</i>. */
-  void setHttpProxyAuthenticator(const QString &authenticator);
+  /** Returns the address of the proxy server Tor makes connections through. */
+  QString getProxyAddress();
+  /** Sets the proxy address and port to <b>addr</b>. */
+  void setProxyAddress(const QString &addr);
 
-  /** Returns true if Tor should make all its OR connections through a
-   * proxy. */
-  bool getUseHttpsProxy();
-  /** Sets to <b>useHttpsProxy</b> whether Tor should make all its OR
-   * connections through the proxy specified to setHttpsProxy.
-   * \sa setHttpsProxy() */
-  void setUseHttpsProxy(bool useHttpsProxy);
-  
-  /** Returns the proxy used for making Tor's OR connections, in the form
-   * of <i>host[:port]</i>. */
-  QString getHttpsProxy();
-  /** Sets the proxy used for making Tor's OR connections. <b>proxy</b>
-   * should be in the form <i>host[:port]</i>. If <i>:port</i> is not
-   * specified, then Tor will use its default of port 443. */
-  void setHttpsProxy(const QString &proxy);
+  /** Returns the username used to login to the proxy server. */
+  QString getProxyUsername();
+  /** Sets the proxy server username to <b>user</b>. */ 
+  void setProxyUsername(const QString &user);
 
-  /** Returns the authentication information Tor should use to authenticate to
-   * an Https proxy. The returned value is in the form 
-   * <i>username:password</i>. */
-  QString getHttpsProxyAuthenticator();
-  /** Sets the authentication information required by an Https proxy.
-   * <b>authenticator</b> should be in the form <i>username:password</i>. */
-  void setHttpsProxyAuthenticator(const QString &authenticator);
+  /** Returns the password used to login to the proxy server. */
+  QString getProxyPassword();
+  /** Sets the proxy server password to <b>pass</b>. */ 
+  void setProxyPassword(const QString &pass);
  
   /** Returns true if Tor should try to use bridge nodes to access the Tor
    * network. */
@@ -113,6 +98,14 @@
   /** Returns true if Tor is configured to try to tunnel its directory
    * connections through a one-hop circuit. */
   bool getTunnelDirConns();
+
+private:
+  /** Converts the ProxyType <b>type</b> to a string to store in the
+   * configuration file. */
+  QString proxyTypeToString(ProxyType type);
+
+  /** Converts the proxy type string <b>type</b> to its ProxyType counterpart. */
+  ProxyType proxyTypeFromString(const QString &type);
 };
 
 #endif