GHashTable *methods;
GHashTable *properties;
+ DRouteIntrospectChildrenFunction introspect_children_cb;
+ void *introspect_children_data;
void *user_data;
DRouteGetDatumFunction get_datum;
};
static DRoutePath *
path_new (DRouteContext *cnx,
void *user_data,
+ DRouteIntrospectChildrenFunction introspect_children_cb,
+ void *introspect_children_data,
DRouteGetDatumFunction get_datum)
{
DRoutePath *new_path;
g_free,
NULL);
+ new_path->introspect_children_cb = introspect_children_cb;
+ new_path->introspect_children_data = introspect_children_data;
new_path->user_data = user_data;
new_path->get_datum = get_datum;
DRoutePath *new_path;
gboolean registered;
- new_path = path_new (cnx, (void *) data, NULL);
+ new_path = path_new (cnx, (void *)data, NULL, NULL, NULL);
registered = dbus_connection_register_object_path (cnx->bus, path, &droute_vtable, new_path);
if (!registered)
- oom();
+ {
+ path_free (new_path, NULL);
+ return NULL;
+ }
g_ptr_array_add (cnx->registered_paths, new_path);
return new_path;
droute_add_many (DRouteContext *cnx,
const char *path,
const void *data,
+ DRouteIntrospectChildrenFunction introspect_children_cb,
+ void *introspect_children_data,
const DRouteGetDatumFunction get_datum)
{
DRoutePath *new_path;
- new_path = path_new (cnx, (void *) data, get_datum);
+ new_path = path_new (cnx, (void *) data, introspect_children_cb, introspect_children_data, get_datum);
if (!dbus_connection_register_fallback (cnx->bus, path, &droute_vtable, new_path))
oom();
(&iter_dict, DBUS_TYPE_DICT_ENTRY, NULL, &iter_dict_entry))
oom ();
dbus_message_iter_append_basic (&iter_dict_entry, DBUS_TYPE_STRING,
- key->two);
+ &key->two);
(value->get) (&iter_dict_entry, datum);
if (!dbus_message_iter_close_container (&iter_dict, &iter_dict_entry))
oom ();
g_string_append_printf(output, introspection_node_element, pathstr);
- for (i=0; i < path->introspection->len; i++)
+ if (!path->get_datum || path_get_datum (path, pathstr))
+ {
+ for (i=0; i < path->introspection->len; i++)
+ {
+ gchar *introspect = (gchar *) g_ptr_array_index (path->introspection, i);
+ g_string_append (output, introspect);
+ }
+ }
+
+ if (path->introspect_children_cb)
{
- gchar *introspect = (gchar *) g_ptr_array_index (path->introspection, i);
- g_string_append (output, introspect);
+ gchar *children = (*path->introspect_children_cb) (pathstr, path->introspect_children_data);
+ if (children)
+ {
+ g_string_append (output, children);
+ g_free (children);
+ }
}
g_string_append(output, introspection_footer);