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

[vidalia-svn] r2160: Register for CircuitEstablishedEvents and call circuitEstabl (in trunk: . src/gui)



Author: edmanm
Date: 2007-12-02 04:34:56 -0500 (Sun, 02 Dec 2007)
New Revision: 2160

Modified:
   trunk/
   trunk/src/gui/mainwindow.cpp
   trunk/src/gui/mainwindow.h
Log:
 r2201@lysithea:  edmanm | 2007-12-02 04:34:47 -0500
 Register for CircuitEstablishedEvents and call circuitEstablished() when the
 event is posted. Also check if there is a circuit established after we've
 authenticated to Tor, since Tor may have already been running (and already
 have sent a CIRCUIT_ESTABLISHED status event).



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r2201] on 0108964c-5b0b-4c9e-969f-e2288315d100

Modified: trunk/src/gui/mainwindow.cpp
===================================================================
--- trunk/src/gui/mainwindow.cpp	2007-12-02 09:30:18 UTC (rev 2159)
+++ trunk/src/gui/mainwindow.cpp	2007-12-02 09:34:56 UTC (rev 2160)
@@ -142,6 +142,7 @@
   connect(_torControl, SIGNAL(authenticated()), this, SLOT(authenticated()));
   connect(_torControl, SIGNAL(authenticationFailed(QString)),
                  this,   SLOT(authenticationFailed(QString)));
+  _torControl->setEvent(TorEvents::ClientStatus, this, true);
 
   /* Catch signals when the application is running or shutting down */
   connect(vApp, SIGNAL(running()), this, SLOT(running()));
@@ -191,6 +192,19 @@
 #endif
 }
 
+/** Catches and processes Tor client status events. */
+void
+MainWindow::customEvent(QEvent *event)
+{
+  if (event->type() == CustomEventType::ClientStatusEvent) {
+    ClientStatusEvent *cse = dynamic_cast<ClientStatusEvent *>(event);
+    if (cse && cse->status() == ClientStatusEvent::CircuitEstablished) {
+      circuitEstablished();
+      cse->accept();
+    }
+  }
+}
+
 /** Called when the application has started and the main event loop is
  * running. */
 void
@@ -465,10 +479,6 @@
   } else if (status == Authenticated) {
       trayIconFile = IMG_TOR_RUNNING;
       statusIconFile = IMG_TOR_RUNNING_48;
-
-      /* XXX: This function should be called when Tor has actually established
-       * a circuit, not just when we've connected to Tor. */
-      circuitEstablished();
   }
 
   /* Update the tray icon */
@@ -823,6 +833,11 @@
          + p(errmsg),
       VMessageBox::Ok);
   }
+  
+  /* Check if Tor has a circuit established */
+  if (_torControl->circuitEstablished())
+    circuitEstablished();
+
 }
 
 /** Called when Vidalia fails to authenticate to Tor. The failure reason is
@@ -920,13 +935,11 @@
   return QByteArray();
 }
 
-/** Called when Tor has successfully established a circuit.
- * TODO: Actually call this when Tor establishes a circuit, instead of simply
- * when we've connected to a running Tor. */
+/** Called when Tor has successfully established a circuit. */
 void
 MainWindow::circuitEstablished()
 {
-
+  vNotice("Tor has established a circuit.");
 }
 
 /** Creates and displays Vidalia's About dialog. */

Modified: trunk/src/gui/mainwindow.h
===================================================================
--- trunk/src/gui/mainwindow.h	2007-12-02 09:30:18 UTC (rev 2159)
+++ trunk/src/gui/mainwindow.h	2007-12-02 09:34:56 UTC (rev 2160)
@@ -29,8 +29,8 @@
 #define _MAINWINDOW_H
 
 #include <QMainWindow>
-
 #include <torcontrol.h>
+#include <circuitestablishedevent.h>
 
 /* QSystemTrayIcon appeared in Qt 4.2, but we need a bugfix to it on Mac 
  * that won't appear until Qt 4.2.2. */
@@ -62,6 +62,10 @@
   /** Destructor. */
   ~MainWindow();
 
+protected:
+  /** Catches and processes Tor client status events. */
+  virtual void customEvent(QEvent *event);
+
 private slots:
   /** Called when the user selects "Start" from the menu. */
   void start();