changeset 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 042786b478c1
children 02dd3b637d66
files libpurple/protocols/jabber/presence.c
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/presence.c	Sun Jul 26 17:43:00 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sun Jul 26 19:25:47 2009 +0000
@@ -62,14 +62,16 @@
 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status)
 {
 	PurpleAccount *account;
+	PurplePresence *presence;
 	const char *username;
 
 	g_return_if_fail(js->user != NULL);
 
 	account = purple_connection_get_account(js->gc);
 	username = purple_connection_get_display_name(js->gc);
+	presence = purple_account_get_presence(account);
 	if (status == NULL)
-		status = purple_account_get_active_status(account);
+		status = purple_presence_get_active_status(presence);
 
 	if (purple_find_buddy(account, username)) {
 		JabberBuddy *jb = jabber_buddy_find(js, username, TRUE);
@@ -86,14 +88,23 @@
 				state == JABBER_BUDDY_STATE_UNKNOWN) {
 			jabber_buddy_remove_resource(jb, js->user->resource);
 		} else {
-			jabber_buddy_track_resource(jb, js->user->resource, priority,
-			                            state, msg);
+			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))) {
-			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);
+			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);
+			purple_prpl_got_user_idle(account, username, jbr->idle, jbr->idle);
 		} else {
-			purple_prpl_got_user_status(account, username, "offline", msg ? "message" : NULL, msg, NULL);
+			purple_prpl_got_user_status(account, username, "offline",
+					msg ? "message" : NULL, msg,
+					NULL);
 		}
 		g_free(msg);
 	}