[evolution/wip/webkit2] Bug 759802 - Report calendar import errors in UI
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] Bug 759802 - Report calendar import errors in UI
- Date: Tue, 31 May 2016 12:03:14 +0000 (UTC)
commit 411956823a8b3d1fa0fe1eba7b3f99f55e59fae4
Author: Milan Crha <mcrha redhat com>
Date: Wed Mar 23 13:51:26 2016 +0100
Bug 759802 - Report calendar import errors in UI
addressbook/importers/evolution-csv-importer.c | 19 ++++--
addressbook/importers/evolution-ldif-importer.c | 13 +++-
addressbook/importers/evolution-vcard-importer.c | 20 +++--
calendar/importers/icalendar-importer.c | 77 ++++++++++----------
e-util/e-import-assistant.c | 22 ++++--
e-util/e-import.c | 6 +-
e-util/e-import.h | 6 +-
mail/importers/elm-importer.c | 4 +-
mail/importers/evolution-mbox-importer.c | 2 +-
mail/importers/kmail-importer.c | 2 +-
mail/importers/pine-importer.c | 4 +-
modules/startup-wizard/e-mail-config-import-page.c | 30 +++++---
plugins/dbx-import/dbx-importer.c | 2 +-
plugins/pst-import/pst-importer.c | 4 +-
14 files changed, 126 insertions(+), 85 deletions(-)
---
diff --git a/addressbook/importers/evolution-csv-importer.c b/addressbook/importers/evolution-csv-importer.c
index 813f324..e98dc54 100644
--- a/addressbook/importers/evolution-csv-importer.c
+++ b/addressbook/importers/evolution-csv-importer.c
@@ -25,6 +25,7 @@
#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -874,7 +875,7 @@ csv_import_done (CSVImporter *gci)
if (gci->fields_map)
g_hash_table_destroy (gci->fields_map);
- e_import_complete (gci->import, gci->target);
+ e_import_complete (gci->import, gci->target, NULL);
g_object_unref (gci->import);
g_free (gci);
@@ -908,19 +909,27 @@ csv_import (EImport *ei,
ESource *source;
gchar *filename;
FILE *file;
+ gint errn;
EImportTargetURI *s = (EImportTargetURI *) target;
+ GError *error = NULL;
- filename = g_filename_from_uri (s->uri_src, NULL, NULL);
+ filename = g_filename_from_uri (s->uri_src, NULL, &error);
if (filename == NULL) {
- g_message (G_STRLOC ": Couldn't get filename from URI '%s'", s->uri_src);
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
+
return;
}
file = g_fopen (filename, "r");
+ errn = errno;
g_free (filename);
+
if (file == NULL) {
- g_message ("Can't open .csv file");
- e_import_complete (ei, target);
+ error = g_error_new_literal (G_IO_ERROR, g_io_error_from_errno (errn), _("Can't open .csv
file"));
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
+
return;
}
diff --git a/addressbook/importers/evolution-ldif-importer.c b/addressbook/importers/evolution-ldif-importer.c
index 9fa6931..2d0454d 100644
--- a/addressbook/importers/evolution-ldif-importer.c
+++ b/addressbook/importers/evolution-ldif-importer.c
@@ -32,6 +32,7 @@
#include <config.h>
#endif
+#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -669,7 +670,7 @@ ldif_import_done (LDIFImporter *gci)
g_slist_free (gci->list_contacts);
g_hash_table_destroy (gci->dn_contact_hash);
- e_import_complete (gci->import, gci->target);
+ e_import_complete (gci->import, gci->target, NULL);
g_object_unref (gci->import);
g_free (gci);
@@ -704,15 +705,21 @@ ldif_import (EImport *ei,
FILE *file = NULL;
EImportTargetURI *s = (EImportTargetURI *) target;
gchar *filename;
+ gint errn = 0;
filename = g_filename_from_uri (s->uri_src, NULL, NULL);
if (filename != NULL) {
file = g_fopen (filename, "r");
+ errn = errno;
g_free (filename);
}
if (file == NULL) {
- g_message (G_STRLOC ":Can't open .ldif file");
- e_import_complete (ei, target);
+ GError *error;
+
+ error = g_error_new_literal (G_IO_ERROR, g_io_error_from_errno (errn), _("Can't open .ldif
file"));
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
+
return;
}
diff --git a/addressbook/importers/evolution-vcard-importer.c
b/addressbook/importers/evolution-vcard-importer.c
index 2d3ba85..9903679 100644
--- a/addressbook/importers/evolution-vcard-importer.c
+++ b/addressbook/importers/evolution-vcard-importer.c
@@ -463,7 +463,7 @@ vcard_import_done (VCardImporter *gci)
g_object_unref (gci->book_client);
g_slist_free_full (gci->contactlist, (GDestroyNotify) g_object_unref);
- e_import_complete (gci->import, gci->target);
+ e_import_complete (gci->import, gci->target, NULL);
g_object_unref (gci->import);
g_free (gci);
}
@@ -523,11 +523,13 @@ vcard_import (EImport *ei,
gchar *filename;
gchar *contents;
VCardEncoding encoding;
+ GError *error = NULL;
- filename = g_filename_from_uri (s->uri_src, NULL, NULL);
+ filename = g_filename_from_uri (s->uri_src, NULL, &error);
if (filename == NULL) {
- g_message (G_STRLOC ": Couldn't get filename from URI '%s'", s->uri_src);
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
+
return;
}
encoding = guess_vcard_encoding (filename);
@@ -535,14 +537,16 @@ vcard_import (EImport *ei,
g_free (filename);
/* This check is superfluous, we've already
* checked otherwise we can't get here ... */
- e_import_complete (ei, target);
+ e_import_complete (ei, target, NULL);
+
return;
}
- if (!g_file_get_contents (filename, &contents, NULL, NULL)) {
- g_message (G_STRLOC ":Couldn't read file.");
+ if (!g_file_get_contents (filename, &contents, NULL, &error)) {
g_free (filename);
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
+
return;
}
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index c255315..af47264 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -95,13 +95,14 @@ is_icalcomp_usable (icalcomponent *icalcomp)
}
static void
-ivcal_import_done (ICalImporter *ici)
+ivcal_import_done (ICalImporter *ici,
+ const GError *error)
{
if (ici->cal_client)
g_object_unref (ici->cal_client);
icalcomponent_free (ici->icalcomp);
- e_import_complete (ici->import, ici->target);
+ e_import_complete (ici->import, ici->target, error);
g_object_unref (ici->import);
g_object_unref (ici->cancellable);
g_free (ici);
@@ -169,7 +170,7 @@ prepare_tasks (icalcomponent *icalcomp,
struct UpdateObjectsData
{
- void (*done_cb) (gpointer user_data);
+ void (*done_cb) (gpointer user_data, const GError *error);
gpointer user_data;
};
@@ -186,15 +187,10 @@ receive_objects_ready_cb (GObject *source_object,
e_cal_client_receive_objects_finish (cal_client, result, &error);
- if (error != NULL) {
- g_warning (
- "%s: Failed to receive objects: %s",
- G_STRFUNC, error->message);
- g_error_free (error);
- }
-
if (uod->done_cb)
- uod->done_cb (uod->user_data);
+ uod->done_cb (uod->user_data, error);
+ g_clear_error (&error);
+
g_free (uod);
}
@@ -202,7 +198,7 @@ static void
update_objects (ECalClient *cal_client,
icalcomponent *icalcomp,
GCancellable *cancellable,
- void (*done_cb) (gpointer user_data),
+ void (*done_cb) (gpointer user_data, const GError *error),
gpointer user_data)
{
icalcomponent_kind kind;
@@ -223,7 +219,7 @@ update_objects (ECalClient *cal_client,
icalcomponent_set_method (vcal, ICAL_METHOD_PUBLISH);
} else {
if (done_cb)
- done_cb (user_data);
+ done_cb (user_data, NULL);
return;
}
@@ -423,9 +419,10 @@ ivcal_getwidget (EImport *ei,
}
static void
-ivcal_call_import_done (gpointer user_data)
+ivcal_call_import_done (gpointer user_data,
+ const GError *error)
{
- ivcal_import_done (user_data);
+ ivcal_import_done (user_data, error);
}
static gboolean
@@ -446,7 +443,7 @@ ivcal_import_items (gpointer d)
g_warn_if_reached ();
ici->idle_id = 0;
- ivcal_import_done (ici);
+ ivcal_import_done (ici, NULL);
return FALSE;
}
@@ -474,9 +471,8 @@ ivcal_connect_cb (GObject *source_object,
((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, error->message);
+ ivcal_import_done (ici, error);
g_error_free (error);
- ivcal_import_done (ici);
return;
}
@@ -579,17 +575,20 @@ ical_import (EImport *ei,
gchar *filename;
gchar *contents;
icalcomponent *icalcomp;
+ GError *error = NULL;
EImportTargetURI *s = (EImportTargetURI *) target;
- filename = g_filename_from_uri (s->uri_src, NULL, NULL);
+ filename = g_filename_from_uri (s->uri_src, NULL, &error);
if (!filename) {
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
return;
}
- if (!g_file_get_contents (filename, &contents, NULL, NULL)) {
+ if (!g_file_get_contents (filename, &contents, NULL, &error)) {
g_free (filename);
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
+ g_clear_error (&error);
return;
}
g_free (filename);
@@ -600,7 +599,7 @@ ical_import (EImport *ei,
if (icalcomp)
ivcal_import (ei, target, icalcomp);
else
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
}
static GtkWidget *
@@ -772,10 +771,11 @@ vcal_import (EImport *ei,
gchar *filename;
icalcomponent *icalcomp;
EImportTargetURI *s = (EImportTargetURI *) target;
+ GError *error = NULL;
- filename = g_filename_from_uri (s->uri_src, NULL, NULL);
+ filename = g_filename_from_uri (s->uri_src, NULL, &error);
if (!filename) {
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
return;
}
@@ -784,7 +784,7 @@ vcal_import (EImport *ei,
if (icalcomp)
ivcal_import (ei, target, icalcomp);
else
- e_import_complete (ei, target);
+ e_import_complete (ei, target, error);
}
static GtkWidget *
@@ -953,13 +953,14 @@ open_default_source (ICalIntelligentImporter *ici,
}
static void
-continue_done_cb (gpointer user_data)
+continue_done_cb (gpointer user_data,
+ const GError *error)
{
ICalIntelligentImporter *ici = user_data;
g_return_if_fail (ici != NULL);
- e_import_complete (ici->ei, ici->target);
+ e_import_complete (ici->ei, ici->target, error);
}
static void
@@ -970,10 +971,7 @@ gc_import_tasks (ECalClient *cal_client,
g_return_if_fail (ici != NULL);
if (error != NULL) {
- g_warning (
- "%s: Failed to open tasks: %s",
- G_STRFUNC, error->message);
- e_import_complete (ici->ei, ici->target);
+ e_import_complete (ici->ei, ici->target, error);
return;
}
@@ -987,13 +985,17 @@ gc_import_tasks (ECalClient *cal_client,
}
static void
-continue_tasks_cb (gpointer user_data)
+continue_tasks_cb (gpointer user_data,
+ const GError *error)
{
ICalIntelligentImporter *ici = user_data;
g_return_if_fail (ici != NULL);
- open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks);
+ if (error)
+ continue_done_cb (ici, error);
+ else
+ open_default_source (ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS, gc_import_tasks);
}
static void
@@ -1004,15 +1006,12 @@ gc_import_events (ECalClient *cal_client,
g_return_if_fail (ici != NULL);
if (error != NULL) {
- g_warning (
- "%s: Failed to open events calendar: %s",
- G_STRFUNC, error->message);
if (ici->tasks)
open_default_source (
ici, E_CAL_CLIENT_SOURCE_TYPE_TASKS,
gc_import_tasks);
else
- e_import_complete (ici->ei, ici->target);
+ e_import_complete (ici->ei, ici->target, error);
return;
}
@@ -1071,7 +1070,7 @@ gnome_calendar_import (EImport *ei,
}
}
- e_import_complete (ei, target);
+ e_import_complete (ei, target, NULL);
}
static void
diff --git a/e-util/e-import-assistant.c b/e-util/e-import-assistant.c
index 0a2c35a..d028312 100644
--- a/e-util/e-import-assistant.c
+++ b/e-util/e-import-assistant.c
@@ -33,6 +33,7 @@
#include <gdk/gdkkeysyms.h>
#include <libebackend/libebackend.h>
+#include "e-dialog-utils.h"
#include "e-dialog-widgets.h"
#include "e-import.h"
#include "e-util-private.h"
@@ -137,8 +138,12 @@ G_DEFINE_TYPE_WITH_CODE (
/* Importing functions */
static void
-import_assistant_emit_finished (EImportAssistant *import_assistant)
+import_assistant_finished (EImportAssistant *import_assistant,
+ const GError *error)
{
+ if (error)
+ e_notice (import_assistant, GTK_MESSAGE_ERROR, "%s", error->message);
+
g_signal_emit (import_assistant, signals[FINISHED], 0);
}
@@ -596,15 +601,17 @@ import_status (EImport *import,
static void
import_done (EImport *ei,
+ const GError *error,
gpointer user_data)
{
EImportAssistant *import_assistant = user_data;
- import_assistant_emit_finished (import_assistant);
+ import_assistant_finished (import_assistant, error);
}
static void
import_simple_done (EImport *ei,
+ const GError *error,
gpointer user_data)
{
EImportAssistant *import_assistant = user_data;
@@ -617,7 +624,7 @@ import_simple_done (EImport *ei,
g_return_if_fail (priv->fileuris != NULL);
g_return_if_fail (priv->simple_page.target != NULL);
- if (import_assistant->priv->fileuris->len > 0) {
+ if (!error && import_assistant->priv->fileuris->len > 0) {
import_status (ei, "", 0, import_assistant);
/* process next file URI */
@@ -630,11 +637,12 @@ import_simple_done (EImport *ei,
priv->import_importer, import_status,
import_simple_done, import_assistant);
} else
- import_done (ei, import_assistant);
+ import_done (ei, error, import_assistant);
}
static void
import_intelligent_done (EImport *ei,
+ const GError *error,
gpointer user_data)
{
EImportAssistant *import_assistant = user_data;
@@ -642,7 +650,7 @@ import_intelligent_done (EImport *ei,
page = &import_assistant->priv->selection_page;
- if (page->current && (page->current = page->current->next)) {
+ if (!error && page->current && (page->current = page->current->next)) {
import_status (ei, "", 0, import_assistant);
import_assistant->priv->import_importer = page->current->data;
e_import_import (
@@ -652,7 +660,7 @@ import_intelligent_done (EImport *ei,
import_status, import_intelligent_done,
import_assistant);
} else
- import_done (ei, import_assistant);
+ import_done (ei, error, import_assistant);
}
static void
@@ -809,7 +817,7 @@ prepare_progress_page (GtkAssistant *assistant,
priv->import_importer, import_status,
done, assistant);
else
- import_assistant_emit_finished (E_IMPORT_ASSISTANT (assistant));
+ import_assistant_finished (E_IMPORT_ASSISTANT (assistant), NULL);
}
static void
diff --git a/e-util/e-import.c b/e-util/e-import.c
index 75531b3..b35319c 100644
--- a/e-util/e-import.c
+++ b/e-util/e-import.c
@@ -222,16 +222,18 @@ e_import_get_preview_widget (EImport *import,
* e_import_complete:
* @import: an #EImport
* @target: Target just completed (unused currently)
+ * @error: a #GError for the operation, %NULL when succeeded
*
* Signify that an import is complete. This must be called by
* importer implementations when they are done.
**/
void
e_import_complete (EImport *import,
- EImportTarget *target)
+ EImportTarget *target,
+ const GError *error)
{
if (import->done)
- import->done (import, import->done_data);
+ import->done (import, error, import->done_data);
}
void
diff --git a/e-util/e-import.h b/e-util/e-import.h
index 8bedcbf..0c9b34d 100644
--- a/e-util/e-import.h
+++ b/e-util/e-import.h
@@ -58,7 +58,8 @@ typedef struct _EImportFactory EImportFactory;
typedef struct _EImportTarget EImportTarget;
typedef void (*EImportCompleteFunc) (EImport *ei,
- gpointer data);
+ const GError *error,
+ gpointer user_data);
typedef void (*EImportStatusFunc) (EImport *ei,
const gchar *what,
gint pc,
@@ -227,7 +228,8 @@ void e_import_status (EImport *import,
const gchar *what,
gint pc);
void e_import_complete (EImport *import,
- EImportTarget *target);
+ EImportTarget *target,
+ const GError *error);
gpointer e_import_target_new (EImport *import,
gint type,
gsize size);
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
index b7cb38a..454cab4 100644
--- a/mail/importers/elm-importer.c
+++ b/mail/importers/elm-importer.c
@@ -213,7 +213,7 @@ elm_import_exec (struct _elm_import_msg *m,
static void
elm_import_done (struct _elm_import_msg *m)
{
- e_import_complete (m->import, (EImportTarget *) m->target);
+ e_import_complete (m->import, (EImportTarget *) m->target, m->base.error);
}
static void
@@ -346,7 +346,7 @@ elm_import (EImport *ei,
if (GPOINTER_TO_INT (g_datalist_get_data (&target->data, "elm-do-mail")))
mail_importer_elm_import (ei, target);
else
- e_import_complete (ei, target);
+ e_import_complete (ei, target, NULL);
}
static void
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index 5187c74..6a9ba05 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -283,7 +283,7 @@ mbox_import_done (gpointer data,
g_mutex_clear (&importer->status_lock);
g_object_unref (importer->cancellable);
- e_import_complete (importer->import, importer->target);
+ e_import_complete (importer->import, importer->target, error ? *error : NULL);
g_free (importer);
}
diff --git a/mail/importers/kmail-importer.c b/mail/importers/kmail-importer.c
index f60ab67..f454c45 100644
--- a/mail/importers/kmail-importer.c
+++ b/mail/importers/kmail-importer.c
@@ -86,7 +86,7 @@ kmail_import_done (gpointer data,
g_mutex_clear (&importer->status_lock);
g_object_unref (importer->cancellable);
- e_import_complete (importer->import, importer->target);
+ e_import_complete (importer->import, importer->target, error ? *error : NULL);
g_free (importer);
}
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
index 8ce8e9c..074ac3b 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -285,7 +285,7 @@ pine_import_exec (struct _pine_import_msg *m,
static void
pine_import_done (struct _pine_import_msg *m)
{
- e_import_complete (m->import, (EImportTarget *) m->target);
+ e_import_complete (m->import, (EImportTarget *) m->target, m->base.error);
}
static void
@@ -447,7 +447,7 @@ pine_import (EImport *ei,
|| GPOINTER_TO_INT (g_datalist_get_data (&target->data, "pine-do-addr")))
mail_importer_pine_import (ei, target);
else
- e_import_complete (ei, target);
+ e_import_complete (ei, target, NULL);
}
static void
diff --git a/modules/startup-wizard/e-mail-config-import-page.c
b/modules/startup-wizard/e-mail-config-import-page.c
index e459636..c2e79aa 100644
--- a/modules/startup-wizard/e-mail-config-import-page.c
+++ b/modules/startup-wizard/e-mail-config-import-page.c
@@ -77,10 +77,11 @@ async_context_free (AsyncContext *async_context)
static void
mail_config_import_page_status (EImport *import,
- const gchar *what,
- gint percent,
- GSimpleAsyncResult *simple)
+ const gchar *what,
+ gint percent,
+ gpointer user_data)
{
+ GSimpleAsyncResult *simple = user_data;
AsyncContext *async_context;
async_context = g_simple_async_result_get_op_res_gpointer (simple);
@@ -91,10 +92,19 @@ mail_config_import_page_status (EImport *import,
static void
mail_config_import_page_complete (EImport *import,
- GSimpleAsyncResult *simple)
+ const GError *error,
+ gpointer user_data)
{
- /* Schedule the next importer to start. */
- g_idle_add (mail_config_import_page_next, simple);
+ GSimpleAsyncResult *simple = user_data;
+
+ if (error) {
+ g_simple_async_result_set_from_error (simple, error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ } else {
+ /* Schedule the next importer to start. */
+ g_idle_add (mail_config_import_page_next, simple);
+ }
}
static gboolean
@@ -124,8 +134,8 @@ mail_config_import_page_next (gpointer user_data)
async_context->page->priv->import,
async_context->page->priv->import_target,
next_importer,
- (EImportStatusFunc) mail_config_import_page_status,
- (EImportCompleteFunc) mail_config_import_page_complete,
+ mail_config_import_page_status,
+ mail_config_import_page_complete,
simple);
} else {
@@ -349,8 +359,8 @@ e_mail_config_import_page_import (EMailConfigImportPage *page,
async_context->page->priv->import,
async_context->page->priv->import_target,
first_importer,
- (EImportStatusFunc) mail_config_import_page_status,
- (EImportCompleteFunc) mail_config_import_page_complete,
+ mail_config_import_page_status,
+ mail_config_import_page_complete,
simple);
else
g_simple_async_result_complete_in_idle (simple);
diff --git a/plugins/dbx-import/dbx-importer.c b/plugins/dbx-import/dbx-importer.c
index 86aae18..c338930 100644
--- a/plugins/dbx-import/dbx-importer.c
+++ b/plugins/dbx-import/dbx-importer.c
@@ -723,7 +723,7 @@ dbx_import_import (DbxImporter *m,
static void
dbx_import_imported (DbxImporter *m)
{
- e_import_complete (m->target->import, (EImportTarget *) m->target);
+ e_import_complete (m->target->import, (EImportTarget *) m->target, m->base.error);
}
static void
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index c6be13f..5aacb4b 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -2062,7 +2062,7 @@ pst_error_msg (const gchar *fmt,
static void
pst_import_imported (PstImporter *m)
{
- e_import_complete (m->target->import, (EImportTarget *) m->target);
+ e_import_complete (m->target->import, (EImportTarget *) m->target, m->base.error);
}
static void
@@ -2181,7 +2181,7 @@ org_credativ_evolution_readpst_import (EImport *ei,
|| GPOINTER_TO_INT (g_datalist_get_data (&target->data, "pst-do-journal"))) {
pst_import (ei, target);
} else {
- e_import_complete (target->import, target);
+ e_import_complete (target->import, target, NULL);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]