[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [vidalia/alpha] Configure bridge with transport support
commit 1fb2a4c79ff55a35cc6405a6cb0edc6646557a20
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date: Tue Aug 14 20:46:00 2012 -0300
Configure bridge with transport support
---
src/vidalia/CMakeLists.txt | 2 +
src/vidalia/config/ServerPage.cpp | 68 ++++++++++++++++++++++++++
src/vidalia/config/ServerPage.h | 10 ++++
src/vidalia/config/ServerPage.ui | 76 +++++++++++++++++++++++------
src/vidalia/config/TransportSettings.cpp | 36 ++++++++++++++
src/vidalia/config/TransportSettings.h | 39 +++++++++++++++
6 files changed, 215 insertions(+), 16 deletions(-)
diff --git a/src/vidalia/CMakeLists.txt b/src/vidalia/CMakeLists.txt
index c46a97b..b458752 100644
--- a/src/vidalia/CMakeLists.txt
+++ b/src/vidalia/CMakeLists.txt
@@ -143,6 +143,7 @@ set(vidalia_SRCS ${vidalia_SRCS}
config/VSettings.cpp
config/torrc/TorrcParser.cpp
config/torrc/Torrc.cpp
+ config/TransportSettings.cpp
)
qt4_wrap_cpp(vidalia_SRCS
config/AbstractTorSettings.h
@@ -166,6 +167,7 @@ qt4_wrap_cpp(vidalia_SRCS
config/VidaliaSettings.h
config/VSettings.h
config/torrc/Torrc.h
+ config/TransportSettings.h
)
if (USE_MINIUPNPC)
include_directories(${MINIUPNPC_INCLUDE_DIR})
diff --git a/src/vidalia/config/ServerPage.cpp b/src/vidalia/config/ServerPage.cpp
index 31660a4..35d3955 100644
--- a/src/vidalia/config/ServerPage.cpp
+++ b/src/vidalia/config/ServerPage.cpp
@@ -23,6 +23,7 @@
#include "DomainValidator.h"
#include "NicknameValidator.h"
#include "BridgeUsageDialog.h"
+#include "TransportSettings.h"
#include "html.h"
#include "stringutil.h"
@@ -243,6 +244,27 @@ ServerPage::serverModeChanged(bool enabled)
ui.lblBridgeUsage->setVisible(bridgeEnabled
&& Vidalia::torControl()->isConnected());
+ TransportSettings transports;
+ ui.transportsFrame->setVisible(enabled && bridgeEnabled && transports.getTransports().size() > 0);
+
+ if (ui.transportsFrame->isVisible()) {
+ QStringList transportList = transports.getTransports();
+ foreach(QString transport, transportList) {
+ QCheckBox *chkTransport = new QCheckBox(transport);
+ ui.transportsFrame->layout()->addWidget(chkTransport);
+ _transportChecks.insert(transport, chkTransport);
+ }
+ loadTransports();
+ } else {
+ while(ui.transportsFrame->layout()->count() > 2) {
+ ui.transportsFrame->layout()->takeAt(ui.transportsFrame->layout()->count() - 1);
+ }
+ foreach(QCheckBox *chk, _transportChecks) {
+ chk->deleteLater();
+ }
+ _transportChecks.clear();
+ }
+
if(bridgeEnabled) {
if(ui.lineDirPort->text().length() != 0) {
_tmpDirPort = ui.lineDirPort->text();
@@ -363,6 +385,8 @@ ServerPage::save(QString &errmsg)
_settings->setUpnpEnabled(ui.chkEnableUpnp->isChecked());
#endif
+ saveTransports();
+
return true;
}
@@ -756,3 +780,47 @@ ServerPage::toggleDisplayDay(const QString &str)
else
ui.spnDay->setMaximum(7);
}
+
+void
+ServerPage::loadTransports()
+{
+ disconnect(ui.chkEnableTransports, 0, 0, 0);
+ connect(ui.chkEnableTransports, SIGNAL(stateChanged(int)), this, SLOT(toggleTransports(int)));
+ QStringList stps = Vidalia::torrc()->value("ServerTransportPlugin");
+ ui.chkEnableTransports->setCheckState(stps.size() > 0 ? Qt::Checked : Qt::Unchecked);
+ toggleTransports(stps.size() > 0 ? Qt::Checked : Qt::Unchecked);
+ foreach (QString stp, stps) {
+ QString transport = stp.split(" ").at(0);
+ if (_transportChecks.count(transport) > 0) {
+ _transportChecks[transport]->setChecked(true);
+ } else {
+ vWarn("Unsupported transport: %1").arg(transport);
+ }
+ }
+}
+
+void
+ServerPage::saveTransports()
+{
+ bool bridgeEnabled = ui.rdoBridgeMode->isChecked();
+ TransportSettings transports;
+
+ if (bridgeEnabled) {
+ Vidalia::torrc()->clear(QStringList() << "ServerTransportPlugin");
+ foreach(QString key, _transportChecks.keys()) {
+ if (_transportChecks[key]->isChecked()) {
+ Vidalia::torrc()->setValue("ServerTransportPlugin", QString("%1 %2").arg(key).arg(transports.getSTP(key)));
+ }
+ }
+ }
+}
+
+void
+ServerPage::toggleTransports(int state)
+{
+ foreach(QCheckBox *chk, _transportChecks) {
+ chk->setEnabled(state == Qt::Checked);
+ chk->setChecked(false);
+ }
+}
+
diff --git a/src/vidalia/config/ServerPage.h b/src/vidalia/config/ServerPage.h
index b906a1f..18f4686 100644
--- a/src/vidalia/config/ServerPage.h
+++ b/src/vidalia/config/ServerPage.h
@@ -87,6 +87,9 @@ private slots:
/** Called when the user selects a new item from cmbTime */
void toggleDisplayDay(const QString &str);
+ /** Called when the user toggle the Enable transports checkbox */
+ void toggleTransports(int state);
+
private:
/** Index values of rate values in the bandwidth limits dropdown box. */
enum BwRateIndex {
@@ -118,6 +121,10 @@ private:
/** Retrieves bridge usage history from Tor, parses and validates it, and
* then displays it in a new dialog. */
void displayBridgeUsage();
+ /** Loads the transport settings */
+ void loadTransports();
+ /** Saves the transport settings */
+ void saveTransports();
/** A ServerSettings object used to get and set information about how a
* local Tor server is configured. */
@@ -131,6 +138,9 @@ private:
* re-added when selecting relay */
QString _tmpDirPort;
bool _tmpMirror;
+
+ /** List of checkboxes used to configure transports */
+ QMap<QString, QCheckBox*> _transportChecks;
};
#endif
diff --git a/src/vidalia/config/ServerPage.ui b/src/vidalia/config/ServerPage.ui
index f26f7e4..1d7f91f 100644
--- a/src/vidalia/config/ServerPage.ui
+++ b/src/vidalia/config/ServerPage.ui
@@ -77,7 +77,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
- <number>1</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="ServerConfig">
<attribute name="title">
@@ -116,7 +116,7 @@
</property>
</widget>
</item>
- <item row="3" column="6">
+ <item row="3" column="5">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -129,7 +129,7 @@
</property>
</spacer>
</item>
- <item row="4" column="0" colspan="6">
+ <item row="4" column="0" colspan="5">
<widget class="QCheckBox" name="chkEnableUpnp">
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
@@ -142,7 +142,7 @@
</property>
</widget>
</item>
- <item row="4" column="6">
+ <item row="4" column="5">
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="btnTestUpnp">
@@ -192,7 +192,7 @@
</item>
</layout>
</item>
- <item row="1" column="1" colspan="7">
+ <item row="1" column="1" colspan="6">
<widget class="QLineEdit" name="lineServerContact">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
@@ -206,7 +206,7 @@ problem with your relay. You might also include your PGP or GPG fingerprint.</st
</property>
</widget>
</item>
- <item row="3" column="3" colspan="3">
+ <item row="3" column="3" colspan="2">
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="lblDirPort">
@@ -276,33 +276,33 @@ problem with your relay. You might also include your PGP or GPG fingerprint.</st
</property>
</widget>
</item>
- <item row="2" column="2" colspan="6">
+ <item row="6" column="0">
<spacer>
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>321</width>
- <height>20</height>
+ <width>20</width>
+ <height>40</height>
</size>
</property>
</spacer>
</item>
- <item row="8" column="0">
+ <item row="2" column="2" colspan="5">
<spacer>
<property name="orientation">
- <enum>Qt::Vertical</enum>
+ <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>20</width>
- <height>40</height>
+ <width>321</width>
+ <height>20</height>
</size>
</property>
</spacer>
</item>
- <item row="3" column="5" colspan="2">
+ <item row="3" column="4" colspan="2">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -315,7 +315,7 @@ problem with your relay. You might also include your PGP or GPG fingerprint.</st
</property>
</spacer>
</item>
- <item row="0" column="1" colspan="7">
+ <item row="0" column="1" colspan="6">
<widget class="QLineEdit" name="lineServerNickname">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
@@ -381,6 +381,50 @@ problem with your relay. You might also include your PGP or GPG fingerprint.</st
</property>
</widget>
</item>
+ <item row="5" column="0" colspan="6">
+ <widget class="QFrame" name="transportsFrame">
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ <property name="midLineWidth">
+ <number>0</number>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>12</number>
+ </property>
+ <property name="topMargin">
+ <number>12</number>
+ </property>
+ <property name="rightMargin">
+ <number>12</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string><b>Transports</b></string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="chkEnableTransports">
+ <property name="text">
+ <string>Enable using transports</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QWidget" name="BandwidthLimits">
diff --git a/src/vidalia/config/TransportSettings.cpp b/src/vidalia/config/TransportSettings.cpp
new file mode 100644
index 0000000..748e77e
--- /dev/null
+++ b/src/vidalia/config/TransportSettings.cpp
@@ -0,0 +1,36 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+** including this file, may be copied, modified, propagated, or distributed
+** except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file TransportSettings.cpp
+** \brief General Vidalia settings, such as language and interface style
+*/
+
+#include "TransportSettings.h"
+
+TransportSettings::TransportSettings()
+ : VSettings("Transport")
+{
+
+}
+
+/** Returns the available transports */
+QStringList
+TransportSettings::getTransports()
+{
+ return childKeys();
+}
+
+/** Returns the ServerTransportPlugin value for a given transport */
+QString
+TransportSettings::getSTP(const QString &transport)
+{
+ return value(transport, "").toString();
+}
diff --git a/src/vidalia/config/TransportSettings.h b/src/vidalia/config/TransportSettings.h
new file mode 100644
index 0000000..2de073f
--- /dev/null
+++ b/src/vidalia/config/TransportSettings.h
@@ -0,0 +1,39 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+** including this file, may be copied, modified, propagated, or distributed
+** except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file TransportSettings.h
+** \brief Pluggable transport settings
+*/
+
+#ifndef _TRANSPORTSETTINGS_H
+#define _TRANSPORTSETTINGS_H
+
+#include "VSettings.h"
+
+#include <QtCore>
+
+class TransportSettings : public VSettings
+{
+ Q_OBJECT
+
+public:
+ /** Default constructor. */
+ TransportSettings();
+
+ /** Returns the available transports */
+ QStringList getTransports();
+
+ /** Returns the ServerTransportPlugin value for a given transport */
+ QString getSTP(const QString &transport);
+};
+
+#endif
+
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits