[tor-commits] [vidalia/alpha] Merge branch 'bug4576_remember' into alpha

chiiph at torproject.org chiiph at torproject.org
Mon Jan 23 16:45:42 UTC 2012


commit 747826009ad4fc2072798b46a9cb072bc009dc0a
Merge: 9789ba9 f2e38a6
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Mon Jan 23 11:41:04 2012 -0300

    Merge branch 'bug4576_remember' into alpha
    
    Conflicts:
    	src/vidalia/config/VidaliaSettings.cpp
    	src/vidalia/config/VidaliaSettings.h

 changes/bug4577                         |    3 +
 src/vidalia/MainWindow.cpp              |    9 +-
 src/vidalia/VMessageBox.cpp             |   55 ++++-
 src/vidalia/VMessageBox.h               |   11 +-
 src/vidalia/config/VidaliaSettings.cpp  |   13 +
 src/vidalia/config/VidaliaSettings.cpp~ |  396 +++++++++++++++++++++++++++++++
 src/vidalia/config/VidaliaSettings.h    |    8 +
 src/vidalia/config/VidaliaSettings.h~   |  163 +++++++++++++
 8 files changed, 645 insertions(+), 13 deletions(-)

diff --cc src/vidalia/config/VidaliaSettings.cpp
index ac15a63,48cd051..b13f98f
--- a/src/vidalia/config/VidaliaSettings.cpp
+++ b/src/vidalia/config/VidaliaSettings.cpp
@@@ -88,7 -87,7 +88,8 @@@ VidaliaSettings::VidaliaSettings(
  
    setDefault(SETTING_PLUGIN_PATH, vApp->dataDirectory());
    setDefault(SETTING_ICON_PREF, Both);
 +  setDefault(SETTING_SKIP_VERSION_CHECK, false);
+   setDefault(SETTING_REMEMBER_SHUTDOWN, false);
  }
  
  /** Gets the currently preferred language code for Vidalia. */
@@@ -374,7 -373,13 +375,19 @@@ VidaliaSettings::fromString(QString ico
  }
  
  bool
 +VidaliaSettings::skipVersionCheck() const
 +{
 +  return value(SETTING_SKIP_VERSION_CHECK).toBool();
 +}
++
++bool
+ VidaliaSettings::rememberShutdown()
+ {
+   return value(SETTING_REMEMBER_SHUTDOWN).toBool();
+ }
+ 
+ void
+ VidaliaSettings::setRememberShutdown(bool val)
+ {
+   setValue(SETTING_REMEMBER_SHUTDOWN, val);
+ }
diff --cc src/vidalia/config/VidaliaSettings.cpp~
index 0000000,0000000..6e468fa
new file mode 100644
--- /dev/null
+++ b/src/vidalia/config/VidaliaSettings.cpp~
@@@ -1,0 -1,0 +1,396 @@@
++/*
++**  This file is part of Vidalia, and is subject to the license terms in the
++**  LICENSE file, found in the top level directory of this distribution. If you
++**  did not receive the LICENSE file with this file, you may obtain it from the
++**  Vidalia source package distributed by the Vidalia Project at
++**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
++**  including this file, may be copied, modified, propagated, or distributed 
++**  except according to the terms described in the LICENSE file.
++*/
++
++/*
++** \file VidaliaSettings.cpp
++** \brief General Vidalia settings, such as language and interface style
++*/
++
++#include "VidaliaSettings.h"
++#include "LanguageSupport.h"
++#include "Vidalia.h"
++#if defined(Q_WS_WIN)
++#include "win32.h"
++#endif
++
++#include <QDir>
++#include <QCoreApplication>
++#include <QStyleFactory>
++
++#define SETTING_LANGUAGE            "LanguageCode"
++#define SETTING_STYLE               "InterfaceStyle"
++#define SETTING_RUN_TOR_AT_START    "RunTorAtStart"
++#define SETTING_DATA_DIRECTORY      "DataDirectory"
++#define SETTING_SHOW_MAINWINDOW_AT_START  "ShowMainWindowAtStart"
++#define SETTING_BROWSER_EXECUTABLE  "BrowserExecutable"
++#define SETTING_BROWSER_DIRECTORY   "BrowserDirectory"
++#define SETTING_IM_EXECUTABLE       "IMExecutable"
++#define SETTING_RUN_PROXY_AT_START  "RunProxyAtStart"
++#define SETTING_PROXY_EXECUTABLE    "ProxyExecutable"
++#define SETTING_PROXY_EXECUTABLE_ARGUMENTS  "ProxyExecutableArguments"
++#define SETTING_CHECK_FOR_UPDATES   "CheckForUpdates"
++#define SETTING_LAST_UPDATE_CHECK   "LastUpdateCheck"
++#define SETTING_USE_LOCAL_GEOIP_DATABASE  "UseLocalGeoIpDatabase"
++#define SETTING_LOCAL_GEOIP_DATABASE "LocalGeoIpDatabase"
++#define SETTING_PLUGIN_PATH         "PluginPath"
++#define SETTING_SKIP_VERSION_CHECK  "SkipVersionCheck"
++
++#if defined(Q_OS_WIN32)
++#define STARTUP_REG_KEY        "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
++#define VIDALIA_REG_KEY        "Vidalia" 
++#endif
++
++#define SETTING_ICON_PREF	"IconPref"
++
++/** Default Constructor */
++VidaliaSettings::VidaliaSettings()
++{
++#if defined(Q_WS_MAC)
++  setDefault(SETTING_STYLE, "macintosh (aqua)");
++#else
++  static QStringList styles = QStyleFactory::keys();
++#if defined(Q_WS_WIN)
++  if (styles.contains("windowsvista", Qt::CaseInsensitive))
++    setDefault(SETTING_STYLE, "windowsvista");
++  else
++#endif
++  {
++    if (styles.contains("cleanlooks", Qt::CaseInsensitive))
++      setDefault(SETTING_STYLE, "cleanlooks");
++    else
++      setDefault(SETTING_STYLE, "plastique");
++  }
++#endif
++
++  setDefault(SETTING_LANGUAGE, LanguageSupport::defaultLanguageCode());
++  setDefault(SETTING_RUN_TOR_AT_START, true);
++  setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true);
++  setDefault(SETTING_BROWSER_EXECUTABLE, "");
++  setDefault(SETTING_IM_EXECUTABLE, "");
++  setDefault(SETTING_RUN_PROXY_AT_START, false);
++  setDefault(SETTING_PROXY_EXECUTABLE, "");
++  setDefault(SETTING_PROXY_EXECUTABLE_ARGUMENTS, QString());
++#if defined(Q_WS_WIN)
++  setDefault(SETTING_CHECK_FOR_UPDATES, true);
++#else
++  setDefault(SETTING_CHECK_FOR_UPDATES, false);
++#endif
++  setDefault(SETTING_LAST_UPDATE_CHECK, QDateTime());
++  setDefault(SETTING_USE_LOCAL_GEOIP_DATABASE, false);
++  setDefault(SETTING_LOCAL_GEOIP_DATABASE, "");
++
++  setDefault(SETTING_PLUGIN_PATH, vApp->dataDirectory());
++  setDefault(SETTING_ICON_PREF, Both);
++<<<<<<< HEAD
++  setDefault(SETTING_SKIP_VERSION_CHECK, false);
++=======
++  setDefault(SETTING_REMEMBER_SHUTDOWN, false);
++>>>>>>> bug4577_remember
++}
++
++/** Gets the currently preferred language code for Vidalia. */
++QString
++VidaliaSettings::getLanguageCode()
++{
++  return value(SETTING_LANGUAGE).toString();
++}
++
++/** Sets the preferred language code. */
++void
++VidaliaSettings::setLanguageCode(QString languageCode)
++{
++  setValue(SETTING_LANGUAGE, languageCode);
++}
++
++/** Gets the interface style key (e.g., "windows", "motif", etc.) */
++QString
++VidaliaSettings::getInterfaceStyle()
++{
++  return value(SETTING_STYLE).toString();
++}
++
++/** Sets the interface style key. */
++void
++VidaliaSettings::setInterfaceStyle(QString styleKey)
++{
++  setValue(SETTING_STYLE, styleKey);
++}
++
++/** Returns true if Tor is to be run when Vidalia starts. */
++bool
++VidaliaSettings::runTorAtStart()
++{
++  return value(SETTING_RUN_TOR_AT_START).toBool();
++}
++
++/** If <b>run</b> is set to true, then Tor will be run when Vidalia starts. */
++void
++VidaliaSettings::setRunTorAtStart(bool run)
++{
++  setValue(SETTING_RUN_TOR_AT_START, run);
++}
++
++/** Returns true if Vidalia's main window should be visible when the
++ * application starts. */
++bool
++VidaliaSettings::showMainWindowAtStart()
++{
++  return value(SETTING_SHOW_MAINWINDOW_AT_START).toBool();
++}
++
++/** Sets whether to show Vidalia's main window when the application starts. */
++void
++VidaliaSettings::setShowMainWindowAtStart(bool show)
++{
++  setValue(SETTING_SHOW_MAINWINDOW_AT_START, show);
++}
++
++
++/** Returns true if Vidalia is set to run on system boot. */
++bool
++VidaliaSettings::runVidaliaOnBoot()
++{
++#if defined(Q_WS_WIN)
++  if (!win32_registry_get_key_value(STARTUP_REG_KEY, VIDALIA_REG_KEY).isEmpty()) {
++    return true;
++  } else {
++    return false;
++  }
++#else
++  /* Platforms other than windows aren't supported yet */
++  return false;
++#endif
++}
++
++/** If <b>run</b> is set to true, then Vidalia will run on system boot. */
++void
++VidaliaSettings::setRunVidaliaOnBoot(bool run)
++{
++#if defined(Q_WS_WIN)
++  if (run) {
++    win32_registry_set_key_value(STARTUP_REG_KEY, VIDALIA_REG_KEY,
++        QString("\"" +
++                QDir::convertSeparators(QCoreApplication::applicationFilePath())) +
++                "\"");
++  } else {
++    win32_registry_remove_key(STARTUP_REG_KEY, VIDALIA_REG_KEY);
++  }
++#else
++  /* Platforms othe rthan windows aren't supported yet */
++  Q_UNUSED(run);
++  return;
++#endif
++}
++
++/** If browserDirectory is empty, returns a fully-qualified path to
++ * the web browser, including the executable name. If browserDirectory
++ * is set, then returns the basename of the configured web browser */
++QString
++VidaliaSettings::getBrowserExecutable() const
++{
++  return QDir::convertSeparators(value(SETTING_BROWSER_EXECUTABLE).toString());
++}
++
++/** Sets the location and name of the web browser executable to the given string.
++ * If set to the empty string, the browser will not be started. */
++void
++VidaliaSettings::setBrowserExecutable(const QString &browserExecutable)
++{
++  setValue(SETTING_BROWSER_EXECUTABLE, browserExecutable);
++}
++
++/** Returns a fully-qualified path to the web browser directory */
++QString
++VidaliaSettings::getBrowserDirectory() const
++{
++  return QDir::convertSeparators(value(SETTING_BROWSER_DIRECTORY).toString());
++}
++
++/** Sets the location and name of the web browser directory to the given string.
++ * If set to the empty string, the browser will not be started. */
++void
++VidaliaSettings::setBrowserDirectory(const QString &browserDirectory)
++{
++  setValue(SETTING_BROWSER_DIRECTORY, browserDirectory);
++}
++
++/** Returns a fully-qualified path to the IM client, including the
++ * executable name. */
++QString
++VidaliaSettings::getIMExecutable() const
++{
++  return QDir::convertSeparators(value(SETTING_IM_EXECUTABLE).toString());
++}
++
++/** Sets the location and name of the IM client executable to the given string.
++ * If set to the empty string, the client will not be started. */
++void
++VidaliaSettings::setIMExecutable(const QString &IMExecutable)
++{
++  setValue(SETTING_IM_EXECUTABLE, IMExecutable);
++}
++
++/** Returns true if Vidalia should start a proxy application when it
++ * starts. */
++bool
++VidaliaSettings::runProxyAtStart()
++{
++  return value(SETTING_RUN_PROXY_AT_START).toBool();
++}
++
++/** Set whether to run a proxy application when Vidalia starts. */
++void
++VidaliaSettings::setRunProxyAtStart(bool run)
++{
++  setValue(SETTING_RUN_PROXY_AT_START, run);
++}
++
++/** Returns a fully-qualified path to the proxy server, including the
++ * executable name. */
++QString
++VidaliaSettings::getProxyExecutable() const
++{
++  return QDir::convertSeparators(value(SETTING_PROXY_EXECUTABLE).toString());
++}
++
++/** Sets the location and name of the proxy server executable to the given
++ * string. If set to the empty string, the proxy will not be started. */
++void
++VidaliaSettings::setProxyExecutable(const QString &proxyExecutable)
++{
++  setValue(SETTING_PROXY_EXECUTABLE, proxyExecutable);
++}
++
++/** Returns a string containing additional command line arguments to be passed
++ * to ProxyExecutable */
++QString
++VidaliaSettings::getProxyExecutableArguments() const
++{
++  return value(SETTING_PROXY_EXECUTABLE_ARGUMENTS).toString();
++}
++
++/** Sets the additional arguments to be passed to Proxy Executable */
++void
++VidaliaSettings::setProxyExecutableArguments(const QString
++                                             &proxyExecutableArguments)
++{
++  setValue(SETTING_PROXY_EXECUTABLE_ARGUMENTS, proxyExecutableArguments);
++}
++
++bool
++VidaliaSettings::isAutoUpdateEnabled() const
++{
++  return value(SETTING_CHECK_FOR_UPDATES).toBool();
++}
++
++void
++VidaliaSettings::setAutoUpdateEnabled(bool enabled)
++{
++  setValue(SETTING_CHECK_FOR_UPDATES, enabled);
++}
++
++QDateTime
++VidaliaSettings::lastCheckedForUpdates() const
++{
++  return value(SETTING_LAST_UPDATE_CHECK).toDateTime();
++}
++
++void
++VidaliaSettings::setLastCheckedForUpdates(const QDateTime &checkedAt)
++{
++  setValue(SETTING_LAST_UPDATE_CHECK, checkedAt);
++}
++
++bool
++VidaliaSettings::useLocalGeoIpDatabase() const
++{
++  return value(SETTING_USE_LOCAL_GEOIP_DATABASE).toBool();
++}
++
++void
++VidaliaSettings::setUseLocalGeoIpDatabase(bool enabled)
++{
++  setValue(SETTING_USE_LOCAL_GEOIP_DATABASE, enabled);
++}
++
++QString
++VidaliaSettings::localGeoIpDatabase() const
++{
++  return QDir::convertSeparators(value(SETTING_LOCAL_GEOIP_DATABASE).toString());
++}
++
++void
++VidaliaSettings::setLocalGeoIpDatabase(const QString &databaseFile)
++{
++  setValue(SETTING_LOCAL_GEOIP_DATABASE, databaseFile);
++}
++
++QString 
++VidaliaSettings::pluginPath() const
++{
++  return QDir::convertSeparators(value(SETTING_PLUGIN_PATH).toString());
++}
++
++void 
++VidaliaSettings::setPluginPath(const QString &path)
++{
++  setValue(SETTING_PLUGIN_PATH, path);
++}
++
++/** Get the icon preference */
++VidaliaSettings::IconPosition
++VidaliaSettings::getIconPref()
++{
++  return fromString(value(SETTING_ICON_PREF).toString());
++}
++
++/** Set the icon preference */
++void
++VidaliaSettings::setIconPref(const IconPosition iconPref)
++{
++  setValue(SETTING_ICON_PREF, toString(iconPref));
++}
++
++QString
++VidaliaSettings::toString(const IconPosition iconPref)
++{
++  switch(iconPref) {
++  case Dock: return "Dock";
++  case Tray: return "Tray";
++  default: return "Both";
++  }
++}
++
++VidaliaSettings::IconPosition
++VidaliaSettings::fromString(QString iconPref)
++{
++  if(iconPref == "Dock") return Dock;
++  if(iconPref == "Tray") return Tray;
++
++  return Both;
++}
++
++bool
++<<<<<<< HEAD
++VidaliaSettings::skipVersionCheck() const
++{
++  return value(SETTING_SKIP_VERSION_CHECK).toBool();
++=======
++VidaliaSettings::rememberShutdown()
++{
++  return value(SETTING_REMEMBER_SHUTDOWN).toBool();
++}
++
++void
++VidaliaSettings::setRememberShutdown(bool val)
++{
++  setValue(SETTING_REMEMBER_SHUTDOWN, val);
++>>>>>>> bug4577_remember
++}
diff --cc src/vidalia/config/VidaliaSettings.h
index 99dfec9,3efbdb5..09360ab
--- a/src/vidalia/config/VidaliaSettings.h
+++ b/src/vidalia/config/VidaliaSettings.h
@@@ -145,8 -147,11 +147,14 @@@ public
    QString toString(const IconPosition iconPref);
    IconPosition fromString(QString iconPref);
  
 +  /** Returns true if Vidalia should skip the version check for tor */
 +  bool skipVersionCheck() const;
++
+   /** Returns true if Vidalia should not ask if the user wants to shutdown 
+    *  tor gracefully */
+   bool rememberShutdown();
+   /** Sets RememberShutdown to val */
+   void setRememberShutdown(bool val);
  };
  
  #endif
diff --cc src/vidalia/config/VidaliaSettings.h~
index 0000000,0000000..75c0b7a
new file mode 100644
--- /dev/null
+++ b/src/vidalia/config/VidaliaSettings.h~
@@@ -1,0 -1,0 +1,163 @@@
++/*
++**  This file is part of Vidalia, and is subject to the license terms in the
++**  LICENSE file, found in the top level directory of this distribution. If you
++**  did not receive the LICENSE file with this file, you may obtain it from the
++**  Vidalia source package distributed by the Vidalia Project at
++**  http://www.torproject.org/projects/vidalia.html. No part of Vidalia, 
++**  including this file, may be copied, modified, propagated, or distributed 
++**  except according to the terms described in the LICENSE file.
++*/
++
++/*
++** \file VidaliaSettings.h
++** \brief General Vidalia settings, such as language and interface style
++*/
++
++#ifndef _VIDALIASETTINGS_H
++#define _VIDALIASETTINGS_H
++
++#include "VSettings.h"
++
++#include <QDateTime>
++
++/** Public setting keys */
++#define SETTING_REMEMBER_SHUTDOWN   "RememberShutdown"
++
++/** Handles saving and restoring Vidalia's settings, such as the
++ * location of Tor, the control port, etc.
++ *
++ * NOTE: Qt 4.1 documentation states that constructing a QSettings object is
++ * "very fast", so we shouldn't need to create a global instance of this
++ * class.
++ */
++class VidaliaSettings : public VSettings
++{
++  Q_OBJECT
++
++public:
++  enum IconPosition {
++    Tray,
++    Dock,
++    Both,
++  };
++
++  /** Default constructor. */
++  VidaliaSettings();
++
++  /** Gets the currently preferred language code for Vidalia. */
++  QString getLanguageCode();
++  /** Saves the preferred language code. */
++  void setLanguageCode(QString languageCode);
++ 
++  /** Gets the interface style key (e.g., "windows", "motif", etc.) */
++  QString getInterfaceStyle();
++  /** Sets the interface style key. */
++  void setInterfaceStyle(QString styleKey);
++  
++  /** Returns true if Vidalia should start Tor when it starts. */
++  bool runTorAtStart();
++  /** Set whether to run Tor when Vidalia starts. */
++  void setRunTorAtStart(bool run);
++
++  /** Returns true if Vidalia's main window should be visible when the
++   * application starts. */
++  bool showMainWindowAtStart();
++  /** Sets whether to show Vidalia's main window when the application starts. */
++  void setShowMainWindowAtStart(bool show);
++  
++  /** Returns true if Vidalia should start on system boot. */
++  bool runVidaliaOnBoot();
++  /** Set whether to run Vidalia on system boot. */
++  void setRunVidaliaOnBoot(bool run);
++
++  /** If browserDirectory is empty, returns a fully-qualified path to
++   * the web browser, including the executable name. If browserDirectory
++   * is set, then returns the basename of the configured web browser */
++  QString getBrowserExecutable() const;
++  /** Sets the location and name of the web browser executable to the given
++   * string. If set to the empty string, the browser will not be started. */
++  void setBrowserExecutable(const QString &browserExecutable);
++
++  /** Returns a fully-qualified path to the web browser directory */
++  QString getBrowserDirectory() const;
++  /** Sets the location and name of the web browser directory to the given string.
++   * If set to the empty string, the browser will not be started. */
++  void setBrowserDirectory(const QString &browserDirectory);
++
++  /** Returns a fully-qualified path to the IM client, including the
++   * executable name. */
++  QString getIMExecutable() const;
++  /** Sets the location and name of the IM client executable to the given
++   * string. If set to the empty string, the client will not be started. */
++  void setIMExecutable(const QString &IMExecutable);
++
++  /** Returns true if Vidalia should start a proxy application when it
++   * starts. */
++  bool runProxyAtStart();
++  /** Set whether to run a proxy application when Vidalia starts. */
++  void setRunProxyAtStart(bool run);
++
++  /** Returns a fully-qualified path to the proxy server, including the
++   * executable name. */
++  QString getProxyExecutable() const;
++  /** Sets the location and name of the proxy server executable to the given
++   * string. If set to the empty string, the proxy will not be started. */
++  void setProxyExecutable(const QString &proxyExecutable);
++
++  /** Returns a list containing additional command line arguments to be
++   * passed to ProxyExecutable */
++  QString getProxyExecutableArguments() const;
++  /** Sets the additional arguments to be passed to Proxy Executable */
++  void setProxyExecutableArguments(const QString &proxyExecutableArguments);
++  
++  /** Returns true if Vidalia should automatically check for software updates.
++   */
++  bool isAutoUpdateEnabled() const;
++  /** Sets to <b>enabled</b> whether Vidalia should automatically check for
++   * software updates or not. */
++  void setAutoUpdateEnabled(bool enabled);
++
++  /** Returns the time at which Vidalia last checked for software updates. */
++  QDateTime lastCheckedForUpdates() const;
++  /** Sets to <b>checkedAt</b> the time at which Vidalia last checked for
++   * available software updates. */
++  void setLastCheckedForUpdates(const QDateTime &checkedAt);
++
++  /** Returns true if Vidalia is currently configured to use a local GeoIP
++   * database. */
++  bool useLocalGeoIpDatabase() const;
++  /** Enables or disables use of a local GeoIP database. */
++  void setUseLocalGeoIpDatabase(bool enabled);
++
++  /** Returns the file, if set, to be used as the local GeoIP database. */
++  QString localGeoIpDatabase() const;
++  /** Sets the file to use as a local GeoIP database. */
++  void setLocalGeoIpDatabase(const QString &databaseFile);
++
++  /** Returns the path where the plugins live */
++  QString pluginPath() const;
++  /** Sets the path where the plugins live */
++  void setPluginPath(const QString &path);
++
++  /** Get the icon preference */
++  IconPosition getIconPref();
++
++  /** Set the icon preference */
++  void setIconPref(const IconPosition iconPref);
++  QString toString(const IconPosition iconPref);
++  IconPosition fromString(QString iconPref);
++
++<<<<<<< HEAD
++  /** Returns true if Vidalia should skip the version check for tor */
++  bool skipVersionCheck() const;
++=======
++  /** Returns true if Vidalia should not ask if the user wants to shutdown 
++   *  tor gracefully */
++  bool rememberShutdown();
++  /** Sets RememberShutdown to val */
++  void setRememberShutdown(bool val);
++>>>>>>> bug4577_remember
++};
++
++#endif
++





More information about the tor-commits mailing list