bootstrapstatus.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "bootstrapstatus.h"
00018
00019
00020 BootstrapStatus::BootstrapStatus()
00021 {
00022 _severity = tc::UnrecognizedSeverity;
00023 _reason = tc::UnrecognizedReason;
00024 _status = UnrecognizedStatus;
00025 _action = UnrecognizedRecommendation;
00026 _percentComplete = -1;
00027 }
00028
00029
00030 BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status,
00031 int percentComplete,
00032 const QString &description,
00033 const QString &warning,
00034 tc::ConnectionStatusReason reason,
00035 Recommendation action)
00036 {
00037 _severity = severity;
00038 _status = status;
00039 _percentComplete = qBound(0, percentComplete, 100);
00040 _description = description;
00041 _warning = warning;
00042 _reason = reason;
00043 _action = action;
00044 }
00045
00046
00047 BootstrapStatus::Status
00048 BootstrapStatus::statusFromString(const QString &str)
00049 {
00050 if (!str.compare("CONN_DIR", Qt::CaseInsensitive))
00051 return ConnectingToDirMirror;
00052 if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive))
00053 return HandshakingWithDirMirror;
00054 if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive))
00055 return CreatingOneHopCircuit;
00056 if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive))
00057 return RequestingNetworkStatus;
00058 if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive))
00059 return LoadingNetworkStatus;
00060 if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive))
00061 return LoadingAuthorityCertificates;
00062 if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive))
00063 return RequestingDescriptors;
00064 if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive))
00065 return LoadingDescriptors;
00066 if (!str.compare("CONN_OR", Qt::CaseInsensitive))
00067 return ConnectingToEntryGuard;
00068 if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive))
00069 return HandshakingWithEntryGuard;
00070 if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive))
00071 return EstablishingCircuit;
00072 if (!str.compare("DONE", Qt::CaseInsensitive))
00073 return BootstrappingDone;
00074 return UnrecognizedStatus;
00075 }
00076
00077
00078
00079 BootstrapStatus::Recommendation
00080 BootstrapStatus::actionFromString(const QString &str)
00081 {
00082 if (!str.compare("WARN", Qt::CaseInsensitive))
00083 return RecommendWarn;
00084 if (!str.compare("IGNORE", Qt::CaseInsensitive))
00085 return RecommendIgnore;
00086 return UnrecognizedRecommendation;
00087 }
00088
00089
00090 bool
00091 BootstrapStatus::isValid() const
00092 {
00093 return (_severity != tc::UnrecognizedSeverity
00094 && _status != UnrecognizedStatus
00095 && _percentComplete >= 0);
00096 }
00097