Mercurial > pidgin
comparison libpurple/protocols/jabber/buddy.c @ 25702:62de30e69768
propagate from branch 'im.pidgin.pidgin' (head d6e38b24a5b289e3e7632def307f1d98b177d697)
to branch 'im.pidgin.cpw.malu.xmpp.attention' (head b6e791fe6305ef52eebfa2e85d3ed46ff1763b6c)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Wed, 07 Jan 2009 22:05:01 +0000 |
parents | 1e121a3eceeb |
children | ca4ccf646993 e33aee62e537 |
comparison
equal
deleted
inserted
replaced
25701:a50545e37a7a | 25702:62de30e69768 |
---|---|
457 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value); | 457 xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value); |
458 } | 458 } |
459 | 459 |
460 avatar_data = purple_imgstore_get_data(img); | 460 avatar_data = purple_imgstore_get_data(img); |
461 avatar_len = purple_imgstore_get_size(img); | 461 avatar_len = purple_imgstore_get_size(img); |
462 /* have to get rid of the old PHOTO if it exists */ | 462 /* Get rid of an old PHOTO if one exists. |
463 * TODO: This may want to be modified to remove all old PHOTO | |
464 * children, at the moment some people have managed to get | |
465 * multiple PHOTO entries in their vCard. */ | |
463 if((photo = xmlnode_get_child(vc_node, "PHOTO"))) { | 466 if((photo = xmlnode_get_child(vc_node, "PHOTO"))) { |
464 xmlnode_free(photo); | 467 xmlnode_free(photo); |
465 } | 468 } |
466 photo = xmlnode_new_child(vc_node, "PHOTO"); | 469 photo = xmlnode_new_child(vc_node, "PHOTO"); |
467 type = xmlnode_new_child(photo, "TYPE"); | 470 type = xmlnode_new_child(photo, "TYPE"); |
471 | 474 |
472 js->avatar_hash = jabber_calculate_data_sha1sum(avatar_data, avatar_len); | 475 js->avatar_hash = jabber_calculate_data_sha1sum(avatar_data, avatar_len); |
473 | 476 |
474 xmlnode_insert_data(binval, enc, -1); | 477 xmlnode_insert_data(binval, enc, -1); |
475 g_free(enc); | 478 g_free(enc); |
479 } else if (vc_node) { | |
480 xmlnode *photo; | |
481 /* TODO: Remove all PHOTO children? (see above note) */ | |
482 if ((photo = xmlnode_get_child(vc_node, "PHOTO"))) { | |
483 xmlnode_free(photo); | |
484 } | |
476 } | 485 } |
477 | 486 |
478 if (vc_node != NULL) { | 487 if (vc_node != NULL) { |
479 iq = jabber_iq_new(js, JABBER_IQ_SET); | 488 iq = jabber_iq_new(js, JABBER_IQ_SET); |
480 xmlnode_insert_child(iq->node, vc_node); | 489 xmlnode_insert_child(iq->node, vc_node); |
576 | 585 |
577 /* publish the metadata */ | 586 /* publish the metadata */ |
578 jabber_pep_publish((JabberStream*)gc->proto_data, publish); | 587 jabber_pep_publish((JabberStream*)gc->proto_data, publish); |
579 | 588 |
580 g_free(hash); | 589 g_free(hash); |
581 } else { /* if(img) */ | 590 } else { |
582 /* remove the metadata */ | 591 purple_debug_error("jabber", "jabber_set_buddy_icon received non-png data"); |
583 xmlnode *metadata, *item; | |
584 xmlnode *publish = xmlnode_new("publish"); | |
585 xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA); | |
586 | |
587 item = xmlnode_new_child(publish, "item"); | |
588 | |
589 metadata = xmlnode_new_child(item, "metadata"); | |
590 xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA); | |
591 | |
592 xmlnode_new_child(metadata, "stop"); | |
593 | |
594 /* publish the metadata */ | |
595 jabber_pep_publish((JabberStream*)gc->proto_data, publish); | |
596 } | 592 } |
597 } else { | 593 } else { |
598 purple_debug(PURPLE_DEBUG_ERROR, "jabber", | 594 /* remove the metadata */ |
599 "jabber_set_buddy_icon received non-png data"); | 595 xmlnode *metadata, *item; |
600 } | 596 xmlnode *publish = xmlnode_new("publish"); |
601 } | 597 xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA); |
602 | 598 |
603 /* even when the image is not png, we can still publish the vCard, since this | 599 item = xmlnode_new_child(publish, "item"); |
604 one doesn't require a specific image type */ | 600 |
605 | 601 metadata = xmlnode_new_child(item, "metadata"); |
606 /* publish vCard for those poor older clients */ | 602 xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA); |
603 | |
604 xmlnode_new_child(metadata, "stop"); | |
605 | |
606 /* publish the metadata */ | |
607 jabber_pep_publish((JabberStream*)gc->proto_data, publish); | |
608 } | |
609 } | |
610 | |
611 /* vCard avatars do not have an image type requirement so update our | |
612 * vCard avatar regardless of image type for those poor older clients | |
613 */ | |
607 jabber_set_info(gc, purple_account_get_user_info(gc->account)); | 614 jabber_set_info(gc, purple_account_get_user_info(gc->account)); |
608 | 615 |
609 gpresence = purple_account_get_presence(gc->account); | 616 gpresence = purple_account_get_presence(gc->account); |
610 status = purple_presence_get_active_status(gpresence); | 617 status = purple_presence_get_active_status(gpresence); |
611 jabber_presence_send(gc->account, status); | 618 jabber_presence_send(gc->account, status); |