[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2082: Implement the rest of the stuff to tell the user their bridg (in trunk: . src/gui/config)
Author: edmanm
Date: 2007-10-24 02:45:13 -0400 (Wed, 24 Oct 2007)
New Revision: 2082
Modified:
trunk/
trunk/src/gui/config/serverpage.cpp
trunk/src/gui/config/serverpage.h
trunk/src/gui/config/serverpage.ui
Log:
r2222@lysithea: edmanm | 2007-10-24 02:45:07 -0400
Implement the rest of the stuff to tell the user their bridge relay
address, port, and fingerprint. (I even proofread my comments this time!) Also
removed a variable we didn't really need to keep around taking up memory.
Property changes on: trunk
___________________________________________________________________
svk:merge ticket from /local/vidalia/trunk [r2222] on dc66be73-d13e-47ba-a267-8dc7cda68c65
Modified: trunk/src/gui/config/serverpage.cpp
===================================================================
--- trunk/src/gui/config/serverpage.cpp 2007-10-24 05:22:43 UTC (rev 2081)
+++ trunk/src/gui/config/serverpage.cpp 2007-10-24 06:45:13 UTC (rev 2082)
@@ -25,6 +25,7 @@
* \brief Tor server configuration options
*/
+#include <QClipboard>
#include <vidalia.h>
#include <vmessagebox.h>
#include <util/html.h>
@@ -80,17 +81,14 @@
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
- /* Keep a pointer to the TorControl object used to talk to Tor */
- _torControl = Vidalia::torControl();
-
/* Create ServerSettings object */
- _settings = new ServerSettings(_torControl);
+ _settings = new ServerSettings(Vidalia::torControl());
/* Bind events to actions */
connect(ui.btnRateHelp, SIGNAL(clicked()), this, SLOT(bandwidthHelp()));
connect(ui.btnExitHelp, SIGNAL(clicked()), this, SLOT(exitPolicyHelp()));
connect(ui.cmboRate, SIGNAL(currentIndexChanged(int)),
- this, SLOT(rateChanged(int)));
+ this, SLOT(rateChanged(int)));
connect(ui.lineAvgRateLimit, SIGNAL(editingFinished()),
this, SLOT(customRateChanged()));
connect(ui.lineMaxRateLimit, SIGNAL(editingFinished()),
@@ -105,6 +103,8 @@
this, SLOT(onAuthenticated()));
connect(Vidalia::torControl(), SIGNAL(disconnected()),
this, SLOT(onDisconnected()));
+ connect(ui.btnCopyBridgeIdentity, SIGNAL(clicked()),
+ this, SLOT(copyBridgeIdentity()));
/* Set validators for address, mask and various port number fields */
ui.lineServerNickname->setValidator(new NicknameValidator(this));
@@ -158,16 +158,62 @@
ui.rdoBridgeMode->setEnabled(true);
}
+/** Copies the user's bridge relay identity to the clipboard. */
+void
+ServerPage::copyBridgeIdentity()
+{
+ QString bridge = ui.lblBridgeIdentity->text();
+ if (!bridge.isEmpty())
+ vApp->clipboard()->setText(bridge);
+}
+
+/** Loads the user's bridge relay identity into the appropriate widgets. If
+ * the user's bridge is not running, then "Not Running" will be displayed.
+ * Otherwise, either the bridge's "address:port", "fingerprint", or
+ * "address:port fingerprint" will be displayed, depending on whether our
+ * GETCONF and GETINFO commands are successful. */
+void
+ServerPage::loadBridgeIdentity()
+{
+ TorControl *tc = Vidalia::torControl();
+ QString bridge, address, orPort, fingerprint;
+
+ if (tc->isConnected()) {
+ tc->getInfo("address", address);
+ tc->getInfo("fingerprint", fingerprint);
+ tc->getConf("ORPort", orPort);
+
+ if (!address.isEmpty() && !orPort.isEmpty() && orPort != "0")
+ bridge = address + ":" + orPort + " ";
+ if (!fingerprint.isEmpty())
+ bridge += fingerprint;
+ bridge = bridge.trimmed();
+ }
+
+ ui.lblBridgeIdentity->setText(bridge.isEmpty() ? tr("Not Running") : bridge);
+ ui.btnCopyBridgeIdentity->setEnabled(!bridge.isEmpty());
+}
+
/** Called when the user toggles any one of the server mode radio buttons
* and hides or displays the server configuration tabs appropriately. */
void
ServerPage::serverModeChanged(bool enabled)
{
- enabled = (ui.rdoServerMode->isChecked() || ui.rdoBridgeMode->isChecked());
- ui.tabsMenu->setVisible(enabled);
+ Q_UNUSED(enabled);
+ bool bridgeEnabled = ui.rdoBridgeMode->isChecked();
- /* Disable the Exit Policies tab when bridge server mode is selected */
- ui.tabsMenu->setTabEnabled(2, !ui.rdoBridgeMode->isChecked());
+ /* Show the tab menu only if the user is running a normal relay or a bridge
+ * relay. */
+ ui.tabsMenu->setVisible(ui.rdoServerMode->isChecked() || bridgeEnabled);
+
+ /* Disable the Exit Policies tab when bridge relay mode is selected */
+ ui.tabsMenu->setTabEnabled(2, !bridgeEnabled);
+
+ /* Display the widgets that show the user their bridge identity if bridge
+ * relay mode is selected. */
+ ui.lblYourBridgeRelayIs->setVisible(bridgeEnabled);
+ ui.lblBridgeIdentity->setVisible(bridgeEnabled);
+ ui.btnCopyBridgeIdentity->setVisible(bridgeEnabled);
}
/** Returns true if the user has changed their server settings since the
@@ -255,6 +301,7 @@
loadBandwidthLimits();
loadExitPolicies();
+ loadBridgeIdentity();
}
/** Shows exit policy related help information */
Modified: trunk/src/gui/config/serverpage.h
===================================================================
--- trunk/src/gui/config/serverpage.h 2007-10-24 05:22:43 UTC (rev 2081)
+++ trunk/src/gui/config/serverpage.h 2007-10-24 06:45:13 UTC (rev 2082)
@@ -83,6 +83,8 @@
/** Called when Vidalia disconnects from Tor. This method reenables the
* bridge server option. */
void onDisconnected();
+ /** Copies the user's bridge relay identity to the clipboard. */
+ void copyBridgeIdentity();
private:
/** Index values of rate values in the bandwidth limits dropdown box. */
@@ -106,9 +108,13 @@
void saveExitPolicies();
/** Loads the server's exit policies. */
void loadExitPolicies();
+ /** Loads the user's bridge relay identity into the appropriate widgets. If
+ * the user's bridge is not running, then "Not Running" will be
+ * displayed. Otherwise, either the bridge's "address:port", "fingerprint",
+ * or "address:port fingerprint" will be displayed, depending on whether
+ * our GETCONF and GETINFO commands are successful. */
+ void loadBridgeIdentity();
- /** A TorControl object used to talk to Tor */
- TorControl* _torControl;
/** A ServerSettings object used to get and set information about how a
* local Tor server is configured. */
ServerSettings* _settings;
Modified: trunk/src/gui/config/serverpage.ui
===================================================================
--- trunk/src/gui/config/serverpage.ui 2007-10-24 05:22:43 UTC (rev 2081)
+++ trunk/src/gui/config/serverpage.ui 2007-10-24 06:45:13 UTC (rev 2082)
@@ -1001,7 +1001,7 @@
<enum>QFrame::Sunken</enum>
</property>
<property name="text" >
- <string/>
+ <string>Not Running</string>
</property>
<property name="textInteractionFlags" >
<enum>Qt::TextSelectableByMouse</enum>
@@ -1010,6 +1010,9 @@
</item>
<item>
<widget class="QToolButton" name="btnCopyBridgeIdentity" >
+ <property name="enabled" >
+ <bool>false</bool>
+ </property>
<property name="toolTip" >
<string>Copy your bridge relay's identity to the clipboard</string>
</property>