Commit 4d2af143 authored by Ronan's avatar Ronan

feat(chat): change default proxy if necessary when a popup message is clicked...

feat(chat): change default proxy if necessary when a popup message is clicked + always notify messages to non-default proxy
parent 2daf3b4a
......@@ -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.
......
......@@ -145,8 +145,27 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
}
void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {
CoreManager::getInstance()->getCore()->setDefaultProxyConfig(proxyConfig);
emit accountSettingsUpdated();
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
if (core->getDefaultProxyConfig() != proxyConfig) {
core->setDefaultProxyConfig(proxyConfig);
emit accountSettingsUpdated();
}
}
void AccountSettingsModel::setDefaultProxyConfigFromSipAddress (const QString &sipAddress) {
shared_ptr<linphone::Core> 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<linphone::ProxyConfig> &proxyConfig) {
......
......@@ -63,6 +63,7 @@ public:
Q_INVOKABLE QVariantMap getProxyConfigDescription (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE void setDefaultProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
Q_INVOKABLE void setDefaultProxyConfigFromSipAddress (const QString &sipAddress);
Q_INVOKABLE bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig, const QVariantMap &data);
Q_INVOKABLE void removeProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
......
......@@ -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
......
......@@ -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')
}
}
}
}
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