[tor-commits] [vidalia/alpha] Handle NEWCONSENSUS status events

chiiph at torproject.org chiiph at torproject.org
Sat Mar 17 17:01:07 UTC 2012


commit ca1dac3571f35dd2977132100c6051af7be8e6e5
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Sat Mar 17 13:51:19 2012 -0300

    Handle NEWCONSENSUS status events
---
 src/torcontrol/TorEvents.cpp |   16 ++++++++++++++++
 src/torcontrol/TorEvents.h   |   10 ++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/torcontrol/TorEvents.cpp b/src/torcontrol/TorEvents.cpp
index fba9c52..db337e5 100644
--- a/src/torcontrol/TorEvents.cpp
+++ b/src/torcontrol/TorEvents.cpp
@@ -65,6 +65,7 @@ TorEvents::toString(Event e)
     case GeneralStatus:   event = "STATUS_GENERAL"; break;
     case ClientStatus:    event = "STATUS_CLIENT"; break;
     case ServerStatus:    event = "STATUS_SERVER"; break;
+    case NewConsensus:    event = "NEWCONSENSUS"; break;
     default: event = "UNKNOWN"; break;
   }
   return event;
@@ -101,6 +102,8 @@ TorEvents::toTorEvent(const QString &event)
     e = ClientStatus;
   } else if (event == "STATUS_SERVER") {
     e = ServerStatus;
+  } else if (event == "NEWCONSENSUS") {
+    e = NewConsensus;
   } else {
     e = Unknown;
   }
@@ -129,6 +132,7 @@ TorEvents::handleEvent(const ControlReply &reply)
       case CircuitStatus:  handleCircuitStatus(line); break;
       case StreamStatus:   handleStreamStatus(line); break;
       case NewDescriptor:  handleNewDescriptor(line); break;
+      case NewConsensus:   handleNewConsensus(line); break;
       case AddressMap:     handleAddressMap(line); break;
 
       case GeneralStatus:
@@ -254,6 +258,18 @@ TorEvents::handleNewDescriptor(const ReplyLine &line)
   emit newDescriptors(descList);
 }
 
+/** Handles a new consensus event. The format for event messages of this type
+ * is:
+ *
+ *   "650" SP "NEWCONSENSUS" CRLF (...)
+ */
+void
+TorEvents::handleNewConsensus(const ReplyLine &line)
+{
+  Q_UNUSED(line);
+  emit newConsensus();
+}
+
 /** Handles a new or updated address mapping event. The format for event
  * messages of this type is:
  *
diff --git a/src/torcontrol/TorEvents.h b/src/torcontrol/TorEvents.h
index ccc01e0..832034d 100644
--- a/src/torcontrol/TorEvents.h
+++ b/src/torcontrol/TorEvents.h
@@ -55,10 +55,11 @@ public:
     AddressMap    = (1u << 10),
     GeneralStatus = (1u << 11),
     ClientStatus  = (1u << 12),
-    ServerStatus  = (1u << 13)
+    ServerStatus  = (1u << 13),
+    NewConsensus  = (1u << 14),
   };
   static const Event EVENT_MIN = TorEvents::Bandwidth;
-  static const Event EVENT_MAX = TorEvents::ServerStatus;
+  static const Event EVENT_MAX = TorEvents::NewConsensus;
   Q_DECLARE_FLAGS(Events, Event);
 
   /** Default Constructor */
@@ -103,6 +104,9 @@ signals:
    */
   void newDescriptors(const QStringList &ids);
 
+  /** Emitted when Tor has received a new consensus. */
+  void newConsensus();
+
   /** Indicates Tor has been able to successfully establish one or more
    * circuits.
    */
@@ -229,6 +233,8 @@ private:
   void handleOrConnStatus(const ReplyLine &line);
   /** Handles a new list of descriptors event. */
   void handleNewDescriptor(const ReplyLine &line);
+  /** Handles a new consensus event. */
+  void handleNewConsensus(const ReplyLine &line);
   /** Handles a new or updated address map event. */
   void handleAddressMap(const ReplyLine &line);
 





More information about the tor-commits mailing list