Tue, 12 Jun 2018 11:14:16 +0200
adds attribute for tagfilter scope
dav/scfg.c | file | annotate | diff | comparison | revisions |
--- a/dav/scfg.c Mon Jun 11 19:32:41 2018 +0200 +++ b/dav/scfg.c Tue Jun 12 11:14:16 2018 +0200 @@ -121,6 +121,24 @@ "malformed tag filter: %s\n", value); return 1; + } else { + // get scope + xmlChar *scope = xmlGetNoNsProp(node, "scope"); + if(scope) { + if(xstreq(scope, "resource")) + { + (*tagfilter)->scope = + DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; + } else if(xstreq(scope, "collection")) { + (*tagfilter)->scope = + DAV_SYNC_TAGFILTER_SCOPE_COLLECTION; + } else if(xstreq(scope, "all")) { + (*tagfilter)->scope = + DAV_SYNC_TAGFILTER_SCOPE_RESOURCE + | DAV_SYNC_TAGFILTER_SCOPE_COLLECTION; + } + } + xmlFree(scope); } } } else { @@ -141,18 +159,6 @@ return 0; } - -static char* get_attr_content(xmlNode *node) { - // TODO: remove code duplication (util_xml_get_text) and config.h - while(node) { - if(node->type == XML_TEXT_NODE) { - return (char*)node->content; - } - node = node->next; - } - return NULL; -} - static TagFormat str2tagformat(const char *str) { if(!strcmp(str, "text")) { return TAG_FORMAT_TEXT; @@ -190,17 +196,10 @@ } xmlAttr *attr = c->properties; - while(attr) { - if(attr->type == XML_ATTRIBUTE_NODE) { - const char *value = get_attr_content(attr->children); - if(!value) { - break; - } - if(xstreq(attr->name, "format")) { - conf.local_format = str2tagformat(value); - } - } - attr = attr->next; + xmlChar *format = xmlGetNoNsProp(node, "format"); + if(format) { + conf.local_format = str2tagformat(format); + xmlFree(format); } } else if(xstreq(c->name, "detect-changes")) { if(!value) {