Commit bda56cf2 authored by Simon Morlat's avatar Simon Morlat
Browse files

change policy regarding quotes in displaynames

parent bc153b80
......@@ -57,14 +57,6 @@ const char *linphone_address_get_display_name(const LinphoneAddress* u){
return sal_address_get_display_name(u);
}
/**
* Returns the display name without quotes.
* @note WARNING: the returned string must be freed by user.
**/
char *linphone_address_get_display_name_unquoted(const LinphoneAddress *addr){
return sal_address_get_display_name_unquoted(addr);
}
/**
* Returns the username.
**/
......
......@@ -64,7 +64,6 @@ LinphoneAddress * linphone_address_new(const char *uri);
LinphoneAddress * linphone_address_clone(const LinphoneAddress *uri);
const char *linphone_address_get_scheme(const LinphoneAddress *u);
const char *linphone_address_get_display_name(const LinphoneAddress* u);
char *linphone_address_get_display_name_unquoted(const LinphoneAddress *u);
const char *linphone_address_get_username(const LinphoneAddress *u);
const char *linphone_address_get_domain(const LinphoneAddress *u);
void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name);
......
......@@ -1589,18 +1589,6 @@ int sal_unregister(SalOp *h){
return 0;
}
static void sal_address_quote_displayname(SalAddress *addr){
osip_from_t *u=(osip_from_t*)addr;
if (u->displayname!=NULL && u->displayname[0]!='\0'
&& u->displayname[0]!='"'){
int len=strlen(u->displayname)+1+2;
char *quoted=osip_malloc(len);
snprintf(quoted,len,"\"%s\"",u->displayname);
osip_free(u->displayname);
u->displayname=quoted;
}
}
SalAddress * sal_address_new(const char *uri){
osip_from_t *from;
osip_from_init(&from);
......@@ -1608,7 +1596,11 @@ SalAddress * sal_address_new(const char *uri){
osip_from_free(from);
return NULL;
}
sal_address_quote_displayname ((SalAddress*)from);
if (from->displayname!=NULL && from->displayname[0]!='"'){
char *unquoted=osip_strdup_without_quote(from->displayname);
osip_free(from->displayname);
from->displayname=unquoted;
}
return (SalAddress*)from;
}
......@@ -1630,18 +1622,6 @@ const char *sal_address_get_display_name(const SalAddress* addr){
return null_if_empty(u->displayname);
}
char *sal_address_get_display_name_unquoted(const SalAddress *addr){
const osip_from_t *u=(const osip_from_t*)addr;
const char *dn=null_if_empty(u->displayname);
char *ret=NULL;
if (dn!=NULL) {
char *tmp=osip_strdup_without_quote(dn);
ret=ms_strdup(tmp);
osip_free(tmp);
}
return ret;
}
const char *sal_address_get_username(const SalAddress *addr){
const osip_from_t *u=(const osip_from_t*)addr;
return null_if_empty(u->url->username);
......@@ -1660,7 +1640,6 @@ void sal_address_set_display_name(SalAddress *addr, const char *display_name){
}
if (display_name!=NULL && display_name[0]!='\0'){
u->displayname=osip_strdup(display_name);
sal_address_quote_displayname(addr);
}
}
......@@ -1712,7 +1691,19 @@ void sal_address_clean(SalAddress *addr){
char *sal_address_as_string(const SalAddress *u){
char *tmp,*ret;
osip_from_to_str((osip_from_t*)u,&tmp);
osip_from_t *from=(osip_from_t *)u;
char *old_displayname=NULL;
/* hack to force use of quotes around the displayname*/
if (from->displayname!=NULL
&& from->displayname[0]!='"'){
old_displayname=from->displayname;
from->displayname=osip_enquote(from->displayname);
}
osip_from_to_str(from,&tmp);
if (old_displayname!=NULL){
ms_free(from->displayname);
from->displayname=old_displayname;
}
ret=ms_strdup(tmp);
osip_free(tmp);
return ret;
......@@ -1729,6 +1720,7 @@ char *sal_address_as_string_uri_only(const SalAddress *u){
void sal_address_destroy(SalAddress *u){
osip_from_free((osip_from_t*)u);
}
void sal_set_keepalive_period(Sal *ctx,unsigned int value) {
eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value);
}
......
......@@ -308,7 +308,7 @@ void linphone_gtk_show_friends(void){
LinphoneFriend *lf=(LinphoneFriend*)itf->data;
const LinphoneAddress *f_uri=linphone_friend_get_address(lf);
char *uri=linphone_address_as_string(f_uri);
char *name=linphone_address_get_display_name_unquoted (f_uri);
const char *name=linphone_address_get_display_name(f_uri);
const char *display=name;
char *escaped=NULL;
if (lookup){
......@@ -341,7 +341,6 @@ void linphone_gtk_show_friends(void){
}
}
ms_free(uri);
if (name!=NULL) ms_free(name);
}
}
......@@ -373,17 +372,16 @@ void linphone_gtk_remove_contact(GtkWidget *button){
void linphone_gtk_show_contact(LinphoneFriend *lf){
GtkWidget *w=linphone_gtk_create_window("contact");
char *uri;
char *name;
const char *name;
const LinphoneAddress *f_uri=linphone_friend_get_address(lf);
uri=linphone_address_as_string_uri_only(f_uri);
name=linphone_address_get_display_name_unquoted (f_uri);
name=linphone_address_get_display_name(f_uri);
if (uri) {
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"sip_address")),uri);
ms_free(uri);
}
if (name){
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(w,"name")),name);
ms_free(name);
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(w,"show_presence")),
linphone_friend_get_send_subscribe(lf));
......
......@@ -72,7 +72,7 @@ void linphone_gtk_show_idle_view(void){
void display_peer_name_in_label(GtkWidget *label, const char *uri){
LinphoneAddress *from;
char *displayname=NULL;
const char *displayname=NULL;
char *id=NULL;
char *uri_label;
......@@ -83,14 +83,13 @@ void display_peer_name_in_label(GtkWidget *label, const char *uri){
from=linphone_address_new(uri);
if (from!=NULL){
displayname=linphone_address_get_display_name_unquoted (from);
displayname=linphone_address_get_display_name(from);
id=linphone_address_as_string_uri_only(from);
}else id=ms_strdup(uri);
if (displayname!=NULL){
uri_label=g_markup_printf_escaped("<span size=\"large\">%s</span>\n<i>%s</i>",
displayname,id);
ms_free(displayname);
}else
uri_label=g_markup_printf_escaped("<span size=\"large\"><i>%s</i></span>\n",id);
gtk_label_set_markup(GTK_LABEL(label),uri_label);
......
......@@ -395,7 +395,7 @@ static void set_video_window_decorations(GdkWindow *w){
linphone_address_clean(uri);
if (linphone_address_get_display_name(uri)!=NULL){
display_name=linphone_address_get_display_name_unquoted (uri);
display_name=ms_strdup(linphone_address_get_display_name(uri));
}else{
display_name=linphone_address_as_string(uri);
}
......
......@@ -803,9 +803,8 @@ void linphone_gtk_show_parameters(void){
contact=linphone_core_get_primary_contact_parsed(lc);
if (contact){
if (linphone_address_get_display_name(contact)) {
char *dn=linphone_address_get_display_name_unquoted (contact);
const char *dn=linphone_address_get_display_name(contact);
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(pb,"displayname")),dn);
ms_free(dn);
}
if (linphone_address_get_username(contact))
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(pb,"username")),linphone_address_get_username(contact));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment