[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2465: Code Cleanup: applied CheckSpace.pl and removed tabs (in vidalia/branches/hidden-services/src: torcontrol vidalia/config)
Author: borkdomenik
Date: 2008-03-26 18:23:40 -0400 (Wed, 26 Mar 2008)
New Revision: 2465
Modified:
vidalia/branches/hidden-services/src/torcontrol/torcontrol.cpp
vidalia/branches/hidden-services/src/torcontrol/torcontrol.h
vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp
vidalia/branches/hidden-services/src/vidalia/config/configdialog.h
vidalia/branches/hidden-services/src/vidalia/config/configpage.h
vidalia/branches/hidden-services/src/vidalia/config/generalpage.cpp
vidalia/branches/hidden-services/src/vidalia/config/service.cpp
vidalia/branches/hidden-services/src/vidalia/config/service.h
vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp
vidalia/branches/hidden-services/src/vidalia/config/servicelist.h
vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp
vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h
Log:
Code Cleanup: applied CheckSpace.pl and removed tabs
Modified: vidalia/branches/hidden-services/src/torcontrol/torcontrol.cpp
===================================================================
--- vidalia/branches/hidden-services/src/torcontrol/torcontrol.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/torcontrol/torcontrol.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -1,6 +1,6 @@
/*
** 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
+** 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.vidalia-project.net/. No part of Vidalia, including this file,
@@ -8,7 +8,7 @@
** the terms described in the LICENSE file.
*/
-/*
+/*
** \file torcontrol.cpp
** \version $Id$
** \brief Object for interacting with the Tor process and control interface
@@ -19,7 +19,6 @@
#include <stringutil.h>
#include "torcontrol.h"
-
/** Default constructor */
TorControl::TorControl()
{
@@ -50,7 +49,7 @@
QObject::connect(_torService, SIGNAL(finished(int, QProcess::ExitStatus)),
this, SLOT(onStopped(int, QProcess::ExitStatus)));
QObject::connect(_torService, SIGNAL(startFailed(QString)),
- this, SLOT(onStartFailed(QString)));
+ this, SLOT(onStartFailed(QString)));
#endif
}
@@ -123,7 +122,7 @@
{
if (_controlConn->status() == ControlConnection::Connecting)
_controlConn->cancelConnect();
-
+
emit stopped();
emit stopped(exitCode, exitStatus);
}
@@ -191,7 +190,7 @@
if (_torProcess) {
/* If we're running a Tor process, then start reading logs from stdout
* again, in case our control connection just died but Tor is still
- * running. In this case, there may be relevant information in the logs. */
+ * running. In this case, there may be relevant information in the logs. */
_torProcess->openStdout();
}
/* Tor isn't running, so it has no version */
@@ -235,7 +234,7 @@
}
/** Sends an authentication cookie to Tor. The syntax is:
- *
+ *
* "AUTHENTICATE" SP 1*HEXDIG CRLF
*/
bool
@@ -244,17 +243,17 @@
ControlCommand cmd("AUTHENTICATE", base16_encode(cookie));
ControlReply reply;
QString str;
-
+
if (!send(cmd, reply, &str)) {
emit authenticationFailed(str);
return err(errmsg, str);
}
- onAuthenticated();
+ onAuthenticated();
return true;
}
/** Sends an authentication password to Tor. The syntax is:
- *
+ *
* "AUTHENTICATE" SP QuotedString CRLF
*/
bool
@@ -264,12 +263,12 @@
.arg(string_escape(password)));
ControlReply reply;
QString str;
-
+
if (!send(cmd, reply, &str)) {
emit authenticationFailed(str);
return err(errmsg, str);
}
- onAuthenticated();
+ onAuthenticated();
return true;
}
@@ -280,11 +279,11 @@
/* The version of Tor isn't going to change while we're connected to it, so
* save it for later. */
getInfo("version", _torVersion);
-
+
/* The control socket is connected, so we can stop reading from stdout */
if (_torProcess)
_torProcess->closeStdout();
-
+
emit authenticated();
}
@@ -306,11 +305,11 @@
foreach (ReplyLine line, reply.getLines()) {
if (line.getStatus() != "250")
continue;
-
+
msg = line.getMessage().trimmed();
idx = msg.indexOf(" ");
topic = msg.mid(0, idx).toUpper();
-
+
if (idx > 0) {
keyvals = string_parse_keyvals(msg.mid(idx+1), &ok);
if (!ok)
@@ -318,7 +317,7 @@
} else {
keyvals = QHash<QString,QString>();
}
-
+
if (topic == "AUTH") {
if (keyvals.contains("METHODS"))
pi.setAuthMethods(keyvals.value("METHODS"));
@@ -357,8 +356,8 @@
/** Sends a GETINFO message to Tor based on the given map of keyvals. The
* syntax is:
- *
- * "GETINFO" 1*(SP keyword) CRLF
+ *
+ * "GETINFO" 1*(SP keyword) CRLF
*/
bool
TorControl::getInfo(QHash<QString,QString> &map, QString *errmsg)
@@ -370,7 +369,7 @@
foreach (QString key, map.keys()) {
cmd.addArgument(key);
}
-
+
/* Ask Tor for the specified info values */
if (send(cmd, reply, errmsg)) {
/* Parse the response for the returned values */
@@ -405,7 +404,7 @@
int index = msg.indexOf("=");
QString key = msg.mid(0, index);
QStringList val;
-
+
if (index > 0 && index < msg.length()-1)
val << msg.mid(index+1);
if (line.hasData())
@@ -458,7 +457,7 @@
* asking it to stop running, so don't try to get a response. */
return _controlConn->send(cmd, errmsg);
}
- return send(cmd, errmsg);
+ return send(cmd, errmsg);
}
/** Returns an address on which Tor is listening for application
@@ -472,7 +471,7 @@
if (getSocksPort() == 0) {
return QHostAddress::Null;
}
-
+
/* Get a list of SocksListenAddress lines and return the first valid IP
* address parsed from the list. */
QStringList addrList = getSocksAddressList(errmsg);
@@ -486,7 +485,7 @@
return QHostAddress::LocalHost;
}
-/** Returns a (possibly empty) list of all currently configured
+/** Returns a (possibly empty) list of all currently configured
* SocksListenAddress entries. */
QStringList
TorControl::getSocksAddressList(QString *errmsg)
@@ -519,8 +518,8 @@
quint16 port, socksPort;
QString portString;
QList<quint16> portList;
-
- /* Get the value of the SocksPort configuration variable */
+
+ /* Get the value of the SocksPort configuration variable */
if (getConf("SocksPort", portString, errmsg)) {
socksPort = (quint16)portString.toUInt(&valid);
if (valid) {
@@ -590,7 +589,7 @@
* otherwise it is removed. If set is true, then the given event will be
* registered with Tor. */
bool
-TorControl::setEvent(TorEvents::TorEvent e, QObject *obj,
+TorControl::setEvent(TorEvents::TorEvent e, QObject *obj,
bool add, bool set, QString *errmsg)
{
if (add) {
@@ -622,7 +621,7 @@
bool
TorControl::setEvents(QString *errmsg)
{
- ControlCommand cmd("SETEVENTS");
+ ControlCommand cmd("SETEVENTS");
quint32 torVersion = getTorVersion();
/* Add each event to the argument list */
@@ -640,13 +639,13 @@
return send(cmd, errmsg);
}
-/** Sets each configuration key in <b>map</b> to the value associated
+/** Sets each configuration key in <b>map</b> to the value associated
* with its key. */
bool
TorControl::setConf(QHash<QString,QString> map, QString *errmsg)
{
ControlCommand cmd("SETCONF");
-
+
/* Add each keyvalue to the argument list */
foreach (QString key, map.uniqueKeys()) {
foreach (QString value, map.values(key)) {
@@ -656,7 +655,7 @@
cmd.addArgument(key);
}
}
- return send(cmd, errmsg);
+ return send(cmd, errmsg);
}
/** Sets a single configuration key to the given value. */
@@ -668,7 +667,7 @@
return setConf(map, errmsg);
}
-/** Sets a single configuration string that is formatted <key=escaped value>. */
+/** Sets a single configuration string that is formatted <key=escaped value>.*/
bool
TorControl::setConf(QString keyAndValue, QString *errmsg)
{
@@ -718,7 +717,7 @@
QStringList keyval = line.getMessage().split("=");
if (keyval.size() == 2) {
confKey = keyval.at(0);
-
+
if (map.contains(confKey)) {
/* This configuration key has multiple values, so add this one to
* the list. */
@@ -778,7 +777,7 @@
int index = msg.indexOf("=");
QString key = msg.mid(0, index);
QString val;
-
+
if (index > 0 && index < msg.length()-1)
val = msg.mid(index+1);
@@ -788,7 +787,7 @@
confMap.insert(key, values);
} else {
confMap.insert(key, val);
- }
+ }
}
return confMap;
}
@@ -821,12 +820,11 @@
cmd.addArgument(key);
if (!send(cmd, reply, errmsg))
return "";
-
+
return reply.toString();
}
-
/** Tells Tor to reset the given configuration keys back to defaults. */
bool
TorControl::resetConf(QStringList keys, QString *errmsg)
@@ -854,7 +852,7 @@
{
QList<RouterDescriptor> rdlist;
RouterDescriptor rd;
-
+
rdlist = getDescriptorListByName(QStringList() << name, errmsg);
if (!rdlist.isEmpty()) {
rd = (RouterDescriptor)rdlist.takeFirst();
@@ -869,7 +867,7 @@
{
QList<RouterDescriptor> rdlist;
RouterDescriptor rd;
-
+
rdlist = getDescriptorListById(QStringList() << id, errmsg);
if (!rdlist.isEmpty()) {
rd = (RouterDescriptor)rdlist.takeFirst();
@@ -885,17 +883,17 @@
ControlCommand cmd("GETINFO");
ControlReply reply;
QList<RouterDescriptor> rdlist;
-
+
/* If there are no IDs in the list, then return now. */
if (nameList.isEmpty()) {
return QList<RouterDescriptor>();
}
-
+
/* Build up the the getinfo arguments from the list of names */
foreach (QString name, nameList) {
cmd.addArgument("desc/name/"+ name);
}
-
+
/* Request the list of router descriptors */
if (send(cmd, reply, errmsg)) {
foreach (ReplyLine line, reply.getLines()) {
@@ -917,12 +915,12 @@
ControlReply reply;
QHash<QString,bool> offline;
QList<RouterDescriptor> rdlist;
-
+
/* If there are no IDs in the list, then return now. */
if (idlist.isEmpty()) {
return QList<RouterDescriptor>();
}
-
+
/* Build up the the getinfo arguments fromthe list of IDs */
foreach (QString id, idlist) {
if (id.startsWith("!")) {
@@ -933,7 +931,7 @@
}
cmd.addArgument("desc/id/"+ id);
}
-
+
/* Request the list of router descriptors */
if (send(cmd, reply, errmsg)) {
foreach (ReplyLine line, reply.getLines()) {
@@ -969,7 +967,8 @@
QStringList idList;
if (send(cmd, reply, errmsg)) {
- QString routerIDs = reply.getMessage().remove(0,qstrlen("network-status="));
+ QString routerIDs = reply.getMessage().remove(0,
+ qstrlen("network-status="));
/* Split the list of router IDs up */
QStringList routers = routerIDs.split(" ");
@@ -996,7 +995,7 @@
ControlReply reply;
QList<Circuit> circuits;
Circuit c;
-
+
if (send(cmd, reply, errmsg)) {
/* Sometimes there is a circuit on the first message line */
QString msg = reply.getMessage();
@@ -1036,7 +1035,7 @@
ControlReply reply;
QList<Stream> streams;
Stream s;
-
+
if (send(cmd, reply, errmsg)) {
/* Sometimes there is a stream on the first message line */
QString msg = reply.getMessage();
@@ -1044,7 +1043,7 @@
if (!s.isEmpty()) {
streams << s;
}
-
+
/* The rest of the streams jsut come as data, one per line */
foreach (QString line, reply.getData()) {
s = Stream::fromString(line);
Modified: vidalia/branches/hidden-services/src/torcontrol/torcontrol.h
===================================================================
--- vidalia/branches/hidden-services/src/torcontrol/torcontrol.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/torcontrol/torcontrol.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -1,6 +1,6 @@
/*
** 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
+** 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.vidalia-project.net/. No part of Vidalia, including this file,
@@ -8,7 +8,7 @@
** the terms described in the LICENSE file.
*/
-/*
+/*
** \file torcontrol.h
** \version $Id$
** \brief Object for interacting with the Tor process and control interface
@@ -35,11 +35,10 @@
#include "torservice.h"
#endif
-
class TorControl : public QObject
{
Q_OBJECT
-
+
public:
/** Default constructor */
TorControl();
@@ -54,7 +53,7 @@
bool isRunning();
/** Detects if the Tor process is running under Vidalia. */
bool isVidaliaRunningTor();
-
+
/** Connect to Tor's control socket */
void connect(const QHostAddress &address, quint16 port);
/** Disconnect from Tor's control socket */
@@ -65,11 +64,11 @@
bool authenticate(const QByteArray cookie, QString *errmsg = 0);
/** Sends an authentication password to Tor. */
bool authenticate(const QString password = QString(), QString *errmsg = 0);
-
+
/** Sends a PROTOCOLINFO command to Tor and parses the response. */
ProtocolInfo protocolInfo(QString *errmsg = 0);
-
- /** Returns true if Tor either has an open circuit or (on Tor >=
+
+ /** Returns true if Tor either has an open circuit or (on Tor >=
* 0.2.0.1-alpha) has previously decided it's able to establish a circuit. */
bool circuitEstablished();
@@ -87,14 +86,13 @@
* constructed QVariant on failure. */
QVariant getInfo(const QString &key, QString *errmsg = 0);
-
/** Sends a signal to Tor */
bool signal(TorSignal::Signal sig, QString *errmsg = 0);
-
+
/** Returns an address on which Tor is listening for application
* requests. If none are available, a null QHostAddress is returned. */
QHostAddress getSocksAddress(QString *errmsg = 0);
- /** Returns a (possibly empty) list of all currently configured
+ /** Returns a (possibly empty) list of all currently configured
* SocksListenAddress entries. */
QStringList getSocksAddressList(QString *errmsg = 0);
/** Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting
@@ -112,13 +110,12 @@
/** Sets an event and its handler. If add is true, then the event is added,
* otherwise it is removed. If set is true, then the given event will be
* registered with Tor. */
- bool setEvent(TorEvents::TorEvent e, QObject *obj,
+ bool setEvent(TorEvents::TorEvent e, QObject *obj,
bool add, bool set = true, QString *errmsg = 0);
/** Registers for a set of logging events according to the given filter. */
bool setLogEvents(uint filter, QObject *obj, QString *errmsg = 0);
/** Register events of interest with Tor */
bool setEvents(QString *errmsg = 0);
-
/** Sets each configuration key in <b>map</b> to the value associated with its key. */
bool setConf(QHash<QString,QString> map, QString *errmsg = 0);
@@ -144,10 +141,10 @@
* QVariant containing the value returned by Tor. Returns a default
* constructed QVariant on failure. */
QVariant getConf(const QString &key, QString *errmsg = 0);
- /** Sends a GETCONF message to Tor with the single key and returns a QString
+ /** Sends a GETCONF message to Tor with the single key and returns a QString
* containing the value returned by Tor */
QString getHiddenServiceConf(const QString &key, QString *errmsg = 0);
-
+
/** Asks Tor to save the current configuration to its torrc */
bool saveConf(QString *errmsg = 0);
/** Tells Tor to reset the given configuration keys back to defaults. */
@@ -172,7 +169,7 @@
QList<Circuit> getCircuits(QString *errmsg = 0);
/** Gets a list of current streams. */
QList<Stream> getStreams(QString *errmsg = 0);
-
+
/** Gets a list of address mappings of the type specified by <b>type</b>
* (defaults to <i>AddressMapAll</i>. */
AddressMap getAddressMap(
@@ -224,7 +221,7 @@
bool send(ControlCommand cmd, ControlReply &reply, QString *errmsg = 0);
/** Send a message to Tor and discard the response */
bool send(ControlCommand cmd, QString *errmsg = 0);
-
+
/* The slots below simply relay signals from the appropriate member objects */
private slots:
void onStarted();
Modified: vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -15,11 +15,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
-/**
+/**
* \file configdialog.cpp
* \version $Id$
* \brief Contains a series of Vidalia and Tor configuration pages
@@ -42,16 +42,15 @@
#define IMAGE_SAVE ":/images/22x22/media-floppy.png"
#define IMAGE_CANCEL ":/images/22x22/emblem-unreadable.png"
#define IMAGE_HELP ":/images/22x22/help-browser.png"
-#define IMAGE_SERVICE ":/images/22x22/service.png"
+#define IMAGE_SERVICE ":/images/22x22/service.png"
-
/** Constructor */
ConfigDialog::ConfigDialog(QWidget* parent)
: VidaliaWindow("ConfigDialog", parent)
{
/* Invoke the Qt Designer generated QObject setup routine */
ui.setupUi(this);
-
+
/* Override the QDialogButtonBox button text so we can use our own
* translations. */
QPushButton *button = ui.buttonBox->button(QDialogButtonBox::Ok);
@@ -60,7 +59,7 @@
button = ui.buttonBox->button(QDialogButtonBox::Cancel);
if (button)
button->setText(tr("Cancel"));
-
+
/* Connect the button box signals to the appropriate slots */
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveChanges()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
@@ -73,26 +72,27 @@
ui.stackPages->add(new GeneralPage(ui.stackPages),
createPageAction(QIcon(IMAGE_GENERAL),
tr("General"), grp));
-
+
ui.stackPages->add(new NetworkPage(ui.stackPages),
createPageAction(QIcon(IMAGE_NETWORK),
tr("Network"), grp));
-
+
ui.stackPages->add(new ServerPage(ui.stackPages),
createPageAction(QIcon(IMAGE_SERVER),
tr("Sharing"), grp));
-
+
ui.stackPages->add(new AppearancePage(ui.stackPages),
createPageAction(QIcon(IMAGE_APPEARANCE),
tr("Appearance"), grp));
-
+
ui.stackPages->add(new AdvancedPage(ui.stackPages),
createPageAction(QIcon(IMAGE_ADVANCED),
tr("Advanced"), grp));
-
+
ui.stackPages->add(new ServicePage(ui.stackPages),
createPageAction(QIcon(IMAGE_SERVICE),
tr("Services"), grp));
+
foreach (ConfigPage *page, ui.stackPages->pages()) {
connect(page, SIGNAL(helpRequested(QString)),
this, SLOT(help(QString)));
@@ -101,9 +101,9 @@
/* Create the toolbar */
ui.toolBar->addActions(grp->actions());
ui.toolBar->addSeparator();
- connect(grp, SIGNAL(triggered(QAction *)),
+ connect(grp, SIGNAL(triggered(QAction *)),
ui.stackPages, SLOT(showPage(QAction *)));
-
+
/* Create and bind the Help button */
QAction *helpAct = new QAction(QIcon(IMAGE_HELP), tr("Help"), ui.toolBar);
addAction(helpAct, SLOT(help()));
@@ -164,16 +164,16 @@
ConfigDialog::saveChanges()
{
QString errmsg;
-
+
/* Call each config page's save() method to save its data */
foreach (ConfigPage *page, ui.stackPages->pages()) {
if (!page->save(errmsg)) {
/* Display the offending page */
ui.stackPages->setCurrentPage(page);
-
+
/* Show the user what went wrong */
- VMessageBox::warning(this,
- tr("Error Saving Settings"),
+ VMessageBox::warning(this,
+ tr("Error Saving Settings"),
p(tr("Vidalia was unable to save your %1 settings.")
.arg(page->title())) + p(errmsg),
VMessageBox::Ok);
@@ -222,7 +222,7 @@
appliedChanges = true;
}
if (appliedChanges)
- saveConf();
+ saveConf();
close();
}
@@ -245,7 +245,7 @@
ConfigDialog::help()
{
Page currentPage = static_cast<Page>(ui.stackPages->currentIndex());
-
+
switch (currentPage) {
case Network:
help("config.network"); break;
Modified: vidalia/branches/hidden-services/src/vidalia/config/configdialog.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/configdialog.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/configdialog.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -30,7 +30,6 @@
#include "ui_configdialog.h"
-
class ConfigDialog : public VidaliaWindow
{
Q_OBJECT
@@ -43,7 +42,7 @@
Server, /** Server configuration page. */
Appearance, /** Appearance configuration page. */
Advanced, /** Advanced configuration page. */
- Service /** Service Configuration page */
+ Service /** Service Configuration page */
};
/** Default Constructor */
@@ -78,7 +77,7 @@
QAction* createPageAction(QIcon img, QString text, QActionGroup *group);
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
-
+
/** Qt Designer generated object */
Ui::ConfigDialog ui;
};
Modified: vidalia/branches/hidden-services/src/vidalia/config/configpage.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/configpage.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/configpage.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -19,14 +19,13 @@
#include <QWidget>
-
class ConfigPage : public QWidget
{
Q_OBJECT
public:
/** Default Constructor */
- ConfigPage(QWidget *parent = 0, const QString title = QString())
+ ConfigPage(QWidget *parent = 0, const QString title = QString())
: QWidget(parent), _title(title) {}
/** Returns the title of this configuration page. */
Modified: vidalia/branches/hidden-services/src/vidalia/config/generalpage.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/generalpage.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/generalpage.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -16,7 +16,6 @@
#include "generalpage.h"
-
/** Constructor */
GeneralPage::GeneralPage(QWidget *parent)
: ConfigPage(parent, tr("General"))
@@ -27,9 +26,9 @@
/* Create settings objects */
_vidaliaSettings = new VidaliaSettings;
_torSettings = new TorSettings;
-
+
/* Bind event to actions */
- connect(ui.btnBrowseTorExecutable, SIGNAL(clicked()),
+ connect(ui.btnBrowseTorExecutable, SIGNAL(clicked()),
this, SLOT(browseTorPath()));
/* Hide platform specific features */
@@ -54,12 +53,12 @@
#else
QString filter = "";
#endif
-
+
/* Prompt the user for an executable file. If we're on windows, filter for
* only .exe files. */
QString filename = QDir::convertSeparators(
QFileDialog::getOpenFileName(this,
- tr("Select Path to Tor"),
+ tr("Select Path to Tor"),
ui.lineTorExecutable->text(),
filter));
if (!filename.isEmpty()) {
Modified: vidalia/branches/hidden-services/src/vidalia/config/service.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/service.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/service.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -8,7 +8,6 @@
** terms described in the LICENSE file.
*/
-
#include "service.h"
/** Default Constructor */
@@ -16,9 +15,9 @@
}
/** Constructor to create a new Service with initial settings */
-Service::Service(QString serviceAddress, QString virtualPort, QString physicalAddressPort,
- QString serviceDirectory, bool enabled) {
-
+Service::Service(QString serviceAddress, QString virtualPort,
+ QString physicalAddressPort, QString serviceDirectory, bool enabled) {
+
_serviceAddress = serviceAddress;
_virtualPort = virtualPort;
_physicalAddressPort = physicalAddressPort;
@@ -60,17 +59,16 @@
_additionalServiceOptions = options;
}
-
/** Writes service class data from <b>myObj</b> to the QDataStream
* <b>out</b>. */
-QDataStream&operator<<(QDataStream &out, const Service &myObj) {
+QDataStream&operator<<(QDataStream &out, const Service &myObj) {
out << myObj.serviceAddress();
out << myObj.virtualPort();
out << myObj.physicalAddressPort();
out << myObj.serviceDirectory();
out << myObj.enabled();
out << myObj.additionalServiceOptions();
-
+
return out;
}
@@ -85,7 +83,8 @@
QString additionalServiceOptions;
/* Read in from the data stream */
- in >> serviceAddress >> virtualPort >> physicalAddressPort >> serviceDirectory >> enabled >> additionalServiceOptions;
+ in >> serviceAddress >> virtualPort >> physicalAddressPort
+ >> serviceDirectory >> enabled >> additionalServiceOptions;
/* Set the appropriate class member variables */
myObj.setServiceAddress(serviceAddress);
@@ -99,4 +98,3 @@
return in;
}
-
Modified: vidalia/branches/hidden-services/src/vidalia/config/service.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/service.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/service.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -21,59 +21,43 @@
/** Default constructor. */
Service();
-
/** Constructor to create a new Service with initial settings */
- Service(QString serviceAddress, QString virtualPort, QString physicalAddressPort,
- QString serviceDirectory, bool enabled);
-
+ Service(QString serviceAddress, QString virtualPort,
+ QString physicalAddressPort, QString serviceDirectory, bool enabled);
/** Destructor */
- virtual ~Service();
-
+ virtual ~Service();
/** Returns the service Adress of the service */
QString serviceAddress() const { return _serviceAddress; }
-
/** Returns the listeningPort of the service */
QString virtualPort() const { return _virtualPort; }
-
/** Returns the physical Adresse and the local Port of the service */
QString physicalAddressPort() const { return _physicalAddressPort; }
-
/** Returns the service directory of the service */
QString serviceDirectory() const { return _serviceDirectory; }
-
- /** Returns the deployed status of a service */
+ /** Returns the deployed status of a service */
bool enabled() const { return _enabled; }
-
/** Returns the additional options of a service e.g. excludeNodes */
- QString additionalServiceOptions() const { return _additionalServiceOptions; }
-
- /** Sets the adress of a service */
+ QString additionalServiceOptions() const
+ { return _additionalServiceOptions; }
+ /** Sets the adress of a service */
void setServiceAddress(QString serviceAddress);
-
- /** Sets the listening port of a service */
+ /** Sets the listening port of a service */
void setVirtualPort(QString virtualPort);
-
- /** Sets the physical Adress and the local Port of a service */
+ /** Sets the physical Adress and the local Port of a service */
void setPhysicalAddressPort(QString physicalAddressPort);
-
- /** Sets the service directory of a service */
+ /** Sets the service directory of a service */
void setServiceDirectory(QString serviceDirectory);
-
- /** Sets the deployed status a service */
+ /** Sets the deployed status a service */
void setEnabled(bool enabled);
-
/** Sets the additional options of a service e.g. excludeNodes */
void setAdditionalServiceOptions(QString options);
-
/** Writes service class data from <b>myObj</b> to the QDataStream
* <b>out</b>. */
friend QDataStream& operator<<(QDataStream &out, const Service &myObj);
-
/** Reads service class data in from the QDataStream <b>in</b> and
populates * the <b>myObj</b> object accordingly. */
- friend QDataStream& operator>>(QDataStream &in, Service &myObj);
-
-
+ friend QDataStream& operator>>(QDataStream &in, Service &myObj);
+
private:
/** The adress of the service */
QString _serviceAddress;
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -8,7 +8,6 @@
** terms described in the LICENSE file.
*/
-
#include "servicelist.h"
/** Default constructor. */
@@ -17,8 +16,7 @@
/** Constructor to create a new Servicelist with initial settings */
void ServiceList::addService(Service service) {
- _services.append(service);
-
+ _services.append(service);
}
/** Destructor */
@@ -27,30 +25,25 @@
/* Sets the serviceList */
void ServiceList::setServices(QList<Service> services) {
- _services = services;
+ _services = services;
}
-
/** Writes ServiceList class data from <b>myObj</b> to the QDataStream
* <b>out</b>. */
QDataStream&operator<<(QDataStream &out, const ServiceList &myObj) {
-
- out << myObj.services(); /* Write the services*/
-
- return out;
+ out << myObj.services(); /* Write the services*/
+ return out;
}
/** Reads ServiceList class data in from the QDataStream <b>in</b> and
populates * the <b>myObj</b> object accordingly. */
QDataStream&operator>>(QDataStream &in, ServiceList &myObj) {
- QList<Service> services;
-
- /* Read in from the data stream */
- in >> services;
-
- /* Set the appropriate class member variables */
- myObj.setServices(services);
-
- /* Return the updated data stream */
- return in;
+ QList<Service> services;
+ /* Read in from the data stream */
+ in >> services;
+ /* Set the appropriate class member variables */
+ myObj.setServices(services);
+ /* Return the updated data stream */
+ return in;
}
+
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicelist.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicelist.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicelist.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -15,36 +15,31 @@
class ServiceList
{
public:
+
/** Default constructor. */
ServiceList();
-
/** Destructor */
virtual ~ServiceList();
-
- /** Returns the list of services */
+ /** Returns the list of services */
void addService(Service service);
-
/** Sets the lists of services */
void setServices(QList<Service> services);
-
- /** Returns the list of services */
+ /** Returns the list of services */
QList<Service> services() const {
- return _services;
+ return _services;
}
-
/** Writes ServiceList class data from <b>myObj</b> to the QDataStream
* <b>out</b>. */
friend QDataStream& operator<<(QDataStream &out, const ServiceList &myObj);
-
/** Reads ServiceList class data in from the QDataStream <b>in</b> and
populates * the <b>myObj</b> object accordingly. */
friend QDataStream& operator>>(QDataStream &in, ServiceList &myObj);
-
-
+
private:
-/** The list of Services */
-QList<Service> _services;
-
+
+ /** The list of Services */
+ QList<Service> _services;
+
};
Q_DECLARE_METATYPE(ServiceList);
#endif /*SERVICELIST_H_*/
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -29,93 +29,102 @@
/* 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();
+ _torControl = Vidalia::torControl();
/* Create Tor settings objects */
_torSettings = new TorSettings;
- /* Keep a pointer to the ServiceSettings object used to store the configuration */
+ /* Keep a pointer to the ServiceSettings object used to store
+ * the configuration */
_serviceSettings = new ServiceSettings(_torControl);
- /* A QMap, mapping from the row number to the Entity for all services */
+ /* A QMap, mapping from the row number to the Entity for
+ * all services */
_services = new QMap<int, Service>();
- /* A QMap, mapping from the directory path to the Entity for all Tor services */
+ /* A QMap, mapping from the directory path to the Entity for
+ * all Tor services */
_torServices = new QMap<QString, Service>();
-
+
ui.serviceWidget->horizontalHeader()->resizeSection(0, 150);
ui.serviceWidget->horizontalHeader()->resizeSection(1, 89);
ui.serviceWidget->horizontalHeader()->resizeSection(2, 100);
ui.serviceWidget->horizontalHeader()->resizeSection(3, 120);
ui.serviceWidget->horizontalHeader()->resizeSection(4, 60);
ui.serviceWidget->verticalHeader()->hide();
-
+
connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addService()));
connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeService()));
connect(ui.copyButton, SIGNAL(clicked()), this, SLOT(copyToClipboard()));
connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseDirectory()));
- connect(ui.serviceWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this, SLOT(serviceSelectionChanged()));
- connect(ui.serviceWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(valueChanged()));
+ connect(ui.serviceWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this,
+ SLOT(serviceSelectionChanged()));
+ connect(ui.serviceWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this,
+ SLOT(valueChanged()));
}
/** Destructor */
ServicePage::~ServicePage()
{
- delete _serviceSettings;
+ delete _serviceSettings;
}
/** Saves changes made to settings on the Server settings page. */
bool
ServicePage::save(QString &errmsg)
{
- QList<Service> serviceList;
+ QList<Service> serviceList;
QList<Service> publishedServices;
int index = 0;
while(index < ui.serviceWidget->rowCount()) {
- QString address = ui.serviceWidget->item(index,0)->text();
- QString virtualPort = ui.serviceWidget->item(index,1)->text();
- QString physicalAddress = ui.serviceWidget->item(index,2)->text();
- QString directoryPath = ui.serviceWidget->item(index,3)->text();
- bool enabled = _services->value(index).enabled();
- Service temp(address, virtualPort, physicalAddress, directoryPath, enabled);
- temp.setAdditionalServiceOptions(_services->value(ui.serviceWidget->currentRow()).additionalServiceOptions());
+ QString address = ui.serviceWidget->item(index,0)->text();
+ QString virtualPort = ui.serviceWidget->item(index,1)->text();
+ QString physicalAddress = ui.serviceWidget->item(index,2)->text();
+ QString directoryPath = ui.serviceWidget->item(index,3)->text();
+ bool enabled = _services->value(index).enabled();
+ Service temp(address, virtualPort, physicalAddress, directoryPath,
+ enabled);
+ temp.setAdditionalServiceOptions(_services->value(ui.serviceWidget->
+ currentRow()).additionalServiceOptions());
serviceList.push_back(temp);
if(enabled) {
- publishedServices.push_back(temp);
- }
+ publishedServices.push_back(temp);
+ }
index++;
}
bool save;
save = checkBeforeSaving(serviceList);
if(save) {
- ServiceList sList;
+ ServiceList sList;
if(serviceList.size() > 0) {
sList.setServices(serviceList);
} else {
- _services = new QMap<int, Service>();
+ _services = new QMap<int, Service>();
sList.setServices(_services->values());
}
_serviceSettings->setServices(sList);
if(publishedServices.size() > 0) {
- startServicesInTor(publishedServices);
+ startServicesInTor(publishedServices);
} else {
- QString errmsg1 = tr("Error while trying to unpublish all services");
- QString &errmsg = errmsg1;
- _serviceSettings->unpublishAllServices(&errmsg);
- }
+ QString errmsg1 = tr("Error while trying to unpublish all services");
+ QString &errmsg = errmsg1;
+ _serviceSettings->unpublishAllServices(&errmsg);
+ }
return true;
} else {
- errmsg = "Please configure at least a service directory and a virtual port for each service you want to save. Remove the other ones.";
- return false;
- }
+ errmsg = tr("Please configure at least a service directory and a virtual\
+ port for each service you want to save. Remove the other ones.");
+ return false;
+ }
}
-/** this method checks either all services have minimal configuration or not s*/
+/** this method checks if either all services have minimal
+ * configuration or not */
bool
ServicePage::checkBeforeSaving(QList<Service> serviceList)
{
bool result = true;
foreach(Service s, serviceList) {
- if(s.serviceDirectory().isEmpty() || s.virtualPort().isEmpty()) {
- result = false;
- break;
- }
+ if(s.serviceDirectory().isEmpty() || s.virtualPort().isEmpty()) {
+ result = false;
+ break;
+ }
}
return result;
}
@@ -129,11 +138,14 @@
QListIterator<Service> it(services);
bool first = true;
while(it.hasNext()) {
- Service temp = it.next();
- serviceConfString.append("hiddenservicedir=" + string_escape(temp.serviceDirectory()) + " ");
- serviceConfString.append("hiddenserviceport=" + string_escape(temp.virtualPort() +
- (temp.physicalAddressPort().isEmpty() ? "" : " " + temp.physicalAddressPort())));
- serviceConfString.append(" "+ temp.additionalServiceOptions());
+ Service temp = it.next();
+ serviceConfString.append("hiddenservicedir=" +
+ string_escape(temp.serviceDirectory()) + " ");
+ serviceConfString.append("hiddenserviceport=" +
+ string_escape(temp.virtualPort() +
+ (temp.physicalAddressPort().isEmpty() ? "" : " " +
+ temp.physicalAddressPort())));
+ serviceConfString.append(" "+ temp.additionalServiceOptions());
}
_serviceSettings->apply(serviceConfString, &errmsg);
}
@@ -149,34 +161,35 @@
_services = new QMap<int, Service>();
_torServices = new QMap<QString, Service>();
QList<Service> torServiceList;
-
- QString torConfigurationString = _serviceSettings->getHiddenServiceDirectories();
+
+ QString torConfigurationString = _serviceSettings->
+ getHiddenServiceDirectories();
torServiceList = extractSingleServices(torConfigurationString);
QList<Service> completeList = torServiceList;
// the services stored with vidalia
- ServiceList serviceList = _serviceSettings->getServices();
- QList<Service> serviceSettingsList = serviceList.services();
+ ServiceList serviceList = _serviceSettings->getServices();
+ QList<Service> serviceSettingsList = serviceList.services();
QListIterator<Service> it(serviceSettingsList);
// check whether a service is already in the list because he is published
while(it.hasNext()) {
- Service temp = it.next();
- if(isServicePublished(temp, torServiceList) == false) {
- completeList.push_back(temp);
- }
+ Service temp = it.next();
+ if(isServicePublished(temp, torServiceList) == false) {
+ completeList.push_back(temp);
+ }
}
// generate the _services data structure used during vidalia session
QListIterator<Service> it2(completeList);
- int index = 0;
- while (it2.hasNext()) {
- Service tempService = it2.next();
- _services->insert(index, tempService);
+ int index = 0;
+ while (it2.hasNext()) {
+ Service tempService = it2.next();
+ _services->insert(index, tempService);
index++;
}
- initServiceTable(_services);
+ initServiceTable(_services);
}
-/** this method returns a list of services by parsing the configuration string given
- * by the tor controller */
+/** this method returns a list of services by parsing the configuration
+ * string given by the tor controller */
QList<Service>
ServicePage::extractSingleServices(QString conf)
{
@@ -186,14 +199,14 @@
QListIterator<QString> it(strList);
//for each service directory splitted string = service
while(it.hasNext()) {
- QString temp = it.next();
- list.push_back(generateService(temp));
+ QString temp = it.next();
+ list.push_back(generateService(temp));
}
- return list;
+ return list;
}
-/** this return a Service by parseing the configuration string of Tor and storeing its
- * values into the object */
+/** this return a Service by parseing the configuration string
+ * of Tor and storeing its values into the object */
Service
ServicePage::generateService(QString s)
{
@@ -202,33 +215,33 @@
int index = additionalOptions.indexOf("250",1);
additionalOptions.remove(0, index+4);
// remove the first appearance of the port
- int startindex = additionalOptions.indexOf("hiddenserviceport", 0, Qt::CaseInsensitive);
+ int startindex = additionalOptions.indexOf("hiddenserviceport",
+ 0, Qt::CaseInsensitive);
int endindex = additionalOptions.indexOf("250", startindex);
if(endindex != -1) {
- additionalOptions.remove(startindex, (endindex-startindex)+4);
- //remove all appearances of "250"
- while(additionalOptions.contains("250")) {
- int i = additionalOptions.indexOf("250", 0);
- additionalOptions.remove(i, 4);
- }
- // prepare for correct quotation
- if (!additionalOptions.endsWith('\n')) {
- additionalOptions.append("\n");
- }
- //quote the values
- int j = additionalOptions.indexOf("=", 0);
- while(j != -1) {
- additionalOptions.insert(j+1, "\"");
- int end = additionalOptions.indexOf("\n", j);
- additionalOptions.insert(end, "\"");
- j = additionalOptions.indexOf("=", end);
- }
- //replace the line brakes with a space and create one single line
- additionalOptions.replace(QString("\n"), QString(" "));
+ additionalOptions.remove(startindex, (endindex-startindex)+4);
+ //remove all appearances of "250"
+ while(additionalOptions.contains("250")) {
+ int i = additionalOptions.indexOf("250", 0);
+ additionalOptions.remove(i, 4);
+ }
+ // prepare for correct quotation
+ if (!additionalOptions.endsWith('\n')) {
+ additionalOptions.append("\n");
+ }
+ //quote the values
+ int j = additionalOptions.indexOf("=", 0);
+ while(j != -1) {
+ additionalOptions.insert(j+1, "\"");
+ int end = additionalOptions.indexOf("\n", j);
+ additionalOptions.insert(end, "\"");
+ j = additionalOptions.indexOf("=", end);
+ }
+ //replace the line brakes with a space and create one single line
+ additionalOptions.replace(QString("\n"), QString(" "));
} else {
- additionalOptions = "";
+ additionalOptions = "";
}
-
QString address, virtualPort, physAddressPort, serviceDir;
// service directory
@@ -238,19 +251,19 @@
//virtual port
QStringList strList2 = s.split("HiddenServicePort");
strList2.removeFirst();
- QStringList strList3 = strList2.first().split("\n");
+ QStringList strList3 = strList2.first().split("\n");
QStringList strList4 = strList3.first().split(" ");
if(strList4.size() > 0) {
- QString tempVirtualPort = strList4.first();
- virtualPort = tempVirtualPort.remove(0, 1);
- strList4.removeFirst();
- //physical address:port
- if(!strList4.isEmpty()) {
- physAddressPort = strList4.first().trimmed();
- }
+ QString tempVirtualPort = strList4.first();
+ virtualPort = tempVirtualPort.remove(0, 1);
+ strList4.removeFirst();
+ //physical address:port
+ if(!strList4.isEmpty()) {
+ physAddressPort = strList4.first().trimmed();
+ }
} else {
- QString tempVirtualPort = strList3.first();
- virtualPort = tempVirtualPort.remove(0, 1);
+ QString tempVirtualPort = strList3.first();
+ virtualPort = tempVirtualPort.remove(0, 1);
}
//get .onion address
QString serviceHostnameDir = serviceDir;
@@ -258,19 +271,19 @@
serviceHostnameDir.append("hostname");
QFile file(serviceHostnameDir);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- address = "[Directory not found]";
+ address = "[Directory not found]";
} else {
- QTextStream in(&file);
- QString hostname;
+ QTextStream in(&file);
+ QString hostname;
while (!in.atEnd()) {
hostname.append(in.readLine());
}
address = hostname;
- }
+ }
Service service(address, virtualPort, physAddressPort, serviceDir, true);
service.setAdditionalServiceOptions(additionalOptions);
_torServices->insert(serviceDir, service);
- return service;
+ return service;
}
/** this method checks either a service is published or not */
@@ -279,15 +292,15 @@
{
QListIterator<Service> it(torServices);
while(it.hasNext()) {
- Service temp = it.next();
- if(temp.serviceDirectory().compare(service.serviceDirectory()) == 0) {
- return true;
- }
+ Service temp = it.next();
+ if(temp.serviceDirectory().compare(service.serviceDirectory()) == 0) {
+ return true;
+ }
}
return false;
}
-/** this method creates/displays the values for each service
+/** this method creates/displays the values for each service
* shown in the service listing */
void
ServicePage::initServiceTable(QMap<int, Service>* _services)
@@ -295,12 +308,12 @@
// clean the widget
int rows = ui.serviceWidget->rowCount();
for(int i = 0; i < rows; i++) {
- ui.serviceWidget->removeRow(0);
+ ui.serviceWidget->removeRow(0);
}
//for each service
int index = 0;
while(index < _services->size()) {
- Service tempService = _services->value(index);
+ Service tempService = _services->value(index);
ui.serviceWidget->insertRow(index);
QTableWidgetItem *cboxitem = new QTableWidgetItem();
cboxitem->setFlags(Qt::ItemIsSelectable);
@@ -309,7 +322,7 @@
if(tempService.serviceAddress().length() < 0) {
addressitem->setText(tempService.serviceAddress());
} else {
- QString serviceHostnameDir = tempService.serviceDirectory();
+ QString serviceHostnameDir = tempService.serviceDirectory();
serviceHostnameDir.append("/");
serviceHostnameDir.append("hostname");
QFile file(serviceHostnameDir);
@@ -323,7 +336,7 @@
}
addressitem->setText(hostname);
tempService.setServiceAddress(hostname);
- }
+ }
}
addressitem->setData(32, addressitem->text());
QTableWidgetItem *serviceDir =
@@ -339,8 +352,8 @@
cboxitem->setCheckState(Qt::Checked);
serviceDir->setFlags(Qt::ItemIsSelectable);
} else {
- cboxitem->setCheckState(Qt::Unchecked);
- }
+ cboxitem->setCheckState(Qt::Unchecked);
+ }
cboxitem->setTextAlignment(Qt::AlignCenter);
ui.serviceWidget->setItem(index, 0, addressitem);
ui.serviceWidget->setItem(index, 1, virtualportitem);
@@ -384,18 +397,19 @@
int rows = ui.serviceWidget->rowCount();
int selrow = ui.serviceWidget->currentRow();
if(selrow < 0 || selrow >= _services->size()) {
- VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), VMessageBox::Ok);
- return;
+ VMessageBox::warning(this, tr("Error"), tr("Please select a Service."),
+ VMessageBox::Ok);
+ return;
} else {
- ui.serviceWidget->removeRow(selrow);
- //decrease all other service keys
- for(int i = 0; i < (rows-selrow-1); i++) {
- int index = i+selrow;
- Service s = _services->take(index+1);
- _services->insert(index, s);
- }
+ ui.serviceWidget->removeRow(selrow);
+ //decrease all other service keys
+ for(int i = 0; i < (rows-selrow-1); i++) {
+ int index = i+selrow;
+ Service s = _services->take(index+1);
+ _services->insert(index, s);
+ }
}
- serviceSelectionChanged();
+ serviceSelectionChanged();
}
/** this method is called when the user clicks on the "Copy"-Button, it
@@ -405,15 +419,16 @@
{
int selrow = ui.serviceWidget->currentRow();
if(selrow < 0 || selrow >= _services->size()) {
- VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), VMessageBox::Ok);
- return;
+ VMessageBox::warning(this, tr("Error"), tr("Please select a Service."),
+ VMessageBox::Ok);
+ return;
} else {
- QString onionAddress = ui.serviceWidget->item(selrow,0)->text();
- QClipboard *clipboard = QApplication::clipboard();
+ QString onionAddress = ui.serviceWidget->item(selrow,0)->text();
+ QClipboard *clipboard = QApplication::clipboard();
QString clipboardText;
- QTableWidgetItem* selectedItem = ui.serviceWidget->item(selrow,0);
+ QTableWidgetItem* selectedItem = ui.serviceWidget->item(selrow,0);
clipboardText.append(selectedItem->text());
- clipboard->setText(clipboardText);
+ clipboard->setText(clipboardText);
}
}
@@ -424,21 +439,23 @@
{
int selrow = ui.serviceWidget->currentRow();
if(selrow < 0 || selrow >= _services->size()) {
- VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), VMessageBox::Ok);
- return;
+ VMessageBox::warning(this, tr("Error"), tr("Please select a Service."),
+ VMessageBox::Ok);
+ return;
} else {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Select Service Directory"),
- "", QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
-
+ QString dirname = QFileDialog::getExistingDirectory(this,
+ tr("Select Service Directory"), "",
+ QFileDialog::ShowDirsOnly|QFileDialog::DontResolveSymlinks);
+
if (dirname.isEmpty()) {
return;
}
ui.serviceWidget->item(selrow,3)->setText(dirname);
Service s = _services->take(selrow);
- s.setServiceDirectory(dirname);
+ s.setServiceDirectory(dirname);
_services->insert(selrow, s);
}
-}
+}
/** this method is called when the selects an other tablewidgetitem */
void
@@ -446,52 +463,54 @@
{
bool emptyTable = false;
if(ui.serviceWidget->rowCount() > 0) {
- ui.removeButton->setEnabled(true);
+ ui.removeButton->setEnabled(true);
ui.copyButton->setEnabled(true);
ui.browseButton->setEnabled(true);
} else {
- ui.removeButton->setEnabled(false);
+ ui.removeButton->setEnabled(false);
ui.copyButton->setEnabled(false);
ui.browseButton->setEnabled(false);
emptyTable = true;
}
int currentRow = ui.serviceWidget->currentRow();
if(emptyTable == false) {
- QTableWidgetItem* item = ui.serviceWidget->item(currentRow, 0);
- if(item != NULL) {
- bool b = item->text().contains(".onion");
- ui.copyButton->setEnabled(b);
- }
- }
- QTableWidgetItem* item = ui.serviceWidget->item(ui.serviceWidget->currentRow(), 3);
- QString selDir = _services->value(ui.serviceWidget->currentRow()).serviceDirectory();
+ QTableWidgetItem* item = ui.serviceWidget->item(currentRow, 0);
+ if(item != NULL) {
+ bool b = item->text().contains(".onion");
+ ui.copyButton->setEnabled(b);
+ }
+ }
+ QTableWidgetItem* item = ui.serviceWidget->item(ui.serviceWidget->
+ currentRow(), 3);
+ QString selDir = _services->value(ui.serviceWidget->currentRow()).
+ serviceDirectory();
QList<QString> strList = _torServices->keys();
if(selDir.length() > 0) {
- QListIterator<QString> it(strList);
- while(it.hasNext()) {
- QString temp = it.next();
- if(selDir.compare(temp) == 0) {
- ui.browseButton->setEnabled(false);
- break;
- }
- }
+ QListIterator<QString> it(strList);
+ while(it.hasNext()) {
+ QString temp = it.next();
+ if(selDir.compare(temp) == 0) {
+ ui.browseButton->setEnabled(false);
+ break;
+ }
+ }
}
- // if the user has clicked on the checkbox cell
+ // if the user has clicked on the checkbox cell
if(ui.serviceWidget->currentColumn() == 4) {
- Service service = _services->take(currentRow);
+ Service service = _services->take(currentRow);
QTableWidgetItem* item = ui.serviceWidget->item(currentRow,4);
if(service.enabled()) {
- item->setCheckState(Qt::Unchecked);
- service.setEnabled(false);
+ item->setCheckState(Qt::Unchecked);
+ service.setEnabled(false);
} else {
- item->setCheckState(Qt::Checked);
- service.setEnabled(true);
+ item->setCheckState(Qt::Checked);
+ service.setEnabled(true);
}
_services->insert(currentRow, service);
}
}
-/** this method is called when the user finished editing a cell and it provides
+/** this method is called when the user finished editing a cell and it provides
* that only valid values are set */
void
ServicePage::valueChanged()
@@ -529,9 +548,9 @@
QString address = strList.at(0);
QString port = strList.at(1);
if((address.compare("localhost") != 0 &&
- ipValidator->validate(address, pos) != QValidator::Acceptable &&
- domainValidator->validate(address, pos) != QValidator::Acceptable) ||
- portValidator->validate(port, pos) != QValidator::Acceptable) {
+ ipValidator->validate(address, pos) != QValidator::Acceptable &&
+ domainValidator->validate(address, pos) != QValidator::Acceptable) ||
+ portValidator->validate(port, pos) != QValidator::Acceptable) {
goto invalid;
}
} else { // either <address> or <port>
@@ -555,8 +574,8 @@
case 3: // service directory
// compare with directories of other enabled services
for (int index = 0; index < ui.serviceWidget->rowCount(); index++) {
- // skip own row
- if(index == item->row()) {
+ // skip own row
+ if(index == item->row()) {
continue;
}
QTableWidgetItem* compareWith = ui.serviceWidget->item(index, 3);
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -8,7 +8,6 @@
** terms described in the LICENSE file.
*/
-
#ifndef _SERVICEPAGE_H
#define _SERVICEPAGE_H
@@ -17,16 +16,15 @@
#include <servicesettings.h>
#include <exitpolicy.h>
#include <helpbrowser.h>
-
#include "configpage.h"
#include "ui_servicepage.h"
-
class ServicePage : public ConfigPage
{
Q_OBJECT
public:
+
/** Default Constructor */
ServicePage(QWidget *parent = 0);
/** Default Destructor */
@@ -39,30 +37,36 @@
void initServiceTable(QMap<int, Service>* _services);
private slots:
+
+ /** this method is called whenefer the user clicks on the 'add' Button*/
void addService();
-
+ /** this method is called whenefer the user clicks on the 'remove' Button*/
void removeService();
-
+ /** this method is called whenefer the user clicks on the 'copy' Button*/
void copyToClipboard();
-
+ /** this method is called whenefer the user clicks on the 'browse' Button*/
void browseDirectory();
-
+ /** this method is called whenefer the selects a different service*/
void serviceSelectionChanged();
-
+ /** this method returns a list of services by parsing the configuration
+ * string given by the tor controller */
QList<Service> extractSingleServices(QString conf);
-
+ /** this return a Service by parseing the configuration string
+ * of Tor and storeing its values into the object */
Service generateService(QString serviceString);
-
+ /** this method checks either a service is published or not */
void startServicesInTor(QList<Service> services);
-
- bool isServicePublished(Service service, QList<Service> torServices);
-
+ /** this method checks either a service is published or not */
+ bool isServicePublished(Service service, QList<Service> torServices);
+ /** this method checks if either all services have minimal
+ * configuration or not */
bool checkBeforeSaving(QList<Service> services);
-
+ /** this method is called when the user finished editing a cell and it provides
+ * that only valid values are set */
void valueChanged();
+private:
-private:
/** A TorControl object used to talk to Tor. */
TorControl* _torControl;
/** A TorSettings object used for saving/loading the Tor settings */
@@ -79,4 +83,3 @@
#endif
-
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp 2008-03-26 22:23:40 UTC (rev 2465)
@@ -1,4 +1,12 @@
-/** header */
+/*
+** 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.vidalia-project.net/. No part of Vidalia, including this file,
+** may be copied, modified, propagated, or distributed except according to the
+** terms described in the LICENSE file.
+*/
#include <stringutil.h>
#include "servicesettings.h"
@@ -14,14 +22,13 @@
#define SETTING_SERVICE_ENABLED "Service/Enabled"
#define SETTING_TOR_SERVICES "Service/Services"
-
/** Constructor.
* \param torControl a TorControl object used to read and apply the Service
* configuration settings.
*/
ServiceSettings::ServiceSettings(TorControl *torControl)
{
- _torControl = torControl;
+ _torControl = torControl;
setDefault(SETTING_SERVICE_VIRTUAL_PORT , 0);
setDefault(SETTING_SERVICE_PHYSICAL_ADDRESS, "127.0.0.1:0");
setDefault(SETTING_SERVICE_ENABLED, "true");
@@ -30,34 +37,33 @@
/** Set ServiceList to serialise it */
void
ServiceSettings::setServices(ServiceList service)
-{
- QVariant v = new QVariant();
- v.setValue(service);
- setValue(SETTING_TOR_SERVICES, v);
+{
+ QVariant v = new QVariant();
+ v.setValue(service);
+ setValue(SETTING_TOR_SERVICES, v);
}
-
/** Get serialised ServiceList */
ServiceList
ServiceSettings::getServices()
{
- QVariant v = value(SETTING_TOR_SERVICES);
- ServiceList services = v.value<ServiceList>();
- return services;
+ QVariant v = value(SETTING_TOR_SERVICES);
+ ServiceList services = v.value<ServiceList>();
+ return services;
}
/** Returns the virtual port for a specififc service*/
QString
ServiceSettings::getVirtualPort()
{
- QString port = value(SETTING_SERVICE_VIRTUAL_PORT).toString();
- return port;
+ QString port = value(SETTING_SERVICE_VIRTUAL_PORT).toString();
+ return port;
}
/** Set the virtual port for a specififc service*/
void
ServiceSettings::setVirtualPort(QString servicePort)
-{
+{
setValue(SETTING_SERVICE_VIRTUAL_PORT, servicePort);
}
@@ -76,7 +82,6 @@
setValue(SETTING_SERVICE_ADDRESS, addr);
}
-
/** Returns the physical address for a specific service */
QString
ServiceSettings::getPhysicalAddressPort()
@@ -98,34 +103,33 @@
return value(SETTING_SERVICE_ENABLED).toBool();
}
-void
+void
ServiceSettings::setEnabled(bool boolean)
{
- setValue(SETTING_SERVICE_ENABLED, boolean);
+ setValue(SETTING_SERVICE_ENABLED, boolean);
}
-
/** Set ServiceDirectory and send it to the Tor Controller */
void
ServiceSettings::apply(QString value, QString *errmsg)
-{
- _torControl->setConf(value, errmsg);
- _torControl->saveConf(errmsg);
+{
+ _torControl->setConf(value, errmsg);
+ _torControl->saveConf(errmsg);
}
/** Get all service directories from Tor */
QString
ServiceSettings::getHiddenServiceDirectories()
{
- QString value = _torControl->getHiddenServiceConf("hiddenserviceoptions");
- return value;
+ QString value = _torControl->getHiddenServiceConf("hiddenserviceoptions");
+ return value;
}
void
ServiceSettings::applyServices(QString value, QString *errmsg)
{
_torControl->setConf(value, errmsg);
- _torControl->saveConf(errmsg);
+ _torControl->saveConf(errmsg);
}
/** Unpublish all HiddenServices */
@@ -133,8 +137,6 @@
ServiceSettings::unpublishAllServices(QString *errmsg)
{
_torControl->resetConf("HiddenServiceDir", errmsg);
- _torControl->saveConf(errmsg);
+ _torControl->saveConf(errmsg);
}
-
-
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h 2008-03-26 00:21:25 UTC (rev 2464)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h 2008-03-26 22:23:40 UTC (rev 2465)
@@ -1,6 +1,13 @@
-/** header */
+/*
+** 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.vidalia-project.net/. No part of Vidalia, including this file,
+** may be copied, modified, propagated, or distributed except according to the
+** terms described in the LICENSE file.
+*/
-
#ifndef _SERVICESETTINGS_H
#define _SERVICESETTINGS_H
@@ -12,57 +19,44 @@
class ServiceSettings : private VidaliaSettings {
public:
- /** Constructor */
- ServiceSettings(TorControl *torControl);
-
- /** Returns the service port for a specififc service*/
- QString getVirtualPort();
- /** Set the service port for a specififc service*/
- void setVirtualPort(QString servicePort);
+ /** Constructor */
+ ServiceSettings(TorControl *torControl);
+ /** Returns the service port for a specififc service*/
+ QString getVirtualPort();
+ /** Set the service port for a specififc service*/
+ void setVirtualPort(QString servicePort);
+ /** Returns the .onion - service address for a specific service */
+ QString getServiceAddress();
+ /** Set the .onion - service address for a specific service */
+ void setServiceAddress(QString serviceAddress);
+ /** Returns the service address or hostname for a specific service */
+ QString getPhysicalAddressPort();
+ /** Set the service address or hostname for a specific service */
+ void setPhysicalAddressPort(QString physicalAddress);
+ /** Returns if the Service is enabled */
+ bool isEnabled();
+ /** Set the service enabled */
+ void setEnabled(bool enabled);
+ /** Returns a ServiceList containing all services */
+ ServiceList getServices();
+ /** Set ServiceList to serialise it */
+ void setServices(ServiceList services);
+ /** Set ServiceDirectory and send it to the Tor Controller */
+ void apply(QString value, QString *errmsg = 0);
+ /** Get Service Directories */
+ QString getHiddenServiceDirectories();
+ /** Set all services the user wants to start and
+ * send it to the Tor Controller */
+ void applyServices(QString value, QString *errmsg);
+ /** Unpublish all services */
+ void unpublishAllServices(QString *errmsg);
- /** Returns the .onion - service address for a specific service */
- QString getServiceAddress();
-
- /** Set the .onion - service address for a specific service */
- void setServiceAddress(QString serviceAddress);
-
- /** Returns the service address or hostname for a specific service */
- QString getPhysicalAddressPort();
-
- /** Set the service address or hostname for a specific service */
- void setPhysicalAddressPort(QString physicalAddress);
-
- /** Returns if the Service is enabled */
- bool isEnabled();
-
- /** Set the service enabled */
- void setEnabled(bool enabled);
-
- ServiceList getServices();
-
- /** Set ServiceList to serialise it */
- void setServices(ServiceList services);
-
- /** Set ServiceDirectory and send it to the Tor Controller */
- void apply(QString value, QString *errmsg = 0);
-
- /** Get Service Directories */
- QString getHiddenServiceDirectories();
-
- /** Set all services the user wants to start and send it to the Tor Controller */
- void applyServices(QString value, QString *errmsg);
-
- /** Unpublish all services */
- void unpublishAllServices(QString *errmsg);
-
private:
-
- /** A TorControl object used to talk to Tor. */
- TorControl* _torControl;
+
+ /** A TorControl object used to talk to Tor. */
+ TorControl* _torControl;
};
#endif
-
-