Merged pidgin/main into default
[pidgin-git.git] / libpurple / purple-client-example.c
blobfc00d4880f7712cd31368dfd02ca9b44b934c28f
1 /*
2 * purple
4 * Purple is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #ifndef DBUS_API_SUBJECT_TO_CHANGE
24 #define DBUS_API_SUBJECT_TO_CHANGE
25 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
30 #include "purple-client.h"
33 This example demonstrates how to use libpurple-client to communicate
34 with purple. The names and signatures of functions provided by
35 libpurple-client are the same as those in purple. However, all
36 structures (such as PurpleAccount) are opaque, that is, you can only
37 use pointer to them. In fact, these pointers DO NOT actually point
38 to anything, they are just integer identifiers of assigned to these
39 structures by purple. So NEVER try to dereference these pointers.
40 Integer ids as disguised as pointers to provide type checking and
41 prevent mistakes such as passing an id of PurpleAccount when an id of
42 PurpleBuddy is expected. According to glib manual, this technique is
43 portable.
46 int main (int argc, char **argv)
48 GList *alist, *node;
50 purple_init();
52 alist = purple_accounts_get_all();
53 for (node = alist; node != NULL; node = node->next)
55 PurpleAccount *account = (PurpleAccount*) node->data;
56 char *name = purple_account_get_username(account);
57 g_print("Name: %s\n", name);
58 g_free(name);
60 g_list_free(alist);
62 return 0;