comparison libpurple/purple-client.c @ 15884:c6e563dfaa7a

More s/gaim/pidgin/ and s/gaim/purple/ and make the RPM spec file work a bit
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 24 Mar 2007 17:51:05 +0000
parents
children d4464c354346
comparison
equal deleted inserted replaced
15883:bfa907029bfc 15884:c6e563dfaa7a
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-purple.h"
8 #include "purple-client-bindings.h"
9
10 static DBusGConnection *bus;
11 static DBusGProxy *purple_proxy;
12
13 static GList *garray_int_to_glist(GArray *array)
14 {
15 GList *list = NULL;
16 int i;
17
18 for (i = 0; i < array->len; i++)
19 list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
20
21 g_array_free(array, TRUE);
22 return list;
23 }
24
25 static GSList *garray_int_to_gslist(GArray *array)
26 {
27 GSList *list = NULL;
28 int i;
29
30 for (i = 0; i < array->len; i++)
31 list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
32
33 g_array_free(array, TRUE);
34 return list;
35 }
36
37 #include "purple-client-bindings.c"
38
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;
41
42 static void
43 lose(const char *str, ...)
44 {
45 va_list args;
46
47 va_start(args, str);
48
49 vfprintf(stderr, str, args);
50 fputc('\n', stderr);
51
52 va_end(args);
53
54 exit(1);
55 }
56
57 static void
58 lose_gerror(const char *prefix, GError *error)
59 {
60 lose("%s: %s", prefix, error->message);
61 }
62
63 void purple_init(void)
64 {
65 GError *error = NULL;
66
67 g_type_init ();
68
69 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
70 if (!bus)
71 lose_gerror ("Couldn't connect to session bus", error);
72
73 purple_proxy = dbus_g_proxy_new_for_name (bus,
74 DBUS_SERVICE_PURPLE,
75 DBUS_PATH_PURPLE,
76 DBUS_INTERFACE_PURPLE);
77
78 if (!purple_proxy)
79 lose_gerror ("Couldn't connect to the Purple Service", error);
80 }
81