Send metadata request on missing avatar
authorMyhailo Danylenko <isbear@ukrpost.net>
Wed, 11 Nov 2009 16:57:58 +0200
changeset 9 a838a4ecf834
parent 8 e7dcbcbb8dbc
child 10 f9ab0b7f462a
Send metadata request on missing avatar
TODO
avatar.c
help/en/hlp_avatar.txt
--- a/TODO	Wed Nov 11 15:21:36 2009 +0200
+++ b/TODO	Wed Nov 11 16:57:58 2009 +0200
@@ -1,5 +1,4 @@
 
-Send metadata request instead of data request?
 Add avatar_aa_options?
 Handle url avatars? (needs common image loading library (sdl-image? imlib?) and web-retrieving library (curl?))
 Report no-avatar
--- a/avatar.c	Wed Nov 11 15:21:36 2009 +0200
+++ b/avatar.c	Wed Nov 11 16:57:58 2009 +0200
@@ -561,10 +561,9 @@
 		struct stat buf;
 
 		if (stat (file, &buf) == -1) {
-			gchar            *bjid = jidtodisp (jid);
-			LmMessage        *request;
-			LmMessageNode    *node;
-			LmMessageHandler *dhandler;
+			gchar         *bjid    = jidtodisp (jid);
+			LmMessage     *request;
+			LmMessageNode *node;
 
 			scr_WriteIncomingMessage (bjid, "No avatar for this buddy yet, sending request.", 0, HBB_PREFIX_INFO|HBB_PREFIX_NOFLAG, 0); // NO conversion from utf-8
 
@@ -577,20 +576,13 @@
 			lm_message_node_set_attribute (node, "xmlns", NS_PUBSUB);
 
 			node = lm_message_node_add_child (node, "items", NULL);
-			lm_message_node_set_attribute (node, "node", NS_AVATAR_DATA);
-
-			node = lm_message_node_add_child (node, "item", NULL);
+			lm_message_node_set_attribute (node, "node", NS_AVATAR_METADATA);
 
-			// create handler
-			dhandler = lm_message_handler_new (avatar_retrieve_data_reply_handler, bjid, g_free);
-			reply_handlers = g_slist_append (reply_handlers, dhandler);
+			// send, result will be handled by pep
+			lm_connection_send (lconnection, request, NULL);
 
-			// send
-			lm_connection_send_with_reply (lconnection, request, dhandler, NULL);
-
-			lm_message_handler_unref (dhandler);
 			lm_message_unref (request);
-			// bjid will be freed on handler destruction
+			g_free (bjid);
 			return TRUE;
 		}
 	}
--- a/help/en/hlp_avatar.txt	Wed Nov 11 15:21:36 2009 +0200
+++ b/help/en/hlp_avatar.txt	Wed Nov 11 16:57:58 2009 +0200
@@ -1,6 +1,6 @@
 
  /AVATAR [filename.png|-]
 
-Publishes filename as your avatar via pep. Specify - to remove avatar. Without argument shows current byddy's avatar.
+Publishes filename as your avatar via pep. Specify - to remove avatar. Without argument shows current byddy's avatar (or requests information from buddy).
 Note: standard states, that avatar MUST be of type image/png, thus, no support for anything alse.
 Note: url avatars are not supported yet.