-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-client.c
97 lines (78 loc) · 2.27 KB
/
test-client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
* test-client.c
*
* Created on: 03-11-2008
* Author: christian
*/
#include <dbus/dbus-glib.h>
#include <stdio.h>
#include <stdlib.h>
static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
static void
lose (const char *str, ...)
{
va_list args;
va_start (args, str);
vfprintf (stderr, str, args);
fputc ('\n', stderr);
va_end (args);
exit (1);
}
static void
lose_gerror (const char *prefix, GError *error)
{
lose ("%s: %s", prefix, error->message);
}
static void
print_hash_value (gpointer key, gpointer val, gpointer data)
{
printf ("%s -> %s\n", (char *) key, (char *) val);
}
int
main (int argc, char **argv)
{
DBusGConnection *bus;
DBusGProxy *remote_object_introspectable;
DBusGProxy *remote_object_xanguli;
GError *error = NULL;
char **reply_list;
char **reply_ptr;
GValueArray *hello_reply_struct;
GHashTable *hello_reply_dict;
char *introspect_data;
char *path;
guint i;
g_type_init ();
{
GLogLevelFlags fatal_mask;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
}
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (!bus)
lose_gerror ("Couldn't connect to session bus", error);
remote_object_introspectable = dbus_g_proxy_new_for_name (bus,
"org.xanguli.Service",
"/Xanguli",
"org.freedesktop.DBus.Introspectable");
if (!dbus_g_proxy_call (remote_object_introspectable, "Introspect", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &introspect_data, G_TYPE_INVALID))
lose_gerror ("Failed to complete Introspect", error);
printf ("%s", introspect_data);
g_free (introspect_data);
g_object_unref (G_OBJECT (remote_object_introspectable));
remote_object_xanguli = dbus_g_proxy_new_for_name (bus,
"org.xanguli.Service",
"/Xanguli",
"org.xanguli.Xanguli");
if (!dbus_g_proxy_call (remote_object_xanguli, "CreateController", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &path, G_TYPE_INVALID))
lose_gerror ("Failed to complete CreateController", error);
printf ("%s", path);
g_free (path);
exit(0);
}