view libpurple/purple-client-example.c @ 30725:b6c3000eec60

Use GtkUIManager for gtk media stuff, since it's internal. applied changes from 7f3cdd61a34080056b8024a0297d01ed559bef25 through c9211cd8bf87478800560441c7eb893f1e3995e0 applied partial changes from 231d9237a777f9d01fa2ff9c26a575a0ac8db31c through d0c6c98ad725a3a64114bd1d5c1da1220d738c93
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 26 Jul 2010 04:21:47 +0000
parents 48d09d62912e
children
line wrap: on
line source

#ifndef DBUS_API_SUBJECT_TO_CHANGE
#define DBUS_API_SUBJECT_TO_CHANGE
#endif

#include <stdio.h>
#include <stdlib.h>

#include "purple-client.h"

/*
   This example demonstrates how to use libpurple-client to communicate
   with purple.  The names and signatures of functions provided by
   libpurple-client are the same as those in purple.  However, all
   structures (such as PurpleAccount) are opaque, that is, you can only
   use pointer to them.  In fact, these pointers DO NOT actually point
   to anything, they are just integer identifiers of assigned to these
   structures by purple.  So NEVER try to dereference these pointers.
   Integer ids as disguised as pointers to provide type checking and
   prevent mistakes such as passing an id of PurpleAccount when an id of
   PurpleBuddy is expected.  According to glib manual, this technique is
   portable.
*/

int main (int argc, char **argv)
{
	GList *alist, *node;

	purple_init();

	alist = purple_accounts_get_all();
	for (node = alist; node != NULL; node = node->next)
	{
		PurpleAccount *account = (PurpleAccount*) node->data;
		char *name = purple_account_get_username(account);
		g_print("Name: %s\n", name);
		g_free(name);
	}
	g_list_free(alist);

	return 0;
}