diff --git a/src/components/core/CoreHandlers.cpp b/src/components/core/CoreHandlers.cpp index af1452552..c046f15fe 100644 --- a/src/components/core/CoreHandlers.cpp +++ b/src/components/core/CoreHandlers.cpp @@ -29,6 +29,7 @@ #include "components/call/CallModel.hpp" #include "components/contact/ContactModel.hpp" #include "components/notifier/Notifier.hpp" +#include "components/settings/AccountSettingsModel.hpp" #include "components/settings/SettingsModel.hpp" #include "utils/Utils.hpp" @@ -174,13 +175,14 @@ void CoreHandlers::onMessageReceived ( emit messageReceived(message); // 1. Do not notify if chat is not activated. - SettingsModel *settingsModel = CoreManager::getInstance()->getSettingsModel(); + CoreManager *coreManager = CoreManager::getInstance(); + SettingsModel *settingsModel = coreManager->getSettingsModel(); if (!settingsModel->getChatEnabled()) return; // 2. Notify with Notification popup. const App *app = App::getInstance(); - if (!app->hasFocus()) + if (!app->hasFocus() || !chatRoom->getLocalAddress()->weakEqual(coreManager->getAccountSettingsModel()->getUsedSipAddress())) app->getNotifier()->notifyReceivedMessage(message); // 3. Notify with sound. diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index fd329faeb..f3698de9e 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -145,8 +145,27 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr
  • &proxyConfig) { - CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxyConfig); - emit accountSettingsUpdated(); + shared_ptr core = CoreManager::getInstance()->getCore(); + if (core->getDefaultProxyConfig() != proxyConfig) { + core->setDefaultProxyConfig(proxyConfig); + emit accountSettingsUpdated(); + } +} + +void AccountSettingsModel::setDefaultProxyConfigFromSipAddress (const QString &sipAddress) { + shared_ptr core = CoreManager::getInstance()->getCore(); + if (Utils::coreStringToAppString(core->getPrimaryContactParsed()->asStringUriOnly()) == sipAddress) { + setDefaultProxyConfig(nullptr); + return; + } + + for (const auto &proxyConfig : core->getProxyConfigList()) + if (Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly()) == sipAddress) { + setDefaultProxyConfig(proxyConfig); + return; + } + + qWarning() << "Unable to set default proxy config from:" << sipAddress; } void AccountSettingsModel::removeProxyConfig (const shared_ptr &proxyConfig) { diff --git a/src/components/settings/AccountSettingsModel.hpp b/src/components/settings/AccountSettingsModel.hpp index 88e0e1484..5d3807c7d 100644 --- a/src/components/settings/AccountSettingsModel.hpp +++ b/src/components/settings/AccountSettingsModel.hpp @@ -63,6 +63,7 @@ public: Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr &proxyConfig); Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr &proxyConfig); + Q_INVOKABLE void setDefaultProxyConfigFromSipAddress (const QString &sipAddress); Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr &proxyConfig, const QVariantMap &data); Q_INVOKABLE void removeProxyConfig (const std::shared_ptr &proxyConfig); diff --git a/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml b/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml index 4e1efd048..127a7804e 100644 --- a/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml +++ b/ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml @@ -73,6 +73,7 @@ Notification { hoverEnabled: true onClicked: notification._close(function () { + AccountSettingsModel.setDefaultProxyConfigFromSipAddress(notification.localAddress) notification.notificationData.window.setView('Conversation', { peerAddress: notification.peerAddress, localAddress: notification.localAddress diff --git a/ui/views/App/Main/Conversation.qml b/ui/views/App/Main/Conversation.qml index 0c55a4765..22180797a 100644 --- a/ui/views/App/Main/Conversation.qml +++ b/ui/views/App/Main/Conversation.qml @@ -170,4 +170,13 @@ ColumnLayout { target: SettingsModel onChatEnabledChanged: chatProxyModel.setEntryTypeFilter(status ? ChatModel.GenericEntry : ChatModel.CallEntry) } + + Connections { + target: AccountSettingsModel + onAccountSettingsUpdated: { + if (conversation.localAddress !== AccountSettingsModel.sipAddress) { + window.setView('Home') + } + } + } }