[tor-commits] [vidalia/alpha] Get the current progress at connect without waiting for events
chiiph at torproject.org
chiiph at torproject.org
Thu Jan 5 18:12:46 UTC 2012
commit 0786bf230ffc3db19a8087dd04b70e12e9db713d
Author: Tomás Touceda <chiiph at torproject.org>
Date: Thu Jan 5 11:08:57 2012 -0300
Get the current progress at connect without waiting for events
---
src/torcontrol/TorControl.cpp | 29 +++++++++++++++++++++++++++++
src/torcontrol/TorControl.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/torcontrol/TorControl.cpp b/src/torcontrol/TorControl.cpp
index 433e1a9..5d31023 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -213,6 +213,33 @@ TorControl::disconnect()
_controlConn->disconnect();
}
+void
+TorControl::getBootstrapPhase()
+{
+ ControlCommand cmd("GETINFO", "status/bootstrap-phase");
+ ControlReply reply;
+ QString str;
+
+ if (!send(cmd, reply, &str)) {
+ return;
+ }
+
+ bool ok;
+ QHash<QString, QString> args;
+ args = string_parse_keyvals(reply.getMessage(), &ok);
+
+ if(!ok)
+ return;
+
+ tc::Severity severity = tc::severityFromString(args.value("status/bootstrap-phase"));
+ BootstrapStatus status
+ = BootstrapStatus(severity,
+ BootstrapStatus::statusFromString(args.value("TAG")),
+ args.value("PROGRESS").toInt(),
+ args.value("SUMMARY"));
+ emit bootstrapStatusChanged(status);
+}
+
/** Emits a signal that the control socket disconnected from Tor */
void
TorControl::onDisconnected()
@@ -313,6 +340,8 @@ TorControl::onAuthenticated()
/* We want to use extended events in all async events */
useFeature("EXTENDED_EVENTS");
+ getBootstrapPhase();
+
emit authenticated();
}
diff --git a/src/torcontrol/TorControl.h b/src/torcontrol/TorControl.h
index 589fa23..f3504f5 100644
--- a/src/torcontrol/TorControl.h
+++ b/src/torcontrol/TorControl.h
@@ -401,6 +401,7 @@ private:
/* The slots below simply relay signals from the appropriate member objects */
private slots:
void onStopped(int exitCode, QProcess::ExitStatus exitStatus);
+ void getBootstrapPhase();
void onDisconnected();
void onLogStdout(const QString &severity, const QString &message);
void onAuthenticated();
More information about the tor-commits
mailing list