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

[vidalia-svn] r3898: Don't display additional plaintext port warning message boxe (in vidalia/trunk: . src/vidalia)



Author: edmanm
Date: 2009-06-26 16:14:38 -0400 (Fri, 26 Jun 2009)
New Revision: 3898

Modified:
   vidalia/trunk/CHANGELOG
   vidalia/trunk/src/vidalia/MainWindow.cpp
Log:

Don't display additional plaintext port warning message boxes until 
the first visible message box is dismissed. Fixes half of ticket #493.
Also make the message box look better on OS X by moving a bulk of the
text to setInformativeText().


Modified: vidalia/trunk/CHANGELOG
===================================================================
--- vidalia/trunk/CHANGELOG	2009-06-26 04:57:58 UTC (rev 3897)
+++ vidalia/trunk/CHANGELOG	2009-06-26 20:14:38 UTC (rev 3898)
@@ -14,6 +14,8 @@
     output, and then again to actually start Tor.
   o Add a signal handler that allows Vidalia to clean up and exit normally
     when it catches a SIGINT or SIGTERM signal. (Ticket #481)
+  o Don't display additional plaintext port warning message boxes until
+    the first visible message box is dismissed. (Ticket #493)
   o Renamed the 'make win32-installer' CMake target to 'make dist-win32'
     for consistency with our 'make dist-osx' target.
   o Fix a couple bugs in the WiX-based Windows installer related to building

Modified: vidalia/trunk/src/vidalia/MainWindow.cpp
===================================================================
--- vidalia/trunk/src/vidalia/MainWindow.cpp	2009-06-26 04:57:58 UTC (rev 3897)
+++ vidalia/trunk/src/vidalia/MainWindow.cpp	2009-06-26 20:14:38 UTC (rev 3898)
@@ -1580,15 +1580,21 @@
 
 /** Called when Tor thinks the user has tried to connect to a port that
  * typically is used for unencrypted applications. Warns the user and allows
- * them to ignore future warnings on <b>port</b>. */
+ * them to ignore future warnings on <b>port</b>. It is possible that Tor
+ * will produce multiple asynchronous status events warning of dangerous ports
+ * while the message box is displayed (for example, while the user is away
+ * from the keyboard), so subsequent messages will be discarded until the
+ * first message box is dismissed. */
 void
 MainWindow::warnDangerousPort(quint16 port, bool rejected)
 {
-  QString warning, application;
-  QMessageBox dlg(QMessageBox::Warning,
-                  tr("Potentially Unsafe Connection"), QString(),
-                  QMessageBox::Ok | QMessageBox::Ignore);
+  static QMessageBox *dlg = 0;
 
+  /* Don't display another message box until the first one is dismissed */
+  if (dlg)
+    return;
+
+  QString application;
   switch (port) {
     case  23:
      application = tr(", probably Telnet, ");
@@ -1604,19 +1610,27 @@
       application = " ";
   }
 
-  warning = p(tr("One of your applications%1appears to be making a "
-                 "potentially unencrypted and unsafe connection to port %2. "
-                 "Anything sent over this connection could be monitored. "
-                 "Please check your application's configuration and use "
-                 "only encrypted protocols, such as SSL, if possible.")
-                 .arg(application).arg(port));
+  QString text = tr("One of your applications%1appears to be making a "
+                    "potentially unencrypted and unsafe connection to port %2.")
+                    .arg(application).arg(port);
+
+  QString extraText = p(tr("Anything sent over this connection could be "
+                           "monitored. Please check your application's "
+                           "configuration and use only encrypted protocols, "
+                           "such as SSL, if possible."));
   if (rejected) {
-    warning.append(p(tr("Tor has automatically closed your connection in "
-                        "order to protect your anonymity.")));
+    extraText.append(p(tr("Tor has automatically closed your connection in "
+                          "order to protect your anonymity.")));
   }
-  dlg.setText(warning);
 
-  int ret = dlg.exec();
+  dlg = new QMessageBox(QMessageBox::Warning,
+                        tr("Potentially Unsafe Connection"), text,
+                        QMessageBox::Ok | QMessageBox::Ignore);
+  dlg->setInformativeText(extraText);
+  dlg->setDefaultButton(QMessageBox::Ok);
+  dlg->setEscapeButton(QMessageBox::Ok);
+
+  int ret = dlg->exec();
   if (ret == QMessageBox::Ignore) {
     TorSettings settings;
     QList<quint16> ports;
@@ -1636,6 +1650,8 @@
       settings.setRejectPlaintextPorts(ports);
     }
   }
+  delete dlg;
+  dlg = 0;
 }
 
 /** Creates and displays Vidalia's About dialog. */