~ubuntu-branches/ubuntu/quantal/pidgin/quantal

« back to all changes in this revision

Viewing changes to libpurple/protocols/jabber/presence.c

  • Committer: Bazaar Package Importer
  • Author(s): Ari Pollak
  • Date: 2011-06-13 21:17:20 UTC
  • mfrom: (1.3.19 upstream)
  • mto: This revision was merged to the branch mainline in revision 73.
  • Revision ID: james.westby@ubuntu.com-20110613211720-ke87vzmdcuaxams7
Tags: 2.8.0-1
* Imported Upstream version 2.8.0 (Closes: #630124)
* Remove SILC support since the library will be orphaned (Closes: #629222)
* Fix typo in libpurple-bin description (Closes: #625462)

Show diffs side-by-side

added added

removed removed

Lines of Context:
450
450
                        g_free(nickname);
451
451
                }
452
452
 
453
 
                if ((photo = xmlnode_get_child(vcard, "PHOTO")) &&
454
 
                                (binval = xmlnode_get_child(photo, "BINVAL")) &&
455
 
                                (text = xmlnode_get_data(binval))) {
456
 
                        guchar *data;
457
 
                        gsize size;
458
 
 
459
 
                        data = purple_base64_decode(text, &size);
460
 
                        if (data) {
461
 
                                gchar *hash = jabber_calculate_data_hash(data, size, "sha1");
462
 
                                purple_buddy_icons_set_for_user(js->gc->account, from, data,
463
 
                                                                size, hash);
464
 
                                g_free(hash);
 
453
                if ((photo = xmlnode_get_child(vcard, "PHOTO"))) {
 
454
                        guchar *data = NULL;
 
455
                        gchar *hash = NULL;
 
456
                        gsize size = 0;
 
457
 
 
458
                        if ((binval = xmlnode_get_child(photo, "BINVAL")) &&
 
459
                                        (text = xmlnode_get_data(binval))) {
 
460
                                data = purple_base64_decode(text, &size);
 
461
                                g_free(text);
 
462
 
 
463
                                if (data)
 
464
                                        hash = jabber_calculate_data_hash(data, size, "sha1");
465
465
                        }
466
466
 
467
 
                        g_free(text);
 
467
                        purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash);
 
468
 
 
469
                        g_free(hash);
468
470
                }
469
471
        }
470
472
}
840
842
                }
841
843
        }
842
844
 
843
 
        if(b && presence->vcard_avatar_hash) {
844
 
                const char *avatar_hash2 = purple_buddy_icons_get_checksum_for_user(b);
845
 
                if(!avatar_hash2 || strcmp(presence->vcard_avatar_hash, avatar_hash2)) {
846
 
                        JabberIq *iq;
847
 
                        xmlnode *vcard;
848
 
 
 
845
        if (b && presence->vcard_avatar_hash) {
 
846
                const char *ah = presence->vcard_avatar_hash[0] != '\0' ?
 
847
                                presence->vcard_avatar_hash : NULL;
 
848
                const char *ah2 = purple_buddy_icons_get_checksum_for_user(b);
 
849
                if (!purple_strequal(ah, ah2)) {
849
850
                        /* XXX this is a crappy way of trying to prevent
850
851
                         * someone from spamming us with presence packets
851
852
                         * and causing us to DoS ourselves...what we really
852
853
                         * need is a queue system that can throttle itself,
853
854
                         * but i'm too tired to write that right now */
854
855
                        if(!g_slist_find(js->pending_avatar_requests, presence->jb)) {
 
856
                                JabberIq *iq;
 
857
                                xmlnode *vcard;
855
858
 
856
 
                                js->pending_avatar_requests = g_slist_prepend(js->pending_avatar_requests, presence->jb);
 
859
                                js->pending_avatar_requests =
 
860
                                        g_slist_prepend(js->pending_avatar_requests, presence->jb);
857
861
 
858
862
                                iq = jabber_iq_new(js, JABBER_IQ_GET);
859
863
                                xmlnode_set_attrib(iq->node, "to", buddy_name);
1206
1210
parse_vcard_avatar(JabberStream *js, JabberPresence *presence, xmlnode *x)
1207
1211
{
1208
1212
        xmlnode *photo = xmlnode_get_child(x, "photo");
 
1213
 
1209
1214
        if (photo) {
 
1215
                char *hash_tmp = xmlnode_get_data(photo);
1210
1216
                g_free(presence->vcard_avatar_hash);
1211
 
                presence->vcard_avatar_hash = xmlnode_get_data(photo);
 
1217
                presence->vcard_avatar_hash =
 
1218
                        hash_tmp ? hash_tmp : g_strdup("");
1212
1219
        }
1213
1220
}
1214
1221