--- /dev/null
+#include <libebook/e-book.h>
+#include <libedataserver/e-source-group.h>
+#include <gconf/gconf.h>
+#include <glib.h>
+
+
+static gchar **search_filter = NULL;
+
+static GOptionEntry entries[] =
+{
+ { G_OPTION_REMAINING, 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING_ARRAY, &search_filter, NULL, NULL},
+ { NULL }
+};
+
+int main(int argc, char **argv)
+{
+ EBook *book;
+ ESourceList *source_list;
+ ESourceGroup *group;
+ ESource *source;
+ GSList *groups;
+ EBookQuery *query;
+ GList *contacts;
+ GSList *sources;
+ GSList *g, *s;
+ GList *c;
+ GError *error = NULL;
+ GOptionContext *optioncontext;
+
+ optioncontext = g_option_context_new ("- whack address book");
+ g_option_context_add_main_entries (optioncontext, entries, NULL);
+ g_option_context_parse (optioncontext, &argc, &argv, &error);
+
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error->message);
+ }
+
+ e_book_get_addressbooks(&source_list, &error);
+
+ if (error != NULL) {
+ fprintf(stderr, "%s\n", error->message);
+ }
+
+ if (search_filter == NULL) {
+ fprintf(stderr, "You must provide a filter\n");
+ exit(1);
+ }
+
+ char *qu = g_strdup_printf ("(or (contains \"email\" \"%s\") "
+ "(contains \"full_name\" \"%s\"))",
+ *search_filter, *search_filter);
+ query = e_book_query_from_string(qu);
+ g_free(qu);
+
+ 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);
+ e_book_open(book, TRUE, &error);
+ e_book_get_contacts(book, query, &contacts, &error);
+
+ for (c = contacts; c; c = c->next) {
+ g_object_set(E_CONTACT(c->data), "fburl", "http://etsted.blah/123");
+ e_book_commit_contact(book, E_CONTACT(c->data), &error);
+ }
+ }
+ }
+ e_book_query_unref (query);
+}