1 /* Copyright (c) 2007, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 /* modest-address-book.c */
32 #include <modest-address-book.h>
33 #include <libebook/e-book.h>
34 #include <libebook/e-book-view.h>
35 #include <libosso-abook/osso-abook.h>
37 static OssoABookContactModel *contact_model = NULL;
38 static EBook *book = NULL;
39 static EBookView * book_view = NULL;
43 get_book_view_cb (EBook *book, EBookStatus status, EBookView *bookview, gpointer data)
45 if (status != E_BOOK_ERROR_OK) {
46 g_object_unref (book);
53 osso_abook_tree_model_set_book_view (OSSO_ABOOK_TREE_MODEL (contact_model),
56 e_book_view_start (book_view);
60 book_open_cb (EBook *view, EBookStatus status, gpointer data)
62 EBookQuery *query = NULL;
64 if (status != E_BOOK_ERROR_OK) {
65 g_object_unref (book);
69 query = e_book_query_any_field_contains ("");
70 e_book_async_get_book_view (book, query, NULL, -1, get_book_view_cb, NULL);
71 e_book_query_unref (query);
77 book = e_book_new_system_addressbook (NULL);
81 e_book_async_open (book, FALSE, book_open_cb, NULL);
83 return TRUE; /* FIXME */
87 modest_address_book_add_address (const gchar *address)
89 OssoABookAccount *account = NULL;
90 GtkWidget *dialog = NULL;
92 contact_model = osso_abook_contact_model_new ();
93 if (!open_addressbook ()) {
95 g_object_unref (contact_model);
101 account = osso_abook_account_get (EVC_EMAIL, NULL, address);
102 dialog = osso_abook_add_to_contacts_dialog_new (contact_model, account);
103 g_object_unref (account);
104 gtk_dialog_run (GTK_DIALOG (dialog));
107 g_object_unref (contact_model);
108 contact_model = NULL;
111 gtk_widget_destroy (dialog);
116 modest_address_book_select_addresses (void)
118 g_message (__FUNCTION__);