changeset 27935:f33f4ddbf01a

propagate from branch 'im.pidgin.pidgin' (head d1b0914c480b5166f0687409b6a396866208d502) to branch 'im.pidgin.pidgin.yaz' (head 16078332e16f8548aed3ca7dcd56049c6829caed)
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sun, 15 Mar 2009 10:41:29 +0000
parents c1f1ed4d7a12 (current diff) 2321248ad702 (diff)
children 1688f7e15530
files libpurple/protocols/oscar/oscar.c libpurple/util.c pidgin/gtkconv.c
diffstat 12 files changed, 94 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Sun Mar 15 10:39:42 2009 +0000
+++ b/COPYRIGHT	Sun Mar 15 10:41:29 2009 +0000
@@ -432,6 +432,7 @@
 Amir Szekely (kichik)
 Robert T.
 Greg Taeger
+Rob Taft
 Peter Tang
 Brian Tarricone
 Peter Teichman
--- a/ChangeLog.API	Sun Mar 15 10:39:42 2009 +0000
+++ b/ChangeLog.API	Sun Mar 15 10:41:29 2009 +0000
@@ -26,6 +26,14 @@
 		* purple_request_field_set_ui_data
 		* purple_strequal
 		* xmlnode_from_file
+		* xmlnode_set_attrib_full
+
+		Changed:
+		* xmlnode_remove_attrib now removes all attributes with the
+		same name.  Previously, it would remove the first one found,
+		which was completely non-deterministic.  If you want to remove
+		the attribute with no namespace, then use NULL with
+		xmlnode_remove_with_namespace.
 
 		Deprecated:
 		* purple_buddy_get_local_alias
@@ -40,6 +48,8 @@
 		* purple_status_set_attr_string
 		* purple_presence_add_status
 		* purple_presence_add_list
+		* xmlnode_set_attrib_with_namespace
+		* xmlnode_set_attrib_with_prefix
 
 	pidgin:
 		Added:
--- a/libpurple/account.h	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/account.h	Sun Mar 15 10:41:29 2009 +0000
@@ -42,6 +42,7 @@
 
 #include "connection.h"
 #include "log.h"
+#include "privacy.h"
 #include "proxy.h"
 #include "prpl.h"
 #include "status.h"
@@ -141,7 +142,7 @@
 	 */
 	GSList *permit;             /**< Permit list.                           */
 	GSList *deny;               /**< Deny list.                             */
-	int perm_deny;              /**< The permit/deny setting.               */
+	PurplePrivacyType perm_deny;  /**< The permit/deny setting.               */
 
 	GList *status_types;        /**< Status types.                          */
 
--- a/libpurple/protocols/bonjour/parser.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/protocols/bonjour/parser.c	Sun Mar 15 10:41:29 2009 +0000
@@ -91,14 +91,12 @@
 		xmlnode_set_namespace(node, (const char*) namespace);
 
 		for(i=0; i < nb_attributes * 5; i+=5) {
+			const char *name = (const char *)attributes[i];
+			const char *prefix = (const char *)attributes[i+1];
+			const char *attrib_ns = (const char *)attributes[i+2];
 			char *txt;
 			int attrib_len = attributes[i+4] - attributes[i+3];
 			char *attrib = g_malloc(attrib_len + 1);
-			char *attrib_ns = NULL;
-
-			if (attributes[i+2]) {
-				attrib_ns = g_strdup((char*)attributes[i+2]);
-			}
 
 			memcpy(attrib, attributes[i+3], attrib_len);
 			attrib[attrib_len] = '\0';
@@ -106,9 +104,8 @@
 			txt = attrib;
 			attrib = purple_unescape_html(txt);
 			g_free(txt);
-			xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib);
+			xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib);
 			g_free(attrib);
-			g_free(attrib_ns);
 		}
 
 		bconv->current = node;
--- a/libpurple/protocols/jabber/parser.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/protocols/jabber/parser.c	Sun Mar 15 10:41:29 2009 +0000
@@ -86,6 +86,8 @@
 			}
 		}
 		for(i=0; i < nb_attributes * 5; i+=5) {
+			const char *name = (const char *)attributes[i];
+			const char *prefix = (const char *)attributes[i+1];
 			const char *attrib_ns = (const char *)attributes[i+2];
 			char *txt;
 			int attrib_len = attributes[i+4] - attributes[i+3];
@@ -97,7 +99,7 @@
 			txt = attrib;
 			attrib = purple_unescape_html(txt);
 			g_free(txt);
-			xmlnode_set_attrib_with_namespace(node, (const char*) attributes[i], attrib_ns, attrib);
+			xmlnode_set_attrib_full(node, name, attrib_ns, prefix, attrib);
 			g_free(attrib);
 		}
 
--- a/libpurple/protocols/oscar/oscar.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Mar 15 10:41:29 2009 +0000
@@ -4818,7 +4818,7 @@
 
 		status_html = purple_status_get_attr_string(status, "message");
 
-		if (primitive == PURPLE_STATUS_AVAILABLE || primitive == PURPLE_STATUS_INVISIBLE)
+		if (status_html == NULL || primitive == PURPLE_STATUS_AVAILABLE || primitive == PURPLE_STATUS_INVISIBLE)
 		{
 			/* This is needed for us to un-set any previous away message. */
 			away = g_strdup("");
@@ -5059,10 +5059,15 @@
 	purple_debug_error("oscar", "ssi: SNAC error %hu\n", reason);
 
 	if (reason == 0x0005) {
-		purple_notify_error(gc, NULL, _("Unable to Retrieve Buddy List"),
-						  _("The AIM servers were temporarily unable to send your buddy list.  Your buddy list is not lost, and will probably become available in a few minutes."));
 		if (od->getblisttimer > 0)
 			purple_timeout_remove(od->getblisttimer);
+		else
+			/* We only show this error the first time it happens */
+			purple_notify_error(gc, NULL,
+					_("Unable to Retrieve Buddy List"),
+					_("The AIM servers were temporarily unable to send "
+					"your buddy list.  Your buddy list is not lost, and "
+					"will probably become available in a few minutes."));
 		od->getblisttimer = purple_timeout_add(30000, purple_ssi_rerequestdata, od);
 		return 1;
 	}
--- a/libpurple/util.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/util.c	Sun Mar 15 10:41:29 2009 +0000
@@ -2893,6 +2893,12 @@
 	return "icon";
 }
 
+/*
+ * TODO: Consider using something faster than SHA-1, such as MD5, MD4
+ *       or CRC32.  Are there security implications to that?  Would
+ *       probably be a good idea to benchmark some algorithms with
+ *       3KB-10KB chunks of data (typical buddy icon sizes).
+ */
 char *
 purple_util_get_image_checksum(gconstpointer image_data, size_t image_len)
 {
--- a/libpurple/xmlnode.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/xmlnode.c	Sun Mar 15 10:41:29 2009 +0000
@@ -27,6 +27,7 @@
  * libxode uses memory pools that we simply have no need for, I decided to
  * write my own stuff.  Also, re-writing this lets me be as lightweight
  * as I want to be.  Thank you libxode for giving me a good starting point */
+#define _PURPLE_XMLNODE_C_
 
 #include "debug.h"
 #include "internal.h"
@@ -126,21 +127,28 @@
 	g_return_if_fail(node != NULL);
 	g_return_if_fail(attr != NULL);
 
-	for(attr_node = node->child; attr_node; attr_node = attr_node->next)
-	{
+	attr_node = node->child;
+	while (attr_node) {
 		if(attr_node->type == XMLNODE_TYPE_ATTRIB &&
 				purple_strequal(attr_node->name, attr))
 		{
-			if(sibling == NULL) {
-				node->child = attr_node->next;
-			} else {
-				sibling->next = attr_node->next;
-			}
 			if (node->lastchild == attr_node) {
 				node->lastchild = sibling;
 			}
-			xmlnode_free(attr_node);
-			return;
+			if (sibling == NULL) {
+				node->child = attr_node->next;
+				xmlnode_free(attr_node);
+				attr_node = node->child;
+			} else {
+				sibling->next = attr_node->next;
+				sibling = attr_node->next;
+				xmlnode_free(attr_node);
+				attr_node = sibling;
+			}
+		}
+		else
+		{
+			attr_node = attr_node->next;
 		}
 		sibling = attr_node;
 	}
@@ -178,24 +186,25 @@
 void
 xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value)
 {
-	xmlnode *attrib_node;
-
-	g_return_if_fail(node != NULL);
-	g_return_if_fail(attr != NULL);
-	g_return_if_fail(value != NULL);
-
 	xmlnode_remove_attrib(node, attr);
-
-	attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB);
-
-	attrib_node->data = g_strdup(value);
-
-	xmlnode_insert_child(node, attrib_node);
+	xmlnode_set_attrib_full(node, attr, NULL, NULL, value);
 }
 
 void
 xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value)
 {
+	xmlnode_set_attrib_full(node, attr, xmlns, NULL, value);
+}
+
+void
+xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value)
+{
+	xmlnode_set_attrib_full(node, attr, NULL, prefix, value);
+}
+
+void
+xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, const char *prefix, const char *value)
+{
 	xmlnode *attrib_node;
 
 	g_return_if_fail(node != NULL);
@@ -207,22 +216,6 @@
 
 	attrib_node->data = g_strdup(value);
 	attrib_node->xmlns = g_strdup(xmlns);
-
-	xmlnode_insert_child(node, attrib_node);
-}
-
-void
-xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value)
-{
-	xmlnode *attrib_node;
-
-	g_return_if_fail(node != NULL);
-	g_return_if_fail(attr != NULL);
-	g_return_if_fail(value != NULL);
-
-	attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB);
-
-	attrib_node->data = g_strdup(value);
 	attrib_node->prefix = g_strdup(prefix);
 
 	xmlnode_insert_child(node, attrib_node);
@@ -585,7 +578,8 @@
 		}
 
 		for(i=0; i < nb_attributes * 5; i+=5) {
-			const char *prefix = (const char *)attributes[i + 1];
+			const char *name = (const char *)attributes[i];
+			const char *prefix = (const char *)attributes[i+1];
 			char *txt;
 			int attrib_len = attributes[i+4] - attributes[i+3];
 			char *attrib = g_malloc(attrib_len + 1);
@@ -594,11 +588,7 @@
 			txt = attrib;
 			attrib = purple_unescape_html(txt);
 			g_free(txt);
-			if (prefix && *prefix) {
-				xmlnode_set_attrib_with_prefix(node, (const char*) attributes[i], prefix, attrib);
-			} else {
-				xmlnode_set_attrib(node, (const char*) attributes[i], attrib);
-			}
+			xmlnode_set_attrib_full(node, name, NULL, prefix, attrib);
 			g_free(attrib);
 		}
 
--- a/libpurple/xmlnode.h	Sun Mar 15 10:39:42 2009 +0000
+++ b/libpurple/xmlnode.h	Sun Mar 15 10:41:29 2009 +0000
@@ -157,6 +157,7 @@
  */
 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value);
 
+#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_XMLNODE_C_)
 /**
  * Sets a prefixed attribute for a node
  *
@@ -164,6 +165,8 @@
  * @param attr   The name of the attribute to set
  * @param prefix The prefix of the attribute to ste
  * @param value  The value of the attribute
+ *
+ * @deprecated Use xmlnode_set_attrib_full instead.
  */
 void xmlnode_set_attrib_with_prefix(xmlnode *node, const char *attr, const char *prefix, const char *value);
 
@@ -174,8 +177,25 @@
  * @param attr  The name of the attribute to set
  * @param xmlns The namespace of the attribute to ste
  * @param value The value of the attribute
+ *
+ * @deprecated Use xmlnode_set_attrib_full instead.
  */
 void xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, const char *value);
+#endif /* PURPLE_DISABLE_DEPRECATED */
+
+/**
+ * Sets a namespaced attribute for a node
+ *
+ * @param node   The node to set an attribute for.
+ * @param attr   The name of the attribute to set
+ * @param xmlns  The namespace of the attribute to ste
+ * @param prefix The prefix of the attribute to ste
+ * @param value  The value of the attribute
+ *
+ * @since 2.6.0
+ */
+void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns,
+	const char *prefix, const char *value);
 
 /**
  * Gets an attribute from a node.
--- a/pidgin/gtkconv.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/pidgin/gtkconv.c	Sun Mar 15 10:41:29 2009 +0000
@@ -45,6 +45,7 @@
 
 #include "account.h"
 #include "cmds.h"
+#include "core.h"
 #include "debug.h"
 #include "idle.h"
 #include "imgstore.h"
@@ -371,7 +372,8 @@
 	PurpleCmdStatus status;
 
 	if (!g_ascii_strcasecmp(args[0], "version")) {
-		tmp = g_strdup_printf("me is using %s v%s.", "Pidgin", DISPLAY_VERSION);
+		tmp = g_strdup_printf("me is using Pidgin v%s with libpurple v%s.",
+				DISPLAY_VERSION, purple_core_get_version());
 		markup = g_markup_escape_text(tmp, -1);
 
 		status = purple_cmd_do_command(conv, tmp, markup, error);
--- a/pidgin/gtkdialogs.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/pidgin/gtkdialogs.c	Sun Mar 15 10:41:29 2009 +0000
@@ -33,6 +33,7 @@
 #include "prpl.h"
 #include "request.h"
 #include "util.h"
+#include "core.h"
 
 #include "gtkblist.h"
 #include "gtkdialogs.h"
@@ -441,7 +442,7 @@
 	str = g_string_sized_new(4096);
 
 	g_string_append_printf(str,
-		"<CENTER><FONT SIZE=\"4\"><B>%s %s</B></FONT></CENTER><BR><BR>", PIDGIN_NAME, DISPLAY_VERSION);
+		"<CENTER><FONT SIZE=\"4\"><B>%s %s</B></FONT></CENTER><BR>(libpurple %s)<BR><BR>", PIDGIN_NAME, DISPLAY_VERSION, purple_core_get_version());
 
 	g_string_append_printf(str,
 		_("%s is a graphical modular messaging client based on "
--- a/pidgin/gtkmain.c	Sun Mar 15 10:39:42 2009 +0000
+++ b/pidgin/gtkmain.c	Sun Mar 15 10:41:29 2009 +0000
@@ -669,7 +669,8 @@
 	}
 	/* show version message */
 	if (opt_version) {
-		printf("%s %s\n", PIDGIN_NAME, DISPLAY_VERSION);
+		printf("%s %s (libpurple %s)\n", PIDGIN_NAME, DISPLAY_VERSION,
+		                                 purple_core_get_version());
 #ifdef HAVE_SIGNAL_H
 		g_free(segfault_message);
 #endif