[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r2312: Add a TorProcess::version() to get the version of a given To (in vidalia/trunk: . src/torcontrol)
Author: edmanm
Date: 2008-01-19 21:10:52 -0500 (Sat, 19 Jan 2008)
New Revision: 2312
Modified:
vidalia/trunk/
vidalia/trunk/src/torcontrol/torprocess.cpp
vidalia/trunk/src/torcontrol/torprocess.h
Log:
r59@lysithea: edmanm | 2008-01-19 21:10:44 -0500
Add a TorProcess::version() to get the version of a given Tor binary before we
start it for serious.
Property changes on: vidalia/trunk
___________________________________________________________________
svk:merge ticket from /local/vidalia/trunk [r59] on 90112fd6-a33b-4cea-8d39-48ff1d78625c
Modified: vidalia/trunk/src/torcontrol/torprocess.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/torprocess.cpp 2008-01-19 23:37:38 UTC (rev 2311)
+++ vidalia/trunk/src/torcontrol/torprocess.cpp 2008-01-20 02:10:52 UTC (rev 2312)
@@ -189,3 +189,25 @@
}
}
+/** Returns the version reported by the Tor executable specified in
+ * <b>exe</b>, or a default-constructed QString on failure. */
+QString
+TorProcess::version(const QString &exe)
+{
+ QProcess tor;
+
+ tor.start(exe, QStringList() << "--version");
+ if (!tor.waitForStarted() || !tor.waitForFinished())
+ return QString();
+
+ while (tor.canReadLine()) {
+ QString line = tor.readLine();
+ if (line.startsWith("Tor version", Qt::CaseInsensitive)) {
+ QStringList parts = line.split(" ");
+ if (parts.size() >= 3)
+ return parts.at(2);
+ }
+ }
+ return QString();
+}
+
Modified: vidalia/trunk/src/torcontrol/torprocess.h
===================================================================
--- vidalia/trunk/src/torcontrol/torprocess.h 2008-01-19 23:37:38 UTC (rev 2311)
+++ vidalia/trunk/src/torcontrol/torprocess.h 2008-01-20 02:10:52 UTC (rev 2312)
@@ -52,6 +52,10 @@
/** Disable reading log messages from stdout. */
void closeStdout();
+ /** Returns the version reported by the Tor executable specified in
+ * <b>exe</b>, or a default-constructed QString on failure. */
+ static QString version(const QString &exe);
+
signals:
/** Emitted when Tor prints a log message to the console */
void log(const QString &severity, const QString &message);