Vidalia  0.2.21
BootstrapStatus.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file BootstrapStatus.h
13 ** \brief Describes the Tor software's current bootstrap status
14 */
15 
16 #ifndef _BOOTSTRAPSTATUS_H
17 #define _BOOTSTRAPSTATUS_H
18 
19 #include "tcglobal.h"
20 
21 #include <QString>
22 #include <QMetaType>
23 
24 
26 {
27 public:
28  /** Currently enumerated bootstrapping states defined by Tor's control
29  * protocol (Tor >= 0.2.1.0-alpha-dev. */
30  enum Status {
44  };
45  /** Actions the Tor software might recommend controllers take in response to
46  * a bootstrap status problem event. */
51  };
52 
53  /** Default constructor. */
55 
56  /** Constructor. */
59  const QString &description,
60  const QString &warning = QString(),
63 
64  /** Returns the severity of this bootstrap status event. */
65  tc::Severity severity() const { return _severity; }
66 
67  /** Returns the BootstrapStatus enum value indicated by this bootstrap
68  * status event. */
69  Status status() const { return _status; }
70 
71  /** Returns an integer between 0 and 100 representing an estimate of how
72  * much of Tor's bootstrapping process it has completed. */
73  int percentComplete() const { return _percentComplete; }
74 
75  /** Returns a description of Tor's current bootstrapping status. */
76  QString description() const { return _description; }
77 
78  /** Returns a description of the most recent error Tor encountered while
79  * attempting to bootstrap, if this event's severity is 'warn'. Otherwise,
80  * this returns a default-constructed QString. */
81  QString warning() const { return _warning; }
82 
83  /** Returns a ConnectionStatusReason enum value describing the most recent
84  * error Tor encountered while attempting to bootstrap, if this event's
85  * severity is 'warn'. Otherwise, this simply returns
86  * tc::UnrecognizedReason. */
88 
89  /** Returns the action that the Tor software recommended be taken in
90  * response to this bootstrap status event. */
92 
93  /** Returns true if this object represents a valid bootstrap status
94  * phase. */
95  bool isValid() const;
96 
97  /** Converts a string TAG value to a BootstrapStatus enum value. */
98  static Status statusFromString(const QString &tag);
99  /** Converts a string RECOMMENDATION value to a RecommendAction enum
100  * value. */
101  static Recommendation actionFromString(const QString &str);
102 
103 private:
104  /** Severity of the current bootstrap status.
105  * \sa severity
106  */
108 
109  /** Current bootstrapping status value.
110  * \sa status
111  */
113 
114  /** Approximate percentage of Tor's bootstrapping process that is complete.
115  * \sa percentComplete
116  */
118 
119  /** Description of Tor's current bootstrapping status.
120  * \sa description
121  */
122  QString _description;
123 
124  /** Description of the most recent error Tor encountered while attempting to
125  * bootstrap.
126  * \sa warning
127  */
128  QString _warning;
129 
130  /** ConnectionStatusReason enum value describing the most recent error Tor
131  * encountered while attempting to bootstrap.
132  * \sa reason
133  */
135 
136  /** Recommendation enum value describing Tor's suggested response to this
137  * bootstrap status event.
138  * \sa recommendedAction
139  */
141 };
142 
144 
145 #endif
146