From: Sergio Villar Senin Date: Thu, 25 Jun 2009 09:31:24 +0000 (+0200) Subject: Added modest_address_book_add_address_list() X-Git-Tag: 3.0.17-rc20~10 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=b425d1a06addd5a5a3c83eb696bb45a82e4a439a;hp=b47c94d3ff2333298a24baa1bcdd1829f45d4e64 Added modest_address_book_add_address_list() Implemented the modest_address_book_add_address_list() method --- diff --git a/src/hildon2/modest-address-book.c b/src/hildon2/modest-address-book.c index b6b59b8..225e3f1 100644 --- a/src/hildon2/modest-address-book.c +++ b/src/hildon2/modest-address-book.c @@ -619,40 +619,6 @@ async_get_contacts_cb (EBook *book, g_list_free (contacts); } - -static void -add_to_address_book (GSList *addresses) -{ - EBookQuery **queries, *composite_query; - gint num_add, i; - - g_return_if_fail (addresses); - - if (!book) - if (!open_addressbook ()) - g_return_if_reached (); - - /* Create the list of queries */ - num_add = g_slist_length (addresses); - queries = g_malloc0 (sizeof (EBookQuery *) * num_add); - for (i = 0; i < num_add; i++) { - gchar *email; - - email = modest_text_utils_get_email_address (g_slist_nth_data (addresses, i)); - queries[i] = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, email); - g_free (email); - } - - /* Create the query */ - composite_query = e_book_query_or (num_add, queries, TRUE); - - /* Asynchronously retrieve contacts */ - e_book_async_get_contacts (book, composite_query, async_get_contacts_cb, addresses); - - /* Frees. This will unref the subqueries as well */ - e_book_query_unref (composite_query); -} - typedef struct _CheckNamesInfo { GtkWidget *banner; guint show_banner_timeout; @@ -893,7 +859,7 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat if (to_commit_addresses) { to_commit_addresses = modest_text_utils_remove_duplicate_addresses_list (to_commit_addresses); if (to_commit_addresses) - add_to_address_book (to_commit_addresses); + modest_address_book_add_address_list (to_commit_addresses); } if (current_start == NULL) { @@ -1176,3 +1142,36 @@ modest_address_book_init (void) { open_addressbook (); } + +void +modest_address_book_add_address_list (GSList *address_list) +{ + EBookQuery **queries, *composite_query; + gint num_add, i; + + g_return_if_fail (address_list); + + if (!book) + if (!open_addressbook ()) + g_return_if_reached (); + + /* Create the list of queries */ + num_add = g_slist_length (address_list); + queries = g_malloc0 (sizeof (EBookQuery *) * num_add); + for (i = 0; i < num_add; i++) { + gchar *email; + + email = modest_text_utils_get_email_address (g_slist_nth_data (address_list, i)); + queries[i] = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, email); + g_free (email); + } + + /* Create the query */ + composite_query = e_book_query_or (num_add, queries, TRUE); + + /* Asynchronously retrieve contacts */ + e_book_async_get_contacts (book, composite_query, async_get_contacts_cb, address_list); + + /* Frees. This will unref the subqueries as well */ + e_book_query_unref (composite_query); +} diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index b8ee6fc..5d4ff9b 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -1051,3 +1051,9 @@ modest_address_book_init (void) { open_addressbook (); } + +void +modest_address_book_add_address_list (GSList *address_list) +{ + +} diff --git a/src/modest-address-book-dummy.c b/src/modest-address-book-dummy.c index 1286541..aff172e 100644 --- a/src/modest-address-book-dummy.c +++ b/src/modest-address-book-dummy.c @@ -70,3 +70,9 @@ modest_address_book_init (void) { /* Do nothing */ } + +void +modest_address_book_add_address_list (GSList *address_list) +{ + /* Do nothing */ +} diff --git a/src/modest-address-book.h b/src/modest-address-book.h index cdd231c..7fd41cb 100644 --- a/src/modest-address-book.h +++ b/src/modest-address-book.h @@ -99,4 +99,13 @@ modest_address_book_has_address (const gchar *address); const gchar * modest_address_book_get_my_name (); +/** + * modest_address_book_add_address_list: + * @address_list: a list of email addresses to add to the addressbook + * + * Inserts a list of addresses in the addressbook + **/ +void +modest_address_book_add_address_list (GSList *address_list); + #endif /* __MODEST_ADDRESS_BOOK_H__ */