Commit 5a647059 authored by Alexandre Savard's avatar Alexandre Savard

Merge branch 'no_globals_in_calltree_experiment' of...

Merge branch 'no_globals_in_calltree_experiment' of git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone into no_globals_in_calltree_experiment
parents 51b2b119 df303839
......@@ -66,10 +66,6 @@ static const gchar * const SFL_TRANSFER_CALL = "Transfer call to";
static GtkWidget *calltree_popupmenu = NULL;
static GtkWidget *calltree_menu_items = NULL;
static callable_obj_t *calltree_source_call = NULL;
static conference_obj_t *calltree_source_conf = NULL;
static void drag_data_received_cb(GtkWidget *, GdkDragContext *, gint, gint, GtkSelectionData *, guint, guint, gpointer);
static void menuitem_response(gchar * string);
......@@ -88,12 +84,6 @@ enum {
COLUMNS_IN_TREE_STORE
};
enum {
DRAG_ACTION_CALL_ON_CALL = 0,
DRAG_ACTION_CALL_ON_CONF,
DRAG_ACTION_CALL_OUT_CONf
};
/**
* Show popup menu
*/
......@@ -138,21 +128,19 @@ call_selected_cb(GtkTreeSelection *sel, void* data UNUSED)
if (is_conference(model, &iter)) {
DEBUG("Selected a conference");
calltree_source_conf = conferencelist_get(active_calltree_tab, id);
conference_obj_t *calltree_selected_conf = conferencelist_get(active_calltree_tab, id);
g_free(id);
if (calltree_source_conf) {
calltab_select_conf(active_calltree_tab, calltree_source_conf);
}
if (calltree_selected_conf)
calltab_select_conf(active_calltree_tab, calltree_selected_conf);
} else {
DEBUG("Selected a call");
calltree_source_call = calllist_get_call(active_calltree_tab, id);
callable_obj_t *selected_call = calllist_get_call(active_calltree_tab, id);
g_free(id);
if (calltree_source_call) {
calltab_select_call(active_calltree_tab, calltree_source_call);
}
if (selected_call)
calltab_select_call(active_calltree_tab, selected_call);
}
update_actions();
......@@ -550,6 +538,11 @@ typedef struct {
callable_obj_t *call;
} CallUpdateCtx;
typedef struct {
calltab_t *tab;
const conference_obj_t *conf;
} ConferenceRemoveCtx;
static gboolean
update_call(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gpointer data)
{
......@@ -1004,61 +997,57 @@ void calltree_add_conference_to_current_calls(conference_obj_t* conf)
}
static
void calltree_remove_conference_recursive(calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent)
gboolean
remove_conference(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gpointer data)
{
GtkTreeModel *model = GTK_TREE_MODEL(tab->store);
int nbChildren = gtk_tree_model_iter_n_children(model, parent);
for (int i = 0; i < nbChildren; i++) {
GtkTreeIter iter_parent;
/* if the nth child of parent has one or more children */
if (gtk_tree_model_iter_nth_child(model, &iter_parent, parent, i)) {
/* RECURSION! */
if (gtk_tree_model_iter_has_child(model, &iter_parent))
calltree_remove_conference_recursive(tab, conf, &iter_parent);
if (!is_conference(model, iter))
return FALSE;
if (is_conference(model, &iter_parent)) {
gchar *conf_id;
gtk_tree_model_get(model, &iter_parent, COLUMN_ID, &conf_id, -1);
gchar *conf_id;
gtk_tree_model_get(model, iter, COLUMN_ID, &conf_id, -1);
conference_obj_t *tempconf = conferencelist_get(tab, conf_id);
g_free(conf_id);
ConferenceRemoveCtx * ctx = (ConferenceRemoveCtx *) data;
calltab_t *tab = ctx->tab;
conference_obj_t *tempconf = conferencelist_get(tab, conf_id);
g_free(conf_id);
/* if this is the conference we want to remove */
if (tempconf == conf) {
int nbParticipants = gtk_tree_model_iter_n_children(model, &iter_parent);
DEBUG("nbParticipants: %d", nbParticipants);
const conference_obj_t *conf = ctx->conf;
/* if this is not the conference we want to remove */
if (tempconf != conf)
return FALSE;
for (int j = 0; j < nbParticipants; j++) {
GtkTreeIter iter_child;
int nbParticipants = gtk_tree_model_iter_n_children(model, iter);
DEBUG("nbParticipants: %d", nbParticipants);
if (gtk_tree_model_iter_nth_child(model, &iter_child, &iter_parent, j)) {
gchar *call_id;
gtk_tree_model_get(model, &iter_child, COLUMN_ID, &call_id, -1);
for (int j = 0; j < nbParticipants; j++) {
GtkTreeIter iter_child;
callable_obj_t *call = calllist_get_call(tab, call_id);
g_free(call_id);
if (gtk_tree_model_iter_nth_child(model, &iter_child, iter, j)) {
gchar *call_id;
gtk_tree_model_get(model, &iter_child, COLUMN_ID, &call_id, -1);
// do not add back call in history calltree when cleaning it
if (call && tab != history_tab)
calltree_add_call(tab, call, NULL);
}
}
callable_obj_t *call = calllist_get_call(tab, call_id);
g_free(call_id);
gtk_tree_store_remove(tab->store, &iter_parent);
}
}
// do not add back call in history calltree when cleaning it
if (call && tab != history_tab)
calltree_add_call(tab, call, NULL);
}
}
gtk_tree_store_remove(GTK_TREE_STORE(model), iter);
if (calltab_get_selected_conf(tab) == conf)
calltab_select_conf(tab, NULL);
return TRUE;
}
void calltree_remove_conference(calltab_t* tab, const conference_obj_t* conf)
{
calltree_remove_conference_recursive(tab, conf, NULL);
ConferenceRemoveCtx context = {tab, conf};
GtkTreeStore *store = tab->store;
GtkTreeModel *model = GTK_TREE_MODEL(store);
gtk_tree_model_foreach(model, remove_conference, (gpointer) &context);
update_actions();
DEBUG("Finished removing conference %s", conf->_confID);
......
Markdown is supported
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