Migrate certificates, icons, logs to XDG dirs
[pidgin-git.git] / libpurple / purple-client-example.c
blobe07ed593fbea8d1073f13b9178a1b53cd043001b
1 #ifndef DBUS_API_SUBJECT_TO_CHANGE
2 #define DBUS_API_SUBJECT_TO_CHANGE
3 #endif
5 #include <stdio.h>
6 #include <stdlib.h>
8 #include "purple-client.h"
11 This example demonstrates how to use libpurple-client to communicate
12 with purple. The names and signatures of functions provided by
13 libpurple-client are the same as those in purple. However, all
14 structures (such as PurpleAccount) are opaque, that is, you can only
15 use pointer to them. In fact, these pointers DO NOT actually point
16 to anything, they are just integer identifiers of assigned to these
17 structures by purple. So NEVER try to dereference these pointers.
18 Integer ids as disguised as pointers to provide type checking and
19 prevent mistakes such as passing an id of PurpleAccount when an id of
20 PurpleBuddy is expected. According to glib manual, this technique is
21 portable.
24 int main (int argc, char **argv)
26 GList *alist, *node;
28 purple_init();
30 alist = purple_accounts_get_all();
31 for (node = alist; node != NULL; node = node->next)
33 PurpleAccount *account = (PurpleAccount*) node->data;
34 char *name = purple_account_get_username(account);
35 g_print("Name: %s\n", name);
36 g_free(name);
38 g_list_free(alist);
40 return 0;