/soc/2015/koosha/main: b1a13e0b7296: xmlnode.c: introduce two fu...

Koosha Khajehmoogahi <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: b1a13e0b72967bf4133883f0bba2e6e3f7472ec9
Author:	 Koosha Khajehmoogahi <[email protected]>
Date:	 2015-08-10 02:00 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/koosha/main/rev/b1a13e0b7296

Description:

xmlnode.c: introduce two functions for checking boolean attributes

diffstat:

 libpurple/protocols/jabber/jabber.c |   2 +-
 libpurple/xmlnode.c                 |   9 +++++++++
 libpurple/xmlnode.h                 |  16 ++++++++++++++++
 3 files changed, 26 insertions(+), 1 deletions(-)

diffs (57 lines):

diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -359,7 +359,7 @@ void jabber_stream_management_parse(Jabb
 	resume = purple_xmlnode_get_attrib(packet, "resume");
 	account = purple_connection_get_account(js->gc);
 
-	resume_enabled = resume && (purple_strequal(resume, "1") || purple_strequal(resume, "true"));
+	resume_enabled = resume && purple_xmlnode_is_attrib_true(resume);
 
 	purple_debug_info( "jabber", "Stream management %s resumption is enabled.\n",
 				resume_enabled ? "with" : "without" );
diff --git a/libpurple/xmlnode.c b/libpurple/xmlnode.c
--- a/libpurple/xmlnode.c
+++ b/libpurple/xmlnode.c
@@ -255,6 +255,15 @@ purple_xmlnode_get_attrib_with_namespace
 	return NULL;
 }
 
+gboolean purple_xmlnode_is_attrib_true(const char *attr)
+{
+	return (!g_ascii_strcasecmp(attr, "true") || !g_ascii_strcasecmp(attr, "1"));
+}
+
+gboolean purple_xmlnode_is_attrib_false(const char *attr)
+{
+	return !g_ascii_strcasecmp(attr, "false") || !g_ascii_strcasecmp(attr, "0");
+}
 
 void purple_xmlnode_set_namespace(PurpleXmlNode *node, const char *xmlns)
 {
diff --git a/libpurple/xmlnode.h b/libpurple/xmlnode.h
--- a/libpurple/xmlnode.h
+++ b/libpurple/xmlnode.h
@@ -242,6 +242,22 @@ const char *purple_xmlnode_get_attrib_wi
 void purple_xmlnode_remove_attrib(PurpleXmlNode *node, const char *attr);
 
 /**
+ * purple_xmlnode_is_attrib_true:
+ * @attrib: The attribute to check.
+ *
+ * Checks whether the given attribute has true value ("1" or "true")
+ */
+gboolean purple_xmlnode_is_attrib_true(const char *attrib);
+
+/**
+ * purple_xmlnode_is_attrib_false:
+ * @attrib: The attribute to check.
+ *
+ * Checks whether the given attribute has false value ("0" or "false")
+ */
+gboolean purple_xmlnode_is_attrib_false(const char *attrib);
+
+/**
  * purple_xmlnode_remove_attrib_with_namespace:
  * @node:  The node to remove an attribute from
  * @attr:  The attribute to remove

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.