From ee312ea00e1f43ef6041df9b95e0ea2b1fa8dd82 Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Thu, 24 Apr 2008 18:42:59 -0400 Subject: [PATCH] Correct case of DBus in interface name When introspecting, free the dautm if needed, only call introspect_children if it is not NULL, fix args, only print arg names if a name is present, and close tags --- libspi/droute.c | 58 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/libspi/droute.c b/libspi/droute.c index 514bfa6..a5052fa 100644 --- a/libspi/droute.c +++ b/libspi/droute.c @@ -149,6 +149,7 @@ introspect (DBusConnection * bus, DBusMessage * message, DRouteData * data) char *str; DBusMessage *reply; GSList *l; + void *datum; if (strcmp (dbus_message_get_member (message), "Introspect")) { @@ -157,6 +158,7 @@ introspect (DBusConnection * bus, DBusMessage * message, DRouteData * data) xml = g_string_new (NULL); /* below code stolen from dbus-glib */ g_string_append (xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE); + g_string_append_printf (xml, "\n", path); /* We are introspectable, though I guess that was pretty obvious */ g_string_append_printf (xml, " \n", @@ -207,13 +209,13 @@ introspect (DBusConnection * bus, DBusMessage * message, DRouteData * data) g_string_append (xml, " \n"); g_string_append (xml, " \n"); - g_string_append_printf (xml, "\n", path); /* end of stolen code */ for (l = data->interfaces; l; l = g_slist_next (l)) { iface_def = (DRouteInterface *) l->data; - if (!(*iface_def->get_datum) (path, data->user_data)) + datum = (*iface_def->get_datum) (path, data->user_data); + if (!datum) continue; g_string_append_printf (xml, "\n", iface_def->name); @@ -225,21 +227,30 @@ introspect (DBusConnection * bus, DBusMessage * message, DRouteData * data) (method->type == DROUTE_METHOD ? "method" : "signal"), method->name); - g_string_append (xml, "\n", - (*p == 'o' ? "out" : "in")); - p += strcspn (p, ":"); - if (*p == ':') - p++; + while (*p) + { + g_string_append (xml, " 0) + { + g_string_append (xml, "\" name=\""); + g_string_append_len (xml, p, strcspn (p, ",:")); + p += strcspn (p, ","); + } + if (*p == ',') + p++; + g_string_append_printf (xml, "\" direction=\"%s\"/>\n", + (*p == 'o' ? "out" : "in")); + p += strcspn (p, ":"); + if (*p == ':') + p++; + } + g_string_append_printf (xml, "\n", + (method->type == + DROUTE_METHOD ? "method" : "signal")); } if (iface_def->properties) for (property = iface_def->properties; property->name; property++) @@ -252,8 +263,15 @@ introspect (DBusConnection * bus, DBusMessage * message, DRouteData * data) (property->get ? "read" : ""), (property->set ? "write" : "")); } + if (iface_def->free_datum) + (*iface_def->free_datum) (datum); + g_string_append (xml, "\n"); + } + if (data->introspect_children) + { + (*data->introspect_children) (path, xml, data->user_data); } - (*data->introspect_children) (path, xml, data->user_data); + g_string_append (xml, "\n"); str = g_string_free (xml, FALSE); reply = dbus_message_new_method_return (message); if (reply) @@ -282,13 +300,13 @@ droute_message (DBusConnection * bus, DBusMessage * message, void *user_data) dbus_error_init (&error); if (!member) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - if (iface && !strcmp (iface, "org.freedesktop.dbus.Properties")) + if (iface && !strcmp (iface, "org.freedesktop.DBus.Properties")) { if (!strcmp (member, "GetAll")) return prop_get_all (bus, message, data); return prop (bus, message, data); } - else if (iface && !strcmp (iface, "org.freedesktop.dbus.Introspectable")) + else if (iface && !strcmp (iface, "org.freedesktop.DBus.Introspectable")) { return introspect (bus, message, data); } -- 2.7.4