# HG changeset patch # User Elliott Sales de Andrade # Date 1262237071 0 # Node ID 249784ec2bc79720b12aff50b6449c4ec673455f # Parent d3298d8f67ddec60286f56b326a7cc0a43efc4cd 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. diff -r d3298d8f67dd -r 249784ec2bc7 libpurple/protocols/msn/slp.c --- a/libpurple/protocols/msn/slp.c Thu Dec 31 04:45:35 2009 +0000 +++ b/libpurple/protocols/msn/slp.c Thu Dec 31 05:24:31 2009 +0000 @@ -276,6 +276,38 @@ 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 @@ -313,11 +345,7 @@ g_free(msnobj_data); 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); + img = find_valid_emoticon(slplink->session->account, obj->location); } else if (type == MSN_OBJECT_USERTILE) { img = msn_object_get_image(obj); if (img)