grim/pidgin

b1a13e0b7296
Parents c10fa2e7a6ba
Children db5b4c0dfb74
xmlnode.c: introduce two functions for checking boolean attributes
--- a/libpurple/protocols/jabber/jabber.c Mon Aug 10 01:26:40 2015 +0200
+++ b/libpurple/protocols/jabber/jabber.c Mon Aug 10 02:00:17 2015 +0200
@@ -359,7 +359,7 @@
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" );
--- a/libpurple/xmlnode.c Mon Aug 10 01:26:40 2015 +0200
+++ b/libpurple/xmlnode.c Mon Aug 10 02:00:17 2015 +0200
@@ -255,6 +255,15 @@
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)
{
--- a/libpurple/xmlnode.h Mon Aug 10 01:26:40 2015 +0200
+++ b/libpurple/xmlnode.h Mon Aug 10 02:00:17 2015 +0200
@@ -242,6 +242,22 @@
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