Vidalia 0.2.10
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file BootstrapStatus.h 00013 ** \version $Id: BootstrapStatus.h 4054 2009-08-17 02:25:08Z edmanm $ 00014 ** \brief Describes the Tor software's current bootstrap status 00015 */ 00016 00017 #ifndef _BOOTSTRAPSTATUS_H 00018 #define _BOOTSTRAPSTATUS_H 00019 00020 #include "tcglobal.h" 00021 00022 #include <QString> 00023 #include <QMetaType> 00024 00025 00026 class BootstrapStatus 00027 { 00028 public: 00029 /** Currently enumerated bootstrapping states defined by Tor's control 00030 * protocol (Tor >= 0.2.1.0-alpha-dev. */ 00031 enum Status { 00032 UnrecognizedStatus, 00033 ConnectingToDirMirror, 00034 HandshakingWithDirMirror, 00035 CreatingOneHopCircuit, 00036 RequestingNetworkStatus, 00037 LoadingNetworkStatus, 00038 LoadingAuthorityCertificates, 00039 RequestingDescriptors, 00040 LoadingDescriptors, 00041 ConnectingToEntryGuard, 00042 HandshakingWithEntryGuard, 00043 EstablishingCircuit, 00044 BootstrappingDone 00045 }; 00046 /** Actions the Tor software might recommend controllers take in response to 00047 * a bootstrap status problem event. */ 00048 enum Recommendation { 00049 UnrecognizedRecommendation, 00050 RecommendIgnore, 00051 RecommendWarn 00052 }; 00053 00054 /** Default constructor. */ 00055 BootstrapStatus(); 00056 00057 /** Constructor. */ 00058 BootstrapStatus(tc::Severity severity, 00059 Status status, int percentComplete, 00060 const QString &description, 00061 const QString &warning = QString(), 00062 tc::ConnectionStatusReason reason = tc::UnrecognizedReason, 00063 Recommendation action = UnrecognizedRecommendation); 00064 00065 /** Returns the severity of this bootstrap status event. */ 00066 tc::Severity severity() const { return _severity; } 00067 00068 /** Returns the BootstrapStatus enum value indicated by this bootstrap 00069 * status event. */ 00070 Status status() const { return _status; } 00071 00072 /** Returns an integer between 0 and 100 representing an estimate of how 00073 * much of Tor's bootstrapping process it has completed. */ 00074 int percentComplete() const { return _percentComplete; } 00075 00076 /** Returns a description of Tor's current bootstrapping status. */ 00077 QString description() const { return _description; } 00078 00079 /** Returns a description of the most recent error Tor encountered while 00080 * attempting to bootstrap, if this event's severity is 'warn'. Otherwise, 00081 * this returns a default-constructed QString. */ 00082 QString warning() const { return _warning; } 00083 00084 /** Returns a ConnectionStatusReason enum value describing the most recent 00085 * error Tor encountered while attempting to bootstrap, if this event's 00086 * severity is 'warn'. Otherwise, this simply returns 00087 * tc::UnrecognizedReason. */ 00088 tc::ConnectionStatusReason reason() const { return _reason; } 00089 00090 /** Returns the action that the Tor software recommended be taken in 00091 * response to this bootstrap status event. */ 00092 Recommendation recommendedAction() const { return _action; } 00093 00094 /** Returns true if this object represents a valid bootstrap status 00095 * phase. */ 00096 bool isValid() const; 00097 00098 /** Converts a string TAG value to a BootstrapStatus enum value. */ 00099 static Status statusFromString(const QString &tag); 00100 /** Converts a string RECOMMENDATION value to a RecommendAction enum 00101 * value. */ 00102 static Recommendation actionFromString(const QString &str); 00103 00104 private: 00105 /** Severity of the current bootstrap status. 00106 * \sa severity 00107 */ 00108 tc::Severity _severity; 00109 00110 /** Current bootstrapping status value. 00111 * \sa status 00112 */ 00113 Status _status; 00114 00115 /** Approximate percentage of Tor's bootstrapping process that is complete. 00116 * \sa percentComplete 00117 */ 00118 int _percentComplete; 00119 00120 /** Description of Tor's current bootstrapping status. 00121 * \sa description 00122 */ 00123 QString _description; 00124 00125 /** Description of the most recent error Tor encountered while attempting to 00126 * bootstrap. 00127 * \sa warning 00128 */ 00129 QString _warning; 00130 00131 /** ConnectionStatusReason enum value describing the most recent error Tor 00132 * encountered while attempting to bootstrap. 00133 * \sa reason 00134 */ 00135 tc::ConnectionStatusReason _reason; 00136 00137 /** Recommendation enum value describing Tor's suggested response to this 00138 * bootstrap status event. 00139 * \sa recommendedAction 00140 */ 00141 Recommendation _action; 00142 }; 00143 00144 Q_DECLARE_METATYPE(BootstrapStatus); 00145 00146 #endif 00147