From 529ca3c13c49fbec082c7a381353d4287db8ad0a Mon Sep 17 00:00:00 2001
From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
Date: Wed, 23 Oct 2019 16:42:48 -0400
Subject: [PATCH] call: handle PEER_BUSY state

Change-Id: I59072ab5cca3274ecc808b2c6e6f00c6c9850eb3
---
 src/conversationmodel.cpp | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/conversationmodel.cpp b/src/conversationmodel.cpp
index 295cfdcf..f19d3eec 100644
--- a/src/conversationmodel.cpp
+++ b/src/conversationmodel.cpp
@@ -1662,13 +1662,13 @@ ConversationModelPimpl::slotCallStatusChanged(const std::string& callId, int cod
             return conversation.callId == callId;
         });
 
-    if (i == conversations.end()) {
-        // In this case, the user didn't pass through placeCall
-        // This means that a participant was invited to a call
-        // or a call was placed via dbus.
-        // We have to update the model
-        try {
-            auto call = linked.owner.callModel->getCall(callId);
+    try {
+        auto call = linked.owner.callModel->getCall(callId);
+        if (i == conversations.end()) {
+            // In this case, the user didn't pass through placeCall
+            // This means that a participant was invited to a call
+            // or a call was placed via dbus.
+            // We have to update the model
             for (auto& conversation: conversations) {
                 if (conversation.participants.front() == call.peerUri) {
                     conversation.callId = callId;
@@ -1676,10 +1676,11 @@ ConversationModelPimpl::slotCallStatusChanged(const std::string& callId, int cod
                     emit linked.conversationUpdated(conversation.uid);
                 }
             }
-        } catch (std::out_of_range& e) {
-            qDebug() << "ConversationModelPimpl::slotCallStatusChanged can't get inexistant call";
+        } else if (call.status == call::Status::PEER_BUSY) {
+            emit behaviorController.showLeaveMessageView(linked.owner.id, *i);
         }
-        return;
+    } catch (std::out_of_range& e) {
+        qDebug() << "ConversationModelPimpl::slotCallStatusChanged can't get inexistant call";
     }
 }
 
-- 
GitLab