X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo%2Fmodest-address-book.c;h=faa1fb1586fdfa29f1a6162d356177ead7137767;hb=e468d62e86da9f16820ac0cc8d7d1f106bf080bf;hp=61f92851cd775e029811a4eae9498a49dcdea51b;hpb=cc379b2109f5c1b1a70419454d1a0e53c26559e6;p=modest diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index 61f9285..faa1fb1 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -508,7 +508,7 @@ run_add_email_addr_to_contact_dlg(const gchar * contact_name) if ((invalid_char_offset != NULL)&&(*invalid_char_offset != '\0')) { gchar *char_in_string = g_strdup_printf ("%c", *invalid_char_offset); gchar *message = g_strdup_printf( - dgettext("hildon-common-strings", "ckdg_ib_illegal_characters_entered"), + _CS("ckdg_ib_illegal_characters_entered"), char_in_string); hildon_banner_show_information ( add_email_addr_to_contact_dlg, NULL, message ); @@ -753,11 +753,11 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat if ((invalid_char_position != NULL) && (*invalid_char_position != '\0')) { gchar *char_in_string = g_strdup_printf("%c", *invalid_char_position); gchar *message = g_strdup_printf( - dgettext("hildon-common-strings", "ckdg_ib_illegal_characters_entered"), + _CS("ckdg_ib_illegal_characters_entered"), char_in_string); g_free (char_in_string); hildon_banner_show_information (NULL, NULL, message ); - g_free (message); + g_free (message); result = FALSE; } else if (strstr (address, "@") == NULL) { /* here goes searching in addressbook */ @@ -996,3 +996,45 @@ unquote_string (const gchar *str) return g_string_free (buffer, FALSE); } + +gboolean +modest_address_book_has_address (const gchar *address) +{ + EBookQuery *query; + GList *contacts = NULL; + GError *err = NULL; + gchar *email; + gboolean result; + + g_return_val_if_fail (address, FALSE); + + if (!book) { + if (!open_addressbook ()) { + g_return_val_if_reached (FALSE); + } + } + + g_return_val_if_fail (book, FALSE); + + email = modest_text_utils_get_email_address (address); + + query = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_IS, email); + if (!e_book_get_contacts (book, query, &contacts, &err)) { + g_printerr ("modest: failed to get contacts: %s", + err ? err->message : ""); + if (err) + g_error_free (err); + return FALSE; + } + e_book_query_unref (query); + + result = (contacts != NULL); + if (contacts) { + g_list_foreach (contacts, (GFunc)unref_gobject, NULL); + g_list_free (contacts); + } + + g_free (email); + + return result; +}