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

[vidalia-svn] r2698: Add initial support for the shiny, new BOOTSTRAP status even (in vidalia: . trunk/src/torcontrol)



Author: edmanm
Date: 2008-06-12 02:50:15 -0400 (Thu, 12 Jun 2008)
New Revision: 2698

Added:
   vidalia/trunk/src/torcontrol/bootstrapstatusevent.cpp
   vidalia/trunk/src/torcontrol/bootstrapstatusevent.h
Modified:
   vidalia/
   vidalia/trunk/src/torcontrol/CMakeLists.txt
   vidalia/trunk/src/torcontrol/clientstatusevent.cpp
   vidalia/trunk/src/torcontrol/clientstatusevent.h
   vidalia/trunk/src/torcontrol/tcglobal.cpp
   vidalia/trunk/src/torcontrol/torevents.cpp
   vidalia/trunk/src/torcontrol/torevents.h
Log:
 r514@thebe:  edmanm | 2008-06-12 02:42:36 -0400
 Add initial support for the shiny, new BOOTSTRAP status events.



Property changes on: vidalia
___________________________________________________________________
 svk:merge ticket from /local/vidalia [r514] on 45a62a8a-8088-484c-baad-c7b3e776dd32

Modified: vidalia/trunk/src/torcontrol/CMakeLists.txt
===================================================================
--- vidalia/trunk/src/torcontrol/CMakeLists.txt	2008-06-12 06:50:12 UTC (rev 2697)
+++ vidalia/trunk/src/torcontrol/CMakeLists.txt	2008-06-12 06:50:15 UTC (rev 2698)
@@ -13,6 +13,7 @@
 
 set(torcontrol_SRCS 
   addressmap.cpp
+  bootstrapstatusevent.cpp
   circuit.cpp
   clientstatusevent.cpp
   controlcommand.cpp

Added: vidalia/trunk/src/torcontrol/bootstrapstatusevent.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/bootstrapstatusevent.cpp	                        (rev 0)
+++ vidalia/trunk/src/torcontrol/bootstrapstatusevent.cpp	2008-06-12 06:50:15 UTC (rev 2698)
@@ -0,0 +1,66 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to the
+**  terms described in the LICENSE file.
+*/
+
+/* 
+** \file bootstrapstatusevent.cpp
+** \version $Id$
+** \brief Event sent by Tor when its bootstrapping status changes
+*/
+
+#include "bootstrapstatusevent.h"
+
+
+/** Constructor. */
+BootstrapStatusEvent::BootstrapStatusEvent(StatusEvent::Severity severity,
+                                           BootstrapStatus status,
+                                           int percentComplete,
+                                           const QString &description,
+                                           const QString &warning,
+                                           tc::ConnectionStatusReason reason)
+  : ClientStatusEvent(severity, ClientStatusEvent::BootstrapStatus)
+{
+  _status = status;
+  _percentComplete = qBound(0, percentComplete, 100);
+  _description = description;
+  _warning = warning;
+  _reason = reason;
+}
+
+/** Converts a string TAG value to a BootstrapStatus enum value. */
+BootstrapStatusEvent::BootstrapStatus
+BootstrapStatusEvent::statusFromString(const QString &str)
+{
+  if (!str.compare("CONN_DIR", Qt::CaseInsensitive))
+    return ConnectingToDirMirror;
+  if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive))
+    return HandshakingWithDirMirror;
+  if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive))
+    return CreatingOneHopCircuit;
+  if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive))
+    return RequestingNetworkStatus;
+  if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive))
+    return LoadingNetworkStatus;
+  if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive))
+    return LoadingAuthorityCertificates;
+  if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive))
+    return RequestingDescriptors;
+  if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive))
+    return LoadingDescriptors;
+  if (!str.compare("CONN_OR", Qt::CaseInsensitive))
+    return ConnectingToEntryGuard;
+  if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive))
+    return HandshakingWithEntryGuard;
+  if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive))
+    return EstablishingCircuit;
+  if (!str.compare("DONE", Qt::CaseInsensitive))
+    return BootstrappingDone;
+  return UnrecognizedStatus;
+}
+


Property changes on: vidalia/trunk/src/torcontrol/bootstrapstatusevent.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: vidalia/trunk/src/torcontrol/bootstrapstatusevent.h
===================================================================
--- vidalia/trunk/src/torcontrol/bootstrapstatusevent.h	                        (rev 0)
+++ vidalia/trunk/src/torcontrol/bootstrapstatusevent.h	2008-06-12 06:50:15 UTC (rev 2698)
@@ -0,0 +1,109 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to the
+**  terms described in the LICENSE file.
+*/
+
+/* 
+** \file bootstrapstatusevent.h
+** \version $Id$
+** \brief Event sent by Tor when its bootstrapping status changes
+*/
+
+#ifndef _BOOTSTRAPSTATUSEVENT_H
+#define _BOOTSTRAPSTATUSEVENT_H
+
+#include <QEvent>
+#include <QString>
+#include "clientstatusevent.h"
+#include "tcglobal.h"
+
+
+class BootstrapStatusEvent : public ClientStatusEvent
+{
+public:
+  /** Currently enumerated bootstrapping states defined by Tor's control
+   * protocol (Tor >= 0.2.1.0-alpha-dev. */ 
+  enum BootstrapStatus {
+    UnrecognizedStatus,
+    ConnectingToDirMirror,
+    HandshakingWithDirMirror,
+    CreatingOneHopCircuit,
+    RequestingNetworkStatus,
+    LoadingNetworkStatus,
+    LoadingAuthorityCertificates,
+    RequestingDescriptors,
+    LoadingDescriptors,
+    ConnectingToEntryGuard,
+    HandshakingWithEntryGuard,
+    EstablishingCircuit,
+    BootstrappingDone
+  };
+
+  /** Constructor. */
+  BootstrapStatusEvent(StatusEvent::Severity severity,
+                       BootstrapStatus status, int percentComplete,
+                       const QString &description,
+                       const QString &warning = QString(),
+                       tc::ConnectionStatusReason reason = tc::UnrecognizedReason);
+
+  /** Returns the BootstrapStatus enum value indicated by this bootstrap
+   * status event. */
+  BootstrapStatus status() const { return _status; }
+
+  /** Returns an integer between 0 and 100 representing an estimate of how
+   * much of Tor's bootstrapping process it has completed. */
+  int percentComplete() const { return _percentComplete; }
+
+  /** Returns a description of Tor's current bootstrapping status. */
+  QString description() const { return _description; }
+  
+  /** Returns a description of the most recent error Tor encountered while
+   * attempting to bootstrap, if this event's severity is 'warn'. Otherwise,
+   * this returns a default-constructed QString. */
+  QString warning() const { return _warning; }
+
+  /** Returns a ConnectionStatusReason enum value describing the most recent
+   * error Tor encountered while attempting to bootstrap, if this event's
+   * severity is 'warn'. Otherwise, this simply returns
+   * tc::UnrecognizedReason. */
+  tc::ConnectionStatusReason reason() const { return _reason; }
+
+  /** Converts a string TAG value to a BootstrapStatus enum value. */
+  static BootstrapStatus statusFromString(const QString &tag);
+
+private:
+  /** Current bootstrapping status value.
+   * \sa status
+   */ 
+  BootstrapStatus _status;
+  
+  /** Approximate percentage of Tor's bootstrapping process that is complete.
+   * \sa percentComplete
+   */
+  int _percentComplete;
+  
+  /** Description of Tor's current bootstrapping status.
+   * \sa description
+   */
+  QString _description;
+  
+  /** Description of the most recent error Tor encountered while attempting to
+   * bootstrap. 
+   * \sa warning
+   */
+  QString _warning;
+
+  /** ConnectionStatusReason enum value describing the most recent error Tor
+   * encountered while attempting to bootstrap.
+   * \sa reason
+   */
+  tc::ConnectionStatusReason _reason;
+};
+
+#endif
+


Property changes on: vidalia/trunk/src/torcontrol/bootstrapstatusevent.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: vidalia/trunk/src/torcontrol/clientstatusevent.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/clientstatusevent.cpp	2008-06-12 06:50:12 UTC (rev 2697)
+++ vidalia/trunk/src/torcontrol/clientstatusevent.cpp	2008-06-12 06:50:15 UTC (rev 2698)
@@ -36,6 +36,8 @@
     return UnknownSocksProtocol;
   if (!str.compare("SOCKS_BAD_HOSTNAME", Qt::CaseInsensitive))
     return SocksBadHostname;
+  if (!str.compare("BOOTSTRAP", Qt::CaseInsensitive))
+    return BootstrapStatus;
   return UnrecognizedStatus;
 }
 

Modified: vidalia/trunk/src/torcontrol/clientstatusevent.h
===================================================================
--- vidalia/trunk/src/torcontrol/clientstatusevent.h	2008-06-12 06:50:12 UTC (rev 2697)
+++ vidalia/trunk/src/torcontrol/clientstatusevent.h	2008-06-12 06:50:15 UTC (rev 2698)
@@ -26,6 +26,7 @@
   /** Tor client status event type. */
   enum Status {
     UnrecognizedStatus,
+    BootstrapStatus,
     CircuitEstablished,
     CircuitNotEstablished,
     NotEnoughDirectoryInfo,

Modified: vidalia/trunk/src/torcontrol/tcglobal.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/tcglobal.cpp	2008-06-12 06:50:12 UTC (rev 2697)
+++ vidalia/trunk/src/torcontrol/tcglobal.cpp	2008-06-12 06:50:15 UTC (rev 2698)
@@ -55,6 +55,8 @@
 ConnectionStatusReason
 connectionStatusReason(const QString &str)
 {
+  if (str.isEmpty())
+    return UnrecognizedReason;
   if (!str.compare("MISC", Qt::CaseInsensitive))
     return MiscellaneousReason;
   if (!str.compare("IDENTITY", Qt::CaseInsensitive))

Modified: vidalia/trunk/src/torcontrol/torevents.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torevents.cpp	2008-06-12 06:50:12 UTC (rev 2697)
+++ vidalia/trunk/src/torcontrol/torevents.cpp	2008-06-12 06:50:15 UTC (rev 2698)
@@ -25,6 +25,7 @@
 #include "unrecognizedgeneralstatusevent.h"
 #include "circuitestablishedevent.h"
 #include "dangerousversionevent.h"
+#include "bootstrapstatusevent.h"
 
 /** Format of expiry times in address map events. */
 #define DATE_FMT "\"yyyy-MM-dd HH:mm:ss\""
@@ -404,6 +405,16 @@
   switch (status) {
     case ClientStatusEvent::CircuitEstablished:
       event = new CircuitEstablishedEvent(severity); break;
+    
+    case ClientStatusEvent::BootstrapStatus:
+      event = new BootstrapStatusEvent(severity,
+                    BootstrapStatusEvent::statusFromString(args.value("TAG")),
+                    args.value("PROGRESS").toInt(),
+                    args.value("SUMMARY"),
+                    args.value("WARNING"),
+                    tc::connectionStatusReason(args.value("REASON")));
+      break;
+
     default:
       event = new UnrecognizedClientStatusEvent(severity, action, args);
   }

Modified: vidalia/trunk/src/torcontrol/torevents.h
===================================================================
--- vidalia/trunk/src/torcontrol/torevents.h	2008-06-12 06:50:12 UTC (rev 2697)
+++ vidalia/trunk/src/torcontrol/torevents.h	2008-06-12 06:50:15 UTC (rev 2698)
@@ -117,7 +117,6 @@
   void dispatchGeneralStatusEvent(StatusEvent::Severity severity,
                                   const QString &action,
                                   const QHash<QString,QString> &args);
-
 };
 
 #endif