summaryrefslogtreecommitdiff
path: root/glib/dbus-gobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'glib/dbus-gobject.c')
-rw-r--r--glib/dbus-gobject.c89
1 files changed, 32 insertions, 57 deletions
diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c
index b0f6c139..6e65770f 100644
--- a/glib/dbus-gobject.c
+++ b/glib/dbus-gobject.c
@@ -24,6 +24,7 @@
#include <config.h>
#include "dbus-glib.h"
#include "dbus-gtest.h"
+#include "dbus-gutils.h"
#include <string.h>
/**
@@ -102,6 +103,7 @@ gobject_unregister_function (DBusConnection *connection,
object = G_OBJECT (user_data);
+ /* FIXME */
}
@@ -187,6 +189,15 @@ handle_introspect (DBusConnection *connection,
unsigned int i;
GType last_type;
DBusMessage *ret;
+ char **path;
+ char **children;
+
+ if (!dbus_message_get_path_decomposed (message, &path))
+ g_error ("Out of memory");
+
+ if (!dbus_connection_list_registered (connection, (const char**) path,
+ &children))
+ g_error ("Out of memory");
xml = g_string_new (NULL);
@@ -268,13 +279,23 @@ handle_introspect (DBusConnection *connection,
g_free (specs);
+ /* Append child nodes */
+
+ i = 0;
+ while (children[i])
+ {
+ g_string_append_printf (xml, " <node name=\"%s\"/>\n",
+ children[i]);
+ ++i;
+ }
+
/* Close the XML, and send it to the requesting app */
g_string_append (xml, "</node>\n");
ret = dbus_message_new_method_return (message);
if (ret == NULL)
- g_error ("out of memory");
+ g_error ("Out of memory");
dbus_message_append_args (message,
DBUS_TYPE_STRING, xml->str,
@@ -285,6 +306,9 @@ handle_introspect (DBusConnection *connection,
g_string_free (xml, TRUE);
+ dbus_free_string_array (path);
+ dbus_free_string_array (children);
+
return DBUS_HANDLER_RESULT_HANDLED;
}
@@ -642,15 +666,15 @@ static DBusObjectPathVTable gobject_dbus_vtable = {
* class_init() for the object class.
*
* Once introspection information has been installed, instances of the
- * object registered with dbus_connection_register_gobject() can have
+ * object registered with dbus_connection_register_g_object() can have
* their methods invoked remotely.
*
* @param object_class class struct of the object
* @param info introspection data generated by dbus-glib-tool
*/
void
-dbus_gobject_class_install_info (GObjectClass *object_class,
- const DBusGObjectInfo *info)
+dbus_g_object_class_install_info (GObjectClass *object_class,
+ const DBusGObjectInfo *info)
{
g_return_if_fail (G_IS_OBJECT_CLASS (object_class));
@@ -666,55 +690,6 @@ dbus_gobject_class_install_info (GObjectClass *object_class,
g_static_mutex_unlock (&info_hash_mutex);
}
-static char**
-split_path (const char *path)
-{
- int len;
- char **split;
- int n_components;
- int i, j, comp;
-
- len = strlen (path);
-
- n_components = 0;
- i = 0;
- while (i < len)
- {
- if (path[i] == '/')
- n_components += 1;
- ++i;
- }
-
- split = g_new0 (char*, n_components + 1);
-
- comp = 0;
- i = 0;
- while (i < len)
- {
- if (path[i] == '/')
- ++i;
- j = i;
-
- while (j < len && path[j] != '/')
- ++j;
-
- /* Now [i, j) is the path component */
- g_assert (i < j);
- g_assert (path[i] != '/');
- g_assert (j == len || path[j] == '/');
-
- split[comp] = g_strndup (&path[i], j - i + 1);
-
- split[comp][j-i] = '\0';
-
- ++comp;
- i = j;
- }
- g_assert (i == len);
-
- return split;
-}
-
/**
* Registers a GObject at the given path. Properties, methods, and signals
* of the object can then be accessed remotely. Methods are only available
@@ -729,9 +704,9 @@ split_path (const char *path)
* @param object the object
*/
void
-dbus_connection_register_gobject (DBusConnection *connection,
- const char *at_path,
- GObject *object)
+dbus_connection_register_g_object (DBusConnection *connection,
+ const char *at_path,
+ GObject *object)
{
char **split;
@@ -739,7 +714,7 @@ dbus_connection_register_gobject (DBusConnection *connection,
g_return_if_fail (at_path != NULL);
g_return_if_fail (G_IS_OBJECT (object));
- split = split_path (at_path);
+ split = _dbus_gutils_split_path (at_path);
if (!dbus_connection_register_object_path (connection,
(const char**) split,