Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
29045:4e7fd81a39c6 | 29046:1c035c869344 |
---|---|
63 | 63 |
64 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status) | 64 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status) |
65 { | 65 { |
66 PurpleAccount *account; | 66 PurpleAccount *account; |
67 PurplePresence *presence; | 67 PurplePresence *presence; |
68 JabberBuddy *jb; | |
69 JabberBuddyResource *jbr; | |
68 const char *username; | 70 const char *username; |
71 JabberBuddyState state; | |
72 char *msg; | |
73 int priority; | |
69 | 74 |
70 g_return_if_fail(js->user != NULL); | 75 g_return_if_fail(js->user != NULL); |
71 | 76 |
72 account = purple_connection_get_account(js->gc); | 77 account = purple_connection_get_account(js->gc); |
73 username = purple_connection_get_display_name(js->gc); | 78 username = purple_connection_get_display_name(js->gc); |
74 presence = purple_account_get_presence(account); | 79 presence = purple_account_get_presence(account); |
75 if (status == NULL) | 80 if (status == NULL) |
76 status = purple_presence_get_active_status(presence); | 81 status = purple_presence_get_active_status(presence); |
77 | 82 purple_status_to_jabber(status, &state, &msg, &priority); |
83 | |
84 jb = js->user_jb; | |
85 | |
86 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || | |
87 state == JABBER_BUDDY_STATE_UNKNOWN) { | |
88 jabber_buddy_remove_resource(jb, js->user->resource); | |
89 } else { | |
90 jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, | |
91 state, msg); | |
92 jbr->idle = purple_presence_is_idle(presence) ? | |
93 purple_presence_get_idle_time(presence) : 0; | |
94 } | |
95 | |
96 /* | |
97 * While we need to track the status of this resource, the core | |
98 * only cares if we're on our own buddy list. | |
99 */ | |
78 if (purple_find_buddy(account, username)) { | 100 if (purple_find_buddy(account, username)) { |
79 JabberBuddy *jb = jabber_buddy_find(js, username, TRUE); | 101 jbr = jabber_buddy_find_resource(jb, NULL); |
80 JabberBuddyResource *jbr; | 102 if (jbr) { |
81 JabberBuddyState state; | |
82 char *msg; | |
83 int priority; | |
84 | |
85 g_return_if_fail(jb != NULL); | |
86 | |
87 purple_status_to_jabber(status, &state, &msg, &priority); | |
88 | |
89 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || | |
90 state == JABBER_BUDDY_STATE_UNKNOWN) { | |
91 jabber_buddy_remove_resource(jb, js->user->resource); | |
92 } else { | |
93 jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, | |
94 state, msg); | |
95 jbr->idle = purple_presence_is_idle(presence) ? | |
96 purple_presence_get_idle_time(presence) : 0; | |
97 } | |
98 | |
99 if ((jbr = jabber_buddy_find_resource(jb, NULL))) { | |
100 purple_prpl_got_user_status(account, username, | 103 purple_prpl_got_user_status(account, username, |
101 jabber_buddy_state_get_status_id(jbr->state), | 104 jabber_buddy_state_get_status_id(jbr->state), |
102 "priority", jbr->priority, | 105 "priority", jbr->priority, |
103 jbr->status ? "message" : NULL, jbr->status, | 106 jbr->status ? "message" : NULL, jbr->status, |
104 NULL); | 107 NULL); |
106 } else { | 109 } else { |
107 purple_prpl_got_user_status(account, username, "offline", | 110 purple_prpl_got_user_status(account, username, "offline", |
108 msg ? "message" : NULL, msg, | 111 msg ? "message" : NULL, msg, |
109 NULL); | 112 NULL); |
110 } | 113 } |
111 g_free(msg); | 114 } |
112 } | 115 g_free(msg); |
113 } | 116 } |
114 | 117 |
115 void jabber_set_status(PurpleAccount *account, PurpleStatus *status) | 118 void jabber_set_status(PurpleAccount *account, PurpleStatus *status) |
116 { | 119 { |
117 PurpleConnection *gc; | 120 PurpleConnection *gc; |