Commit 28ea972c authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2006] Remove/add main participant from conferences

parent 786b96cf
......@@ -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)
{
......
......@@ -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
......
......@@ -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>
......
......@@ -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)
......
......@@ -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>
......
......@@ -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)
{
......
......@@ -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 );
......
......@@ -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);
......
......@@ -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);
......
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