Mercurial > pidgin
comparison libpurple/protocols/jabber/buddy.c @ 26045:62b41bb71a60
merge of '36ce4dcc4d637d6227ef52b2e9e72f957f0435ff'
and 'fc5fe0f88226b374c4d42d65ed90e97a059f4d0f'
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 13 Jan 2009 09:00:57 +0000 |
parents | ca4ccf646993 |
children | 5dd25c58b65e c814641afcf2 1d1d1829de11 d978395b4e18 94a6eb10c691 |
comparison
equal
deleted
inserted
replaced
26044:b04508e5cc6c | 26045:62b41bb71a60 |
---|---|
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); |
612 } | 619 } |
613 | 620 |
614 /* | 621 /* |
615 * This is the callback from the "ok clicked" for "set vCard" | 622 * This is the callback from the "ok clicked" for "set vCard" |
616 * | 623 * |
617 * Formats GSList data into XML-encoded string and returns a pointer | 624 * Sets the vCard with data from PurpleRequestFields. |
618 * to said string. | |
619 * | |
620 * g_free()'ing the returned string space is the responsibility of | |
621 * the caller. | |
622 */ | 625 */ |
623 static void | 626 static void |
624 jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields) | 627 jabber_format_info(PurpleConnection *gc, PurpleRequestFields *fields) |
625 { | 628 { |
626 xmlnode *vc_node; | 629 xmlnode *vc_node; |