[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3357: Pass "--controller-log-format" to the thandy client and chan (vidalia/branches/auto-updates/src/vidalia)
Author: edmanm
Date: 2008-11-30 19:04:44 -0500 (Sun, 30 Nov 2008)
New Revision: 3357
Modified:
vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp
vidalia/branches/auto-updates/src/vidalia/updateprocess.h
Log:
Pass "--controller-log-format" to the thandy client and change
UpdateProcess to parse that format. Also fix a flipped comparison
when deciding whether it's time to check for updates again.
Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp 2008-11-30 21:37:59 UTC (rev 3356)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp 2008-12-01 00:04:44 UTC (rev 3357)
@@ -290,6 +290,10 @@
/* Schedule the next time to check for updates */
QDateTime nextCheckAt = UpdateProcess::nextCheckForUpdates(lastCheckedAt);
QDateTime now = QDateTime::currentDateTime().toUTC();
+
+ vInfo("Last checked for software updates at %1. Will check again at %2.")
+ .arg(lastCheckedAt.toLocalTime().toString("dd-MM-yyyy hh:mm:ss"))
+ .arg(nextCheckAt.toLocalTime().toString("dd-MM-yyyy hh:mm:ss"));
_updateTimer.start((nextCheckAt.toTime_t() - now.toTime_t()) * 1000);
}
}
Modified: vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp 2008-11-30 21:37:59 UTC (rev 3356)
+++ vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp 2008-12-01 00:04:44 UTC (rev 3357)
@@ -10,13 +10,14 @@
#include <QtDebug>
#include <vidalia.h>
+#include <stringutil.h>
#include "updateprocess.h"
UpdateProcess::UpdateProcess(QObject *parent)
: QProcess(parent)
-{
+{
connect(this, SIGNAL(readyReadStandardError()),
this, SLOT(readStandardError()));
connect(this, SIGNAL(readyReadStandardOutput()),
@@ -28,13 +29,10 @@
{
QStringList args;
- /* XXX: Super lame! This is a temporary hack until there is a real
- * thandy executable. */
- args << "E:\\thandy\\lib\\thandy\\ClientCLI.py";
+ args << "E:\\thandy\\lib\\thandy\\ClientCLI.py"
+ << "update" << "--controller-log-format"
+ << "--debug" << bundleInfoToString(bi);
- args << "update" << "--debug"
- << bundleInfoToString(bi);
-
vNotice("updater: launching auto-update executable: %1 %2")
.arg(updateExecutable())
.arg(args.join(" "));
@@ -45,16 +43,26 @@
void
UpdateProcess::installUpdates(BundleInfo bi)
{
- /* TODO: Call thandy to install the downloaded files, whenver
- * that part gets unbroken.
- */
+ QStringList args;
+
+ args << "E:\\thandy\\lib\\thandy\\ClientCLI.py"
+ << "update" << "--controller-log-format"
+ << "--install" << bundleInfoToString(bi);
+
+ vNotice("updater: launching auto-update executable: %1 %2")
+ .arg(updateExecutable())
+ .arg(args.join(" "));
+ _currentBundle = bi;
+ start(updateExecutable(), args);
}
void
UpdateProcess::readStandardError()
{
int idx;
- QString line, msg;
+ bool ok;
+ QString line, type;
+ QHash<QString,QString> args;
setReadChannel(QProcess::StandardError);
while (canReadLine()) {
@@ -65,18 +73,20 @@
* get the message we're interested in though, since the delimiters for the
* first two fields can be contained (and are unescaped) in the third field.
*/
- idx = line.indexOf(":");
+ idx = line.indexOf(" ");
if (idx < 0 || idx == line.length()-1)
continue;
- idx = line.indexOf(":", idx+1);
- if (idx < 0 || idx == line.length()-1)
+ type = line.mid(0, idx);
+ line = line.mid(idx + 1);
+
+ args = string_parse_keyvals(line, &ok);
+ if (! ok)
continue;
- msg = line.mid(idx+1);
/* All we can do is match on unspecified, free-form log message text. */
- if (msg.startsWith("Ready to install files:", Qt::CaseInsensitive))
+ if (! type.compare("CAN_INSTALL", Qt::CaseInsensitive))
emit updatesAvailable(_currentBundle);
- }
+ }
}
void
@@ -113,14 +123,14 @@
QDateTime
UpdateProcess::nextCheckForUpdates(const QDateTime &lastCheckedAt)
{
- return lastCheckedAt.toUTC().addSecs(checkForUpdatesInterval());
+ return lastCheckedAt.addSecs(checkForUpdatesInterval()).toUTC();
}
bool
UpdateProcess::shouldCheckForUpdates(const QDateTime &lastCheckedAt)
{
- QDateTime nextCheck = nextCheckForUpdates(lastCheckedAt);
- return (nextCheck >= QDateTime::currentDateTime().toUTC());
+ QDateTime nextCheckAt = nextCheckForUpdates(lastCheckedAt);
+ return (QDateTime::currentDateTime().toUTC() >= nextCheckAt);
}
QString
Modified: vidalia/branches/auto-updates/src/vidalia/updateprocess.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/updateprocess.h 2008-11-30 21:37:59 UTC (rev 3356)
+++ vidalia/branches/auto-updates/src/vidalia/updateprocess.h 2008-12-01 00:04:44 UTC (rev 3357)
@@ -29,18 +29,17 @@
*/
UpdateProcess(QObject *parent = 0);
- /** Begin a check for software updates using the updater binary specified
- * by <b>updaterExecutable</b>. The arguments in <b>args</b> will be given
- * to the auto-update binary on the command line.
+ /** Begin a check for software updates that may be available for the
+ * software package specified by <b>bi</b>.
*/
- void checkForUpdates(BundleInfo bundle);
+ void checkForUpdates(BundleInfo bi);
/** Instructs the software update process to install previously downloaded
* files for <b>bi</b>.
*/
void installUpdates(BundleInfo bi);
- /** Return the time at which we should next check for available updates,
+ /** Return the time at which we should next check for available updates,
* given the last we checked was at <b>lastCheckedAt</b>.
*/
static QDateTime nextCheckForUpdates(const QDateTime &lastCheckedAt);