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