aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/addressbook-component.c
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/component/addressbook-component.c')
-rw-r--r--addressbook/gui/component/addressbook-component.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c
index 8117ced2cf..3e414f86f9 100644
--- a/addressbook/gui/component/addressbook-component.c
+++ b/addressbook/gui/component/addressbook-component.c
@@ -279,6 +279,8 @@ static void
local_addressbook_cb (EBook *book, gpointer closure)
{
gboolean is_list = GPOINTER_TO_INT (closure);
+ if (book == NULL)
+ return;
if (is_list)
e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, TRUE);
else
@@ -286,21 +288,44 @@ local_addressbook_cb (EBook *book, gpointer closure)
}
static void
+nonlocal_addressbook_cb (EBook *book, EBookStatus status, gpointer closure)
+{
+ if (status == E_BOOK_STATUS_SUCCESS)
+ local_addressbook_cb (book, closure);
+ else
+ local_addressbook_cb (NULL, closure);
+}
+
+static void
user_create_new_item_cb (EvolutionShellComponent *shell_component,
const char *id,
const char *parent_folder_physical_uri,
const char *parent_folder_type,
gpointer data)
{
+ gboolean is_contact_list;
if (!strcmp (id, "contact")) {
- e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (0));
- return;
+ is_contact_list = FALSE;
} else if (!strcmp (id, "contact_list")) {
- e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (1));
+ is_contact_list = TRUE;
+ } else {
+ g_warning ("Don't know how to create item of type \"%s\"", id);
return;
- }
+ }
+ if (IS_CONTACT_TYPE (parent_folder_type)) {
+ EBook *book;
+ gchar *uri;
+
+ book = e_book_new ();
+ uri = g_strdup_printf ("%s/addressbook.db", parent_folder_physical_uri);
- g_warning ("Don't know how to create item of type \"%s\"", id);
+ if (e_book_load_uri (book, uri, nonlocal_addressbook_cb, GINT_TO_POINTER (is_contact_list)) == 0)
+ g_warning ("Couldn't load addressbook %s", uri);
+
+ g_free (uri);
+ } else {
+ e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (is_contact_list));
+ }
}