Commit c1e85765 authored by Ghislain MARY's avatar Ghislain MARY

Handle version update check.

parent e81c7a7e
...@@ -24,6 +24,7 @@ lcb_external_source_paths("../linphone-desktop") ...@@ -24,6 +24,7 @@ lcb_external_source_paths("../linphone-desktop")
lcb_dependencies("linphone" "ms2plugins") lcb_dependencies("linphone" "ms2plugins")
lcb_groupable(YES) lcb_groupable(YES)
lcb_cmake_options("-DENABLE_UPDATE_CHECK=${ENABLE_UPDATE_CHECK}")
# Add config step for packaging # Add config step for packaging
set(LINPHONE_BUILDER_ADDITIONAL_CONFIG_STEPS "${CMAKE_CURRENT_LIST_DIR}/additional_steps.cmake") set(LINPHONE_BUILDER_ADDITIONAL_CONFIG_STEPS "${CMAKE_CURRENT_LIST_DIR}/additional_steps.cmake")
...@@ -29,6 +29,8 @@ set(CMAKE_CXX_STANDARD 11) ...@@ -29,6 +29,8 @@ set(CMAKE_CXX_STANDARD 11)
set(ASSETS_DIR assets) set(ASSETS_DIR assets)
option(ENABLE_UPDATE_CHECK "Enable update check." NO)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
......
...@@ -887,6 +887,13 @@ your friend&apos;s SIP address or username.</translation> ...@@ -887,6 +887,13 @@ your friend&apos;s SIP address or username.</translation>
<translation>Play me!</translation> <translation>Play me!</translation>
</message> </message>
</context> </context>
<context>
<name>Notifier</name>
<message>
<source>newVersionAvailable</source>
<translation>A new version (%1) of Linphone is available!</translation>
</message>
</context>
<context> <context>
<name>OutgoingMessage</name> <name>OutgoingMessage</name>
<message> <message>
......
...@@ -886,6 +886,13 @@ un chat ou ajouter un contact.</translation> ...@@ -886,6 +886,13 @@ un chat ou ajouter un contact.</translation>
<translation>Joue-moi !</translation> <translation>Joue-moi !</translation>
</message> </message>
</context> </context>
<context>
<name>Notifier</name>
<message>
<source>newVersionAvailable</source>
<translation>Une nouvelle version (%1) de Linphone est disponible !</translation>
</message>
</context>
<context> <context>
<name>OutgoingMessage</name> <name>OutgoingMessage</name>
<message> <message>
......
[misc]
version_check_url_root=https://linphone.org/releases
[sound] [sound]
ec_filter=MSWebRTCAEC ec_filter=MSWebRTCAEC
...@@ -21,3 +21,4 @@ ...@@ -21,3 +21,4 @@
*******************************************************************************/ *******************************************************************************/
#cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}" #cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}"
#cmakedefine ENABLE_UPDATE_CHECK 1
\ No newline at end of file
...@@ -324,6 +324,7 @@ ...@@ -324,6 +324,7 @@
<file>ui/modules/Linphone/Contact/MessagesCounter.qml</file> <file>ui/modules/Linphone/Contact/MessagesCounter.qml</file>
<file>ui/modules/Linphone/Menus/SipAddressesMenu.qml</file> <file>ui/modules/Linphone/Menus/SipAddressesMenu.qml</file>
<file>ui/modules/Linphone/Notifications/Notification.qml</file> <file>ui/modules/Linphone/Notifications/Notification.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationNewVersionAvailable.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedCall.qml</file> <file>ui/modules/Linphone/Notifications/NotificationReceivedCall.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml</file> <file>ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml</file> <file>ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml</file>
...@@ -344,6 +345,7 @@ ...@@ -344,6 +345,7 @@
<file>ui/modules/Linphone/Styles/Contact/ContactStyle.qml</file> <file>ui/modules/Linphone/Styles/Contact/ContactStyle.qml</file>
<file>ui/modules/Linphone/Styles/Contact/MessagesCounterStyle.qml</file> <file>ui/modules/Linphone/Styles/Contact/MessagesCounterStyle.qml</file>
<file>ui/modules/Linphone/Styles/Menus/SipAddressesMenuStyle.qml</file> <file>ui/modules/Linphone/Styles/Menus/SipAddressesMenuStyle.qml</file>
<file>ui/modules/Linphone/Styles/Notifications/NotificationNewVersionAvailableStyle.qml</file>
<file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedCallStyle.qml</file> <file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedCallStyle.qml</file>
<file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedFileMessageStyle.qml</file> <file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedFileMessageStyle.qml</file>
<file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedMessageStyle.qml</file> <file>ui/modules/Linphone/Styles/Notifications/NotificationReceivedMessageStyle.qml</file>
......
...@@ -293,6 +293,10 @@ void App::smartShowWindow (QQuickWindow *window) { ...@@ -293,6 +293,10 @@ void App::smartShowWindow (QQuickWindow *window) {
window->requestActivate(); window->requestActivate();
} }
void App::checkForUpdate () {
CoreManager::getInstance()->getCore()->checkForUpdate(LINPHONE_QT_GIT_VERSION);
}
QString App::convertUrlToLocalPath (const QUrl &url) { QString App::convertUrlToLocalPath (const QUrl &url) {
return QDir::toNativeSeparators(url.toLocalFile()); return QDir::toNativeSeparators(url.toLocalFile());
} }
......
...@@ -77,6 +77,7 @@ public: ...@@ -77,6 +77,7 @@ 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 ();
Q_INVOKABLE static QString convertUrlToLocalPath (const QUrl &url); Q_INVOKABLE static QString convertUrlToLocalPath (const QUrl &url);
public slots: public slots:
......
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
#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;
// ============================================================================= // =============================================================================
...@@ -83,6 +88,15 @@ void CoreHandlers::notifyCoreStarted () { ...@@ -83,6 +88,15 @@ 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);
timer->setObjectName(VERSION_UPDATE_CHECK_OBJECT_NAME);
QObject::connect(timer, &QTimer::timeout, this, &App::checkForUpdate);
timer->start();
App::checkForUpdate();
#endif
} }
); );
} }
...@@ -217,3 +231,14 @@ void CoreHandlers::onTransferStateChanged ( ...@@ -217,3 +231,14 @@ void CoreHandlers::onTransferStateChanged (
break; break;
} }
} }
void CoreHandlers::onVersionUpdateCheckResultReceived (
const shared_ptr<linphone::Core> &,
linphone::VersionUpdateCheckResult result,
const string &version,
const string &url
) {
if (result == linphone::VersionUpdateCheckResultNewVersionAvailable) {
App::getInstance()->getNotifier()->notifyNewVersionAvailable(version, url);
}
}
\ No newline at end of file
...@@ -115,6 +115,13 @@ private: ...@@ -115,6 +115,13 @@ private:
linphone::CallState state linphone::CallState state
) override; ) override;
void onVersionUpdateCheckResultReceived (
const std::shared_ptr<linphone::Core> &,
linphone::VersionUpdateCheckResult result,
const std::string &version,
const std::string &url
) override;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool mCoreCreated = false; bool mCoreCreated = false;
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#define QML_NOTIFICATION_PATH_RECEIVED_MESSAGE "qrc:/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml" #define QML_NOTIFICATION_PATH_RECEIVED_MESSAGE "qrc:/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml"
#define QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE "qrc:/ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml" #define QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE "qrc:/ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml"
#define QML_NOTIFICATION_PATH_RECEIVED_CALL "qrc:/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml" #define QML_NOTIFICATION_PATH_RECEIVED_CALL "qrc:/ui/modules/Linphone/Notifications/NotificationReceivedCall.qml"
#define QML_NOTIFICATION_PATH_NEW_VERSION_AVAILABLE "qrc:/ui/modules/Linphone/Notifications/NotificationNewVersionAvailable.qml"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Timeouts. // Timeouts.
...@@ -62,6 +63,7 @@ ...@@ -62,6 +63,7 @@
#define NOTIFICATION_TIMEOUT_RECEIVED_MESSAGE 10000 #define NOTIFICATION_TIMEOUT_RECEIVED_MESSAGE 10000
#define NOTIFICATION_TIMEOUT_RECEIVED_FILE_MESSAGE 10000 #define NOTIFICATION_TIMEOUT_RECEIVED_FILE_MESSAGE 10000
#define NOTIFICATION_TIMEOUT_RECEIVED_CALL 30000 #define NOTIFICATION_TIMEOUT_RECEIVED_CALL 30000
#define NOTIFICATION_TIMEOUT_NEW_VERSION_AVAILABLE 30000
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Arbitrary hardcoded values. // Arbitrary hardcoded values.
...@@ -106,6 +108,7 @@ Notifier::Notifier (QObject *parent) : ...@@ -106,6 +108,7 @@ Notifier::Notifier (QObject *parent) :
mComponents[Notifier::MessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_MESSAGE)); mComponents[Notifier::MessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_MESSAGE));
mComponents[Notifier::FileMessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE)); mComponents[Notifier::FileMessageReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_FILE_MESSAGE));
mComponents[Notifier::CallReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_CALL)); mComponents[Notifier::CallReceived] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_RECEIVED_CALL));
mComponents[Notifier::NewVersionAvailable] = new QQmlComponent(engine, QUrl(QML_NOTIFICATION_PATH_NEW_VERSION_AVAILABLE));
// Check errors. // Check errors.
for (int i = 0; i < Notifier::MaxNbTypes; ++i) { for (int i = 0; i < Notifier::MaxNbTypes; ++i) {
...@@ -271,3 +274,16 @@ void Notifier::notifyReceivedCall (const shared_ptr<linphone::Call> &call) { ...@@ -271,3 +274,16 @@ void Notifier::notifyReceivedCall (const shared_ptr<linphone::Call> &call) {
::setProperty(*notification, NOTIFICATION_PROPERTY_DATA, map); ::setProperty(*notification, NOTIFICATION_PROPERTY_DATA, map);
showNotification(notification, NOTIFICATION_TIMEOUT_RECEIVED_CALL); showNotification(notification, NOTIFICATION_TIMEOUT_RECEIVED_CALL);
} }
void Notifier::notifyNewVersionAvailable (const std::string &version, const std::string &url) {
QObject *notification = createNotification(Notifier::NewVersionAvailable);
if (!notification)
return;
QVariantMap map;
map["message"] = tr("newVersionAvailable").arg(::Utils::coreStringToAppString(version));
map["url"] = ::Utils::coreStringToAppString(url);
::setProperty(*notification, NOTIFICATION_PROPERTY_DATA, map);
showNotification(notification, NOTIFICATION_TIMEOUT_NEW_VERSION_AVAILABLE);
}
\ No newline at end of file
...@@ -42,12 +42,14 @@ public: ...@@ -42,12 +42,14 @@ public:
MessageReceived, MessageReceived,
FileMessageReceived, FileMessageReceived,
CallReceived, CallReceived,
NewVersionAvailable,
MaxNbTypes MaxNbTypes
}; };
void notifyReceivedMessage (const std::shared_ptr<linphone::ChatMessage> &message); void notifyReceivedMessage (const std::shared_ptr<linphone::ChatMessage> &message);
void notifyReceivedFileMessage (const std::shared_ptr<linphone::ChatMessage> &message); void notifyReceivedFileMessage (const std::shared_ptr<linphone::ChatMessage> &message);
void notifyReceivedCall (const std::shared_ptr<linphone::Call> &call); void notifyReceivedCall (const std::shared_ptr<linphone::Call> &call);
void notifyNewVersionAvailable (const std::string &version, const std::string &url);
public slots: public slots:
void deleteNotification (QVariant notification); void deleteNotification (QVariant notification);
......
import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
import Linphone.Styles 1.0
import Utils 1.0
// =============================================================================
Notification {
id: notification
// ---------------------------------------------------------------------------
Rectangle {
color: NotificationNewVersionAvailableStyle.color
height: NotificationNewVersionAvailableStyle.height
width: NotificationNewVersionAvailableStyle.width
Icon {
anchors {
left: parent.left
top: parent.top
}
icon: 'file_sign'
iconSize: NotificationNewVersionAvailableStyle.iconSize
}
Loader {
active: notificationData.url.length > 0
anchors {
fill: parent
leftMargin: NotificationNewVersionAvailableStyle.leftMargin
rightMargin: NotificationNewVersionAvailableStyle.rightMargin
}
sourceComponent: RowLayout {
anchors.fill: parent
spacing: NotificationNewVersionAvailableStyle.spacing
Text {
Layout.fillWidth: true
Layout.fillHeight: true
topPadding: NotificationNewVersionAvailableStyle.message.topPadding
color: NotificationNewVersionAvailableStyle.message.color
elide: Text.ElideRight
wrapMode: Text.Wrap
font.pointSize: NotificationNewVersionAvailableStyle.message.fontSize
text: notificationData.message
}
}
MouseArea {
anchors.fill: parent
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
hoverEnabled: true
onClicked: notification._close(function () {
Qt.openUrlExternally(notificationData.url)
})
}
}
}
}
pragma Singleton
import QtQuick 2.7
import Common 1.0
// =============================================================================
QtObject {
property color color: Colors.k
property int height: 55
property int iconSize: 40
property int leftMargin: 25
property int rightMargin: 15
property int spacing: 10
property int width: 300
property QtObject message: QtObject {
property color color: Colors.h
property int fontSize: 10
property real topPadding: 10
}
}
...@@ -25,6 +25,7 @@ singleton MessagesCounterStyle 1.0 Contact/MessagesCounterStyle. ...@@ -25,6 +25,7 @@ singleton MessagesCounterStyle 1.0 Contact/MessagesCounterStyle.
singleton SipAddressesMenuStyle 1.0 Menus/SipAddressesMenuStyle.qml singleton SipAddressesMenuStyle 1.0 Menus/SipAddressesMenuStyle.qml
singleton NotificationNewVersionAvailableStyle 1.0 Notifications/NotificationNewVersionAvailableStyle.qml
singleton NotificationReceivedCallStyle 1.0 Notifications/NotificationReceivedCallStyle.qml singleton NotificationReceivedCallStyle 1.0 Notifications/NotificationReceivedCallStyle.qml
singleton NotificationReceivedMessageStyle 1.0 Notifications/NotificationReceivedMessageStyle.qml singleton NotificationReceivedMessageStyle 1.0 Notifications/NotificationReceivedMessageStyle.qml
singleton NotificationReceivedFileMessageStyle 1.0 Notifications/NotificationReceivedFileMessageStyle.qml singleton NotificationReceivedFileMessageStyle 1.0 Notifications/NotificationReceivedFileMessageStyle.qml
......
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