[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2553: Initial commit according to the GSoC project, including the (in vidalia/branches/hidden-services/src/vidalia: . config)
Author: borkdomenik
Date: 2008-05-05 11:56:08 -0400 (Mon, 05 May 2008)
New Revision: 2553
Added:
vidalia/branches/hidden-services/src/vidalia/config/user.cpp
vidalia/branches/hidden-services/src/vidalia/config/user.h
Modified:
vidalia/branches/hidden-services/src/vidalia/CMakeLists.txt
vidalia/branches/hidden-services/src/vidalia/config/configdialog.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/servicepage.cpp
vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui
vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp
vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h
Log:
Initial commit according to the GSoC project, including the new .ui file with the new tabs for service providers and consumers as well as the new User entity.
Most of the method bodies are empty, yet but i already started to implement them. The persistent storage of users associated to a service is already implemented.
Modified: vidalia/branches/hidden-services/src/vidalia/CMakeLists.txt
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/CMakeLists.txt 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/CMakeLists.txt 2008-05-05 15:56:08 UTC (rev 2553)
@@ -70,6 +70,7 @@
config/servicepage.cpp
config/servicesettings.cpp
config/torsettings.cpp
+ config/user.cpp
config/vidaliasettings.cpp
config/vsettings.cpp
)
Modified: vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/configdialog.cpp 2008-05-05 15:56:08 UTC (rev 2553)
@@ -81,6 +81,10 @@
createPageAction(QIcon(IMAGE_SERVER),
tr("Sharing"), grp));
+ ui.stackPages->add(new ServicePage(ui.stackPages),
+ createPageAction(QIcon(IMAGE_SERVICE),
+ tr("Services"), grp));
+
ui.stackPages->add(new AppearancePage(ui.stackPages),
createPageAction(QIcon(IMAGE_APPEARANCE),
tr("Appearance"), grp));
@@ -89,9 +93,6 @@
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)),
Modified: vidalia/branches/hidden-services/src/vidalia/config/service.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/service.cpp 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/service.cpp 2008-05-05 15:56:08 UTC (rev 2553)
@@ -16,7 +16,8 @@
/** Constructor to create a new Service with initial settings */
Service::Service(QString serviceAddress, QString virtualPort,
- QString physicalAddressPort, QString serviceDirectory, bool enabled) {
+ QString physicalAddressPort, QString serviceDirectory, bool enabled)
+{
_serviceAddress = serviceAddress;
_virtualPort = virtualPort;
@@ -26,65 +27,86 @@
}
/** Destructor */
-Service::~Service() {
+Service::~Service()
+{
}
/** Sets the deploy status of a service */
-void Service::setEnabled(bool enabled) {
+void Service::setEnabled(bool enabled)
+{
_enabled = enabled;
}
/** Sets the adress of a service */
-void Service::setServiceAddress(QString serviceAddress) {
+void Service::setServiceAddress(QString serviceAddress)
+{
_serviceAddress = serviceAddress;
}
/** Sets the virtualPort of a service */
-void Service::setVirtualPort(QString virtualPort) {
+void Service::setVirtualPort(QString virtualPort)
+{
_virtualPort = virtualPort;
}
/** Sets the physical Adress and the local port of a service */
-void Service::setPhysicalAddressPort(QString physicalAddressPort) {
+void Service::setPhysicalAddressPort(QString physicalAddressPort)
+{
_physicalAddressPort = physicalAddressPort;
}
/** Sets the service directory of a service */
-void Service::setServiceDirectory(QString serviceDirectory) {
+void Service::setServiceDirectory(QString serviceDirectory)
+{
_serviceDirectory = serviceDirectory;
}
/** Sets the additional options of a service e.g. excludeNodes */
-void Service::setAdditionalServiceOptions(QString options) {
+void Service::setAdditionalServiceOptions(QString options)
+{
_additionalServiceOptions = options;
}
+void Service::addUser(User user)
+{
+ _users.push_back(user);
+}
+
+void Service::setUsers(QList<User> users)
+{
+ _users = users;
+}
+
/** 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();
+ out << myObj.users();
return out;
}
/** Reads service class data in from the QDataStream <b>in</b> and
populates * the <b>myObj</b> object accordingly. */
-QDataStream&operator>>(QDataStream &in, Service &myObj) {
+QDataStream&operator>>(QDataStream &in, Service &myObj)
+{
QString serviceAddress;
QString virtualPort;
QString physicalAddressPort;
QString serviceDirectory;
bool enabled;
QString additionalServiceOptions;
+ QList<User> users;
/* Read in from the data stream */
in >> serviceAddress >> virtualPort >> physicalAddressPort
- >> serviceDirectory >> enabled >> additionalServiceOptions;
+ >> serviceDirectory >> enabled >> additionalServiceOptions >> users;
/* Set the appropriate class member variables */
myObj.setServiceAddress(serviceAddress);
@@ -93,8 +115,24 @@
myObj.setServiceDirectory(serviceDirectory);
myObj.setEnabled(enabled);
myObj.setAdditionalServiceOptions(additionalServiceOptions);
-
+ myObj.setUsers(users);
+
/* Return the updated data stream */
return in;
}
+/** Creates a string by concatenating the values of the service. */
+//TODO noch anpassen einzelne user ausgeben!
+QString
+Service::toString()
+{
+ QString s;
+ s.append(_serviceAddress +"#"+ _virtualPort +"#"+ _physicalAddressPort +
+ "#"+ _serviceDirectory +"#"+ _enabled + "#"+ _additionalServiceOptions +
+ "#");
+ foreach(User user, _users)
+ {
+ s.append(user.toString());
+ }
+ return s;
+}
Modified: vidalia/branches/hidden-services/src/vidalia/config/service.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/service.h 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/service.h 2008-05-05 15:56:08 UTC (rev 2553)
@@ -11,6 +11,7 @@
#ifndef SERVICE_H_
#define SERVICE_H_
+#include <user.h>
#include <QString>
#include <QList>
#include <QMetaType>
@@ -39,6 +40,8 @@
/** Returns the additional options of a service e.g. excludeNodes */
QString additionalServiceOptions() const
{ return _additionalServiceOptions; }
+ /** Returns the list of users associated to the service */
+ QList<User> users() const { return _users; }
/** Sets the adress of a service */
void setServiceAddress(QString serviceAddress);
/** Sets the listening port of a service */
@@ -51,19 +54,25 @@
void setEnabled(bool enabled);
/** Sets the additional options of a service e.g. excludeNodes */
void setAdditionalServiceOptions(QString options);
+ /** Adds the given user to the list of users associated to the service */
+ void addUser(User user);
+ /** Sets the list of users as the associated users to the service */
+ void setUsers(QList<User> users);
/** 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);
+ /** this method creates a string by concatenating the values of the service */
+ QString toString();
private:
/** The adress of the service */
QString _serviceAddress;
/** The listening Port of the service */
QString _virtualPort;
- /** The physical Adress and the local port of teh service */
+ /** The physical Adress and the local port of the service */
QString _physicalAddressPort;
/** the directory of the service */
QString _serviceDirectory;
@@ -71,6 +80,8 @@
bool _enabled;
/** Some additional service options, not configured/displayed by Vidalia */
QString _additionalServiceOptions;
+ /** The list of users associated to the service */
+ QList<User> _users;
};
Q_DECLARE_METATYPE(Service);
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicelist.cpp 2008-05-05 15:56:08 UTC (rev 2553)
@@ -11,33 +11,39 @@
#include "servicelist.h"
/** Default constructor. */
-ServiceList::ServiceList() {
+ServiceList::ServiceList()
+{
}
/** Constructor to create a new Servicelist with initial settings */
-void ServiceList::addService(Service service) {
+void ServiceList::addService(Service service)
+{
_services.append(service);
}
/** Destructor */
-ServiceList::~ServiceList() {
+ServiceList::~ServiceList()
+{
}
/* Sets the serviceList */
-void ServiceList::setServices(QList<Service> services) {
+void ServiceList::setServices(QList<Service> services)
+{
_services = services;
}
/** Writes ServiceList class data from <b>myObj</b> to the QDataStream
* <b>out</b>. */
-QDataStream&operator<<(QDataStream &out, const ServiceList &myObj) {
+QDataStream&operator<<(QDataStream &out, const ServiceList &myObj)
+{
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) {
+QDataStream&operator>>(QDataStream &in, ServiceList &myObj)
+{
QList<Service> services;
/* Read in from the data stream */
in >> services;
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp 2008-05-05 15:56:08 UTC (rev 2553)
@@ -8,7 +8,7 @@
** terms described in the LICENSE file.
*/
-#include <util/stringutil.h>
+#include <stringutil.h>
#include <vmessagebox.h>
#include <qheaderview.h>
#include <qclipboard.h>
@@ -17,11 +17,14 @@
#include <file.h>
#include "configdialog.h"
#include "ipvalidator.h"
+#include "user.h"
#include "service.h"
#include "servicelist.h"
#include "domainvalidator.h"
#include "ipvalidator.h"
+//TODO aufpassen das keine '#' im comment sein dürfen und auch nicht in der authdata!
+
/** Constructor */
ServicePage::ServicePage(QWidget *parent)
: ConfigPage(parent, tr("Services"))
@@ -48,15 +51,35 @@
ui.serviceWidget->horizontalHeader()->resizeSection(3, 120);
ui.serviceWidget->horizontalHeader()->resizeSection(4, 60);
ui.serviceWidget->verticalHeader()->hide();
+ ui.serviceAuthWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
+ ui.serviceAuthWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Custom);
+ ui.serviceAuthWidget->horizontalHeader()->resizeSection(1,150);
+ ui.serviceAuthWidget->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.addServiceBtn, SIGNAL(clicked()), this, SLOT(addService()));
+ connect(ui.removeServiceBtn, SIGNAL(clicked()), this, SLOT(removeService()));
+ connect(ui.copyServiceBtn, SIGNAL(clicked()), this, SLOT(copyToClipboard()));
+ connect(ui.browseServiceBtn, 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.restrictAccessCheckBox, SIGNAL(stateChanged(int)), this,
+ SLOT(clientAuthChecked(int)));
+ connect(ui.addClientAuthBtn, SIGNAL(clicked()), this,
+ SLOT(addClientAuthBtnClicked()));
+ connect(ui.removeClientAuthBtn, SIGNAL(clicked()), this,
+ SLOT(removeClientAuthBtnClicked()));
+ connect(ui.copyClientAuthBtn, SIGNAL(clicked()), this,
+ SLOT(copyClientAuthBtnClicked()));
+ connect(ui.addServiceAuthBtn, SIGNAL(clicked()), this,
+ SLOT(addServiceAuthBtnClicked()));
+ connect(ui.removeServiceAuthBtn, SIGNAL(clicked()), this,
+ SLOT(removeServiceAuthBtnClicked()));
+ connect(ui.copyServiceAuthBtn, SIGNAL(clicked()), this,
+ SLOT(copyServiceAuthBtnClicked()));
+ connect(ui.serviceAuthWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this,
+ SLOT(authValueChanged()));
}
/** Destructor */
@@ -78,10 +101,12 @@
QString physicalAddress = ui.serviceWidget->item(index,2)->text();
QString directoryPath = ui.serviceWidget->item(index,3)->text();
bool enabled = _services->value(index).enabled();
+ QList<User> users = _services->value(index).users();
Service temp(address, virtualPort, physicalAddress, directoryPath,
enabled);
temp.setAdditionalServiceOptions(_services->value(ui.serviceWidget->
currentRow()).additionalServiceOptions());
+ temp.setUsers(users);
serviceList.push_back(temp);
if(enabled) {
publishedServices.push_back(temp);
@@ -147,16 +172,30 @@
temp.physicalAddressPort())));
serviceConfString.append(" "+ temp.additionalServiceOptions());
}
- _serviceSettings->apply(serviceConfString, &errmsg);
+ _serviceSettings->applyServices(serviceConfString, &errmsg);
}
+void
+ServicePage::clientAuthChecked(int state)
+{
+ if(state == Qt::Checked)
+ {
+ ui.authClientsGroupBox->setVisible(true);
+ } else {
+ ui.authClientsGroupBox->setVisible(false);
+ }
+}
+
/** Loads previously saved settings */
void
ServicePage::load()
{
- ui.removeButton->setEnabled(false);
- ui.copyButton->setEnabled(false);
- ui.browseButton->setEnabled(false);
+ ui.removeServiceBtn->setEnabled(false);
+ ui.copyServiceBtn->setEnabled(false);
+ ui.browseServiceBtn->setEnabled(false);
+ ui.authClientsGroupBox->setVisible(false);
+ ui.restrictAccessCheckBox->setCheckState(Qt::Unchecked);
+ ui.restrictAccessCheckBox->setEnabled(false);
// get all services
_services = new QMap<int, Service>();
_torServices = new QMap<QString, Service>();
@@ -310,6 +349,10 @@
for(int i = 0; i < rows; i++) {
ui.serviceWidget->removeRow(0);
}
+ int rows2 = ui.serviceAuthWidget->rowCount();
+ for(int i = 0; i < rows2; i++) {
+ ui.serviceAuthWidget->removeRow(0);
+ }
//for each service
int index = 0;
while(index < _services->size()) {
@@ -423,7 +466,6 @@
VMessageBox::Ok);
return;
} else {
- QString onionAddress = ui.serviceWidget->item(selrow,0)->text();
QClipboard *clipboard = QApplication::clipboard();
QString clipboardText;
QTableWidgetItem* selectedItem = ui.serviceWidget->item(selrow,0);
@@ -463,13 +505,23 @@
{
bool emptyTable = false;
if(ui.serviceWidget->rowCount() > 0) {
- ui.removeButton->setEnabled(true);
- ui.copyButton->setEnabled(true);
- ui.browseButton->setEnabled(true);
+ ui.removeServiceBtn->setEnabled(true);
+ ui.copyServiceBtn->setEnabled(true);
+ ui.browseServiceBtn->setEnabled(true);
+ ui.restrictAccessCheckBox->setEnabled(true);
+ //TODO erst prüfen ob gechecket ist!
+ ui.addServiceAuthBtn->setEnabled(true);
+ ui.removeServiceAuthBtn->setEnabled(true);
+ ui.copyServiceAuthBtn->setEnabled(true);
} else {
- ui.removeButton->setEnabled(false);
- ui.copyButton->setEnabled(false);
- ui.browseButton->setEnabled(false);
+ ui.removeServiceBtn->setEnabled(false);
+ ui.copyServiceBtn->setEnabled(false);
+ ui.browseServiceBtn->setEnabled(false);
+ ui.restrictAccessCheckBox->setEnabled(false);
+ //TODO
+ ui.addServiceAuthBtn->setEnabled(false);
+ ui.removeServiceAuthBtn->setEnabled(false);
+ ui.copyServiceAuthBtn->setEnabled(false);
emptyTable = true;
}
int currentRow = ui.serviceWidget->currentRow();
@@ -477,9 +529,30 @@
QTableWidgetItem* item = ui.serviceWidget->item(currentRow, 0);
if(item != NULL) {
bool b = item->text().contains(".onion");
- ui.copyButton->setEnabled(b);
+ ui.copyServiceBtn->setEnabled(b);
}
}
+ // clean the user authorization widget
+ int rows = ui.serviceAuthWidget->rowCount();
+ for(int i = 0; i < rows; i++) {
+ ui.serviceAuthWidget->removeRow(0);
+ }
+ // show the users with user authorization for the service
+ Service selService = _services->take(ui.serviceWidget->currentRow());
+ QList<User> assoziatedUsers = selService.users();
+ int rowcount = 0;
+ QListIterator<User> it(assoziatedUsers);
+ while(it.hasNext()) {
+ User tempUser = it.next();
+ ui.serviceAuthWidget->insertRow(rowcount);
+ QTableWidgetItem* authdataItem = new QTableWidgetItem(tempUser.authdata());
+ authdataItem->setFlags(Qt::ItemIsSelectable);
+ QTableWidgetItem* commentItem = new QTableWidgetItem(tempUser.comment());
+ ui.serviceAuthWidget->setItem(rowcount, 0, authdataItem);
+ ui.serviceAuthWidget->setItem(rowcount, 1, commentItem);
+ rowcount++;
+ }
+ _services->insert(ui.serviceWidget->currentRow(), selService);
QTableWidgetItem* item = ui.serviceWidget->item(ui.serviceWidget->
currentRow(), 3);
QString selDir = _services->value(ui.serviceWidget->currentRow()).
@@ -490,7 +563,7 @@
while(it.hasNext()) {
QString temp = it.next();
if(selDir.compare(temp) == 0) {
- ui.browseButton->setEnabled(false);
+ ui.browseServiceBtn->setEnabled(false);
break;
}
}
@@ -597,3 +670,82 @@
}
}
+void
+ServicePage::addClientAuthBtnClicked()
+{
+ QString comment = ui.privateCommentLineProvider->text();
+ if(comment.length() > 0)
+ {
+ QTableWidgetItem *commentItem = new QTableWidgetItem();
+ QTableWidgetItem *addressItem = new QTableWidgetItem();
+ addressItem->setFlags(Qt::ItemIsSelectable);
+ commentItem->setText(comment);
+ addressItem->setText("[Created by Tor]");
+ int rows = ui.serviceAuthWidget->rowCount();
+ ui.serviceAuthWidget->insertRow(rows);
+ ui.serviceAuthWidget->setItem(rows, 0, addressItem);
+ ui.serviceAuthWidget->setItem(rows, 1, commentItem);
+ ui.privateCommentLineProvider->clear();
+ User u(comment, "[Created by Tor]");
+ Service s = _services->take(ui.serviceWidget->currentRow());
+ s.addUser(u);
+ _services->insert(ui.serviceWidget->currentRow(), s);
+ } else {
+ VMessageBox::warning(this, tr("Error"),
+ tr("Please choose a comment for the user, e.g. a name."),
+ VMessageBox::Ok);
+ }
+}
+
+void
+ServicePage::removeClientAuthBtnClicked()
+{
+ int rows = ui.serviceAuthWidget->rowCount();
+ int selrow = ui.serviceAuthWidget->currentRow();
+ if(selrow < 0 || selrow >= rows) {
+ VMessageBox::warning(this, tr("Error"), tr("Please select a user."),
+ VMessageBox::Ok);
+ return;
+ } else {
+ ui.serviceAuthWidget->removeRow(selrow);
+ }
+}
+
+void
+ServicePage::copyClientAuthBtnClicked()
+{
+ int selrow = ui.serviceAuthWidget->currentRow();
+ int rowCount = ui.serviceAuthWidget->rowCount();
+ if(selrow < 0 || selrow >= rowCount) {
+ VMessageBox::warning(this, tr("Error"), tr("Please select a user."),
+ VMessageBox::Ok);
+ return;
+ } else {
+ QClipboard *clipboard = QApplication::clipboard();
+ QString clipboardText;
+ QTableWidgetItem* selectedItem = ui.serviceAuthWidget->item(selrow,0);
+ clipboardText.append(selectedItem->text());
+ clipboard->setText(clipboardText);
+ }
+}
+
+void
+ServicePage::addServiceAuthBtnClicked()
+{
+}
+
+void
+ServicePage::removeServiceAuthBtnClicked()
+{
+}
+
+void
+ServicePage::copyServiceAuthBtnClicked()
+{
+}
+/** ensure no double comments */
+void
+ServicePage::authValueChanged()
+{
+}
+
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.h 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.h 2008-05-05 15:56:08 UTC (rev 2553)
@@ -24,7 +24,6 @@
Q_OBJECT
public:
-
/** Default Constructor */
ServicePage(QWidget *parent = 0);
/** Default Destructor */
@@ -37,45 +36,51 @@
void initServiceTable(QMap<int, Service>* _services);
private slots:
-
- /** this method is called whenefer the user clicks on the 'add' Button*/
+ /** Called whenever the user clicks on the 'add' button. */
void addService();
- /** this method is called whenefer the user clicks on the 'remove' Button*/
+ /** Called whenever the user clicks on the 'remove' button. */
void removeService();
- /** this method is called whenefer the user clicks on the 'copy' Button*/
+ /** Called whenever the user clicks on the 'copy' button. */
void copyToClipboard();
- /** this method is called whenefer the user clicks on the 'browse' Button*/
+ /** Called whenever the user clicks on the 'browse' button. */
void browseDirectory();
- /** this method is called whenefer the selects a different service*/
+ /** Called whenever the user selects a different service. */
void serviceSelectionChanged();
- /** this method returns a list of services by parsing the configuration
- * string given by the tor controller */
+ /** 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 */
+ /** Returns a Service by parsing the configuration string from Tor and
+ * storing its values into the Service object. */
Service generateService(QString serviceString);
- /** this method checks either a service is published or not */
+ /** Starts all services in <b>services</b>, with Tor. */
void startServicesInTor(QList<Service> services);
- /** this method checks either a service is published or not */
+ /** Returns true if <b>service</b> is published. */
bool isServicePublished(Service service, QList<Service> torServices);
- /** this method checks if either all services have minimal
- * configuration or not */
+ /** Returns true if all services have the required minimal configuration. */
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 */
+ /** Called when the user finished editing a cell and checks that only valid
+ * values are set. */
void valueChanged();
+ /** Called when the user checks the box for restricted access to hidden service*/
+ void clientAuthChecked(int state);
+ void addClientAuthBtnClicked();
+ void removeClientAuthBtnClicked();
+ void copyClientAuthBtnClicked();
+ void addServiceAuthBtnClicked();
+ void removeServiceAuthBtnClicked();
+ void copyServiceAuthBtnClicked();
+ void authValueChanged();
private:
-
/** A TorControl object used to talk to Tor. */
TorControl* _torControl;
/** A TorSettings object used for saving/loading the Tor settings */
TorSettings *_torSettings;
/** A ServiceSettings object used to load/save the services. */
ServiceSettings* _serviceSettings;
- /* A QMap, mapping from QString servicename to the Entity service */
+ /** A QMap, mapping from the row number in the table to the service Entity */
QMap<int, Service>* _services;
- /* A QList, consisting of all running services before vidalia starts*/
+ /** A QList, consisting of all running services before vidalia starts */
QMap<QString, Service>* _torServices;
/** Qt Designer generated object */
Ui::ServicePage ui;
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui 2008-05-05 15:56:08 UTC (rev 2553)
@@ -5,162 +5,583 @@
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
- <height>400</height>
+ <width>653</width>
+ <height>519</height>
</rect>
</property>
- <property name="minimumSize" >
- <size>
- <width>600</width>
- <height>400</height>
- </size>
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
+ <property name="contextMenuPolicy" >
+ <enum>Qt::NoContextMenu</enum>
+ </property>
<property name="windowTitle" >
- <string>Form</string>
+ <string/>
</property>
+ <property name="windowIcon" >
+ <iconset>../../../../../.designer/backup</iconset>
+ </property>
<layout class="QVBoxLayout" >
<item>
- <widget class="QGroupBox" name="groupBox" >
+ <widget class="QTabWidget" name="tabWidget" >
<property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="title" >
- <string>Provided Hidden Services</string>
+ <property name="currentIndex" >
+ <number>1</number>
</property>
- <layout class="QGridLayout" >
- <item rowspan="5" row="0" column="0" >
- <widget class="QTableWidget" name="serviceWidget" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="selectionMode" >
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior" >
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <property name="textElideMode" >
- <enum>Qt::ElideLeft</enum>
- </property>
- <property name="showGrid" >
- <bool>true</bool>
- </property>
- <column>
- <property name="text" >
- <string>Onion Address</string>
+ <widget class="QWidget" name="tab_3" >
+ <attribute name="title" >
+ <string>Provide Hidden Services</string>
+ </attribute>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- </column>
- <column>
- <property name="text" >
- <string>Virtual Port</string>
+ <property name="minimumSize" >
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
</property>
- </column>
- <column>
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>Service List</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item rowspan="5" row="0" column="0" >
+ <widget class="QTableWidget" name="serviceWidget" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="baseSize" >
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="selectionMode" >
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ <property name="selectionBehavior" >
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="textElideMode" >
+ <enum>Qt::ElideLeft</enum>
+ </property>
+ <property name="showGrid" >
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Onion Address</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Virtual Port</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Target</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Directory Path</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Enabled</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QToolButton" name="addServiceBtn" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Add new service to list</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-add.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QToolButton" name="removeServiceBtn" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Remove selected service from list</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-remove.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QToolButton" name="copyServiceBtn" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Copy onion address of selected service to clipboard</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <widget class="QToolButton" name="browseServiceBtn" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Browse in local file system and choose directory for selected service</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/folder.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>26</width>
+ <height>70</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="restrictAccessCheckBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Check to configure user authorization for a service</string>
+ </property>
<property name="text" >
- <string>Target</string>
+ <string>Restrict Access to Authorized Clients only</string>
</property>
- </column>
- <column>
+ <property name="checked" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="authClientsGroupBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="baseSize" >
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="title" >
+ <string>Authorized Clients</string>
+ </property>
+ <layout class="QVBoxLayout" >
+ <item>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Add client with (private only) comment:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="privateCommentLineProvider" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <item rowspan="4" row="0" column="0" >
+ <widget class="QTableWidget" name="serviceAuthWidget" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="selectionMode" >
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ <property name="selectionBehavior" >
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="textElideMode" >
+ <enum>Qt::ElideLeft</enum>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Client Authorization String</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Comment</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QToolButton" name="addClientAuthBtn" >
+ <property name="toolTip" >
+ <string>Add a new user with authorization to the selected service</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-add.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QToolButton" name="removeClientAuthBtn" >
+ <property name="toolTip" >
+ <string>Remove the selected user and his authorization data from the selected service</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-remove.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QToolButton" name="copyClientAuthBtn" >
+ <property name="toolTip" >
+ <string>Copy authorization data to clipboard</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_4" >
+ <attribute name="title" >
+ <string>Access Hidden Services</string>
+ </attribute>
+ <layout class="QVBoxLayout" >
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="lineWidth" >
+ <number>1</number>
+ </property>
<property name="text" >
- <string>Directory Path</string>
+ <string>If you want to access hidden services for which the service provider has restricted acces to authorized users only, you have to enter the Client Authorization String below (plus an optional comment):</string>
</property>
- </column>
- <column>
+ <property name="scaledContents" >
+ <bool>false</bool>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>Add authorization for another hidden service:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLabel" name="label_4" >
+ <property name="text" >
+ <string>Comment</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QLineEdit" name="authLineAccess" />
+ </item>
+ <item row="1" column="1" >
+ <widget class="QLineEdit" name="commentLineAccess" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" >
+ <item rowspan="4" row="0" column="0" >
+ <widget class="QTableWidget" name="tableWidget_2" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <column>
+ <property name="text" >
+ <string>Client Authorization String</string>
+ </property>
+ </column>
+ <column>
+ <property name="text" >
+ <string>Comment</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QToolButton" name="addServiceAuthBtn" >
+ <property name="toolTip" >
+ <string>Add new service with authorization data</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-add.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QToolButton" name="removeServiceAuthBtn" >
+ <property name="toolTip" >
+ <string>Remove selected service and authorization data from list</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-remove.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" >
+ <widget class="QToolButton" name="copyServiceAuthBtn" >
+ <property name="toolTip" >
+ <string>Copy authorization data of selected service to clipboard</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_5" >
+ <property name="lineWidth" >
+ <number>1</number>
+ </property>
<property name="text" >
- <string>Enabled</string>
+ <string>Afterwards you can access the hidden service using the first part of the Client Athorization String, the onion adress.! (Don't forget to save before trying.)</string>
</property>
- </column>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QToolButton" name="addButton" >
- <property name="toolTip" >
- <string>Add new service to list</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-add.png</iconset>
- </property>
- </widget>
- </item>
- <item row="1" column="1" >
- <widget class="QToolButton" name="removeButton" >
- <property name="toolTip" >
- <string>Remove selected service from list</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-remove.png</iconset>
- </property>
- </widget>
- </item>
- <item row="2" column="1" >
- <widget class="QToolButton" name="copyButton" >
- <property name="toolTip" >
- <string>Copy onion address of selected service to clipboard</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
- </property>
- </widget>
- </item>
- <item row="3" column="1" >
- <widget class="QToolButton" name="browseButton" >
- <property name="toolTip" >
- <string>Browse in local file system and choose directory for selected service</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/folder.png</iconset>
- </property>
- </widget>
- </item>
- <item row="4" column="1" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>21</width>
- <height>46</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <property name="scaledContents" >
+ <bool>false</bool>
+ </property>
+ <property name="wordWrap" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>141</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
- <resources/>
- <connections/>
+ <resources>
+ <include location="../res/vidalia_common.qrc" />
+ </resources>
+ <connections>
+ <connection>
+ <sender>restrictAccessCheckBox</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>authClientsGroupBox</receiver>
+ <slot>setVisible(bool)</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>326</x>
+ <y>55</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>326</x>
+ <y>469</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>privateCommentLineProvider</sender>
+ <signal>returnPressed()</signal>
+ <receiver>addClientAuthBtn</receiver>
+ <slot>click()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>434</x>
+ <y>350</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>607</x>
+ <y>383</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>commentLineAccess</sender>
+ <signal>returnPressed()</signal>
+ <receiver>addServiceAuthBtn</receiver>
+ <slot>click()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>480</x>
+ <y>120</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>618</x>
+ <y>153</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
</ui>
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp 2008-05-05 15:56:08 UTC (rev 2553)
@@ -8,13 +8,11 @@
** terms described in the LICENSE file.
*/
+#include <vmessagebox.h>
#include <stringutil.h>
#include "servicesettings.h"
#include "torsettings.h"
-/* Server-related torrc configuration parameters */
-#define SERVER_SERVICE_DIR "ServiceDir"
-
/* Service Settings */
#define SETTING_SERVICE_VIRTUAL_PORT "Service/VirtualPort"
#define SETTING_SERVICE_ADDRESS "Service/ServiceAddress"
@@ -38,17 +36,63 @@
void
ServiceSettings::setServices(ServiceList service)
{
- QVariant v = new QVariant();
- v.setValue(service);
- setValue(SETTING_TOR_SERVICES, v);
+ QStringList serviceList;
+ if(service.services().size() > 0) {
+ QList<Service> services = service.services();
+ foreach (Service tempService, services) {
+ serviceList << tempService.toString();
+ }
+ }
+ setValue(SETTING_TOR_SERVICES, serviceList);
}
/** Get serialised ServiceList */
ServiceList
ServiceSettings::getServices()
{
- QVariant v = value(SETTING_TOR_SERVICES);
- ServiceList services = v.value<ServiceList>();
+ QString address,virtualPort,physAddrPort,serviceDir,enabledS,additionalData;
+ bool enabled = false;
+ QStringList stringList;
+ ServiceList services;
+ QString userString;
+
+ stringList = value(SETTING_TOR_SERVICES).toStringList();
+ foreach (QString s, stringList) {
+ QList<User> users;
+ QStringList skippedList = s.split("#");
+ address = skippedList.first();
+ skippedList.removeFirst();
+ virtualPort = skippedList.first();
+ skippedList.removeFirst();
+ physAddrPort = skippedList.first();
+ skippedList.removeFirst();
+ serviceDir = skippedList.first();
+ skippedList.removeFirst();
+ enabledS = skippedList.first();
+ skippedList.removeFirst();
+ additionalData = skippedList.first();
+ if(enabledS.compare("x1") == 0) {
+ enabled = true;
+ }
+ skippedList.removeFirst();
+ //for each user parse the authorization data
+ foreach(QString user, skippedList)
+ {
+ if(user.contains('*', Qt::CaseSensitive))
+ {
+ QStringList secondsplit = user.split("*");
+ QString comment = secondsplit.first();
+ secondsplit.removeFirst();
+ QString authdata = secondsplit.first();
+ User u(comment, authdata);
+ users.push_back(u);
+ }
+ }
+ Service s(address, virtualPort, physAddrPort, serviceDir, enabled);
+ s.setAdditionalServiceOptions(additionalData);
+ s.setUsers(users);
+ services.addService(s);
+ }
return services;
}
@@ -97,26 +141,20 @@
setValue(SETTING_SERVICE_PHYSICAL_ADDRESS, addr);
}
+/** Returns if the Service is enabled */
bool
ServiceSettings::isEnabled()
{
return value(SETTING_SERVICE_ENABLED).toBool();
}
+/** Set the service enabled */
void
ServiceSettings::setEnabled(bool 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);
-}
-
/** Get all service directories from Tor */
QString
ServiceSettings::getHiddenServiceDirectories()
@@ -125,6 +163,8 @@
return value;
}
+/** Set all services the user wants to start and send it to the
+ * Tor Controller*/
void
ServiceSettings::applyServices(QString value, QString *errmsg)
{
Modified: vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h 2008-05-02 20:35:35 UTC (rev 2552)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicesettings.h 2008-05-05 15:56:08 UTC (rev 2553)
@@ -13,10 +13,12 @@
#include <torcontrol.h>
#include <servicelist.h>
+#include <user.h>
#include "vidaliasettings.h"
#include "exitpolicy.h"
-class ServiceSettings : private VidaliaSettings {
+class ServiceSettings : private VidaliaSettings
+{
public:
@@ -42,12 +44,10 @@
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 */
+ /** 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);
Added: vidalia/branches/hidden-services/src/vidalia/config/user.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/user.cpp (rev 0)
+++ vidalia/branches/hidden-services/src/vidalia/config/user.cpp 2008-05-05 15:56:08 UTC (rev 2553)
@@ -0,0 +1,69 @@
+/*
+** 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 "user.h"
+
+/** Default constructor. */
+User::User()
+{
+}
+
+/** Constructor to create a new User with initial settings */
+User::User(QString comment, QString authdata)
+{
+ _comment = comment;
+ _authdata = authdata;
+}
+
+/** Destructor */
+User::~User()
+{
+}
+
+/* Sets the comment */
+void User::setComment(QString comment)
+{
+ _comment = comment;
+}
+
+/** Sets the authorization data */
+void User::setAuthdata(QString authdata)
+{
+ _authdata = authdata;
+}
+
+/** Writes User class data from <b>myObj</b> to the QDataStream
+ * <b>out</b>. */
+QDataStream&operator<<(QDataStream &out, const User &myObj)
+{
+ out << myObj.comment() << myObj.authdata();
+ return out;
+}
+
+/** Reads User class data in from the QDataStream <b>in</b> and
+ populates * the <b>myObj</b> object accordingly. */
+QDataStream&operator>>(QDataStream &in, User &myObj)
+{
+ QString comment;
+ QString authdata;
+ /* Read in from the data stream */
+ in >> comment >> authdata;
+ /* Set the appropriate class member variables */
+ myObj.setComment(comment);
+ myObj.setAuthdata(authdata);
+ /* Return the updated data stream */
+ return in;
+}
+
+QString User::toString()
+{
+ return _comment.append("*").append(_authdata).append("#");
+}
+
Added: vidalia/branches/hidden-services/src/vidalia/config/user.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/user.h (rev 0)
+++ vidalia/branches/hidden-services/src/vidalia/config/user.h 2008-05-05 15:56:08 UTC (rev 2553)
@@ -0,0 +1,53 @@
+/*
+** 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 USER_H_
+#define USER_H_
+
+#include <QString>
+#include <QMetaType>
+
+class User
+{
+public:
+
+ /** Default constructor. */
+ User();
+ /** Constructor to create a new Service with initial settings */
+ User(QString comment, QString authdata);
+ /** Destructor */
+ virtual ~User();
+ /** Returns the comment of a specific user */
+ QString comment() const { return _comment; }
+ /** Sets a comment of a specific user */
+ void setComment(QString comment);
+ /** Sets the authorization data of a specific user */
+ void setAuthdata(QString authdata);
+ /** Returns the authorization data of a specific user */
+ QString authdata() const { return _authdata; }
+ /** Writes service class data from <b>myObj</b> to the QDataStream
+ * <b>out</b>. */
+ friend QDataStream& operator<<(QDataStream &out, const User &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, User &myObj);
+ /** this method creates a string by concatenating the values of the service */
+ QString toString();
+
+private:
+ /** The comment of a specific user */
+ QString _comment;
+ /** The authorization data of a specific user */
+ QString _authdata;
+
+};
+Q_DECLARE_METATYPE(User);
+#endif /*User_H_*/
+