-#include <libebook/e-book.h>
-#include <libedataserver/e-source-group.h>
+#include <libebook/libebook.h>
#include <glib.h>
#include <locale.h>
int main(int argc, char **argv)
{
EBook *book;
- ESourceList *source_list;
- ESourceGroup *group;
+ ESourceRegistry *eds_source_registry = NULL;
+ GList *sources;
ESource *source;
GSList *groups;
EBookQuery *query;
GList *contacts;
- GSList *sources;
- GSList *g, *s;
+ GList *g, *s;
GList *c;
GError *error = NULL;
GOptionContext *optioncontext;
return 1;
}
- e_book_get_addressbooks(&source_list, &error);
-
+ eds_source_registry = e_source_registry_new_sync (NULL, &error);
if (error != NULL) {
fprintf(stderr, "%s\n", error->message);
return 1;
}
+ sources = e_source_registry_list_sources (eds_source_registry, NULL);
+
if (search_filter != NULL) {
query = e_book_query_any_field_contains(*search_filter);
} else {
query = e_book_query_field_exists(E_CONTACT_FULL_NAME);
}
- groups = e_source_list_peek_groups(source_list);
- for (g = groups; g; g = g->next) {
-
- group = E_SOURCE_GROUP (g->data);
- sources = e_source_group_peek_sources(group);
-
- for (s = sources ; s; s = s->next) {
- source = E_SOURCE(s->data);
- book = e_book_new(source, &error);
-
- if (error != NULL) {
- fprintf(stderr, "%s\n", error->message);
- return 1;
- }
-
- e_book_open(book, TRUE, &error);
+ for (s = sources ; s; s = s->next) {
+ source = E_SOURCE(s->data);
+ book = e_book_new(source, &error);
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error->message);
+ return 1;
+ }
- if (error != NULL) {
- fprintf(stderr, "%s\n", error->message);
- return 1;
- }
+ e_book_open(book, TRUE, &error);
- e_book_get_contacts(book, query, &contacts, &error);
- if (error != NULL) {
- fprintf(stderr, "%s\n", error->message);
- return 1;
- }
- for (c = contacts; c; c = c->next) {
- dump_as_vcard(E_CONTACT(c->data), 1);
- }
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error->message);
+ return 1;
+ }
+
+ e_book_get_contacts(book, query, &contacts, &error);
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error->message);
+ return 1;
+ }
+
+ for (c = contacts; c; c = c->next) {
+ dump_as_vcard(E_CONTACT(c->data), 1);
}
}
- e_book_query_unref (query);
+ e_book_query_unref(query);
+ g_list_free_full(sources, g_object_unref);
+
}