From aed0de97ee0d5deb6d5caacce6a4af6d689b6f36 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 22 Oct 2015 13:39:49 +0200 Subject: [PATCH] Propose to add contact to friend list in call history only if this contact is not already in the friend list. --- gtk/calllogs.c | 4 +++- gtk/friendlist.c | 20 ++++---------------- gtk/linphone.h | 3 ++- gtk/utils.c | 11 +++++++++++ 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gtk/calllogs.c b/gtk/calllogs.c index efa6f1884..8c0004a81 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -177,7 +177,9 @@ static GtkWidget *linphone_gtk_create_call_log_menu(GtkWidget *call_log){ name=linphone_address_as_string(la); call_label=g_strdup_printf(_("Call %s"),name); text_label=g_strdup_printf(_("Send text to %s"),name); - add_contact_label=g_strdup_printf(_("Add %s to your contact list"),name); + if (!linphone_gtk_is_friend(linphone_gtk_get_core(), name)) { + add_contact_label=g_strdup_printf(_("Add %s to your contact list"),name); + } ms_free(name); menu=gtk_menu_new(); } diff --git a/gtk/friendlist.c b/gtk/friendlist.c index 2286f3bfe..8b4a0dd3c 100644 --- a/gtk/friendlist.c +++ b/gtk/friendlist.c @@ -464,22 +464,10 @@ static void update_star(GtkEntry *entry, gboolean is_known){ static void check_contact(GtkEditable *editable, LinphoneCore *lc){ bool_t known = TRUE; - char *tmp=gtk_editable_get_chars(editable,0,-1); - if (tmp!=NULL){ - if (strlen(tmp)>0){ - LinphoneAddress *addr=linphone_core_interpret_url(lc,tmp); - if (addr){ - char *uri=linphone_address_as_string_uri_only(addr); - LinphoneFriend *lf=linphone_core_get_friend_by_address(lc,uri); - ms_free(uri); - linphone_address_destroy(addr); - if (lf) { - update_star(GTK_ENTRY(editable),TRUE); - g_free(tmp); - return; - } - } - known = FALSE; + char *tmp = gtk_editable_get_chars(editable, 0, -1); + if (tmp != NULL) { + if (strlen(tmp) > 0) { + known = linphone_gtk_is_friend(lc, tmp); } g_free(tmp); } diff --git a/gtk/linphone.h b/gtk/linphone.h index 0d5e76c4b..7f8c0cc27 100644 --- a/gtk/linphone.h +++ b/gtk/linphone.h @@ -344,4 +344,5 @@ LINPHONE_PUBLIC void linphone_gtk_proxy_transport_changed(GtkWidget *combo); LINPHONE_PUBLIC void linphone_gtk_tunnel_ok(GtkButton *button); LINPHONE_PUBLIC void linphone_gtk_notebook_current_page_changed(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data); LINPHONE_PUBLIC void linphone_gtk_reload_sound_devices(void); -LINPHONE_PUBLIC void linphone_gtk_reload_video_devices(void); \ No newline at end of file +LINPHONE_PUBLIC void linphone_gtk_reload_video_devices(void); +LINPHONE_PUBLIC bool_t linphone_gtk_is_friend(LinphoneCore *lc, const char *contact); diff --git a/gtk/utils.c b/gtk/utils.c index fc3ebde92..c4c7b428c 100644 --- a/gtk/utils.c +++ b/gtk/utils.c @@ -112,6 +112,17 @@ void linphone_gtk_reload_video_devices(void){ if (pb) linphone_gtk_fill_webcams(pb); } +bool_t linphone_gtk_is_friend(LinphoneCore *lc, const char *contact) { + LinphoneAddress *addr = linphone_core_interpret_url(lc, contact); + if (addr) { + char *uri = linphone_address_as_string_uri_only(addr); + LinphoneFriend *lf = linphone_core_get_friend_by_address(lc, uri); + linphone_address_destroy(addr); + if (lf) return TRUE; + } + return FALSE; +} + #ifdef HAVE_LIBUDEV_H static struct udev *udevroot=NULL;