/soc/2013/ankitkv/gobjectification: f01a800348ec: Warn about new...

Ankit Vani a at nevitus.org
Sun Jan 19 21:36:39 EST 2014


Changeset: f01a800348ecbc2d5ddf069052c1c874766b6e4f
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2014-01-20 08:05 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/f01a800348ec

Description:

Warn about newer versions for pounces.xml and smileys.xml.
Keep smileys.xml to "1.0" as it does not store protocol IDs.

diffstat:

 libpurple/pounce.c |  13 +++++++++++--
 libpurple/smiley.c |   9 ++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diffs (77 lines):

diff --git a/libpurple/pounce.c b/libpurple/pounce.c
--- a/libpurple/pounce.c
+++ b/libpurple/pounce.c
@@ -32,6 +32,8 @@
 #include "pounce.h"
 #include "util.h"
 
+#define POUNCES_XML_VERSION "1.1"
+
 /**
  * A buddy pounce structure.
  *
@@ -257,7 +259,7 @@ pounces_to_xmlnode(void)
 	GList *cur;
 
 	node = purple_xmlnode_new("pounces");
-	purple_xmlnode_set_attrib(node, "version", "1.0");
+	purple_xmlnode_set_attrib(node, "version", POUNCES_XML_VERSION);
 
 	for (cur = purple_pounces_get_all(); cur != NULL; cur = cur->next)
 	{
@@ -351,7 +353,14 @@ start_element_handler(GMarkupParseContex
 		data->buffer = NULL;
 	}
 
-	if (purple_strequal(element_name, "pounce")) {
+	if (purple_strequal(element_name, "pounces")) {
+		const char *version = g_hash_table_lookup(atts, "version");
+
+		if (purple_version_strcmp(version, POUNCES_XML_VERSION) > 0)
+			purple_debug_warning("pounce", "pounces.xml on disk is for a "
+					"newer version of libpurple");
+	}
+	else if (purple_strequal(element_name, "pounce")) {
 		const char *ui = g_hash_table_lookup(atts, "ui");
 
 		if (ui == NULL) {
diff --git a/libpurple/smiley.c b/libpurple/smiley.c
--- a/libpurple/smiley.c
+++ b/libpurple/smiley.c
@@ -60,6 +60,7 @@ static char *smileys_dir = NULL;
 #define SMILEYS_LOG_ID				"smileys"
 
 #define XML_FILE_NAME				"smileys.xml"
+#define XML_VERSION				"1.0"
 
 #define XML_ROOT_TAG				"smileys"
 #define XML_PROFILE_TAG			"profile"
@@ -168,7 +169,7 @@ smileys_to_xmlnode(void)
 	PurpleXmlNode *root_node, *profile_node, *smileyset_node;
 
 	root_node = purple_xmlnode_new(XML_ROOT_TAG);
-	purple_xmlnode_set_attrib(root_node, "version", "1.0");
+	purple_xmlnode_set_attrib(root_node, "version", XML_VERSION);
 
 	/* See the top comments above to understand why initial tag elements
 	 * are not being considered by now. */
@@ -250,6 +251,7 @@ purple_smileys_load(void)
 	PurpleXmlNode *root_node, *profile_node;
 	PurpleXmlNode *smileyset_node = NULL;
 	PurpleXmlNode *smiley_node;
+	const char *version;
 
 	smileys_loaded = TRUE;
 
@@ -259,6 +261,11 @@ purple_smileys_load(void)
 	if (root_node == NULL)
 		return;
 
+	version = purple_xmlnode_get_attrib(root_node, "version");
+	if (purple_version_strcmp(version, XML_VERSION) > 0)
+		purple_debug_warning("smiley", "%s on disk is for a newer version of "
+				"libpurple", XML_FILE_NAME);
+
 	/* See the top comments above to understand why initial tag elements
 	 * are not being considered by now. */
 	profile_node = purple_xmlnode_get_child(root_node, XML_PROFILE_TAG);



More information about the Commits mailing list