Mercurial > pidgin.yaz
comparison libgaim/protocols/jabber/presence.c @ 14463:7df4ab213577
[gaim-migrate @ 17177]
commit part of 1547648
commit some jabber stuff I did a few days ago and forgot about
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Wed, 06 Sep 2006 03:58:53 +0000 |
parents | 60b1bc8dbf37 |
children | 7ac8259f355d |
comparison
equal
deleted
inserted
replaced
14462:34a5709ff951 | 14463:7df4ab213577 |
---|---|
64 if(gaim_find_buddy(js->gc->account, my_base_jid)) { | 64 if(gaim_find_buddy(js->gc->account, my_base_jid)) { |
65 JabberBuddy *jb; | 65 JabberBuddy *jb; |
66 JabberBuddyResource *jbr; | 66 JabberBuddyResource *jbr; |
67 if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { | 67 if((jb = jabber_buddy_find(js, my_base_jid, TRUE))) { |
68 JabberBuddyState state; | 68 JabberBuddyState state; |
69 const char *msg; | 69 char *msg; |
70 int priority; | 70 int priority; |
71 | 71 |
72 gaim_status_to_jabber(gstatus, &state, &msg, &priority); | 72 gaim_status_to_jabber(gstatus, &state, &msg, &priority); |
73 | 73 |
74 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || state == JABBER_BUDDY_STATE_UNKNOWN) { | 74 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || state == JABBER_BUDDY_STATE_UNKNOWN) { |
79 if((jbr = jabber_buddy_find_resource(jb, NULL))) { | 79 if((jbr = jabber_buddy_find_resource(jb, NULL))) { |
80 gaim_prpl_got_user_status(js->gc->account, my_base_jid, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); | 80 gaim_prpl_got_user_status(js->gc->account, my_base_jid, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); |
81 } else { | 81 } else { |
82 gaim_prpl_got_user_status(js->gc->account, my_base_jid, "offline", msg ? "message" : NULL, msg, NULL); | 82 gaim_prpl_got_user_status(js->gc->account, my_base_jid, "offline", msg ? "message" : NULL, msg, NULL); |
83 } | 83 } |
84 | |
85 g_free(msg); | |
84 } | 86 } |
85 } | 87 } |
86 g_free(my_base_jid); | 88 g_free(my_base_jid); |
87 } | 89 } |
88 | 90 |
93 JabberStream *js = NULL; | 95 JabberStream *js = NULL; |
94 gboolean disconnected; | 96 gboolean disconnected; |
95 int primitive; | 97 int primitive; |
96 xmlnode *presence, *x, *photo; | 98 xmlnode *presence, *x, *photo; |
97 char *stripped = NULL; | 99 char *stripped = NULL; |
98 const char *msg; | |
99 JabberBuddyState state; | 100 JabberBuddyState state; |
100 int priority; | 101 int priority; |
101 | 102 |
102 if(!gaim_status_is_active(status)) | 103 if(!gaim_status_is_active(status)) |
103 return; | 104 return; |
109 return; | 110 return; |
110 | 111 |
111 gc = gaim_account_get_connection(account); | 112 gc = gaim_account_get_connection(account); |
112 js = gc->proto_data; | 113 js = gc->proto_data; |
113 | 114 |
114 gaim_status_to_jabber(status, &state, &msg, &priority); | 115 gaim_status_to_jabber(status, &state, &stripped, &priority); |
115 | 116 |
116 if(msg) | |
117 gaim_markup_html_to_xhtml(msg, NULL, &stripped); | |
118 | 117 |
119 presence = jabber_presence_create(state, stripped, priority); | 118 presence = jabber_presence_create(state, stripped, priority); |
120 g_free(stripped); | 119 g_free(stripped); |
121 | 120 |
122 if(js->avatar_hash) { | 121 if(js->avatar_hash) { |
602 | 601 |
603 jabber_send(js, presence); | 602 jabber_send(js, presence); |
604 xmlnode_free(presence); | 603 xmlnode_free(presence); |
605 } | 604 } |
606 | 605 |
607 void gaim_status_to_jabber(const GaimStatus *status, JabberBuddyState *state, const char **msg, int *priority) | 606 void gaim_status_to_jabber(const GaimStatus *status, JabberBuddyState *state, char **msg, int *priority) |
608 { | 607 { |
609 const char *status_id = NULL; | 608 const char *status_id = NULL; |
609 const char *formatted_msg = NULL; | |
610 | 610 |
611 if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; | 611 if(state) *state = JABBER_BUDDY_STATE_UNKNOWN; |
612 if(msg) *msg = NULL; | 612 if(msg) *msg = NULL; |
613 if(priority) *priority = 0; | 613 if(priority) *priority = 0; |
614 | 614 |
619 status_id = gaim_status_get_id(status); | 619 status_id = gaim_status_get_id(status); |
620 *state = jabber_buddy_status_id_get_state(status_id); | 620 *state = jabber_buddy_status_id_get_state(status_id); |
621 } | 621 } |
622 | 622 |
623 if(msg) { | 623 if(msg) { |
624 *msg = gaim_status_get_attr_string(status, "message"); | 624 formatted_msg = gaim_status_get_attr_string(status, "message"); |
625 | 625 |
626 /* if the message is blank, then there really isn't a message */ | 626 /* if the message is blank, then there really isn't a message */ |
627 if(*msg && !**msg) | 627 if(formatted_msg && !*formatted_msg) |
628 *msg = NULL; | 628 formatted_msg = NULL; |
629 | |
630 if(formatted_msg) | |
631 gaim_markup_html_to_xhtml(formatted_msg, NULL, msg); | |
629 } | 632 } |
630 | 633 |
631 if(priority) | 634 if(priority) |
632 *priority = gaim_status_get_attr_int(status, "priority"); | 635 *priority = gaim_status_get_attr_int(status, "priority"); |
633 } | 636 } |