summaryrefslogtreecommitdiff
path: root/src/librygel-ruih
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2014-10-19 14:38:16 +0200
committerJens Georg <mail@jensge.org>2014-11-08 13:20:55 +0100
commit59f22cc74562bf351e485f2c961323297005150f (patch)
treebe220fff79334e1f54cfe017e5b7b9b337691412 /src/librygel-ruih
parentcf5eeb73292099ab6984d86563a711199c8bc109 (diff)
downloadrygel-59f22cc74562bf351e485f2c961323297005150f.tar.gz
core,ruih: Add XML node iterator and use it
Signed-off-by: Jens Georg <mail@jensge.org>
Diffstat (limited to 'src/librygel-ruih')
-rw-r--r--src/librygel-ruih/rygel-ruih-icon-elem.vala4
-rw-r--r--src/librygel-ruih/rygel-ruih-protocol-elem.vala5
-rw-r--r--src/librygel-ruih/rygel-ruih-servicemanager.vala13
-rw-r--r--src/librygel-ruih/rygel-ruih-ui-elem.vala12
4 files changed, 13 insertions, 21 deletions
diff --git a/src/librygel-ruih/rygel-ruih-icon-elem.vala b/src/librygel-ruih/rygel-ruih-icon-elem.vala
index d30b946a..556fd4cb 100644
--- a/src/librygel-ruih/rygel-ruih-icon-elem.vala
+++ b/src/librygel-ruih/rygel-ruih-icon-elem.vala
@@ -48,7 +48,7 @@ protected class IconElem : UIListing {
throw new Rygel.RuihServiceError.OPERATION_REJECTED ("Unable to parse Icon data - null");
}
// Invalid XML Handling?
- for (Xml.Node* child_node = node->children; child_node != null; child_node = child_node->next) {
+ foreach (var child_node in new Rygel.XMLUtils.ChildIterator (node)) {
if (child_node->type == Xml.ElementType.TEXT_NODE) {
// ignore text nodes
continue;
@@ -107,4 +107,4 @@ protected class IconElem : UIListing {
}
return "";
}
-} \ No newline at end of file
+}
diff --git a/src/librygel-ruih/rygel-ruih-protocol-elem.vala b/src/librygel-ruih/rygel-ruih-protocol-elem.vala
index c5eed142..8de200cc 100644
--- a/src/librygel-ruih/rygel-ruih-protocol-elem.vala
+++ b/src/librygel-ruih/rygel-ruih-protocol-elem.vala
@@ -55,8 +55,7 @@ protected class ProtocolElem : UIListing {
}
}
- for (Xml.Node* child_node = node->children; child_node != null;
- child_node = child_node->next) {
+ foreach (var child_node in new Rygel.XMLUtils.ChildIterator (node)) {
if (child_node->type == Xml.ElementType.TEXT_NODE) {
// ignore text nodes
continue;
@@ -145,4 +144,4 @@ protected class ProtocolElem : UIListing {
}
return sb.str;
}
-} \ No newline at end of file
+}
diff --git a/src/librygel-ruih/rygel-ruih-servicemanager.vala b/src/librygel-ruih/rygel-ruih-servicemanager.vala
index 03ef01a3..8c57c3e6 100644
--- a/src/librygel-ruih/rygel-ruih-servicemanager.vala
+++ b/src/librygel-ruih/rygel-ruih-servicemanager.vala
@@ -120,14 +120,13 @@ public class Rygel.RuihServiceManager : Object
var ui_list_node = doc->get_root_element ();
if (ui_list_node != null && ui_list_node->name == UILIST)
{
- for (var child_node = ui_list_node->children;
- child_node != null;
- child_node = child_node->next) {
- if (child_node->name == UI) {
- this.ui_list.add (new UIElem (child_node));
+ foreach (var node in new XMLUtils.ChildIterator (ui_list_node)) {
+ if (node->name == UI) {
+ this.ui_list.add (new UIElem (node));
}
}
}
+
delete doc;
}
@@ -190,9 +189,7 @@ public class Rygel.RuihServiceManager : Object
return;
}
- for (var child_node = node->children;
- child_node != null;
- child_node = child_node->next) {
+ foreach (var child_node in new XMLUtils.ChildIterator (node)) {
if (child_node->type == Xml.ElementType.TEXT_NODE) {
// ignore text nodes
continue;
diff --git a/src/librygel-ruih/rygel-ruih-ui-elem.vala b/src/librygel-ruih/rygel-ruih-ui-elem.vala
index 3fbefca1..112924e8 100644
--- a/src/librygel-ruih/rygel-ruih-ui-elem.vala
+++ b/src/librygel-ruih/rygel-ruih-ui-elem.vala
@@ -52,9 +52,7 @@ protected class UIElem : UIListing
this.protocols = new ArrayList<ProtocolElem> ();
// invalid XML exception?
- for (Xml.Node* child_node = node->children; child_node != null;
- child_node = child_node->next)
- {
+ foreach (var child_node in new Rygel.XMLUtils.ChildIterator (node)) {
if (child_node->type == Xml.ElementType.TEXT_NODE) {
// ignore text nodes
continue;
@@ -71,11 +69,9 @@ protected class UIElem : UIListing
this.description = child_node->get_content ();
break;
case ICONLIST:
- for (Xml.Node* icon_node = child_node->children;
- icon_node != null; icon_node = icon_node->next)
- {
- if (icon_node->name == ICON)
- {
+ var it = new Rygel.XMLUtils.ChildIterator (child_node);
+ foreach (var icon_node in it) {
+ if (icon_node->name == ICON) {
this.icons.add (new IconElem (icon_node));
}
}