#include <abstracttorsettings.h>
Inheritance diagram for AbstractTorSettings:
Public Member Functions | |
AbstractTorSettings (const QString &group, TorControl *torControl=0) | |
void | setChanged (bool changed) |
virtual bool | changedSinceLastApply () const |
virtual void | revert () |
virtual bool | apply (QString *errmsg)=0 |
Protected Member Functions | |
virtual QVariant | value (const QString &key) const |
virtual QVariant | localValue (const QString &key) const |
virtual QVariant | torValue (const QString &key) const |
virtual void | setValue (const QString &key, const QVariant &value) |
bool | isEmptyValue (const QVariant &value) const |
TorControl * | torControl () const |
Private Attributes | |
TorControl * | _torControl |
QMap< QString, QVariant > | _backupSettings |
Definition at line 24 of file abstracttorsettings.h.
AbstractTorSettings::AbstractTorSettings | ( | const QString & | group, | |
TorControl * | torControl = 0 | |||
) |
Constructor. All settings will be under the heading group and torControl will be used to getconf values from Tor.
Definition at line 26 of file abstracttorsettings.cpp.
References _backupSettings, _torControl, VSettings::allSettings(), VSettings::setDefault(), SETTING_CHANGED, and torControl().
virtual bool AbstractTorSettings::apply | ( | QString * | errmsg | ) | [pure virtual] |
Subclasses must implement this to setconf values to apply them to a running Tor instance.
Implemented in NetworkSettings, ServerSettings, and TorSettings.
bool AbstractTorSettings::changedSinceLastApply | ( | ) | const [virtual] |
Returns true if any settings have changed since the last time apply() was called.
Definition at line 50 of file abstracttorsettings.cpp.
References localValue(), and SETTING_CHANGED.
Referenced by ServerPage::changedSinceLastApply(), AdvancedPage::changedSinceLastApply(), ServerSettings::isServerEnabled(), and value().
bool AbstractTorSettings::isEmptyValue | ( | const QVariant & | value | ) | const [protected] |
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 69 of file abstracttorsettings.cpp.
Referenced by torValue().
QVariant AbstractTorSettings::localValue | ( | const QString & | key | ) | const [protected, virtual] |
Returns the value associated with key saved in the local configuration file.
Definition at line 89 of file abstracttorsettings.cpp.
References VSettings::value().
Referenced by TorSettings::apply(), NetworkSettings::apply(), changedSinceLastApply(), ServerSettings::confValues(), TorSettings::getAuthenticationMethod(), TorSettings::getControlAddress(), TorSettings::getControlPassword(), TorSettings::getExecutable(), NetworkSettings::getFascistFirewall(), TorSettings::getTorrc(), NetworkSettings::getUseHttpProxy(), NetworkSettings::getUseHttpsProxy(), ServerSettings::isDirectoryMirror(), ServerSettings::isServerEnabled(), ServerSettings::isUpnpEnabled(), setValue(), torValue(), TorSettings::useRandomPassword(), and value().
void AbstractTorSettings::revert | ( | ) | [virtual] |
Reverts all settings to their values at the last time apply() was called.
Definition at line 39 of file abstracttorsettings.cpp.
References _backupSettings, and setValue().
Referenced by ServerPage::revert(), NetworkPage::revert(), and AdvancedPage::revert().
void AbstractTorSettings::setChanged | ( | bool | changed | ) |
Sets a value indicating that the server settings have changed since apply() was last called.
Definition at line 58 of file abstracttorsettings.cpp.
References _backupSettings, VSettings::allSettings(), SETTING_CHANGED, and VSettings::setValue().
Referenced by setValue().
void AbstractTorSettings::setValue | ( | const QString & | key, | |
const QVariant & | value | |||
) | [protected, virtual] |
Saves the value val for the setting key to the local settings file.
Reimplemented from VSettings.
Definition at line 124 of file abstracttorsettings.cpp.
References localValue(), setChanged(), and VSettings::setValue().
Referenced by revert(), TorSettings::setAuthenticationMethod(), ServerSettings::setBandwidthAvgRate(), ServerSettings::setBandwidthBurstRate(), ServerSettings::setBridgeEnabled(), NetworkSettings::setBridgeList(), ServerSettings::setContactInfo(), TorSettings::setControlAddress(), TorSettings::setControlPassword(), TorSettings::setControlPort(), TorSettings::setDataDirectory(), ServerSettings::setDirectoryMirror(), ServerSettings::setDirPort(), TorSettings::setExecutable(), ServerSettings::setExitPolicy(), NetworkSettings::setFascistFirewall(), NetworkSettings::setHttpProxy(), NetworkSettings::setHttpProxyAuthenticator(), NetworkSettings::setHttpsProxy(), NetworkSettings::setHttpsProxyAuthenticator(), ServerSettings::setNickname(), ServerSettings::setORPort(), NetworkSettings::setReachablePorts(), ServerSettings::setServerEnabled(), TorSettings::setTorrc(), ServerSettings::setUpnpEnabled(), NetworkSettings::setUseBridges(), NetworkSettings::setUseHttpProxy(), NetworkSettings::setUseHttpsProxy(), and TorSettings::setUseRandomPassword().
TorControl* AbstractTorSettings::torControl | ( | ) | const [inline, protected] |
Returns the TorControl object used for reading settings from or writing settings to Tor, if one was specified. Returns 0 if no TorControl object was given.
Definition at line 70 of file abstracttorsettings.h.
References _torControl.
Referenced by AbstractTorSettings(), TorSettings::apply(), ServerSettings::apply(), NetworkSettings::apply(), ServerSettings::confValues(), TorSettings::getAuthenticationMethod(), TorSettings::getTorrc(), ServerSettings::isServerEnabled(), and ServerSettings::torValue().
QVariant AbstractTorSettings::torValue | ( | const QString & | key | ) | const [protected, virtual] |
Returns the value associated with key by querying TOr via getconf key.
Reimplemented in ServerSettings.
Definition at line 97 of file abstracttorsettings.cpp.
References _torControl, VSettings::defaultValue(), TorControl::getConf(), isEmptyValue(), and localValue().
Referenced by ServerSettings::torValue(), and value().
QVariant AbstractTorSettings::value | ( | const QString & | key | ) | const [protected, virtual] |
If Vidalia is connected to Tor, this returns the value associated with key by calling torValue(). Otherwise, this calls localValue() to get the locally saved value associated with key.
Definition at line 114 of file abstracttorsettings.cpp.
References _torControl, changedSinceLastApply(), TorControl::isConnected(), localValue(), and torValue().
Referenced by ServerSettings::getBandwidthAvgRate(), ServerSettings::getBandwidthBurstRate(), NetworkSettings::getBridgeList(), ServerSettings::getContactInfo(), TorSettings::getControlPort(), TorSettings::getDataDirectory(), ServerSettings::getDirPort(), ServerSettings::getExitPolicy(), NetworkSettings::getHttpProxy(), NetworkSettings::getHttpProxyAuthenticator(), NetworkSettings::getHttpsProxy(), NetworkSettings::getHttpsProxyAuthenticator(), ServerSettings::getNickname(), ServerSettings::getORPort(), NetworkSettings::getReachablePorts(), NetworkSettings::getTunnelDirConns(), NetworkSettings::getUseBridges(), and ServerSettings::isBridgeEnabled().
QMap<QString, QVariant> AbstractTorSettings::_backupSettings [private] |
Collection of settings values at the last time apply() was called.
Definition at line 77 of file abstracttorsettings.h.
Referenced by AbstractTorSettings(), revert(), and setChanged().
TorControl* AbstractTorSettings::_torControl [private] |
TorControl object used for reading settings from or applying settings to Tor.
Definition at line 70 of file abstracttorsettings.h.
Referenced by AbstractTorSettings(), torControl(), torValue(), and value().