1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 #include <libebook/e-book.h>
6 #include "ebook-test-utils.h"
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 (EBook *book)
35 query = e_book_query_field_exists (E_CONTACT_FULL_NAME);
37 status = e_book_get_contacts (book, query, &cards, NULL);
39 e_book_query_unref (query);
41 if (status == FALSE) {
42 printf ("error %d getting card list\n", status);
46 for (c = cards; c; c = c->next) {
47 EContact *contact = E_CONTACT (c->data);
49 print_email (contact);
51 g_object_unref (contact);
57 print_one_email (EBook *book)
62 if (!e_book_get_contact (book, "pas-id-0002023", &contact, &error)) {
63 printf ("error %d getting card: %s\n", error->code, error->message);
64 g_clear_error (&error);
68 print_email (contact);
70 g_object_unref (contact);
74 main (gint argc, gchar **argv)
81 ** the actual ebook foo
84 printf ("loading addressbook\n");
85 book = e_book_new_system_addressbook (NULL);
87 printf ("failed to create local addressbook\n");
91 ebook_test_utils_book_open (book, FALSE);
93 printf ("printing one contact\n");
94 print_one_email (book);
96 printf ("printing all contacts\n");
97 print_all_emails (book);
99 g_object_unref (book);