pidgin.2.6.5: 64937fa3: *** Plucked rev 4be2df4f72bd8a55cdae7f25...

datallah at pidgin.im datallah at pidgin.im
Thu Jan 7 19:00:59 EST 2010


-----------------------------------------------------------------
Revision: 64937fa364b24dccc5006d84e81c9f3db5a31dd7
Ancestor: 3c54c32773c1f4469b35603025eb4516315aebf0
Author: datallah at pidgin.im
Date: 2010-01-07T23:38:42
Branch: im.pidgin.pidgin.2.6.5
URL: http://d.pidgin.im/viewmtn/revision/info/64937fa364b24dccc5006d84e81c9f3db5a31dd7

Modified files:
        libpurple/protocols/msn/slp.c

ChangeLog: 

*** Plucked rev 4be2df4f72bd8a55cdae7f2554b73342a497c92f (bcc0147bab874ca52c55ad4900545e17528bf8fd):
There's no need to check type twice here. Also, g_return_if_reached is not
correct since img==NULL is caused by invalid network input and not some
programmer error.

*** Plucked rev 3d02401cf232459fc80c0837d31e05fae7ae5467 (bcc0147bab874ca52c55ad4900545e17528bf8fd):
Using 'if (img==NULL) return;' fails to clean up properly, so invert the
logic of that section.

*** Plucked rev c64a1adc8bda2b4aeaae1f273541afbc4f71b810 (bcc0147bab874ca52c55ad4900545e17528bf8fd):
Each PurpleSmiley has a PurpleStoredImage behind it, so there's no need to
go and create a new one when someone asks for one.

Also, ignore requests for smileys that don't exist in the image store.


-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c	0b5fc641e7da6096b1bd8f18e10ffa02cd65c4bc
+++ libpurple/protocols/msn/slp.c	d74d6f3a7444cabd1cbe3cd2e7f5c0523dcbe842
@@ -238,6 +238,38 @@ send_decline(MsnSlpCall *slpcall, const 
 	msn_slplink_queue_slpmsg(slplink, slpmsg);
 }
 
+/* XXX: this could be improved if we tracked custom smileys
+ * per-protocol, per-account, per-session or (ideally) per-conversation
+ */
+static PurpleStoredImage *
+find_valid_emoticon(PurpleAccount *account, const char *path)
+{
+	GList *smileys;
+
+	if (!purple_account_get_bool(account, "custom_smileys", TRUE))
+		return NULL;
+
+	smileys = purple_smileys_get_all();
+
+	for (; smileys; smileys = g_list_delete_link(smileys, smileys)) {
+		PurpleSmiley *smiley;
+		PurpleStoredImage *img;
+
+		smiley = smileys->data;
+		img = purple_smiley_get_stored_image(smiley);
+
+		if (purple_strequal(path, purple_imgstore_get_filename(img))) {
+			g_list_free(smileys);
+			return img;
+		}
+
+		purple_imgstore_unref(img);
+	}
+
+	purple_debug_error("msn", "Received illegal request for file %s\n", path);
+	return NULL;
+}
+
 #define MAX_FILE_NAME_LEN 0x226
 
 static void
@@ -255,7 +287,7 @@ got_sessionreq(MsnSlpCall *slpcall, cons
 		MsnSlpMessage *slpmsg;
 		MsnObject *obj;
 		char *msnobj_data;
-		PurpleStoredImage *img;
+		PurpleStoredImage *img = NULL;
 		int type;
 
 		/* Send Ok */
@@ -274,50 +306,38 @@ got_sessionreq(MsnSlpCall *slpcall, cons
 		type = msn_object_get_type(obj);
 		g_free(msnobj_data);
 
-		if ((type != MSN_OBJECT_USERTILE) && (type != MSN_OBJECT_EMOTICON))
-		{
-			purple_debug_error("msn", "Wrong object?\n");
-			msn_object_destroy(obj);
-			g_return_if_reached();
-		}
-
 		if (type == MSN_OBJECT_EMOTICON) {
-			char *path;
-			path = g_build_filename(purple_smileys_get_storing_dir(),
-					obj->location, NULL);
-			img = purple_imgstore_new_from_file(path);
-			g_free(path);
-		} else {
+			img = find_valid_emoticon(slplink->session->account, obj->location);
+		} else if (type == MSN_OBJECT_USERTILE) {
 			img = msn_object_get_image(obj);
 			if (img)
 				purple_imgstore_ref(img);
 		}
 		msn_object_destroy(obj);
 
-		if (img == NULL)
-		{
-			purple_debug_error("msn", "Wrong object.\n");
-			g_return_if_reached();
-		}
+		if (img != NULL) {
+			/* DATA PREP */
+			slpmsg = msn_slpmsg_new(slplink);
+			slpmsg->slpcall = slpcall;
+			slpmsg->session_id = slpcall->session_id;
+			msn_slpmsg_set_body(slpmsg, NULL, 4);
+			slpmsg->info = "SLP DATA PREP";
+			msn_slplink_queue_slpmsg(slplink, slpmsg);
 
-		/* DATA PREP */
-		slpmsg = msn_slpmsg_new(slplink);
-		slpmsg->slpcall = slpcall;
-		slpmsg->session_id = slpcall->session_id;
-		msn_slpmsg_set_body(slpmsg, NULL, 4);
-		slpmsg->info = "SLP DATA PREP";
-		msn_slplink_queue_slpmsg(slplink, slpmsg);
+			/* DATA */
+			slpmsg = msn_slpmsg_new(slplink);
+			slpmsg->slpcall = slpcall;
+			slpmsg->flags = 0x20;
+			slpmsg->info = "SLP DATA";
+			msn_slpmsg_set_image(slpmsg, img);
+			msn_slplink_queue_slpmsg(slplink, slpmsg);
+			purple_imgstore_unref(img);
 
-		/* DATA */
-		slpmsg = msn_slpmsg_new(slplink);
-		slpmsg->slpcall = slpcall;
-		slpmsg->flags = 0x20;
-		slpmsg->info = "SLP DATA";
-		msn_slpmsg_set_image(slpmsg, img);
-		msn_slplink_queue_slpmsg(slplink, slpmsg);
-		purple_imgstore_unref(img);
+			accepted = TRUE;
 
-		accepted = TRUE;
+		} else {
+			purple_debug_error("msn", "Wrong object.\n");
+		}
 	}
 
 	else if (!strcmp(euf_guid, MSN_FT_GUID))


More information about the Commits mailing list