empathy r538 - trunk/libempathy



Author: xclaesse
Date: Fri Jan 11 16:38:15 2008
New Revision: 538
URL: http://svn.gnome.org/viewvc/empathy?rev=538&view=rev

Log:
Add avatar token in logs and load avatar from cache when getting logs messages


Modified:
   trunk/libempathy/empathy-log-manager.c

Modified: trunk/libempathy/empathy-log-manager.c
==============================================================================
--- trunk/libempathy/empathy-log-manager.c	(original)
+++ trunk/libempathy/empathy-log-manager.c	Fri Jan 11 16:38:15 2008
@@ -138,6 +138,8 @@
 	EmpathyContact *sender;
 	const gchar   *body_str;
 	const gchar   *str;
+	EmpathyAvatar *avatar;
+	gchar         *avatar_token = NULL;
 	gchar         *filename;
 	gchar         *basedir;
 	gchar         *body;
@@ -193,11 +195,17 @@
 	str = empathy_contact_get_id (sender);
 	contact_id = g_markup_escape_text (str, -1);
 
+	avatar = empathy_contact_get_avatar (sender);
+	if (avatar) {
+		avatar_token = g_markup_escape_text (avatar->token, -1);		
+	}
+
 	g_fprintf (file,
-		   "<message time='%s' id='%s' name='%s' isuser='%s' type='%s'>%s</message>\n" LOG_FOOTER,
+		   "<message time='%s' id='%s' name='%s' token='%s' isuser='%s' type='%s'>%s</message>\n" LOG_FOOTER,
 		   timestamp,
 		   contact_id,
 		   contact_name,
+		   avatar_token ? avatar_token : "",
 		   empathy_contact_is_user (sender) ? "true" : "false",
 		   empathy_message_type_to_str (msg_type),
 		   body);
@@ -208,6 +216,7 @@
 	g_free (contact_name);
 	g_free (timestamp);
 	g_free (body);
+	g_free (avatar_token);
 }
 
 gboolean
@@ -329,10 +338,12 @@
 	for (node = log_node->children; node; node = node->next) {
 		EmpathyMessage     *message;
 		EmpathyContact     *sender;
+		EmpathyAvatar      *avatar = NULL;
 		gchar              *time;
 		time_t              t;
 		gchar              *sender_id;
 		gchar              *sender_name;
+		gchar              *sender_avatar_token;
 		gchar              *body;
 		gchar              *is_user_str;
 		gboolean            is_user = FALSE;
@@ -347,9 +358,13 @@
 		time = xmlGetProp (node, "time");
 		sender_id = xmlGetProp (node, "id");
 		sender_name = xmlGetProp (node, "name");
+		sender_avatar_token = xmlGetProp (node, "token");
 		is_user_str = xmlGetProp (node, "isuser");
 		msg_type_str = xmlGetProp (node, "type");
 
+		if (sender_avatar_token) {
+			avatar = empathy_avatar_new_from_cache (sender_avatar_token);
+		}
 		if (is_user_str) {
 			is_user = strcmp (is_user_str, "true") == 0;
 		}
@@ -361,6 +376,11 @@
 
 		sender = empathy_contact_new_full (account, sender_id, sender_name);
 		empathy_contact_set_is_user (sender, is_user);
+		if (avatar) {
+			empathy_contact_set_avatar (sender, avatar);
+			empathy_avatar_unref (avatar);
+		}
+
 		message = empathy_message_new (body);
 		empathy_message_set_sender (message, sender);
 		empathy_message_set_timestamp (message, t);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]