[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r2172: Being const-correct as an afterthought seems a neverending b (in trunk: . src/config)



Author: edmanm
Date: 2007-12-04 13:00:18 -0500 (Tue, 04 Dec 2007)
New Revision: 2172

Modified:
   trunk/
   trunk/src/config/abstracttorsettings.cpp
   trunk/src/config/abstracttorsettings.h
   trunk/src/config/torsettings.cpp
   trunk/src/config/torsettings.h
   trunk/src/config/vsettings.cpp
   trunk/src/config/vsettings.h
Log:
 r2220@lysithea:  edmanm | 2007-12-04 13:00:15 -0500
 Being const-correct as an afterthought seems a neverending battle.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r2220] on 0108964c-5b0b-4c9e-969f-e2288315d100

Modified: trunk/src/config/abstracttorsettings.cpp
===================================================================
--- trunk/src/config/abstracttorsettings.cpp	2007-12-04 17:39:46 UTC (rev 2171)
+++ trunk/src/config/abstracttorsettings.cpp	2007-12-04 18:00:18 UTC (rev 2172)
@@ -58,7 +58,7 @@
 /** Returns true if any settings have changed since the last time apply()
  * was called. */
 bool
-AbstractTorSettings::changedSinceLastApply()
+AbstractTorSettings::changedSinceLastApply() const
 {
   return localValue(SETTING_CHANGED).toBool();
 }
@@ -77,7 +77,7 @@
  * the data type. For example, 0 is considered an empty integer and "" is
  * an empty string. */
 bool
-AbstractTorSettings::isEmptyValue(const QVariant &value)
+AbstractTorSettings::isEmptyValue(const QVariant &value) const
 {
   switch (value.type()) {
     case QVariant::String: 
@@ -97,7 +97,7 @@
 /** Returns the value associated with <b>key</b> saved in the local
  * configuration file. */
 QVariant
-AbstractTorSettings::localValue(const QString &key)
+AbstractTorSettings::localValue(const QString &key) const
 {
   return VSettings::value(key);
 }
@@ -105,7 +105,7 @@
 /** Returns the value associated with <b>key</b> by querying TOr via 
  * <i>getconf key</i>. */
 QVariant
-AbstractTorSettings::torValue(const QString &key)
+AbstractTorSettings::torValue(const QString &key) const
 {
   QVariant value;
   QVariant defaultVal;
@@ -123,7 +123,7 @@
  * <b>key</b> by calling torValue(). Otherwise, this calls localValue() to get
  * the locally saved value associated with <b>key</b>. */
 QVariant
-AbstractTorSettings::value(const QString &key)
+AbstractTorSettings::value(const QString &key) const
 {
   if (_torControl && _torControl->isConnected() && !changedSinceLastApply())
     return torValue(key);

Modified: trunk/src/config/abstracttorsettings.h
===================================================================
--- trunk/src/config/abstracttorsettings.h	2007-12-04 17:39:46 UTC (rev 2171)
+++ trunk/src/config/abstracttorsettings.h	2007-12-04 18:00:18 UTC (rev 2172)
@@ -44,7 +44,7 @@
   void setChanged(bool changed);
   /** Returns true if any settings have changed since the last time apply()
    * was called. */
-  virtual bool changedSinceLastApply();
+  virtual bool changedSinceLastApply() const;
   /** Reverts all settings to their values at the last time apply() was
    * called. */
   virtual void revert();
@@ -56,13 +56,13 @@
   /** If Vidalia is connected to Tor, this returns the value associated with
    * <b>key</b> by calling torValue(). Otherwise, this calls localValue()
    * to get the locally saved value associated with <b>key</b>. */
-  virtual QVariant value(const QString &key);
+  virtual QVariant value(const QString &key) const;
   /** Returns the value associated with <b>key</b> saved in the local
    * configuration file. */
-  virtual QVariant localValue(const QString &key);
+  virtual QVariant localValue(const QString &key) const;
   /** Returns the value associated with <b>key</b> by querying TOr via 
    * <i>getconf key</i>. */
-  virtual QVariant torValue(const QString &key);
+  virtual QVariant torValue(const QString &key) const;
   /** Saves the value <b>val</b> for the setting <b>key</b> to the local
    * settings file. */
   virtual void setValue(const QString &key, const QVariant &value);
@@ -70,13 +70,13 @@
   /** 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. */
-  bool isEmptyValue(const QVariant &value);
+  bool isEmptyValue(const QVariant &value) const;
 
 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. */
-  TorControl* torControl() { return _torControl; };
+  TorControl* torControl() const { return _torControl; };
 
 private:
   /** TorControl object used for reading settings from or applying settings to

Modified: trunk/src/config/torsettings.cpp
===================================================================
--- trunk/src/config/torsettings.cpp	2007-12-04 17:39:46 UTC (rev 2171)
+++ trunk/src/config/torsettings.cpp	2007-12-04 18:00:18 UTC (rev 2172)
@@ -124,14 +124,14 @@
 
 /** Gets the location of Tor's data directory. */
 QString
-TorSettings::getDataDirectory()
+TorSettings::getDataDirectory() const
 {
   return QDir::convertSeparators(value(SETTING_DATA_DIRECTORY).toString());
 }
 
 /** Sets the location to use as Tor's data directory. */
 void
-TorSettings::setDataDirectory(QString dataDirectory)
+TorSettings::setDataDirectory(const QString &dataDirectory)
 {
   setValue(SETTING_DATA_DIRECTORY, dataDirectory);
 }
@@ -139,21 +139,21 @@
 /** Returns a fully-qualified path to Tor's executable, including the
  * executable name. */
 QString
-TorSettings::getExecutable()
+TorSettings::getExecutable() const
 {
   return QDir::convertSeparators(localValue(SETTING_TOR_EXECUTABLE).toString());
 }
 
 /** Sets the location and name of Tor's executable to the given string. */
 void
-TorSettings::setExecutable(QString torExecutable)
+TorSettings::setExecutable(const QString &torExecutable)
 {
   setValue(SETTING_TOR_EXECUTABLE, torExecutable);
 }
 
 /** Returns the torrc that will be used when starting Tor. */
 QString
-TorSettings::getTorrc()
+TorSettings::getTorrc() const
 {
   QString torrc;
   TorControl *tc = torControl();
@@ -166,7 +166,7 @@
  * \param torrc The torrc to use. 
  */
 void
-TorSettings::setTorrc(QString torrc)
+TorSettings::setTorrc(const QString &torrc)
 {
   setValue(SETTING_TORRC, torrc);
 }
@@ -174,7 +174,7 @@
 /** Returns the user used when running Tor. The user is specified as an
  * argument to Tor, which will setuid to this user. */
 QString
-TorSettings::getUser()
+TorSettings::getUser() const
 {
   return value(SETTING_TOR_USER).toString();
 }
@@ -182,7 +182,7 @@
 /** Sets the user used when running Tor. The user is specified as an argument
  * to Tor, which will setuid to this user. */
 void
-TorSettings::setUser(QString user)
+TorSettings::setUser(const QString &user)
 {
   setValue(SETTING_TOR_USER, user);
 }
@@ -190,7 +190,7 @@
 /** Returns the group used when running Tor. The group is specified as an
  * argument to Tor, which will setgid to this group. */
 QString
-TorSettings::getGroup()
+TorSettings::getGroup() const
 {
   return value(SETTING_TOR_GROUP).toString();
 }
@@ -198,14 +198,14 @@
 /** Sets the group used when running Tor. The group is specified as an
  * argument to Tor, which will setgid to this group. */
 void
-TorSettings::setGroup(QString group)
+TorSettings::setGroup(const QString &group)
 {
   setValue(SETTING_TOR_GROUP, group);
 }
 
 /** Get the address or hostname used to connect to Tor */
 QHostAddress
-TorSettings::getControlAddress()
+TorSettings::getControlAddress() const
 {
   QString addr = localValue(SETTING_CONTROL_ADDR).toString();
   return QHostAddress(addr);
@@ -213,14 +213,14 @@
 
 /** Set the address or hostname used to connect to Tor */
 void
-TorSettings::setControlAddress(QHostAddress addr)
+TorSettings::setControlAddress(const QHostAddress &addr)
 {
   setValue(SETTING_CONTROL_ADDR, addr.toString());
 }
 
 /** Get the control port used to connect to Tor */
 quint16
-TorSettings::getControlPort()
+TorSettings::getControlPort() const
 {
   return (quint16)value(SETTING_CONTROL_PORT).toInt();
 }
@@ -235,7 +235,7 @@
 /** Returns the plaintext (i.e., not hashed) control password used when
  * authenticating to Tor. */
 QString
-TorSettings::getControlPassword()
+TorSettings::getControlPassword() const
 {
   return localValue(SETTING_CONTROL_PASSWORD).toString();
 }
@@ -243,7 +243,7 @@
 /** Sets the control password used when starting Tor with
  * HashedControlPassword to <b>password</b>. */
 void
-TorSettings::setControlPassword(QString password)
+TorSettings::setControlPassword(const QString &password)
 {
   setValue(SETTING_CONTROL_PASSWORD, password);
 }
@@ -251,7 +251,7 @@
 /** Returns true if a new, random control password is to be used each time Tor
  * is started. */
 bool
-TorSettings::useRandomPassword()
+TorSettings::useRandomPassword() const
 {
   return localValue(SETTING_USE_RANDOM_PASSWORD).toBool();
 }
@@ -266,7 +266,7 @@
 
 /** Returns the current authentication method used when connecting to Tor. */
 TorSettings::AuthenticationMethod
-TorSettings::getAuthenticationMethod()
+TorSettings::getAuthenticationMethod() const
 {
   AuthenticationMethod type = UnknownAuth;
   TorControl *tc = torControl();
@@ -298,7 +298,7 @@
  * <b>method</b>. The authentication method string is stored in Vidalia's
  * configuration file. */
 QString
-TorSettings::toString(AuthenticationMethod method)
+TorSettings::toString(AuthenticationMethod method) const
 {
   switch (method) {
     case NullAuth:  return "none";
@@ -312,7 +312,7 @@
 /** Returns the AuthenticationMethod enum value for the string
  * description of the authentication method given in <b>authMethod</b>. */
 TorSettings::AuthenticationMethod
-TorSettings::toAuthenticationMethod(const QString &authMethod)
+TorSettings::toAuthenticationMethod(const QString &authMethod) const
 { 
   QString str = authMethod.toLower();
   if (str == toString(NullAuth))

Modified: trunk/src/config/torsettings.h
===================================================================
--- trunk/src/config/torsettings.h	2007-12-04 17:39:46 UTC (rev 2171)
+++ trunk/src/config/torsettings.h	2007-12-04 18:00:18 UTC (rev 2172)
@@ -52,58 +52,58 @@
   bool apply(QString *errmsg = 0);
 
   /** Gets the name and path of Tor's executable. */
-  QString getExecutable();
+  QString getExecutable() const;
   /** Sets the name and path of Tor's executable. */
-  void setExecutable(QString torExecutable);
+  void setExecutable(const QString &torExecutable);
  
   /** Gets the location of Tor's data directory. */
-  QString getDataDirectory();
+  QString getDataDirectory() const;
   /** Sets the location to use for Tor's data directory. */
-  void setDataDirectory(QString dataDir);
+  void setDataDirectory(const QString &dataDir);
   
   /** Gets the torrc to use when starting Tor. */
-  QString getTorrc();
+  QString getTorrc() const;
   /** Sets the torrc to use when starting Tor. */
-  void setTorrc(QString torrc);
+  void setTorrc(const QString &torrc);
   
   /** Get Tor's control interface address. */
-  QHostAddress getControlAddress();
+  QHostAddress getControlAddress() const;
   /** Set Tor's control interface address. */
-  void setControlAddress(QHostAddress addr);
+  void setControlAddress(const QHostAddress &addr);
   
   /** Get the control port. */
-  quint16 getControlPort();
+  quint16 getControlPort() const;
   /** Set the control port. */
   void setControlPort(quint16 port);
   
   /** Returns the plaintext (i.e., not hashed) control password used when
    * authenticating to Tor. */
-  QString getControlPassword();
+  QString getControlPassword() const;
   /** Sets the control password used when starting Tor with
    * HashedControlPassword to <b>password</b>. */
-  void setControlPassword(QString password);
+  void setControlPassword(const QString &password);
 
  /** Returns true if a new, random control password is to be used each time
   * Tor is started. */
-  bool useRandomPassword();
+  bool useRandomPassword() const;
   /** Sets whether or not to generate and use a random control password each
    * time Tor is started. */
   void setUseRandomPassword(bool useRandomPassword);
 
   /** Returns the current authentication method used when connecting to Tor.*/
-  AuthenticationMethod getAuthenticationMethod();
+  AuthenticationMethod getAuthenticationMethod() const;
   /** Sets the authentication method used when starting Tor to <b>method</b>.*/
   void setAuthenticationMethod(AuthenticationMethod method);
    
   /** Get which user will be used to run Tor. */
-  QString getUser();
+  QString getUser() const;
   /** Set which user will be used to run Tor. */
-  void setUser(QString user);
+  void setUser(const QString &user);
   
   /** Get which group will be used to run Tor. */
-  QString getGroup();
+  QString getGroup() const;
   /** Set which group will be used to run Tor. */
-  void setGroup(QString group);
+  void setGroup(const QString &group);
 
   /** Generates a random control password consisting of PASSWORD_LEN
    * characters. */
@@ -115,11 +115,11 @@
 private:
   /** Returns the AuthenticationMethod enum value for the string
    * description of the authentication method given in <b>authMethod</b>. */
-  AuthenticationMethod toAuthenticationMethod(const QString &authMethod);
+  AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const;
   /** Returns the string description of the authentication method specified by
    * <b>method</b>. The authentication method string is stored in  Vidalia's
    * configuration file. */
-  QString toString(AuthenticationMethod type);
+  QString toString(AuthenticationMethod type) const;
 };
 
 #endif

Modified: trunk/src/config/vsettings.cpp
===================================================================
--- trunk/src/config/vsettings.cpp	2007-12-04 17:39:46 UTC (rev 2171)
+++ trunk/src/config/vsettings.cpp	2007-12-04 18:00:18 UTC (rev 2172)
@@ -46,7 +46,7 @@
  * \sa setDefault
  */
 QVariant
-VSettings::value(const QString &key, const QVariant &defaultVal)
+VSettings::value(const QString &key, const QVariant &defaultVal) const
 {
   return QSettings::value(key, defaultVal.isNull() ? defaultValue(key)
                                                    : defaultVal);
@@ -72,7 +72,7 @@
 /** Returns the default setting value associated with <b>key</b>. If
  * <b>key</b> has no default value, then an empty QVariant is returned. */
 QVariant
-VSettings::defaultValue(const QString &key)
+VSettings::defaultValue(const QString &key) const
 {
   if (_defaults.contains(key))
     return _defaults.value(key);
@@ -90,7 +90,7 @@
 
 /** Returns a map of all currently saved settings at the last appyl() point. */
 QMap<QString, QVariant>
-VSettings::allSettings()
+VSettings::allSettings() const
 {
   QMap<QString, QVariant> settings;
   foreach (QString key, allKeys()) {

Modified: trunk/src/config/vsettings.h
===================================================================
--- trunk/src/config/vsettings.h	2007-12-04 17:39:46 UTC (rev 2171)
+++ trunk/src/config/vsettings.h	2007-12-04 18:00:18 UTC (rev 2172)
@@ -48,7 +48,7 @@
    * \sa setDefault
    */
   virtual QVariant value(const QString &key,
-                         const QVariant &defaultVal = QVariant());
+                         const QVariant &defaultVal = QVariant()) const;
   /** Sets the value associated with <b>key</b> to <b>val</b>. */
   virtual void setValue(const QString &key, const QVariant &val);
 
@@ -57,10 +57,10 @@
   void setDefault(const QString &key, const QVariant &val);
   /** Returns the default setting value associated with <b>key</b>. If
    * <b>key</b> has no default value, then an empty QVariant is returned. */
-  QVariant defaultValue(const QString &key);
+  QVariant defaultValue(const QString &key) const;
   /** Returns a map of all currently saved settings at the last apply()
    * point. */
-  QMap<QString, QVariant> allSettings();
+  QMap<QString, QVariant> allSettings() const;
 
 private:
   /** Association of setting key names to default setting values. */