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

[vidalia-svn] r1830: Add the ability to specify Tor's data directory. (in trunk: . src/config src/gui/config)



Author: edmanm
Date: 2007-08-13 12:49:53 -0400 (Mon, 13 Aug 2007)
New Revision: 1830

Modified:
   trunk/
   trunk/src/config/torsettings.cpp
   trunk/src/config/torsettings.h
   trunk/src/gui/config/advancedpage.cpp
   trunk/src/gui/config/advancedpage.h
   trunk/src/gui/config/advancedpage.ui
Log:
 r1978@adrastea:  edmanm | 2007-08-05 17:34:24 -0400
 Add the ability to specify Tor's data directory.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /vidalia/local/trunk [r1978] on 54b3572a-7227-0410-958f-53ecd705b71a

Modified: trunk/src/config/torsettings.cpp
===================================================================
--- trunk/src/config/torsettings.cpp	2007-08-13 16:49:44 UTC (rev 1829)
+++ trunk/src/config/torsettings.cpp	2007-08-13 16:49:53 UTC (rev 1830)
@@ -39,6 +39,7 @@
 #define SETTING_AUTH_TOKEN      "Tor/AuthToken"
 #define SETTING_TOR_USER        "Tor/User"
 #define SETTING_TOR_GROUP       "Tor/Group"
+#define SETTING_DATA_DIRECTORY  "Tor/DataDirectory"
 
 /* On win32, we need to add the .exe onto Tor's filename */
 #if defined(Q_OS_WIN32)
@@ -53,6 +54,7 @@
 #define TOR_ARG_TORRC           "-f"
 #define TOR_ARG_USER            "User"
 #define TOR_ARG_GROUP           "Group"
+#define TOR_ARG_DATA_DIRECTORY  "DataDirectory"
 
 
 /** Default constructor */
@@ -65,8 +67,23 @@
   setDefault(SETTING_AUTH_TOKEN,    QByteArray(""));
   setDefault(SETTING_TOR_USER,      "");
   setDefault(SETTING_TOR_GROUP,     "");
+  setDefault(SETTING_DATA_DIRECTORY, "");
 }
 
+/** Gets the location of Tor's data directory. */
+QString
+TorSettings::getDataDirectory()
+{
+  return value(SETTING_DATA_DIRECTORY).toString();  
+}
+
+/** Sets the location to use as Tor's data directory. */
+void
+TorSettings::setDataDirectory(QString dataDirectory)
+{
+  setValue(SETTING_DATA_DIRECTORY, dataDirectory);
+}
+
 /** Returns a fully-qualified path to Tor's executable, including the
  * executable name. */
 QString
@@ -107,6 +124,13 @@
     args += formatArgument(TOR_ARG_TORRC, 
                            expand_filename(torrc)) + " ";
   }
+  /* Specify the location to use for Tor's data directory, if different from
+   * the default. */
+  QString dataDirectory = getDataDirectory();
+  if (!dataDirectory.isEmpty()) {
+    args += formatArgument(TOR_ARG_DATA_DIRECTORY,
+                           expand_filename(dataDirectory)) + " ";
+  }
   /* Add the ControlPort value */
   quint16 controlPort = getControlPort();
   if (controlPort) {

Modified: trunk/src/config/torsettings.h
===================================================================
--- trunk/src/config/torsettings.h	2007-08-13 16:49:44 UTC (rev 1829)
+++ trunk/src/config/torsettings.h	2007-08-13 16:49:53 UTC (rev 1830)
@@ -44,6 +44,11 @@
   QString getExecutable();
   /** Sets the name and path of Tor's executable. */
   void setExecutable(QString torExecutable);
+ 
+  /** Gets the location of Tor's data directory. */
+  QString getDataDirectory();
+  /** Sets the location to use for Tor's data directory. */
+  void setDataDirectory(QString dataDir);
   
   /** Builds and formats a list of command-line arguments. */
   QString getArguments();

Modified: trunk/src/gui/config/advancedpage.cpp
===================================================================
--- trunk/src/gui/config/advancedpage.cpp	2007-08-13 16:49:44 UTC (rev 1829)
+++ trunk/src/gui/config/advancedpage.cpp	2007-08-13 16:49:53 UTC (rev 1830)
@@ -56,6 +56,8 @@
   
   /* Bind event to actions */
   connect(ui.btnBrowseTorConfig, SIGNAL(clicked()), this, SLOT(browseTorConfig()));
+  connect(ui.btnBrowseTorDataDirectory, SIGNAL(clicked()),
+          this, SLOT(browseTorDataDirectory()));
 
   /* Hide platform specific features */
 #if defined(Q_WS_WIN)
@@ -83,6 +85,7 @@
   _settings->setControlAddress(controlAddress);
   _settings->setControlPort(ui.lineControlPort->text().toUShort());
   _settings->setTorrc(ui.lineTorConfig->text());
+  _settings->setDataDirectory(ui.lineTorDataDirectory->text());
   _settings->setUser(ui.lineUser->text());
   _settings->setGroup(ui.lineGroup->text());
   
@@ -101,6 +104,7 @@
   ui.lineControlAddress->setText(_settings->getControlAddress().toString());
   ui.lineControlPort->setText(QString::number(_settings->getControlPort()));
   ui.lineTorConfig->setText(_settings->getTorrc());
+  ui.lineTorDataDirectory->setText(_settings->getDataDirectory());
   ui.lineUser->setText(_settings->getUser());
   ui.lineGroup->setText(_settings->getGroup());
 
@@ -152,6 +156,19 @@
   ui.lineTorConfig->setText(filename);
 }
 
+/** Opens a QFileDialog for the user to browse to or create a directory for
+ * Tor's DataDirectory. */
+void
+AdvancedPage::browseTorDataDirectory()
+{
+  QString dataDir = QFileDialog::getExistingDirectory(this,
+                      tr("Select a Directory to Use for Tor Data"),
+                      ui.lineTorDataDirectory->text());
+  
+  if (!dataDir.isEmpty()) 
+    ui.lineTorDataDirectory->setText(dataDir);
+}
+
 #if defined(Q_WS_WIN)
 /** Installs or removes the Tor service as necessary. */
 void

Modified: trunk/src/gui/config/advancedpage.h
===================================================================
--- trunk/src/gui/config/advancedpage.h	2007-08-13 16:49:44 UTC (rev 1829)
+++ trunk/src/gui/config/advancedpage.h	2007-08-13 16:49:53 UTC (rev 1830)
@@ -50,9 +50,13 @@
   void load();
 
 private slots:
-  /** Called when user clicks "Browse" to choose location of Tor config file */
+  /** Called when the user clicks "Browse" to choose location of Tor config 
+   * file */
   void browseTorConfig();
-  
+  /** Called when the user clicks "Browse" to choose the location of Tor's
+   * data directory. */
+  void browseTorDataDirectory();
+
 private:
 #if defined(Q_WS_WIN)
   /** Installs or removes the Tor service as necessary */

Modified: trunk/src/gui/config/advancedpage.ui
===================================================================
--- trunk/src/gui/config/advancedpage.ui	2007-08-13 16:49:44 UTC (rev 1829)
+++ trunk/src/gui/config/advancedpage.ui	2007-08-13 16:49:53 UTC (rev 1830)
@@ -652,6 +652,62 @@
     </widget>
    </item>
    <item>
+    <widget class="QGroupBox" name="grpTorDataDirectory" >
+     <property name="contextMenuPolicy" >
+      <enum>Qt::NoContextMenu</enum>
+     </property>
+     <property name="title" >
+      <string>Tor Data Directory</string>
+     </property>
+     <layout class="QHBoxLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item>
+       <widget class="QLineEdit" name="lineTorDataDirectory" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="cursor" >
+         <cursor>4</cursor>
+        </property>
+        <property name="contextMenuPolicy" >
+         <enum>Qt::NoContextMenu</enum>
+        </property>
+        <property name="toolTip" >
+         <string>Store Tor data in the following directory</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="btnBrowseTorDataDirectory" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="minimumSize" >
+         <size>
+          <width>0</width>
+          <height>0</height>
+         </size>
+        </property>
+        <property name="contextMenuPolicy" >
+         <enum>Qt::NoContextMenu</enum>
+        </property>
+        <property name="toolTip" >
+         <string>Select the directory used to store Tor data</string>
+        </property>
+        <property name="text" >
+         <string>Browse</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <widget class="QGroupBox" name="grpPermissions" >
      <property name="minimumSize" >
       <size>