11241
|
1 #define DBUS_API_SUBJECT_TO_CHANGE
|
|
2
|
|
3 #include <dbus/dbus-glib.h>
|
|
4 #include <stdio.h>
|
|
5 #include <stdlib.h>
|
|
6
|
|
7 #include "dbus-gaim.h"
|
|
8 #include "gaim-client-bindings.h"
|
|
9
|
|
10 static DBusGConnection *bus;
|
|
11 static DBusGProxy *gaim_proxy;
|
|
12
|
14035
|
13 static GList *garray_int_to_glist(GArray *array)
|
|
14 {
|
|
15 GList *list = NULL;
|
|
16 int i;
|
11277
|
17
|
14035
|
18 for (i = 0; i < array->len; i++)
|
|
19 list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
|
11277
|
20
|
14035
|
21 g_array_free(array, TRUE);
|
|
22 return list;
|
11277
|
23 }
|
|
24
|
14035
|
25 static GSList *garray_int_to_gslist(GArray *array)
|
|
26 {
|
|
27 GSList *list = NULL;
|
|
28 int i;
|
11277
|
29
|
14035
|
30 for (i = 0; i < array->len; i++)
|
|
31 list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
|
11277
|
32
|
14035
|
33 g_array_free(array, TRUE);
|
|
34 return list;
|
11277
|
35 }
|
|
36
|
11241
|
37 #include "gaim-client-bindings.c"
|
|
38
|
14035
|
39 static void lose(const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
|
|
40 static void lose_gerror(const char *prefix, GError *error) G_GNUC_NORETURN;
|
11241
|
41
|
|
42 static void
|
14035
|
43 lose(const char *str, ...)
|
11241
|
44 {
|
14035
|
45 va_list args;
|
11241
|
46
|
14035
|
47 va_start(args, str);
|
11241
|
48
|
14035
|
49 vfprintf(stderr, str, args);
|
|
50 fputc('\n', stderr);
|
11241
|
51
|
14035
|
52 va_end(args);
|
11241
|
53
|
14035
|
54 exit(1);
|
11241
|
55 }
|
|
56
|
|
57 static void
|
14035
|
58 lose_gerror(const char *prefix, GError *error)
|
11241
|
59 {
|
14035
|
60 lose("%s: %s", prefix, error->message);
|
11241
|
61 }
|
|
62
|
14035
|
63 void gaim_init(void)
|
|
64 {
|
|
65 GError *error = NULL;
|
11241
|
66
|
14035
|
67 g_type_init ();
|
11241
|
68
|
14035
|
69 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
|
|
70 if (!bus)
|
|
71 lose_gerror ("Couldn't connect to session bus", error);
|
11241
|
72
|
14035
|
73 gaim_proxy = dbus_g_proxy_new_for_name (bus,
|
|
74 DBUS_SERVICE_GAIM,
|
|
75 DBUS_PATH_GAIM,
|
|
76 DBUS_INTERFACE_GAIM);
|
11241
|
77
|
14035
|
78 if (!gaim_proxy)
|
|
79 lose_gerror ("Couldn't connect to the Gaim Service", error);
|
11241
|
80 }
|
|
81
|