aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-09-21 15:29:39 -0500
committerTed Gould <ted@canonical.com>2009-09-21 15:29:39 -0500
commit0e09fe611584c9af4e5e91c8c0858fc58eaf991e (patch)
tree008abd1dcbf4480097f568153e27b2b2f059be5a /libdbusmenu-glib/client.c
parent3d18c3ba52732b35324069ac1bae45f481493510 (diff)
downloadlibdbusmenu-0e09fe611584c9af4e5e91c8c0858fc58eaf991e.tar.gz
libdbusmenu-0e09fe611584c9af4e5e91c8c0858fc58eaf991e.tar.bz2
libdbusmenu-0e09fe611584c9af4e5e91c8c0858fc58eaf991e.zip
Getting the revision data off of the root node there.
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r--libdbusmenu-glib/client.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index d4582a9..4e11359 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -492,6 +492,34 @@ build_proxies (DbusmenuClient * client)
return;
}
+/* Get the "revision" attribute of the node, parse it and
+ return it. Also we're checking to ensure the node
+ is a 'menu' here. */
+static gint
+parse_node_get_revision (xmlNodePtr node)
+{
+ if (g_strcmp0((gchar *)node->name, "menu") != 0) {
+ /* This kills some nodes early */
+ g_warning("XML Node is not 'menu' it is '%s'", node->name);
+ return 0;
+ }
+
+ xmlAttrPtr attrib;
+ for (attrib = node->properties; attrib != NULL; attrib = attrib->next) {
+ if (g_strcmp0((gchar *)attrib->name, "revision") == 0) {
+ if (attrib->children != NULL) {
+ guint revision = (guint)g_ascii_strtoull((gchar *)attrib->children->content, NULL, 10);
+ /* g_debug ("Found ID: %d", id); */
+ return revision;
+ }
+ break;
+ }
+ }
+
+ g_warning("Unable to find a revision on the node");
+ return 0;
+}
+
/* Get the ID attribute of the node, parse it and
return it. Also we're checking to ensure the node
is a 'menu' here. */
@@ -691,6 +719,7 @@ parse_layout (DbusmenuClient * client, const gchar * layout)
xmldoc = xmlReadMemory(layout, g_utf8_strlen(layout, 16*1024), "dbusmenu.xml", NULL, 0);
xmlNodePtr root = xmlDocGetRootElement(xmldoc);
+ gint revision = parse_node_get_revision(root);
DbusmenuMenuitem * oldroot = priv->root;
priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy);
@@ -704,7 +733,7 @@ parse_layout (DbusmenuClient * client, const gchar * layout)
g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE);
}
- return 1;
+ return revision;
}
/* When the layout property returns, here's where we take care of that. */