comparison libpurple/protocols/jabber/presence.c @ 25237:401f548e3544

propagate from branch 'im.pidgin.pidgin' (head df6eba32e5b6b34d7483cbfb7e9f2e4c836ac35f) to branch 'org.darkrain42.pidgin.buddy-add' (head 6831808999a270f8c1a128c7430a73d3dc0bfae2)
author Paul Aurich <paul@darkrain42.org>
date Sun, 21 Dec 2008 18:32:37 +0000
parents bba38f03085d
children 68f4edb42f39 9100b9176a16 0fa91206cf5a 54dcfe059dd4 1d1d1829de11 5f9a24d1c25e
comparison
equal deleted inserted replaced
25172:125cac3e24ee 25237:401f548e3544
19 * 19 *
20 */ 20 */
21 #include "internal.h" 21 #include "internal.h"
22 22
23 #include "account.h" 23 #include "account.h"
24 #include "cipher.h"
25 #include "conversation.h" 24 #include "conversation.h"
26 #include "debug.h" 25 #include "debug.h"
27 #include "notify.h" 26 #include "notify.h"
28 #include "request.h" 27 #include "request.h"
29 #include "server.h" 28 #include "server.h"
347 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { 346 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
348 if((photo = xmlnode_get_child(vcard, "PHOTO")) && 347 if((photo = xmlnode_get_child(vcard, "PHOTO")) &&
349 (( (binval = xmlnode_get_child(photo, "BINVAL")) && 348 (( (binval = xmlnode_get_child(photo, "BINVAL")) &&
350 (text = xmlnode_get_data(binval))) || 349 (text = xmlnode_get_data(binval))) ||
351 (text = xmlnode_get_data(photo)))) { 350 (text = xmlnode_get_data(photo)))) {
352 unsigned char hashval[20]; 351 char *hash;
353 char hash[41], *p;
354 int i;
355 352
356 data = purple_base64_decode(text, &size); 353 data = purple_base64_decode(text, &size);
357 354 hash = jabber_calculate_data_sha1sum(data, size);
358 purple_cipher_digest_region("sha1", data, size,
359 sizeof(hashval), hashval, NULL);
360 p = hash;
361 for(i=0; i<20; i++, p+=2)
362 snprintf(p, 3, "%02x", hashval[i]);
363
364 purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); 355 purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash);
356 g_free(hash);
365 g_free(text); 357 g_free(text);
366 } 358 }
367 } 359 }
368 } 360 }
369 361
508 char *p = xmlnode_get_data(y); 500 char *p = xmlnode_get_data(y);
509 if(p) { 501 if(p) {
510 priority = atoi(p); 502 priority = atoi(p);
511 g_free(p); 503 g_free(p);
512 } 504 }
505 } else if(xmlns == NULL) {
506 /* The rest of the cases used to check xmlns individually. */
507 continue;
513 } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) { 508 } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) {
514 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ 509 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */
515 delayed = TRUE; 510 delayed = TRUE;
516 } else if(xmlns && !strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) { 511 } else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) {
517 caps = y; /* store for later, when creating buddy resource */ 512 caps = y; /* store for later, when creating buddy resource */
518 } else if(!strcmp(y->name, "x")) { 513 } else if(!strcmp(y->name, "x")) {
519 const char *xmlns = xmlnode_get_namespace(y); 514 if(!strcmp(xmlns, "jabber:x:delay")) {
520 if(xmlns && !strcmp(xmlns, "jabber:x:delay")) {
521 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ 515 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */
522 delayed = TRUE; 516 delayed = TRUE;
523 } else if(xmlns && !strcmp(xmlns, "http://jabber.org/protocol/muc#user")) { 517 } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user")) {
524 xmlnode *z; 518 xmlnode *z;
525 519
526 muc = TRUE; 520 muc = TRUE;
527 if((z = xmlnode_get_child(y, "status"))) { 521 if((z = xmlnode_get_child(y, "status"))) {
528 const char *code = xmlnode_get_attrib(z, "code"); 522 const char *code = xmlnode_get_attrib(z, "code");
561 flags |= PURPLE_CBFLAGS_OP; 555 flags |= PURPLE_CBFLAGS_OP;
562 else if (!strcmp(role, "participant")) 556 else if (!strcmp(role, "participant"))
563 flags |= PURPLE_CBFLAGS_VOICE; 557 flags |= PURPLE_CBFLAGS_VOICE;
564 } 558 }
565 } 559 }
566 } else if(xmlns && !strcmp(xmlns, "vcard-temp:x:update")) { 560 } else if(!strcmp(xmlns, "vcard-temp:x:update")) {
567 xmlnode *photo = xmlnode_get_child(y, "photo"); 561 xmlnode *photo = xmlnode_get_child(y, "photo");
568 if(photo) { 562 if(photo) {
569 g_free(avatar_hash); 563 g_free(avatar_hash);
570 avatar_hash = xmlnode_get_data(photo); 564 avatar_hash = xmlnode_get_data(photo);
571 } 565 }