1 #include <libebook/e-book.h>
2 #include <libedataserver/e-source-group.h>
3 #include <gconf/gconf.h>
6 void dump_as_vcard(EContact *contact, int dump_all)
11 attrs = e_vcard_get_attributes(&contact->parent);
12 for (i = 0; i < g_list_length(attrs); i++) {
13 EVCardAttribute *attr = (EVCardAttribute *)
14 g_list_nth_data(attrs, i);
16 char *attr_name = e_vcard_attribute_get_name(attr);
19 strcmp(attr_name, "TEL") != 0 &&
20 strcmp(attr_name, "FN") != 0 &&
21 strcmp(attr_name, "BDAY") != 0 &&
22 strcmp(attr_name, "ORG") != 0 &&
23 strcmp(attr_name, "TEL") != 0 &&
24 strcmp(attr_name, "EMAIL") != 0 &&
25 strcmp(attr_name, "NOTE") != 0 &&
26 strcmp(attr_name, "NICKNAME") != 0
31 if (strcmp(attr_name, "N") == 0 ||
32 strcmp(attr_name, "ADR") == 0) {
36 if (e_vcard_attribute_is_single_valued(attr)) {
37 char *av = e_vcard_attribute_get_value(attr);
42 GList *vals = e_vcard_attribute_get_values(attr);
44 for (j = 0; j < g_list_length(vals); j++) {
45 char *av = g_list_nth(vals, j);
55 int main(int argc, char **argv)
58 ESourceList *source_list;
69 printf("%d\n", e_book_get_addressbooks(&source_list, &error));
72 fprintf(stderr, "%s\n", error->message);
75 groups = e_source_list_peek_groups(source_list);
76 for (g = groups; g; g = g->next) {
78 group = E_SOURCE_GROUP (g->data);
79 sources = e_source_group_peek_sources(group);
81 for (s = sources ; s; s = s->next) {
82 source = E_SOURCE(s->data);
83 book = e_book_new(source, &error);
84 e_book_open(book, TRUE, &error);
86 // query = e_book_query_any_field_contains("");
87 query = e_book_query_field_exists(E_CONTACT_FULL_NAME);
88 e_book_get_contacts(book, query, &contacts, &error);
90 for (c = contacts; c; c = c->next) {
91 dump_as_vcard(E_CONTACT(c->data), 1);