Hi,
I instantiated a GDBusObjectManager that gets information from a dbus service, particularly the "org.bluez" service. I can retrieve the objects using g_dbus_object_manager_get_objects() and I can retrieve the interfaces using g_dbus_object_get_interfaces(), but using g_dbus_interface_get_info() always returns NULL and my program segfaults when trying to retrieve the name. I think I am missing something or doing something wrong.
I attached my source code in this email. The problem occurs at line 24.
Any help and feedback is appreciated.
Thanks,
-Daniel J. Sills
#include <gio/gio.h> #include <stdio.h> #include <stdlib.h> static void print_objects(GDBusObjectManager *manager) { GList *objects; GList *l; g_print("Object manager at %s\n", g_dbus_object_manager_get_object_path(manager)); objects = g_dbus_object_manager_get_objects(manager); for (l = objects; l != NULL; l = l->next) { GDBusObject *object = l->data; GList *interfaces; GList *ll; g_print(" - Object at %s\n", g_dbus_object_get_object_path(G_DBUS_OBJECT(object))); interfaces = g_dbus_object_get_interfaces(G_DBUS_OBJECT(object)); for (ll = interfaces; ll != NULL; ll = ll->next) { GDBusInterface *interface = G_DBUS_INTERFACE(ll->data); g_print(" - Interface %s\n", g_dbus_interface_get_info(interface)->name); // <--- NULL POINTER EXCEPTION HERE } g_list_free_full(interfaces, g_object_unref); } g_list_free_full(objects, g_object_unref); } int main(int argc, char** argv) { GDBusObjectManager *manager; GError *error; gchar *name_owner; manager = NULL; error = NULL; name_owner = NULL; manager = g_dbus_object_manager_client_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, "org.bluez", "/", NULL, NULL, NULL, NULL, &error); if (manager == NULL) { g_printerr("Error getting object manager client: %s", error->message); g_error_free(error); return (EXIT_FAILURE); } name_owner = g_dbus_object_manager_client_get_name_owner(G_DBUS_OBJECT_MANAGER_CLIENT(manager)); g_print("name-owner: %s\n", name_owner); g_free(name_owner); print_objects(manager); g_object_unref(manager); return (EXIT_SUCCESS); }
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list