From 0bc609fe49d4efe1b292688ff60ab7f87fececea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Tue, 5 May 2020 10:05:43 -0400
Subject: [PATCH] sipcall: hangup calls when deleting the account

Change-Id: Ife2fc6bf69c1e0ab81ab04616f1c31dbfd81e421
---
 src/account.cpp             | 2 +-
 src/account.h               | 4 ++--
 src/jamidht/jamiaccount.cpp | 1 +
 src/sip/sipaccount.cpp      | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/account.cpp b/src/account.cpp
index 981fb81b95..fe0e0486ad 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -135,7 +135,7 @@ Account::detachCall(const std::string& id)
 }
 
 void
-Account::freeAccount()
+Account::hangupCalls()
 {
     decltype(callIDSet_) calls;
     {
diff --git a/src/account.h b/src/account.h
index 40d91bc73b..3ac4c56231 100644
--- a/src/account.h
+++ b/src/account.h
@@ -95,7 +95,7 @@ public:
      * Free all ressources related to this account.
      *   ***Current calls using this account are HANG-UP***
      */
-    void freeAccount();
+    void hangupCalls();
 
     virtual void setAccountDetails(const std::map<std::string, std::string>& details);
 
@@ -311,7 +311,7 @@ public:
 
     /**
      * Get the user-agent
-    */
+     */
     const std::string& getUserAgentName();
 
 public: // virtual methods that has to be implemented by concrete classes
diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index adc4557acf..8650d7bb7a 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -315,6 +315,7 @@ JamiAccount::JamiAccount(const std::string& accountID, bool /* presenceEnabled *
 
 JamiAccount::~JamiAccount()
 {
+    hangupCalls();
     shutdownConnections();
     if (peerDiscovery_) {
         peerDiscovery_->stopPublish(PEER_DISCOVERY_JAMI_SERVICE);
diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp
index c1b3e71f77..42497caec3 100644
--- a/src/sip/sipaccount.cpp
+++ b/src/sip/sipaccount.cpp
@@ -843,7 +843,7 @@ SIPAccount::doRegister2_()
 
         // Dropping current calls already using the transport is currently required
         // with TLS.
-        freeAccount();
+        hangupCalls();
         initTlsConfiguration();
 
         if (!tlsListener_) {
-- 
GitLab