From f9ca31c61b8cb7f25bbcf4bd5169469458bc1c63 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 9 Apr 2019 16:35:50 -0400
Subject: [PATCH] newcallmodel: add ability to close all calls and conferences

Change-Id: I1f4b91a472dc4255f393ce33980fdb2c3ddee76d
---
 src/api/newcallmodel.h |  5 +++++
 src/newcallmodel.cpp   | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/src/api/newcallmodel.h b/src/api/newcallmodel.h
index 2f192d75..da82a839 100644
--- a/src/api/newcallmodel.h
+++ b/src/api/newcallmodel.h
@@ -187,6 +187,11 @@ public:
      */
     bool isRecording(const std::string& callId) const;
 
+    /**
+     * Close all active calls and conferences
+     */
+    static void hangupCallsAndConferences();
+
 Q_SIGNALS:
     /**
      * Emitted when a call state changes
diff --git a/src/newcallmodel.cpp b/src/newcallmodel.cpp
index be49b0c4..537ecac0 100644
--- a/src/newcallmodel.cpp
+++ b/src/newcallmodel.cpp
@@ -463,6 +463,19 @@ NewCallModel::sendSipMessage(const std::string& callId, const std::string& body)
     CallManager::instance().sendTextMessage(callId.c_str(), payloads, true /* not used */);
 }
 
+void
+NewCallModel::hangupCallsAndConferences()
+{
+    QStringList conferences = CallManager::instance().getConferenceList();
+    for (const auto& conf : conferences) {
+        CallManager::instance().hangUpConference(conf);
+    }
+    QStringList calls = CallManager::instance().getCallList();
+    for (const auto &call : calls) {
+        CallManager::instance().hangUp(call);
+    }
+}
+
 void
 NewCallModelPimpl::slotIncomingCall(const std::string& accountId, const std::string& callId, const std::string& fromId)
 {
-- 
GitLab