Skip to content
Snippets Groups Projects
Commit ae8c4c31 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#8315: Fix unknown call when hanging up a call in another client

parent 00d8956c
No related branches found
No related tags found
No related merge requests found
......@@ -748,7 +748,7 @@ calltree_update_call_recursive(calltab_t* tab, callable_obj_t * c, GtkTreeIter *
void calltree_update_call(calltab_t* tab, callable_obj_t * c)
{
return calltree_update_call_recursive(tab, c, NULL);
calltree_update_call_recursive(tab, c, NULL);
}
void calltree_add_call(calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
......
......@@ -145,63 +145,111 @@ incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const
im_widget_add_message(IM_WIDGET(*widget), from, msg, 0);
}
static void
call_state_cb(DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state,
void * foo UNUSED)
/**
* Perform the right sflphone action based on the requested state
*/
static void process_existant_call_state_change(callable_obj_t *c, const gchar *state)
{
callable_obj_t *c = calllist_get_call(current_calls_tab, callID);
if(c == NULL) {
ERROR("Pointer to call is NULL in %s\n", __func__);
return;
}
if (c) {
if (g_strcmp0(state, "HUNGUP") == 0) {
if (c->_state == CALL_STATE_CURRENT) {
time(&c->_time_stop);
calltree_update_call(history_tab, c);
}
if(state == NULL) {
ERROR("Pointer to state is NULL in %s\n", __func__);
return;
}
if (g_strcmp0(state, "HUNGUP") == 0) {
if (c->_state == CALL_STATE_CURRENT) {
time(&c->_time_stop);
calltree_update_call(history_tab, c);
status_bar_display_account();
sflphone_hung_up(c);
} else if (g_strcmp0(state, "UNHOLD_CURRENT") == 0) {
sflphone_current(c);
} else if (g_strcmp0(state, "UNHOLD_RECORD") == 0) {
sflphone_record(c);
} else if (g_strcmp0(state, "HOLD") == 0) {
sflphone_hold(c);
} else if (g_strcmp0(state, "RINGING") == 0) {
sflphone_ringing(c);
} else if (g_strcmp0(state, "CURRENT") == 0) {
sflphone_current(c);
} else if (g_strcmp0(state, "RECORD") == 0) {
sflphone_record(c);
} else if (g_strcmp0(state, "FAILURE") == 0) {
sflphone_fail(c);
} else if (g_strcmp0(state, "BUSY") == 0) {
sflphone_busy(c);
}
} else {
ERROR("DBUS: Error: Call is NULL in %s", __func__);
// The callID is unknow, threat it like a new call
// If it were an incoming call, we won't be here
// It means that a new call has been initiated with an other client (cli for instance)
if ((g_strcmp0(state, "RINGING")) == 0 ||
(g_strcmp0(state, "CURRENT")) == 0 ||
(g_strcmp0(state, "RECORD"))) {
calltree_update_call(history_tab, c);
status_bar_display_account();
sflphone_hung_up(c);
} else if (g_strcmp0(state, "UNHOLD_CURRENT") == 0) {
sflphone_current(c);
} else if (g_strcmp0(state, "UNHOLD_RECORD") == 0) {
sflphone_record(c);
} else if (g_strcmp0(state, "HOLD") == 0) {
sflphone_hold(c);
} else if (g_strcmp0(state, "RINGING") == 0) {
sflphone_ringing(c);
} else if (g_strcmp0(state, "CURRENT") == 0) {
sflphone_current(c);
} else if (g_strcmp0(state, "RECORD") == 0) {
sflphone_record(c);
} else if (g_strcmp0(state, "FAILURE") == 0) {
sflphone_fail(c);
} else if (g_strcmp0(state, "BUSY") == 0) {
sflphone_busy(c);
}
DEBUG("DBUS: New ringing call! accountID: %s", callID);
return;
}
// We fetch the details associated to the specified call
GHashTable *call_details = dbus_get_call_details(callID);
callable_obj_t *new_call = create_new_call_from_details(callID, call_details);
new_call->_history_state = (g_strcasecmp(g_hash_table_lookup(call_details, "CALL_TYPE"), INCOMING_STRING) == 0)
/**
* This function process call state changes in case the call have not been created yet.
* This mainly occurs when anotehr SFLphone client takes actions.
*/
static void process_inexistant_call_state_change(const gchar *callID, const gchar *state)
{
if(callID == NULL) {
ERROR("Pointer to call id is NULL in %s\n", __func__);
return;
}
if(state == NULL) {
ERROR("Pointer to state is NULL in %s\n", __func__);
return;
}
// Could occur if a user picked up the phone and hung up without making a call
if(g_strcmp0(state, "HUNGUP") == 0)
return;
// The callID is unknow, threat it like a new call
// If it were an incoming call, we won't be here
// It means that a new call has been initiated with an other client (cli for instance)
if ((g_strcmp0(state, "RINGING")) == 0 ||
(g_strcmp0(state, "CURRENT")) == 0 ||
(g_strcmp0(state, "RECORD"))) {
DEBUG("DBUS: New ringing call! accountID: %s", callID);
// We fetch the details associated to the specified call
GHashTable *call_details = dbus_get_call_details(callID);
callable_obj_t *new_call = create_new_call_from_details(callID, call_details);
new_call->_history_state = (g_strcasecmp(g_hash_table_lookup(call_details, "CALL_TYPE"), INCOMING_STRING) == 0)
? g_strdup(INCOMING_STRING) : g_strdup(OUTGOING_STRING);
calllist_add_call(current_calls_tab, new_call);
calltree_add_call(current_calls_tab, new_call, NULL);
update_actions();
calltree_display(current_calls_tab);
}
calllist_add_call(current_calls_tab, new_call);
calltree_add_call(current_calls_tab, new_call, NULL);
update_actions();
calltree_display(current_calls_tab);
}
}
/**
* Callback called when a
*/
static void
call_state_cb(DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state,
void * foo UNUSED)
{
callable_obj_t *c = calllist_get_call(current_calls_tab, callID);
if (c) {
process_existant_call_state_change(c, state);
} else {
WARN("DBUS: Call does not exist in %s", __func__);
process_inexistant_call_state_change(callID, state);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment