Vidalia
0.2.21
Main Page
Namespaces
Classes
Files
File List
File Members
src
torcontrol
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
19
BootstrapStatus::BootstrapStatus
()
20
{
21
_severity
=
tc::UnrecognizedSeverity
;
22
_reason
=
tc::UnrecognizedReason
;
23
_status
=
UnrecognizedStatus
;
24
_action
=
UnrecognizedRecommendation
;
25
_percentComplete
= -1;
26
}
27
28
/** Constructor. */
29
BootstrapStatus::BootstrapStatus
(
tc::Severity
severity,
Status
status,
30
int
percentComplete,
31
const
QString &description,
32
const
QString &warning,
33
tc::ConnectionStatusReason
reason,
34
Recommendation
action)
35
{
36
_severity
=
severity
;
37
_status
=
status
;
38
_percentComplete
= qBound(0, percentComplete, 100);
39
_description
=
description
;
40
_warning
=
warning
;
41
_reason
=
reason
;
42
_action
= action;
43
}
44
45
/** Converts a string TAG value to a BootstrapStatus enum value. */
46
BootstrapStatus::Status
47
BootstrapStatus::statusFromString
(
const
QString &str)
48
{
49
if
(!str.compare(
"CONN_DIR"
, Qt::CaseInsensitive))
50
return
ConnectingToDirMirror
;
51
if
(!str.compare(
"HANDSHAKE_DIR"
, Qt::CaseInsensitive))
52
return
HandshakingWithDirMirror
;
53
if
(!str.compare(
"ONEHOP_CREATE"
, Qt::CaseInsensitive))
54
return
CreatingOneHopCircuit
;
55
if
(!str.compare(
"REQUESTING_STATUS"
, Qt::CaseInsensitive))
56
return
RequestingNetworkStatus
;
57
if
(!str.compare(
"LOADING_STATUS"
, Qt::CaseInsensitive))
58
return
LoadingNetworkStatus
;
59
if
(!str.compare(
"LOADING_KEYS"
, Qt::CaseInsensitive))
60
return
LoadingAuthorityCertificates
;
61
if
(!str.compare(
"REQUESTING_DESCRIPTORS"
, Qt::CaseInsensitive))
62
return
RequestingDescriptors
;
63
if
(!str.compare(
"LOADING_DESCRIPTORS"
, Qt::CaseInsensitive))
64
return
LoadingDescriptors
;
65
if
(!str.compare(
"CONN_OR"
, Qt::CaseInsensitive))
66
return
ConnectingToEntryGuard
;
67
if
(!str.compare(
"HANDSHAKE_OR"
, Qt::CaseInsensitive))
68
return
HandshakingWithEntryGuard
;
69
if
(!str.compare(
"CIRCUIT_CREATE"
, Qt::CaseInsensitive))
70
return
EstablishingCircuit
;
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. */
78
BootstrapStatus::Recommendation
79
BootstrapStatus::actionFromString
(
const
QString &str)
80
{
81
if
(!str.compare(
"WARN"
, Qt::CaseInsensitive))
82
return
RecommendWarn
;
83
if
(!str.compare(
"IGNORE"
, Qt::CaseInsensitive))
84
return
RecommendIgnore
;
85
return
UnrecognizedRecommendation
;
86
}
87
88
/** Returns true if this object represents a valid bootstrap status phase. */
89
bool
90
BootstrapStatus::isValid
()
const
91
{
92
return
(
_severity
!=
tc::UnrecognizedSeverity
93
&&
_status
!=
UnrecognizedStatus
94
&&
_percentComplete
>= 0);
95
}
96
Generated on Thu Dec 6 2012 04:33:16 for Vidalia by
1.8.2