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

[vidalia-svn] r1650: Only allow 'New Identity' to be clicked once every 60 second (in trunk: . src/gui)



Author: edmanm
Date: 2007-02-24 13:33:46 -0500 (Sat, 24 Feb 2007)
New Revision: 1650

Modified:
   trunk/
   trunk/src/gui/mainwindow.cpp
   trunk/src/gui/mainwindow.h
Log:
 r1696@adrastea:  edmanm | 2007-02-24 13:27:07 -0500
 Only allow 'New Identity' to be clicked once every 60 seconds.



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

Modified: trunk/src/gui/mainwindow.cpp
===================================================================
--- trunk/src/gui/mainwindow.cpp	2007-02-24 18:33:17 UTC (rev 1649)
+++ trunk/src/gui/mainwindow.cpp	2007-02-24 18:33:46 UTC (rev 1650)
@@ -30,6 +30,7 @@
  */
 
 #include <QtGui>
+#include <QTimer>
 #include <vidalia.h>
 #include <util/html.h>
 
@@ -85,7 +86,10 @@
 #define IMG_TOR_STOPPING   ":/images/22x22/tor-stopping.png"
 #endif
 
+/** Only allow 'New Identity' to be clicked once every 60 seconds. */
+#define MIN_NEWIDENTITY_INTERVAL   (60*1000)
 
+
 /** Default constructor. It installs an icon in the system tray area and
  * creates the popup menu associated with that icon. */
 MainWindow::MainWindow()
@@ -564,6 +568,12 @@
     QString message = tr("All subsequent connections will "
                          "appear to be different than your "
                          "old connections.");
+
+    /* Disable the New Identity button for MIN_NEWIDENTITY_INTERVAL */
+    _newIdentityAct->setEnabled(false);
+    QTimer::singleShot(MIN_NEWIDENTITY_INTERVAL, 
+                       this, SLOT(enableNewIdentity()));
+    
 #if defined(USE_QSYSTEMTRAYICON)
     if (QSystemTrayIcon::supportsMessages()) {
       _trayIcon.showMessage(title, message, QSystemTrayIcon::Information);
@@ -580,3 +590,12 @@
   }
 }
 
+/** Re-enables the 'New Identity' button after a delay from the previous time
+ * 'New Identity' was used. */
+void
+MainWindow::enableNewIdentity()
+{
+  if (_torControl->isConnected())
+    _newIdentityAct->setEnabled(true);
+}
+

Modified: trunk/src/gui/mainwindow.h
===================================================================
--- trunk/src/gui/mainwindow.h	2007-02-24 18:33:17 UTC (rev 1649)
+++ trunk/src/gui/mainwindow.h	2007-02-24 18:33:46 UTC (rev 1650)
@@ -81,6 +81,9 @@
   void connectFailed(QString errmsg);
   /** Called when the control socket has been disconnected. */
   void disconnected();
+  /** Re-enables the 'New Identity' button after a delay from the previous time
+   * 'New Identity' was used. */
+  void enableNewIdentity();
   /** Called when the user selects the "New Identity" action from the menu. */
   void newIdentity();
   /** Called when the user exits Vidalia. */