diff --git a/Linphone/core/notifier/Notifier.cpp b/Linphone/core/notifier/Notifier.cpp index 9509dbb79..06c83f663 100644 --- a/Linphone/core/notifier/Notifier.cpp +++ b/Linphone/core/notifier/Notifier.cpp @@ -385,6 +385,11 @@ void Notifier::notifyReceivedMessages(const std::shared_ptr map["chat"] = QVariant::fromValue(chatCore ? new ChatGui(chatCore) : nullptr); CREATE_NOTIFICATION(Notifier::ReceivedMessage, map) }); + auto settings = SettingsModel::getInstance(); + if (settings && !settings->dndEnabled()) { + CoreModel::getInstance()->getCore()->playLocal( + Utils::appStringToCoreString(settings->getChatNotificationSoundPath())); + } } } /* diff --git a/Linphone/core/variant/VariantList.hpp b/Linphone/core/variant/VariantList.hpp index e1c2a837c..f3d2e6f5c 100644 --- a/Linphone/core/variant/VariantList.hpp +++ b/Linphone/core/variant/VariantList.hpp @@ -31,7 +31,7 @@ class VariantList : public AbstractListProxy, public AbstractObject { Q_OBJECT - Q_PROPERTY(QList model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QList model READ getModel WRITE setModel NOTIFY modelChanged) public: VariantList(QObject *parent = Q_NULLPTR); VariantList(QList list, QObject *parent = Q_NULLPTR); diff --git a/Linphone/model/address-books/ldap/LdapModel.cpp b/Linphone/model/address-books/ldap/LdapModel.cpp index 1fc66ccef..346d73623 100644 --- a/Linphone/model/address-books/ldap/LdapModel.cpp +++ b/Linphone/model/address-books/ldap/LdapModel.cpp @@ -82,7 +82,7 @@ bool LdapModel::getDebug() const { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); return mLdapParamsClone->getDebugLevel() == linphone::Ldap::DebugLevel::Verbose; } -void LdapModel::setDebug(bool data) { +void LdapModel::setDebug(const bool &data) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); if (getDebug() != data) { mLdapParamsClone->setDebugLevel(data ? linphone::Ldap::DebugLevel::Verbose : linphone::Ldap::DebugLevel::Off); diff --git a/Linphone/model/setting/SettingsModel.cpp b/Linphone/model/setting/SettingsModel.cpp index 6d5f45254..8ec9744ab 100644 --- a/Linphone/model/setting/SettingsModel.cpp +++ b/Linphone/model/setting/SettingsModel.cpp @@ -652,7 +652,7 @@ bool SettingsModel::getIpv6Enabled() const { return CoreModel::getInstance()->getCore()->ipv6Enabled(); } -void SettingsModel::setIpv6Enabled(bool status) { +void SettingsModel::setIpv6Enabled(const bool &status) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); if (getIpv6Enabled() != status) { CoreModel::getInstance()->getCore()->enableIpv6(status); @@ -728,7 +728,7 @@ QVariantList SettingsModel::getShortcuts() const { return shortcuts; } -void SettingsModel::setShortcuts(QVariantList data) { +void SettingsModel::setShortcuts(const QVariantList &data) { if (getShortcuts() != data) { // clean auto sections = mConfig->getSectionsNamesList(); @@ -773,12 +773,23 @@ QString SettingsModel::getCallForwardToAddress() const { return Utils::coreStringToAppString(mConfig->getString(UiSection, "call_forward_to_address", "")); } -void SettingsModel::setCallForwardToAddress(QString data) { +void SettingsModel::setCallForwardToAddress(const QString &data) { if (data == "") disableCallForward(); else enableCallForward(data); emit(callForwardToAddressChanged(data)); } +QString SettingsModel::getChatNotificationSoundPath() const { + static const string defaultFile = linphone::Factory::get()->getSoundResourcesDir() + "/incoming_chat.wav"; + return Utils::coreStringToAppString(mConfig->getString(UiSection, "chat_sound_notification_file", defaultFile)); +} + +void SettingsModel::setChatNotificationSoundPath(const QString &path) { + QString cleanedPath = QDir::cleanPath(path); + mConfig->setString(UiSection, "chat_sound_notification_file", Utils::appStringToCoreString(cleanedPath)); + emit chatNotificationSoundPathChanged(cleanedPath); +} + QFont SettingsModel::getEmojiFont() const { QString family = Utils::coreStringToAppString(mConfig->getString( UiSection, "emoji_font", Utils::appStringToCoreString(QFont(Constants::DefaultEmojiFont).family()))); diff --git a/Linphone/model/setting/SettingsModel.hpp b/Linphone/model/setting/SettingsModel.hpp index 5dedc5fe3..a5b4474cd 100644 --- a/Linphone/model/setting/SettingsModel.hpp +++ b/Linphone/model/setting/SettingsModel.hpp @@ -198,6 +198,7 @@ public: DECLARE_GETSET(bool, disableCommandLine, DisableCommandLine) DECLARE_GETSET(bool, disableCallForward, DisableCallForward) DECLARE_GETSET(QString, callForwardToAddress, CallForwardToAddress) + DECLARE_GETSET(QString, chatNotificationSoundPath, ChatNotificationSoundPath) signals: void logsUploadUrlChanged(); diff --git a/Linphone/tool/AbstractObject.hpp b/Linphone/tool/AbstractObject.hpp index 0c4104da4..7d98b51d9 100644 --- a/Linphone/tool/AbstractObject.hpp +++ b/Linphone/tool/AbstractObject.hpp @@ -63,7 +63,7 @@ public: #define DECLARE_CORE_GETSET_MEMBER(type, x, X) \ Q_PROPERTY(type x MEMBER m##X WRITE set##X NOTIFY x##Changed) \ - Q_SIGNAL void set##X(type data); \ + Q_SIGNAL void set##X(const type &data); \ Q_SIGNAL void x##Changed(); \ type m##X; @@ -74,14 +74,14 @@ public: #define DECLARE_CORE_GETSET(type, x, X) \ Q_PROPERTY(type x READ get##X WRITE set##X NOTIFY x##Changed) \ - Q_SIGNAL void set##X(type data); \ + Q_SIGNAL void set##X(const type &data); \ type get##X() const; \ Q_SIGNAL void x##Changed(); \ type m##X; #define DECLARE_GUI_GETSET(type, x, X) \ Q_PROPERTY(type x READ get##X WRITE set##X NOTIFY x##Changed) \ - void set##X(type data); \ + void set##X(const type &data); \ type get##X() const; \ Q_SIGNAL void x##Changed(); \ type m##X; @@ -94,11 +94,13 @@ public: #define DECLARE_CORE_GET_CONSTANT(type, x, X) \ Q_PROPERTY(type x MEMBER m##X CONSTANT) \ type m##X; \ - type get##X() const { return m##X;} + type get##X() const { \ + return m##X; \ + } #define DECLARE_GETSET(type, x, X) \ type get##X() const; \ - void set##X(type data); \ + void set##X(const type &data); \ Q_SIGNAL void x##Changed(type x); #define INIT_CORE_MEMBER(X, model) m##X = model->get##X(); @@ -129,7 +131,7 @@ public: mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ return !!mConfig->get##Type(UiSection, key, def); \ } \ - void Class::set##X(type data) { \ + void Class::set##X(const type &data) { \ if (get##X() != data) { \ mConfig->set##Type(UiSection, key, data); \ emit x##Changed(data); \ @@ -141,7 +143,7 @@ public: mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ return Utils::coreStringToAppString(mConfig->getString(UiSection, key, def)); \ } \ - void Class::set##X(QString data) { \ + void Class::set##X(const QString &data) { \ if (get##X() != data) { \ mConfig->setString(UiSection, key, Utils::appStringToCoreString(data)); \ emit x##Changed(data); \ @@ -152,14 +154,14 @@ public: #define DECLARE_GETSET_API(type, x, X) \ type get##X() const; \ - void set##X(type data); \ + void set##X(const type &data); \ Q_SIGNAL void x##Changed(type x); #define DEFINE_GET_SET_API(Class, type, x, X) \ type Class::get##X() const { \ return m##X; \ } \ - void Class::set##X(type data) { \ + void Class::set##X(const type &data) { \ if (get##X() != data) { \ m##X = data; \ emit x##Changed(); \ @@ -171,7 +173,7 @@ public: mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ return ownerNotNull->get##X(); \ } \ - void Class::set##X(type data) { \ + void Class::set##X(const type &data) { \ mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ if (get##X() != data) { \ ownerNotNull->set##X(data); \ @@ -196,7 +198,7 @@ public: mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ return Utils::coreStringToAppString(ownerNotNull->get##X()); \ } \ - void Class::set##X(QString data) { \ + void Class::set##X(const QString &data) { \ mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ if (get##X() != data) { \ ownerNotNull->set##X(Utils::appStringToCoreString(data)); \ @@ -209,7 +211,7 @@ public: mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ return ownerNotNull->x##Enabled(); \ } \ - void Class::set##X(bool data) { \ + void Class::set##X(const bool &data) { \ mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ if (get##X() != data) { \ ownerNotNull->enable##X(data); \ @@ -222,7 +224,7 @@ public: mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ return ownerNotNull->enabled(); \ } \ - void Class::set##X(bool data) { \ + void Class::set##X(const bool &data) { \ mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); \ if (get##X() != data) { \ ownerNotNull->enable(data); \