EVCardAttribute *attr = (EVCardAttribute *)
g_list_nth_data(attrs, i);
int j;
- char *attr_name = e_vcard_attribute_get_name(attr);
+ const char *attr_name = e_vcard_attribute_get_name(attr);
if (!dump_all &&
strcmp(attr_name, "TEL") != 0 &&
GList *vals = e_vcard_attribute_get_values(attr);
for (j = 0; j < g_list_length(vals); j++) {
- char *av = g_list_nth(vals, j);
+ const char *av = (char*) g_list_nth(vals, j);
printf("%s: %s\n",
attr_name,
}
}
+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;
GSList *g, *s;
GList *c;
GError *error = NULL;
+ GOptionContext *optioncontext;
- printf("%d\n", e_book_get_addressbooks(&source_list, &error));
+ 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) {
+ 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);
+ } 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) {
source = E_SOURCE(s->data);
book = e_book_new(source, &error);
e_book_open(book, TRUE, &error);
-
- // 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) {
}
}
}
+ e_book_query_unref (query);
}