/pidgin/main: 237ad851330e: imgstore: unref bonjour

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 10 19:11:16 EDT 2014


Changeset: 237ad851330e3222a7fa4e26e50af65f472eb2eb
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-11 01:11 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/237ad851330e

Description:

imgstore: unref bonjour

diffstat:

 libpurple/protocols/bonjour/bonjour.h     |   1 -
 libpurple/protocols/bonjour/mdns_common.c |  20 ++++++--------------
 2 files changed, 6 insertions(+), 15 deletions(-)

diffs (56 lines):

diff --git a/libpurple/protocols/bonjour/bonjour.h b/libpurple/protocols/bonjour/bonjour.h
--- a/libpurple/protocols/bonjour/bonjour.h
+++ b/libpurple/protocols/bonjour/bonjour.h
@@ -29,7 +29,6 @@
 #include "mdns_common.h"
 #include "internal.h"
 #include "jabber.h"
-#include "imgstore.h" /* TODO: temp */
 
 #define BONJOUR_GROUP_NAME _("Bonjour")
 #define BONJOUR_PROTOCOL_NAME "bonjour"
diff --git a/libpurple/protocols/bonjour/mdns_common.c b/libpurple/protocols/bonjour/mdns_common.c
--- a/libpurple/protocols/bonjour/mdns_common.c
+++ b/libpurple/protocols/bonjour/mdns_common.c
@@ -179,35 +179,27 @@ void bonjour_dns_sd_retrieve_buddy_icon(
 }
 
 void bonjour_dns_sd_update_buddy_icon(BonjourDnsSd *data) {
-	PurpleStoredImage *img;
+	PurpleImage *img;
 
 	if ((img = purple_buddy_icons_find_account_icon(data->account))) {
 		gconstpointer avatar_data;
 		gsize avatar_len;
 
-		avatar_data = purple_imgstore_get_data(img);
-		avatar_len = purple_imgstore_get_size(img);
+		avatar_data = purple_image_get_data(img);
+		avatar_len = purple_image_get_size(img);
 
 		if (_mdns_set_buddy_icon_data(data, avatar_data, avatar_len)) {
-			/* The filename is a SHA-1 hash of the data (conveniently what we need) */
-			const char *p, *filename = purple_imgstore_get_filename(img);
-
 			g_free(data->phsh);
 			data->phsh = NULL;
 
-			/* Get rid of the extension */
-			p = strchr(filename, '.');
-			if (p)
-				data->phsh = g_strndup(filename, p - filename);
-			else
-				purple_debug_error("bonjour", "account buddy icon returned unexpected filename (%s)"
-								"; unable to extract hash. Clearing buddy icon\n", filename);
+			data->phsh = g_compute_checksum_for_data(
+				G_CHECKSUM_SHA1, avatar_data, avatar_len);
 
 			/* Update our TXT record */
 			publish_presence(data, PUBLISH_UPDATE);
 		}
 
-		purple_imgstore_unref(img);
+		g_object_unref(img);
 	} else {
 		/* We need to do this regardless of whether data->phsh is set so that we
 		 * cancel any icons that are currently in the process of being set */



More information about the Commits mailing list