From 2a772badda42e30da739c944c29b80bcdbb58b1b Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Wed, 29 Sep 2010 10:43:04 +0200 Subject: Bug #629636 - Doesn't recognize local ESource-s --- addressbook/gui/widgets/eab-gui-util.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'addressbook') diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c index 4cf5219e71..a40a3a3ff5 100644 --- a/addressbook/gui/widgets/eab-gui-util.c +++ b/addressbook/gui/widgets/eab-gui-util.c @@ -74,11 +74,30 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, const GError *error) "to download its contents."); } - else if (uri && !strncmp (uri, "file:", 5)) { - gchar *path = g_filename_from_uri (uri, NULL, NULL); + else if (uri && g_str_has_prefix (uri, "local:")) { + const gchar *user_data_dir; + const gchar *source_dir; + gchar *mangled_source_dir; + gchar *path; + + user_data_dir = e_get_user_data_dir (); + source_dir = e_source_peek_relative_uri (source); + + if (!source_dir || !g_str_equal (source_dir, "system")) + source_dir = e_source_peek_uid (source); + + /* Mangle the URI to not contain invalid characters. */ + mangled_source_dir = g_strdelimit (g_strdup (source_dir), ":/", '_'); + + path = g_build_filename ( + user_data_dir, "addressbook", mangled_source_dir, NULL); + + g_free (mangled_source_dir); + label = g_strdup_printf ( _("This address book cannot be opened. Please check that the " "path %s exists and that permissions are set to access it."), path); + g_free (path); label_string = label; } -- cgit