Mercurial > pidgin
comparison libpurple/protocols/jabber/presence.c @ 27699:735040819c16
jabber: Properly track own idle time in fake_to_self.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 26 Jul 2009 19:25:47 +0000 |
parents | f95bcb5eb047 |
children | 49cb3fc2c01a |
comparison
equal
deleted
inserted
replaced
27695:042786b478c1 | 27699:735040819c16 |
---|---|
60 } | 60 } |
61 | 61 |
62 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status) | 62 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status) |
63 { | 63 { |
64 PurpleAccount *account; | 64 PurpleAccount *account; |
65 PurplePresence *presence; | |
65 const char *username; | 66 const char *username; |
66 | 67 |
67 g_return_if_fail(js->user != NULL); | 68 g_return_if_fail(js->user != NULL); |
68 | 69 |
69 account = purple_connection_get_account(js->gc); | 70 account = purple_connection_get_account(js->gc); |
70 username = purple_connection_get_display_name(js->gc); | 71 username = purple_connection_get_display_name(js->gc); |
72 presence = purple_account_get_presence(account); | |
71 if (status == NULL) | 73 if (status == NULL) |
72 status = purple_account_get_active_status(account); | 74 status = purple_presence_get_active_status(presence); |
73 | 75 |
74 if (purple_find_buddy(account, username)) { | 76 if (purple_find_buddy(account, username)) { |
75 JabberBuddy *jb = jabber_buddy_find(js, username, TRUE); | 77 JabberBuddy *jb = jabber_buddy_find(js, username, TRUE); |
76 JabberBuddyResource *jbr; | 78 JabberBuddyResource *jbr; |
77 JabberBuddyState state; | 79 JabberBuddyState state; |
84 | 86 |
85 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || | 87 if (state == JABBER_BUDDY_STATE_UNAVAILABLE || |
86 state == JABBER_BUDDY_STATE_UNKNOWN) { | 88 state == JABBER_BUDDY_STATE_UNKNOWN) { |
87 jabber_buddy_remove_resource(jb, js->user->resource); | 89 jabber_buddy_remove_resource(jb, js->user->resource); |
88 } else { | 90 } else { |
89 jabber_buddy_track_resource(jb, js->user->resource, priority, | 91 jbr = jabber_buddy_track_resource(jb, js->user->resource, priority, |
90 state, msg); | 92 state, msg); |
93 jbr->idle = purple_presence_is_idle(presence) ? | |
94 purple_presence_get_idle_time(presence) : 0; | |
91 } | 95 } |
92 | 96 |
93 if ((jbr = jabber_buddy_find_resource(jb, NULL))) { | 97 if ((jbr = jabber_buddy_find_resource(jb, NULL))) { |
94 purple_prpl_got_user_status(account, username, jabber_buddy_state_get_status_id(jbr->state), "priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL); | 98 purple_prpl_got_user_status(account, username, |
99 jabber_buddy_state_get_status_id(jbr->state), | |
100 "priority", jbr->priority, | |
101 jbr->status ? "message" : NULL, jbr->status, | |
102 NULL); | |
103 purple_prpl_got_user_idle(account, username, jbr->idle, jbr->idle); | |
95 } else { | 104 } else { |
96 purple_prpl_got_user_status(account, username, "offline", msg ? "message" : NULL, msg, NULL); | 105 purple_prpl_got_user_status(account, username, "offline", |
106 msg ? "message" : NULL, msg, | |
107 NULL); | |
97 } | 108 } |
98 g_free(msg); | 109 g_free(msg); |
99 } | 110 } |
100 } | 111 } |
101 | 112 |