1 /* -*- mode: C; c-file-style: "gnu" -*- */
8 main (int argc, char **argv)
10 DBusConnection *connection;
14 DBusPendingCall *call;
21 loop = g_main_loop_new (NULL, FALSE);
24 connection = dbus_bus_get_with_g_main (DBUS_BUS_SESSION,
26 if (connection == NULL)
28 g_printerr ("Failed to open connection to bus: %s\n",
34 /* Create a proxy object for the "bus driver" */
36 driver = dbus_gproxy_new_for_service (connection,
37 DBUS_SERVICE_ORG_FREEDESKTOP_DBUS,
38 DBUS_PATH_ORG_FREEDESKTOP_DBUS,
39 DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS);
41 /* Call ListServices method */
43 call = dbus_gproxy_begin_call (driver, "ListServices", DBUS_TYPE_INVALID);
46 if (!dbus_gproxy_end_call (driver, call, &error,
47 DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
48 &service_list, &service_list_len,
51 g_printerr ("Failed to complete ListServices call: %s\n",
57 g_print ("Services on the message bus:\n");
59 while (i < service_list_len)
61 g_assert (service_list[i] != NULL);
62 g_print (" %s\n", service_list[i]);
65 g_assert (service_list[i] == NULL);
67 dbus_free_string_array (service_list);
69 g_object_unref (G_OBJECT (driver));
71 g_print ("Successfully completed %s\n", argv[0]);