changeset 27944:cfa78428d8b2

propagate from branch 'im.pidgin.pidgin' (head 8f2b3a7063a7a0e5cae9de55e55f7066c0d202d6) to branch 'im.pidgin.pidgin.yaz' (head f0674cac79a9d60c5a3d998b37fc2cd75ce0a6b2)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 02 May 2009 20:35:36 +0000
parents d387f1164b3a (diff) 684690dbda4a (current diff)
children cc45ac2782cc
files libpurple/protocols/jabber/jabber.c libpurple/util.c libpurple/util.h
diffstat 10 files changed, 51 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri May 01 20:44:30 2009 +0000
+++ b/ChangeLog	Sat May 02 20:35:36 2009 +0000
@@ -33,6 +33,8 @@
 	* 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
--- a/libpurple/blist.h	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/blist.h	Sat May 02 20:35:36 2009 +0000
@@ -260,8 +260,8 @@
 PurpleBlistNode *purple_blist_get_root(void);
 
 /**
- * Returns a list of every buddy in the list. The usage of this function
- * is discourage if you do not actually need every buddy in the list. Use
+ * Returns a list of every buddy in the list.  Use of this function is
+ * discouraged if you do not actually need every buddy in the list.  Use
  * purple_find_buddies instead.
  *
  * @return A list of every buddy in the list. Caller is responsible for
--- a/libpurple/protocols/jabber/caps.c	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/protocols/jabber/caps.c	Sat May 02 20:35:36 2009 +0000
@@ -286,10 +286,10 @@
 					id->type = g_strdup(type);
 					id->name = g_strdup(name);
 					id->lang = g_strdup(lang);
-					
+
 					value->identities = g_list_append(value->identities,id);
 				} else if(!strcmp(child->name,"x")) {
-					/* FIXME: See #7814 -- this will cause problems if anyone
+					/* TODO: See #7814 -- this might cause problems if anyone
 					 * ever actually specifies forms. In fact, for this to
 					 * work properly, that bug needs to be fixed in
 					 * xmlnode_from_str, not the output version... */
@@ -794,9 +794,11 @@
 }
 
 static GString*
-jabber_caps_verification_append(GString *verification, const gchar *string)
+jabber_caps_verification_append(GString *verification, const gchar *str)
 {
-	verification = g_string_append(verification, string);
+	char *tmp = g_markup_escape_text(str, -1);
+	verification = g_string_append(verification, tmp);
+	g_free(tmp);
 	return g_string_append_c(verification, '<');
 }
 
@@ -822,9 +824,18 @@
 	/* concat identities to the verification string */
 	for (node = info->identities; node; node = node->next) {
 		JabberIdentity *id = (JabberIdentity*)node->data;
+		char *category = g_markup_escape_text(id->category, -1);
+		char *type = g_markup_escape_text(id->type, -1);
+		char *lang = g_markup_escape_text(id->lang, -1);
+		char *name = g_markup_escape_text(id->name, -1);
 
-		g_string_append_printf(verification, "%s/%s/%s/%s<", id->category,
-		        id->type, id->lang ? id->lang : "", id->name);
+		g_string_append_printf(verification, "%s/%s/%s/%s<", category,
+		        type, lang ? lang : "", name ? name : "");
+
+		g_free(category);
+		g_free(type);
+		g_free(lang);
+		g_free(name);
 	}
 
 	/* concat features to the verification string */
--- a/libpurple/protocols/jabber/jabber.c	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Sat May 02 20:35:36 2009 +0000
@@ -383,6 +383,11 @@
 			char *data_start, *tag_end = strchr(tag_start, '>');
 			text = g_strdup(data);
 
+			/* Better to print out some wacky debugging than crash
+			 * due to a plugin sending bad xml */
+			if (tag_end == NULL)
+				tag_end = tag_start;
+
 			data_start = text + (tag_end - data) + 1;
 
 			last_part = strchr(data_start, '<');
--- a/libpurple/protocols/jabber/presence.c	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/protocols/jabber/presence.c	Sat May 02 20:35:36 2009 +0000
@@ -441,6 +441,7 @@
 	char *avatar_hash = NULL;
 	xmlnode *caps = NULL;
 	int idle = 0;
+	gchar *nickname = NULL;
 
 	if(!(jb = jabber_buddy_find(js, from, TRUE)))
 		return;
@@ -463,6 +464,11 @@
 		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);
@@ -474,8 +480,9 @@
 		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")) {
@@ -526,6 +533,8 @@
 			stamp = xmlnode_get_attrib(y, "stamp");
 		} 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")) {
+			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 */
@@ -626,6 +635,7 @@
 			jabber_id_free(jid);
 			g_free(status);
 			g_free(avatar_hash);
+			g_free(nickname);
 			return;
 		}
 
@@ -642,6 +652,7 @@
 				jabber_id_free(jid);
 				g_free(status);
 				g_free(avatar_hash);
+				g_free(nickname);
 				return;
 			}
 
@@ -728,6 +739,7 @@
 				jabber_id_free(jid);
 				g_free(avatar_hash);
 				g_free(buddy_name);
+				g_free(nickname);
 				g_free(status);
 				return;
 			} else {
@@ -784,6 +796,8 @@
 			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 (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);
 		}
@@ -810,6 +824,7 @@
 		}
 	}
 
+	g_free(nickname);
 	g_free(status);
 	jabber_id_free(jid);
 	g_free(avatar_hash);
--- a/libpurple/protocols/jabber/usernick.c	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/protocols/jabber/usernick.c	Sat May 02 20:35:36 2009 +0000
@@ -35,7 +35,7 @@
 	xmlnode *nick;
 	char *nickname = NULL;
 
-	/* ignore the tune of people not on our buddy list */
+	/* ignore the nick of people not on our buddy list */
 	if (!buddy || !item)
 		return;
 
--- a/libpurple/protocols/msn/slplink.c	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/protocols/msn/slplink.c	Sat May 02 20:35:36 2009 +0000
@@ -493,7 +493,7 @@
 {
 	MsnSlpMessage *slpmsg;
 	const char *data;
-	gsize offset;
+	guint64 offset;
 	gsize len;
 
 #ifdef MSN_DEBUG_SLP
@@ -565,6 +565,7 @@
 			if (slpmsg->buffer == NULL)
 			{
 				purple_debug_error("msn", "Failed to allocate buffer for slpmsg\n");
+				msn_slpmsg_destroy(slpmsg);
 				return;
 			}
 		}
--- a/libpurple/upnp.c	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/upnp.c	Sat May 02 20:35:36 2009 +0000
@@ -130,7 +130,7 @@
 	guint tima;	/* purple_timeout_add handle */
 	int fd;
 	struct sockaddr_in server;
-	gchar service_type[25];
+	gchar service_type[20];
 	int retry_count;
 	gchar *full_url;
 } UPnPDiscoveryData;
--- a/libpurple/util.h	Fri May 01 20:44:30 2009 +0000
+++ b/libpurple/util.h	Sat May 02 20:35:36 2009 +0000
@@ -496,7 +496,8 @@
 char *purple_markup_linkify(const char *str);
 
 /**
- * Unescapes HTML entities to their literal characters.
+ * Unescapes HTML entities to their literal characters. Also translates
+ * "<br>" to "\n".
  * For example "&amp;" is replaced by '&' and so on.
  * Actually only "&amp;", "&quot;", "&lt;" and "&gt;" are currently
  * supported.
@@ -505,6 +506,8 @@
  *
  * @return The text with HTML entities literalized.  You must g_free
  *         this string when finished with it.
+ *
+ * @see purple_escape_html
  */
 char *purple_unescape_html(const char *html);
 
--- a/pidgin/win32/winpidgin.c	Fri May 01 20:44:30 2009 +0000
+++ b/pidgin/win32/winpidgin.c	Sat May 02 20:35:36 2009 +0000
@@ -586,7 +586,7 @@
 		return;
 	}
 
-	printf("Trying to handle protocol message:\n'%*s'\n", len, tmp1);
+	printf("Trying to handle protocol message:\n'%.*s'\n", len, tmp1);
 
 	/* MEM_COMMIT initializes the memory to zero,
 	 * so we don't need to worry that our section of tmp1 isn't nul-terminated */