[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3391: If "Check Now" is clicked and a check for updates is already (vidalia/branches/auto-updates/src/vidalia)
Author: edmanm
Date: 2008-12-13 01:16:38 -0500 (Sat, 13 Dec 2008)
New Revision: 3391
Modified:
vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
vidalia/branches/auto-updates/src/vidalia/mainwindow.h
Log:
If "Check Now" is clicked and a check for updates is already in progress,
then just bring up the progress dialog again. Otherwise, kick off a new check
for updates immediately and update the progress dialog as thandy does its
thing. When new updates are about to be installed, kill Tor and then restart
it after the updates are finished installing.
Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp 2008-12-13 06:14:11 UTC (rev 3390)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp 2008-12-13 06:16:38 UTC (rev 3391)
@@ -123,6 +123,7 @@
createTrayIcon();
/* Start with Tor initially stopped */
_status = Unset;
+ _isVidaliaRunningTor = false;
updateTorStatus(Stopped);
/* Create a new TorControl object, used to communicate with Tor */
@@ -169,9 +170,23 @@
#if defined(USE_AUTOUPDATE)
/* Create a timer used to remind us to check for software updates */
connect(&_updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
-
+
+ /* Also check for updates in the foreground when the user clicks the
+ * "Check Now" button in the config dialog. */
+ connect(_configDialog, SIGNAL(checkForUpdates()),
+ this, SLOT(checkForUpdatesWithUI()));
+
+ /* The rest of these slots are called as the update process executes. */
+ connect(&_updateProcess, SIGNAL(downloadProgress(QString,int,int)),
+ &_updateProgressDialog, SLOT(setDownloadProgress(QString,int,int)));
connect(&_updateProcess, SIGNAL(updatesAvailable(UpdateProcess::BundleInfo,PackageList)),
this, SLOT(updatesAvailable(UpdateProcess::BundleInfo,PackageList)));
+ connect(&_updateProcess, SIGNAL(updatesInstalled(int)),
+ this, SLOT(updatesInstalled(int)));
+ connect(&_updateProcess, SIGNAL(installUpdatesFailed(QString)),
+ this, SLOT(installUpdatesFailed(QString)));
+ connect(&_updateProgressDialog, SIGNAL(cancelUpdate()),
+ &_updateProcess, SLOT(cancel()));
#endif
#if defined(USE_MINIUPNPC)
@@ -1496,27 +1511,49 @@
#if defined(USE_AUTOUPDATE)
void
-MainWindow::checkForUpdates()
+MainWindow::checkForUpdatesWithUI()
{
+ checkForUpdates(true);
+}
+
+void
+MainWindow::checkForUpdates(bool showProgress)
+{
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);
+ if (_updateProcess.isRunning() && showProgress) {
+ /* A check for updates is already in progress, so just bring the update
+ * progress dialog into focus.
+ */
+ _updateProgressDialog.show();
+ } else {
+ /* Initialize the UpdateProgressDialog and display it, if necessary. */
+ _updateProgressDialog.setStatus(UpdateProgressDialog::CheckingForUpdates);
+ if (showProgress)
+ _updateProgressDialog.show();
- /* Remember when we last checked for software updates */
- settings.setLastCheckedForUpdates(QDateTime::currentDateTime().toUTC());
+ /* 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);
- /* Restart the "Check for Updates" timer */
- _updateTimer.start(UpdateProcess::checkForUpdatesInterval() * 1000);
+ /* Remember when we last checked for software updates */
+ settings.setLastCheckedForUpdates(QDateTime::currentDateTime().toUTC());
+
+ /* Restart the "Check for Updates" timer */
+ _updateTimer.start(UpdateProcess::checkForUpdatesInterval() * 1000);
+ }
}
void
MainWindow::checkForUpdatesFailed(const QString &errmsg)
{
- Q_UNUSED(errmsg);
+ if (_updateProgressDialog.isVisible()) {
+ _updateProgressDialog.hide();
+ VMessageBox::warning(this, tr("Update Failed"), errmsg,
+ VMessageBox::Ok);
+ }
}
void
@@ -1525,21 +1562,71 @@
{
vInfo("%1 software update(s) available").arg(packageList.size());
if (packageList.size() > 0) {
- UpdateDialog dlg(packageList, this);
+ UpdateDialog dlg(packageList, &_updateProgressDialog);
switch (dlg.exec()) {
case UpdateDialog::InstallUpdatesNow:
- _updateProcess.installUpdates(bi);
+ installUpdates(bi);
break;
case UpdateDialog::InstallUpdatesLater:
- /* Do nothing */
+ _updateProgressDialog.hide();
break;
default:
break;
}
+ } else {
+ if (_updateProgressDialog.isVisible()) {
+ _updateProgressDialog.hide();
+ VMessageBox::information(this, tr("No Updates Available"),
+ tr("You are currently running the most recent "
+ "Tor software available."),
+ VMessageBox::Ok);
+ }
}
}
+
+void
+MainWindow::installUpdates(UpdateProcess::BundleInfo bi)
+{
+ _updateProgressDialog.setStatus(UpdateProgressDialog::InstallingUpdates);
+ _updateProgressDialog.show();
+
+ if (_isVidaliaRunningTor) {
+ _restartTorAfterUpgrade = true;
+ _isIntentionalExit = true;
+ _torControl->stop();
+ } else {
+ _restartTorAfterUpgrade = false;
+ }
+ _updateProcess.installUpdates(bi);
+}
+
+void
+MainWindow::updatesInstalled(int numUpdates)
+{
+ _updateProgressDialog.setStatus(UpdateProgressDialog::UpdatesInstalled);
+ _updateProgressDialog.show();
+
+ if (_restartTorAfterUpgrade)
+ start();
+}
+
+void
+MainWindow::installUpdatesFailed(const QString &errmsg)
+{
+ _updateProgressDialog.hide();
+
+ VMessageBox::warning(this, tr("Installation Failed"),
+ p(tr("Vidalia was unable to install your software updates."))
+ + p(tr("The following error occurred:"))
+ + p(errmsg),
+ VMessageBox::Ok);
+
+ if (_restartTorAfterUpgrade)
+ start();
+}
+
#endif
Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.h 2008-12-13 06:14:11 UTC (rev 3390)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.h 2008-12-13 06:16:38 UTC (rev 3391)
@@ -36,6 +36,7 @@
#if defined(USE_AUTOUPDATE)
#include "updateprocess.h"
+#include "updateprogressdialog.h"
#endif
#if defined(USE_MINIUPNPC)
#include "config/upnpcontrol.h"
@@ -118,13 +119,25 @@
void onProxyFailed(QString errmsg);
#if defined(USE_AUTOUPDATE)
+ /** Called when the user clicks the 'Check Now' button in the General
+ * settings page. */
+ void checkForUpdatesWithUI();
/** Called when the update interval timer expires, notifying Vidalia that
* we should check for updates again. */
- void checkForUpdates();
+ void checkForUpdates(bool showProgress = false);
/** 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, const PackageList &packageList);
+ /** Stops Tor (if necessary), installs any available for <b>bi</b>, and
+ * restarts Tor (if necessary). */
+ void installUpdates(UpdateProcess::BundleInfo bi);
+ /** Called when all <b>numUpdates</b> software updates have been installed
+ * successfully. */
+ void updatesInstalled(int numUpdates);
+ /** Called when an update fails to install. <b>errmsg</b> contains details
+ * about the failure. */
+ void installUpdatesFailed(const QString &errmsg);
#endif
#if defined(USE_MINIUPNPC)
@@ -219,11 +232,17 @@
bool _useSavedPassword;
/** The Vidalia icon that sits in the tray. */
TrayIcon _trayIcon;
+
+#if defined(USE_AUTOUPDATE)
/** Timer used to remind us to check for software updates. */
QTimer _updateTimer;
-#if defined(USE_AUTOUPDATE)
/** The auto-update process used to check for and download updates. */
UpdateProcess _updateProcess;
+ /** Dialog instance that is be used to show the progress of the auto-update
+ * executable. */
+ UpdateProgressDialog _updateProgressDialog;
+ /** Set to true if Vidalia should restart Tor after a software upgrade. */
+ bool _restartTorAfterUpgrade;
#endif
/** The menubar (Mac OS X only). */
QMenuBar *_menuBar;