Commit 8fedfb58 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(src/components/chat/ChatModel): handle correctly call state

parent 71b04c5e
......@@ -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<linphone::ChatMessage> &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<linphone::Call> &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<linphone::Call> &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<linphone::ChatMessage> &message) {
if (m_chat_room == message->getChatRoom()) {
insertMessageAtEnd(message);
resetMessagesCount();
emit messageReceived(message);
}
}
......@@ -122,6 +122,9 @@ private:
void resetMessagesCount ();
void handleCallStateChanged (const std::shared_ptr<linphone::Call> &call, linphone::CallState state);
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
QList<ChatEntryData> m_entries;
std::shared_ptr<linphone::ChatRoom> m_chat_room;
......
bctoolbox @ e93227f5
Subproject commit cb6314384fd108ce206e1467e9c253bc8cddd161
Subproject commit e93227f56dc0c2299de20ac1460bfdb72e8e695b
bzrtp @ 4c37a23c
Subproject commit b64ed01b6d7a276fb39d3692ec9e737048135805
Subproject commit 4c37a23c805e7f08c8874d848525a720c165c906
linphone @ 15bc3050
Subproject commit cca2555ca61485dc6ba4cdfb9a5cb17d48665049
Subproject commit 15bc305047eacfc9ff7f8c733bdeef21b0a5842c
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