From bde7e27a7b972017f16ebf40ad173896d22bec25 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 13:30:31 -0500 Subject: Whoa, it like builds and stuff --- libindicate/listener.c | 61 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 6 deletions(-) (limited to 'libindicate') diff --git a/libindicate/listener.c b/libindicate/listener.c index b647f0a..6613e3d 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -27,6 +27,9 @@ License version 3 and version 2.1 along with this program. If not, see */ +#include +#include + #include "listener.h" #include "listener-marshal.h" #include @@ -89,6 +92,7 @@ typedef struct { gchar * type; IndicateListener * listener; GHashTable * indicators; + guint introspect_level; IndicateListenerServer server; } proxy_t; @@ -1046,17 +1050,29 @@ indicate_listener_indicator_get_gtype (void) return our_type; } -static const gchar * _introspector_path[] = ["", "org", "freedesktop", "indicate", NULL]; +static const gchar * _introspector_path[] = {"", "org", "freedesktop", "indicate", NULL}; +static const gchar * _introspector_fullpath[] = {"/", "/org", "/org/freedesktop", "/org/freedesktop/indicate", NULL}; static const gchar * _introspector_interface = "org.freedesktop.indicator"; -void -introspect_this (gchar * xml, IndicateServer * server) +static void +introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data) { - if (xml != NULL) { + g_debug("Introspect this:\n%s", OUT_data); + proxy_t * server = (proxy_t *)data; + if (OUT_data != NULL) { + xmlDocPtr xmldoc; /* Parse the XML */ + xmldoc = xmlReadMemory(OUT_data, g_utf8_strlen(OUT_data, 16*1024), "introspection.xml", NULL, 0); /* Check for root being "node" */ + xmlNodePtr root = xmlDocGetRootElement(xmldoc); + if (g_strcmp(root->name, "node") != 0) { + xmlFreeDoc(xmldoc); + g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data); + return; + } + server->introspect_level += 1; const gchar * nodename = NULL; const gchar * nameval = NULL; if (_introspector_path[server->introspect_level] == NULL) { @@ -1069,11 +1085,44 @@ introspect_this (gchar * xml, IndicateServer * server) nameval = _introspector_path[server->introspect_level]; } + gboolean found = FALSE; + xmlNodePtr children; + for (children = root->children; children != NULL; children = children->next) { + gchar * xmlnameval = NULL; + if (g_strcmp0(children->name, nodename) == 0) { + xmlAttrPtr attrib; + for (attrib = children->properties; attrib != NULL; attrib = attrib->next) { + if (g_strcmp0(attrib->name, "name") == 0) { + if (attrib->children != NULL) { + xmlnameval = attrib->children->content; + } + break; + } + } + + if (!g_strcmp0(nameval, xmlnameval)) { + found = TRUE; + break; + } + } + } + + xmlFreeDoc(xmldoc); + + if (!found) { + /* Ah, nothing we're interested in */ + return; + } } else { server->introspect_level = 0; } - dbus_proxy_create(); - dbus_proxy_call(intropsect_this); + DBusGProxy * newproxy = dbus_g_proxy_new_for_name(server->connection, + server->name, + _introspector_fullpath[server->introspect_level], + DBUS_INTERFACE_INTROSPECTABLE); + org_freedesktop_DBus_Introspectable_introspect_async(newproxy, introspect_this, server); + + return; } -- cgit v1.2.3