Add introspection interface to the output of introspection calls
[framework/connectivity/connman.git] / gdbus / object.c
index 0786aeb..811c2e1 100644 (file)
@@ -155,7 +155,13 @@ static void generate_introspection_xml(DBusConnection *conn,
 
        gstr = g_string_new(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE);
 
-       g_string_append_printf(gstr, "<node name=\"%s\">\n", path);
+       g_string_append_printf(gstr,
+               "<node name=\"%s\">\n"
+               "\t<interface name=\"org.freedesktop.DBus.Introspectable\">\n"
+               "\t\t<method name=\"Introspect\">\n"
+               "\t\t\t<arg name=\"xml_data\" type=\"s\" direction=\"out\"/>\n"
+               "\t\t</method>\n"
+               "\t</interface>\n", path);
 
        for (list = data->interfaces; list; list = list->next) {
                struct interface_data *iface = list->data;
@@ -224,6 +230,9 @@ static struct interface_data *find_interface(GSList *interfaces,
 {
        GSList *list;
 
+       if (!name)
+               return NULL;
+
        for (list = interfaces; list; list = list->next) {
                struct interface_data *iface = list->data;
                if (!strcmp(name, iface->name))
@@ -304,7 +313,11 @@ static void invalidate_parent_data(DBusConnection *conn, const char *child_path)
        if (!slash)
                goto done;
 
-       *slash = '\0';
+       if (slash == parent_path && parent_path[1] != '\0')
+               parent_path[1] = '\0';
+       else
+               *slash = '\0';
+
        if (!strlen(parent_path))
                goto done;
 
@@ -391,7 +404,6 @@ static gboolean check_signal(DBusConnection *conn, const char *path,
        }
 
        iface = find_interface(data->interfaces, interface);
-
        if (!iface) {
                error("dbus_connection_emit_signal: %s does not implement %s",
                                path, interface);