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