Commit f7d93108 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2006] Fix detachParticipant/removeParticipant switchCall ids

parent 4af0e7f7
......@@ -56,20 +56,6 @@ void Conference::add(CallID participant_id)
_debug("---- Conference:: add participant %s\n", participant_id.c_str());
/*
if(_nbParticipant >= 1)
{
ParticipantSet::iterator iter;
for(iter = _participants.begin(); iter != _participants.end(); iter++)
{
_debug("---- Conference:: bind callid %s with %s in conference add\n", participant_id.c_str(), (*iter).c_str());
Manager::instance().getAudioDriver()->getMainBuffer()->bindCallID(participant_id, *iter);
}
}
Manager::instance().getAudioDriver()->getMainBuffer()->bindCallID(participant_id);
*/
_participants.insert(participant_id);
_nbParticipant++;
......@@ -81,19 +67,6 @@ void Conference::remove(CallID participant_id)
_debug("---- Conference:: remove participant %s\n", participant_id.c_str());
/*
if(_nbParticipant >= 1)
{
ParticipantSet::iterator iter = _participants.begin();
for(iter = _participants.begin(); iter != _participants.end(); iter++)
{
_debug("---- Conference:: unbind callid %s from %s in conference add\n", participant_id.c_str(), (*iter).c_str());
Manager::instance().getAudioDriver()->getMainBuffer()->unBindCallID(participant_id, *iter);
}
}
*/
_participants.erase(participant_id);
_nbParticipant--;
......@@ -146,3 +119,16 @@ std::string Conference::getStateStr()
return state_str;
}
CallID Conference::getLastParticipant()
{
CallID call_id = "";
ParticipantSet::iterator iter = _participants.begin();
if (iter != _participants.end())
{
call_id = *iter;
return call_id;
}
}
......@@ -54,6 +54,8 @@ class Conference{
void bindParticipant(CallID participant_id);
CallID getLastParticipant();
private:
/** Unique ID of the call */
......
......@@ -246,7 +246,7 @@ ManagerImpl::outgoingCall (const std::string& accountid, const CallID& id, const
else
{
_debug ("ManagerImpl::outgoingCall() Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str());
detachParticipant();
// detachParticipant();
}
}
......@@ -569,7 +569,7 @@ ManagerImpl::offHoldCall (const CallID& id)
else
{
_debug ("Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str());
detachParticipant();
// detachParticipant();
}
}
......@@ -708,7 +708,7 @@ ManagerImpl::refuseCall (const CallID& id)
}
void
Conference*
ManagerImpl::createConference(const CallID& id1, const CallID& id2)
{
_debug("ManagerImpl::createConference()\n");
......@@ -724,7 +724,8 @@ ManagerImpl::createConference(const CallID& id1, const CallID& id2)
// broadcast a signal over dbus
_dbus->getCallManager()->conferenceCreated(default_conf);
return conf;
}
void
......@@ -981,8 +982,10 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
if(iter == _conferencemap.end()){
_debug("NO CONFERENCE YET, CREATE ONE\n");
createConference(call_id1, call_id2);
_debug("ManagerImpl::joinParticipant create a conference\n");
Conference *conf = createConference(call_id1, call_id2);
iter_details = call1_details.find("CALL_STATE");
_debug(" call %s state: %s\n", call_id1.c_str(), iter_details->second.c_str());
......@@ -996,6 +999,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
_debug(" ANSWER %s\n", call_id1.c_str());
answerCall(call_id1);
}
else if(iter_details->second == "CURRENT")
{
_debug(" CURRENT %s\n", call_id1.c_str());
conf->bindParticipant(call_id1);
}
iter_details = call2_details.find("CALL_STATE");
_debug(" call %s state: %s\n", call_id2.c_str(), iter_details->second.c_str());
......@@ -1009,6 +1017,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
_debug(" ANSWER %s\n", call_id2.c_str());
answerCall(call_id2);
}
else if(iter_details->second == "CURRENT")
{
_debug(" CURRENT %s\n", call_id2.c_str());
conf->bindParticipant(call_id2);
}
AccountID currentAccountId;
......@@ -1020,45 +1033,17 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2)
currentAccountId = getAccountFromCall (call_id2);
call = getAccountLink (currentAccountId)->getCall (call_id2);
call->setConfId (default_conf);
call->setConfId (default_conf);
switchCall(default_conf);
}
else {
_debug("ALREADY A CONFERENCE CREATED\n");
/*
Conference* conf = iter->second;
conf->add(call_id1);
_conferencecall.insert(pair<CallID, Conference*>(call_id1, conf));
_debug("ManagerImpl::joinParticipant already a conference created with this ID\n");
iter_details = call1_details.find("CALL_STATE");
if(iter_details->second == "HOLD")
{
_debug(" Add INCOMING call to conference\n");
offHoldCall (call_id1);
}
else if(iter_details->second == "INCOMING")
{
_debug(" Add INCOMING call to conference\n");
answerCall(call_id1);
}
*/
/*
iter_details = call2_details.find("CALL_STATE");
if(iter_details->second == "HOLD")
{
}
else if(iter_details->second == "INCOMING")
{
}
*/
}
switchCall(default_conf);
}
......@@ -1072,11 +1057,8 @@ ManagerImpl::detachParticipant(const CallID& call_id)
if(iter == _conferencemap.end()) {
_debug("Error there is no conference, call is not conferencing\n");
if(iter != _conferencemap.end()) {
}
else {
_debug("ManagerImpl::detachParticipant detach participant %s\n", call_id.c_str());
if(call_id != default_id)
......@@ -1094,6 +1076,13 @@ ManagerImpl::detachParticipant(const CallID& call_id)
}
// _dbus->getCallManager()->conferenceChanged(conference_id);
}
else {
_debug("Error there is no conference, call is not conferencing\n");
}
}
......@@ -1111,19 +1100,39 @@ ManagerImpl::removeParticipant(const CallID& call_id)
ConferenceMap::iterator iter = conf_map.find(default_conf);
if(iter == _conferencemap.end()) {
_debug("NO CONFERENCE CREATED, CANNOT REMOVE PARTICIPANT\n");
_debug("ManagerImpl::removeParticipant no conference created, cannot remove participant \n");
}
else {
conf = iter->second;
_debug("REMOVE PARTICIPANT %s\n", call_id.c_str());
_debug("ManagerImpl::removeParticipant %s\n", call_id.c_str());
conf->remove(call_id);
_conferencecall.erase(iter->first);
if (conf->getNbParticipants() <= 1)
if(conf->getNbParticipants() > 1)
{
switchCall(default_conf);
}
else if (conf->getNbParticipants() == 1)
{
CallID last_participant = conf->getLastParticipant();
_debug("ManagerImpl::removeParticipant only one participant remaining %s\n", last_participant.c_str());
removeConference(default_conf);
switchCall(last_participant);
}
else
{
removeConference(default_conf);
switchCall("");
}
}
}
......
......@@ -195,7 +195,7 @@ class ManagerImpl {
*/
bool refuseCall(const CallID& id);
void createConference(const CallID& id1, const CallID& id2);
Conference* createConference(const CallID& id1, const CallID& id2);
void removeConference(const CallID& conference_id);
......
Supports Markdown
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