comparison libpurple/protocols/jabber/buddy.c @ 25832:2d92bbe6807b

Use a JabberStream variable instead of a setting for the initial hash The hash is only used at login to compare with the PEP avatar(s) and vCard and is recalculated at each login, so there's no need to store it as a setting. The variable is eitehr NULL or the hash now, instead of "" or the hash.
author Paul Aurich <paul@darkrain42.org>
date Sat, 14 Feb 2009 18:23:13 +0000
parents ca8934dafd28
children 7e020fbe2cdb
comparison
equal deleted inserted replaced
25831:0fa91206cf5a 25832:2d92bbe6807b
494 } 494 }
495 } 495 }
496 496
497 void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) 497 void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img)
498 { 498 {
499 PurpleAccount *account = purple_connection_get_account(gc);
499 jabber_avatar_set(gc->proto_data, img, NULL); 500 jabber_avatar_set(gc->proto_data, img, NULL);
500 /* vCard avatars do not have an image type requirement so update our 501 /* vCard avatars do not have an image type requirement so update our
501 * vCard avatar regardless of image type for those poor older clients 502 * vCard avatar regardless of image type for those poor older clients
502 */ 503 */
503 jabber_set_info(gc, purple_account_get_user_info(gc->account)); 504 jabber_set_info(gc, purple_account_get_user_info(account));
505
506 /* TODO: Fake image to ourselves, since a number of servers do not echo
507 * back our presence to us. To do this without uselessly copying the data
508 * of the image, we need purple_buddy_icons_set_for_user_image (i.e. takes
509 * an existing icon/stored image). */
504 } 510 }
505 511
506 /* 512 /*
507 * This is the callback from the "ok clicked" for "set vCard" 513 * This is the callback from the "ok clicked" for "set vCard"
508 * 514 *
1042 1048
1043 static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data) 1049 static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data)
1044 { 1050 {
1045 xmlnode *vcard, *photo, *binval; 1051 xmlnode *vcard, *photo, *binval;
1046 char *txt, *vcard_hash = NULL; 1052 char *txt, *vcard_hash = NULL;
1047 const char *current_hash;
1048 1053
1049 if((vcard = xmlnode_get_child(packet, "vCard")) || 1054 if((vcard = xmlnode_get_child(packet, "vCard")) ||
1050 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) 1055 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp")))
1051 { 1056 {
1052 txt = xmlnode_to_str(vcard, NULL); 1057 txt = xmlnode_to_str(vcard, NULL);
1070 vcard_hash = jabber_calculate_data_sha1sum(data, size); 1075 vcard_hash = jabber_calculate_data_sha1sum(data, size);
1071 g_free(data); 1076 g_free(data);
1072 } 1077 }
1073 } 1078 }
1074 1079
1075 current_hash = purple_account_get_string(js->gc->account,
1076 "prpl-jabber_icon_checksum", "");
1077
1078 /* Republish our vcard if the photo is different than the server's */ 1080 /* Republish our vcard if the photo is different than the server's */
1079 if ((!vcard_hash && current_hash[0] != '\0') || 1081 if ((!vcard_hash && js->initial_avatar_hash) ||
1080 (vcard_hash && strcmp(vcard_hash, current_hash))) { 1082 (vcard_hash && (!js->initial_avatar_hash || strcmp(vcard_hash, js->initial_avatar_hash)))) {
1081 PurpleAccount *account = purple_connection_get_account(js->gc); 1083 PurpleAccount *account = purple_connection_get_account(js->gc);
1082 jabber_set_info(js->gc, purple_account_get_user_info(account)); 1084 jabber_set_info(js->gc, purple_account_get_user_info(account));
1083 } else if (current_hash != '\0') { 1085 } else if (js->initial_avatar_hash) {
1084 /* Our photo is in the vcard, so advertise vcard-temp updates */ 1086 /* Our photo is in the vcard, so advertise vcard-temp updates */
1085 js->avatar_hash = g_strdup(current_hash); 1087 js->avatar_hash = g_strdup(js->initial_avatar_hash);
1086 } 1088 }
1087 1089
1088 g_free(vcard_hash); 1090 g_free(vcard_hash);
1089 } 1091 }
1090 1092