Vidalia 0.3.1
BootstrapStatus.cpp
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.cpp
13** \brief Describes the Tor software's current bootstrapping status
14*/
15
16#include "BootstrapStatus.h"
17
18
20{
26}
27
28/** Constructor. */
30 int percentComplete,
31 const QString &description,
32 const QString &warning,
34 Recommendation action)
35{
38 _percentComplete = qBound(0, percentComplete, 100);
42 _action = action;
43}
44
45/** Converts a string TAG value to a BootstrapStatus enum value. */
48{
49 if (!str.compare("CONN_DIR", Qt::CaseInsensitive))
51 if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive))
53 if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive))
55 if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive))
57 if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive))
59 if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive))
61 if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive))
63 if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive))
64 return LoadingDescriptors;
65 if (!str.compare("CONN_OR", Qt::CaseInsensitive))
67 if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive))
69 if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive))
71 if (!str.compare("DONE", Qt::CaseInsensitive))
72 return BootstrappingDone;
73 return UnrecognizedStatus;
74}
75
76/** Returns the action that the Tor software recommended be taken in response
77 * to this bootstrap status. */
80{
81 if (!str.compare("WARN", Qt::CaseInsensitive))
82 return RecommendWarn;
83 if (!str.compare("IGNORE", Qt::CaseInsensitive))
84 return RecommendIgnore;
86}
87
88/** Returns true if this object represents a valid bootstrap status phase. */
89bool
91{
94 && _percentComplete >= 0);
95}
96
bool isValid() const
int percentComplete() const
QString description() const
static Status statusFromString(const QString &tag)
QString warning() const
tc::ConnectionStatusReason _reason
static Recommendation actionFromString(const QString &str)
tc::Severity _severity
Recommendation _action
tc::Severity severity() const
tc::ConnectionStatusReason reason() const
Status status() const
ConnectionStatusReason
Definition: tcglobal.h:56
@ UnrecognizedReason
Definition: tcglobal.h:57
Severity
Definition: tcglobal.h:69
@ UnrecognizedSeverity
Definition: tcglobal.h:70