Commit b9353adc authored by Ronan Abhamon's avatar Ronan Abhamon

fix(App): check update at startup

parent 93f91b42
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <QtDebug> #include <QtDebug>
#include <QTimer> #include <QTimer>
#include "config.h"
#include "../components/Components.hpp" #include "../components/Components.hpp"
#include "../utils/Utils.hpp" #include "../utils/Utils.hpp"
...@@ -55,6 +57,8 @@ ...@@ -55,6 +57,8 @@
#define SELF_TEST_DELAY 300000 #define SELF_TEST_DELAY 300000
#define VERSION_UPDATE_CHECK_INTERVAL 86400000 // 24 hours in milliseconds.
using namespace std; using namespace std;
// ============================================================================= // =============================================================================
...@@ -256,12 +260,6 @@ void App::smartShowWindow (QQuickWindow *window) { ...@@ -256,12 +260,6 @@ void App::smartShowWindow (QQuickWindow *window) {
window->requestActivate(); window->requestActivate();
} }
void App::checkForUpdate () {
CoreManager::getInstance()->getCore()->checkForUpdate(
::Utils::appStringToCoreString(applicationVersion())
);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool App::hasFocus () const { bool App::hasFocus () const {
...@@ -528,6 +526,24 @@ void App::openAppAfterInit () { ...@@ -528,6 +526,24 @@ void App::openAppAfterInit () {
if (!commandArgument.isEmpty()) if (!commandArgument.isEmpty())
executeCommand(commandArgument); executeCommand(commandArgument);
} }
#ifdef ENABLE_UPDATE_CHECK
QTimer *timer = new QTimer(mEngine);
timer->setInterval(VERSION_UPDATE_CHECK_INTERVAL);
QObject::connect(timer, &QTimer::timeout, this, &App::checkForUpdate);
timer->start();
checkForUpdate();
#endif // ifdef ENABLE_UPDATE_CHECK
}
// -----------------------------------------------------------------------------
void App::checkForUpdate () {
CoreManager::getInstance()->getCore()->checkForUpdate(
::Utils::appStringToCoreString(applicationVersion())
);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -78,7 +78,6 @@ public: ...@@ -78,7 +78,6 @@ public:
Q_INVOKABLE QQuickWindow *getSettingsWindow (); Q_INVOKABLE QQuickWindow *getSettingsWindow ();
Q_INVOKABLE static void smartShowWindow (QQuickWindow *window); Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);
Q_INVOKABLE static void checkForUpdate ();
public slots: public slots:
void quit (); void quit ();
...@@ -109,6 +108,8 @@ private: ...@@ -109,6 +108,8 @@ private:
void openAppAfterInit (); void openAppAfterInit ();
static void checkForUpdate ();
static QString getQtVersion () { static QString getQtVersion () {
return qVersion(); return qVersion();
} }
......
...@@ -31,11 +31,6 @@ ...@@ -31,11 +31,6 @@
#include "CoreHandlers.hpp" #include "CoreHandlers.hpp"
#include "config.h"
#define VERSION_UPDATE_CHECK_OBJECT_NAME "version-update-check-timer"
#define VERSION_UPDATE_CHECK_INTERVAL 86400000 /* 24 hours in milliseconds. */
using namespace std; using namespace std;
// ============================================================================= // =============================================================================
...@@ -78,16 +73,6 @@ void CoreHandlers::notifyCoreStarted () { ...@@ -78,16 +73,6 @@ void CoreHandlers::notifyCoreStarted () {
[this]() { [this]() {
qInfo() << QStringLiteral("Core started."); qInfo() << QStringLiteral("Core started.");
emit coreStarted(); emit coreStarted();
#ifdef ENABLE_UPDATE_CHECK
QTimer *timer = new QTimer(this);
timer->setInterval(VERSION_UPDATE_CHECK_INTERVAL);
QObject::connect(timer, &QTimer::timeout, this, &App::checkForUpdate);
timer->start();
App::checkForUpdate();
#endif // ifdef ENABLE_UPDATE_CHECK
}); });
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "app/App.hpp" #include "app/App.hpp"
// Must be unique. Used by `SingleApplication`. // Must be unique. Used by `SingleApplication` and `Paths`.
#define APPLICATION_NAME "linphone" #define APPLICATION_NAME "linphone"
#define APPLICATION_VERSION LINPHONE_QT_GIT_VERSION #define APPLICATION_VERSION LINPHONE_QT_GIT_VERSION
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment