[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [vidalia/master] Remove BootstrapStatus::Status. We will get the description from tor
commit 8144a2ff47fb3bc6c112aaef145912d7fe9f15d5
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date: Mon Feb 20 18:08:59 2012 -0300
Remove BootstrapStatus::Status. We will get the description from tor
---
src/torcontrol/BootstrapStatus.cpp | 37 ++--------------------------------
src/torcontrol/BootstrapStatus.h | 25 ++--------------------
src/torcontrol/TorControl.cpp | 4 +-
src/torcontrol/TorEvents.cpp | 2 +-
src/vidalia/MainWindow.cpp | 38 +-----------------------------------
5 files changed, 10 insertions(+), 96 deletions(-)
diff --git a/src/torcontrol/BootstrapStatus.cpp b/src/torcontrol/BootstrapStatus.cpp
index 8184ffe..f4e38b8 100644
--- a/src/torcontrol/BootstrapStatus.cpp
+++ b/src/torcontrol/BootstrapStatus.cpp
@@ -20,13 +20,14 @@ BootstrapStatus::BootstrapStatus()
{
_severity = tc::UnrecognizedSeverity;
_reason = tc::UnrecognizedReason;
- _status = UnrecognizedStatus;
+ _status = QString();
_action = UnrecognizedRecommendation;
_percentComplete = -1;
}
/** Constructor. */
-BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status,
+BootstrapStatus::BootstrapStatus(tc::Severity severity,
+ const QString &status,
int percentComplete,
const QString &description,
const QString &warning,
@@ -42,37 +43,6 @@ BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status,
_action = action;
}
-/** Converts a string TAG value to a BootstrapStatus enum value. */
-BootstrapStatus::Status
-BootstrapStatus::statusFromString(const QString &str)
-{
- if (!str.compare("CONN_DIR", Qt::CaseInsensitive))
- return ConnectingToDirMirror;
- if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive))
- return HandshakingWithDirMirror;
- if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive))
- return CreatingOneHopCircuit;
- if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive))
- return RequestingNetworkStatus;
- if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive))
- return LoadingNetworkStatus;
- if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive))
- return LoadingAuthorityCertificates;
- if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive))
- return RequestingDescriptors;
- if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive))
- return LoadingDescriptors;
- if (!str.compare("CONN_OR", Qt::CaseInsensitive))
- return ConnectingToEntryGuard;
- if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive))
- return HandshakingWithEntryGuard;
- if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive))
- return EstablishingCircuit;
- if (!str.compare("DONE", Qt::CaseInsensitive))
- return BootstrappingDone;
- return UnrecognizedStatus;
-}
-
/** Returns the action that the Tor software recommended be taken in response
* to this bootstrap status. */
BootstrapStatus::Recommendation
@@ -90,7 +60,6 @@ bool
BootstrapStatus::isValid() const
{
return (_severity != tc::UnrecognizedSeverity
- && _status != UnrecognizedStatus
&& _percentComplete >= 0);
}
diff --git a/src/torcontrol/BootstrapStatus.h b/src/torcontrol/BootstrapStatus.h
index 7526fdb..a2e3297 100644
--- a/src/torcontrol/BootstrapStatus.h
+++ b/src/torcontrol/BootstrapStatus.h
@@ -25,23 +25,6 @@
class BootstrapStatus
{
public:
- /** Currently enumerated bootstrapping states defined by Tor's control
- * protocol (Tor >= 0.2.1.0-alpha-dev. */
- enum Status {
- UnrecognizedStatus,
- ConnectingToDirMirror,
- HandshakingWithDirMirror,
- CreatingOneHopCircuit,
- RequestingNetworkStatus,
- LoadingNetworkStatus,
- LoadingAuthorityCertificates,
- RequestingDescriptors,
- LoadingDescriptors,
- ConnectingToEntryGuard,
- HandshakingWithEntryGuard,
- EstablishingCircuit,
- BootstrappingDone
- };
/** Actions the Tor software might recommend controllers take in response to
* a bootstrap status problem event. */
enum Recommendation {
@@ -55,7 +38,7 @@ public:
/** Constructor. */
BootstrapStatus(tc::Severity severity,
- Status status, int percentComplete,
+ const QString &status, int percentComplete,
const QString &description,
const QString &warning = QString(),
tc::ConnectionStatusReason reason = tc::UnrecognizedReason,
@@ -66,7 +49,7 @@ public:
/** Returns the BootstrapStatus enum value indicated by this bootstrap
* status event. */
- Status status() const { return _status; }
+ QString status() const { return _status; }
/** Returns an integer between 0 and 100 representing an estimate of how
* much of Tor's bootstrapping process it has completed. */
@@ -94,8 +77,6 @@ public:
* phase. */
bool isValid() const;
- /** Converts a string TAG value to a BootstrapStatus enum value. */
- static Status statusFromString(const QString &tag);
/** Converts a string RECOMMENDATION value to a RecommendAction enum
* value. */
static Recommendation actionFromString(const QString &str);
@@ -109,7 +90,7 @@ private:
/** Current bootstrapping status value.
* \sa status
*/
- Status _status;
+ QString _status;
/** Approximate percentage of Tor's bootstrapping process that is complete.
* \sa percentComplete
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp
index 3cf7467..a73c81d 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -230,7 +230,7 @@ TorControl::getBootstrapPhase()
tc::Severity severity = tc::severityFromString(args.value("status/bootstrap-phase"));
BootstrapStatus status
= BootstrapStatus(severity,
- BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("TAG"),
args.value("PROGRESS").toInt(),
args.value("SUMMARY"));
emit bootstrapStatusChanged(status);
@@ -403,7 +403,7 @@ TorControl::bootstrapStatus(QString *errmsg)
tc::Severity severity = tc::severityFromString(str.section(' ', 0, 0));
QHash<QString,QString> args = string_parse_keyvals(str);
return BootstrapStatus(severity,
- BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("TAG"),
args.value("PROGRESS").toInt(),
args.value("SUMMARY"),
args.value("WARNING"),
diff --git a/src/torcontrol/TorEvents.cpp b/src/torcontrol/TorEvents.cpp
index 588a093..f068f1a 100644
--- a/src/torcontrol/TorEvents.cpp
+++ b/src/torcontrol/TorEvents.cpp
@@ -368,7 +368,7 @@ TorEvents::handleClientStatusEvent(tc::Severity severity,
} else if (! action.compare("BOOTSTRAP", Qt::CaseInsensitive)) {
BootstrapStatus status
= BootstrapStatus(severity,
- BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("TAG"),
args.value("PROGRESS").toInt(),
args.value("SUMMARY"),
args.value("WARNING"),
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index d170d47..166b472 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -804,43 +804,7 @@ MainWindow::bootstrapStatusChanged(const BootstrapStatus &bs)
bs.recommendedAction() != BootstrapStatus::RecommendIgnore);
QString description;
- switch (bs.status()) {
- case BootstrapStatus::ConnectingToDirMirror:
- description = tr("Connecting to a relay directory");
- break;
- case BootstrapStatus::HandshakingWithDirMirror:
- case BootstrapStatus::CreatingOneHopCircuit:
- description = tr("Establishing an encrypted directory connection");
- break;
- case BootstrapStatus::RequestingNetworkStatus:
- description = tr("Retrieving network status");
- break;
- case BootstrapStatus::LoadingNetworkStatus:
- description = tr("Loading network status");
- break;
- case BootstrapStatus::LoadingAuthorityCertificates:
- description = tr("Loading authority certificates");
- break;
- case BootstrapStatus::RequestingDescriptors:
- description = tr("Requesting relay information");
- break;
- case BootstrapStatus::LoadingDescriptors:
- description = tr("Loading relay information");
- break;
- case BootstrapStatus::ConnectingToEntryGuard:
- description = tr("Connecting to the Tor network");
- break;
- case BootstrapStatus::HandshakingWithEntryGuard:
- case BootstrapStatus::EstablishingCircuit:
- description = tr("Establishing a Tor circuit");
- break;
- case BootstrapStatus::BootstrappingDone:
- description = tr("Connected to the Tor network!");
- warn = false; /* probably false anyway */
- break;
- default:
- description = tr("Unrecognized startup status");
- }
+ description = bs.description();
if (warn) {
QString reason;
/* Is it really a good idea to translate these? */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits