serversettings.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /** 
00023  * \file serversettings.h
00024  * \version $Id: serversettings.h 1238 2006-09-25 17:50:57Z edmanm $
00025  * \brief Settings for running a Tor server
00026  */
00027 
00028 #ifndef _SERVERSETTINGS_H
00029 #define _SERVERSETTINGS_H
00030 
00031 #include <control/torcontrol.h>
00032 
00033 #include "vidaliasettings.h"
00034 #include "exitpolicy.h"
00035 
00036 
00037 class ServerSettings : private VidaliaSettings
00038 {
00039 
00040 public:
00041   /** Constructor */
00042   ServerSettings(TorControl *torControl);
00043 
00044   /** Reverts all settings changes since the last apply. */
00045   void revert();
00046   /** Returns true if the settings have changed since the last apply. */
00047   bool changedSinceLastApply();
00048   /** Applies changese to Tor. */
00049   bool apply(QString *errmsg = 0);
00050 
00051   /** Enables running Tor as a server. */
00052   void setServerEnabled(bool enable);
00053   /** Returns true if Tor is running as a server. */
00054   bool isServerEnabled();
00055 
00056   /** Sets the server's ORPort value. */
00057   void setORPort(quint16 orPort);
00058   /** Gets the server's ORPort value. */
00059   quint16 getORPort();
00060 
00061   /** Sets the server's DirPort value. */
00062   void setDirPort(quint16 dirPort);
00063   /** Gets the server's DirPort value. */
00064   quint16 getDirPort();
00065  
00066   /** Sets the server's nickname. */
00067   void setNickname(QString nickname);
00068   /** Gets the server's nickname. */
00069   QString getNickname();
00070   
00071   /** Sets the server's external IP address. */
00072   void setAddress(QString address);
00073   /** Gets the server's external IP address. */
00074   QString getAddress();
00075 
00076   /** Sets the server operator's contact information. */
00077   void setContactInfo(QString info);
00078   /** Gets the server operator's contact information. */
00079   QString getContactInfo();
00080 
00081   /** Enables or disables the server to act as a directory mirror. */
00082   void setDirectoryMirror(bool mirror);
00083   /** Returns true if the server will mirror the directory. */
00084   bool isDirectoryMirror();
00085  
00086   /** Sets whether the server will act as a middleman or not. */
00087   void setMiddleman(bool middleman);
00088   /** Returns true if the server is a middleman server. */
00089   bool isMiddleman();
00090 
00091   /** Sets the exit policy for this server. */
00092   void setExitPolicy(ExitPolicy &policy);
00093   /** Gets the exit policy for this server. */
00094   ExitPolicy getExitPolicy();
00095   
00096   /** Sets the long-term average bandwidth rate (in KB/s) of this server. */
00097   void setBandwidthAvgRate(quint32 rate);
00098   /** Gets the long-term average bandwidth rate (in KB/s) of this server. */
00099   quint32 getBandwidthAvgRate();
00100 
00101   /** Sets the maximum burst rate (in B/s) of this server. */
00102   void setBandwidthBurstRate(quint32 rate);
00103   /** Gets the maximum burst rate (in B/s) of this server. */
00104   quint32 getBandwidthBurstRate();
00105 
00106   /** Sets whether we automatically update the server address or not. */
00107   void setAutoUpdateAddress(bool enabled);
00108   /** Gets whether we automatically update the server address. */
00109   bool getAutoUpdateAddress();
00110 
00111 private:
00112   /** Sets a value indicating that the server settings have changed since
00113    * apply() was last called. */
00114   void setChanged(bool changed);
00115   
00116   /** Returns Tor-recognizable configuration keys and current values. */
00117   QHash<QString,QString> confValues();
00118 
00119   /** Returns all currently stored server settings. */
00120   QMap<QString, QVariant> allSettings();
00121   
00122   /** Returns true if the specified QVariant contains an empty value. */
00123   bool isEmptyValue(QVariant value);
00124   /** Retrieves a configuration value. If one isn't found, use a default. */
00125   QVariant value(QString key);
00126   /** Stores a configuration key-value. */
00127   void setValue(QString key, QVariant value);
00128 
00129   /** A TorControl object used to talk to Tor. */
00130   TorControl* _torControl;
00131   /** Values of all stored settings at the last apply() point. */
00132   QMap<QString, QVariant> _backupSettings;
00133 };
00134 
00135 #endif
00136 

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0