open_addressbook ()
{
OssoABookRoster *roster;
+ GError *error = NULL;
+ time_t init,end;
if (book && book_view)
return TRUE;
- roster = osso_abook_aggregator_get_default (NULL);
- if (roster) {
- book = osso_abook_roster_get_book (roster);
- book_view = osso_abook_roster_get_book_view (roster);
+ roster = osso_abook_aggregator_get_default (&error);
+ if (error)
+ goto error;
- return TRUE;
- } else {
- return FALSE;
- }
+ /* Wait until it's ready */
+ init = time (NULL);
+ osso_abook_waitable_run ((OssoABookWaitable *) roster,
+ g_main_context_default (),
+ &error);
+ end = time (NULL);
+ g_debug ("Opening addressbook lasted %ld seconds", (gint) end-init);
+
+ if (error)
+ goto error;
+
+ if (!osso_abook_waitable_is_ready ((OssoABookWaitable *) roster,
+ &error))
+ goto error;
+
+ book = osso_abook_roster_get_book (roster);
+ book_view = osso_abook_roster_get_book_view (roster);
+
+ return TRUE;
+ error:
+ g_warning ("error opening addressbook %s", error->message);
+ g_error_free (error);
+ return FALSE;
}
void
emailid = get_email_addr_from_user(display_name, canceled);
if (emailid) {
- e_contact_set(contact, E_CONTACT_EMAIL_1, emailid);
+ e_contact_set(E_CONTACT (abook_contact), E_CONTACT_EMAIL_1, emailid);
osso_abook_contact_commit (abook_contact, FALSE, NULL, NULL);
}
g_object_unref (abook_contact);
g_slist_foreach (addresses, (GFunc) g_free, NULL);
g_slist_free (addresses);
}
- if (contacts) {
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
+ if (contacts)
g_list_free (contacts);
- }
}
start_pos = (*((gint*) current_start->data)) + offset_delta;
end_pos = (*((gint*) current_end->data)) + offset_delta;
-
+
start_ptr = g_utf8_offset_to_pointer (recipients, start_pos);
end_ptr = g_utf8_offset_to_pointer (recipients, end_pos);
}
/* Add addresses to address-book */
- if (to_commit_addresses)
- add_to_address_book (to_commit_addresses);
+ 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);
+ }
if (current_start == NULL) {
gtk_text_buffer_get_end_iter (buffer, &end_iter);
if (gtk_dialog_run (GTK_DIALOG (contact_dialog)) == GTK_RESPONSE_OK)
result = osso_abook_contact_chooser_get_selection (contact_dialog);
+ gtk_widget_destroy ((GtkWidget *) contact_dialog);
+
g_free (unquoted);
return result;
*canceled = FALSE;
info = g_slice_new0 (CheckNamesInfo);
show_check_names_banner (info);
-
- contact_model = osso_abook_contact_model_new ();
+
+ contact_model = osso_abook_contact_model_get_default ();
if (!open_addressbook ()) {
hide_check_names_banner (info);
if (contact_model) {
}
}
- g_list_foreach (resolved_contacts, (GFunc)g_object_unref, NULL);
g_list_free (resolved_contacts);
clean_check_names_banner (info);
roster = (OssoABookAggregator *) osso_abook_aggregator_get_default (NULL);
contacts = osso_abook_aggregator_find_contacts_for_email_address (roster, email);
if (!contacts) {
- g_printerr ("modest: failed to get contacts: %s",
- err ? err->message : "<unknown>");
if (err)
g_error_free (err);
g_free (email);
return FALSE;
}
- result = (contacts != NULL);
if (contacts) {
- g_list_foreach (contacts, (GFunc)g_object_unref, NULL);
g_list_free (contacts);
+ result = TRUE;
}
g_free (email);
else
return NULL;
}
+
+void
+modest_address_book_init (void)
+{
+ open_addressbook ();
+}