#include <glib.h>
-static gchar **search_filter = NULL;
+static gchar *id = NULL;
+static gchar *full_name = NULL;
+static gchar *nickname = NULL;
+static gchar *company = NULL;
+static gchar **phones = NULL;
+static gchar **emails = NULL;
static GOptionEntry entries[] =
{
- { G_OPTION_REMAINING, 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING_ARRAY, &search_filter, NULL, NULL},
+ { "id", 0, 0, G_OPTION_ARG_STRING, &id, "ID of element to modify", "ID" },
+ { "full-name", 0, 0, G_OPTION_ARG_STRING, &full_name, "Full name of person", "full_name" },
+ { "nickname", 0, 0, G_OPTION_ARG_STRING, &nickname, "Nickname of person", "nick" },
+ { "company", 0, 0, G_OPTION_ARG_STRING, &company, "Company of person", "company" },
+ { "phones", 0, 0, G_OPTION_ARG_STRING_ARRAY, &phones, "Phone numbers (all)", "phone" },
+ { "emails", 0, 0, G_OPTION_ARG_STRING_ARRAY, &emails, "Email addresses (all)", "email" },
+
{ NULL }
};
+/*
+Addresses List of `bbdb-record-addresses' List of address vectors
+ Vectors `bbdb-record-set-addresses'
+Net List of `bbdb-record-net' List of network
+address Strings `bbdb-record-set-net' addresses
+Notes String or `bbdb-record-raw-notes' String or Association
+ Alist `bbdb-record-set-raw-notes'list of note fields
+ (strings)
+*/
+
int main(int argc, char **argv)
{
EBook *book;
fprintf(stderr, "%s\n", error->message);
}
- if (search_filter == NULL) {
+ if (id == 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);
+ char *qu = g_strdup_printf ("(is \"id\" \"%s\")", id);
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) {
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);
+ if (emails != NULL) {
+ gchar **head = emails;
+ GList *el = NULL;
+ while (*head != NULL) {
+ printf("appending %s\n", *head);
+ el = g_list_prepend(el, *head);
+ head++;
+ }
+ g_object_set(E_CONTACT(c->data), "email", el);
+ e_book_commit_contact(book, E_CONTACT(c->data), &error);
+ }
}
}
}
e_book_query_unref (query);
+ g_free(qu);
}