Mercurial > pidgin
diff libpurple/protocols/jabber/presence.c @ 29046:1c035c869344
jabber: Always track our own presence, even if we're not on the buddy list.
This fixes various issues, like one's own resource not appearing in a
Get Info dialog (and the jabber:iq:last query from the previous commit).
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Mon, 15 Feb 2010 00:12:12 +0000 |
parents | 1d58c44c87f4 |
children | 2ad2e3490b23 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/presence.c Sun Feb 14 23:56:00 2010 +0000 +++ b/libpurple/protocols/jabber/presence.c Mon Feb 15 00:12:12 2010 +0000 @@ -65,7 +65,12 @@ { PurpleAccount *account; PurplePresence *presence; + JabberBuddy *jb; + JabberBuddyResource *jbr; const char *username; + JabberBuddyState state; + char *msg; + int priority; g_return_if_fail(js->user != NULL); @@ -74,29 +79,27 @@ presence = purple_account_get_presence(account); if (status == NULL) status = purple_presence_get_active_status(presence); + purple_status_to_jabber(status, &state, &msg, &priority); - if (purple_find_buddy(account, username)) { - JabberBuddy *jb = jabber_buddy_find(js, username, TRUE); - JabberBuddyResource *jbr; - JabberBuddyState state; - char *msg; - int priority; - - g_return_if_fail(jb != NULL); - - purple_status_to_jabber(status, &state, &msg, &priority); + jb = js->user_jb; - if (state == JABBER_BUDDY_STATE_UNAVAILABLE || - state == JABBER_BUDDY_STATE_UNKNOWN) { - jabber_buddy_remove_resource(jb, js->user->resource); - } else { - jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, - state, msg); - jbr->idle = purple_presence_is_idle(presence) ? - purple_presence_get_idle_time(presence) : 0; - } + if (state == JABBER_BUDDY_STATE_UNAVAILABLE || + state == JABBER_BUDDY_STATE_UNKNOWN) { + jabber_buddy_remove_resource(jb, js->user->resource); + } else { + jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, + state, msg); + jbr->idle = purple_presence_is_idle(presence) ? + purple_presence_get_idle_time(presence) : 0; + } - if ((jbr = jabber_buddy_find_resource(jb, NULL))) { + /* + * While we need to track the status of this resource, the core + * only cares if we're on our own buddy list. + */ + if (purple_find_buddy(account, username)) { + jbr = jabber_buddy_find_resource(jb, NULL); + if (jbr) { purple_prpl_got_user_status(account, username, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, @@ -108,8 +111,8 @@ msg ? "message" : NULL, msg, NULL); } - g_free(msg); } + g_free(msg); } void jabber_set_status(PurpleAccount *account, PurpleStatus *status)