Skip to content
Snippets Groups Projects
Commit b97b9cce authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #10736: calltree: simplify remove_call

parent 9c540e4f
Branches
Tags
No related merge requests found
......@@ -181,7 +181,7 @@ sflphone_hung_up(callable_obj_t * c)
DEBUG("%s", __PRETTY_FUNCTION__);
calllist_remove_call(current_calls_tab, c->_callID);
calltree_remove_call(current_calls_tab, c->_callID, FALSE);
calltree_remove_call(current_calls_tab, c->_callID);
c->_state = CALL_STATE_DIALING;
call_remove_all_errors(c);
update_actions();
......@@ -395,7 +395,8 @@ sflphone_pick_up()
case CALL_STATE_TRANSFER:
dbus_transfer(selectedCall);
time(&selectedCall->_time_stop);
calltree_remove_call(current_calls_tab, selectedCall->_callID, TRUE);
calltree_remove_call(current_calls_tab, selectedCall->_callID);
update_actions();
calllist_remove_call(current_calls_tab, selectedCall->_callID);
break;
case CALL_STATE_CURRENT:
......@@ -694,7 +695,8 @@ sflphone_keypad(guint keyval, gchar * key)
case GDK_KP_Enter:
dbus_transfer(c);
time(&c->_time_stop);
calltree_remove_call(current_calls_tab, c->_callID, TRUE);
calltree_remove_call(current_calls_tab, c->_callID);
update_actions();
break;
case GDK_Escape:
sflphone_unset_transfer();
......@@ -820,7 +822,7 @@ sflphone_detach_participant(const gchar* callID)
}
im_widget_update_state(IM_WIDGET(selectedCall->_im_widget), TRUE);
calltree_remove_call(current_calls_tab, selectedCall->_callID, TRUE);
calltree_remove_call(current_calls_tab, selectedCall->_callID);
calltree_add_call(current_calls_tab, selectedCall, NULL);
dbus_detach_participant(selectedCall->_callID);
}
......
......@@ -136,7 +136,7 @@ calllist_clean_history(void)
for (guint i = 0; i < size; i++) {
callable_obj_t * c = calllist_get_nth(history_tab, i);
if (c)
calltree_remove_call(history_tab, c->_callID, TRUE);
calltree_remove_call(history_tab, c->_callID);
}
calllist_reset(history_tab);
......@@ -146,7 +146,7 @@ void
calllist_remove_from_history(callable_obj_t* c)
{
calllist_remove_call(history_tab, c->_callID);
calltree_remove_call(history_tab, c->_callID, TRUE);
calltree_remove_call(history_tab, c->_callID);
}
void
......
......@@ -506,32 +506,29 @@ calltree_create(calltab_t* tab, int searchbar_type)
gtk_widget_show(tab->tree);
}
static void
calltree_remove_call_recursive(calltab_t* tab, const gchar *target_id, GtkTreeIter *parent)
static gboolean
remove_element_if_match(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gpointer data)
{
GtkTreeStore *store = tab->store;
GtkTreeModel *model = GTK_TREE_MODEL(store);
int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent);
for (int i = 0; i < nbChild; i++) {
GtkTreeIter child;
if (gtk_tree_model_iter_nth_child(model, &child, parent, i)) {
if (gtk_tree_model_iter_has_child(model, &child))
calltree_remove_call_recursive(tab, target_id, &child);
const gchar *target_id = (const gchar *) data;
gchar *id;
gtk_tree_model_get(model, &child, COLUMN_ID, &id, -1);
if (g_strcmp0(id, target_id) == 0)
gtk_tree_store_remove(store, &child);
g_free(id);
gtk_tree_model_get(model, iter, COLUMN_ID, &id, -1);
gboolean result = FALSE;
if (g_strcmp0(id, target_id) == 0) {
gtk_tree_store_remove(GTK_TREE_STORE(model), iter);
result = TRUE; // stop iterating, we found it
}
g_free(id);
return result;
}
void
calltree_remove_call(calltab_t* tab, const gchar *target_id)
{
GtkTreeStore *store = tab->store;
GtkTreeModel *model = GTK_TREE_MODEL(store);
gtk_tree_model_foreach(model, remove_element_if_match, (gpointer) target_id);
/* invalidate selected call if it was our target */
callable_obj_t *sel = calltab_get_selected_call(tab);
if (sel && g_strcmp0(sel->_callID, target_id) == 0)
......@@ -540,14 +537,6 @@ calltree_remove_call_recursive(calltab_t* tab, const gchar *target_id, GtkTreeIt
statusbar_update_clock("");
}
void
calltree_remove_call(calltab_t* tab, const gchar *id, gboolean do_update_actions)
{
calltree_remove_call_recursive(tab, id, NULL);
if (do_update_actions)
update_actions();
}
GdkPixbuf *history_state_to_pixbuf(const gchar *history_state)
{
gchar *svg_filename = g_strconcat(ICONS_DIR, "/", history_state, ".svg", NULL);
......@@ -1004,7 +993,7 @@ void calltree_add_conference_to_current_calls(conference_obj_t* conf)
const gchar * const call_id = (gchar *) part->data;
callable_obj_t *call = calllist_get_call(current_calls_tab, call_id);
calltree_remove_call(current_calls_tab, call->_callID, FALSE);
calltree_remove_call(current_calls_tab, call->_callID);
calltree_add_call(current_calls_tab, call, &iter);
}
......@@ -1209,7 +1198,7 @@ handle_drop_into(GtkTreeModel *model, GtkTreeIter *source_iter, GtkTreeIter *des
result = TRUE;
} else {
DEBUG("dropped call on call, creating new conference or transferring");
calltree_remove_call(current_calls_tab, source_ID, FALSE);
calltree_remove_call(current_calls_tab, source_ID);
callable_obj_t *source_call = calllist_get_call(current_calls_tab, source_ID);
calltree_add_call(current_calls_tab, source_call, NULL);
cleanup_popup_data(&popup_data);
......@@ -1313,8 +1302,9 @@ menuitem_response(gchar * string)
if (g_strcmp0(string, SFL_CREATE_CONFERENCE) == 0) {
dbus_join_participant(popup_data->source_ID,
popup_data->dest_ID);
calltree_remove_call(current_calls_tab, popup_data->source_ID, TRUE);
calltree_remove_call(current_calls_tab, popup_data->dest_ID, TRUE);
calltree_remove_call(current_calls_tab, popup_data->source_ID);
calltree_remove_call(current_calls_tab, popup_data->dest_ID);
update_actions();
} else if (g_strcmp0(string, SFL_TRANSFER_CALL) == 0) {
callable_obj_t * source_call = calllist_get_call(current_calls_tab, popup_data->source_ID);
callable_obj_t * dest_call = calllist_get_call(current_calls_tab, popup_data->dest_ID);
......@@ -1322,7 +1312,7 @@ menuitem_response(gchar * string)
source_call->_peer_number,
dest_call->_peer_number);
dbus_attended_transfer(source_call, dest_call);
calltree_remove_call(current_calls_tab, popup_data->source_ID, TRUE);
calltree_remove_call(current_calls_tab, popup_data->source_ID);
} else
ERROR("Unknown option in menu %s", string);
......
......@@ -83,7 +83,7 @@ calltree_update_call (calltab_t *, callable_obj_t *);
* @param c The ID of the call to remove
*/
void
calltree_remove_call(calltab_t *, const gchar*, gboolean do_update_actions);
calltree_remove_call(calltab_t *, const gchar*);
/**
* Add a callable object to history treeview
......
......@@ -847,6 +847,7 @@ remove_from_history(void * foo UNUSED)
}
calllist_remove_from_history(call);
update_actions();
}
static void
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment