[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r3341: Start parsing thandy log messages and trying to match messag (vidalia/branches/auto-updates/src/vidalia)



Author: edmanm
Date: 2008-11-22 02:24:32 -0500 (Sat, 22 Nov 2008)
New Revision: 3341

Modified:
   vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
   vidalia/branches/auto-updates/src/vidalia/mainwindow.h
   vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp
   vidalia/branches/auto-updates/src/vidalia/updateprocess.h
Log:
Start parsing thandy log messages and trying to match message text in order
to determine if there are updates to install. If there are, call a slot that
does nothing until thandy's install thing is unbroken. :(


Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp	2008-11-22 05:51:54 UTC (rev 3340)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp	2008-11-22 07:24:32 UTC (rev 3341)
@@ -162,8 +162,13 @@
   connect(vApp, SIGNAL(running()), this, SLOT(running()));
   connect(vApp, SIGNAL(shutdown()), this, SLOT(shutdown()));
 
+#if defined(USE_AUTOUPDATE)
   /* Create a timer used to remind us to check for software updates */
   connect(&_updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
+  
+  connect(&_updateProcess, SIGNAL(updatesAvailable(UpdateProcess::BundleInfo)),
+          this, SLOT(updatesAvailable(UpdateProcess::BundleInfo)));
+#endif
 
 #if defined(USE_MINIUPNPC)
   /* Catch UPnP-related signals */
@@ -1481,10 +1486,10 @@
 }
 #endif
 
+#if defined(USE_AUTOUPDATE)
 void
 MainWindow::checkForUpdates()
 {
-#if defined(USE_AUTOUPDATE)
   /* Initiate a check for available software updates. This check will
    * be done in the background, notifying the user only if there are
    * updates to be installed.
@@ -1492,13 +1497,21 @@
   _updateProcess.checkForUpdates(UpdateProcess::TorBundleInfo);
 
   /* XXX: The stuff below should be moved to another method that gets called
-   *      when the glider check is complete.
+   *      when the auto-update check is complete.
    */
   VidaliaSettings settings;
   settings.setLastCheckedForUpdates(QDateTime::currentDateTime().toUTC());
 
   /* Restart the "Check for Updates" timer */
   _updateTimer.start(UpdateProcess::checkForUpdatesInterval() * 1000);
-#endif
 }
 
+void
+MainWindow::updatesAvailable(UpdateProcess::BundleInfo bi)
+{
+  /* TODO: Get information about the updates from the auto-update
+   *       executable and display it in an UpdateDialog.
+   */
+  vInfo("software updates available");
+}
+#endif

Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.h	2008-11-22 05:51:54 UTC (rev 3340)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.h	2008-11-22 07:24:32 UTC (rev 3341)
@@ -116,9 +116,14 @@
   void onIMFailed(QString errmsg);
   /** Called when the proxy server fails to start */
   void onProxyFailed(QString errmsg);
+
+#if defined(USE_AUTOUPDATE)
   /** Called when the update interval timer expires, notifying Vidalia that
    * we should check for updates again. */
   void checkForUpdates();
+  /** Called when there is an update available for installation. */
+  void updatesAvailable(UpdateProcess::BundleInfo bi);
+#endif
 
 #if defined(USE_MINIUPNPC)
   /** Called when a UPnP error occurs. */

Modified: vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp	2008-11-22 05:51:54 UTC (rev 3340)
+++ vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp	2008-11-22 07:24:32 UTC (rev 3341)
@@ -9,6 +9,7 @@
 */
 
 #include <QtDebug>
+#include <vidalia.h>
 
 #include "updateprocess.h"
 
@@ -34,18 +35,47 @@
   args << "update" << "--debug"
        << bundleInfoToString(bi);
 
+  vNotice("updater: launching auto-update executable: %1 %2")
+                                           .arg(updateExecutable())
+                                           .arg(args.join(" "));
+  _currentBundle = bi;
   start(updateExecutable(), args);
 }
 
 void
+UpdateProcess::installUpdates(BundleInfo bi)
+{
+  /* TODO: Call thandy to install the downloaded files, whenver
+   *       that part gets unbroken.
+   */
+}
+
+void
 UpdateProcess::readStandardError()
 {
-  QString line;
+  int idx;
+  QString line, msg;
 
   setReadChannel(QProcess::StandardError);
   while (canReadLine()) {
-    line = readLine();
-    qDebug() << QString("updater (stderr): %1").arg(line);
+    line = readLine().trimmed();
+    vInfo("updater (stderr): %1").arg(line);
+
+    /* Skip the first two fields. We can't just use split() or section() to
+     * 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(":");
+    if (idx < 0 || idx == line.length()-1)
+      continue;
+    idx = line.indexOf(":", idx+1);
+    if (idx < 0 || idx == line.length()-1)
+      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))
+      emit updatesAvailable(_currentBundle);
   }  
 }
 
@@ -56,8 +86,8 @@
 
   setReadChannel(QProcess::StandardOutput);
   while (canReadLine()) {
-    line = readLine();
-    qDebug() << QString("updater (stdout): %1").arg(line);
+    line = readLine().trimmed();
+    vInfo("updater (stdout): %1").arg(line);
   }
 }
 
@@ -65,6 +95,7 @@
 UpdateProcess::onError(QProcess::ProcessError error)
 {
   if (error == QProcess::FailedToStart) {
+    vWarn("updater: failed to start");
     emit checkForUpdatesFailed(tr("Vidalia was unable to check for available "
                                   "software updates because it could not find "
                                   "'%1'.").arg(updateExecutable()));

Modified: vidalia/branches/auto-updates/src/vidalia/updateprocess.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/updateprocess.h	2008-11-22 05:51:54 UTC (rev 3340)
+++ vidalia/branches/auto-updates/src/vidalia/updateprocess.h	2008-11-22 07:24:32 UTC (rev 3341)
@@ -35,6 +35,11 @@
    */
   void checkForUpdates(BundleInfo bundle);
 
+  /** 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, 
    * given the last we checked was at <b>lastCheckedAt</b>.
    */
@@ -59,7 +64,7 @@
   void downloadProgressChanged(QString filename,
                                int bytesReceived, int bytesTotal);
 
-  void updatesAvailable(QStringList updates);
+  void updatesAvailable(UpdateProcess::BundleInfo bi);
 
 protected slots:
   /** Called when there is data to be read from the update process's stdout.
@@ -79,6 +84,11 @@
   /** Converts a BundleInfo enum value to its proper Thandy-recognized URL
    * for the current OS and architecture. */
   QString bundleInfoToString(BundleInfo bundleInfo);
+
+private:
+  /** Enum value of the last bundle for which we performed some action
+   * (e.g., check for updates, install an update, etc. */
+  BundleInfo _currentBundle;
 };
 
 #endif