changeset 27574:ff640fedbfde

Pass around a copy of our bare JID
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Jun 2009 03:58:11 +0000
parents 9a5a9a4e7626
children efb40ca43589
files libpurple/protocols/jabber/roster.c
diffstat 1 files changed, 7 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/roster.c	Sun Jun 07 06:17:29 2009 +0000
+++ b/libpurple/protocols/jabber/roster.c	Wed Jun 10 03:58:11 2009 +0000
@@ -53,10 +53,9 @@
 }
 
 static void add_purple_buddy_to_groups(JabberStream *js, const char *jid,
-		const char *alias, GSList *groups)
+		const char *alias, GSList *groups, const char *own_jid)
 {
 	GSList *buddies, *l;
-	gchar *my_bare_jid;
 	GList *pool = NULL;
 
 	buddies = purple_find_buddies(js->gc->account, jid);
@@ -74,8 +73,6 @@
 		}
 	}
 
-	my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
-
 	while(buddies) {
 		PurpleBuddy *b = buddies->data;
 		PurpleGroup *g = purple_buddy_get_group(b);
@@ -132,7 +129,7 @@
 		/* If we just learned about ourself, then fake our status,
 		 * because we won't be receiving a normal presence message
 		 * about ourself. */
-		if(!strcmp(purple_buddy_get_name(b), my_bare_jid))
+		if(!strcmp(purple_buddy_get_name(b), own_jid))
 			jabber_presence_fake_to_self(js, NULL);
 
 		g_free(groups->data);
@@ -147,7 +144,6 @@
 		pool = g_list_delete_link(pool, pool);
 	}
 
-	g_free(my_bare_jid);
 	g_slist_free(buddies);
 }
 
@@ -228,7 +224,7 @@
 				groups = g_slist_prepend(groups, group_name);
 			}
 
-			add_purple_buddy_to_groups(js, jid, name, groups);
+			add_purple_buddy_to_groups(js, jid, name, groups, own_jid);
 		}
 	}
 
@@ -328,7 +324,7 @@
 	char *who;
 	JabberBuddy *jb;
 	JabberBuddyResource *jbr;
-	char *my_bare_jid;
+	char *own_jid;
 	const char *name;
 
 	/* If we haven't received the roster yet, ignore any adds */
@@ -346,8 +342,8 @@
 
 	jabber_roster_update(js, who, NULL);
 
-	my_bare_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
-	if(!strcmp(who, my_bare_jid)) {
+	own_jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
+	if (g_str_equal(who, own_jid)) {
 		jabber_presence_fake_to_self(js, NULL);
 	} else if(!jb || !(jb->subscription & JABBER_SUB_TO)) {
 		jabber_presence_subscription_set(js, who, "subscribe");
@@ -357,7 +353,7 @@
 				"priority", jbr->priority, jbr->status ? "message" : NULL, jbr->status, NULL);
 	}
 
-	g_free(my_bare_jid);
+	g_free(own_jid);
 	g_free(who);
 }