comparison libpurple/protocols/jabber/presence.c @ 25804:9100b9176a16

propagate from branch 'im.pidgin.pidgin' (head a03e0bee477b05d1143ef3e5607d990c1120da34) to branch 'im.pidgin.cpw.malu.xmpp.idle' (head e0c18c146f94850aa81c1e4094e7fe549d028148)
author Marcus Lundblad <ml@update.uu.se>
date Wed, 17 Dec 2008 18:01:08 +0000
parents bba38f03085d 6f94b4a27372
children 6fed1bb3b02e
comparison
equal deleted inserted replaced
24761:c2054d8d23fc 25804:9100b9176a16
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"
24 #include "conversation.h" 25 #include "conversation.h"
25 #include "debug.h" 26 #include "debug.h"
26 #include "notify.h" 27 #include "notify.h"
27 #include "request.h" 28 #include "request.h"
28 #include "server.h" 29 #include "server.h"
346 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) { 347 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) {
347 if((photo = xmlnode_get_child(vcard, "PHOTO")) && 348 if((photo = xmlnode_get_child(vcard, "PHOTO")) &&
348 (( (binval = xmlnode_get_child(photo, "BINVAL")) && 349 (( (binval = xmlnode_get_child(photo, "BINVAL")) &&
349 (text = xmlnode_get_data(binval))) || 350 (text = xmlnode_get_data(binval))) ||
350 (text = xmlnode_get_data(photo)))) { 351 (text = xmlnode_get_data(photo)))) {
351 char *hash; 352 unsigned char hashval[20];
353 char hash[41], *p;
354 int i;
352 355
353 data = purple_base64_decode(text, &size); 356 data = purple_base64_decode(text, &size);
354 hash = jabber_calculate_data_sha1sum(data, size); 357
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
355 purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); 364 purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash);
356 g_free(hash);
357 g_free(text); 365 g_free(text);
358 } 366 }
359 } 367 }
360 } 368 }
361 369
500 char *p = xmlnode_get_data(y); 508 char *p = xmlnode_get_data(y);
501 if(p) { 509 if(p) {
502 priority = atoi(p); 510 priority = atoi(p);
503 g_free(p); 511 g_free(p);
504 } 512 }
505 } else if(xmlns == NULL) {
506 /* The rest of the cases used to check xmlns individually. */
507 continue;
508 } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) { 513 } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) {
509 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ 514 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */
510 delayed = TRUE; 515 delayed = TRUE;
511 } else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) { 516 } else if(xmlns && !strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) {
512 caps = y; /* store for later, when creating buddy resource */ 517 caps = y; /* store for later, when creating buddy resource */
513 } else if(!strcmp(y->name, "x")) { 518 } else if(!strcmp(y->name, "x")) {
514 if(!strcmp(xmlns, "jabber:x:delay")) { 519 const char *xmlns = xmlnode_get_namespace(y);
520 if(xmlns && !strcmp(xmlns, "jabber:x:delay")) {
515 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ 521 /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */
516 delayed = TRUE; 522 delayed = TRUE;
517 } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user")) { 523 } else if(xmlns && !strcmp(xmlns, "http://jabber.org/protocol/muc#user")) {
518 xmlnode *z; 524 xmlnode *z;
519 525
520 muc = TRUE; 526 muc = TRUE;
521 if((z = xmlnode_get_child(y, "status"))) { 527 if((z = xmlnode_get_child(y, "status"))) {
522 const char *code = xmlnode_get_attrib(z, "code"); 528 const char *code = xmlnode_get_attrib(z, "code");
555 flags |= PURPLE_CBFLAGS_OP; 561 flags |= PURPLE_CBFLAGS_OP;
556 else if (!strcmp(role, "participant")) 562 else if (!strcmp(role, "participant"))
557 flags |= PURPLE_CBFLAGS_VOICE; 563 flags |= PURPLE_CBFLAGS_VOICE;
558 } 564 }
559 } 565 }
560 } else if(!strcmp(xmlns, "vcard-temp:x:update")) { 566 } else if(xmlns && !strcmp(xmlns, "vcard-temp:x:update")) {
561 xmlnode *photo = xmlnode_get_child(y, "photo"); 567 xmlnode *photo = xmlnode_get_child(y, "photo");
562 if(photo) { 568 if(photo) {
563 g_free(avatar_hash); 569 g_free(avatar_hash);
564 avatar_hash = xmlnode_get_data(photo); 570 avatar_hash = xmlnode_get_data(photo);
565 } 571 }