[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [vidalia/master] Handle bootstrap like before and display what tor says if unknown
commit 1f0d99388380cad1d9ba3fc144ff19a572fc7475
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date: Tue Mar 6 15:54:28 2012 -0300
Handle bootstrap like before and display what tor says if unknown
This way we can partially translate the descriptions
Conflicts:
src/vidalia/MainWindow.cpp
---
src/torcontrol/BootstrapStatus.cpp | 39 ++++++++++++++++++++++++++++++++---
src/torcontrol/BootstrapStatus.h | 25 ++++++++++++++++++++--
src/torcontrol/TorControl.cpp | 4 +-
src/torcontrol/TorEvents.cpp | 2 +-
src/vidalia/MainWindow.cpp | 38 ++++++++++++++++++++++++++++++++++-
5 files changed, 97 insertions(+), 11 deletions(-)
diff --git a/src/torcontrol/BootstrapStatus.cpp b/src/torcontrol/BootstrapStatus.cpp
index f4e38b8..fb79eb9 100644
--- a/src/torcontrol/BootstrapStatus.cpp
+++ b/src/torcontrol/BootstrapStatus.cpp
@@ -20,14 +20,13 @@ BootstrapStatus::BootstrapStatus()
{
_severity = tc::UnrecognizedSeverity;
_reason = tc::UnrecognizedReason;
- _status = QString();
+ _status = UnrecognizedStatus;
_action = UnrecognizedRecommendation;
_percentComplete = -1;
}
/** Constructor. */
-BootstrapStatus::BootstrapStatus(tc::Severity severity,
- const QString &status,
+BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status,
int percentComplete,
const QString &description,
const QString &warning,
@@ -43,6 +42,37 @@ BootstrapStatus::BootstrapStatus(tc::Severity severity,
_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
@@ -60,6 +90,7 @@ bool
BootstrapStatus::isValid() const
{
return (_severity != tc::UnrecognizedSeverity
- && _percentComplete >= 0);
+ && _status != UnrecognizedStatus
+ && _percentComplete >= 0);
}
diff --git a/src/torcontrol/BootstrapStatus.h b/src/torcontrol/BootstrapStatus.h
index a2e3297..7526fdb 100644
--- a/src/torcontrol/BootstrapStatus.h
+++ b/src/torcontrol/BootstrapStatus.h
@@ -25,6 +25,23 @@
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 {
@@ -38,7 +55,7 @@ public:
/** Constructor. */
BootstrapStatus(tc::Severity severity,
- const QString &status, int percentComplete,
+ Status status, int percentComplete,
const QString &description,
const QString &warning = QString(),
tc::ConnectionStatusReason reason = tc::UnrecognizedReason,
@@ -49,7 +66,7 @@ public:
/** Returns the BootstrapStatus enum value indicated by this bootstrap
* status event. */
- QString status() const { return _status; }
+ Status 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. */
@@ -77,6 +94,8 @@ 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);
@@ -90,7 +109,7 @@ private:
/** Current bootstrapping status value.
* \sa status
*/
- QString _status;
+ Status _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 f87f3a9..57785e0 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,
- args.value("TAG"),
+ BootstrapStatus::statusFromString(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,
- args.value("TAG"),
+ BootstrapStatus::statusFromString(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 f068f1a..588a093 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,
- args.value("TAG"),
+ BootstrapStatus::statusFromString(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 166b472..a23478e 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -804,7 +804,43 @@ MainWindow::bootstrapStatusChanged(const BootstrapStatus &bs)
bs.recommendedAction() != BootstrapStatus::RecommendIgnore);
QString description;
- description = bs.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 = 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