From 20836b86feb5aad4c938a4af26e57f544e75a69c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 10 Apr 2009 15:51:26 -0500 Subject: Adding in libxml linking --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 15e4110..ca46ff9 100644 --- a/configure.ac +++ b/configure.ac @@ -50,11 +50,13 @@ AM_GCONF_SOURCE_2 GLIB_REQUIRED_VERSION=2.18 GIO_REQUIRED_VERSION=2.18 GDK_PIXBUF_REQUIRED_VERSION=2.12 +XML_REQUIRED_VERSION=2.6 PKG_CHECK_MODULES(LIBINDICATE, glib-2.0 >= $GLIB_REQUIRED_VERSION gio-2.0 >= $GIO_REQUIRED_VERSION gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED_VERSION - dbus-glib-1 >= $DBUS_REQUIRED_VERSION) + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) AC_SUBST(LIBINDICATE_CFLAGS) AC_SUBST(LIBINDICATE_LIBS) -- cgit v1.2.3 From ce664599c72dcb80f9e0427a2a49fc3c26fb79c8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 12 Apr 2009 21:41:48 -0500 Subject: Proto-pseudo-code for the introspection functions that are going to be needed --- libindicate/listener.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index 0646e81..8ae3973 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1046,3 +1046,34 @@ indicate_listener_indicator_get_gtype (void) return our_type; } +static const gchar * _introspector_path[] = ["", "org", "freedesktop", "indicate", NULL]; +static const gchar * _introspector_interface = "org.freedesktop.indicator"; + +void +introspect_this (gchar * xml, IndicateServer * server) +{ + if (xml != NULL) { + /* Parse the XML */ + + /* Check for root being "node" */ + + const gchar * nodename = NULL; + const gchar * nameval = NULL; + if (_introspector_path[server->introspect_level] == NULL) { + /* We're looking for our interface */ + nodename = "interface"; + nameval = _introspector_interface; + } else { + /* We're looking for our next node */ + nodename = "node"; + nameval = _introspector_path[server->introspect_level]; + } + + } else { + server->introspect_level = 0; + } + + dbus_proxy_create(); + dbus_proxy_call(intropsect_this); + +} -- cgit v1.2.3 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(-) 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 From 24e268d166ef026a3f1c4e7b09ae13d15bf427eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:07:46 -0500 Subject: Fleshing out some --- libindicate/listener.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libindicate/listener.c b/libindicate/listener.c index 6613e3d..420d8cd 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1059,6 +1059,16 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d { g_debug("Introspect this:\n%s", OUT_data); proxy_t * server = (proxy_t *)data; + if (proxy != NULL) { + g_object_unref(proxy); + } + if (error != NULL) { + /* We probably couldn't introspect that far up. That's + life, it happens. */ + g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); + return; + } + if (OUT_data != NULL) { xmlDocPtr xmldoc; /* Parse the XML */ -- cgit v1.2.3 From dec69be399365590e8bc5140f470aafd805ff17d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:15:01 -0500 Subject: Okay, connected into that other there code... let's see what happens. --- libindicate/listener.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 420d8cd..fd35d66 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -133,6 +133,7 @@ static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data); static void proxy_get_indicator_type (DBusGProxy * proxy, gchar * type, GError * error, gpointer data); static void proxy_indicators_free (gpointer data); +static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data); /* DBus interface */ gboolean _indicate_listener_get_indicator_servers (IndicateListener * listener, GList * servers); @@ -502,13 +503,9 @@ todo_idle (gpointer data) priv->proxies_possible = g_list_prepend(priv->proxies_possible, proxyt); - /* I think that we need to have this as there is a race - * condition here. If someone comes on the bus and we get - * that message, but before we set up the handler for the ServerShow - * signal it gets sent, we wouldn't get it. So then we would - * miss an indicator server coming on the bus. I'd like to not - * generate a warning in every app with DBus though. */ - indicate_listener_server_get_type(listener, &proxyt->server, get_type_cb, proxyt); + /* Look through the introspection data to see if this + is already a server */ + introspect_this (NULL, NULL, NULL, proxyt); return TRUE; } @@ -1123,6 +1120,13 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d /* Ah, nothing we're interested in */ return; } + + if (_introspector_path[server->introspect_level] == NULL) { + /* If we've found the interface at the end of the tree, whoo! hoo! */ + /* Now we know it's safe to get the type on it */ + indicate_listener_server_get_type(server->listener, &server->server, get_type_cb, server); + return; + } } else { server->introspect_level = 0; } -- cgit v1.2.3 From 135906b4b250f8c5be3a1a157d77c689313f381a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:16:25 -0500 Subject: Ah, a typo. Bother. --- libindicate/listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index fd35d66..5ae3e09 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1073,7 +1073,7 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d /* Check for root being "node" */ xmlNodePtr root = xmlDocGetRootElement(xmldoc); - if (g_strcmp(root->name, "node") != 0) { + if (g_strcmp0(root->name, "node") != 0) { xmlFreeDoc(xmldoc); g_warning("Introspection data from %s is not valid: %s", server->name, OUT_data); return; -- cgit v1.2.3 From 46a050c2eac7bc12566339cbdea6bdb3376ccecf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:41:33 -0500 Subject: Less debug --- libindicate/listener.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 5ae3e09..20a3278 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1054,7 +1054,7 @@ static const gchar * _introspector_interface = "org.freedesktop.indicator"; static void introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer data) { - g_debug("Introspect this:\n%s", OUT_data); + /* g_debug("Introspect this:\n%s", OUT_data); */ proxy_t * server = (proxy_t *)data; if (proxy != NULL) { g_object_unref(proxy); -- cgit v1.2.3 From e32b37d049968231cb19129654fd3be997efb48b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Apr 2009 14:47:35 -0500 Subject: Commenting out some debug messages --- libindicate/listener.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libindicate/listener.c b/libindicate/listener.c index 20a3278..a314ea8 100644 --- a/libindicate/listener.c +++ b/libindicate/listener.c @@ -1061,8 +1061,9 @@ introspect_this (DBusGProxy * proxy, char * OUT_data, GError * error, gpointer d } if (error != NULL) { /* We probably couldn't introspect that far up. That's - life, it happens. */ - g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); + life, it happens. Or there's a timeout, that happens + too, I guess some apps are too busy for us. */ + /* g_debug("Introspection error on %s object %s: %s", server->name, _introspector_fullpath[server->introspect_level], error->message); */ return; } -- cgit v1.2.3