diff --git a/linphone-app/assets/languages/cs.ts b/linphone-app/assets/languages/cs.ts
index 1f82f51f2..3b6bc2ba7 100644
--- a/linphone-app/assets/languages/cs.ts
+++ b/linphone-app/assets/languages/cs.ts
@@ -2391,7 +2391,7 @@ Klikněte zde: <a href="%1">%1</a>
newVersionAvailable
K dispozici je nová verze (%1)!
-
+
newFileMessage
Obdržena nová příloha!
diff --git a/linphone-app/assets/languages/en.ts b/linphone-app/assets/languages/en.ts
index 2fc06a141..258302fcf 100644
--- a/linphone-app/assets/languages/en.ts
+++ b/linphone-app/assets/languages/en.ts
@@ -1922,6 +1922,26 @@ Click here: <a href="%1">%1</a>
MainWindow
+
+ newVersionCheckError
+ An error occured checking for a new version. Try again later or contact support if problem persists.
+
+
+ newVersionAvailableInstructions
+ To upgrade to the new version, download the package and install it over the existing one
+
+
+ downloadUpdate
+ Download
+
+
+ noNewVersionAvailable
+ Your application is up to date.
+
+
+ newVersionInstalled
+ New application version successfully installed.
+
mainSearchBarPlaceholder
Search contact, start a call or a chat…
diff --git a/linphone-app/assets/languages/fr_FR.ts b/linphone-app/assets/languages/fr_FR.ts
index c6d0d8489..3ac8eb623 100644
--- a/linphone-app/assets/languages/fr_FR.ts
+++ b/linphone-app/assets/languages/fr_FR.ts
@@ -1922,6 +1922,26 @@ Cliquez ici : <a href="%1">%1</a>
MainWindow
+
+ newVersionCheckError
+ Une erreur est survenue. Merci de réessayer plus tard ou de contacter le support.
+
+
+ newVersionAvailableInstructions
+ Pour mettre à jour télécharger l'application et lancer l'installeur.
+
+
+ downloadUpdate
+ Télécharger
+
+
+ noNewVersionAvailable
+ Votre application est à jour.
+
+
+ newVersionInstalled
+ La nouvelle version de l'application a été installée avec succès.
+
mainSearchBarPlaceholder
Chercher un contact, appeler ou envoyer un message…
diff --git a/linphone-app/src/app/App.cpp b/linphone-app/src/app/App.cpp
index e135fefec..e85c834bc 100644
--- a/linphone-app/src/app/App.cpp
+++ b/linphone-app/src/app/App.cpp
@@ -298,6 +298,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
qInfo() << QStringLiteral("Received command from other application: `%1`.").arg(command);
Cli::executeCommand(command);
});
+ mCheckForUpdateUserInitiated = false;
}
App::~App () {
@@ -1162,6 +1163,12 @@ void App::openAppAfterInit (bool mustBeIconified) {
#endif
setOpened(true);
useFetchConfig(fetchFilePath);
+
+ QString lastRunningVersion = CoreManager::getInstance()->getSettingsModel()->getLastRunningVersionOfApp();
+ if (lastRunningVersion != "unknown" && lastRunningVersion != applicationVersion()) {
+ emit CoreManager::getInstance()->userInitiatedVersionUpdateCheckResult(3, "", "");
+ }
+ CoreManager::getInstance()->getSettingsModel()->setLastRunningVersionOfApp(applicationVersion());
}
// -----------------------------------------------------------------------------
@@ -1187,10 +1194,11 @@ void App::checkForUpdate() {
checkForUpdates(false);
}
void App::checkForUpdates(bool force) {
- if(force || CoreManager::getInstance()->getSettingsModel()->isCheckForUpdateEnabled())
+ if(force || CoreManager::getInstance()->getSettingsModel()->isCheckForUpdateEnabled()) {
+ getInstance()->mCheckForUpdateUserInitiated = force;
CoreManager::getInstance()->getCore()->checkForUpdate(
- Utils::appStringToCoreString(applicationVersion())
- );
+ Utils::appStringToCoreString(applicationVersion()));
+ }
}
bool App::isPdfAvailable(){
diff --git a/linphone-app/src/app/App.hpp b/linphone-app/src/app/App.hpp
index 240633dc6..2fc5b36a6 100644
--- a/linphone-app/src/app/App.hpp
+++ b/linphone-app/src/app/App.hpp
@@ -122,6 +122,7 @@ public:
Q_INVOKABLE QQuickWindow *getSettingsWindow () const;
Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);
+ bool mCheckForUpdateUserInitiated;
Q_INVOKABLE static void checkForUpdates(bool force = false);
// Check module availability when no dependencies are needed (else use SettingsModel)
diff --git a/linphone-app/src/components/core/CoreHandlers.cpp b/linphone-app/src/components/core/CoreHandlers.cpp
index 5a67bb05a..1a1669f77 100644
--- a/linphone-app/src/components/core/CoreHandlers.cpp
+++ b/linphone-app/src/components/core/CoreHandlers.cpp
@@ -449,11 +449,23 @@ void CoreHandlers::onVersionUpdateCheckResultReceived (
const string &version,
const string &url
) {
- if (result == linphone::VersionUpdateCheckResult::NewVersionAvailable)
- App::getInstance()->getNotifier()->notifyNewVersionAvailable(
- Utils::coreStringToAppString(version),
- Utils::coreStringToAppString(url)
- );
+
+ if (App::getInstance()->mCheckForUpdateUserInitiated) {
+ App::getInstance()->mCheckForUpdateUserInitiated = false;
+ if (result == linphone::VersionUpdateCheckResult::Error) {
+ emit CoreManager::getInstance()->userInitiatedVersionUpdateCheckResult(0);
+ } else if (result == linphone::VersionUpdateCheckResult::NewVersionAvailable) {
+ emit CoreManager::getInstance()->userInitiatedVersionUpdateCheckResult(1, Utils::coreStringToAppString(version), Utils::coreStringToAppString(url));
+ } else if (result == linphone::VersionUpdateCheckResult::UpToDate) {
+ emit CoreManager::getInstance()->userInitiatedVersionUpdateCheckResult(2);
+ }
+ } else {
+ if (result == linphone::VersionUpdateCheckResult::NewVersionAvailable)
+ App::getInstance()->getNotifier()->notifyNewVersionAvailable(
+ Utils::coreStringToAppString(version),
+ Utils::coreStringToAppString(url)
+ );
+ }
}
void CoreHandlers::onEcCalibrationResult(
const std::shared_ptr &,
diff --git a/linphone-app/src/components/core/CoreManager.hpp b/linphone-app/src/components/core/CoreManager.hpp
index f4af36360..6a32f578a 100644
--- a/linphone-app/src/components/core/CoreManager.hpp
+++ b/linphone-app/src/components/core/CoreManager.hpp
@@ -192,8 +192,9 @@ signals:
void eventCountChanged ();
void callLogsCountChanged();
- void remoteProvisioningFailed();
-
+ void remoteProvisioningFailed();
+ void userInitiatedVersionUpdateCheckResult(int result, QString version = nullptr, QString url = nullptr);
+
private:
CoreManager (QObject *parent, const QString &configPath);
~CoreManager ();
diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp
index b316accfb..806c3aa4d 100644
--- a/linphone-app/src/components/settings/SettingsModel.cpp
+++ b/linphone-app/src/components/settings/SettingsModel.cpp
@@ -1689,6 +1689,15 @@ void SettingsModel::setVersionCheckUrl(const QString& url){
}
}
+QString SettingsModel::getLastRunningVersionOfApp(){
+ auto version = mConfig->getString("app_version", "last_running", "unknown");
+ return Utils::coreStringToAppString(version);
+}
+
+void SettingsModel::setLastRunningVersionOfApp(const QString& version){
+ mConfig->setString("app_version", "last_running", Utils::appStringToCoreString(version));
+}
+
SettingsModel::VersionCheckType SettingsModel::getVersionCheckType() const{
return (SettingsModel::VersionCheckType) mConfig->getInt(UiSection, "version_check_type", (int)VersionCheckType_Release);
}
diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp
index e38927a4b..cd5ccd0b7 100644
--- a/linphone-app/src/components/settings/SettingsModel.hpp
+++ b/linphone-app/src/components/settings/SettingsModel.hpp
@@ -614,6 +614,9 @@ public:
QString getVersionCheckUrl();
void setVersionCheckUrl(const QString& url);
+ QString getLastRunningVersionOfApp();
+ void setLastRunningVersionOfApp (const QString& version);
+
VersionCheckType getVersionCheckType() const;
void setVersionCheckType(const VersionCheckType& type);
Q_INVOKABLE bool haveVersionNightlyUrl()const;
diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp
index c8e68877d..37c227765 100644
--- a/linphone-app/src/utils/Utils.cpp
+++ b/linphone-app/src/utils/Utils.cpp
@@ -21,7 +21,6 @@
#include
#include
#include
-#include
#include
#include
#include
diff --git a/linphone-app/src/utils/Utils.hpp b/linphone-app/src/utils/Utils.hpp
index 547a3801b..e7624b080 100644
--- a/linphone-app/src/utils/Utils.hpp
+++ b/linphone-app/src/utils/Utils.hpp
@@ -26,6 +26,8 @@
#include
#include
#include
+#include
+
#include
diff --git a/linphone-app/ui/views/App/Main/MainWindow.js b/linphone-app/ui/views/App/Main/MainWindow.js
index 6bf7cfc1c..d6dae277d 100644
--- a/linphone-app/ui/views/App/Main/MainWindow.js
+++ b/linphone-app/ui/views/App/Main/MainWindow.js
@@ -122,3 +122,14 @@ function handleAuthenticationRequested (authInfo, realm, sipAddress, userId) {
function warnProvisioningFailed(window) {
Utils.infoDialog(window, qsTr('lastProvisioningFailed'))
}
+
+function proposeDownloadUpdate(window, version, url) {
+ window.attachVirtualWindow(Utils.buildCommonDialogUri('ConfirmDialog'), {
+ descriptionText:qsTr('newVersionAvailable').replace("%1", version)+"\n"+qsTr('newVersionAvailableInstructions'),
+ buttonTexts : [qsTr('cancel'),qsTr('downloadUpdate')]
+ }, function (status) {
+ if (status) {
+ Qt.openUrlExternally(url)
+ }
+ })
+}
diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml
index 5b45977b8..7eaca553e 100644
--- a/linphone-app/ui/views/App/Main/MainWindow.qml
+++ b/linphone-app/ui/views/App/Main/MainWindow.qml
@@ -22,6 +22,7 @@ ApplicationWindow {
property string _currentView
property var _lockedInfo
property SmartSearchBar mainSearchBar : (mainLoader.item ? mainLoader.item.mainSearchBar : null)
+ property var notifyNewVersionInstallWhenLoaded : false
// ---------------------------------------------------------------------------
@@ -56,7 +57,18 @@ ApplicationWindow {
Connections {
target: CoreManager
onCoreManagerInitialized: mainLoader.active = true
- onRemoteProvisioningFailed: if(mainLoader.active) Logic.warnProvisioningFailed(window)
+ onRemoteProvisioningFailed: if(mainLoader.active) Logic.warnProvisioningFailed(window)
+ onUserInitiatedVersionUpdateCheckResult: switch(result) {
+ case 0 : Utils.infoDialog(window, qsTr('newVersionCheckError')); break;
+ case 1 : Logic.proposeDownloadUpdate(window, version, url); break;
+ case 2 : Utils.infoDialog(window, qsTr('noNewVersionAvailable')+"\n"+Qt.application.version); break;
+ case 3 : if (mainLoader.active)
+ Utils.infoDialog(window, qsTr('newVersionInstalled')+"\n"+Qt.application.version)
+ else
+ notifyNewVersionInstallWhenLoaded = true
+ break;
+ default : {}
+ }
}
Shortcut {
@@ -72,16 +84,20 @@ ApplicationWindow {
anchors.fill: parent
onLoaded: {
- if(!CoreManager.isLastRemoteProvisioningGood()) {
- Logic.warnProvisioningFailed(window)
- }
- switch(SettingsModel.getShowDefaultPage()) {
- case 1 : window.setView('Calls'); break;
- case 2 : window.setView('Conversations'); break;
- case 3 : ContactsListModel.update(); window.setView('Contacts'); break;
- case 4 : window.setView('Conferences'); break;
- default:{}
- }
+ if(!CoreManager.isLastRemoteProvisioningGood()) {
+ Logic.warnProvisioningFailed(window)
+ }
+ if (notifyNewVersionInstallWhenLoaded) {
+ notifyNewVersionInstallWhenLoaded = false
+ Utils.infoDialog(window, qsTr('newVersionInstalled')+"\n"+Qt.application.version)
+ }
+ switch(SettingsModel.getShowDefaultPage()) {
+ case 1 : window.setView('Calls'); break;
+ case 2 : window.setView('Conversations'); break;
+ case 3 : ContactsListModel.update(); window.setView('Contacts'); break;
+ case 4 : window.setView('Conferences'); break;
+ default:{}
+ }
}
sourceComponent: ColumnLayout {