[tor-commits] [vidalia/master] Get the current progress at connect without waiting for events
chiiph at torproject.org
chiiph at torproject.org
Thu Jan 5 18:12:35 UTC 2012
commit 172c2f640f50f07d6f20ad5e3410c4fdb249ee2e
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 57abeb1..af925a7 100644
--- a/src/torcontrol/TorControl.cpp
+++ b/src/torcontrol/TorControl.cpp
@@ -209,6 +209,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()
@@ -309,6 +336,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