Vidalia 0.2.15
|
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.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file ServerPage.h 00013 ** \brief Tor server configuration options 00014 */ 00015 00016 #ifndef _SERVERPAGE_H 00017 #define _SERVERPAGE_H 00018 00019 #include "ui_ServerPage.h" 00020 #include "ConfigPage.h" 00021 #include "TorControl.h" 00022 #include "ServerSettings.h" 00023 #include "ExitPolicy.h" 00024 #include "HelpBrowser.h" 00025 00026 #include <QMessageBox> 00027 #include <QTimer> 00028 00029 00030 class ServerPage : public ConfigPage 00031 { 00032 Q_OBJECT 00033 00034 public: 00035 /** Default Constructor */ 00036 ServerPage(QWidget *parent = 0); 00037 /** Default Destructor */ 00038 ~ServerPage(); 00039 /** Saves the changes on this page */ 00040 bool save(QString &errmsg); 00041 /** Loads the settings for this page */ 00042 void load(); 00043 00044 /** Applies the server configuration settings to Tor. Returns true if the 00045 * settings were applied successfully. Otherwise, <b>errmsg</b> is set and 00046 * false is returned. */ 00047 bool apply(QString &errmsg); 00048 /** Reverts the server configuration settings to their values at the last 00049 * time they were successfully applied to Tor. */ 00050 void revert(); 00051 /** Returns true if the user has changed their server settings since the 00052 * last time they were applied to Tor. */ 00053 bool changedSinceLastApply(); 00054 /** Called when the user changes the UI translation. */ 00055 virtual void retranslateUi(); 00056 00057 private slots: 00058 /** Called when the user toggles any one of the server mode radio buttons 00059 * and hides or displays the server configuration tabs appropriately. */ 00060 void serverModeChanged(bool enabled); 00061 /** Called when the user clicks the bandwidth help button */ 00062 void bandwidthHelp(); 00063 /** Called when the user clicks the exit policy help button */ 00064 void exitPolicyHelp(); 00065 /** Called when the user selects a new value from the rate combo box */ 00066 void rateChanged(int rate); 00067 /** Called when the user edits the max or average bandwidth limits. */ 00068 void customRateChanged(); 00069 /** Called when Vidalia has authenticated to Tor. If the user's Tor is not 00070 * recent enough, this disables the bridge server option and displays a 00071 * warning if the user had previously configured Tor as a bridge. */ 00072 void onAuthenticated(); 00073 /** Called when Vidalia disconnects from Tor. This method reenables the 00074 * bridge server option. */ 00075 void onDisconnected(); 00076 /** Copies the user's bridge relay identity to the clipboard. */ 00077 void copyBridgeIdentity(); 00078 /** Tests automatic port forwarding with UPnP. */ 00079 void testUpnp(); 00080 /** Called when the user clicks the UPnP test dialog's help button. */ 00081 void upnpHelp(); 00082 /** Called when the user clicks on a QLabel containing a hyperlink. */ 00083 void linkActivated(const QString &url); 00084 00085 private: 00086 /** Index values of rate values in the bandwidth limits dropdown box. */ 00087 enum BwRateIndex { 00088 CableDsl256 = 0, /**< Cable/DSL 256 Kbps */ 00089 CableDsl512, /**< Cable/DSL 512 Kbps */ 00090 CableDsl768, /**< Cable/DSL 768 Kbps */ 00091 T1CableDsl1500, /**< T1/Cable/DSL 1.5 Mbps */ 00092 GreaterThan1500, /**< > 1.5 Mbps */ 00093 CustomBwLimits /**< Custom bandwidth limits */ 00094 }; 00095 00096 /** Returns the index of the selected item in lstExitPolicies */ 00097 int selectedIndex(); 00098 00099 /** Saves the server's bandwidth average and burst limits. */ 00100 void saveBandwidthLimits(); 00101 /** Loads the server's bandwidth average and burst limits. */ 00102 void loadBandwidthLimits(); 00103 /** Saves the server's exit policies. */ 00104 void saveExitPolicies(); 00105 /** Loads the server's exit policies. */ 00106 void loadExitPolicies(); 00107 /** Loads the user's bridge relay identity into the appropriate widgets. If 00108 * the user's bridge is not running, then "Not Running" will be 00109 * displayed. Otherwise, either the bridge's "address:port", "fingerprint", 00110 * or "address:port fingerprint" will be displayed, depending on whether 00111 * our GETCONF and GETINFO commands are successful. */ 00112 void loadBridgeIdentity(); 00113 /** Retrieves bridge usage history from Tor, parses and validates it, and 00114 * then displays it in a new dialog. */ 00115 void displayBridgeUsage(); 00116 00117 /** A ServerSettings object used to get and set information about how a 00118 * local Tor server is configured. */ 00119 ServerSettings* _settings; 00120 00121 /** Qt Designer generated object */ 00122 Ui::ServerPage ui; 00123 00124 /** Used to store the dirport value and if the user wants to mirror the 00125 * directory so that they can be emptied when selecting being a bridge and 00126 * re-added when selecting relay */ 00127 QString _tmpDirPort; 00128 bool _tmpMirror; 00129 }; 00130 00131 #endif 00132