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

[vidalia-svn] r2033: Add some UI to the Server config page for setting oneself as (in trunk: . src/gui/config)



Author: edmanm
Date: 2007-10-15 23:00:00 -0400 (Mon, 15 Oct 2007)
New Revision: 2033

Modified:
   trunk/
   trunk/src/gui/config/serverpage.cpp
   trunk/src/gui/config/serverpage.h
   trunk/src/gui/config/serverpage.ui
Log:
 r2125@lysithea:  edmanm | 2007-10-15 22:59:37 -0400
 Add some UI to the Server config page for setting oneself as a bridge. Also
 rearrange a skosh of code. I still need to make this use different default
 values for bridge nodes versus regular servers.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r2125] on dc66be73-d13e-47ba-a267-8dc7cda68c65

Modified: trunk/src/gui/config/serverpage.cpp
===================================================================
--- trunk/src/gui/config/serverpage.cpp	2007-10-16 02:59:44 UTC (rev 2032)
+++ trunk/src/gui/config/serverpage.cpp	2007-10-16 03:00:00 UTC (rev 2033)
@@ -93,6 +93,12 @@
                          this, SLOT(customRateChanged()));
   connect(ui.lineMaxRateLimit, SIGNAL(editingFinished()), 
                          this, SLOT(customRateChanged()));
+  connect(ui.rdoClientMode, SIGNAL(toggled(bool)),
+                      this, SLOT(serverModeChanged(bool)));
+  connect(ui.rdoServerMode, SIGNAL(toggled(bool)),
+                      this, SLOT(serverModeChanged(bool)));
+  connect(ui.rdoBridgeMode, SIGNAL(toggled(bool)),
+                      this, SLOT(serverModeChanged(bool)));
 
   /* Set validators for address, mask and various port number fields */
   ui.lineServerNickname->setValidator(new NicknameValidator(this));
@@ -110,6 +116,40 @@
   delete _settings;
 }
 
+/** Called when the user toggles any one of the server mode radio buttons
+ * and hides or displays the server configuration tabs appropriatey. */
+void
+ServerPage::serverModeChanged(bool enabled)
+{
+  enabled = (ui.rdoServerMode->isChecked() || ui.rdoBridgeMode->isChecked());
+  ui.tabsMenu->setVisible(enabled);
+}
+
+/** Returns true if the user has changed their server settings since the
+ * last time they were applied to Tor. */
+bool
+ServerPage::changedSinceLastApply()
+{
+  return _settings->changedSinceLastApply();
+}
+
+/** Applies the server configuration settings to Tor. Returns true if the
+ * settings were applied successfully. Otherwise, <b>errmsg</b> is
+ * set and false is returned. */
+bool
+ServerPage::apply(QString &errmsg)
+{
+  return _settings->apply(&errmsg);
+}
+
+/** Returns true if the user has changed their server settings since the
+ * last time they were applied to Tor. */
+void
+ServerPage::revert()
+{
+  _settings->revert();
+}
+
 /** Saves changes made to settings on the Server settings page. */
 bool
 ServerPage::save(QString &errmsg)
@@ -117,7 +157,7 @@
   /* Force the bandwidth rate limits to validate */
   customRateChanged();
   
-  if (ui.chkEnableServer->isChecked()) {
+  if (ui.rdoServerMode->isChecked() || ui.rdoBridgeMode->isChecked()) {
     /* A server must have an ORPort and a nickname */
     if (ui.lineServerPort->text().isEmpty() ||
         ui.lineServerNickname->text().isEmpty()) {
@@ -132,7 +172,14 @@
       ui.lineMaxRateLimit->setText(QString::number(5242880/1024) /* 5MB */);
     }
   }
-  _settings->setServerEnabled(ui.chkEnableServer->isChecked());
+  
+  /* "Server" is enabled whether we're a bridge or normal relay. "Bridge" is
+   * only enabled if we're a bridge (obviously). */
+  _settings->setServerEnabled(ui.rdoServerMode->isChecked()
+                                || ui.rdoBridgeMode->isChecked());
+  _settings->setBridgeEnabled(ui.rdoBridgeMode->isChecked());
+  
+  /* Save the rest of the server settings. */
   _settings->setDirectoryMirror(ui.chkMirrorDirectory->isChecked());
   _settings->setNickname(ui.lineServerNickname->text());
   _settings->setORPort(ui.lineServerPort->text().toUInt());
@@ -144,46 +191,27 @@
   return true;
 }
 
-/** Returns true if the user has changed their server settings since the
- * last time they were applied to Tor. */
-bool
-ServerPage::changedSinceLastApply()
-{
-  return _settings->changedSinceLastApply();
-}
-
-/** Applies the server configuration settings to Tor. Returns true if the
- * settings were applied successfully. Otherwise, <b>errmsg</b> is
- * set and false is returned. */
-bool
-ServerPage::apply(QString &errmsg)
-{
-  return _settings->apply(&errmsg);
-}
-
-/** Returns true if the user has changed their server settings since the
- * last time they were applied to Tor. */
-void
-ServerPage::revert()
-{
-  _settings->revert();
-}
-
 /** Loads previously saved settings */
 void
 ServerPage::load()
 {
-  ui.chkEnableServer->setChecked(_settings->isServerEnabled());
-  ui.chkMirrorDirectory->setChecked(_settings->isDirectoryMirror());
+  if (_settings->isBridgeEnabled())
+    ui.rdoBridgeMode->setChecked(true);
+  else if (_settings->isServerEnabled())
+    ui.rdoServerMode->setChecked(true);
+  else
+    ui.rdoClientMode->setChecked(true);
 
   ui.lineServerNickname->setText(_settings->getNickname());
   ui.lineServerPort->setText(QString::number(_settings->getORPort()));
   ui.lineDirPort->setText(QString::number(_settings->getDirPort()));
   ui.lineServerContact->setText(_settings->getContactInfo());
+  ui.chkMirrorDirectory->setChecked(_settings->isDirectoryMirror());
+  
   loadBandwidthLimits();
   loadExitPolicies();
 
-  ui.frmServer->setVisible(ui.chkEnableServer->isChecked());
+  //ui.frmServer->setVisible(ui.chkEnableServer->isChecked());
 }
 
 /** Shows exit policy related help information */

Modified: trunk/src/gui/config/serverpage.h
===================================================================
--- trunk/src/gui/config/serverpage.h	2007-10-16 02:59:44 UTC (rev 2032)
+++ trunk/src/gui/config/serverpage.h	2007-10-16 03:00:00 UTC (rev 2033)
@@ -65,6 +65,9 @@
   bool changedSinceLastApply();
 
 private slots:
+  /** Called when the user toggles any one of the server mode radio buttons
+   * and hides or displays the server configuration tabs appropriatey. */
+  void serverModeChanged(bool enabled);
   /** Called when the user clicks the bandwidth help button */
   void bandwidthHelp();
   /** Called when the user clicks the exit policy help button */

Modified: trunk/src/gui/config/serverpage.ui
===================================================================
--- trunk/src/gui/config/serverpage.ui	2007-10-16 02:59:44 UTC (rev 2032)
+++ trunk/src/gui/config/serverpage.ui	2007-10-16 03:00:00 UTC (rev 2033)
@@ -25,18 +25,23 @@
     <number>6</number>
    </property>
    <item>
-    <widget class="QCheckBox" name="chkEnableServer" >
-     <property name="contextMenuPolicy" >
-      <enum>Qt::NoContextMenu</enum>
+    <widget class="QRadioButton" name="rdoClientMode" >
+     <property name="text" >
+      <string>Run Tor as a client only</string>
      </property>
-     <property name="toolTip" >
-      <string>Check to run as a Tor network server</string>
-     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="rdoServerMode" >
      <property name="text" >
       <string>Relay traffic for the Tor network</string>
      </property>
-     <property name="checked" >
-      <bool>false</bool>
+    </widget>
+   </item>
+   <item>
+    <widget class="QRadioButton" name="rdoBridgeMode" >
+     <property name="text" >
+      <string>Help censored users reach the Tor network</string>
      </property>
     </widget>
    </item>
@@ -925,7 +930,6 @@
   </layout>
  </widget>
  <tabstops>
-  <tabstop>chkEnableServer</tabstop>
   <tabstop>tabsMenu</tabstop>
   <tabstop>lineServerNickname</tabstop>
   <tabstop>lineServerContact</tabstop>
@@ -947,22 +951,6 @@
  <resources/>
  <connections>
   <connection>
-   <sender>chkEnableServer</sender>
-   <signal>toggled(bool)</signal>
-   <receiver>frmServer</receiver>
-   <slot>setVisible(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>257</x>
-     <y>42</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>257</x>
-     <y>308</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
    <sender>chkMirrorDirectory</sender>
    <signal>toggled(bool)</signal>
    <receiver>lineDirPort</receiver>