From 49af53828a34c96739a1e76c24dceabdbe761781 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Tue, 16 Oct 2007 17:31:10 +0200 Subject: [PATCH 1/1] Initial import from non-versioned sources --- Makefile.am | 2 ++ autogen.sh | 10 +++++++++ configure.ac | 28 ++++++++++++++++++++++++ src/Makefile.am | 6 ++++++ src/dump-addressbook.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 Makefile.am create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 src/Makefile.am create mode 100644 src/dump-addressbook.c diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..c24d07c --- /dev/null +++ b/Makefile.am @@ -0,0 +1,2 @@ + +SUBDIRS=src \ No newline at end of file diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..f1fd559 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,10 @@ +#! /bin/sh + +set -e + +aclocal-1.9 +autoheader +libtoolize --copy --force +automake-1.9 --copy --add-missing --foreign +autoconf +./configure --enable-maintainer-mode "$@" diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..9dd8c8c --- /dev/null +++ b/configure.ac @@ -0,0 +1,28 @@ + +AC_INIT([eds-address], 0.1) +AC_CONFIG_SRCDIR(src/dump-addressbook.c) +AM_INIT_AUTOMAKE([1.9]) +AM_CONFIG_HEADER(config.h) +# AM_MAINTAINER_MODE + +PKG_CHECK_MODULES(EDS_ADDRESS, [libedataserver-1.2 libebook-1.2 gconf-2.0 glib-2.0]) + +AC_CHECK_TYPES([sig_atomic_t], [], [], [#include ]) +AC_CHECK_HEADER([sys/types.h], [], [exit 1], []) +AC_CHECK_HEADER([tdb.h],[],[exit 1],[[ +#include +#include +]]) + +AC_DISABLE_STATIC +AM_PROG_LIBTOOL + +AC_PROG_CC + +#GETTEXT_PACKAGE=evolution-backend-tdb +#AC_SUBST(GETTEXT_PACKAGE) +#AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The prefix for our gettext translation domains.]) + +#AM_GLIB_GNU_GETTEXT + +AC_OUTPUT([Makefile src/Makefile]) diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..e91f9a7 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,6 @@ + +bin_PROGRAMS = dump-addressbook + +dump_addressbook_SOURCES = dump-addressbook.c +AM_CFLAGS = $(EDS_ADDRESS_CFLAGS) +AM_LDFLAGS = $(EDS_ADDRESS_LIBS) diff --git a/src/dump-addressbook.c b/src/dump-addressbook.c new file mode 100644 index 0000000..bdd63e6 --- /dev/null +++ b/src/dump-addressbook.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +int main(int argc, char **argv) { + EBook *book; + ESourceList *source_list; + ESourceGroup *group; + ESource *source; + GSList *groups; + EBookQuery *query; + GList *contacts; + EContact *contact; + GSList *sources; + GSList *g, *s; + GList *c; + + int i; + GError *error = NULL; + + fprintf(stderr,"%d\n", e_book_get_addressbooks(&source_list, &error)); + if (error != NULL) { + fprintf(stderr, "%s\n", error->message); + } + groups = e_source_list_peek_groups(source_list); + for (g = groups; g; g = g->next) { + + group = E_SOURCE_GROUP (g->data); + fprintf(stderr, "SOURCE GROUP: %s\n", e_source_group_peek_base_uri(group)); + 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); + e_book_open(book, TRUE, &error); + fprintf(stderr, "\tSOURCE: %s\n", e_source_peek_name(source)); + // query = e_book_query_any_field_contains(""); + query = e_book_query_field_exists(E_CONTACT_FULL_NAME); + e_book_get_contacts(book, query, &contacts, &error); + + for (c = contacts; c; c = c->next) { + contact = E_CONTACT(c->data); + fprintf(stderr, "\t\tCONTACT: %s\n", e_contact_get(contact, E_CONTACT_FULL_NAME)); + } + + } + } +} -- 2.39.5