From 8fedfb58ac11985a10b6555e2deeb220c005cfd4 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 12 Apr 2017 11:15:34 +0200 Subject: [PATCH] fix(src/components/chat/ChatModel): handle correctly call state --- .../src/components/chat/ChatModel.cpp | 37 +++++++++---------- .../src/components/chat/ChatModel.hpp | 3 ++ submodules/bctoolbox | 2 +- submodules/bzrtp | 2 +- submodules/linphone | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) diff --git a/linphone-desktop/src/components/chat/ChatModel.cpp b/linphone-desktop/src/components/chat/ChatModel.cpp index a25e3e0c8..fdfdd90cf 100644 --- a/linphone-desktop/src/components/chat/ChatModel.cpp +++ b/linphone-desktop/src/components/chat/ChatModel.cpp @@ -176,25 +176,8 @@ ChatModel::ChatModel (QObject *parent) : QAbstractListModel(parent) { core->getSipAddressesModel()->connectToChatModel(this); - QObject::connect( - &(*m_core_handlers), &CoreHandlers::messageReceived, - this, [this](const shared_ptr &message) { - if (m_chat_room == message->getChatRoom()) { - insertMessageAtEnd(message); - resetMessagesCount(); - - emit messageReceived(message); - } - } - ); - - QObject::connect( - &(*m_core_handlers), &CoreHandlers::callStateChanged, - this, [this](const std::shared_ptr &call, linphone::CallState state) { - if (state == linphone::CallStateEnd || state == linphone::CallStateError) - insertCall(call->getCallLog()); - } - ); + QObject::connect(&(*m_core_handlers), &CoreHandlers::messageReceived, this, &ChatModel::handleMessageReceived); + QObject::connect(&(*m_core_handlers), &CoreHandlers::callStateChanged, this, &ChatModel::handleCallStateChanged); } ChatModel::~ChatModel () { @@ -580,3 +563,19 @@ void ChatModel::resetMessagesCount () { m_chat_room->markAsRead(); emit messagesCountReset(); } + +// ----------------------------------------------------------------------------- + +void ChatModel::handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state) { + if (m_chat_room == call->getChatRoom() && (state == linphone::CallStateEnd || state == linphone::CallStateError)) + insertCall(call->getCallLog()); +} + +void ChatModel::handleMessageReceived (const std::shared_ptr &message) { + if (m_chat_room == message->getChatRoom()) { + insertMessageAtEnd(message); + resetMessagesCount(); + + emit messageReceived(message); + } +} diff --git a/linphone-desktop/src/components/chat/ChatModel.hpp b/linphone-desktop/src/components/chat/ChatModel.hpp index e67a34fe8..58eec019e 100644 --- a/linphone-desktop/src/components/chat/ChatModel.hpp +++ b/linphone-desktop/src/components/chat/ChatModel.hpp @@ -122,6 +122,9 @@ private: void resetMessagesCount (); + void handleCallStateChanged (const std::shared_ptr &call, linphone::CallState state); + void handleMessageReceived (const std::shared_ptr &message); + QList m_entries; std::shared_ptr m_chat_room; diff --git a/submodules/bctoolbox b/submodules/bctoolbox index cb6314384..e93227f56 160000 --- a/submodules/bctoolbox +++ b/submodules/bctoolbox @@ -1 +1 @@ -Subproject commit cb6314384fd108ce206e1467e9c253bc8cddd161 +Subproject commit e93227f56dc0c2299de20ac1460bfdb72e8e695b diff --git a/submodules/bzrtp b/submodules/bzrtp index b64ed01b6..4c37a23c8 160000 --- a/submodules/bzrtp +++ b/submodules/bzrtp @@ -1 +1 @@ -Subproject commit b64ed01b6d7a276fb39d3692ec9e737048135805 +Subproject commit 4c37a23c805e7f08c8874d848525a720c165c906 diff --git a/submodules/linphone b/submodules/linphone index cca2555ca..15bc30504 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit cca2555ca61485dc6ba4cdfb9a5cb17d48665049 +Subproject commit 15bc305047eacfc9ff7f8c733bdeef21b0a5842c