diff --git a/linphone/coreapi/siplogin.c b/linphone/coreapi/siplogin.c index 54f62ed5d..8c0dccddc 100644 --- a/linphone/coreapi/siplogin.c +++ b/linphone/coreapi/siplogin.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #include "linphonecore.h" - +#include static void sip_login_init_instance(SipSetupContext *ctx){ LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx); @@ -30,14 +30,47 @@ static void sip_login_init_instance(SipSetupContext *ctx){ linphone_proxy_config_enable_register(cfg,FALSE); } +static void guess_display_name(osip_from_t *from){ + char *dn=(char*)osip_malloc(strlen(from->url->username)+3); + char *it=from->url->username; + char *wptr=dn; + bool_t begin=TRUE; + bool_t surname=0; + for(it=from->url->username;*it!='\0';++it){ + if (begin) + *wptr=toupper(*it); + else if (*it=='.'){ + if (surname) break; + *wptr=' '; + begin=TRUE; + surname=TRUE; + }else *wptr=*it; + wptr++; + } + if (from->displayname!=NULL) osip_free(from->displayname); + from->displayname=dn; +} + static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char *passwd){ LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx); LinphoneCore *lc=linphone_proxy_config_get_core(cfg); - LinphoneAuthInfo *auth=linphone_auth_info_new(ctx->username,NULL,passwd,NULL,NULL); - linphone_proxy_config_set_identity(cfg,uri); + LinphoneAuthInfo *auth; + osip_from_t *parsed_uri; + char *tmp; + + osip_from_init(&parsed_uri); + osip_from_parse(parsed_uri,uri); + if (parsed_uri->displayname==NULL || strlen(parsed_uri->displayname)==0){ + guess_display_name(parsed_uri); + } + osip_from_to_str(parsed_uri,&tmp); + linphone_proxy_config_set_identity(cfg,tmp); + auth=linphone_auth_info_new(parsed_uri->url->username,NULL,passwd,NULL,NULL); linphone_core_add_auth_info(lc,auth); linphone_proxy_config_enable_register(cfg,TRUE); linphone_proxy_config_done(cfg); + osip_free(tmp); + osip_from_free(parsed_uri); ms_message("SipLogin: done"); return 0; } diff --git a/linphone/gtk-glade/incall_view.c b/linphone/gtk-glade/incall_view.c index 7c98ca24a..879b5dcd5 100644 --- a/linphone/gtk-glade/incall_view.c +++ b/linphone/gtk-glade/incall_view.c @@ -28,6 +28,34 @@ void linphone_gtk_show_idle_view(void){ gtk_widget_hide(in_call_frame); } +void display_peer_name_in_label(GtkWidget *label, const char *uri){ + osip_from_t *from; + char *displayname=NULL,*id=NULL; + char *uri_label; + + osip_from_init(&from); + if (osip_from_parse(from,uri)==0){ + + if (from->displayname!=NULL && strlen(from->displayname)>0) + displayname=osip_strdup(from->displayname); + if (from->displayname!=NULL){ + osip_free(from->displayname); + from->displayname=NULL; + } + osip_from_to_str(from,&id); + }else id=osip_strdup(uri); + osip_from_free(from); + if (displayname!=NULL) + uri_label=g_markup_printf_escaped("%s\n%s", + displayname,id); + else + uri_label=g_markup_printf_escaped("%s\n",id); + gtk_label_set_markup(GTK_LABEL(label),uri_label); + if (displayname!=NULL) osip_free(displayname); + osip_free(id); + g_free(uri_label); +} + void linphone_gtk_in_call_view_set_calling(const char *uri){ GtkWidget *main_window=linphone_gtk_get_main_window(); GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status"); @@ -36,13 +64,11 @@ void linphone_gtk_in_call_view_set_calling(const char *uri){ GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation"); GdkPixbufAnimation *pbuf=create_pixbuf_animation("calling_anim.gif"); GtkWidget *terminate_button=linphone_gtk_get_widget(main_window,"in_call_terminate"); - char *uri_label; gtk_widget_set_sensitive(terminate_button,TRUE); gtk_label_set_markup(GTK_LABEL(status),_("Calling...")); - uri_label=g_markup_printf_escaped("%s", uri); - gtk_label_set_markup(GTK_LABEL(callee),uri_label); - g_free(uri_label); + display_peer_name_in_label(callee,uri); + gtk_label_set_text(GTK_LABEL(duration),"00:00:00"); if (pbuf!=NULL){ gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf); @@ -56,35 +82,16 @@ void linphone_gtk_in_call_view_set_in_call(){ GtkWidget *status=linphone_gtk_get_widget(main_window,"in_call_status"); GtkWidget *callee=linphone_gtk_get_widget(main_window,"in_call_uri"); GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration"); - char *uri_label; GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation"); GdkPixbufAnimation *pbuf=create_pixbuf_animation("incall_anim.gif"); GtkWidget *terminate_button=linphone_gtk_get_widget(main_window,"in_call_terminate"); const char *uri=linphone_core_get_remote_uri(lc); - osip_from_t *from; - char *displayname=NULL,*id=NULL; + + display_peer_name_in_label(callee,uri); gtk_widget_set_sensitive(terminate_button,TRUE); gtk_label_set_markup(GTK_LABEL(status),_("In call with")); - osip_from_init(&from); - osip_from_parse(from,uri); - - if (from->displayname!=NULL && strlen(from->displayname)>0) - displayname=osip_strdup(from->displayname); - if (from->displayname!=NULL){ - osip_free(from->displayname); - from->displayname=NULL; - } - osip_from_to_str(from,&id); - osip_from_free(from); - if (displayname!=NULL) - uri_label=g_markup_printf_escaped("%s\n%s", - displayname,id); - else - uri_label=g_markup_printf_escaped("%s\n",id); - gtk_label_set_markup(GTK_LABEL(callee),uri_label); - g_free(uri_label); gtk_label_set_text(GTK_LABEL(duration),_("00::00::00")); if (pbuf!=NULL){ gtk_image_set_from_animation(GTK_IMAGE(animation),pbuf); diff --git a/linphone/po/it.po b/linphone/po/it.po index b268d1321..37c7eb078 100644 --- a/linphone/po/it.po +++ b/linphone/po/it.po @@ -625,7 +625,7 @@ msgstr "Prego inserire la password di dominio" #: ../gtk-glade/call_logs.glade.h:1 msgid "Call history" -msgstr "Storico chiamate" +msgstr "Cronologia" #: ../gtk-glade/sip_account.glade.h:1 msgid "Configure a SIP account" @@ -1044,7 +1044,7 @@ msgstr "Connessione" #: ../coreapi/linphonecore.c:1793 msgid "Call ended" -msgstr "Chimata terminata" +msgstr "Chiamata terminata" #: ../coreapi/linphonecore.c:2155 msgid "No nat/firewall address supplied !"