diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 2a6dcc9457d86627d43e63eda5e8a782c6e18c7d..617a9534ae000a1f2b767beb8ad9f9b36f8883a7 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -897,6 +897,13 @@ sflphone_add_conference() // dbus_join_participant(selected_call, dragged_call); } +void +sflphone_add_main_participant(const conference_obj_t * c) +{ + DEBUG("sflphone add main participant"); + dbus_add_main_participant(c->_confID); +} + void sflphone_conference_on_hold(const conference_obj_t * c) { diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index e74fe3c6806c022c0aef3acdea65d09f92c40b43..560e7faa5999c7f7ed390f98df783496c5691039 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -140,56 +140,83 @@ void row_activated(GtkTreeView *tree_view UNUSED, GtkTreeViewColumn *column UNUSED, void * data UNUSED) { - callable_obj_t* selectedCall; + callable_obj_t* selectedCall = NULL; callable_obj_t* new_call; + conference_obj_t* selectedConf = NULL; gchar *account_id; DEBUG("double click action"); - selectedCall = calltab_get_selected_call( active_calltree ); - - if (selectedCall) + if( active_calltree == current_calls ) { - // Get the right event from the right calltree - if( active_calltree == current_calls ) - { - switch(selectedCall->_state) - { - case CALL_STATE_INCOMING: - dbus_accept(selectedCall); - stop_notification(); - break; - case CALL_STATE_HOLD: - dbus_unhold(selectedCall); - break; - case CALL_STATE_RINGING: - case CALL_STATE_CURRENT: - case CALL_STATE_BUSY: - case CALL_STATE_FAILURE: - break; - case CALL_STATE_DIALING: - sflphone_place_call (selectedCall); - break; - default: - WARN("Row activated - Should not happen!"); - break; - } - } - - // If history or contact: double click action places a new call - else - { - account_id = g_strdup (selectedCall->_accountID); + + if(calltab_get_selected_type(current_calls) == A_CALL) + { + selectedCall = calltab_get_selected_call(current_calls); - // Create a new call - create_new_call (CALL, CALL_STATE_DIALING, "", account_id, selectedCall->_peer_name, selectedCall->_peer_number, &new_call); + if (selectedCall) + { + // Get the right event from the right calltree + if( active_calltree == current_calls ) + { + switch(selectedCall->_state) + { + case CALL_STATE_INCOMING: + dbus_accept(selectedCall); + stop_notification(); + break; + case CALL_STATE_HOLD: + dbus_unhold(selectedCall); + break; + case CALL_STATE_RINGING: + case CALL_STATE_CURRENT: + case CALL_STATE_BUSY: + case CALL_STATE_FAILURE: + break; + case CALL_STATE_DIALING: + sflphone_place_call (selectedCall); + break; + default: + WARN("Row activated - Should not happen!"); + break; + } + } - calllist_add(current_calls, new_call); - calltree_add_call(current_calls, new_call, NULL); - sflphone_place_call(new_call); - calltree_display(current_calls); - } + // If history or contact: double click action places a new call + else + { + account_id = g_strdup (selectedCall->_accountID); + + // Create a new call + create_new_call (CALL, CALL_STATE_DIALING, "", account_id, selectedCall->_peer_name, selectedCall->_peer_number, &new_call); + + calllist_add(current_calls, new_call); + calltree_add_call(current_calls, new_call, NULL); + sflphone_place_call(new_call); + calltree_display(current_calls); + } + } + } + else + { + selectedConf = calltab_get_selected_conf(current_calls); + + if(selectedConf) + { + switch(selectedConf->_state) + { + case CONFERENCE_STATE_ACTIVE: + sflphone_add_main_participant(selectedConf); + break; + case CONFERENCE_STATE_HOLD: + sflphone_conference_off_hold(selectedConf); + break; + } + } + } } + + } static gboolean diff --git a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml index 164272b29bd2a809f9d8855bed60ff3759aad152..68be3002a85ccb8572104dca23c168ecc30fb3dc 100644 --- a/sflphone-client-gnome/src/dbus/callmanager-introspec.xml +++ b/sflphone-client-gnome/src/dbus/callmanager-introspec.xml @@ -66,6 +66,10 @@ <arg type="s" name="confID" direction="in"/> </method> + <method name="addMainParticipant"> + <arg type="s" name="confID" direction="in"/> + </method> + <method name="detachParticipant"> <arg type="s" name="callID" direction="in"/> </method> diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 174f2d3774c2a9c6f0e019fa3860736035f41e6f..fac06fff5836d3899252fc0399a90fdfb96804ac 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -1386,6 +1386,22 @@ dbus_add_participant(const gchar* callID, const gchar* confID) } +dbus_add_main_participant(const gchar* confID) +{ + DEBUG("dbus_add_participant %s\n", confID); + + GError* error = NULL; + + org_sflphone_SFLphone_CallManager_add_main_participant ( + callManagerProxy, + confID, + &error); + if(error) + { + g_error_free(error); + } +} + void dbus_detach_participant(const gchar* callID) diff --git a/sflphone-common/src/dbus/callmanager-introspec.xml b/sflphone-common/src/dbus/callmanager-introspec.xml index e17008068cfdfcc6f6ba52d870eca65cc9f36053..36e72d6d717b40b70e792c21ee472dfe7db96c59 100644 --- a/sflphone-common/src/dbus/callmanager-introspec.xml +++ b/sflphone-common/src/dbus/callmanager-introspec.xml @@ -66,6 +66,10 @@ <arg type="s" name="confID" direction="in"/> </method> + <method name="addMainParticipant"> + <arg type="s" name="confID" direction="in"/> + </method> + <method name="detachParticipant"> <arg type="s" name="callID" direction="in"/> </method> diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp index 6cc4c2231a489f5801fa5663fd4e1d0954775f9f..6608ac42c1b0cfa12bc42e6b30176bc13aa5d31d 100644 --- a/sflphone-common/src/dbus/callmanager.cpp +++ b/sflphone-common/src/dbus/callmanager.cpp @@ -136,10 +136,17 @@ CallManager::joinParticipant (const std::string& sel_callID, const std::string& void CallManager::addParticipant (const std::string& callID, const std::string& confID) { - _debug ("CallManager::joinParticipant received %s, %s\n", callID.c_str(), confID.c_str()); + _debug ("CallManager::addParticipant received %s, %s\n", callID.c_str(), confID.c_str()); Manager::instance().addParticipant(callID, confID); } +void +CallManager::addMainParticipant (const std::string& confID) +{ + _debug ("CallManager::addMainParticipant received %s\n", confID.c_str()); + Manager::instance().addMainParticipant(confID); +} + void CallManager::detachParticipant (const std::string& callID) { diff --git a/sflphone-common/src/dbus/callmanager.h b/sflphone-common/src/dbus/callmanager.h index 6994a874a4dfed2da24bfcf8d246ec18908e19ec..e97e215524148dde5829ab6b18ba69caf7b17555 100644 --- a/sflphone-common/src/dbus/callmanager.h +++ b/sflphone-common/src/dbus/callmanager.h @@ -51,6 +51,7 @@ public: double getVolume( const std::string& device ); void joinParticipant( const std::string& sel_callID, const std::string& drag_callID ); void addParticipant( const std::string& callID, const std::string& confID ); + void addMainParticipant( const std::string& confID ); void detachParticipant( const std::string& callID ); void holdConference( const std::string& confID ); void unholdConference( const std::string& confID ); diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index d5cebdd6f4c5dc25f15551e6c085c56407adf5e4..f243cb0c1cec1db24f191923a7c137194a6f0f28 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -186,7 +186,7 @@ ManagerImpl::isCurrentCall (const CallID& callId) bool ManagerImpl::hasCurrentCall() { - _debug ("Current call ID = %s\n", _currentCallId2.c_str()); + _debug ("ManagerImpl::hasCurrentCall current call ID = %s\n", _currentCallId2.c_str()); if (_currentCallId2 != "") { return true; @@ -205,6 +205,7 @@ void ManagerImpl::switchCall (const CallID& id) { ost::MutexLock m (_currentCallMutex); + _debug("------------------------- SWITCH %s ---------------------------\n", id.c_str()); _currentCallId2 = id; } @@ -233,8 +234,24 @@ ManagerImpl::outgoingCall (const std::string& accountid, const CallID& id, const /* Check what kind of call we are dealing with */ check_call_configuration (id, to_cleaned, &callConfig); + if (hasCurrentCall()) { + + _debug ("ManagerImpl::outgoingCall() Has current call (id %s) put it onhold\n", getCurrentCallId().c_str()); + // if this is not a conferenceand this and is not a conference participant + if (!isConference(getCurrentCallId()) && !participToConference(getCurrentCallId())) + { + _debug ("ManagerImpl::outgoingCall() Put the current call (ID=%s) on hold\n", getCurrentCallId().c_str()); + onHoldCall (getCurrentCallId()); + } + else + { + _debug ("ManagerImpl::outgoingCall() Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str()); + detachParticipant(); + } + } + if (callConfig == Call::IPtoIP) { - _debug ("Start IP to IP call\n"); + _debug ("ManagerImpl::outgoingCall Start IP to IP call\n"); /* We need to retrieve the sip voiplink instance */ siplink = SIPVoIPLink::instance (""); @@ -258,10 +275,6 @@ ManagerImpl::outgoingCall (const std::string& accountid, const CallID& id, const return false; } - if (hasCurrentCall()) { - _debug ("* Manager Info: there is currently a call, try to hold it\n"); - onHoldCall (getCurrentCallId()); - } _debug ("- Manager Action: Adding Outgoing Call %s on account %s\n", id.data(), accountid.data()); @@ -445,6 +458,8 @@ ManagerImpl::hangupConference (const ConfID& id) } + switchCall (""); + return true; } @@ -543,10 +558,19 @@ ManagerImpl::offHoldCall (const CallID& id) current_call_id = getCurrentCallId(); //Place current call on hold if it isn't - if (hasCurrentCall() && !participToConference(current_call_id)) + if (hasCurrentCall()) { - _debug ("Put the current call (ID=%s) on hold\n", getCurrentCallId().c_str()); - onHoldCall (current_call_id); + // if this is not a conferenceand this and is not a conference participant + if (!isConference(current_call_id) && !participToConference(current_call_id)) + { + _debug ("Put the current call (ID=%s) on hold\n", getCurrentCallId().c_str()); + onHoldCall (current_call_id); + } + else + { + _debug ("Put the current conference (ID=%s) on hold\n", getCurrentCallId().c_str()); + detachParticipant(); + } } switchCall(id); @@ -771,12 +795,15 @@ ManagerImpl::holdConference(const CallID& id) while(iter_participant != _conferencecall.end()) { - _debug("ManagerImpl::hangupConference participant %s\n", iter_participant->first.c_str()); + _debug("ManagerImpl::holdConference participant %s\n", iter_participant->first.c_str()); currentAccountId = getAccountFromCall (iter_participant->first); call = getAccountLink (currentAccountId)->getCall (iter_participant->first); if(call->getConfId() == id) + { + switchCall(iter_participant->first); onHoldCall (iter_participant->first); + } iter_participant++; @@ -809,7 +836,7 @@ ManagerImpl::unHoldConference(const CallID& id) while(iter_participant != _conferencecall.end()) { - _debug("ManagerImpl::hangupConference participant %s\n", iter_participant->first.c_str()); + _debug("ManagerImpl::unholdConference participant %s\n", iter_participant->first.c_str()); currentAccountId = getAccountFromCall (iter_participant->first); call = getAccountLink (currentAccountId)->getCall (iter_participant->first); @@ -901,9 +928,40 @@ ManagerImpl::addParticipant(const CallID& call_id, const CallID& conference_id) _dbus->getCallManager()->conferenceChanged(conference_id); } + + switchCall(default_id); } +void +ManagerImpl::addMainParticipant(const CallID& conference_id) +{ + if(hasCurrentCall()) + { + CallID current_call_id = getCurrentCallId(); + onHoldCall(current_call_id); + } + + ConferenceMap::iterator iter = _conferencemap.find(conference_id); + + Conference *conf = NULL; + + if(iter != _conferencemap.end()) + { + conf = iter->second; + } + + ConferenceCallMap::iterator iter_participant = _conferencecall.begin(); + while(iter_participant != _conferencecall.end()) + { + _debug("Quecequispasse\n"); + if (iter_participant->second == conf) + _audiodriver->getMainBuffer()->bindCallID(iter_participant->first, default_id); + + iter_participant++; + } +} + void ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) @@ -999,6 +1057,8 @@ ManagerImpl::joinParticipant(const CallID& call_id1, const CallID& call_id2) */ } + switchCall(default_conf); + } @@ -1010,20 +1070,28 @@ ManagerImpl::detachParticipant(const CallID& call_id) // TODO: add conference_id as a second parameter ConferenceMap::iterator iter = _conferencemap.find(default_conf); + + if(iter == _conferencemap.end()) { _debug("Error there is no conference, call is not conferencing\n"); } else { _debug("ManagerImpl::detachParticipant detach participant %s\n", call_id.c_str()); - // Conference* conf = iter->second; - - // conf->remove(call_id); - // _conferencecall.erase(call_id); - removeParticipant(call_id); + if(call_id != default_id) + { - onHoldCall(call_id); + removeParticipant(call_id); + + onHoldCall(call_id); + + } + else + { + _debug("ManagerImpl::detachParticipant unbind main participant from all\n"); + _audiodriver->getMainBuffer()->unBindAll(default_id); + } // _dbus->getCallManager()->conferenceChanged(conference_id); } @@ -1297,7 +1365,7 @@ ManagerImpl::incomingCall (Call* call, const AccountID& accountId) if (accountId==AccountNULL) associateConfigToCall (call->getCallId(), Call::IPtoIP); - _debug ("ManagerImpl::incomingCall :: hasCurrentCall() %i \n",hasCurrentCall()); + _debug ("ManagerImpl::incomingCall :: hasCurrentCall() %i \n", hasCurrentCall()); if (!hasCurrentCall()) { call->setConnectionState (Call::Ringing); diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 2c827cb7ae358a66689a509baa626448e67d37f7..f8ddc8c60caf6b621d2ca1e0059c6de5318cfe4e 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -209,9 +209,11 @@ class ManagerImpl { void addParticipant(const CallID& call_id, const CallID& conference_id); + void addMainParticipant(const CallID& conference_id); + void joinParticipant(const CallID& call_id1, const CallID& call_id2); - void detachParticipant(const CallID& call_id); + void detachParticipant(const CallID& call_id = default_id); void removeParticipant(const CallID& call_id);