Remove useless comparison
[pidgin-git.git] / libpurple / purple-client.c
blobd52428df7a0723a0c9c6416e30ae8720ccbe6329
1 #ifndef DBUS_API_SUBJECT_TO_CHANGE
2 #define DBUS_API_SUBJECT_TO_CHANGE
3 #endif
5 #include <dbus/dbus-glib.h>
6 #include <stdio.h>
7 #include <stdlib.h>
9 #include "dbus-purple.h"
10 #include "purple-client.h"
12 static DBusGConnection *bus;
13 static DBusGProxy *purple_proxy;
15 static GList *garray_int_to_glist(GArray *array)
17 GList *list = NULL;
18 gsize i;
20 for (i = 0; i < array->len; i++)
21 list = g_list_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
23 g_array_free(array, TRUE);
24 return list;
27 static GSList *garray_int_to_gslist(GArray *array)
29 GSList *list = NULL;
30 gsize i;
32 for (i = 0; i < array->len; i++)
33 list = g_slist_append(list, GINT_TO_POINTER(g_array_index(array,gint,i)));
35 g_array_free(array, TRUE);
36 return list;
39 #include "purple-client-bindings.c"
41 static void lose(const char *fmt, ...) G_GNUC_NORETURN G_GNUC_PRINTF (1, 2);
42 static void lose_gerror(const char *prefix, GError *error) G_GNUC_NORETURN;
44 static void
45 lose(const char *str, ...)
47 va_list args;
49 va_start(args, str);
51 vfprintf(stderr, str, args);
52 fputc('\n', stderr);
54 va_end(args);
56 exit(1);
59 static void
60 lose_gerror(const char *prefix, GError *error)
62 lose("%s: %s", prefix, error->message);
65 void purple_init(void)
67 GError *error = NULL;
69 #if !GLIB_CHECK_VERSION(2, 36, 0)
70 /* GLib type system is automaticaly initialized since 2.36. */
71 g_type_init();
72 #endif
74 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
75 if (!bus)
76 lose_gerror ("Couldn't connect to session bus", error);
78 purple_proxy = dbus_g_proxy_new_for_name (bus,
79 DBUS_SERVICE_PURPLE,
80 DBUS_PATH_PURPLE,
81 DBUS_INTERFACE_PURPLE);
83 if (!purple_proxy)
84 lose_gerror ("Couldn't connect to the Purple Service", error);