annotate src/gaim-client.c @ 12312:1c8ea8f3b84e

[gaim-migrate @ 14616] forgot a line, and infamy committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Sun, 04 Dec 2005 05:04:39 +0000
parents 421a8523ad04
children 8bda65b88e49
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
1 #define DBUS_API_SUBJECT_TO_CHANGE
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
2
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
3 #include <dbus/dbus-glib.h>
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
4 #include <stdio.h>
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
5 #include <stdlib.h>
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
6
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
7 #include "dbus-gaim.h"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
8 #include "gaim-client-bindings.h"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
9
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
10 static DBusGConnection *bus;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
11 static DBusGProxy *gaim_proxy;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
12
11277
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
13 static GList *garray_int_to_glist(GArray *array) {
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
14 GList *list = NULL;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
15 int i;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
16
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
17 for(i = 0; i < array->len; i++)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
18 list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
19
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
20 g_array_free(array, TRUE);
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
21 return list;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
22 }
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
23
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
24 static GSList *garray_int_to_gslist(GArray *array) {
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
25 GSList *list = NULL;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
26 int i;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
27
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
28 for(i = 0; i < array->len; i++)
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
29 list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
30
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
31 g_array_free(array, TRUE);
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
32 return list;
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
33 }
421a8523ad04 [gaim-migrate @ 13467]
Piotr Zielinski <zielaj>
parents: 11241
diff changeset
34
11241
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
35 #include "gaim-client-bindings.c"
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
36
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
37 static void lose (const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
38 static void lose_gerror (const char *prefix, GError *error) G_GNUC_NORETURN;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
39
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
40 static void
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
41 lose (const char *str, ...)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
42 {
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
43 va_list args;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
44
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
45 va_start (args, str);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
46
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
47 vfprintf (stderr, str, args);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
48 fputc ('\n', stderr);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
49
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
50 va_end (args);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
51
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
52 exit (1);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
53 }
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
54
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
55 static void
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
56 lose_gerror (const char *prefix, GError *error)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
57 {
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
58 lose ("%s: %s", prefix, error->message);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
59 }
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
60
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
61 void gaim_init(void) {
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
62 GError *error = NULL;
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
63
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
64 g_type_init ();
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
65
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
66 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
67 if (!bus)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
68 lose_gerror ("Couldn't connect to session bus", error);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
69
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
70 gaim_proxy = dbus_g_proxy_new_for_name (bus,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
71 DBUS_SERVICE_GAIM,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
72 DBUS_PATH_GAIM,
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
73 DBUS_INTERFACE_GAIM);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
74
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
75 if (!gaim_proxy)
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
76 lose_gerror ("Couldn't connect to the Gaim Service", error);
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
77 }
66f872f30e40 [gaim-migrate @ 13404]
Piotr Zielinski <zielaj>
parents:
diff changeset
78