Mercurial > pidgin
diff libgaim/xmlnode.c @ 15203:f814b2df9cce
[gaim-migrate @ 17993]
Blocking on Google Talk. Our Privacy API sucks so bad that even with no prior support for blocking in Jabber, this has no interface changes. If someone wanted to implement the deprecated Jabber privacy lists API, though, that would be ok by me.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Thu, 14 Dec 2006 04:56:54 +0000 |
| parents | 50f263712df1 |
| children | c65def04fb44 |
line wrap: on
line diff
--- a/libgaim/xmlnode.c Thu Dec 14 04:17:02 2006 +0000 +++ b/libgaim/xmlnode.c Thu Dec 14 04:56:54 2006 +0000 @@ -142,6 +142,34 @@ } } + +void +xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) +{ + xmlnode *attr_node, *sibling = NULL; + + g_return_if_fail(node != NULL); + g_return_if_fail(attr != NULL); + + for(attr_node = node->child; attr_node; attr_node = attr_node->next) + { + if(attr_node->type == XMLNODE_TYPE_ATTRIB && + !strcmp(attr_node->name, attr) && + !strcmp(attr_node->xmlns, xmlns)) { + if(node->child == attr_node) { + node->child = attr_node->next; + } else if (node->lastchild == attr_node) { + node->lastchild = sibling; + } else { + sibling->next = attr_node->next; + } + xmlnode_free(attr_node); + return; + } + sibling = attr_node; + } +} + void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value) { @@ -160,6 +188,25 @@ xmlnode_insert_child(node, attrib_node); } +void +xmlnode_set_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns, 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_with_namespace(node, attr, xmlns); + + attrib_node = new_node(attr, XMLNODE_TYPE_ATTRIB); + + attrib_node->data = g_strdup(value); + attrib_node->xmlns = g_strdup(xmlns); + + xmlnode_insert_child(node, attrib_node); +} + const char * xmlnode_get_attrib(xmlnode *node, const char *attr) { @@ -176,6 +223,23 @@ return NULL; } +const char * +xmlnode_get_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) +{ + xmlnode *x; + + g_return_val_if_fail(node != NULL, NULL); + + for(x = node->child; x; x = x->next) { + if(x->type == XMLNODE_TYPE_ATTRIB && + !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { + return x->data; + } + } + + return NULL; +} + void xmlnode_set_namespace(xmlnode *node, const char *xmlns) {
