00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 #ifndef _SERVICEPAGE_H 00012 #define _SERVICEPAGE_H 00013 00014 #include <torcontrol.h> 00015 #include <torsettings.h> 00016 #include <servicesettings.h> 00017 #include <exitpolicy.h> 00018 #include <helpbrowser.h> 00019 #include "configpage.h" 00020 #include "ui_servicepage.h" 00021 00022 class ServicePage : public ConfigPage 00023 { 00024 Q_OBJECT 00025 00026 public: 00027 /** Default Constructor */ 00028 ServicePage(QWidget *parent = 0); 00029 /** Default Destructor */ 00030 ~ServicePage(); 00031 /** Saves the changes on this page */ 00032 bool save(QString &errmsg); 00033 /** Loads the settings for this page */ 00034 void load(); 00035 /** Initialize the service table */ 00036 void initServiceTable(QMap<int, Service>* _services); 00037 00038 private slots: 00039 /** Called whenever the user clicks on the 'add' button. */ 00040 void addService(); 00041 /** Called whenever the user clicks on the 'remove' button. */ 00042 void removeService(); 00043 /** Called whenever the user clicks on the 'copy' button. */ 00044 void copyToClipboard(); 00045 /** Called whenever the user clicks on the 'browse' button. */ 00046 void browseDirectory(); 00047 /** Called whenever the user selects a different service. */ 00048 void serviceSelectionChanged(); 00049 /** Returns a list of services by parsing the configuration string given 00050 * by the Tor controller. */ 00051 QList<Service> extractSingleServices(QString conf); 00052 /** Returns a Service by parsing the configuration string from Tor and 00053 * storing its values into the Service object. */ 00054 Service generateService(QString serviceString); 00055 /** Starts all services in <b>services</b>, with Tor. */ 00056 void startServicesInTor(QList<Service> services); 00057 /** Returns true if <b>service</b> is published. */ 00058 bool isServicePublished(Service service, QList<Service> torServices); 00059 /** Returns true if all services have the required minimal configuration. */ 00060 bool checkBeforeSaving(QList<Service> services); 00061 /** Called when the user finished editing a cell and checks that only valid 00062 * values are set. */ 00063 void valueChanged(); 00064 00065 private: 00066 /** A TorControl object used to talk to Tor. */ 00067 TorControl* _torControl; 00068 /** A TorSettings object used for saving/loading the Tor settings */ 00069 TorSettings *_torSettings; 00070 /** A ServiceSettings object used to load/save the services. */ 00071 ServiceSettings* _serviceSettings; 00072 /** A QMap, mapping from the row number in the table to the service Entity */ 00073 QMap<int, Service>* _services; 00074 /** A QList, consisting of all running services before vidalia starts */ 00075 QMap<QString, Service>* _torServices; 00076 /** Qt Designer generated object */ 00077 Ui::ServicePage ui; 00078 }; 00079 00080 #endif 00081