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

[vidalia-svn] r3367: Display the UpdateDialog if Thandy found one or more package (vidalia/branches/auto-updates/src/vidalia)



Author: edmanm
Date: 2008-12-06 19:29:13 -0500 (Sat, 06 Dec 2008)
New Revision: 3367

Modified:
   vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
   vidalia/branches/auto-updates/src/vidalia/mainwindow.h
Log:
Display the UpdateDialog if Thandy found one or more packages available
to be updated, with information on the available updates. If the user
clicks "Install Now", then call Thandy again to install the package.
Otherwise, do nothing.


Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp	2008-12-07 00:25:05 UTC (rev 3366)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp	2008-12-07 00:29:13 UTC (rev 3367)
@@ -33,6 +33,10 @@
 #include "mainwindow.h"
 #include "controlpasswordinputdialog.h"
 
+#ifdef USE_AUTOUPDATE
+#include "updatedialog.h"
+#endif
+
 #define IMG_BWGRAPH        ":/images/16x16/utilities-system-monitor.png"
 #define IMG_CONTROL_PANEL  ":/images/16x16/system-run.png"
 #define IMG_MESSAGELOG     ":/images/16x16/format-justify-fill.png"
@@ -166,8 +170,8 @@
   /* 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)));
+  connect(&_updateProcess, SIGNAL(updatesAvailable(UpdateProcess::BundleInfo,PackageList)),
+          this, SLOT(updatesAvailable(UpdateProcess::BundleInfo,PackageList)));
 #endif
 
 #if defined(USE_MINIUPNPC)
@@ -1494,16 +1498,15 @@
 void
 MainWindow::checkForUpdates()
 {
+  VidaliaSettings settings;
+
   /* 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.
    */
   _updateProcess.checkForUpdates(UpdateProcess::TorBundleInfo);
 
-  /* XXX: The stuff below should be moved to another method that gets called
-   *      when the auto-update check is complete.
-   */
-  VidaliaSettings settings;
+  /* Remember when we last checked for software updates */
   settings.setLastCheckedForUpdates(QDateTime::currentDateTime().toUTC());
 
   /* Restart the "Check for Updates" timer */
@@ -1511,11 +1514,32 @@
 }
 
 void
-MainWindow::updatesAvailable(UpdateProcess::BundleInfo bi)
+MainWindow::checkForUpdatesFailed(const QString &errmsg)
 {
-  /* TODO: Get information about the updates from the auto-update
-   *       executable and display it in an UpdateDialog.
-   */
-  vInfo("software updates available");
+  Q_UNUSED(errmsg);
 }
+
+void
+MainWindow::updatesAvailable(UpdateProcess::BundleInfo bi,
+                             const PackageList &packageList)
+{
+  vInfo("%1 software update(s) available").arg(packageList.size());
+  if (packageList.size() > 0) {
+    UpdateDialog dlg(packageList, this);
+    
+    switch (dlg.exec()) {
+      case UpdateDialog::InstallUpdatesNow:
+        _updateProcess.installUpdates(bi);    
+        break;
+
+      case UpdateDialog::InstallUpdatesLater:
+        /* Do nothing */
+        break;
+
+      default:
+        break;
+    }
+  }
+}
 #endif
+

Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.h	2008-12-07 00:25:05 UTC (rev 3366)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.h	2008-12-07 00:29:13 UTC (rev 3367)
@@ -121,8 +121,10 @@
   /** Called when the update interval timer expires, notifying Vidalia that
    * we should check for updates again. */
   void checkForUpdates();
+  /** Called when the check for software updates fails. */
+  void checkForUpdatesFailed(const QString &errmsg);
   /** Called when there is an update available for installation. */
-  void updatesAvailable(UpdateProcess::BundleInfo bi);
+  void updatesAvailable(UpdateProcess::BundleInfo bi, const PackageList &packageList);
 #endif
 
 #if defined(USE_MINIUPNPC)