From ecf545a0b910d5163f29bf6baa82c79904bf1dee Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Thu, 6 Aug 2015 19:34:23 +0200 Subject: [PATCH] Updater: update Linux updater code to work with changes in master master moved much of the responsibility of the updating process to the updater class. This also fixes a build failure --- src/gui/application.cpp | 18 ++---------------- src/gui/application.h | 1 - src/gui/updater/ocupdater.cpp | 18 ++++++++++++++++++ src/gui/updater/ocupdater.h | 4 ++++ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 3a777feb0..78102670c 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -171,15 +171,11 @@ Application::Application(int &argc, char **argv) : UpdaterScheduler *updaterScheduler = new UpdaterScheduler(this); connect(updaterScheduler, SIGNAL(updaterAnnouncement(QString, QString)), _gui, SLOT(slotShowTrayMessage(QString, QString))); + connect(updaterScheduler, SIGNAL(requestRestart()), + _folderManager.data(), SLOT(slotScheduleAppRestart())); // Cleanup at Quit. connect (this, SIGNAL(aboutToQuit()), SLOT(slotCleanup())); - - // remember the version of the currently running binary. On Linux it might happen that the - // package management updates the package while the app is running. This is detected in the - // updater slot: If the installed binary on the hd has a different version than the one - // running, the running app is restart. That happens in folderman. - _runningAppVersion = Utility::versionOfInstalledBinary(); } Application::~Application() @@ -217,16 +213,6 @@ void Application::slotCleanup() _gui->deleteLater(); } - - if( Utility::isLinux() ) { - // on linux, check if the installed binary is still the same version - // as the one that is running. If not, restart if possible. - const QByteArray fsVersion = Utility::versionOfInstalledBinary(); - - if( !(fsVersion.isEmpty() || _runningAppVersion.isEmpty()) && fsVersion != _runningAppVersion ) { - _folderManager->slotScheduleAppRestart(); - } - } void Application::slotCheckConnection() { auto list = AccountManager::instance()->accounts(); diff --git a/src/gui/application.h b/src/gui/application.h index b09895c4f..7a246e6c5 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -105,7 +105,6 @@ private: bool _logFlush; bool _userTriggeredConnect; bool _debugMode; - QByteArray _runningAppVersion; ClientProxy _proxy; diff --git a/src/gui/updater/ocupdater.cpp b/src/gui/updater/ocupdater.cpp index b62a40de1..13134707c 100644 --- a/src/gui/updater/ocupdater.cpp +++ b/src/gui/updater/ocupdater.cpp @@ -48,6 +48,7 @@ UpdaterScheduler::UpdaterScheduler(QObject *parent) : if (OCUpdater *updater = dynamic_cast(Updater::instance())) { connect(updater, SIGNAL(newUpdateAvailable(QString,QString)), this, SIGNAL(updaterAnnouncement(QString,QString)) ); + connect(updater, SIGNAL(requestRestart()), SIGNAL(requestRestart())); } // at startup, do a check in any case. @@ -421,7 +422,24 @@ void NSISUpdater::slotSetSeenVersion() PassiveUpdateNotifier::PassiveUpdateNotifier(const QUrl &url, QObject *parent) : OCUpdater(url, parent) { + // remember the version of the currently running binary. On Linux it might happen that the + // package management updates the package while the app is running. This is detected in the + // updater slot: If the installed binary on the hd has a different version than the one + // running, the running app is restart. That happens in folderman. + _runningAppVersion = Utility::versionOfInstalledBinary(); +} +void PassiveUpdateNotifier::backgroundCheckForUpdate() +{ + if( Utility::isLinux() ) { + // on linux, check if the installed binary is still the same version + // as the one that is running. If not, restart if possible. + const QByteArray fsVersion = Utility::versionOfInstalledBinary(); + qDebug() << Q_FUNC_INFO; + if( !(fsVersion.isEmpty() || _runningAppVersion.isEmpty()) && fsVersion != _runningAppVersion ) { + emit requestRestart(); + } + } } void PassiveUpdateNotifier::versionInfoArrived(const UpdateInfo &info) diff --git a/src/gui/updater/ocupdater.h b/src/gui/updater/ocupdater.h index 08c1c5a92..3983ac397 100644 --- a/src/gui/updater/ocupdater.h +++ b/src/gui/updater/ocupdater.h @@ -72,6 +72,7 @@ public: signals: void updaterAnnouncement(const QString& title, const QString& msg); + void requestRestart(); private slots: void slotTimerFired(); @@ -106,6 +107,7 @@ public: signals: void downloadStateChanged(); void newUpdateAvailable(const QString& header, const QString& message); + void requestRestart(); public slots: void slotStartInstaller(); @@ -166,9 +168,11 @@ class PassiveUpdateNotifier : public OCUpdater { public: explicit PassiveUpdateNotifier(const QUrl &url, QObject *parent = 0); bool handleStartup() Q_DECL_OVERRIDE { return false; } + void backgroundCheckForUpdate() Q_DECL_OVERRIDE; private: void versionInfoArrived(const UpdateInfo &info) Q_DECL_OVERRIDE; + QByteArray _runningAppVersion; };