Mercurial > pidgin.yaz
comparison src/gaim-client.c @ 11241:66f872f30e40
[gaim-migrate @ 13404]
New shared library libgaim-client, which provides C bindings to
communicate with gaim.
committer: Tailor Script <tailor@pidgin.im>
author | Piotr Zielinski <zielaj> |
---|---|
date | Fri, 12 Aug 2005 16:56:45 +0000 |
parents | |
children | 421a8523ad04 |
comparison
equal
deleted
inserted
replaced
11240:2ab2de8add8b | 11241:66f872f30e40 |
---|---|
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 | |
13 #include "gaim-client-bindings.c" | |
14 | |
15 static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2); | |
16 static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN; | |
17 | |
18 static void | |
19 lose (const char *str, ...) | |
20 { | |
21 va_list args; | |
22 | |
23 va_start (args, str); | |
24 | |
25 vfprintf (stderr, str, args); | |
26 fputc ('\n', stderr); | |
27 | |
28 va_end (args); | |
29 | |
30 exit (1); | |
31 } | |
32 | |
33 static void | |
34 lose_gerror (const char *prefix, GError *error) | |
35 { | |
36 lose ("%s: %s", prefix, error->message); | |
37 } | |
38 | |
39 void gaim_init(void) { | |
40 GError *error = NULL; | |
41 | |
42 g_type_init (); | |
43 | |
44 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); | |
45 if (!bus) | |
46 lose_gerror ("Couldn't connect to session bus", error); | |
47 | |
48 gaim_proxy = dbus_g_proxy_new_for_name (bus, | |
49 DBUS_SERVICE_GAIM, | |
50 DBUS_PATH_GAIM, | |
51 DBUS_INTERFACE_GAIM); | |
52 | |
53 if (!gaim_proxy) | |
54 lose_gerror ("Couldn't connect to the Gaim Service", error); | |
55 } | |
56 |