~liuxingcs/+junk/pidgin

« back to all changes in this revision

Viewing changes to libpurple/purple-client-example.c

  • Committer: liuxing
  • Date: 2013-04-25 11:10:17 UTC
  • Revision ID: liuxingcs@yeah.net-20130425111017-fm4mtfsuvhq0dbqd
pidgin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef DBUS_API_SUBJECT_TO_CHANGE
 
2
#define DBUS_API_SUBJECT_TO_CHANGE
 
3
#endif
 
4
 
 
5
#include <stdio.h>
 
6
#include <stdlib.h>
 
7
 
 
8
#include "purple-client.h"
 
9
 
 
10
/*
 
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.
 
22
*/
 
23
 
 
24
int main (int argc, char **argv)
 
25
{
 
26
        GList *alist, *node;
 
27
 
 
28
        purple_init();
 
29
 
 
30
        alist = purple_accounts_get_all();
 
31
        for (node = alist; node != NULL; node = node->next)
 
32
        {
 
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);
 
37
        }
 
38
        g_list_free(alist);
 
39
 
 
40
        return 0;
 
41
}