changeset 29011:a363b5aff793

jabber: Add a PurpleAccount convenience variable. ...because what jabber_presence_parse() needs is another function-scoped var.
author Paul Aurich <paul@darkrain42.org>
date Wed, 10 Feb 2010 05:22:00 +0000
parents db0762fbb60b
children 9c9cfcd69181
files libpurple/protocols/jabber/presence.c
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/presence.c	Wed Feb 10 05:06:36 2010 +0000
+++ b/libpurple/protocols/jabber/presence.c	Wed Feb 10 05:22:00 2010 +0000
@@ -502,6 +502,7 @@
 	PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE;
 	gboolean delayed = FALSE;
 	const gchar *stamp = NULL; /* from <delayed/> element */
+	PurpleAccount *account;
 	PurpleBuddy *b = NULL;
 	char *buddy_name;
 	JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN;
@@ -523,6 +524,8 @@
 	if (signal_return)
 		return;
 
+	account = purple_connection_get_account(js->gc);
+
 	jid = jabber_id_new(from);
 	if (jid == NULL) {
 		purple_debug_error("jabber", "Ignoring presence with malformed 'from' "
@@ -559,12 +562,10 @@
 	} else if (g_str_equal(type, "subscribe")) {
 		struct _jabber_add_permit *jap = g_new0(struct _jabber_add_permit, 1);
 		gboolean onlist = FALSE;
-		PurpleAccount *account;
 		PurpleBuddy *buddy;
 		JabberBuddy *jb = NULL;
 		xmlnode *nick;
 
-		account = purple_connection_get_account(js->gc);
 		buddy = purple_find_buddy(account, from);
 		nick = xmlnode_get_child_with_namespace(packet, "nick", "http://jabber.org/protocol/nick");
 		if (nick)
@@ -748,7 +749,7 @@
 											" you like to configure it, or"
 											" accept the default settings?"),
 										/* Default Action */ 1,
-										purple_connection_get_account(js->gc), NULL, chat->conv,
+										account, NULL, chat->conv,
 										chat, 2,
 										_("_Configure Room"), G_CALLBACK(jabber_chat_request_room_configure),
 										_("_Accept Defaults"), G_CALLBACK(jabber_chat_create_instant_room));
@@ -957,10 +958,10 @@
 	} else {
 		buddy_name = g_strdup_printf("%s%s%s", jid->node ? jid->node : "",
 									 jid->node ? "@" : "", jid->domain);
-		if((b = purple_find_buddy(js->gc->account, buddy_name)) == NULL) {
+		if((b = purple_find_buddy(account, buddy_name)) == NULL) {
 			if (jb != js->user_jb) {
 				purple_debug_warning("jabber", "Got presence for unknown buddy %s on account %s (%p)\n",
-									 buddy_name, purple_account_get_username(js->gc->account), js->gc->account);
+									 buddy_name, purple_account_get_username(account), account);
 				jabber_id_free(jid);
 				g_free(avatar_hash);
 				g_free(buddy_name);
@@ -1004,7 +1005,7 @@
 			PurpleConversation *conv;
 
 			jabber_buddy_remove_resource(jb, jid->resource);
-			if((conv = jabber_find_unnormalized_im_conv(from, js->gc->account)))
+			if((conv = jabber_find_unnormalized_im_conv(from, account)))
 				/*
 				 * If a resource went offline (or the buddy unsubscribed),
 				 * send further messages to the bare JID.  (This is also
@@ -1024,12 +1025,12 @@
 
 		if((found_jbr = jabber_buddy_find_resource(jb, NULL))) {
 			jabber_google_presence_incoming(js, buddy_name, found_jbr);
-			purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, "message", found_jbr->status, NULL);
-			purple_prpl_got_user_idle(js->gc->account, buddy_name, found_jbr->idle, found_jbr->idle);
+			purple_prpl_got_user_status(account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, "message", found_jbr->status, NULL);
+			purple_prpl_got_user_idle(account, buddy_name, found_jbr->idle, found_jbr->idle);
 			if (nickname)
 				serv_got_alias(js->gc, buddy_name, nickname);
 		} else {
-			purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL);
+			purple_prpl_got_user_status(account, buddy_name, "offline", status ? "message" : NULL, status, NULL);
 		}
 		g_free(buddy_name);
 	}