Mercurial > pidgin.yaz
changeset 29213:249784ec2bc7
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.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 31 Dec 2009 05:24:31 +0000 |
parents | d3298d8f67dd |
children | 6ea85c7fe152 |
files | libpurple/protocols/msn/slp.c |
diffstat | 1 files changed, 33 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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)