X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-address-book.c;h=d6d06c0716acf3441b77d3e750862dcbf360568f;hb=23147dbc26514846be4a9b803b862801c7b1c82b;hp=225e3f1fb1f955d216a537ccbb0a6315c463af83;hpb=b425d1a06addd5a5a3c83eb696bb45a82e4a439a;p=modest diff --git a/src/hildon2/modest-address-book.c b/src/hildon2/modest-address-book.c index 225e3f1..d6d06c0 100644 --- a/src/hildon2/modest-address-book.c +++ b/src/hildon2/modest-address-book.c @@ -38,6 +38,7 @@ #include #include "modest-hildon-includes.h" #include +#include #include "modest-platform.h" #include "modest-runtime.h" #include "widgets/modest-window-mgr.h" @@ -104,7 +105,8 @@ open_addressbook () } void -modest_address_book_add_address (const gchar *address) +modest_address_book_add_address (const gchar *address, + GtkWindow *parent) { GtkWidget *dialog = NULL; gchar *email_address; @@ -115,10 +117,11 @@ modest_address_book_add_address (const gchar *address) } email_address = modest_text_utils_get_email_address (address); - + attribute = e_vcard_attribute_new (NULL, EVC_EMAIL); e_vcard_attribute_add_value (attribute, email_address); - dialog = osso_abook_temporary_contact_dialog_new (NULL, book, attribute, NULL); + dialog = osso_abook_temporary_contact_dialog_new (parent, book, attribute, NULL); + gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -239,7 +242,8 @@ get_recipients_for_given_contact (EContact * contact, emailid = get_email_addr_from_user(display_name, canceled); if (emailid) { - e_contact_set(E_CONTACT (abook_contact), E_CONTACT_EMAIL_1, emailid); + list = g_list_append (list, g_strdup (emailid)); + e_contact_set(E_CONTACT (abook_contact), E_CONTACT_EMAIL, list); osso_abook_contact_commit (abook_contact, FALSE, NULL, NULL); } g_object_unref (abook_contact); @@ -576,12 +580,15 @@ async_get_contacts_cb (EBook *book, g_debug ("----Preparing to commit contact %s", address); } else { gchar *email_address, *display_address; + GList *email_list = NULL; /* Create new contact and add it to the list */ contact = e_contact_new (); email_address = modest_text_utils_get_email_address (address); - e_contact_set (contact, E_CONTACT_EMAIL_1, email_address); + email_list = g_list_append (email_list, email_address); + e_contact_set (contact, E_CONTACT_EMAIL, email_list); g_free (email_address); + g_list_free (email_list); display_address = g_strdup (address); if (display_address) { @@ -710,11 +717,12 @@ void free_resolved_addresses_list (gpointer data, } gboolean -modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean update_addressbook) +modest_address_book_check_names (ModestRecptEditor *recpt_editor, + GSList **address_list) { const gchar *recipients = NULL; GSList *start_indexes = NULL, *end_indexes = NULL; - GSList *current_start, *current_end, *to_commit_addresses; + GSList *current_start, *current_end; gboolean result = TRUE; GtkTextBuffer *buffer; gint offset_delta = 0; @@ -739,7 +747,6 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat current_start = start_indexes; current_end = end_indexes; buffer = modest_recpt_editor_get_buffer (recpt_editor); - to_commit_addresses = NULL; while (current_start != NULL) { gchar *address; @@ -828,14 +835,14 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat } g_slist_free (tags); if (!has_recipient) { - GSList * address_list = NULL; + GSList * addr_list = NULL; - address_list = g_slist_prepend (address_list, address); + addr_list = g_slist_prepend (addr_list, address); modest_recpt_editor_replace_with_resolved_recipient (recpt_editor, &start_iter, &end_iter, - address_list, + addr_list, ""); - g_slist_free (address_list); + g_slist_free (addr_list); store_address = TRUE; } } @@ -843,8 +850,8 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat /* so, it seems a valid address */ /* note: adding it the to the addressbook if it did not exist yet, * and adding it to the recent_list */ - if (result && update_addressbook && store_address) - to_commit_addresses = g_slist_prepend (to_commit_addresses, address); + if (result && address_list && store_address) + *address_list = g_slist_prepend (*address_list, address); else g_free (address); @@ -855,12 +862,9 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat current_end = g_slist_next (current_end); } - /* Add addresses to address-book */ - if (to_commit_addresses) { - to_commit_addresses = modest_text_utils_remove_duplicate_addresses_list (to_commit_addresses); - if (to_commit_addresses) - modest_address_book_add_address_list (to_commit_addresses); - } + /* Remove dup's */ + if (address_list && *address_list) + *address_list = modest_text_utils_remove_duplicate_addresses_list (*address_list); if (current_start == NULL) { gtk_text_buffer_get_end_iter (buffer, &end_iter); @@ -927,6 +931,7 @@ get_contacts_for_name (const gchar *name) return result; } +#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC static gboolean filter_by_name (OssoABookContactChooser *chooser, OssoABookContact *contact, @@ -937,20 +942,30 @@ filter_by_name (OssoABookContactChooser *chooser, contact_name = osso_abook_contact_get_name (contact); /* contact_name includes both name and surname */ - if (contact_name && name && strstr (contact_name, name)) + if (contact_name && name && e_util_utf8_strstrcase (contact_name, name)) return TRUE; else return FALSE; } +#endif static GList * select_contacts_for_name_dialog (const gchar *name) { +#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC GtkWidget *contact_view; OssoABookContactChooser *contact_dialog; +#else + EBookQuery *full_name_book_query = NULL; + EBookView *book_view = NULL; +#endif + GList *result = NULL; gchar *unquoted; + unquoted = unquote_string (name); + +#ifdef HAVE_OSSO_ABOOK_CONTACT_CHOOSER_SET_VISIBLE_FUNC contact_dialog = (OssoABookContactChooser *) osso_abook_contact_chooser_new_with_capabilities (NULL, _AB("addr_ti_dia_select_contacts"), @@ -961,7 +976,6 @@ select_contacts_for_name_dialog (const gchar *name) osso_abook_contact_chooser_set_maximum_selection (contact_dialog, G_MAXUINT); /* Set up the filtering */ - unquoted = unquote_string (name); contact_view = osso_abook_contact_chooser_get_contact_view (contact_dialog); osso_abook_contact_chooser_set_model (contact_dialog, contact_model); osso_abook_contact_chooser_set_visible_func (contact_dialog, filter_by_name, unquoted, NULL); @@ -970,6 +984,34 @@ select_contacts_for_name_dialog (const gchar *name) result = osso_abook_contact_chooser_get_selection (contact_dialog); gtk_widget_destroy ((GtkWidget *) contact_dialog); +#else + full_name_book_query = e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_CONTAINS, unquoted); + e_book_get_book_view (book, full_name_book_query, NULL, -1, &book_view, NULL); + e_book_query_unref (full_name_book_query); + + if (book_view) { + GtkWidget *contact_dialog = NULL; + osso_abook_list_store_set_book_view (OSSO_ABOOK_LIST_STORE (contact_model), book_view); + e_book_view_start (book_view); + + /* TODO: figure out how to make the contact chooser modal */ + contact_dialog = osso_abook_contact_chooser_new_with_capabilities (NULL, + _AB("addr_ti_dia_select_contacts"), + OSSO_ABOOK_CAPS_EMAIL, + OSSO_ABOOK_CONTACT_ORDER_NAME); + /* Enable multiselection */ + osso_abook_contact_chooser_set_maximum_selection (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog), + G_MAXUINT); + osso_abook_contact_chooser_set_model (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog), + contact_model); + + if (gtk_dialog_run (GTK_DIALOG (contact_dialog)) == GTK_RESPONSE_OK) + result = osso_abook_contact_chooser_get_selection (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog)); + e_book_view_stop (book_view); + g_object_unref (book_view); + gtk_widget_destroy (contact_dialog); + } +#endif g_free (unquoted);