Mercurial > pidgin.yaz
changeset 16031:7873f314fadf
Patch in Trac ticket #113 from Simom.
"Continued from patch #1693706 in SF tracker:
Newer Live Messenger -versions doesn't always send SHA1C-field in msnobj's and
so Pidgin discards them. This new version of patch uses sha1c as icon checksum
if it exists, otherwise it falls back to using sha1d, as datallah suggested."
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 23 Apr 2007 16:28:04 +0000 |
parents | 00a4de6880da |
children | 08557e94840c |
files | libpurple/protocols/msn/object.c libpurple/protocols/msn/object.h libpurple/protocols/msn/slp.c |
diffstat | 3 files changed, 33 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/object.c Mon Apr 09 13:02:46 2007 +0000 +++ b/libpurple/protocols/msn/object.c Mon Apr 23 16:28:04 2007 +0000 @@ -92,9 +92,10 @@ GET_STRING_TAG(sha1c, "SHA1C"); /* If we are missing any of the required elements then discard the object */ + /* SHA1C is not always sent anymore */ if (obj->creator == NULL || obj->size == 0 || obj->type == 0 || obj->location == NULL || obj->friendly == NULL - || obj->sha1d == NULL || obj->sha1c == NULL) { + || obj->sha1d == NULL /*|| obj->sha1c == NULL*/) { purple_debug_error("msn", "Discarding invalid msnobj: '%s'\n", str); msn_object_destroy(obj); obj = NULL; @@ -274,18 +275,30 @@ return obj->sha1c; } +const char * +msn_object_get_sha1(const MsnObject *obj) +{ + g_return_val_if_fail(obj != NULL, NULL); + + if(obj->sha1c != NULL) { + return obj->sha1c; + } else { + return obj->sha1d; + } +} + static MsnObject * -msn_object_find_local(const char *sha1c) +msn_object_find_local(const char *sha1) { GList *l; - g_return_val_if_fail(sha1c != NULL, NULL); + g_return_val_if_fail(sha1 != NULL, NULL); for (l = local_objs; l != NULL; l = l->next) { MsnObject *local_obj = l->data; - if (!strcmp(msn_object_get_sha1c(local_obj), sha1c)) + if (!strcmp(msn_object_get_sha1(local_obj), sha1)) return local_obj; } @@ -324,7 +337,7 @@ g_return_val_if_fail(obj != NULL, NULL); - local_obj = msn_object_find_local(msn_object_get_sha1c(obj)); + local_obj = msn_object_find_local(msn_object_get_sha1(obj)); if (local_obj != NULL) return local_obj->real_location;
--- a/libpurple/protocols/msn/object.h Mon Apr 09 13:02:46 2007 +0000 +++ b/libpurple/protocols/msn/object.h Mon Apr 23 16:28:04 2007 +0000 @@ -196,6 +196,15 @@ */ const char *msn_object_get_sha1c(const MsnObject *obj); +/** + * Returns a MsnObject's SHA1C value if it exists, otherwise SHA1D. + * + * @param obj The object. + * + * @return The SHA1C value. + */ +const char *msn_object_get_sha1(const MsnObject *obj); + void msn_object_set_local(MsnObject *obj); const char *msn_object_get_real_location(const MsnObject *obj); void msn_object_set_real_location(MsnObject *obj,
--- a/libpurple/protocols/msn/slp.c Mon Apr 09 13:02:46 2007 +0000 +++ b/libpurple/protocols/msn/slp.c Mon Apr 23 16:28:04 2007 +0000 @@ -793,7 +793,7 @@ MsnObject *obj; char **tokens; char *smile, *body_str; - const char *body, *who, *sha1c; + const char *body, *who, *sha1; guint tok; size_t body_len; @@ -825,7 +825,7 @@ break; who = msn_object_get_creator(obj); - sha1c = msn_object_get_sha1c(obj); + sha1 = msn_object_get_sha1(obj); slplink = msn_session_get_slplink(session, who); @@ -842,14 +842,14 @@ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, session->account, who); } - if (purple_conv_custom_smiley_add(conv, smile, "sha1", sha1c, TRUE)) { + if (purple_conv_custom_smiley_add(conv, smile, "sha1", sha1, TRUE)) { msn_slplink_request_object(slplink, smile, got_emoticon, NULL, obj); } msn_object_destroy(obj); obj = NULL; who = NULL; - sha1c = NULL; + sha1 = NULL; } g_strfreev(tokens); } @@ -871,7 +871,7 @@ return FALSE; old = purple_blist_node_get_string((PurpleBlistNode *)buddy, "icon_checksum"); - new = msn_object_get_sha1c(obj); + new = msn_object_get_sha1(obj); if (new == NULL) return FALSE; @@ -1090,7 +1090,7 @@ obj = msn_user_get_object(user); - info = msn_object_get_sha1c(obj); + info = msn_object_get_sha1(obj); if (g_ascii_strcasecmp(user->passport, purple_account_get_username(account)))