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

[vidalia-svn] r2484: Implement saving and loading the proxy executable settings f (in vidalia/trunk: . src/vidalia/config)



Author: edmanm
Date: 2008-04-05 00:09:20 -0400 (Sat, 05 Apr 2008)
New Revision: 2484

Modified:
   vidalia/trunk/
   vidalia/trunk/src/vidalia/config/generalpage.cpp
   vidalia/trunk/src/vidalia/config/generalpage.h
Log:
 r310@lysithea:  edmanm | 2008-04-05 00:05:47 -0400
 Implement saving and loading the proxy executable settings from the 'General'
 settings page..



Property changes on: vidalia/trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r310] on 90112fd6-a33b-4cea-8d39-48ff1d78625c

Modified: vidalia/trunk/src/vidalia/config/generalpage.cpp
===================================================================
--- vidalia/trunk/src/vidalia/config/generalpage.cpp	2008-04-05 04:09:18 UTC (rev 2483)
+++ vidalia/trunk/src/vidalia/config/generalpage.cpp	2008-04-05 04:09:20 UTC (rev 2484)
@@ -14,6 +14,7 @@
 ** \brief General Tor and Vidalia configuration options
 */
 
+#include <stringutil.h>
 #include "generalpage.h"
 
 
@@ -30,7 +31,9 @@
   
   /* Bind event to actions */
   connect(ui.btnBrowseTorExecutable, SIGNAL(clicked()), 
-          this, SLOT(browseTorPath()));
+          this, SLOT(browseTorExecutable()));
+  connect(ui.btnBrowseProxyExecutable, SIGNAL(clicked()), 
+          this, SLOT(browseProxyExecutable()));
 
   /* Hide platform specific features */
 #ifndef Q_WS_WIN
@@ -45,9 +48,12 @@
   delete _torSettings;
 }
 
-/* Open a QFileDialog to browse for Tor executable */
-void
-GeneralPage::browseTorPath()
+/** Displays a file dialog allowing the user to browse for an executable
+ * file. <b>caption</b> will be displayed in the dialog's title bar and
+ * <b>file</b>, if specified, is the default file selected in the dialog.
+ */
+QString
+GeneralPage::browseExecutable(const QString &caption, const QString &file)
 {
 #if defined(Q_OS_WIN32)
   QString filter = tr("Executables (*.exe)");
@@ -55,19 +61,32 @@
   QString filter = "";
 #endif
  
-  /* Prompt the user for an executable file. If we're on windows, filter for
-   * only .exe files. */
-  QString filename = QDir::convertSeparators(
-                          QFileDialog::getOpenFileName(this,
-                              tr("Select Path to Tor"), 
-                              ui.lineTorExecutable->text(),
-                              filter));
-  if (!filename.isEmpty()) {
-    ui.lineTorExecutable->setText(filename);
-  }
+  QString filePath = QFileDialog::getOpenFileName(this, caption, file, filter);
+  return QDir::convertSeparators(filePath);
 }
 
-/* Saves all settings for this page */
+/** Open a QFileDialog to browse for a Tor executable file. */
+void
+GeneralPage::browseTorExecutable()
+{
+  QString filePath = browseExecutable(tr("Select Path to Tor"),
+                                      ui.lineTorExecutable->text());
+  if (! filePath.isEmpty())
+    ui.lineTorExecutable->setText(filePath);
+}
+
+/** Open a QFileDialog to browse for a proxy executable file. */
+void
+GeneralPage::browseProxyExecutable()
+{
+  QString filePath = browseExecutable(tr("Select Proxy Executable"),
+                                      ui.lineProxyExecutable->text());
+
+  if (! filePath.isEmpty())
+    ui.lineProxyExecutable->setText(filePath);
+}
+
+/** Saves all settings for this page */
 bool
 GeneralPage::save(QString &errmsg)
 {
@@ -76,20 +95,41 @@
     errmsg = tr("You must specify the name of your Tor executable.");
     return false;
   }
+  if (ui.chkRunProxyAtVidaliaStartup->isChecked()) {
+    bool ok;
+    QStringList proxyArgs = string_parse_arguments(
+                              ui.lineProxyExecutableArguments->text(), &ok);
+    if (! ok) {
+      errmsg = tr("The proxy arguments specified are not properly formatted.");
+      return false;
+    }
+    _vidaliaSettings->setProxyExecutable(ui.lineProxyExecutable->text());
+    _vidaliaSettings->setProxyExecutableArguments(proxyArgs);
+  }
+  
   _torSettings->setExecutable(torExecutable);
   _vidaliaSettings->setRunTorAtStart(ui.chkRunTorAtVidaliaStartup->isChecked());
   _vidaliaSettings->setRunVidaliaOnBoot(
     ui.chkRunVidaliaAtSystemStartup->isChecked());
+  _vidaliaSettings->setRunProxyAtStart(
+    ui.chkRunProxyAtVidaliaStartup->isChecked());
+
   return true;
 }
 
-/* Loads previously saved settings */
+/** Loads previously saved settings */
 void
 GeneralPage::load()
 {
+  ui.chkRunVidaliaAtSystemStartup->setChecked(
+    _vidaliaSettings->runVidaliaOnBoot());
+  
   ui.lineTorExecutable->setText(_torSettings->getExecutable());
   ui.chkRunTorAtVidaliaStartup->setChecked(_vidaliaSettings->runTorAtStart());
-  ui.chkRunVidaliaAtSystemStartup->setChecked(
-    _vidaliaSettings->runVidaliaOnBoot());
+
+  ui.lineProxyExecutable->setText(_vidaliaSettings->getProxyExecutable());
+  ui.lineProxyExecutableArguments->setText(
+    string_format_arguments(_vidaliaSettings->getProxyExecutableArguments()));
+  ui.chkRunProxyAtVidaliaStartup->setChecked(_vidaliaSettings->runProxyAtStart());
 }
 

Modified: vidalia/trunk/src/vidalia/config/generalpage.h
===================================================================
--- vidalia/trunk/src/vidalia/config/generalpage.h	2008-04-05 04:09:18 UTC (rev 2483)
+++ vidalia/trunk/src/vidalia/config/generalpage.h	2008-04-05 04:09:20 UTC (rev 2484)
@@ -39,13 +39,21 @@
   void load();
 
 private slots:
-  /** Called when the user clicks "Browse" */
-  void browseTorPath();
+  /** Open a QFileDialog to browse for a Tor executable file. */
+  void browseTorExecutable();
+  /** Open a QFileDialog to browse for a proxy executable file. */
+  void browseProxyExecutable();
   
 private:
-  /* A VidaliaSettings object used for saving/loading vidalia settings */
+  /** Displays a file dialog allowing the user to browse for an executable
+   * file. <b>caption</b> will be displayed in the dialog's title bar and <b>
+   * file</b>, if specified, is the default file selected in the dialog. */
+  QString browseExecutable(const QString &caption,
+                           const QString &file = QString());
+
+  /** A VidaliaSettings object used for saving/loading vidalia settings */
   VidaliaSettings *_vidaliaSettings;
-  /* A TorSettings ovject used for saving/loading tor settings */
+  /** A TorSettings ovject used for saving/loading tor settings */
   TorSettings *_torSettings;
   /** Qt Designer generated object */
   Ui::GeneralPage ui;