diff --git a/linphone-app/src/components/notifier/Notifier.cpp b/linphone-app/src/components/notifier/Notifier.cpp index 89fab2433..6a7e5d238 100644 --- a/linphone-app/src/components/notifier/Notifier.cpp +++ b/linphone-app/src/components/notifier/Notifier.cpp @@ -63,7 +63,6 @@ namespace { constexpr int NotificationSpacing = 10; constexpr int MaxNotificationsNumber = 5; - constexpr int MaxTimeout = 30000; } // ============================================================================= @@ -81,14 +80,16 @@ void setProperty (QObject &object, const char *property, const T &value) { // ============================================================================= const QHash Notifier::Notifications = { - { Notifier::ReceivedMessage, { "NotificationReceivedMessage.qml", 10 } }, - { Notifier::ReceivedFileMessage, { "NotificationReceivedFileMessage.qml", 10 } }, - { Notifier::ReceivedCall, { "NotificationReceivedCall.qml", 30 } }, - { Notifier::NewVersionAvailable, { "NotificationNewVersionAvailable.qml", 30 } }, - { Notifier::SnapshotWasTaken, { "NotificationSnapshotWasTaken.qml", 10 } }, - { Notifier::RecordingCompleted, { "NotificationRecordingCompleted.qml", 10 } } + { Notifier::ReceivedMessage, { Notifier::ReceivedMessage, "NotificationReceivedMessage.qml", 10 } }, + { Notifier::ReceivedFileMessage, { Notifier::ReceivedFileMessage, "NotificationReceivedFileMessage.qml", 10 } }, + { Notifier::ReceivedCall, { Notifier::ReceivedCall, "NotificationReceivedCall.qml", 30 } }, + { Notifier::NewVersionAvailable, { Notifier::NewVersionAvailable, "NotificationNewVersionAvailable.qml", 30 } }, + { Notifier::SnapshotWasTaken, { Notifier::SnapshotWasTaken, "NotificationSnapshotWasTaken.qml", 10 } }, + { Notifier::RecordingCompleted, { Notifier::RecordingCompleted, "NotificationRecordingCompleted.qml", 10 } } }; + + // ----------------------------------------------------------------------------- Notifier::Notifier (QObject *parent) : QObject(parent) { @@ -206,7 +207,7 @@ void Notifier::showNotification (QObject *notification, int timeout) { QMetaObject::invokeMethod(notification, NotificationShowMethodName, Qt::DirectConnection); QTimer *timer = new QTimer(notification); - timer->setInterval(timeout > MaxTimeout ? MaxTimeout : timeout); + timer->setInterval(timeout); timer->setSingleShot(true); notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer)); @@ -266,7 +267,7 @@ void Notifier::deleteNotification (QVariant notification) { QObject * notification = createNotification(TYPE, DATA); \ if (!notification) \ return; \ - const int timeout = Notifications[TYPE].timeout * 1000; \ + const int timeout = Notifications[TYPE].getTimeout() * 1000; \ showNotification(notification, timeout); // ----------------------------------------------------------------------------- diff --git a/linphone-app/src/components/notifier/Notifier.hpp b/linphone-app/src/components/notifier/Notifier.hpp index 9e508617f..990e1bba7 100644 --- a/linphone-app/src/components/notifier/Notifier.hpp +++ b/linphone-app/src/components/notifier/Notifier.hpp @@ -26,64 +26,74 @@ #include #include +#include "components/core/CoreManager.hpp" +#include "components/settings/SettingsModel.hpp" // ============================================================================= class QMutex; class QQmlComponent; namespace linphone { - class Call; - class ChatMessage; +class Call; +class ChatMessage; } class Notifier : public QObject { - Q_OBJECT; - + Q_OBJECT; + public: - Notifier (QObject *parent = Q_NULLPTR); - ~Notifier (); - - enum NotificationType { - ReceivedMessage, - ReceivedFileMessage, - ReceivedCall, - NewVersionAvailable, - SnapshotWasTaken, - RecordingCompleted - }; - - void notifyReceivedMessage (const std::shared_ptr &message); - void notifyReceivedFileMessage (const std::shared_ptr &message); - void notifyReceivedCall (const std::shared_ptr &call); - void notifyNewVersionAvailable (const QString &version, const QString &url); - void notifySnapshotWasTaken (const QString &filePath); - void notifyRecordingCompleted (const QString &filePath); - + Notifier (QObject *parent = Q_NULLPTR); + ~Notifier (); + + enum NotificationType { + ReceivedMessage, + ReceivedFileMessage, + ReceivedCall, + NewVersionAvailable, + SnapshotWasTaken, + RecordingCompleted + }; + + void notifyReceivedMessage (const std::shared_ptr &message); + void notifyReceivedFileMessage (const std::shared_ptr &message); + void notifyReceivedCall (const std::shared_ptr &call); + void notifyNewVersionAvailable (const QString &version, const QString &url); + void notifySnapshotWasTaken (const QString &filePath); + void notifyRecordingCompleted (const QString &filePath); + public slots: - void deleteNotificationOnTimeout(QVariant notification); - void deleteNotification (QVariant notification); - + void deleteNotificationOnTimeout(QVariant notification); + void deleteNotification (QVariant notification); + private: - struct Notification { - Notification (const QString &filename = QString(""), int timeout = 0) { - this->filename = filename; - this->timeout = timeout; - } - - QString filename; - int timeout; - }; - - QObject *createNotification (NotificationType type, QVariantMap data); - void showNotification (QObject *notification, int timeout); - - QHash mScreenHeightOffset; - int mInstancesNumber = 0; - - QMutex *mMutex = nullptr; - QQmlComponent **mComponents = nullptr; - - static const QHash Notifications; + struct Notification { + Notification (const int& type = 0, const QString &filename = QString(""), int timeout = 0) { + this->type = type; + this->filename = filename; + this->timeout = timeout; + } + int getTimeout() const{ + if( type == Notifier::ReceivedCall){ + return CoreManager::getInstance()->getSettingsModel()->getIncomingCallTimeout(); + }else + return timeout; + } + QString filename; + private: + int timeout; + int type; + }; + + QObject *createNotification (NotificationType type, QVariantMap data); + void showNotification (QObject *notification, int timeout); + + QHash mScreenHeightOffset; + int mInstancesNumber = 0; + + QMutex *mMutex = nullptr; + QQmlComponent **mComponents = nullptr; + + static const QHash Notifications; }; #endif // NOTIFIER_H_ diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index e880815a9..c10c7e2d2 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -798,6 +798,9 @@ void SettingsModel::setContactsEnabled (bool status) { emit contactsEnabledChanged(getContactsEnabled ()); } +int SettingsModel::getIncomingCallTimeout() const { + return CoreManager::getInstance()->getCore()->getIncTimeout(); +} // ============================================================================= // Network. // ============================================================================= diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 0e226c384..e8c0289c0 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -370,6 +370,8 @@ public: bool getContactsEnabled () const; void setContactsEnabled (bool status); + int getIncomingCallTimeout() const; + // Network. ------------------------------------------------------------------ bool getShowNetworkSettings () const;