From 19bd9a2bac755ed68b4a9adf4b9cde5554879042 Mon Sep 17 00:00:00 2001
From: smorlat <smorlat@3f6dc0c8-ddfe-455d-9043-3cd528dc4637>
Date: Thu, 22 Oct 2009 14:52:25 +0000
Subject: [PATCH] fetch and display of buddy icons works.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@728 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
---
 linphone/coreapi/linphonecore.c | 10 +++++-----
 linphone/coreapi/linphonecore.h |  2 ++
 linphone/gtk-glade/friendlist.c |  6 ++++++
 linphone/gtk-glade/linphone.h   |  1 +
 linphone/gtk-glade/main.c       |  3 ++-
 5 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/linphone/coreapi/linphonecore.c b/linphone/coreapi/linphonecore.c
index 239fdd19f7..c5a07d1b4d 100644
--- a/linphone/coreapi/linphonecore.c
+++ b/linphone/coreapi/linphonecore.c
@@ -1040,7 +1040,9 @@ static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){
 	LinphoneFriend *lf=linphone_core_get_friend_by_uri(lc,info->sip_uri);
 	if (lf!=NULL){
 		lf->info=info;
-		ms_message("%s has a BuddyInfo assigned.",info->sip_uri);
+		ms_message("%s has a BuddyInfo assigned with image %p",info->sip_uri, info->image_data);
+		if (lc->vtable.buddy_info_updated)
+			lc->vtable.buddy_info_updated(lc,lf);
 	}else{
 		ms_warning("Could not any friend with uri %s",info->sip_uri);
 	}
@@ -1076,16 +1078,14 @@ static void linphone_core_grab_buddy_infos(LinphoneCore *lc, LinphoneProxyConfig
 		if (lf->info==NULL){
 			char *url=linphone_friend_get_url(lf);
 			if (linphone_core_lookup_known_proxy(lc,url)==cfg){
-				char *name=linphone_friend_get_name(lf);
-				if (name!=NULL && strlen(name)>0){
+				if (lf->url->url->username!=NULL && lf->url->url->username[0]!='0'){
 					BuddyLookupRequest *req;
 					req=sip_setup_context_create_buddy_lookup_request(ctx);
-					buddy_lookup_request_set_key(req,name);
+					buddy_lookup_request_set_key(req,lf->url->url->username);
 					buddy_lookup_request_set_max_results(req,1);
 					sip_setup_context_buddy_lookup_submit(ctx,req);
 					lc->bl_reqs=ms_list_append(lc->bl_reqs,req);
 				}
-				ms_free(name);
 			}
 			ms_free(url);
 		}
diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h
index 5485cbd262..9a14f7d76b 100644
--- a/linphone/coreapi/linphonecore.h
+++ b/linphone/coreapi/linphonecore.h
@@ -403,6 +403,7 @@ typedef void (*TextMessageReceived)(struct _LinphoneCore *lc, LinphoneChatRoom *
 typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralState *gstate);
 typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf);
 typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
+typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
 
 typedef struct _LinphoneVTable
 {
@@ -426,6 +427,7 @@ typedef struct _LinphoneVTable
 	GeneralStateChange general_state;
 	DtmfReceived dtmf_received;
 	ReferReceived refer_received;
+	BuddyInfoUpdated buddy_info_updated;
 } LinphoneCoreVTable;
 
 typedef struct _LCCallbackObj
diff --git a/linphone/gtk-glade/friendlist.c b/linphone/gtk-glade/friendlist.c
index 59f05e58b5..ea2ada2586 100644
--- a/linphone/gtk-glade/friendlist.c
+++ b/linphone/gtk-glade/friendlist.c
@@ -571,3 +571,9 @@ gboolean linphone_gtk_contact_list_button_pressed(GtkWidget *widget, GdkEventBut
 	return FALSE;
 }
 
+void linphone_gtk_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf){
+	/*refresh the entire list*/
+	linphone_gtk_show_friends();
+}
+
+
diff --git a/linphone/gtk-glade/linphone.h b/linphone/gtk-glade/linphone.h
index d1ba99459a..5d497b4178 100644
--- a/linphone/gtk-glade/linphone.h
+++ b/linphone/gtk-glade/linphone.h
@@ -66,6 +66,7 @@ void linphone_gtk_log_show(void);
 void linphone_gtk_log_push(OrtpLogLevel lev, const char *fmt, va_list args);
 void linphone_gtk_destroy_log_window(void);
 gboolean linphone_gtk_check_logs();
+void linphone_gtk_buddy_info_updated(LinphoneCore *lc, LinphoneFriend *lf);
 const gchar *linphone_gtk_get_ui_config(const char *key, const char *def);
 int linphone_gtk_get_ui_config_int(const char *key, int def);
 void linphone_gtk_set_ui_config_int(const char *key , int val);
diff --git a/linphone/gtk-glade/main.c b/linphone/gtk-glade/main.c
index 8c115e09d6..20c4253114 100644
--- a/linphone/gtk-glade/main.c
+++ b/linphone/gtk-glade/main.c
@@ -70,7 +70,8 @@ static LinphoneCoreVTable vtable={
 	.call_log_updated=linphone_gtk_call_log_updated,
 	.text_received=linphone_gtk_text_received,
 	.general_state=linphone_gtk_general_state,
-	.refer_received=linphone_gtk_refer_received
+	.refer_received=linphone_gtk_refer_received,
+	.buddy_info_updated=linphone_gtk_buddy_info_updated
 };
 
 static gboolean verbose=0;
-- 
GitLab