From 2b46f9493000ca10e264ee3bf221764fcc05b6dc Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Mon, 9 Jun 2008 16:12:54 +0000 Subject: [PATCH] Integrating support for addressbook 4.0 * configure.ac: Replace MODEST_ABOOK_OLD with MODEST_ABOOK_API, which contains the major version number of libosso-abook. Define OSSO_ABOOK_ENABLE_DEPRECATED. * src/maemo/modest-address-book.c: Use OssoABookListStore instead of OssoABookTreeModel when needed. * src/maemo/modest-address-book.c: Use OssoABookContactChooser when MODEST_ABOOK_API suggests it. pmo-trunk-r4624 --- configure.ac | 11 +++++------ src/maemo/modest-address-book.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 6083367..2669999 100644 --- a/configure.ac +++ b/configure.ac @@ -335,12 +335,11 @@ if test "x$with_platform" == "xmaemo"; then AC_SUBST(MODEST_ABOOK_CFLAGS) AC_SUBST(MODEST_ABOOK_LIBS) - if test "x$have_abook" == "xtrue"; then - PKG_CHECK_MODULES(MODEST_ABOOK_OLD, osso-addressbook-1.0 < 2.0, have_old_abook=true,have_old_abook=false) - if test "x$have_old_abook" == "xtrue"; then - AC_DEFINE_UNQUOTED(MODEST_HAVE_OLD_ABOOK, 1, ["whether we have an old osso-addressbook"]) - fi - AC_DEFINE_UNQUOTED(MODEST_HAVE_ABOOK,1, ["whether we have osso-addressbook"]) + if test "x$have_abook" == "xtrue"; then + abook_api=`$PKG_CONFIG --modversion osso-addressbook-1.0 | cut -d. -f1` + AC_DEFINE_UNQUOTED(OSSO_ABOOK_ENABLE_DEPRECATED, 1, ["use deprecated addressbook API"]) + AC_DEFINE_UNQUOTED(MODEST_ABOOK_API, $abook_api, ["the API version of osso-addressbook"]) + AC_DEFINE_UNQUOTED(MODEST_HAVE_ABOOK, 1, ["whether we have osso-addressbook"]) addressbook="osso-addressbook" fi fi diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index 3120bb3..c7087ca 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -82,8 +82,13 @@ get_book_view_cb (EBook *book, EBookStatus status, EBookView *bookview, gpointer book_view = bookview; if (contact_model) +#if MODEST_ABOOK_API < 4 osso_abook_tree_model_set_book_view (OSSO_ABOOK_TREE_MODEL (contact_model), book_view); +#else /* MODEST_ABOOK_API < 4 */ + osso_abook_list_store_set_book_view (OSSO_ABOOK_LIST_STORE (contact_model), + book_view); +#endif /* MODEST_ABOOK_API < 4 */ e_book_view_start (book_view); } @@ -166,15 +171,21 @@ modest_address_book_add_address (const gchar *address) void modest_address_book_select_addresses (ModestRecptEditor *recpt_editor) { +#if MODEST_ABOOK_API < 4 GtkWidget *contact_view = NULL; - GList *contacts_list = NULL; GtkWidget *contact_dialog; +#else /* MODEST_ABOOK_API < 4 */ + OssoABookContactChooser *contact_chooser = NULL; +#endif /* MODEST_ABOOK_API < 4 */ + + GList *contacts_list = NULL; GSList *email_addrs_per_contact = NULL; gchar *econtact_id; gboolean focus_recpt_editor = FALSE; g_return_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor)); +#if MODEST_ABOOK_API < 4 if (!open_addressbook ()) { if (contact_model) { g_object_unref (contact_model); @@ -198,6 +209,18 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor) osso_abook_contact_selector_get_extended_selection (OSSO_ABOOK_CONTACT_SELECTOR (contact_view)); } +#else /* MODEST_ABOOK_API < 4 */ + /* TODO: figure out how to make the contact chooser modal */ + contact_chooser = osso_abook_contact_chooser_new + ("title", _("mcen_ti_select_recipients"), + "help-topic", "", + "minimum-selection", 1, NULL); + + if (osso_abook_contact_chooser_run (contact_chooser) == GTK_RESPONSE_OK) + contacts_list = osso_abook_contact_chooser_get_selection (contact_chooser); + + g_object_unref (contact_chooser); +#endif if (contacts_list) { GList *node; @@ -219,12 +242,14 @@ modest_address_book_select_addresses (ModestRecptEditor *recpt_editor) g_list_free (contacts_list); } +#if MODEST_ABOOK_API < 4 if (contact_model) { g_object_unref (contact_model); contact_model = NULL; } gtk_widget_destroy (contact_dialog); +#endif if (focus_recpt_editor) modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (recpt_editor)); @@ -341,11 +366,11 @@ commit_contact(EContact * contact, gboolean is_new) if (!contact || !book) return; -#ifdef MODEST_HAVE_OLD_ABOOK +#if MODEST_ABOOK_API < 2 osso_abook_contact_commit(contact, is_new, book); #else osso_abook_contact_commit(contact, is_new, book, NULL); -#endif /* MODEST_HILDON_VERSION_0 */ +#endif /* MODEST_ABOOK_API < 2 */ } /** @@ -844,7 +869,11 @@ select_contacts_for_name_dialog (const gchar *name) if (book_view) { GtkWidget *contact_view = NULL; GtkWidget *contact_dialog = NULL; +#if MODEST_ABOOK_API < 4 osso_abook_tree_model_set_book_view (OSSO_ABOOK_TREE_MODEL (contact_model), book_view); +#else /* MODEST_ABOOK_API < 4 */ + osso_abook_list_store_set_book_view (OSSO_ABOOK_LIST_STORE (contact_model), book_view); +#endif /* MODEST_ABOOK_API < 4 */ e_book_view_start (book_view); contact_view = osso_abook_contact_view_new_basic (contact_model); -- 1.7.9.5