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

[tor-commits] [vidalia/alpha] Adapt MainWindow behavior



commit b32177a35c890073225ed863fb115e10166e1cf2
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Fri Feb 3 22:38:19 2012 -0300

    Adapt MainWindow behavior
    
    We don't want to launch tor with so many arguments, we handle those through
    the torrc file.
    Also adapt the "remember previous random ports used" fix.
---
 src/vidalia/MainWindow.cpp |   49 +++++++++++++++++--------------------------
 1 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index c3b1954..f7c67e1 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -620,8 +620,6 @@ MainWindow::start()
   /* Specify Tor's data directory, if different from the default */
   QString dataDirectory = settings.getDataDirectory();
   QString expDataDirectory = expand_filename(dataDirectory);
-  if (!dataDirectory.isEmpty())
-    args << "DataDirectory" << expDataDirectory;
   
   if(settings.getControlMethod() == ControlMethod::Port) {
     if(settings.autoControlPort()) {
@@ -629,30 +627,15 @@ MainWindow::start()
       if(!QFile::remove(portconf))
         vWarn(QString("Unable to remove %1, may be it didn't existed.").arg(portconf));
 
-      QString control_str = "auto";
-      QString socks_str = "auto";
-
       if(!_previousControlPort.isEmpty()) {
-        control_str = _previousControlPort;
+        Vidalia::torrc()->setValue("ControlPort", _previousControlPort);
         _startedWithPrevious = true;
       }
       if(!_previousSocksPort.isEmpty()) {
-        socks_str = _previousSocksPort;
+        Vidalia::torrc()->setValue("ControlPort", _previousSocksPort);
         _startedWithPrevious = true;
       }
-
-      args << "ControlPort" << control_str;
-      args << "SocksPort" << socks_str;
-      args << "ControlPortWriteToFile" << QString("%1/port.conf").arg(expDataDirectory);
-    } else {
-      /* Add the intended control port value */
-      quint16 controlPort = settings.getControlPort();
-      if (controlPort)
-        args << "ControlPort" << QString::number(controlPort);
     }
-  } else {
-    QString path = settings.getSocketPath();
-    args << "ControlSocket" << path;
   }
 
   args << "__OwningControllerProcess" << QString::number(QCoreApplication::applicationPid());
@@ -664,20 +647,15 @@ MainWindow::start()
         if (settings.useRandomPassword()) {
           _controlPassword = TorSettings::randomPassword();
           _useSavedPassword = false;
-        } else {
-          _controlPassword = settings.getControlPassword();
+          Vidalia::torrc()->setValue("HashedControlPassword",
+                                     TorSettings::hashPassword(_controlPassword));
+          Vidalia::torrc()->apply(Vidalia::torControl(), new QString());
+        } else
           _useSavedPassword = true;
-        }
       }
-      args << "HashedControlPassword"
-           << TorSettings::hashPassword(_controlPassword);
-
-      break;
-    case TorSettings::CookieAuth:
-      args << "CookieAuthentication"  << "1";
       break;
     default:
-      args << "CookieAuthentication"  << "0";
+      break;
   }
 
   /* This doesn't get set to false until Tor is actually up and running, so we
@@ -753,10 +731,16 @@ MainWindow::started()
     /* Try to connect to Tor's control port */
     if(settings.getControlMethod() == ControlMethod::Port)
       _torControl->connect(settings.getControlAddress(),
-                          settings.getControlPort());
+                           settings.getControlPort());
     else
       _torControl->connect(settings.getSocketPath());
   }
+  // If we used the previous ports, set the *Port to auto again
+  if(_startedWithPrevious) {
+    Vidalia::torrc()->setValue("ControlPort", "auto");
+    Vidalia::torrc()->setValue("SocksPort", "auto");
+    Vidalia::torrc()->apply(Vidalia::torControl());
+  }
   setStartupProgress(STARTUP_PROGRESS_CONNECTING, tr("Connecting to Tor"));
 }
 
@@ -867,6 +851,9 @@ MainWindow::startFailed(QString errmsg)
     _startedWithPrevious = false;
     _previousControlPort = "";
     _previousSocksPort = "";
+    Vidalia::torrc()->setValue("ControlPort", "auto");
+    Vidalia::torrc()->setValue("SocksPort", "auto");
+    Vidalia::torrc()->apply(Vidalia::torControl());
     vWarn("Retrying with new ports");
     start();
     return;
@@ -1666,6 +1653,8 @@ MainWindow::showConfigDialog(ConfigDialog::Page page)
   ConfigDialog *configDialog = new ConfigDialog();
   connect(configDialog, SIGNAL(helpRequested(QString)),
           this, SLOT(showHelpDialog(QString)));
+  connect(configDialog, SIGNAL(restartTor()),
+          this, SLOT(restart()));
   configDialog->showWindow(page);
 }
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits