Update the dbus test.
[mmediamanager.git] / test / clients / test-dbus.c
blobce902bc0c42dbce196229d943f45c7f2d4f46eed
1 #include <glib.h>
2 #include <glib-object.h>
3 #include <dbus/dbus-glib.h>
5 int main (int argc, char **argv)
7 DBusGProxy *proxy;
8 DBusGConnection *connection;
9 GError *error = NULL;
10 char **applications;
11 char *app;
12 int i;
14 g_type_init ();
15 g_thread_init (NULL);
16 dbus_g_thread_init ();
18 connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
19 if (!connection) {
20 g_warning ("Error getting connection to the bus");
21 g_error_free (error);
22 return 0;
24 proxy = dbus_g_proxy_new_for_name (connection,
25 "org.gnome.MediaManager",
26 "/org/gnome/MediaManager/Manager",
27 "org.gnome.MediaManager.Manager");
28 if (!proxy) {
29 g_warning ("Error creating proxy");
30 g_error_free (error);
31 return 0;
34 dbus_g_proxy_call (proxy, "RegisterApp", &error,
35 G_TYPE_STRING, "org.Foo.Bar",
36 G_TYPE_INVALID, G_TYPE_INVALID);
37 if (error) {
38 g_warning ("Error calling RegisterApp: %s", error->message);
39 g_error_free (error);
40 error = NULL;
43 dbus_g_proxy_call (proxy, "GetRegisteredApps", &error,
44 G_TYPE_INVALID, G_TYPE_STRV, &applications,
45 G_TYPE_INVALID);
46 if (!applications) {
47 g_print ("no reg apps\n");
48 } else {
49 for (i = 0; i < G_N_ELEMENTS (applications); i++) {
50 app = applications [i];
51 g_print ("reg app: %s\n", app);
54 return 0;