1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4
#include <libebook/e-book.h>
6
static GMainLoop *loop;
9
print_email (EContact *contact)
11
const gchar *file_as = e_contact_get_const (contact, E_CONTACT_FILE_AS);
12
const gchar *name_or_org = e_contact_get_const (contact, E_CONTACT_NAME_OR_ORG);
15
printf ("Contact: %s\n", file_as);
16
printf ("Name or org: %s\n", name_or_org);
17
printf ("Email addresses:\n");
18
emails = e_contact_get (contact, E_CONTACT_EMAIL);
19
for (e = emails; e; e = e->next) {
20
printf ("\t%s\n", (gchar *)e->data);
22
g_list_foreach (emails, (GFunc) g_free, NULL);
29
print_all_emails_cb (EBook *book, const GError *error, GList *contacts, gpointer closure)
34
for (c = contacts; c; c = c->next) {
35
EContact *contact = E_CONTACT (c->data);
37
print_email (contact);
40
g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
43
g_main_loop_quit (loop);
47
print_all_emails (EBook *book)
51
query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
53
e_book_get_contacts_async (book, query, print_all_emails_cb, NULL);
55
e_book_query_unref (query);
59
print_email_cb (EBook *book, const GError *error, EContact *contact, gpointer closure)
62
print_email (contact);
64
g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
66
printf ("printing all contacts\n");
67
print_all_emails (book);
71
print_one_email (EBook *book)
73
e_book_get_contact_async (book, "pas-id-0002023", print_email_cb, NULL);
77
book_loaded_cb (EBook *book, const GError *error, gpointer data)
80
g_warning ("%s: Got error %d (%s)", G_STRFUNC, error->code, error->message);
84
printf ("printing one contact\n");
85
print_one_email (book);
89
main (gint argc, gchar **argv)
94
loop = g_main_loop_new (NULL, TRUE);
97
** the actual ebook foo
100
book = e_book_new_system_addressbook (NULL);
102
printf ("loading addressbook\n");
103
e_book_open_async (book, FALSE, book_loaded_cb, book);
105
g_main_loop_run (loop);