diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index b8eb4ba5c735653de945e512c5245284f6e49a6c..8c45c22dae76ef30f6c4356d1a9394d1a47df974 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -652,7 +652,6 @@ process_dialing (callable_obj_t *c, guint keyval, gchar *key) switch (keyval) { case 65293: /* ENTER */ case 65421: /* ENTER numpad */ - DEBUG("------------------------------------------------ SFLPHONE PLACE CALL (process dialing)"); sflphone_place_call (c); break; case 65307: /* ESCAPE */ @@ -921,10 +920,10 @@ static int _place_registered_call (callable_obj_t * c) DEBUG ("Actions: Get account for this call"); if (g_strcasecmp (c->_accountID, "") != 0) { - DEBUG ("-------------------------------------------------------- Actions: Account %s already set for this call", c->_accountID); + DEBUG ("Actions: Account %s already set for this call", c->_accountID); current = account_list_get_by_id (c->_accountID); } else { - DEBUG ("-------------------------------------------------------- Actions: No account set for this call, use first of the list"); + DEBUG ("Actions: No account set for this call, use first of the list"); current = account_list_get_current(); } @@ -1281,7 +1280,7 @@ void sflphone_fill_history (void) gboolean is_first; - DEBUG ("Loading history ..."); + DEBUG ("SFLphone: Loading history ..."); entries = dbus_get_history (); @@ -1321,14 +1320,30 @@ void sflphone_fill_history (void) gchar **ptr; const gchar *delim = "|"; - DEBUG("---------------------------------- HISTORY VALUE %s", value); ptr = g_strsplit(value, delim, 6); if(ptr != NULL) { + DEBUG("!!!!!!!!!!!!!!!!!!!!!!!!!!!! %s", *ptr); + // first ptr refers to entry type if(g_strcmp0(*ptr, "2188") == 0) { - // create_conference_history_entry_from_serialized((gchar *)key, (gchar **)ptr, &conference_entry); + DEBUG("---------------------------------- HISTORY VALUE %s", value); + create_conference_history_entry_from_serialized((gchar *)key, (gchar **)ptr, &conference_entry); + conferencelist_add (history, conference_entry); + calltree_add_conference (history, conference_entry); + conferencelist_add(current_calls, conference_entry); +/* + GSList *part = conference_entry->participant_list; + + while(part) { + callable_obj_t *call_to_add = NULL; + gchar *call_id = (gchar *)part->data; + call_to_add = calllist_get_call(history, call_id); + + calltree_add_call(); + } +*/ g_hash_table_remove(entries, key_to_min); } else { diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index df20980b58a6756473367ea16c07eef2b6086843..d37d449bc47fadb272fab45970b7f1b36cf57085 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -313,27 +313,21 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar **ptr, c while (ptr != NULL && token < 6) { switch (token) { case 0: - DEBUG("------------------------------------------------------------------------------------------ HISTORYSTATE FROM SERIALIZATION %s", *ptr); history_state = get_history_state_from_id (*ptr); break; case 1: - DEBUG("------------------------------------------------------------------------------------------ PEERNUMBER FROM SERIALIZATION %s", *ptr); peer_number = *ptr; break; case 2: - DEBUG("------------------------------------------------------------------------------------------ PEERNAME FROM SERIALIZATION %s", *ptr); peer_name = *ptr; break; case 3: - DEBUG("------------------------------------------------------------------------------------------ TIMESTOP FROM SERIALIZATION %s", *ptr); time_stop = *ptr; break; case 4: - DEBUG("------------------------------------------------------------------------------------------ ACCOUNTID FROM SERIALIZATION %s", *ptr); accountID = *ptr; break; case 5: - DEBUG("------------------------------------------------------------------------------------------ RECORDFILE FROM SERIALIZATION %s", *ptr); recordfile = *ptr; default: break; diff --git a/sflphone-client-gnome/src/conference_obj.c b/sflphone-client-gnome/src/conference_obj.c index 663f971579d0879d25a1e23cb90e32332c9025ad..6212ee46ce3366907ae5c01f42f37c98fbc62f15 100644 --- a/sflphone-client-gnome/src/conference_obj.c +++ b/sflphone-client-gnome/src/conference_obj.c @@ -38,6 +38,7 @@ static void set_conference_timestamp (time_t *); static void conference_add_participant_number(const gchar *, conference_obj_t *); +static void process_conference_participant_from_serialized(gchar *, conference_obj_t *); static void set_conference_timestamp (time_t *timestamp) { @@ -50,21 +51,27 @@ static void set_conference_timestamp (time_t *timestamp) void create_new_conference (conference_state_t state, const gchar* confID, conference_obj_t ** conf) { - DEBUG ("create_new_conference"); - - // conference_obj_t *obj; conference_obj_t *new_conf; - const gchar* conf_id; + + if(confID == NULL) { + ERROR("Conference: Error: Conference ID is NULL while creating new conference"); + return; + } + + DEBUG ("Conference: Create new conference %s", confID); // Allocate memory new_conf = g_new0 (conference_obj_t, 1); + if(new_conf == NULL) { + ERROR("Conference: Error: Could not allocate data "); + return; + } // Set state field new_conf->_state = state; // Set the ID field - conf_id = confID; - new_conf->_confID = g_strdup (conf_id); + new_conf->_confID = g_strdup (confID); new_conf->participant_list = NULL; new_conf->participant_number = NULL; @@ -74,15 +81,18 @@ void create_new_conference (conference_state_t state, const gchar* confID, confe void create_new_conference_from_details (const gchar *conf_id, GHashTable *details, conference_obj_t ** conf) { - DEBUG ("create_new_conference_from_details"); - conference_obj_t *new_conf; gchar** participants; gchar* state_str; - // GSList* participant_list; + + DEBUG ("Conference: Create new conference from details"); // Allocate memory new_conf = g_new0 (conference_obj_t, 1); + if(new_conf == NULL) { + ERROR("Conference: Error: Could not allocate data "); + return; + } new_conf->_confID = g_strdup (conf_id); @@ -93,6 +103,9 @@ void create_new_conference_from_details (const gchar *conf_id, GHashTable *detai // get participant list participants = dbus_get_participant_list (conf_id); + if(participants == NULL) { + ERROR("Conference: Error: Could not get participant list"); + } // generate conference participant list conference_participant_list_update (participants, new_conf); @@ -131,6 +144,8 @@ void free_conference_obj_t (conference_obj_t *c) void conference_add_participant (const gchar* call_id, conference_obj_t* conf) { + DEBUG("Conference: Conference %s, adding participant %s", conf->_confID, call_id); + // store the new participant list after appending participant id conf->participant_list = g_slist_append (conf->participant_list, (gpointer) g_strdup(call_id)); @@ -246,6 +261,8 @@ void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **p gchar *recordfile = ""; const gchar *confID = "conf_1234"; + DEBUG("Conference: Create a conference from serialized form"); + // create a new empty conference create_new_conference(state, confID, conf); @@ -255,7 +272,8 @@ void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **p history_state = MISSED; break; case 1: - participant = *ptr; + participant = g_strdup(*ptr); + process_conference_participant_from_serialized(participant, *conf); break; case 2: name = *ptr; @@ -276,9 +294,11 @@ void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **p token++; ptr++; } + + g_free(participant); } -void process_conference_participant_from_serialized(gchar *participant, conference_obj_t *conf) +static void process_conference_participant_from_serialized(gchar *participant, conference_obj_t *conf) { gchar **ptr = NULL; gchar **numberptr = NULL; @@ -286,15 +306,22 @@ void process_conference_participant_from_serialized(gchar *participant, conferen gchar *delimnumber = ","; gchar *numberaccount; guint token = 0; + callable_obj_t *tmp_call = NULL; + gint tok = 0; + + + DEBUG("------------------------------- process_conference_participant_from_serialized"); - ptr = g_strsplit(participant, delim, 0); - while(ptr != NULL) { + ptr = g_strsplit(participant, delim, 2); + while(ptr != NULL && (tok < 2)) { + gchar *phone_number = NULL; + gchar *account = NULL; token = 0; numberaccount = *ptr; + DEBUG("HERE IS THE PROBLEM"); numberptr = g_strsplit(numberaccount, delimnumber, 2); - while(numberptr != NULL) { - gchar *phone_number = NULL; - gchar *account = NULL; + DEBUG("problem !!!"); + while(numberptr != NULL && (token < 2)) { switch(token) { case 0: phone_number = *numberptr; @@ -307,8 +334,22 @@ void process_conference_participant_from_serialized(gchar *participant, conferen } token++; numberptr++; - - // we should create call here and add it to the conference to be inserted in history } + + tok++; + + gchar *name = "name"; + gchar *call_id = generate_call_id(); + + // we should create call here and add it to the conference to be inserted in history + create_new_call(HISTORY_ENTRY, CALL_STATE_DIALING, call_id, account, name, phone_number, &tmp_call); + calllist_add_history_call(tmp_call); + calllist_add_call(current_calls, tmp_call); + + DEBUG("BEFORE %s", call_id); + conference_add_participant(call_id, conf); + DEBUG("AFTER"); + + ptr++; } } diff --git a/sflphone-client-gnome/src/conference_obj.h b/sflphone-client-gnome/src/conference_obj.h index 9acbc4cb77648ffa9ba5545dd4223fd660fb5032..c66071d2bc8ab22f304f98f5052d16fd4d9b12be 100644 --- a/sflphone-client-gnome/src/conference_obj.h +++ b/sflphone-client-gnome/src/conference_obj.h @@ -86,4 +86,6 @@ void conference_participant_list_update (gchar**, conference_obj_t*); gchar *serialize_history_conference_entry(conference_obj_t *entry); +void create_conference_history_entry_from_serialized(gchar *, gchar **, conference_obj_t **); + #endif diff --git a/sflphone-client-gnome/src/config/addressbook-config.c b/sflphone-client-gnome/src/config/addressbook-config.c index e2108b362d98e1da4684ad367b8fcca924b7a6f6..39deed31b5843984db743ba6b0ec0409faa77a59 100644 --- a/sflphone-client-gnome/src/config/addressbook-config.c +++ b/sflphone-client-gnome/src/config/addressbook-config.c @@ -246,13 +246,6 @@ addressbook_config_book_active_toggled ( } book_data->active = active; - if(active) { - DEBUG("-------------------------------------------- SET ADDRESSBOOK %s AS ACTIVE", book_data->name); - } - else { - DEBUG("-------------------------------------------- SET ADDRESSBOOK %s AS INACTIVE", book_data->name); - } - // Save data gboolean valid; diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 307338f03983d8e7654bef4338948a86587a83c1..f99fa289f86901e5c6b397934e119a324c5db7e3 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -77,7 +77,8 @@ static void calltree_add_history_conference(conference_obj_t *); static void drag_begin_cb (GtkWidget *, GdkDragContext *, gpointer); static void drag_end_cb (GtkWidget *, GdkDragContext *, gpointer); -void drag_data_received_cb (GtkWidget *, GdkDragContext *, gint, gint, GtkSelectionData *, guint, guint, gpointer); +static void drag_data_received_cb (GtkWidget *, GdkDragContext *, gint, gint, GtkSelectionData *, guint, guint, gpointer); +static void drag_history_received_cb (GtkWidget *, GdkDragContext *, gint, gint, GtkSelectionData *, guint, guint, gpointer); static void menuitem_response (gchar *); static void calltree_create_conf_from_participant_list (GSList *); @@ -104,7 +105,7 @@ static void call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) { - DEBUG ("******************************************* CallTree: Selection callback"); + DEBUG ("CallTree: Selection callback"); GtkTreeIter iter; GValue val; @@ -119,10 +120,10 @@ call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) } if(active_calltree == history) { - DEBUG("Current call tree is history"); + DEBUG("CallTree: Current call tree is history"); } else if(active_calltree == current_calls) { - DEBUG("Current call tree is current calls"); + DEBUG("CallTree: Current call tree is current calls"); } // store info for dragndrop @@ -154,7 +155,7 @@ call_selected_cb (GtkTreeSelection *sel, void* data UNUSED) } } - DEBUG ("******************************* CallTree: selected_path %s, selected_conf_id %s, selected_path_depth %d", + DEBUG ("CallTree: selected_path %s, selected_conf_id %s, selected_path_depth %d", selected_path, selected_call_id, selected_path_depth); } else { @@ -201,10 +202,12 @@ row_activated (GtkTreeView *tree_view UNUSED, conference_obj_t* selectedConf = NULL; gchar *account_id; - DEBUG ("----------------------------------------------- CallTree: Double click action"); + DEBUG ("CallTree: Double click action"); if (calltab_get_selected_type (active_calltree) == A_CALL) { + DEBUG("CallTree: Selected a conference"); + selectedCall = calltab_get_selected_call (active_calltree); if (selectedCall) { @@ -251,7 +254,7 @@ row_activated (GtkTreeView *tree_view UNUSED, } } else if (calltab_get_selected_type (active_calltree) == A_CONFERENCE) { - DEBUG("SELECTED A CONFERENCE"); + DEBUG("CallTree: Seleceted a conference"); if (active_calltree == current_calls) { @@ -276,7 +279,6 @@ row_activated (GtkTreeView *tree_view UNUSED, } } else if (active_calltree == history) { - DEBUG("SELECTED A CONFERENCE IN HISTORY"); selectedConf = calltab_get_selected_conf(history); if(selectedConf == NULL) { @@ -284,8 +286,6 @@ row_activated (GtkTreeView *tree_view UNUSED, return; } - DEBUG("Selected conf id %s", selectedConf->_confID); - calltree_create_conf_from_participant_list(selectedConf->participant_list); } } @@ -302,13 +302,11 @@ calltree_create_conf_from_participant_list(GSList *list) { DEBUG("CallTree: Create conference from participant list"); participant_list = (void *) malloc(sizeof(void*)); - // concatenate for(i = 0; i < list_length; i++) { gchar *number; gchar *participant_id = g_slist_nth_data(list, i); - DEBUG("********************* participant %s ***************************", participant_id); callable_obj_t *call = calllist_get_call(history, participant_id); if(c!=0) { @@ -667,6 +665,7 @@ calltree_create (calltab_t* tab, gboolean searchbar_type) if(tab == history) { gtk_tree_view_set_show_expanders(GTK_TREE_VIEW(tab->view), TRUE); + g_signal_connect (G_OBJECT (tab->view), "drag_data_received", G_CALLBACK (drag_history_received_cb), NULL); } @@ -985,7 +984,10 @@ void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) gtk_tree_store_prepend (tab->store, &iter, parent); if (c != NULL) { - account_details = account_list_get_by_id (c->_callID); + account_details = account_list_get_by_id (c->_accountID); + if(account_details == NULL) { + ERROR("CallTree: Could not find account %s", c->_accountID); + } if (account_details != NULL) { srtp_enabled = g_hash_table_lookup (account_details->properties, ACCOUNT_SRTP_ENABLED); @@ -1162,7 +1164,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) GdkPixbuf *pixbuf_security = NULL; GtkTreeIter iter; GtkTreePath *path; - GtkTreeModel *model = (GtkTreeModel*) active_calltree->store; + GtkTreeModel *model = (GtkTreeModel*) tab->store; GSList *conference_participant; gchar *call_id; callable_obj_t *call; @@ -1170,14 +1172,14 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) gchar *srtp_enabled = ""; // New call in the list gchar * description; - - DEBUG ("Calltree: Add conference %s", conf->_confID); - + if (!conf) { ERROR ("Calltree: Error: Conference is null"); return; } + DEBUG ("Calltree: Add conference %s", conf->_confID); + if(tab == history) { calltree_add_history_conference(conf); return; @@ -1238,10 +1240,16 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) while (conference_participant) { call_id = (gchar*) (conference_participant->data); call = calllist_get_call(tab, call_id); + if(call == NULL) { + ERROR("Calltree: Error: Could not find call %s in call list", call_id); + } if (call != NULL) { - account_details = account_list_get_by_id (call->_callID); + account_details = account_list_get_by_id (call->_accountID); + if (account_details == NULL) { + ERROR("Calltree: Error: Could not find account %s in account list", call->_accountID); + } if (account_details != NULL) { srtp_enabled = g_hash_table_lookup (account_details->properties, ACCOUNT_SRTP_ENABLED); @@ -1264,12 +1272,9 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) DEBUG ("Calltree: Determine if all conference participant are secured"); if (conf->_conf_srtp_enabled) { - // participant = conf->participant; conference_participant = conf->participant_list; - // for (pl = participant; *pl; pl++) while (conference_participant) { - // call_id = (gchar*)(*pl); call_id = (gchar*) (conference_participant->data); call = calllist_get_call(tab, call_id); @@ -1317,8 +1322,6 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) return; } - // participant = conf->participant; - // participant = dbus_get_participant_list(conf->_confID); conference_participant = conf->participant_list; if (conference_participant) { @@ -1339,13 +1342,6 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) } } - /* - else - { - WARN ("Conferences cannot be added in this widget - This is a bug in the application."); - } - */ - gtk_tree_view_set_model (GTK_TREE_VIEW (tab->view), GTK_TREE_MODEL (tab->store)); path = gtk_tree_model_get_path (model, &iter); @@ -1367,21 +1363,19 @@ void calltree_update_conference (calltab_t* tab, const conference_obj_t* conf) void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent) { - - DEBUG ("CallTree: Remove conference %s\n", conf->_confID); - GtkTreeIter iter_parent; GtkTreeIter iter_child; GValue confval; GValue callval; - conference_obj_t * tempconf; - callable_obj_t * call; + conference_obj_t *tempconf = NULL; + callable_obj_t *call = NULL; GtkTreeStore* store = tab->store; - - int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); - int nbParticipant; int i, j; + + DEBUG ("CallTree: Remove conference %s\n", conf->_confID); + + int nbChild = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), parent); for (i = 0; i < nbChild; i++) { @@ -1430,20 +1424,21 @@ void calltree_remove_conference (calltab_t* tab, const conference_obj_t* conf, G } -void calltree_add_history_conference(conference_obj_t *conf) { +void calltree_add_history_conference(conference_obj_t *conf) +{ GdkPixbuf *pixbuf = NULL; gchar *description = "Conference: ", *date = "", *duration = ""; GtkTreeIter iter; gchar *call_id; callable_obj_t *call; GSList *conference_participant; - - DEBUG("CallTree: Add conference %s to history", conf->_confID); - + if(!conf) { ERROR("CallTree: Error conference is NULL"); } + DEBUG("CallTree: Add conference %s to history", conf->_confID); + gtk_tree_store_prepend(history->store, &iter, NULL); pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/usersAttached.svg", NULL); @@ -1478,8 +1473,6 @@ void calltree_add_history_conference(conference_obj_t *conf) { void calltree_display (calltab_t *tab) { - - GtkTreeSelection *sel; /* If we already are displaying the specified calltree */ @@ -1489,7 +1482,7 @@ void calltree_display (calltab_t *tab) /* case 1: we want to display the main calltree */ if (tab==current_calls) { - DEBUG ("display main tab"); + DEBUG ("CallTree: Display main tab"); if (active_calltree==contacts) { @@ -1503,9 +1496,9 @@ void calltree_display (calltab_t *tab) } /* case 2: we want to display the history */ - else if (tab==history) { + else if (tab == history) { - DEBUG ("display history tab"); + DEBUG ("ConferenceList: Display history tab"); if (active_calltree==contacts) { gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) contactButton, FALSE); @@ -1516,7 +1509,7 @@ void calltree_display (calltab_t *tab) else if (tab==contacts) { - DEBUG ("display contact tab"); + DEBUG ("CallTree: Display contact tab"); if (active_calltree==history) { gtk_toggle_tool_button_set_active ( (GtkToggleToolButton*) historyButton, FALSE); @@ -1526,17 +1519,16 @@ void calltree_display (calltab_t *tab) set_forcus_on_addressbook_searchbar(); } - - else - ERROR ("calltree.c line %d . This is probably a bug in the application", __LINE__); - + else { + ERROR ("CallTree: Error: Not a valid call tab (%d, %s)", __LINE__, __FILE__); + } gtk_widget_hide (active_calltree->tree); active_calltree = tab; gtk_widget_show (active_calltree->tree); sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (active_calltree->view)); - DEBUG ("Emit signal changed from calltree_display"); + DEBUG ("CallTree: Emit signal changed from calltree_display"); g_signal_emit_by_name (sel, "changed"); update_actions(); } @@ -1855,6 +1847,10 @@ static void drag_end_cb (GtkWidget * widget UNUSED, GdkDragContext * context UNU } +void drag_history_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, gint x UNUSED, gint y UNUSED, GtkSelectionData *selection_data UNUSED, guint info UNUSED, guint t UNUSED, gpointer data UNUSED) +{ + g_signal_stop_emission_by_name(G_OBJECT(widget), "drag_data_received"); +} void drag_data_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, gint x UNUSED, gint y UNUSED, GtkSelectionData *selection_data UNUSED, guint info UNUSED, guint t UNUSED, gpointer data UNUSED) { @@ -1863,6 +1859,10 @@ void drag_data_received_cb (GtkWidget *widget, GdkDragContext *context UNUSED, g GtkTreeViewDropPosition position; GValue val; + if(active_calltree == history) { + g_signal_stop_emission_by_name(G_OBJECT(widget), "drag_data_received"); + } + GtkTreeModel* tree_model = gtk_tree_view_get_model (tree_view); GtkTreeIter iter; diff --git a/sflphone-client-gnome/src/contacts/conferencelist.c b/sflphone-client-gnome/src/contacts/conferencelist.c index 5ecb86cab89c60864bcfe28f6018d1104b8b2dc2..399cee58aa16f39d5bd14834616b58d41447a054 100644 --- a/sflphone-client-gnome/src/contacts/conferencelist.c +++ b/sflphone-client-gnome/src/contacts/conferencelist.c @@ -118,6 +118,8 @@ void conferencelist_remove (calltab_t *tab, const gchar* conf) { gchar* c; + DEBUG("ConferenceList: Remove conference %s", conf); + if(conf == NULL) { ERROR("ConferenceList: Error: Conf id is NULL"); return; @@ -143,6 +145,8 @@ conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* conf_id) GList* c; + DEBUG("ConferenceList: Conference list get %s", conf_id); + if(tab == NULL) { ERROR("ConferenceList: Error: Calltab is NULL"); return; diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index cc38c1953da7cc35591a25a5c5c9c2cd6dea1fad..764f7c2b5ba5ca2bc606116771faee76083670ed 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -1,343 +1,4 @@ -/* - * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. - * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com> - * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> - * Author: Guillaume Carmel-Archambault <guillaume.carmel-archambault@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Additional permission under GNU GPL version 3 section 7: - * - * If you modify this program, or any covered work, by linking or - * combining it with the OpenSSL project's OpenSSL library (or a - * modified version of that library), containing parts covered by the - * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. - * grants you additional permission to convey the resulting work. - * Corresponding Source for a non-source form of such a combination - * shall include the source code for the parts of OpenSSL used as well - * as that of the covered work. - */ -#include <config.h> - -#include <calltab.h> -#include <callmanager-glue.h> -#include <configurationmanager-glue.h> -#include <instance-glue.h> -#include <preferencesdialog.h> -#include <accountlistconfigdialog.h> -#include <mainwindow.h> -#include <marshaller.h> -#include <sliders.h> -#include <statusicon.h> -#include <assistant.h> - -#include <dbus.h> -#include <actions.h> -#include <string.h> - -#include <widget/imwidget.h> - -#include <eel-gconf-extensions.h> - -#define DEFAULT_DBUS_TIMEOUT 30000 - -DBusGConnection * connection; -DBusGProxy * callManagerProxy; -DBusGProxy * configurationManagerProxy; -DBusGProxy * instanceProxy; - -static void -new_call_created_cb (DBusGProxy *proxy UNUSED, const gchar *accountID, - const gchar *callID, const gchar *to, void *foo UNUSED) -{ - callable_obj_t *c; - gchar *peer_name = (gchar *)to; - gchar *peer_number = ""; - - DEBUG("DBus: New Call (%s) created to (%s)", callID, to); - - create_new_call(CALL, CALL_STATE_RINGING, g_strdup(callID), g_strdup(accountID), - peer_name, peer_number, &c); - - set_timestamp(&c->_time_start); - - calllist_add_call(current_calls, c); - calllist_add_call(history, c); - calltree_add_call(current_calls, c, NULL); - calltree_add_call(history, c, NULL); - - update_actions(); - calltree_display(current_calls); -} - -static void -incoming_call_cb (DBusGProxy *proxy UNUSED, const gchar* accountID, - const gchar* callID, const gchar* from, void * foo UNUSED) -{ - callable_obj_t * c; - gchar *peer_name, *peer_number; - - DEBUG ("DBus: Incoming call (%s) from %s", callID, from); - - // We receive the from field under a formatted way. We want to extract the number and the name of the caller - peer_name = call_get_peer_name (from); - peer_number = call_get_peer_number (from); - - DEBUG ("DBus incoming peer name: %s", peer_name); - DEBUG ("DBus incoming peer number: %s", peer_number); - - create_new_call (CALL, CALL_STATE_INCOMING, g_strdup (callID), g_strdup ( - accountID), peer_name, peer_number, &c); -#if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink (TRUE); - popup_main_window(); -#endif - - set_timestamp (&c->_time_start); - notify_incoming_call (c); - sflphone_incoming_call (c); -} - -static void -zrtp_negotiation_failed_cb (DBusGProxy *proxy UNUSED, const gchar* callID, - const gchar* reason, const gchar* severity, void * foo UNUSED) -{ - DEBUG ("Zrtp negotiation failed."); - main_window_zrtp_negotiation_failed (callID, reason, severity); - callable_obj_t * c = NULL; - c = calllist_get_call (current_calls, callID); - - if (c) { - notify_zrtp_negotiation_failed (c); - } -} - -static void -current_selected_audio_codec (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, - const gchar* codecName UNUSED, void * foo UNUSED) -{ -} - -static void -volume_changed_cb (DBusGProxy *proxy UNUSED, const gchar* device, const gdouble value, - void * foo UNUSED) -{ - DEBUG ("Volume of %s changed to %f.",device, value); - set_slider (device, value); -} - -static void -voice_mail_cb (DBusGProxy *proxy UNUSED, const gchar* accountID, const guint nb, - void * foo UNUSED) -{ - DEBUG ("%d Voice mail waiting!",nb); - sflphone_notify_voice_mail (accountID, nb); -} - -static void -incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const gchar *from, const gchar* msg, void * foo UNUSED) -{ - DEBUG ("Message \"%s\" from %s!", msg, from); - - callable_obj_t *call = NULL; - conference_obj_t *conf = NULL; - - // do not display message if instant messaging is disabled - gboolean instant_messaging_enabled = TRUE; - - if (eel_gconf_key_exists (INSTANT_MESSAGING_ENABLED)) - instant_messaging_enabled = eel_gconf_get_integer (INSTANT_MESSAGING_ENABLED); - - if (!instant_messaging_enabled) - return; - // Get the call information. (if this call exist) - call = calllist_get_call (current_calls, callID); - - // Get the conference information (if this conference exist) - conf = conferencelist_get (current_calls, callID); - - /* First check if the call is valid */ - if (call) { - - /* Make the instant messaging main window pops, add messages only if the main window exist. - Elsewhere the message is displayed asynchronously*/ - if (im_widget_display ( (IMWidget **) (&call->_im_widget), msg, call->_callID, from)) - im_widget_add_message (IM_WIDGET (call->_im_widget), from, msg, 0); - } else if (conf) { - /* Make the instant messaging main window pops, add messages only if the main window exist. - Elsewhere the message is displayed asynchronously*/ - if (im_widget_display ( (IMWidget **) (&conf->_im_widget), msg, conf->_confID, from)) - im_widget_add_message (IM_WIDGET (conf->_im_widget), from, msg, 0); - } else { - ERROR ("Message received, but no recipient found"); - } -} - -static void -call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state, - void * foo UNUSED) -{ - DEBUG ("DBUS: Call %s state %s",callID, state); - callable_obj_t *c = calllist_get_call (current_calls, callID); - if(c == NULL) { - ERROR("DBUS: Call is NULL"); - } - - if (c) { - if (strcmp (state, "HUNGUP") == 0) { - if (c->_state == CALL_STATE_CURRENT) { - // peer hung up, the conversation was established, so _stop has been initialized with the current time value - DEBUG ("DBUS: call state current"); - set_timestamp (&c->_time_stop); - calltree_update_call (history, c, NULL); - } - - stop_notification(); - calltree_update_call (history, c, NULL); - status_bar_display_account(); - sflphone_hung_up (c); - } else if (strcmp (state, "UNHOLD_CURRENT") == 0) { - sflphone_current (c); - } else if (strcmp (state, "UNHOLD_RECORD") == 0) { - sflphone_record (c); - } else if (strcmp (state, "HOLD") == 0) { - sflphone_hold (c); - } else if (strcmp (state, "RINGING") == 0) { - sflphone_ringing (c); - } else if (strcmp (state, "CURRENT") == 0) { - sflphone_current (c); - } else if (strcmp (state, "RECORD") == 0) { - sflphone_record (c); - } else if (strcmp (state, "FAILURE") == 0) { - sflphone_fail (c); - } else if (strcmp (state, "BUSY") == 0) { - sflphone_busy (c); - } - } else { - // 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 ((strcmp (state, "RINGING")) == 0 || - (strcmp (state, "CURRENT")) == 0 || - (strcmp (state, "RECORD"))) { - callable_obj_t *new_call; - GHashTable *call_details; - gchar *type; - - DEBUG ("DBUS: New ringing call! accountID: %s", callID); - - // We fetch the details associated to the specified call - call_details = dbus_get_call_details (callID); - create_new_call_from_details (callID, call_details, &new_call); - - // Restore the callID to be synchronous with the daemon - new_call->_callID = g_strdup (callID); - type = g_hash_table_lookup (call_details, "CALL_TYPE"); - - if (g_strcasecmp (type, "0") == 0) { - // DEBUG("incoming\n"); - new_call->_history_state = INCOMING; - } else { - // DEBUG("outgoing\n"); - new_call->_history_state = OUTGOING; - } - - calllist_add_call (current_calls, new_call); - calllist_add_call (history, new_call); - calltree_add_call (current_calls, new_call, NULL); - update_actions(); - calltree_display (current_calls); - - //sflphone_incoming_call (new_call); - } - } -} - -static void -conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, - const gchar* state, void * foo UNUSED) -{ - - callable_obj_t *call; - gchar* call_id; - - // sflphone_display_transfer_status("Transfer successfull"); - conference_obj_t* changed_conf = conferencelist_get (current_calls, confID); - GSList * part; - - DEBUG ("---------------------------- DBUS: Conference state changed: %s\n", state); - - if (changed_conf) { - // remove old conference from calltree - calltree_remove_conference (current_calls, changed_conf, NULL); - - // update conference state - if (strcmp (state, "ACTIVE_ATACHED") == 0) { - changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATACHED; - } else if (strcmp (state, "ACTIVE_DETACHED") == 0) { - changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED; - } else if (strcmp (state, "ACTIVE_ATTACHED_REC") == 0) { - changed_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD; - } else if (strcmp(state, "ACTIVE_DETACHED_REC") == 0) { - changed_conf->_state = CONFERENCE_STATE_ACTIVE_DETACHED_RECORD; - } else if (strcmp (state, "HOLD") == 0) { - changed_conf->_state = CONFERENCE_STATE_HOLD; - } else if (strcmp(state, "HOLD_REC") == 0) { - changed_conf->_state = CONFERENCE_STATE_HOLD_RECORD; - } else { - DEBUG ("Error: conference state not recognized"); - } - - // reactivate instant messaging window for these calls - part = changed_conf->participant_list; - - while (part) { - call_id = (gchar*) (part->data); - call = calllist_get_call (current_calls, call_id); - - if (call && call->_im_widget) { - im_widget_update_state (IM_WIDGET (call->_im_widget), TRUE); - } - - part = g_slist_next (part); - } - - // update conferece participants - conference_participant_list_update (dbus_get_participant_list (changed_conf->_confID), changed_conf); - - // deactivate instant messaging window for new participants - part = changed_conf->participant_list; - - while (part) { - call_id = (gchar*) (part->data); - call = calllist_get_call (current_calls, call_id); - - if (call && call->_im_widget) { - im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE); - } - - part = g_slist_next (part); - } - - // add new conference to calltree - calltree_add_conference (current_calls, changed_conf); - } -} - -static void conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo UNUSED) { DEBUG ("DBUS: Conference %s added", confID); @@ -350,6 +11,9 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo create_new_conference (CONFERENCE_STATE_ACTIVE_ATACHED, confID, &new_conf); + conferencelist_add (current_calls, new_conf); + conferencelist_add (history, new_conf); + participants = (gchar**) dbus_get_participant_list (new_conf->_confID); // Update conference list @@ -365,7 +29,6 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE); } - // if one of these participant is currently recording, the whole conference will be recorded if(call->_state == CALL_STATE_RECORD) { new_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD; @@ -377,10 +40,10 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo set_timestamp(&new_conf->_time_start); - conferencelist_add (current_calls, new_conf); - conferencelist_add (history, new_conf); calltree_add_conference (current_calls, new_conf); calltree_add_conference (history, new_conf); + + calltree_display(current_calls); } static void @@ -545,7 +208,6 @@ sip_call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, { callable_obj_t * c = NULL; c = calllist_get_call (current_calls, callID); - if (c != NULL) { ERROR("DBUS: Error call is NULL in state changed"); return;