Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/presence.c @ 18684:5c1ed6296b56
propagate from branch 'im.pidgin.pidgin' (head b195e262642015df66e36d33e9dd16ecae5df9d5)
to branch 'im.pidgin.soc.2007.xmpp' (head 06f9dbd73b69e26dc9f56873a9ce106146bb1b18)
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Wed, 11 Jul 2007 22:27:44 +0000 |
parents | 935005186312 075fa1c68bce |
children | 54a5fbeadd7c |
comparison
equal
deleted
inserted
replaced
17634:8d2ea5072f6f | 18684:5c1ed6296b56 |
---|---|
106 int priority; | 106 int priority; |
107 const char *artist, *title, *source, *uri, *track; | 107 const char *artist, *title, *source, *uri, *track; |
108 int length; | 108 int length; |
109 gboolean allowBuzz; | 109 gboolean allowBuzz; |
110 | 110 |
111 if(NULL == status) { | |
112 PurplePresence *gpresence = purple_account_get_presence(account); | |
113 status = purple_presence_get_active_status(gpresence); | |
114 } | |
115 | |
111 if(!purple_status_is_active(status)) | 116 if(!purple_status_is_active(status)) |
112 return; | 117 return; |
113 | 118 |
114 disconnected = purple_account_is_disconnected(account); | 119 disconnected = purple_account_is_disconnected(account); |
115 | 120 |
118 | 123 |
119 primitive = purple_status_type_get_primitive(purple_status_get_type(status)); | 124 primitive = purple_status_type_get_primitive(purple_status_get_type(status)); |
120 | 125 |
121 gc = purple_account_get_connection(account); | 126 gc = purple_account_get_connection(account); |
122 js = gc->proto_data; | 127 js = gc->proto_data; |
128 | |
129 /* we don't want to send presence before we've gotten our roster */ | |
130 if(!js->roster_parsed) { | |
131 purple_debug_info("jabber", "attempt to send presence before roster retrieved\n"); | |
132 return; | |
133 } | |
123 | 134 |
124 purple_status_to_jabber(status, &state, &stripped, &priority); | 135 purple_status_to_jabber(status, &state, &stripped, &priority); |
125 | 136 |
126 /* check for buzz support */ | 137 /* check for buzz support */ |
127 allowBuzz = purple_status_get_attr_boolean(status,"buzz"); | 138 allowBuzz = purple_status_get_attr_boolean(status,"buzz"); |
519 } | 530 } |
520 } | 531 } |
521 } else if(xmlns && !strcmp(xmlns, "vcard-temp:x:update")) { | 532 } else if(xmlns && !strcmp(xmlns, "vcard-temp:x:update")) { |
522 xmlnode *photo = xmlnode_get_child(y, "photo"); | 533 xmlnode *photo = xmlnode_get_child(y, "photo"); |
523 if(photo) { | 534 if(photo) { |
524 if(avatar_hash) | 535 g_free(avatar_hash); |
525 g_free(avatar_hash); | |
526 avatar_hash = xmlnode_get_data(photo); | 536 avatar_hash = xmlnode_get_data(photo); |
527 } | 537 } |
528 } | 538 } |
529 } | 539 } |
530 } | 540 } |
549 | 559 |
550 jabber_chat_destroy(chat); | 560 jabber_chat_destroy(chat); |
551 jabber_id_free(jid); | 561 jabber_id_free(jid); |
552 g_free(status); | 562 g_free(status); |
553 g_free(room_jid); | 563 g_free(room_jid); |
554 if(avatar_hash) | 564 g_free(avatar_hash); |
555 g_free(avatar_hash); | |
556 return; | 565 return; |
557 } | 566 } |
558 | 567 |
559 | 568 |
560 if(type && !strcmp(type, "unavailable")) { | 569 if(type && !strcmp(type, "unavailable")) { |
566 if(jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) | 575 if(jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) |
567 jabber_chat_destroy(chat); | 576 jabber_chat_destroy(chat); |
568 jabber_id_free(jid); | 577 jabber_id_free(jid); |
569 g_free(status); | 578 g_free(status); |
570 g_free(room_jid); | 579 g_free(room_jid); |
571 if(avatar_hash) | 580 g_free(avatar_hash); |
572 g_free(avatar_hash); | |
573 return; | 581 return; |
574 } | 582 } |
575 | 583 |
576 jabber_buddy_remove_resource(jb, jid->resource); | 584 jabber_buddy_remove_resource(jb, jid->resource); |
577 if(chat->muc) { | 585 if(chat->muc) { |
647 g_free(room_jid); | 655 g_free(room_jid); |
648 } else { | 656 } else { |
649 buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", | 657 buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "", |
650 jid->node ? "@" : "", jid->domain); | 658 jid->node ? "@" : "", jid->domain); |
651 if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) { | 659 if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) { |
652 purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%x)", | 660 purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%x)\n", |
653 buddy_name, purple_account_get_username(js->gc->account), js->gc->account); | 661 buddy_name, purple_account_get_username(js->gc->account), js->gc->account); |
654 jabber_id_free(jid); | 662 jabber_id_free(jid); |
655 if(avatar_hash) | 663 g_free(avatar_hash); |
656 g_free(avatar_hash); | |
657 g_free(buddy_name); | 664 g_free(buddy_name); |
658 g_free(status); | 665 g_free(status); |
659 return; | 666 return; |
660 } | 667 } |
661 | 668 |
711 } | 718 } |
712 } | 719 } |
713 } | 720 } |
714 | 721 |
715 if((found_jbr = jabber_buddy_find_resource(jb, NULL))) { | 722 if((found_jbr = jabber_buddy_find_resource(jb, NULL))) { |
716 if(!jbr || jbr == found_jbr) { | 723 purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, found_jbr->status ? "message" : NULL, found_jbr->status, NULL); |
717 purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(state), "priority", found_jbr->priority, found_jbr->status ? "message" : NULL, found_jbr->status, NULL); | |
718 } | |
719 } else { | 724 } else { |
720 purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL); | 725 purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL); |
721 } | 726 } |
722 g_free(buddy_name); | 727 g_free(buddy_name); |
723 } | 728 } |
724 g_free(status); | 729 g_free(status); |
725 jabber_id_free(jid); | 730 jabber_id_free(jid); |
726 if(avatar_hash) | 731 g_free(avatar_hash); |
727 g_free(avatar_hash); | |
728 } | 732 } |
729 | 733 |
730 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) | 734 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) |
731 { | 735 { |
732 xmlnode *presence = xmlnode_new("presence"); | 736 xmlnode *presence = xmlnode_new("presence"); |
761 /* if the message is blank, then there really isn't a message */ | 765 /* if the message is blank, then there really isn't a message */ |
762 if(formatted_msg && !*formatted_msg) | 766 if(formatted_msg && !*formatted_msg) |
763 formatted_msg = NULL; | 767 formatted_msg = NULL; |
764 | 768 |
765 if(formatted_msg) | 769 if(formatted_msg) |
766 purple_markup_html_to_xhtml(formatted_msg, NULL, msg); | 770 *msg = purple_markup_strip_html(formatted_msg); |
767 } | 771 } |
768 | 772 |
769 if(priority) | 773 if(priority) |
770 *priority = purple_status_get_attr_int(status, "priority"); | 774 *priority = purple_status_get_attr_int(status, "priority"); |
771 } | 775 } |