diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 89a48d47d082e2f46dc6942b8ec5fd566610025f..9fc579db20d87af4e83128a9ba83290dfb8919e8 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -253,6 +253,7 @@ row_activated(GtkTreeView *tree_view UNUSED, } + /* Catch cursor-activated signal. That is, when the entry is single clicked */ void row_single_click(GtkTreeView *tree_view UNUSED, void * data UNUSED) @@ -336,6 +337,186 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS return FALSE; } + +gchar* +calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gchar *audio_codec, gchar** display_info) +{ + + gchar * description; + gchar * tmp_info; + + gchar * peer_number = c->_peer_number; + gchar * hostname = NULL; + gchar * display_number = ""; + + DEBUG("Display call info"); + + // Get the hostname for this call (NULL if not existent) + hostname = g_strrstr(peer_number, "@"); + + // Test if we are dialing a new number + if(g_strcmp0("", c->_peer_number) != 0) { + + // Strip the hostname if existent + if(hostname) { + display_number = g_strndup(peer_number, hostname - peer_number); + } + else { + display_number = peer_number; + } + } + else { + + display_number = peer_number; + } + + // Different display depending on type + switch(display_type) { + + case DISPLAY_TYPE_CALL: + + DEBUG("display a normal call"); + if(c->_state_code == 0) { + + if(g_strcmp0("", c->_peer_name) == 0) { + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>", + display_number, + c->_peer_name); + } + else { + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", + c->_peer_name, + display_number); + } + + } + else { + if(g_strcmp0("", c->_peer_name) == 0) { + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s (%d)</i>", + display_number, + c->_peer_name, + c->_state_code_description, + c->_state_code); + } + else { + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>", + c->_peer_name, + display_number, + c->_state_code_description, + c->_state_code); + } + } + + break; + + + case DISPLAY_TYPE_CALL_TRANSFER: + + DEBUG("display a call transfer") + + if(g_strcmp0("",c->_peer_name) == 0){ + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Transfert to:%s</i> ", + display_number, + c->_peer_name, + c->_trsft_to); + } + else { + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ", + c->_peer_name, + display_number, + c->_trsft_to); + } + + break; + + + case DISPLAY_TYPE_STATE_CODE : + + DEBUG("display a state code"); + + if(g_strcmp0("",c->_peer_name) == 0){ + + if (c->_state_code) { + + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", + display_number, + c->_peer_name, + c->_state_code_description, + c->_state_code, + audio_codec); + } else { + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s</i>", + display_number, + c->_peer_name, + audio_codec); + } + } + else { + if (c->_state_code) { + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", + c->_peer_name, + display_number, + c->_state_code_description, + c->_state_code, + audio_codec); + } else { + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s</i>", + c->_peer_name, + display_number, + audio_codec); + } + } + break; + + case DISPLAY_TYPE_SAS: + + DEBUG("display a call with sas"); + + if(g_strcmp0("",c->_peer_name) == 0){ + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", + display_number, + c->_peer_name, + c->_sas); + } + else { + + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", + c->_peer_name, + display_number, + c->_sas); + } + + case DISPLAY_TYPE_HISTORY : + + DEBUG("display history entry"); + + if(g_strcmp0("", c->_peer_name) == 0) { + + description = g_markup_printf_escaped("<b>%s</b><i>%s</i>", + display_number, + c->_peer_name); + } + else { + + description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", + c->_peer_name, + display_number); + } + break; + + default : + DEBUG("Not an allowable type of display"); + break; + + } + + // return description; + tmp_info = g_strdup(description); + *display_info = tmp_info; +} + + + /** * Reset call tree */ @@ -521,212 +702,156 @@ calltree_remove_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) void calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) { - GdkPixbuf *pixbuf=NULL; - GdkPixbuf *pixbuf_security=NULL; - GtkTreeIter iter; - GValue val; - callable_obj_t * iterCall; - GtkTreeStore* store = tab->store; - - gchar* srtp_enabled = ""; - gboolean display_sas = TRUE; - account_t* account_details=NULL; - gchar *audio_codec = ""; - - - int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); - int i; + GdkPixbuf *pixbuf=NULL; + GdkPixbuf *pixbuf_security=NULL; + GtkTreeIter iter; + GValue val; + callable_obj_t * iterCall; + GtkTreeStore* store = tab->store; - if(c != NULL) { - account_details = account_list_get_by_id(c->_accountID); - if(account_details != NULL) { - srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); - if(g_strcasecmp(g_hash_table_lookup(account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) - { display_sas = FALSE; } - } else { - GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); - if(properties != NULL) { - if(g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) - { display_sas = FALSE; } - } - } - } + gchar* srtp_enabled = ""; + gboolean display_sas = TRUE; + account_t* account_details=NULL; + gchar *audio_codec = ""; + + + int nbChild = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), parent); + int i; + + if(c != NULL) { + account_details = account_list_get_by_id(c->_accountID); + if(account_details != NULL) { + srtp_enabled = g_hash_table_lookup(account_details->properties, ACCOUNT_SRTP_ENABLED); + if(g_strcasecmp(g_hash_table_lookup(account_details->properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) + { display_sas = FALSE; } + } else { + GHashTable * properties = NULL; + sflphone_get_ip2ip_properties (&properties); + if(properties != NULL) { + if(g_strcasecmp(g_hash_table_lookup(properties, ACCOUNT_ZRTP_DISPLAY_SAS),"false") == 0) + { display_sas = FALSE; } + } + } + } - for( i = 0; i < nbChild; i++) - { + for( i = 0; i < nbChild; i++) { - if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, parent, i)) - { + if(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), &iter, parent, i)) { - if(gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter)) - { + if(gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter)) { calltree_update_call (tab, c, &iter); - } - - val.g_type = 0; - gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter, COLUMN_ACCOUNT_PTR, &val); - - - iterCall = (callable_obj_t*) g_value_get_pointer(&val); - g_value_unset(&val); + } - if(iterCall != c) { - continue; - } + val.g_type = 0; + gtk_tree_model_get_value (GTK_TREE_MODEL(store), &iter, COLUMN_ACCOUNT_PTR, &val); - /* Update text */ - gchar * description; - gchar * date=""; - gchar * duration=""; - audio_codec = call_get_audio_codec (c); + + iterCall = (callable_obj_t*) g_value_get_pointer(&val); + g_value_unset(&val); + + if(iterCall != c) { + continue; + } - if(c->_state == CALL_STATE_TRANSFERT) - { - if(g_strcmp0("",c->_peer_name) == 0){ - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ", - c->_peer_number, - c->_peer_name, - c->_trsft_to); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ", - c->_peer_name, - c->_peer_number, - c->_trsft_to); - } - } - else - { - // c->_zrtp_confirmed == FALSE : Hack explained in callable_obj.h - if((c->_sas != NULL) && (display_sas == TRUE) && (c->_srtp_state == SRTP_STATE_SAS_UNCONFIRMED) && (c->_zrtp_confirmed == FALSE)) { - - if(g_strcmp0("",c->_peer_name) == 0){ - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", - c->_peer_number, - c->_peer_name, - c->_sas); - } - else { - - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Confirm SAS <b>%s</b> ?</i> ", - c->_peer_name, - c->_peer_number, - c->_sas); - } - } else { - DEBUG("Updating state code %d %s", c->_state_code, c->_state_code_description); - if(g_strcmp0("",c->_peer_name) == 0){ - if (c->_state_code) { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", - c->_peer_number, - c->_peer_name, - c->_state_code_description, - c->_state_code, - audio_codec); - } else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s</i>", - c->_peer_number, - c->_peer_name, - audio_codec); - } - } - else { - if (c->_state_code) { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i> <i>%s</i>", - c->_peer_name, - c->_peer_number, - c->_state_code_description, - c->_state_code, - audio_codec); - } else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s</i>", - c->_peer_name, - c->_peer_number, - audio_codec); - } - } - } - } + /* Update text */ + gchar * description; + gchar * date=""; + gchar * duration=""; + audio_codec = call_get_audio_codec (c); + + if(c->_state == CALL_STATE_TRANSFERT) { - /* Update icons */ - if( tab == current_calls ) - { - DEBUG("Receiving in state %d", c->_state); - switch(c->_state) - { - case CALL_STATE_HOLD: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL); - break; - case CALL_STATE_INCOMING: - case CALL_STATE_RINGING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL); - break; - case CALL_STATE_CURRENT: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/current.svg", NULL); - break; - case CALL_STATE_DIALING: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/dial.svg", NULL); - break; - case CALL_STATE_FAILURE: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/fail.svg", NULL); - break; - case CALL_STATE_BUSY: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/busy.svg", NULL); - break; - case CALL_STATE_TRANSFERT: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/transfert.svg", NULL); - break; - case CALL_STATE_RECORD: - pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/icon_rec.svg", NULL); - break; - default: - WARN("Update calltree - Should not happen!"); - } + calltree_display_call_info(c, DISPLAY_TYPE_CALL_TRANSFER, NULL, &description); + + } + else { - switch(c->_srtp_state) - { - case SRTP_STATE_SAS_UNCONFIRMED: - DEBUG("Secure is ON"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_unconfirmed.svg", NULL); - if(c->_sas != NULL) { DEBUG("SAS is ready with value %s", c->_sas); } - break; - case SRTP_STATE_SAS_CONFIRMED: - DEBUG("SAS is confirmed"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_confirmed.svg", NULL); - break; - case SRTP_STATE_SAS_SIGNED: - DEBUG("Secure is ON with SAS signed and verified"); - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_certified.svg", NULL); - break; - case SRTP_STATE_UNLOCKED: - DEBUG("Secure is off calltree %d", c->_state); - if(g_strcasecmp(srtp_enabled,"true") == 0) { - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); - } - break; - default: - WARN("Update calltree srtp state #%d- Should not happen!", c->_srtp_state); - if(g_strcasecmp(srtp_enabled,"true") == 0) { - pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); - } + if((c->_sas != NULL) && (display_sas == TRUE) && (c->_srtp_state == SRTP_STATE_SAS_UNCONFIRMED) && (c->_zrtp_confirmed == FALSE)) { - } - gtk_tree_store_set(store, &iter, - 0, pixbuf, // Icon - 1, description, // Description - 2, pixbuf_security, - 3, c, - -1); + calltree_display_call_info(c, DISPLAY_TYPE_SAS, NULL, &description); + + } else { - if (pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); + calltree_display_call_info(c, DISPLAY_TYPE_STATE_CODE, audio_codec, &description); + + } + } - } + /* Update icons */ + if( tab == current_calls ) { + DEBUG("Receiving in state %d", c->_state); + switch(c->_state) { + case CALL_STATE_HOLD: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL); + break; + case CALL_STATE_INCOMING: + case CALL_STATE_RINGING: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL); + break; + case CALL_STATE_CURRENT: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/current.svg", NULL); + break; + case CALL_STATE_DIALING: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/dial.svg", NULL); + break; + case CALL_STATE_FAILURE: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/fail.svg", NULL); + break; + case CALL_STATE_BUSY: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/busy.svg", NULL); + break; + case CALL_STATE_TRANSFERT: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/transfert.svg", NULL); + break; + case CALL_STATE_RECORD: + pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/icon_rec.svg", NULL); + break; + default: + WARN("Update calltree - Should not happen!"); + } + + switch(c->_srtp_state) { + case SRTP_STATE_SAS_UNCONFIRMED: + DEBUG("Secure is ON"); + pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_unconfirmed.svg", NULL); + if(c->_sas != NULL) { DEBUG("SAS is ready with value %s", c->_sas); } + break; + case SRTP_STATE_SAS_CONFIRMED: + DEBUG("SAS is confirmed"); + pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_confirmed.svg", NULL); + break; + case SRTP_STATE_SAS_SIGNED: + DEBUG("Secure is ON with SAS signed and verified"); + pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_certified.svg", NULL); + break; + case SRTP_STATE_UNLOCKED: + DEBUG("Secure is off calltree %d", c->_state); + if(g_strcasecmp(srtp_enabled,"true") == 0) { + pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); + } + break; + default: + WARN("Update calltree srtp state #%d- Should not happen!", c->_srtp_state); + if(g_strcasecmp(srtp_enabled,"true") == 0) { + pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_off.svg", NULL); } + } + gtk_tree_store_set(store, &iter, + 0, pixbuf, // Icon + 1, description, // Description + 2, pixbuf_security, + 3, c, + -1); + + if (pixbuf != NULL) + g_object_unref(G_OBJECT(pixbuf)); + } - update_actions(); + } + + } + update_actions(); } @@ -754,36 +879,7 @@ void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) gchar * date=""; gchar *duration=""; - if(c->_state_code == 0) { - - if(g_strcmp0("", c->_peer_name) == 0) { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", - c->_peer_name, - c->_peer_number); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", - c->_peer_name, - c->_peer_number); - } - - } - else { - if(g_strcmp0("", c->_peer_name) == 0) { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>", - c->_peer_number, - c->_peer_name, - c->_state_code_description, - c->_state_code); - } - else { - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>", - c->_peer_name, - c->_peer_number, - c->_state_code_description, - c->_state_code); - } - } + calltree_display_call_info(c, DISPLAY_TYPE_CALL, NULL, &description); gtk_tree_store_prepend (tab->store, &iter, parent); @@ -890,18 +986,7 @@ void calltree_add_history_entry (callable_obj_t * c) // New call in the list gchar * description, *date="", *duration=""; - if(g_strcmp0("", c->_peer_name) == 0) { - - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", - c->_peer_number, - c->_peer_name); - } - else { - - description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", - c->_peer_name, - c->_peer_number); - } + calltree_display_call_info(c, DISPLAY_TYPE_HISTORY, NULL, &description); gtk_tree_store_prepend (history->store, &iter, NULL); diff --git a/sflphone-client-gnome/src/contacts/calltree.h b/sflphone-client-gnome/src/contacts/calltree.h index a01565bc4b29f245bf94c745d5780f9bfd4647ce..fd6c33f455f321656d0f1e4e388b916274ef139c 100644 --- a/sflphone-client-gnome/src/contacts/calltree.h +++ b/sflphone-client-gnome/src/contacts/calltree.h @@ -34,12 +34,23 @@ * @brief The GtkTreeView that list calls in the main window. */ -enum -{ +enum { A_CALL, A_CONFERENCE }; + +/** + * Tags used to identify display type in calltree + */ +typedef enum { + DISPLAY_TYPE_CALL, + DISPLAY_TYPE_CALL_TRANSFER, + DISPLAY_TYPE_SAS, + DISPLAY_TYPE_STATE_CODE, + DISPLAY_TYPE_HISTORY +} CallDisplayType; + /** * Create a new widget calltree * @return GtkWidget* A new widget