Skip to content
Snippets Groups Projects
Commit b651713c authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2474] Strip the caller hostname when displaying phone numbers

parent 0c0ecfd1
No related branches found
No related tags found
No related merge requests found
...@@ -339,14 +339,38 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS ...@@ -339,14 +339,38 @@ button_pressed(GtkWidget* widget, GdkEventButton *event, gpointer user_data UNUS
gchar* gchar*
calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gchar** display_info) calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gchar *audio_codec, gchar** display_info)
{ {
gchar * description; gchar * description;
gchar * tmp_info; gchar * tmp_info;
DEBUG("----------------- calltree_display_call_info -----------------\n"); 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) { switch(display_type) {
case DISPLAY_TYPE_CALL: case DISPLAY_TYPE_CALL:
...@@ -356,20 +380,20 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch ...@@ -356,20 +380,20 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch
if(g_strcmp0("", c->_peer_name) == 0) { if(g_strcmp0("", c->_peer_name) == 0) {
description = g_markup_printf_escaped("<b>%s</b><i>%s</i>", description = g_markup_printf_escaped("<b>%s</b><i>%s</i>",
c->_peer_name, display_number,
c->_peer_number); c->_peer_name);
} }
else { else {
description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>", description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>",
c->_peer_name, c->_peer_name,
c->_peer_number); display_number);
} }
} }
else { else {
if(g_strcmp0("", c->_peer_name) == 0) { if(g_strcmp0("", c->_peer_name) == 0) {
description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s (%d)</i>", description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>%s (%d)</i>",
c->_peer_number, display_number,
c->_peer_name, c->_peer_name,
c->_state_code_description, c->_state_code_description,
c->_state_code); c->_state_code);
...@@ -377,7 +401,7 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch ...@@ -377,7 +401,7 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch
else { else {
description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>", description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>%s (%d)</i>",
c->_peer_name, c->_peer_name,
c->_peer_number, display_number,
c->_state_code_description, c->_state_code_description,
c->_state_code); c->_state_code);
} }
...@@ -392,21 +416,94 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch ...@@ -392,21 +416,94 @@ calltree_display_call_info(callable_obj_t * c, CallDisplayType display_type, gch
if(g_strcmp0("",c->_peer_name) == 0){ if(g_strcmp0("",c->_peer_name) == 0){
description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Transfert to:%s</i> ", description = g_markup_printf_escaped("<b>%s</b><i>%s</i>\n<i>Transfert to:%s</i> ",
c->_peer_number, display_number,
c->_peer_name, c->_peer_name,
c->_trsft_to); c->_trsft_to);
} }
else { else {
description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ", description = g_markup_printf_escaped("<b>%s</b> <i>%s</i>\n<i>Transfert to:%s</i> ",
c->_peer_name, c->_peer_name,
c->_peer_number, display_number,
c->_trsft_to); c->_trsft_to);
} }
DEBUG("Transfer string: %s", description);
break; 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 : default :
DEBUG("Not an allowable type of display"); DEBUG("Not an allowable type of display");
break; break;
...@@ -637,14 +734,11 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) ...@@ -637,14 +734,11 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
} }
} }
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); calltree_update_call (tab, c, &iter);
} }
...@@ -665,85 +759,28 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) ...@@ -665,85 +759,28 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
gchar * duration=""; gchar * duration="";
audio_codec = call_get_audio_codec (c); audio_codec = call_get_audio_codec (c);
if(c->_state == CALL_STATE_TRANSFERT) if(c->_state == CALL_STATE_TRANSFERT) {
{
calltree_display_call_info(c, DISPLAY_TYPE_CALL_TRANSFER, NULL, &description);
calltree_display_call_info(c, DISPLAY_TYPE_CALL_TRANSFER, &description);
DEBUG("second try: %s", description);
/*
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 { 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((c->_sas != NULL) && (display_sas == TRUE) && (c->_srtp_state == SRTP_STATE_SAS_UNCONFIRMED) && (c->_zrtp_confirmed == FALSE)) {
if(g_strcmp0("",c->_peer_name) == 0){ calltree_display_call_info(c, DISPLAY_TYPE_SAS, NULL, &description);
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 { } else {
DEBUG("Updating state code %d %s", c->_state_code, c->_state_code_description);
if(g_strcmp0("",c->_peer_name) == 0){ calltree_display_call_info(c, DISPLAY_TYPE_STATE_CODE, audio_codec, &description);
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 icons */ /* Update icons */
if( tab == current_calls ) if( tab == current_calls ) {
{
DEBUG("Receiving in state %d", c->_state); DEBUG("Receiving in state %d", c->_state);
switch(c->_state) switch(c->_state) {
{
case CALL_STATE_HOLD: case CALL_STATE_HOLD:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL); pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL);
break; break;
...@@ -773,8 +810,7 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) ...@@ -773,8 +810,7 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
WARN("Update calltree - Should not happen!"); WARN("Update calltree - Should not happen!");
} }
switch(c->_srtp_state) switch(c->_srtp_state) {
{
case SRTP_STATE_SAS_UNCONFIRMED: case SRTP_STATE_SAS_UNCONFIRMED:
DEBUG("Secure is ON"); DEBUG("Secure is ON");
pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_unconfirmed.svg", NULL); pixbuf_security = gdk_pixbuf_new_from_file(ICONS_DIR "/lock_unconfirmed.svg", NULL);
...@@ -843,40 +879,7 @@ void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) ...@@ -843,40 +879,7 @@ void calltree_add_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent)
gchar * date=""; gchar * date="";
gchar *duration=""; gchar *duration="";
/* calltree_display_call_info(c, DISPLAY_TYPE_CALL, NULL, &description);
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, &description);
gtk_tree_store_prepend (tab->store, &iter, parent); gtk_tree_store_prepend (tab->store, &iter, parent);
...@@ -983,18 +986,7 @@ void calltree_add_history_entry (callable_obj_t * c) ...@@ -983,18 +986,7 @@ void calltree_add_history_entry (callable_obj_t * c)
// New call in the list // New call in the list
gchar * description, *date="", *duration=""; gchar * description, *date="", *duration="";
if(g_strcmp0("", c->_peer_name) == 0) { calltree_display_call_info(c, DISPLAY_TYPE_HISTORY, NULL, &description);
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);
}
gtk_tree_store_prepend (history->store, &iter, NULL); gtk_tree_store_prepend (history->store, &iter, NULL);
......
...@@ -47,7 +47,8 @@ typedef enum { ...@@ -47,7 +47,8 @@ typedef enum {
DISPLAY_TYPE_CALL, DISPLAY_TYPE_CALL,
DISPLAY_TYPE_CALL_TRANSFER, DISPLAY_TYPE_CALL_TRANSFER,
DISPLAY_TYPE_SAS, DISPLAY_TYPE_SAS,
DISPLAY_TYPE_STATE_CODE DISPLAY_TYPE_STATE_CODE,
DISPLAY_TYPE_HISTORY
} CallDisplayType; } CallDisplayType;
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment