Mercurial > pidgin.yaz
changeset 29222:6ea85c7fe152
merge of '016d96cd3d2c3e0c9966b9209bae225a8d3cb696'
and 'c64a1adc8bda2b4aeaae1f273541afbc4f71b810'
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 01 Jan 2010 08:32:17 +0000 |
parents | 111a0a420ac7 (current diff) 249784ec2bc7 (diff) |
children | 932f16167621 |
files | |
diffstat | 2 files changed, 61 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/slp.c Thu Dec 31 18:03:25 2009 +0000 +++ b/libpurple/protocols/msn/slp.c Fri Jan 01 08:32:17 2010 +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 @@ -293,7 +325,7 @@ MsnSlpMessage *slpmsg; MsnObject *obj; char *msnobj_data; - PurpleStoredImage *img; + PurpleStoredImage *img = NULL; int type; /* Send Ok */ @@ -312,50 +344,38 @@ 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))
--- a/pidgin/gtkconv.c Thu Dec 31 18:03:25 2009 +0000 +++ b/pidgin/gtkconv.c Fri Jan 01 08:32:17 2010 +0000 @@ -5493,10 +5493,12 @@ } /* Somebody wants to keep this conversation around, so don't time it out */ - timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); - if (timer) { - purple_timeout_remove(timer); - purple_conversation_set_data(conv, "close-timer", GINT_TO_POINTER(0)); + if (conv) { + timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); + if (timer) { + purple_timeout_remove(timer); + purple_conversation_set_data(conv, "close-timer", GINT_TO_POINTER(0)); + } } }