+
+static gboolean /* make this public? */
+add_to_address_book (const gchar* address)
+{
+ EBookQuery *query;
+ GList *contacts = NULL;
+ GError *err = NULL;
+
+ g_return_val_if_fail (address, FALSE);
+
+ if (!book)
+ open_addressbook ();
+
+ g_return_val_if_fail (book, FALSE);
+
+ query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, address);
+ if (!e_book_get_contacts (book, query, &contacts, &err)) {
+ g_printerr ("modest: failed to get contacts: %s",
+ err ? err->message : "<unknown>");
+ if (err)
+ g_error_free (err);
+ return FALSE;
+ }
+ e_book_query_unref (query);
+
+ /* we need to 'commit' it, even if we already found the email
+ * address in the addressbook; thus, it will show up in the 'recent list' */
+ if (contacts) {
+ g_debug ("%s already in the address book", address);
+ commit_contact ((EContact*)contacts->data, FALSE);
+
+ g_list_foreach (contacts, (GFunc)unref_gobject, NULL);
+ g_list_free (contacts);
+
+ } else {
+ /* it's not yet in the addressbook, add it now! */
+ EContact *new_contact = e_contact_new ();
+ e_contact_set (new_contact, E_CONTACT_EMAIL_1, (const gpointer)address);
+ commit_contact (new_contact, TRUE);
+ g_debug ("%s added to address book", address);
+ g_object_unref (new_contact);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+show_check_names_banner (gpointer data)
+{
+ GtkWidget **banner = (GtkWidget **) data;
+
+ *banner = hildon_banner_show_animation (NULL, NULL, _("mail_ib_checking_names"));
+ g_object_ref (G_OBJECT (*banner));
+
+ return FALSE;
+}
+