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

[vidalia-svn] r2781: Damn you, 'svn add'. (vidalia/trunk/src/torcontrol)



Author: edmanm
Date: 2008-06-21 17:50:09 -0400 (Sat, 21 Jun 2008)
New Revision: 2781

Added:
   vidalia/trunk/src/torcontrol/bootstrapstatus.cpp
   vidalia/trunk/src/torcontrol/bootstrapstatus.h
Log:
Damn you, 'svn add'.


Added: vidalia/trunk/src/torcontrol/bootstrapstatus.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/bootstrapstatus.cpp	                        (rev 0)
+++ vidalia/trunk/src/torcontrol/bootstrapstatus.cpp	2008-06-21 21:50:09 UTC (rev 2781)
@@ -0,0 +1,97 @@
+/*
+**  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: bootstrapstatusevent.cpp 2772 2008-06-20 23:36:05Z edmanm $
+** \brief  sent by Tor when its bootstrapping status changes
+*/
+
+#include "bootstrapstatus.h"
+
+
+BootstrapStatus::BootstrapStatus()
+{
+  _severity = tc::UnrecognizedSeverity;
+  _reason   = tc::UnrecognizedReason;
+  _status   = UnrecognizedStatus;
+  _action   = UnrecognizedRecommendation;
+  _percentComplete = -1;
+}
+
+/** Constructor. */
+BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status, 
+                                 int percentComplete,
+                                 const QString &description,
+                                 const QString &warning,
+                                 tc::ConnectionStatusReason reason,
+                                 Recommendation action)
+{
+  _severity = severity;
+  _status = status;
+  _percentComplete = qBound(0, percentComplete, 100);
+  _description = description;
+  _warning = warning;
+  _reason = reason;
+  _action = action;
+}
+
+/** Converts a string TAG value to a BootstrapStatus enum value. */
+BootstrapStatus::Status
+BootstrapStatus::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;
+}
+
+/** Returns the action that the Tor software recommended be taken in response
+ * to this bootstrap status. */
+BootstrapStatus::Recommendation
+BootstrapStatus::actionFromString(const QString &str)
+{
+  if (!str.compare("WARN", Qt::CaseInsensitive))
+    return RecommendWarn;
+  if (!str.compare("IGNORE", Qt::CaseInsensitive))
+    return RecommendIgnore;
+  return UnrecognizedRecommendation;
+}
+
+/** Returns true if this object represents a valid bootstrap status phase. */
+bool
+BootstrapStatus::isValid() const
+{
+  return (_severity != tc::UnrecognizedSeverity
+            && _status != UnrecognizedStatus
+            && _percentComplete >= 0);
+}
+

Added: vidalia/trunk/src/torcontrol/bootstrapstatus.h
===================================================================
--- vidalia/trunk/src/torcontrol/bootstrapstatus.h	                        (rev 0)
+++ vidalia/trunk/src/torcontrol/bootstrapstatus.h	2008-06-21 21:50:09 UTC (rev 2781)
@@ -0,0 +1,143 @@
+/*
+**  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 bootstrapstatus.h
+** \version $Id: bootstrapstatusevent.h 2772 2008-06-20 23:36:05Z edmanm $
+** \brief Describes the Tor software's current bootstrap status
+*/
+
+#ifndef _BOOTSTRAPSTATUS_H
+#define _BOOTSTRAPSTATUS_H
+
+#include <QString>
+#include "tcglobal.h"
+
+
+class BootstrapStatus
+{
+public:
+  /** Currently enumerated bootstrapping states defined by Tor's control
+   * protocol (Tor >= 0.2.1.0-alpha-dev. */ 
+  enum Status {
+    UnrecognizedStatus,
+    ConnectingToDirMirror,
+    HandshakingWithDirMirror,
+    CreatingOneHopCircuit,
+    RequestingNetworkStatus,
+    LoadingNetworkStatus,
+    LoadingAuthorityCertificates,
+    RequestingDescriptors,
+    LoadingDescriptors,
+    ConnectingToEntryGuard,
+    HandshakingWithEntryGuard,
+    EstablishingCircuit,
+    BootstrappingDone
+  };
+  /** Actions the Tor software might recommend controllers take in response to
+   * a bootstrap status problem event. */
+  enum Recommendation {
+    UnrecognizedRecommendation,
+    RecommendIgnore,
+    RecommendWarn
+  };
+
+  /** Default constructor. */
+  BootstrapStatus();
+
+  /** Constructor. */
+  BootstrapStatus(tc::Severity severity,
+                  Status status, int percentComplete,
+                  const QString &description,
+                  const QString &warning = QString(),
+                  tc::ConnectionStatusReason reason = tc::UnrecognizedReason,
+                  Recommendation action = UnrecognizedRecommendation);
+
+  /** Returns the severity of this bootstrap status event. */
+  tc::Severity severity() const { return _severity; }
+
+  /** Returns the BootstrapStatus enum value indicated by this bootstrap
+   * status event. */
+  Status 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; }
+
+  /** Returns the action that the Tor software recommended be taken in
+   * response to this bootstrap status event. */ 
+  Recommendation recommendedAction() const { return _action; }
+
+  /** Returns true if this object represents a valid bootstrap status
+   * phase. */
+  bool isValid() const;
+
+  /** Converts a string TAG value to a BootstrapStatus enum value. */
+  static Status statusFromString(const QString &tag);
+  /** Converts a string RECOMMENDATION value to a RecommendAction enum
+   * value. */
+  static Recommendation actionFromString(const QString &str);
+
+private:
+  /** Severity of the current bootstrap status.
+   * \sa severity
+   */
+  tc::Severity _severity;
+
+  /** Current bootstrapping status value.
+   * \sa status
+   */ 
+  Status _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;
+
+  /** Recommendation enum value describing Tor's suggested response to this
+   * bootstrap status event.
+   * \sa recommendedAction
+   */
+  Recommendation _action;
+};
+
+#endif
+