pidgin: 043dfec3: A little bit better (free memory and sup...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat May 2 00:40:26 EDT 2009


-----------------------------------------------------------------
Revision: 043dfec38d634f26f4654b15146fbd0f27376389
Ancestor: 8e3ce42b3d6264d5e582fc55da07f8ec8d4afe0c
Author: darkrain42 at pidgin.im
Date: 2009-05-02T04:39:38
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/043dfec38d634f26f4654b15146fbd0f27376389

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

ChangeLog: 

A little bit better (free memory and support receiving the nick in subscriptions) and Changelog.

-------------- next part --------------
============================================================
--- ChangeLog	b4de3f33882d41b97d87a004ea1fc7144b26dfb2
+++ ChangeLog	465e04e62ef61cf8c849610c7934ebc9a30f9e7b
@@ -33,6 +33,8 @@ version 2.6.0 (??/??/2009):
 	* Support showing and reporting idle times in the buddy list. (XEP-0256)
 	* Support most recent version of User Avatar. (XEP-0084 v1.1)
 	* Updated Entity Capabilities support. (Tobias Markmann)
+	* Support receiving user nicknames in presence packets and subscriptions.
+	  (XEP-0172)
 
 	IRC:
 	* Correctly handle WHOIS for users who are joined to a large number of
============================================================
--- libpurple/protocols/jabber/presence.c	93058e206a0cfa52e4329fe4fe3be06cf91a7ff9
+++ libpurple/protocols/jabber/presence.c	13674cf135948854b78222809145f3f75d812b93
@@ -441,7 +441,7 @@ void jabber_presence_parse(JabberStream 
 	char *avatar_hash = NULL;
 	xmlnode *caps = NULL;
 	int idle = 0;
-	const gchar *nick = NULL;
+	gchar *nickname = NULL;
 
 	if(!(jb = jabber_buddy_find(js, from, TRUE)))
 		return;
@@ -464,7 +464,12 @@ void jabber_presence_parse(JabberStream 
 		gboolean onlist = FALSE;
 		PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from);
 		JabberBuddy *jb = NULL;
+		xmlnode *nick;
 
+		nick = xmlnode_get_child_with_namespace(packet, "nick", "http://jabber.org/protocol/nick");
+		if (nick)
+			nickname = xmlnode_get_data(nick);
+
 		if (buddy) {
 			jb = jabber_buddy_find(js, from, TRUE);
 			if ((jb->subscription & (JABBER_SUB_TO | JABBER_SUB_PENDING)))
@@ -475,8 +480,9 @@ void jabber_presence_parse(JabberStream 
 		jap->who = g_strdup(from);
 		jap->js = js;
 
-		purple_account_request_authorization(purple_connection_get_account(js->gc), from, NULL, NULL, NULL, onlist,
+		purple_account_request_authorization(purple_connection_get_account(js->gc), from, NULL, nickname, NULL, onlist,
 				authorize_add_cb, deny_add_cb, jap);
+		g_free(nickname);
 		jabber_id_free(jid);
 		return;
 	} else if(type && !strcmp(type, "subscribed")) {
@@ -528,7 +534,7 @@ void jabber_presence_parse(JabberStream 
 		} else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) {
 			caps = y; /* store for later, when creating buddy resource */
 		} else if (g_str_equal(y->name, "nick") && g_str_equal(xmlns, "http://jabber.org/protocol/nick")) {
-			nick = xmlnode_get_data(y);
+			nickname = xmlnode_get_data(y);
 		} else if(!strcmp(y->name, "x")) {
 			if(!strcmp(xmlns, "jabber:x:delay")) {
 				/* XXX: compare the time.  jabber:x:delay can happen on presence packets that aren't really and truly delayed */
@@ -629,6 +635,7 @@ void jabber_presence_parse(JabberStream 
 			jabber_id_free(jid);
 			g_free(status);
 			g_free(avatar_hash);
+			g_free(nickname);
 			return;
 		}
 
@@ -645,6 +652,7 @@ void jabber_presence_parse(JabberStream 
 				jabber_id_free(jid);
 				g_free(status);
 				g_free(avatar_hash);
+				g_free(nickname);
 				return;
 			}
 
@@ -731,6 +739,7 @@ void jabber_presence_parse(JabberStream 
 				jabber_id_free(jid);
 				g_free(avatar_hash);
 				g_free(buddy_name);
+				g_free(nickname);
 				g_free(status);
 				return;
 			} else {
@@ -787,8 +796,8 @@ void jabber_presence_parse(JabberStream 
 			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);
-			if (nick)
-				serv_got_alias(js->gc, buddy_name, nick);
+			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);
 		}
@@ -815,6 +824,7 @@ void jabber_presence_parse(JabberStream 
 		}
 	}
 
+	g_free(nickname);
 	g_free(status);
 	jabber_id_free(jid);
 	g_free(avatar_hash);


More information about the Commits mailing list