#include <serversettings.h>
Public Member Functions | |
ServerSettings (TorControl *torControl) | |
void | revert () |
bool | changedSinceLastApply () |
bool | apply (QString *errmsg=0) |
void | setServerEnabled (bool enable) |
bool | isServerEnabled () |
void | setORPort (quint16 orPort) |
quint16 | getORPort () |
void | setDirPort (quint16 dirPort) |
quint16 | getDirPort () |
void | setNickname (QString nickname) |
QString | getNickname () |
void | setContactInfo (QString info) |
QString | getContactInfo () |
void | setDirectoryMirror (bool mirror) |
bool | isDirectoryMirror () |
void | setExitPolicy (ExitPolicy &policy) |
ExitPolicy | getExitPolicy () |
void | setBandwidthAvgRate (quint32 rate) |
quint32 | getBandwidthAvgRate () |
void | setBandwidthBurstRate (quint32 rate) |
quint32 | getBandwidthBurstRate () |
Private Member Functions | |
void | setChanged (bool changed) |
QHash< QString, QString > | confValues () |
QMap< QString, QVariant > | allSettings () |
bool | isEmptyValue (QVariant value) |
QVariant | value (QString key) |
void | setValue (QString key, QVariant value) |
Private Attributes | |
TorControl * | _torControl |
QMap< QString, QVariant > | _backupSettings |
Definition at line 37 of file serversettings.h.
ServerSettings::ServerSettings | ( | TorControl * | torControl | ) |
Constructor
Constructor.
torControl | a TorControl object used to read and apply the server configuration settings. |
Definition at line 71 of file serversettings.cpp.
References _backupSettings, _torControl, allSettings(), ExitPolicy::Default, VidaliaSettings::setDefault(), SETTING_SERVER_BWBURST, SETTING_SERVER_BWRATE, SETTING_SERVER_CHANGED, SETTING_SERVER_CONTACT, SETTING_SERVER_DIRMIRROR, SETTING_SERVER_DIRPORT, SETTING_SERVER_ENABLED, SETTING_SERVER_EXITPOLICY, SETTING_SERVER_NICKNAME, and SETTING_SERVER_ORPORT.
void ServerSettings::revert | ( | ) |
Reverts all settings changes since the last apply.
Restores the server configuration back to its state after the last call to apply().
Definition at line 113 of file serversettings.cpp.
References _backupSettings, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::changedSinceLastApply | ( | ) |
Returns true if the settings have changed since the last apply.
Returns a boolean value indicating if the server's configuration has changed since it was last applied.
Definition at line 103 of file serversettings.cpp.
References SETTING_SERVER_CHANGED, and VidaliaSettings::value().
Referenced by MainWindow::authenticated(), isServerEnabled(), and ServerPage::save().
bool ServerSettings::apply | ( | QString * | errmsg = 0 |
) |
Applies changese to Tor.
Applies the current server configuration settings to Tor and tells Tor to write the new configuration to disk.
errmsg | If specified, will store an error message should something go wrong. |
Definition at line 256 of file serversettings.cpp.
References _backupSettings, _torControl, allSettings(), confValues(), TorControl::getTorVersion(), isServerEnabled(), TorControl::resetConf(), TorControl::saveConf(), SERVER_BANDWIDTH_BURST, SERVER_BANDWIDTH_RATE, SERVER_CONTACTINFO, SERVER_DIRPORT, SERVER_EXITPOLICY, SERVER_NICKNAME, SERVER_ORPORT, SERVER_RELAY_BANDWIDTH_BURST, SERVER_RELAY_BANDWIDTH_RATE, setChanged(), and TorControl::setConf().
Referenced by MainWindow::authenticated(), and ServerPage::save().
void ServerSettings::setServerEnabled | ( | bool | enable | ) |
Enables running Tor as a server.
Enables or disables running Tor as a server.
enable | Whether to enable or disable the Tor server. |
Definition at line 291 of file serversettings.cpp.
References SETTING_SERVER_ENABLED, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::isServerEnabled | ( | ) |
Returns true if Tor is running as a server.
Returns true if Tor is currently configured to run as a Tor server. If Tor was started with a specific torrc, we will ask Tor whether that torrc told it to be a server. Otherwise, we use our local settings.
Definition at line 300 of file serversettings.cpp.
References _torControl, changedSinceLastApply(), confValues(), TorControl::getConf(), TorControl::isConnected(), SERVER_NICKNAME, SERVER_ORPORT, SETTING_SERVER_ENABLED, and VidaliaSettings::value().
Referenced by apply(), MainWindow::close(), confValues(), ServerPage::load(), and MainWindow::stop().
void ServerSettings::setORPort | ( | quint16 | orPort | ) |
Sets the server's ORPort value.
Sets the server's ORPort.
Definition at line 317 of file serversettings.cpp.
References SETTING_SERVER_ORPORT, and setValue().
Referenced by ServerPage::save().
quint16 ServerSettings::getORPort | ( | ) |
Gets the server's ORPort value.
Gets the server's current ORPort setting.
Definition at line 324 of file serversettings.cpp.
References SETTING_SERVER_ORPORT, and value().
Referenced by ServerPage::load().
void ServerSettings::setDirPort | ( | quint16 | dirPort | ) |
Sets the server's DirPort value.
Sets the server's current DirPort.
Definition at line 331 of file serversettings.cpp.
References SETTING_SERVER_DIRPORT, and setValue().
Referenced by ServerPage::save().
quint16 ServerSettings::getDirPort | ( | ) |
Gets the server's DirPort value.
Gets the server's current DirPort.
Definition at line 338 of file serversettings.cpp.
References SETTING_SERVER_DIRPORT, and value().
Referenced by ServerPage::load().
void ServerSettings::setNickname | ( | QString | nickname | ) |
Sets the server's nickname.
Definition at line 345 of file serversettings.cpp.
References SETTING_SERVER_NICKNAME, and setValue().
Referenced by ServerPage::save().
QString ServerSettings::getNickname | ( | ) |
Gets the server's nickname.
Definition at line 352 of file serversettings.cpp.
References ensure_valid_chars(), MAX_NICKNAME_LEN, SETTING_SERVER_NICKNAME, VALID_NICKNAME_CHARS, and value().
Referenced by ServerPage::load().
void ServerSettings::setContactInfo | ( | QString | contact | ) |
Sets the server operator's contact information.
Sets the server's contact information.
Definition at line 362 of file serversettings.cpp.
References SETTING_SERVER_CONTACT, and setValue().
Referenced by ServerPage::save().
QString ServerSettings::getContactInfo | ( | ) |
Gets the server operator's contact information.
Gets the server's contact information.
Definition at line 369 of file serversettings.cpp.
References SETTING_SERVER_CONTACT, and value().
Referenced by ServerPage::load().
void ServerSettings::setDirectoryMirror | ( | bool | mirror | ) |
Enables or disables the server to act as a directory mirror.
Sets whether this server will act as a directory mirror.
Definition at line 383 of file serversettings.cpp.
References SETTING_SERVER_DIRMIRROR, and setValue().
Referenced by ServerPage::save().
bool ServerSettings::isDirectoryMirror | ( | ) |
Returns true if the server will mirror the directory.
Returns whether this server will act as a directory mirror or not.
Definition at line 376 of file serversettings.cpp.
References SETTING_SERVER_DIRMIRROR, and VidaliaSettings::value().
Referenced by confValues(), and ServerPage::load().
void ServerSettings::setExitPolicy | ( | ExitPolicy & | exitPolicy | ) |
Sets the exit policy for this server.
Definition at line 397 of file serversettings.cpp.
References SETTING_SERVER_EXITPOLICY, setValue(), and ExitPolicy::toString().
Referenced by ServerPage::saveExitPolicies().
ExitPolicy ServerSettings::getExitPolicy | ( | ) |
Gets the exit policy for this server.
Returns the exit policy for this server.
Definition at line 390 of file serversettings.cpp.
References SETTING_SERVER_EXITPOLICY, and value().
Referenced by ServerPage::loadExitPolicies().
void ServerSettings::setBandwidthAvgRate | ( | quint32 | rate | ) |
Sets the long-term average bandwidth rate (in KB/s) of this server.
Sets the long-term average bandwidth rate (in KB/s) for this server.
Definition at line 411 of file serversettings.cpp.
References SETTING_SERVER_BWRATE, and setValue().
Referenced by ServerPage::saveBandwidthLimits().
quint32 ServerSettings::getBandwidthAvgRate | ( | ) |
Gets the long-term average bandwidth rate (in KB/s) of this server.
Returns the long-term average bandwidth rate (in KB/s) for this server.
Definition at line 404 of file serversettings.cpp.
References SETTING_SERVER_BWRATE, and value().
Referenced by ServerPage::loadBandwidthLimits().
void ServerSettings::setBandwidthBurstRate | ( | quint32 | rate | ) |
Sets the maximum burst rate (in B/s) of this server.
Sets the maximum bandwidth burst rate (in KB/s) for this server.
Definition at line 425 of file serversettings.cpp.
References SETTING_SERVER_BWBURST, and setValue().
Referenced by ServerPage::saveBandwidthLimits().
quint32 ServerSettings::getBandwidthBurstRate | ( | ) |
Gets the maximum burst rate (in B/s) of this server.
Returns the maximum bandwidth burst rate (in KB/s) for this server.
Definition at line 418 of file serversettings.cpp.
References SETTING_SERVER_BWBURST, and value().
Referenced by ServerPage::loadBandwidthLimits().
void ServerSettings::setChanged | ( | bool | changed | ) | [private] |
Sets a value indicating that the server settings have changed since apply() was last called.
Stores a boolean value indicating if the server's configuration has changed since it was last applied.
changed | Boolean value indicating whether settings have been changed. |
Definition at line 94 of file serversettings.cpp.
References SETTING_SERVER_CHANGED, and VidaliaSettings::setValue().
Referenced by apply(), and setValue().
QHash< QString, QString > ServerSettings::confValues | ( | ) | [private] |
Returns Tor-recognizable configuration keys and current values.
Returns a QHash of Tor-recognizable configuratin keys to their current values.
Definition at line 207 of file serversettings.cpp.
References _torControl, VidaliaSettings::defaultValue(), TorControl::getTorVersion(), isDirectoryMirror(), isServerEnabled(), scrub_email_addr(), SERVER_BANDWIDTH_BURST, SERVER_BANDWIDTH_RATE, SERVER_CONTACTINFO, SERVER_DIRPORT, SERVER_EXITPOLICY, SERVER_NICKNAME, SERVER_ORPORT, SERVER_RELAY_BANDWIDTH_BURST, SERVER_RELAY_BANDWIDTH_RATE, SETTING_SERVER_BWBURST, SETTING_SERVER_BWRATE, SETTING_SERVER_CONTACT, SETTING_SERVER_DIRPORT, SETTING_SERVER_EXITPOLICY, SETTING_SERVER_NICKNAME, SETTING_SERVER_ORPORT, and VidaliaSettings::value().
Referenced by apply(), and isServerEnabled().
QMap< QString, QVariant > ServerSettings::allSettings | ( | ) | [private] |
Returns all currently stored server settings.
Returns a map of all server configuration settings currently stored in Vidalia's settings file.
Definition at line 126 of file serversettings.cpp.
Referenced by apply(), and ServerSettings().
bool ServerSettings::isEmptyValue | ( | QVariant | value | ) | [private] |
Returns true if the specified QVariant contains an empty value.
Returns true if the given QVariant contains an empty value, depending on the data type. For example, 0 is considered an empty integer and "" is an empty string.
Definition at line 141 of file serversettings.cpp.
Referenced by value().
QVariant ServerSettings::value | ( | QString | key | ) | [private] |
Retrieves a configuration value. If one isn't found, use a default.
Returns the stored value for the given key. If no stored value exists for the given key, the specified default value is used. If Vidalia is currently connected to Tor, we will ask Tor what its value is. Otherwise, we will retrieve it from Vidalia's stored settings, allowing the configuration information to be edited even if Tor isn't running.
key | Configuration key | |
defaultValue | Value to use if no configuration value exists for the specified key. |
Reimplemented from VidaliaSettings.
Definition at line 166 of file serversettings.cpp.
References _torControl, VidaliaSettings::defaultValue(), TorControl::getConf(), TorControl::getTorVersion(), TorControl::isConnected(), isEmptyValue(), SERVER_BANDWIDTH_BURST, SERVER_BANDWIDTH_RATE, SERVER_RELAY_BANDWIDTH_BURST, SERVER_RELAY_BANDWIDTH_RATE, and VidaliaSettings::value().
Referenced by getBandwidthAvgRate(), getBandwidthBurstRate(), getContactInfo(), getDirPort(), getExitPolicy(), getNickname(), and getORPort().
void ServerSettings::setValue | ( | QString | key, | |
QVariant | value | |||
) | [private] |
Stores a configuration key-value.
Saves the given configuration key-value to the application settings file.
key | Configuration key | |
value | Value to assign to key |
Reimplemented from VidaliaSettings.
Definition at line 196 of file serversettings.cpp.
References setChanged(), VidaliaSettings::setValue(), and VidaliaSettings::value().
Referenced by revert(), setBandwidthAvgRate(), setBandwidthBurstRate(), setContactInfo(), setDirectoryMirror(), setDirPort(), setExitPolicy(), setNickname(), setORPort(), and setServerEnabled().
TorControl* ServerSettings::_torControl [private] |
A TorControl object used to talk to Tor.
Definition at line 114 of file serversettings.h.
Referenced by apply(), confValues(), isServerEnabled(), ServerSettings(), and value().
QMap<QString, QVariant> ServerSettings::_backupSettings [private] |
Values of all stored settings at the last apply() point.
Definition at line 116 of file serversettings.h.
Referenced by apply(), revert(), and ServerSettings().