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

[vidalia-svn] r3126: Hide the "Reset" button on non-Windowses or if we can't find (vidalia/trunk/src/vidalia)



Author: edmanm
Date: 2008-09-21 17:23:50 -0400 (Sun, 21 Sep 2008)
New Revision: 3126

Modified:
   vidalia/trunk/src/vidalia/mainwindow.cpp
Log:
Hide the "Reset" button on non-Windowses or if we can't find a "tor.exe" in
the running process list.


Modified: vidalia/trunk/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/trunk/src/vidalia/mainwindow.cpp	2008-09-21 21:21:40 UTC (rev 3125)
+++ vidalia/trunk/src/vidalia/mainwindow.cpp	2008-09-21 21:23:50 UTC (rev 3126)
@@ -28,6 +28,7 @@
 #include <clientstatusevent.h>
 #include <dangerousversionevent.h>
 #include <vmessagebox.h>
+#include <procutil.h>
 
 #include "mainwindow.h"
 #include "controlpasswordinputdialog.h"
@@ -1156,7 +1157,21 @@
   /* Parsing log messages is evil, but we're left with little option */
   if (errmsg.contains("Password did not match")) {
     ControlPasswordInputDialog dlg;
+    qint64 torPid = 0;
 
+#if defined(Q_OS_WIN32)
+    QHash<qint64, QString> procs = process_list();
+    foreach (qint64 pid, procs) {
+      if (! procs.value(pid).compare("tor.exe", Qt::CaseInsensitive)) {
+        torPid = pid;
+        break;
+      }
+    }
+    dlg.setResetEnabled(torPid > 0);
+#else
+    dlg.setResetEnabled(false);
+#endif
+
     int ret = dlg.exec();
     if (ret == QDialogButtonBox::Ok) {
       if (dlg.isSavePasswordChecked()) {
@@ -1171,9 +1186,12 @@
       }
       retry = true;
     } else if (ret == QDialogButtonBox::Reset) {
-      /* TODO: Try to kill the existing Tor and restart it with a password
-       * we actually know.
-       */
+      QString processError;
+      if (! process_kill(torPid, &processError)) {
+        /* TODO: Display a helpful error message. */
+      } else {
+        retry = true;
+      }
     }
   } else {
     /* Something else went wrong */