From 0771f9305fea2a77bc03c44d74d24b85eb45f34b Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Tue, 28 May 2013 16:01:05 -0400
Subject: [PATCH] * #23666: daemon: ensure that calls are only in one
 conference at a time

---
 daemon/src/managerimpl.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp
index fdd16a7a7d..6430f0c31e 100644
--- a/daemon/src/managerimpl.cpp
+++ b/daemon/src/managerimpl.cpp
@@ -832,6 +832,10 @@ ManagerImpl::addParticipant(const std::string& callId, const std::string& confer
         return false;
     }
 
+    // ensure that calls are only in one conference at a time
+    if (isConferenceParticipant(callId))
+        detachParticipant(callId);
+
     // store the current call id (it will change in offHoldCall or in answerCall)
     std::string current_call_id(getCurrentCallId());
 
@@ -978,6 +982,12 @@ ManagerImpl::joinParticipant(const std::string& callId1, const std::string& call
         return false;
     }
 
+    // ensure that calls are only in one conference at a time
+    if (isConferenceParticipant(callId1))
+        detachParticipant(callId1);
+    if (isConferenceParticipant(callId2))
+        detachParticipant(callId2);
+
     std::map<std::string, std::string> call1Details(getCallDetails(callId1));
     std::map<std::string, std::string> call2Details(getCallDetails(callId2));
 
@@ -1260,10 +1270,8 @@ ManagerImpl::joinConference(const std::string& conf_id1,
     ParticipantSet participants(conf->getParticipantList());
 
     for (ParticipantSet::const_iterator p = participants.begin();
-            p != participants.end(); ++p) {
-        detachParticipant(*p);
+            p != participants.end(); ++p)
         addParticipant(*p, conf_id2);
-    }
 
     return true;
 }
-- 
GitLab