pidgin: 7d48379e: jabber: Always track our own presence, e...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Feb 14 19:31:17 EST 2010


-----------------------------------------------------------------
Revision: 7d48379ec50d5f267e76d1b1ffa51498bf19529e
Ancestor: b5a5f38cb77e61bca90f7791428de9ec3c742771
Author: darkrain42 at pidgin.im
Date: 2010-02-15T00:12:12
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/7d48379ec50d5f267e76d1b1ffa51498bf19529e

Modified files:
        libpurple/protocols/jabber/presence.c

ChangeLog: 

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).

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/presence.c	aaacf23ca91a318035ad4e0231ed4794a892eb07
+++ libpurple/protocols/jabber/presence.c	4e58c4ee37b84d1776aa09ba08a5c031da027832
@@ -65,7 +65,12 @@ void jabber_presence_fake_to_self(Jabber
 {
 	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 @@ void jabber_presence_fake_to_self(Jabber
 	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;
+	jb = js->user_jb;
 
-		g_return_if_fail(jb != NULL);
+	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;
+	}
 
-		purple_status_to_jabber(status, &state, &msg, &priority);
-
-		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 @@ void jabber_presence_fake_to_self(Jabber
 					msg ? "message" : NULL, msg,
 					NULL);
 		}
-		g_free(msg);
 	}
+	g_free(msg);
 }
 
 void jabber_set_status(PurpleAccount *account, PurpleStatus *status)


More information about the Commits mailing list