diff --git a/sflphone-client-gnome/src/Makefile.am b/sflphone-client-gnome/src/Makefile.am index 190c3ecec800f5b164966d7e9b1470b718918733..51eb9d8f65f33f3e4622a874a4afb143e8f01e2c 100644 --- a/sflphone-client-gnome/src/Makefile.am +++ b/sflphone-client-gnome/src/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS = config contacts dbus widget icons NOFIFY_LIBS = -lnotify X11_LIBS = -lX11 +LD_LIBS = -ldl SFLPHONEGTK_LIBS=./contacts/libcontacts.la ./config/libconfig.la ./dbus/libdbus.la ./widget/libwidget.la ./icons/libicons.la @@ -35,7 +36,7 @@ noinst_HEADERS = actions.h sflnotify.h mainwindow.h dialpad.h codeclist.h \ shortcuts.h eel-gconf-extensions.h logger.h sflphone_client_gnome_LDADD = $(DBUSGLIB_LIBS) $(LIBNOTIFY_LIBS) $(NOTIFY_LIBS) $(SFLPHONEGTK_LIBS) $(LIBSEXY_LIBS) $(X11_LIBS) \ - $(GTK_LIBS) $(GLIB_LIBS) $(WEBKIT_LIBS) $(LIBGNOMEUI_LIBS) $(GNOMEDOCUTILS_LIBS) + $(GTK_LIBS) $(GLIB_LIBS) $(WEBKIT_LIBS) $(LIBGNOMEUI_LIBS) $(GNOMEDOCUTILS_LIBS) $(LD_LIBS) sflphone_client_gnome_CFLAGS = $(DBUSGLIB_CFLAGS) $(LIBNOTIFY_CFLAGS) $(NOTIFY_CFLAGS) $(SFLPHONEGTK_CFLAGS) $(LIBSEXY_CFLAGS) $(X11_CFLAGS) \ $(GTK_CFLAGS) $(GLIB_CFLAGS) $(WEBKIT_CFLAGS) $(LIBGNOMEUI_CFLAGS) $(GNOMEDOCUTILS_CFLAGS) diff --git a/sflphone-client-gnome/src/accountlist.c b/sflphone-client-gnome/src/accountlist.c index f54f7a9ade23cd5fd63a2f2edffed36849bd8d45..cf3e96c2ddedab5f6e169b911de0fcc0c64f4131 100644 --- a/sflphone-client-gnome/src/accountlist.c +++ b/sflphone-client-gnome/src/accountlist.c @@ -94,6 +94,8 @@ account_list_remove (const gchar * accountID) { GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); + DEBUG("Account List remove"); + if (c) { g_queue_remove (accountQueue, c->data); } @@ -118,11 +120,12 @@ account_list_get_by_id (gchar * accountID) { GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct); - if (c) { - return (account_t *) c->data; - } else { - return NULL; - } + if(c == NULL) { + ERROR("AccountList: Could not find account %s", accountID); + return NULL; + } + + return (account_t *) c->data; } guint account_list_get_size (void) diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 5d98d19e7bb864c8690e8924ea42eef82c9bdacf..b8eb4ba5c735653de945e512c5245284f6e49a6c 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -195,7 +195,7 @@ sflphone_hung_up (callable_obj_t * c) { DEBUG ("SFLphone: Hung up"); - calllist_remove (current_calls, c->_callID); + calllist_remove_call (current_calls, c->_callID); calltree_remove_call (current_calls, c, NULL); c->_state = CALL_STATE_DIALING; call_remove_all_errors (c); @@ -337,7 +337,8 @@ gboolean sflphone_init (GError **error) account_list_init (); codec_capabilities_load (); - conferencelist_init (); + conferencelist_init (current_calls); + conferencelist_init (history); // Fetch the configured accounts sflphone_fill_account_list (); @@ -452,7 +453,6 @@ sflphone_pick_up() if (selectedCall) { switch (selectedCall->_state) { case CALL_STATE_DIALING: - DEBUG("------------------------------------ PLACING A NEW CALL FROM SFLPHONE PICKUP"); sflphone_place_call (selectedCall); // if instant messaging window is visible, create new tab (deleted automatically if not used) @@ -469,7 +469,6 @@ sflphone_pick_up() im_widget_display ( (IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL); dbus_accept (selectedCall); - DEBUG ("from sflphone_pick_up : "); stop_notification(); break; case CALL_STATE_HOLD: @@ -625,9 +624,10 @@ sflphone_incoming_call (callable_obj_t * c) gchar *msg = ""; c->_history_state = MISSED; - calllist_add (current_calls, c); - calllist_add (history, c); + 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); @@ -737,7 +737,7 @@ sflphone_new_call() c->_history_state = OUTGOING; - calllist_add (current_calls,c); + calllist_add_call (current_calls,c); calltree_add_call (current_calls, c, NULL); update_actions(); @@ -952,7 +952,10 @@ static int _place_registered_call (callable_obj_t * c) } c->_history_state = OUTGOING; - calllist_add (history, c); + + calllist_add_call (history, c); + calltree_add_call (history, c, NULL); + return 0; } @@ -1009,7 +1012,7 @@ sflphone_detach_participant (const gchar* callID) calltree_add_call (current_calls, selectedCall, NULL); dbus_detach_participant (selectedCall->_callID); } else { - callable_obj_t * selectedCall = calllist_get (current_calls, callID); + callable_obj_t * selectedCall = calllist_get_call (current_calls, callID); DEBUG ("Action: Darticipant %s", callID); if (selectedCall->_confID) { @@ -1225,7 +1228,7 @@ void sflphone_fill_call_list (void) c->_zrtp_confirmed = FALSE; // Add it to the list DEBUG ("Add call retrieved from server side: %s\n", c->_callID); - calllist_add (current_calls, c); + calllist_add_call (current_calls, c); // Update the GUI calltree_add_call (current_calls, c, NULL); } @@ -1259,7 +1262,7 @@ void sflphone_fill_conference_list (void) conf->_confID = g_strdup (conf_id); - conferencelist_add (conf); + conferencelist_add (current_calls, conf); calltree_add_conference (current_calls, conf); } } @@ -1272,6 +1275,7 @@ void sflphone_fill_history (void) gpointer key, value; gpointer key_to_min = NULL; callable_obj_t *history_entry; + conference_obj_t *conference_entry; int timestamp = 0; int min_timestamp = 0; @@ -1314,14 +1318,30 @@ void sflphone_fill_history (void) if (g_hash_table_lookup_extended (entries, key_to_min, &key, &value)) { - // do something with key and value - create_history_entry_from_serialized_form ( (gchar*) key, (gchar*) value, &history_entry); - DEBUG ("HISTORY ENTRY: %i\n", history_entry->_time_start); - // Add it and update the GUI - calllist_add (history, history_entry); - - // remove entry from map - g_hash_table_remove (entries, key_to_min); + gchar **ptr; + const gchar *delim = "|"; + + DEBUG("---------------------------------- HISTORY VALUE %s", value); + + ptr = g_strsplit(value, delim, 6); + if(ptr != NULL) { + + // first ptr refers to entry type + if(g_strcmp0(*ptr, "2188") == 0) { + // create_conference_history_entry_from_serialized((gchar *)key, (gchar **)ptr, &conference_entry); + g_hash_table_remove(entries, key_to_min); + } + else { + // do something with key and value + create_history_entry_from_serialized_form ( (gchar*) key, (gchar **) ptr, &history_entry); + + // Add it and update the GUI + calllist_add_call (history, history_entry); + calltree_add_call (history, history_entry, NULL); + // remove entry from map + g_hash_table_remove (entries, key_to_min); + } + } } } } @@ -1329,28 +1349,59 @@ void sflphone_fill_history (void) void sflphone_save_history (void) { - GQueue *items; gint size; - int i; - callable_obj_t *current; + gint i; + QueueElement *current; + conference_obj_t *conf; GHashTable *result = NULL; gchar *key, *value; - DEBUG ("Saving history ..."); + DEBUG ("SFLphone: Saving history"); result = g_hash_table_new (NULL, g_str_equal); - items = history->callQueue; size = calllist_get_size (history); - for (i=0; i<size; i++) { - current = g_queue_peek_nth (items, i); + for (i = 0; i < size; i++) { + current = calllist_get_nth (history, i); if (current) { - value = serialize_history_entry (current); - key = convert_timestamp_to_gchar (current->_time_start); - g_hash_table_replace (result, (gpointer) key, - (gpointer) value); + if(current->type == HIST_CALL) { + DEBUG("Serialize call"); + value = serialize_history_call_entry (current->elem.call); + key = convert_timestamp_to_gchar (current->elem.call->_time_start); + } + else if(current->type == HIST_CONFERENCE) { + DEBUG("Serialize conference"); + value = serialize_history_conference_entry(current->elem.conf); + key = convert_timestamp_to_gchar (current->elem.conf->_time_start); + } + else { + ERROR("SFLphone: Error: Unknown type for serialization"); + } + + g_hash_table_replace (result, (gpointer) key, (gpointer) value); + } + else { + WARN("SFLphone: Warning: %dth element is null", i); + } + } + + size = conferencelist_get_size(history); + DEBUG("Conference list size %d", size); + + while(size > 0) { + conf = conferencelist_pop_head(history); + size = conferencelist_get_size(history); + + if(conf) { + DEBUG("Serialize conference"); + value = serialize_history_conference_entry(conf); + key = convert_timestamp_to_gchar(conf->_time_start); + } + else { + WARN("SFLphone: Warning: %dth element is NULL", i); } + g_hash_table_replace(result, (gpointer)key, (gpointer)value); } dbus_set_history (result); diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index d38539a81491341fc7556e3f2a3b63445639733d..df20980b58a6756473367ea16c07eef2b6086843 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -39,10 +39,10 @@ #define UNIX_DAY 86400 #define UNIX_WEEK 86400 * 6 #define UNIX_TWO_DAYS 86400 * 2 - +/* gint is_callID_callstruct (gconstpointer a, gconstpointer b) { - callable_obj_t * c = (callable_obj_t*) a; + callable_obj_t * c = (callable_obj_t*) a; if (g_strcasecmp (c->_callID, (const gchar*) b) == 0) { return 0; @@ -50,6 +50,7 @@ gint is_callID_callstruct (gconstpointer a, gconstpointer b) return 1; } } +*/ gint get_state_callstruct (gconstpointer a, gconstpointer b) { @@ -297,55 +298,50 @@ void create_new_call_from_details (const gchar *call_id, GHashTable *details, ca *call = new_call; } -void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details, callable_obj_t **call) +void create_history_entry_from_serialized_form (gchar *timestamp, gchar **ptr, callable_obj_t **call) { - gchar *peer_name=""; - gchar *peer_number="", *accountID="", *time_stop=""; - gchar *recordfile=""; + gchar *peer_name = ""; + gchar *peer_number = "", *accountID = "", *time_stop = ""; + gchar *recordfile = ""; callable_obj_t *new_call; history_state_t history_state = MISSED; - char **ptr; - const char *delim="|"; - int token=0; + const gchar *delim = "|"; + gint token = 0; // details is in serialized form, i e: calltype%to%from%callid - if ( (ptr = g_strsplit (details, delim, 6)) != NULL) { - - 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; - } - - token++; - ptr++; - + 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; } + token++; + ptr++; + } if (g_strcasecmp (peer_name, "empty") == 0) @@ -454,7 +450,7 @@ gchar* get_call_duration (callable_obj_t *obj) } -gchar* serialize_history_entry (callable_obj_t *entry) +gchar* serialize_history_call_entry (callable_obj_t *entry) { // "0|514-276-5468|Savoir-faire Linux|144562458" for instance @@ -470,8 +466,6 @@ gchar* serialize_history_entry (callable_obj_t *entry) gchar* peer_name = (entry->_peer_name == NULL || g_strcasecmp (entry->_peer_name,"") == 0) ? "empty": entry->_peer_name; gchar* account_id = (entry->_accountID == NULL || g_strcasecmp (entry->_accountID,"") == 0) ? "empty": entry->_accountID; - DEBUG("ACCOUNT ID STORED IN HISTORY %s", account_id); - result = g_strconcat (history_state, separator, entry->_peer_number, separator, peer_name, separator, diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index f64e40015459a9fdc67acea1b8347e454e4c9a8b..7184eaf03d74e355a90114304dc01afea9f528b8 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -171,7 +171,7 @@ void create_new_call (callable_type_t, call_state_t, gchar*, gchar*, gchar*, gch void create_new_call_from_details (const gchar *, GHashTable *, callable_obj_t **); -void create_history_entry_from_serialized_form (gchar *, gchar *, callable_obj_t **); +void create_history_entry_from_serialized_form (gchar *, gchar **, callable_obj_t **); void call_add_error (callable_obj_t * call, gpointer dialog); @@ -182,7 +182,7 @@ void call_remove_all_errors (callable_obj_t * call); /* * GCompareFunc to compare a callID (gchar* and a callable_obj_t) */ -gint is_callID_callstruct (gconstpointer, gconstpointer); +// gint is_callID_callstruct (gconstpointer, gconstpointer); /* * GCompareFunc to get current call (gchar* and a callable_obj_t) @@ -223,7 +223,7 @@ history_state_t get_history_state_from_id (gchar *indice); gchar* get_call_duration (callable_obj_t *obj); -gchar* serialize_history_entry (callable_obj_t *entry); +gchar* serialize_history_call_entry(callable_obj_t *entry); gchar* get_history_id_from_state (history_state_t state); diff --git a/sflphone-client-gnome/src/conference_obj.c b/sflphone-client-gnome/src/conference_obj.c index 3649d996f6f5aafbb2576319e0f21cd0b622ea22..663f971579d0879d25a1e23cb90e32332c9025ad 100644 --- a/sflphone-client-gnome/src/conference_obj.c +++ b/sflphone-client-gnome/src/conference_obj.c @@ -28,19 +28,24 @@ * as that of the covered work. */ -#include <callable_obj.h> -#include <sflphone_const.h> #include <time.h> -gint is_confID_confstruct (gconstpointer a, gconstpointer b) +#include "callable_obj.h" +#include "sflphone_const.h" + +#include "calltab.h" +#include "calllist.h" + +static void set_conference_timestamp (time_t *); +static void conference_add_participant_number(const gchar *, conference_obj_t *); + +static void set_conference_timestamp (time_t *timestamp) { - conference_obj_t * c = (conference_obj_t*) a; + time_t tmp; - if (g_strcasecmp (c->_confID, (const gchar*) b) == 0) { - return 0; - } else { - return 1; - } + // Set to current value + (void) time(&tmp); + *timestamp = tmp; } void create_new_conference (conference_state_t state, const gchar* confID, conference_obj_t ** conf) @@ -111,6 +116,7 @@ void create_new_conference_from_details (const gchar *conf_id, GHashTable *detai *conf = new_conf; } + void free_conference_obj_t (conference_obj_t *c) { g_free (c->_confID); @@ -127,11 +133,25 @@ void conference_add_participant (const gchar* call_id, conference_obj_t* conf) { // store the new participant list after appending participant id conf->participant_list = g_slist_append (conf->participant_list, (gpointer) g_strdup(call_id)); + + // store the phone number of this participant + conference_add_participant_number(call_id, conf); } +static void conference_add_participant_number(const gchar *call_id, conference_obj_t *conf) { - conf->participant_number = g_slist_append(conf->participant_number, (gpointer) g_strdup(call_id)); + gchar *number_account; + + callable_obj_t *call = calllist_get_call(current_calls, call_id); + if(call == NULL) { + ERROR("Conference: Error: Could not find"); + return; + } + + number_account = g_strconcat(call->_peer_number, ",", call->_accountID, NULL); + + conf->participant_number = g_slist_append(conf->participant_number, (gpointer) number_account); } void conference_remove_participant (const gchar* call_id, conference_obj_t* conf) @@ -170,3 +190,125 @@ void conference_participant_list_update (gchar** participants, conference_obj_t* } } + +gchar *serialize_history_conference_entry(conference_obj_t *entry) +{ + gchar *result; + gchar *separator = "|"; + gchar *sep; + gchar *timestamp; + gchar *peer_name; + gchar *numberstr = ""; + GSList *number_list; + gint length = 0; + gint i; + + timestamp = convert_timestamp_to_gchar(entry->_time_stop); + + peer_name = (entry->_confID == NULL || g_strcasecmp(entry->_confID, "") == 0) ? "empty": entry->_confID; + + length = g_slist_length(entry->participant_number); + number_list = entry->participant_number; + + for(i = 0; i < length; i++) { + gchar *tmp = g_slist_nth_data(number_list, i); + if(tmp == NULL) { + WARN("Conference: Peer number is NULL in conference list"); + } + numberstr = g_strconcat(numberstr, tmp, ";", NULL); + + + DEBUG("Print: %s concat: %s", tmp, numberstr); + } + + result = g_strconcat("2188", separator, + numberstr, separator, // peer number + peer_name, separator, + timestamp, separator, + "", separator, // peer AccountID + entry->_recordfile ? entry->_recordfile : "", + NULL); + + + return result; +} + +void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **ptr, conference_obj_t **conf) +{ + gchar *conference_id = ""; + history_state_t history_state = MISSED; + gint token = 0; + conference_state_t state = CONFERENCE_STATE_ACTIVE_ATACHED; + gchar *participant = ""; + gchar *name = ""; + gchar *time_stop = ""; + gchar *accountID = ""; + gchar *recordfile = ""; + const gchar *confID = "conf_1234"; + + // create a new empty conference + create_new_conference(state, confID, conf); + + while(ptr != NULL && token < 6) { + switch(token) { + case 0: + history_state = MISSED; + break; + case 1: + participant = *ptr; + break; + case 2: + name = *ptr; + break; + case 3: + time_stop = *ptr; + break; + case 4: + accountID = *ptr; + break; + case 5: + recordfile = *ptr; + break; + default: + break; + } + + token++; + ptr++; + } +} + +void process_conference_participant_from_serialized(gchar *participant, conference_obj_t *conf) +{ + gchar **ptr = NULL; + gchar **numberptr = NULL; + gchar *delim = ";"; + gchar *delimnumber = ","; + gchar *numberaccount; + guint token = 0; + + ptr = g_strsplit(participant, delim, 0); + while(ptr != NULL) { + token = 0; + numberaccount = *ptr; + numberptr = g_strsplit(numberaccount, delimnumber, 2); + while(numberptr != NULL) { + gchar *phone_number = NULL; + gchar *account = NULL; + switch(token) { + case 0: + phone_number = *numberptr; + break; + case 1: + account = *numberptr; + break; + default: + break; + } + token++; + numberptr++; + + // we should create call here and add it to the conference to be inserted in history + } + } +} diff --git a/sflphone-client-gnome/src/conference_obj.h b/sflphone-client-gnome/src/conference_obj.h index 20ec9e88475222ce2c534f93e8a820c221b9bfdc..9acbc4cb77648ffa9ba5545dd4223fd660fb5032 100644 --- a/sflphone-client-gnome/src/conference_obj.h +++ b/sflphone-client-gnome/src/conference_obj.h @@ -67,6 +67,7 @@ typedef struct { time_t _time_start; time_t _time_stop; time_t _time_current; + gchar *_recordfile; } conference_obj_t; void create_new_conference (conference_state_t, const gchar*, conference_obj_t **); @@ -75,11 +76,6 @@ void create_new_conference_from_details (const gchar *, GHashTable *, conference void free_conference_obj_t (conference_obj_t *c); -/* - * GCompareFunc to compare a confID (gchar* and a callable_obj_t) - */ -gint is_confID_confstruct (gconstpointer, gconstpointer); - void conference_add_participatn (const gchar*, conference_obj_t *); void conference_remove_participant (const gchar*, conference_obj_t *); @@ -88,4 +84,6 @@ GSList* conference_next_participant (GSList* participant); void conference_participant_list_update (gchar**, conference_obj_t*); +gchar *serialize_history_conference_entry(conference_obj_t *entry); + #endif diff --git a/sflphone-client-gnome/src/contacts/calllist.c b/sflphone-client-gnome/src/contacts/calllist.c index 765ce2b874d0c7552af28040c6c3cedb10a1bf86..ab95bd03c64fc1209e14f66ed860d587538d4b7b 100644 --- a/sflphone-client-gnome/src/contacts/calllist.c +++ b/sflphone-client-gnome/src/contacts/calllist.c @@ -33,6 +33,30 @@ #include <contacts/searchbar.h> #include <eel-gconf-extensions.h> +static +gint is_callID_callstruct(gconstpointer a, gconstpointer b) +{ + QueueElement *c = (QueueElement *) a; + callable_obj_t *call; + + if(c == NULL) { + return 1; + } + + if(c->type != HIST_CALL) { + return 1; + } + + call = c->elem.call; + + if(g_strcasecmp(call->_callID, (const gchar *) b) == 0) { + return 0; + } + else { + return 1; + } +} + // TODO : sflphoneGTK : try to do this more generic void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo) { @@ -66,7 +90,7 @@ void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_ty attach_thumbnail (new_call, pixbuf); } - calllist_add (contacts, new_call); + calllist_add_call (contacts, new_call); calltree_add_call (contacts, new_call, NULL); } } @@ -91,38 +115,62 @@ calllist_reset (calltab_t* tab) tab->callQueue = g_queue_new(); } -void calllist_add_history_entry (callable_obj_t *obj) +void calllist_add_history_call (callable_obj_t *obj) { + QueueElement *element; + if (eel_gconf_get_integer (HISTORY_ENABLED)) { - g_queue_push_tail (history->callQueue, (gpointer *) obj); + element = (QueueElement *)malloc(sizeof(QueueElement)); + element->type = HIST_CALL; + element->elem.call = obj; + g_queue_push_tail (history->callQueue, (gpointer *) element); calltree_add_call (history, obj, NULL); } } -void -calllist_add (calltab_t* tab, callable_obj_t * c) +void calllist_add_history_conference(conference_obj_t *obj) { - if (tab == history) { - calllist_add_history_entry (c); - } else { - g_queue_push_tail (tab->callQueue, (gpointer *) c); + QueueElement *element; + + if(eel_gconf_get_integer (HISTORY_ENABLED)) { + element = (QueueElement *)malloc(sizeof(QueueElement)); + element->type = HIST_CONFERENCE; + element->elem.conf = obj; + g_queue_push_tail (history->callQueue, (gpointer *)element); + calltree_add_conference (history, obj); } } +void +calllist_add_call (calltab_t* tab, callable_obj_t * c) +{ + QueueElement *element; + + DEBUG("Calllist: Add Call %s", c->_callID); + + element = (QueueElement *)malloc(sizeof(QueueElement)); + element->type = HIST_CALL; + element->elem.call = c; + g_queue_push_tail (tab->callQueue, (gpointer *) element); +} + // TODO : sflphoneGTK : try to do this more generic void calllist_clean_history (void) { unsigned int i; guint size = calllist_get_size (history); - DEBUG ("CallList: history list size = %i", calllist_get_size (history)); - - for (i = 0 ; i < size ; i++) { - DEBUG ("CallList: Delete calls"); - callable_obj_t* c = calllist_get_nth (history , i); - // Delete the call from the call tree - DEBUG ("CallList: Delete calls"); - calltree_remove_call (history, c, NULL); + DEBUG ("CallList: History list size = %i", calllist_get_size (history)); + + for (i = 0 ; i < size; i++) { + QueueElement* c = calllist_get_nth (history , i); + if(c->type == HIST_CALL) { + calltree_remove_call (history, c->elem.call, NULL); + } + else if(c->type == HIST_CONFERENCE) { + calltree_remove_conference (history, c->elem.conf, NULL); + } + free(c); } calllist_reset (history); @@ -132,19 +180,32 @@ calllist_clean_history (void) void calllist_remove_from_history (callable_obj_t* c) { - calllist_remove (history, c->_callID); + calllist_remove_call (history, c->_callID); calltree_remove_call (history, c, NULL); - DEBUG ("CallList: Size of history = %i" , calllist_get_size (history)); + DEBUG ("CallList: Size of history = %d" , calllist_get_size (history)); } void -calllist_remove (calltab_t* tab, const gchar * callID) +calllist_remove_call (calltab_t* tab, const gchar * callID) { - callable_obj_t * c = calllist_get (tab, callID); + QueueElement *element; + GList *c; + + DEBUG("CallList: Remove call %s from list", callID); - if (c) { - g_queue_remove (tab->callQueue, c); + c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct); + if(c == NULL) { + DEBUG("CallList: Could not remove call %s", callID); + return; } + + element = (QueueElement *)c->data; + if(element->type != HIST_CALL) { + ERROR("CallList: Error: Element %s is not a call", callID); + return; + } + + g_queue_remove (tab->callQueue, element); } @@ -167,20 +228,33 @@ calllist_get_size (calltab_t* tab) return g_queue_get_length (tab->callQueue); } -callable_obj_t * +QueueElement * calllist_get_nth (calltab_t* tab, guint n) { return g_queue_peek_nth (tab->callQueue, n); } callable_obj_t * -calllist_get (calltab_t* tab, const gchar * callID) +calllist_get_call (calltab_t* tab, const gchar * callID) { + QueueElement *element; + callable_obj_t *call; + + DEBUG("CallList: Get call: %s", callID); + GList * c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct); - - if (c) { - return (callable_obj_t *) c->data; - } else { + if(c == NULL) { + ERROR("CallList: Error: Could not find call %s", callID); return NULL; } + + element = (QueueElement *)c->data; + if(element->type != HIST_CALL) { + ERROR("CallList: Error: Element %s is not a call", callID); + return NULL; + } + + call = element->elem.call; + + return call; } diff --git a/sflphone-client-gnome/src/contacts/calllist.h b/sflphone-client-gnome/src/contacts/calllist.h index e851fbaae0e9943a0233dd6f53a99994ba19ad3d..ce814c42511cb7d67f117795c31217f4e4ed2a31 100644 --- a/sflphone-client-gnome/src/contacts/calllist.h +++ b/sflphone-client-gnome/src/contacts/calllist.h @@ -39,6 +39,18 @@ * @brief A list to hold calls. */ +typedef enum { HIST_CONFERENCE, HIST_CALL } ElementType; + +typedef struct { + callable_obj_t *call; + conference_obj_t *conf; +} callableElement; + +typedef struct { + ElementType type; + callableElement elem; +} QueueElement; + typedef struct { GtkTreeStore* store; GtkWidget* view; @@ -47,6 +59,7 @@ typedef struct { // Calllist vars GQueue* callQueue; + GQueue* conferenceQueue; gint selectedType; callable_obj_t* selectedCall; conference_obj_t* selectedConf; @@ -56,7 +69,9 @@ typedef struct { void calllist_add_contact (gchar *, gchar *, contact_type_t, GdkPixbuf *); -void calllist_add_history_entry (callable_obj_t *obj); +void calllist_add_history_call (callable_obj_t *obj); + +void calllist_add_history_conference (conference_obj_t *obj); /** This function initialize a call list. */ void @@ -82,13 +97,13 @@ call_history_set_max_calls (const gdouble number); * @param c The call you want to add * */ void -calllist_add (calltab_t* tab, callable_obj_t * c); +calllist_add_call (calltab_t* tab, callable_obj_t * c); /** This function remove a call from list. * @param callID The callID of the call you want to remove */ void -calllist_remove (calltab_t* tab, const gchar * callID); +calllist_remove_call (calltab_t* tab, const gchar * callID); /** Return the first call that corresponds to the state. * This is usefull for unique states as DIALING and CURRENT. @@ -105,14 +120,14 @@ calllist_get_size (calltab_t* tab); /** Return the call at the nth position in the list * @param n The position of the call you want * @return A call or NULL */ -callable_obj_t * +QueueElement * calllist_get_nth (calltab_t* tab, guint n); /** Return the call corresponding to the callID * @param n The callID of the call you want * @return A call or NULL */ callable_obj_t * -calllist_get (calltab_t* tab, const gchar * callID); +calllist_get_call (calltab_t* tab, const gchar * callID); /** * Clean the history. Delete all calls diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 80e32bd82c602b9f9fe5726b5a143855b9cc9cb9..307338f03983d8e7654bef4338948a86587a83c1 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -242,7 +242,7 @@ row_activated (GtkTreeView *tree_view UNUSED, create_new_call (CALL, CALL_STATE_DIALING, "", account_id, selectedCall->_peer_name, selectedCall->_peer_number, &new_call); // sflphone_place_call(new_call); - calllist_add (current_calls, new_call); + calllist_add_call(current_calls, new_call); calltree_add_call (current_calls, new_call, NULL); // Function sflphone_place_call (new_call) is processed in process_dialing sflphone_place_call(new_call); @@ -306,16 +306,19 @@ calltree_create_conf_from_participant_list(GSList *list) { // 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(history, participant_id); + callable_obj_t *call = calllist_get_call(history, participant_id); if(c!=0) { participant_list = (void *) realloc(participant_list, (c+1) * sizeof(void *)); } - // allocate memory for teh participant number - *(participant_list+c) = g_strdup(call->_peer_number); + // allocate memory for the participant number + number = g_strconcat(call->_peer_number,",",call->_accountID, NULL); + + *(participant_list+c) = number; c++; } @@ -1234,7 +1237,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) while (conference_participant) { call_id = (gchar*) (conference_participant->data); - call = calllist_get (tab, call_id); + call = calllist_get_call(tab, call_id); if (call != NULL) { @@ -1268,7 +1271,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) while (conference_participant) { // call_id = (gchar*)(*pl); call_id = (gchar*) (conference_participant->data); - call = calllist_get (tab, call_id); + call = calllist_get_call(tab, call_id); if (call != NULL) { @@ -1326,7 +1329,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf) while (conference_participant) { call_id = (gchar*) (conference_participant->data); - call = calllist_get (tab, call_id); + call = calllist_get_call(tab, call_id); // create_new_call_from_details (conf_id, conference_details, &c); calltree_remove_call (tab, call, NULL); @@ -1455,7 +1458,7 @@ void calltree_add_history_conference(conference_obj_t *conf) { if(conference_participant) { while(conference_participant) { call_id = (gchar *)(conference_participant->data); - call = calllist_get(current_calls, call_id); + call = calllist_get_call(current_calls, call_id); if(call) { calltree_add_history_entry(call, &iter); } diff --git a/sflphone-client-gnome/src/contacts/conferencelist.c b/sflphone-client-gnome/src/contacts/conferencelist.c index 9c0744e2a3f6002de1fb85b3967bb7392d9495da..5ecb86cab89c60864bcfe28f6018d1104b8b2dc2 100644 --- a/sflphone-client-gnome/src/contacts/conferencelist.c +++ b/sflphone-client-gnome/src/contacts/conferencelist.c @@ -30,90 +30,170 @@ #include <conferencelist.h> +#include "logger.h" -gchar* -generate_conf_id (void) +static gint is_confID_confstruct(gconstpointer, gconstpointer); +static gchar *generate_conf_id (void); + +static gint is_confID_confstruct (gconstpointer a, gconstpointer b) +{ + conference_obj_t * c = (conference_obj_t*) a; + + if (g_strcasecmp (c->_confID, (const gchar*) b) == 0) { + return 0; + } else { + return 1; + } +} + +static gchar *generate_conf_id (void) { gchar *conf_id; conf_id = g_new0 (gchar, 30); g_sprintf (conf_id, "%d", rand()); + return conf_id; } -void -conferencelist_init() +void conferencelist_init(calltab_t *tab) { - conferenceQueue = g_queue_new (); + if(tab == NULL) { + ERROR("ConferenceList: Error: Call tab is NULL"); + return; + } + + tab->conferenceQueue = g_queue_new (); } -void -conferencelist_clean() +void conferencelist_clean(calltab_t *tab) { - g_queue_free (conferenceQueue); + if(tab == NULL) { + ERROR("ConferenceList: Error: Calltab tab is NULL"); + return; + } + + g_queue_free (tab->conferenceQueue); } -void -conferencelist_reset() +void conferencelist_reset(calltab_t *tab) { - g_queue_free (conferenceQueue); - conferenceQueue = g_queue_new(); + if(tab == NULL) { + ERROR("ConferenceList: Error: Calltab tab is NULL"); + return; + } + + g_queue_free (tab->conferenceQueue); + tab->conferenceQueue = g_queue_new(); } -void -conferencelist_add (const conference_obj_t* conf) +void conferencelist_add (calltab_t *tab, const conference_obj_t* conf) { - gchar* c = (gchar*) conferencelist_get (conf->_confID); + gchar* c; + + if(conf == NULL) { + ERROR("ConferenceList: Error: Conference is NULL"); + return; + } + + if(tab == NULL) { + ERROR("ConferenceList: Error: Tab is NULL"); + return; + } + + c = (gchar*) conferencelist_get (tab, conf->_confID); if (!c) { - g_queue_push_tail (conferenceQueue, (gpointer) conf); + // only add conference into the list if not already inserted + g_queue_push_tail (tab->conferenceQueue, (gpointer) conf); } } -void -conferencelist_remove (const gchar* conf) +void conferencelist_remove (calltab_t *tab, const gchar* conf) { - gchar* c = (gchar*) conferencelist_get (conf); + gchar* c; - if (c) { - g_queue_remove (conferenceQueue, c); + if(conf == NULL) { + ERROR("ConferenceList: Error: Conf id is NULL"); + return; } + + if(tab == NULL) { + ERROR("ConferenceList: Error: Calltab is NULL"); + return; + } + + c = (gchar*) conferencelist_get (tab, conf); + + if(c == NULL) { + ERROR("ConferenceList: Error: Could not find conference %s", conf); + return; + } + + g_queue_remove (tab->conferenceQueue, c); } -conference_obj_t* -conferencelist_get (const gchar* conf_id) +conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* conf_id) { - GList* c = g_queue_find_custom (conferenceQueue, conf_id, is_confID_confstruct); + GList* c; - if (c) { - return (conference_obj_t*) c->data; - } else { + if(tab == NULL) { + ERROR("ConferenceList: Error: Calltab is NULL"); + return; + } + + c = g_queue_find_custom (tab->conferenceQueue, conf_id, is_confID_confstruct); + + if(c == NULL) { + ERROR("ConferenceList: Error: Could not find conference %s", conf_id); return NULL; } + + return (conference_obj_t*) c->data; } -conference_obj_t* -conferencelist_get_nth (guint n) +conference_obj_t* conferencelist_get_nth (calltab_t *tab, guint n) { - GList* c = g_queue_peek_nth (conferenceQueue, n); + GList* c; - if (c) { - return (conference_obj_t*) c->data; - } else { - return NULL; + if(tab == NULL) { + ERROR("ConferenceList: Error: Calltab is NULL"); + return NULL; } + + c = g_queue_peek_nth (tab->conferenceQueue, n); + + if(c == NULL) { + ERROR("ConferenceList: Error: Could not fetch conference %d", n); + return NULL; + } + + return (conference_obj_t*) c->data; } +conference_obj_t *conferencelist_pop_head(calltab_t *tab) +{ + if(tab == NULL) { + ERROR("ConferenceList: Error: Tab is NULL"); + return NULL; + } -guint -conferencelist_get_size () + return g_queue_pop_head(tab->conferenceQueue); +} + +guint conferencelist_get_size (calltab_t *tab) { - return g_queue_get_length (conferenceQueue); + if(tab == NULL) { + ERROR("ConferenceList: Error: Calltab is NULL"); + return 0; + } + + return g_queue_get_length (tab->conferenceQueue); } diff --git a/sflphone-client-gnome/src/contacts/conferencelist.h b/sflphone-client-gnome/src/contacts/conferencelist.h index a2bcc6a45584d16993765660d267169d76009d85..f09060b85049cefb093e8b85798d08c9ce0e459c 100644 --- a/sflphone-client-gnome/src/contacts/conferencelist.h +++ b/sflphone-client-gnome/src/contacts/conferencelist.h @@ -31,56 +31,59 @@ #ifndef __CONFERENCELIST_H__ #define __CONFERENCELIST_H__ - -#include <conference_obj.h> #include <gtk/gtk.h> +#include "conference_obj.h" +#include "calllist.h" + /** @file conferencelist.h * @brief A list to store conferences. */ -GQueue* conferenceQueue; +// GQueue* conferenceQueue; /** This function initialize a conference list. */ void -conferencelist_init (); +conferencelist_init (calltab_t *); /** This function empty and free the conference list. */ void -conferencelist_clean (); +conferencelist_clean (calltab_t *); /** This function empty, free the conference list and allocate a new one. */ void -conferencelist_reset (); +conferencelist_reset (calltab_t *); /** This function append a conference to the list. * @param conf The conference you want to add * */ void -conferencelist_add (const conference_obj_t* conf); +conferencelist_add (calltab_t *, const conference_obj_t *); /** This function remove a conference from list. * @param callID The callID of the conference you want to remove */ void -conferencelist_remove (const gchar* conf); +conferencelist_remove (calltab_t *, const gchar *); /** Return the number of calls in the list * @return The number of calls in the list */ guint -conferencelist_get_size (); +conferencelist_get_size (calltab_t *); /** Return the call at the nth position in the list * @param n The position of the call you want * @return A call or NULL */ conference_obj_t* -conferencelist_get_nth (guint n); +conferencelist_get_nth (calltab_t *, guint); /** Return the call corresponding to the callID - * @param n The callID of the call you want + * @param n The callID of the call want * @return A call or NULL */ conference_obj_t* -conferencelist_get (const gchar* conf); +conferencelist_get (calltab_t *, const gchar *); +conference_obj_t* +conferencelist_pop_head(calltab_t *); #endif diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 2b6149ff8c9fbf4d4c0541c6698d3ae13062492b..cc38c1953da7cc35591a25a5c5c9c2cd6dea1fad 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -63,7 +63,7 @@ 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 = to; + gchar *peer_name = (gchar *)to; gchar *peer_number = ""; DEBUG("DBus: New Call (%s) created to (%s)", callID, to); @@ -73,9 +73,11 @@ new_call_created_cb (DBusGProxy *proxy UNUSED, const gchar *accountID, set_timestamp(&c->_time_start); - calllist_add(current_calls, c); - calllist_add(history, c); + 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); } @@ -115,7 +117,7 @@ zrtp_negotiation_failed_cb (DBusGProxy *proxy UNUSED, const gchar* callID, DEBUG ("Zrtp negotiation failed."); main_window_zrtp_negotiation_failed (callID, reason, severity); callable_obj_t * c = NULL; - c = calllist_get (current_calls, callID); + c = calllist_get_call (current_calls, callID); if (c) { notify_zrtp_negotiation_failed (c); @@ -162,10 +164,10 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const return; // Get the call information. (if this call exist) - call = calllist_get (current_calls, callID); + call = calllist_get_call (current_calls, callID); // Get the conference information (if this conference exist) - conf = conferencelist_get (callID); + conf = conferencelist_get (current_calls, callID); /* First check if the call is valid */ if (call) { @@ -189,13 +191,16 @@ 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 (current_calls, callID); + 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 ("call state current"); + DEBUG ("DBUS: call state current"); set_timestamp (&c->_time_stop); calltree_update_call (history, c, NULL); } @@ -250,8 +255,8 @@ call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state new_call->_history_state = OUTGOING; } - calllist_add (current_calls, new_call); - calllist_add (history, new_call); + 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); @@ -270,7 +275,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, gchar* call_id; // sflphone_display_transfer_status("Transfer successfull"); - conference_obj_t* changed_conf = conferencelist_get (confID); + conference_obj_t* changed_conf = conferencelist_get (current_calls, confID); GSList * part; DEBUG ("---------------------------- DBUS: Conference state changed: %s\n", state); @@ -301,7 +306,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, while (part) { call_id = (gchar*) (part->data); - call = calllist_get (current_calls, call_id); + call = calllist_get_call (current_calls, call_id); if (call && call->_im_widget) { im_widget_update_state (IM_WIDGET (call->_im_widget), TRUE); @@ -318,7 +323,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, while (part) { call_id = (gchar*) (part->data); - call = calllist_get (current_calls, call_id); + call = calllist_get_call (current_calls, call_id); if (call && call->_im_widget) { im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE); @@ -353,7 +358,7 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo // Add conference ID in in each calls for (part = participants; *part; part++) { call_id = (gchar*) (*part); - call = calllist_get (current_calls, call_id); + call = calllist_get_call (current_calls, call_id); // if a text widget is already created, disable it, use conference widget instead if (call->_im_widget) { @@ -372,7 +377,8 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo set_timestamp(&new_conf->_time_start); - conferencelist_add (new_conf); + conferencelist_add (current_calls, new_conf); + conferencelist_add (history, new_conf); calltree_add_conference (current_calls, new_conf); calltree_add_conference (history, new_conf); } @@ -382,7 +388,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo { DEBUG ("DBUS: Conference removed %s", confID); - conference_obj_t * c = conferencelist_get (confID); + conference_obj_t * c = conferencelist_get (current_calls, confID); calltree_remove_conference (current_calls, c, NULL); GSList *participant = c->participant_list; @@ -395,7 +401,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo // remove all participant for this conference while (participant) { - call = calllist_get (current_calls, (const gchar *) (participant->data)); + call = calllist_get_call (current_calls, (const gchar *) (participant->data)); if (call) { DEBUG ("DBUS: Remove participant %s", call->_callID); @@ -413,7 +419,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo participant = conference_next_participant (participant); } - conferencelist_remove (c->_confID); + conferencelist_remove (current_calls, c->_confID); } static void @@ -450,7 +456,7 @@ static void secure_sdes_on_cb (DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED) { DEBUG ("SRTP using SDES is on"); - callable_obj_t *c = calllist_get (current_calls, callID); + callable_obj_t *c = calllist_get_call (current_calls, callID); if (c) { sflphone_srtp_sdes_on (c); @@ -463,7 +469,7 @@ static void secure_sdes_off_cb (DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED) { DEBUG ("SRTP using SDES is off"); - callable_obj_t *c = calllist_get (current_calls, callID); + callable_obj_t *c = calllist_get_call (current_calls, callID); if (c) { sflphone_srtp_sdes_off (c); @@ -476,7 +482,7 @@ secure_zrtp_on_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* c void * foo UNUSED) { DEBUG ("SRTP using ZRTP is ON secure_on_cb"); - callable_obj_t * c = calllist_get (current_calls, callID); + callable_obj_t * c = calllist_get_call (current_calls, callID); if (c) { c->_srtp_cipher = g_strdup (cipher); @@ -490,7 +496,7 @@ static void secure_zrtp_off_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED) { DEBUG ("SRTP using ZRTP is OFF"); - callable_obj_t * c = calllist_get (current_calls, callID); + callable_obj_t * c = calllist_get_call (current_calls, callID); if (c) { sflphone_srtp_zrtp_off (c); @@ -503,7 +509,7 @@ show_zrtp_sas_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* sa const gboolean verified, void * foo UNUSED) { DEBUG ("Showing SAS"); - callable_obj_t * c = calllist_get (current_calls, callID); + callable_obj_t * c = calllist_get_call (current_calls, callID); if (c) { sflphone_srtp_zrtp_show_sas (c, sas, verified); @@ -514,7 +520,7 @@ static void confirm_go_clear_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED) { DEBUG ("Confirm Go Clear request"); - callable_obj_t * c = calllist_get (current_calls, callID); + callable_obj_t * c = calllist_get_call (current_calls, callID); if (c) { sflphone_confirm_go_clear (c); @@ -525,7 +531,7 @@ static void zrtp_not_supported_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED) { DEBUG ("ZRTP not supported on the other end"); - callable_obj_t * c = calllist_get (current_calls, callID); + callable_obj_t * c = calllist_get_call (current_calls, callID); if (c) { sflphone_srtp_zrtp_not_supported (c); @@ -538,7 +544,7 @@ sip_call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* description, const guint code, void * foo UNUSED) { callable_obj_t * c = NULL; - c = calllist_get (current_calls, callID); + c = calllist_get_call (current_calls, callID); if (c != NULL) { ERROR("DBUS: Error call is NULL in state changed"); diff --git a/sflphone-client-gnome/src/imwindow.c b/sflphone-client-gnome/src/imwindow.c index 03b296c50bb45b7fb8598427d408a31f31363fc4..3681fa940289c02eefdcace3bb9d9f74a550fada 100644 --- a/sflphone-client-gnome/src/imwindow.c +++ b/sflphone-client-gnome/src/imwindow.c @@ -202,8 +202,8 @@ im_window_add_tab (GtkWidget *widget) IMWidget *im = IM_WIDGET (widget); /* Fetch the call */ - callable_obj_t *im_widget_call = calllist_get (current_calls, im->call_id); - conference_obj_t *im_widget_conf = conferencelist_get (im->call_id); + callable_obj_t *im_widget_call = calllist_get_call (current_calls, im->call_id); + conference_obj_t *im_widget_conf = conferencelist_get (current_calls, im->call_id); /* A container to include the tab label and the close button */ GtkWidget *tab_Container = gtk_hbox_new (FALSE, 3); @@ -274,8 +274,8 @@ im_window_remove_tab (GtkWidget *widget) /* Need to do some memory clean up, so that we could re-open an Im widget for this call later. */ IMWidget *im = IM_WIDGET (widget); - callable_obj_t *call = calllist_get (current_calls, im->call_id); - conference_obj_t *conf = conferencelist_get (im->call_id); + callable_obj_t *call = calllist_get_call (current_calls, im->call_id); + conference_obj_t *conf = conferencelist_get (current_calls, im->call_id); if (call) call->_im_widget = NULL; diff --git a/sflphone-client-gnome/src/mainwindow.c b/sflphone-client-gnome/src/mainwindow.c index d46daed0a3e85e3b34bd98abaaec7b55a19447b4..3f44a9e8bc9887b7f8eca4c83fdbe93b4f422ff2 100644 --- a/sflphone-client-gnome/src/mainwindow.c +++ b/sflphone-client-gnome/src/mainwindow.c @@ -533,7 +533,7 @@ main_window_zrtp_negotiation_failed (const gchar* callID, const gchar* reason, { gchar* peer_number = "(number unknown)"; callable_obj_t * c = NULL; - c = calllist_get (current_calls, callID); + c = calllist_get_call (current_calls, callID); if (c != NULL) { peer_number = c->_peer_number; diff --git a/sflphone-client-gnome/src/uimanager.c b/sflphone-client-gnome/src/uimanager.c index 89434a20111762ffa93feb742e315a6273c59209..63bd16a1abdef5d59357638086dc23949d26730e 100644 --- a/sflphone-client-gnome/src/uimanager.c +++ b/sflphone-client-gnome/src/uimanager.c @@ -211,7 +211,7 @@ update_actions() if (selectedCall) { - DEBUG("UIManager: Update actions for call"); + DEBUG("UIManager: Update actions for call %s", selectedCall->_callID); // update icon in systray show_status_hangup_icon(); @@ -650,7 +650,7 @@ call_pick_up (void * foo UNUSED) create_new_call (CALL, CALL_STATE_DIALING, "", "", "", selectedCall->_peer_number, &new_call); - calllist_add (current_calls, new_call); + calllist_add_call (current_calls, new_call); calltree_add_call (current_calls, new_call, NULL); sflphone_place_call (new_call); calltree_display (current_calls); @@ -733,7 +733,7 @@ call_back (void * foo UNUSED) create_new_call (CALL, CALL_STATE_DIALING, "", "", selected_call->_peer_name, selected_call->_peer_number, &new_call); - calllist_add (current_calls, new_call); + calllist_add_call (current_calls, new_call); calltree_add_call (current_calls, new_call, NULL); sflphone_place_call (new_call); calltree_display (current_calls); @@ -909,7 +909,7 @@ call_mailbox_cb (void) create_new_call (CALL, CALL_STATE_DIALING, "", account_id, _ ("Voicemail"), to, &mailbox_call); DEBUG ("TO : %s" , mailbox_call->_peer_number); - calllist_add (current_calls, mailbox_call); + calllist_add_call (current_calls, mailbox_call); calltree_add_call (current_calls, mailbox_call, NULL); update_actions(); sflphone_place_call (mailbox_call); @@ -1570,7 +1570,7 @@ ok_cb (GtkWidget *widget UNUSED, gpointer userdata) original->_peer_name, g_strdup (new_number), &modified_call); // Update the internal data structure and the GUI - calllist_add (current_calls, modified_call); + calllist_add_call (current_calls, modified_call); calltree_add_call (current_calls, modified_call, NULL); sflphone_place_call (modified_call); calltree_display (current_calls); diff --git a/sflphone-client-gnome/src/widget/imwidget.c b/sflphone-client-gnome/src/widget/imwidget.c index 5c3172a5046ff9dfb984c6ee3980ea43f7650534..5cb55eb237789137d859e8851532635cd87e77c3 100644 --- a/sflphone-client-gnome/src/widget/imwidget.c +++ b/sflphone-client-gnome/src/widget/imwidget.c @@ -50,8 +50,8 @@ on_frame_loading_done (GObject *gobject UNUSED, GParamSpec *pspec UNUSED, gpoint case WEBKIT_LOAD_COMMITTED: break; case WEBKIT_LOAD_FINISHED: - call = calllist_get (current_calls, im->call_id); - conf = conferencelist_get (im->call_id); + call = calllist_get_call (current_calls, im->call_id); + conf = conferencelist_get (current_calls, im->call_id); if (call) im_widget_add_message (im, im->first_message_from, im->first_message, 0); @@ -215,13 +215,13 @@ void im_widget_send_message (gchar *id, const gchar *message) { - callable_obj_t *im_widget_call = calllist_get (current_calls, id); - conference_obj_t *im_widget_conf = conferencelist_get (id); + callable_obj_t *im_widget_call = calllist_get_call (current_calls, id); + conference_obj_t *im_widget_conf = conferencelist_get (current_calls, id); /* If the call has been hungup, it is not anymore in the current_calls calltab */ if (!im_widget_call) { /* So try the history tab */ - im_widget_call = calllist_get (history, id); + im_widget_call = calllist_get_call (history, id); } if (im_widget_conf) { @@ -395,8 +395,8 @@ im_widget_infobar (IMWidget *im) GtkWidget *content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar)); /* Fetch call/conference information */ - callable_obj_t *im_widget_call = calllist_get (current_calls, im->call_id); - conference_obj_t *im_widget_conf = conferencelist_get (im->call_id); + callable_obj_t *im_widget_call = calllist_get_call (current_calls, im->call_id); + conference_obj_t *im_widget_conf = conferencelist_get (current_calls, im->call_id); /* Create the label widgets with the call information saved in the IM Widget struct */ gchar *msg1; diff --git a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h index 2fad01eed47517cfda17904a1563a9a1430b08f2..c9d2acadff0bf7c9caba62ecefe3ee24309fc81e 100644 --- a/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h +++ b/sflphone-common/src/audio/audiortp/ZrtpSessionCallback.h @@ -30,6 +30,9 @@ #ifndef __SFL_ZRTP_CALLBACK_H__ #define __SFL_ZRTP_CALLBACK_H__ +#include <cstddef> + +using std::ptrdiff_t; #include <libzrtpcpp/zrtpccrtp.h> #include <libzrtpcpp/ZrtpQueue.h> diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index a082cae1957e000aed4a2f22276ff17f4f88a21a..b986824ad387bccb0b616f8374caf3ff1586c1f2 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1316,29 +1316,19 @@ void ManagerImpl::createConfFromParticipantList(const std::vector< std::string > Conference *conf = new Conference(); - // std::vector< std::string >::iterator iter; + for(unsigned int i = 0; i < participantList.size(); i++) { + std::string numberaccount = participantList[i]; + std::string tostr = numberaccount.substr(0, numberaccount.find(",")); + std::string account = numberaccount.substr(numberaccount.find(",")+1, numberaccount.size()); + + std::string generatedCallID = getNewCallID(); - // iter = participantList.begin(); + conf->add(generatedCallID); - /* - while(iter != participantList.end()) { - std::string participant = *iter; - _debug("PARTICIPANT LIST %s", participant.c_str()); - iter++; - } - */ - - std::string generatedCallID = "callid"; - std::string accountstr = "Account:1307562458"; + outgoingCall(account, generatedCallID, tostr, conf->getConfID()); - for(unsigned int i = 0; i < participantList.size(); i++) { - _debug("********************************************************************* PARTICIPANT LIST %s", participantList[i].c_str()); - std::string tostr = participantList[i].c_str(); - generatedCallID = generatedCallID + participantList[i]; - conf->add(generatedCallID); - outgoingCall(accountstr, generatedCallID, tostr, conf->getConfID()); if(_dbus) { - _dbus->getCallManager()->newCallCreated(accountstr, generatedCallID, tostr); + _dbus->getCallManager()->newCallCreated(account, generatedCallID, tostr); } }