From e41f2bf59b9394e3c255f74f9cac22cd371f245a Mon Sep 17 00:00:00 2001 From: Alexandre Savard Date: Fri, 4 Sep 2009 11:20:48 -0400 Subject: [PATCH] [#2006] Add minimal multiple conference handling --- sflphone-client-gnome/src/contacts/calltree.c | 6 +- sflphone-client-gnome/src/dbus/dbus.c | 4 +- sflphone-common/src/dbus/callmanager.cpp | 2 +- sflphone-common/src/managerimpl.cpp | 58 +++++++++++++------ sflphone-common/src/managerimpl.h | 2 +- 5 files changed, 48 insertions(+), 24 deletions(-) diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 96a806b6e..20871d076 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -209,6 +209,7 @@ void row_activated(GtkTreeView *tree_view UNUSED, sflphone_add_main_participant(selectedConf); break; case CONFERENCE_STATE_ACTIVE_DETACHED: + sflphone_add_main_participant(selectedConf); break; case CONFERENCE_STATE_HOLD: sflphone_conference_off_hold(selectedConf); @@ -733,17 +734,20 @@ void calltree_add_conference (calltab_t* tab, const conference_obj_t* conf) switch(conf->_state) { case CONFERENCE_STATE_ACTIVE_ATACHED: + { pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/usersActive.svg", NULL); break; + } case CONFERENCE_STATE_ACTIVE_DETACHED: case CONFERENCE_STATE_HOLD: + { pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/users.svg", NULL); break; + } default: WARN("Update conference add - Should not happen!"); } - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/users.svg", NULL); } else { diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 3d7e6447b..0a69d0da6 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -209,7 +209,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* state, void * foo UNUSED ) { - DEBUG ("Conference changed\n"); + DEBUG ("-------------------- Conference changed ---------------------\n"); // sflphone_display_transfer_status("Transfer successfull"); conference_obj_t* changed_conf = conferencelist_get(confID); @@ -223,7 +223,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, { changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; } - else if ( strcmp(state, "ACTIVE_DTACHED") == 0 ) + else if ( strcmp(state, "ACTIVE_DETACHED") == 0 ) { changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; } diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp index 6608ac42c..a8e1878d0 100644 --- a/sflphone-common/src/dbus/callmanager.cpp +++ b/sflphone-common/src/dbus/callmanager.cpp @@ -151,7 +151,7 @@ void CallManager::detachParticipant (const std::string& callID) { _debug ("CallManager::detachParticipant received %s\n", callID.c_str()); - Manager::instance().detachParticipant(callID); + Manager::instance().detachParticipant(callID, ""); } void diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index f8345a32e..60d1aafad 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -251,7 +251,7 @@ ManagerImpl::outgoingCall (const std::string& account_id, const CallID& call_id, else if (isConference(current_call_id) && !participToConference(call_id)) { _debug (" outgoingCall: detach main participant from conference\n"); - detachParticipant(); + detachParticipant(default_id, current_call_id); } } @@ -357,7 +357,7 @@ ManagerImpl::answerCall (const CallID& call_id) else if (isConference(current_call_id) && !participToConference(call_id)) { _debug (" answerCall: detach main participant from conference\n"); - detachParticipant(); + detachParticipant(default_id, current_call_id); } } @@ -601,7 +601,7 @@ ManagerImpl::offHoldCall (const CallID& call_id) else if (isConference(current_call_id) && !participToConference(call_id)) { _debug (" offHoldCall Put current conference (%s) on hold\n", current_call_id.c_str()); - detachParticipant(); + detachParticipant(default_id, current_call_id); } } @@ -1025,7 +1025,7 @@ ManagerImpl::addParticipant(const CallID& call_id, const CallID& conference_id) // bind main participant to conference after adding new participant - detachParticipant(); + detachParticipant(default_id, current_call_id); // to avoid puting onhold the added call switchCall(""); @@ -1042,7 +1042,15 @@ ManagerImpl::addMainParticipant(const CallID& conference_id) if(hasCurrentCall()) { CallID current_call_id = getCurrentCallId(); - onHoldCall(current_call_id); + + if(isConference(current_call_id)) + { + detachParticipant(default_id, current_call_id); + } + else + { + onHoldCall(current_call_id); + } } ConferenceMap::iterator iter = _conferencemap.find(conference_id); @@ -1052,21 +1060,21 @@ ManagerImpl::addMainParticipant(const CallID& conference_id) if(iter != _conferencemap.end()) { conf = iter->second; - } - // should be nice but at some point default_id is bound to itself - // conf->bindParticipant(default_id); + ParticipantSet participants = conf->getParticipantList(); - // so we must do it manually + ParticipantSet::iterator iter_participant = participants.begin(); + while(iter_participant != participants.end()) + { + _audiodriver->getMainBuffer()->bindCallID(*iter_participant, default_id); + + iter_participant++; + } - ParticipantSet participants = conf->getParticipantList(); + conf->setState(Conference::Active_Atached); - ParticipantSet::iterator iter_participant = participants.begin(); - while(iter_participant != participants.end()) - { - _audiodriver->getMainBuffer()->bindCallID(*iter_participant, default_id); - - iter_participant++; + _dbus->getCallManager()->conferenceChanged(conference_id, conf->getStateStr()); + } switchCall(conference_id); @@ -1093,7 +1101,7 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) if ((current_call_id != call_id1) && (current_call_id != call_id2)) { if (isConference(current_call_id)) - detachParticipant(); + detachParticipant(default_id, current_call_id); else onHoldCall(current_call_id); } @@ -1178,11 +1186,11 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) void -ManagerImpl::detachParticipant(const CallID& call_id) +ManagerImpl::detachParticipant(const CallID& call_id, const CallID& current_call_id) { _debug("ManagerImpl::detachParticipant(%s)\n", call_id.c_str()); - CallID current_call_id = getCurrentCallId(); + // CallID current_call_id = getCurrentCallId(); if(call_id != default_id) { @@ -1230,6 +1238,18 @@ ManagerImpl::detachParticipant(const CallID& call_id) { _debug(" detachParticipant: unbind main participant from all\n"); _audiodriver->getMainBuffer()->unBindAll(default_id); + + if( isConference(current_call_id) ) + { + + ConferenceMap::iterator iter = _conferencemap.find(current_call_id); + Conference *conf = iter->second; + + conf->setState(Conference::Active_Detached); + + _dbus->getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr()); + } + } } diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index ebe6fbac4..33416e982 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -215,7 +215,7 @@ class ManagerImpl { void joinParticipant(const CallID& call_id1, const CallID& call_id2); - void detachParticipant(const CallID& call_id = default_id); + void detachParticipant(const CallID& call_id, const CallID& current_call_id); void removeParticipant(const CallID& call_id);