diff options
author | Milan Crha <mcrha@redhat.com> | 2010-07-09 20:29:51 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2010-07-09 20:29:51 +0800 |
commit | 03d626856b294bc98919ac244e04e9b8821a681d (patch) | |
tree | 62433e158f1791aa6b9222ecbe05d164c4703f6c /calendar | |
parent | 6d4ce8571ff62a3e489999d2feeac1691e06c59a (diff) | |
download | gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.gz gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.zst gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.zip |
Bug #623204 - Be able to report detailed errors from backends
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify.c | 8 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 8 | ||||
-rw-r--r-- | calendar/gui/dialogs/delete-error.c | 30 | ||||
-rw-r--r-- | calendar/gui/dialogs/delete-error.h | 2 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.c | 31 | ||||
-rw-r--r-- | calendar/gui/e-cal-model.h | 6 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 12 | ||||
-rw-r--r-- | calendar/gui/e-memo-table.c | 11 | ||||
-rw-r--r-- | calendar/gui/e-task-table.c | 11 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 23 | ||||
-rw-r--r-- | calendar/importers/icalendar-importer.c | 6 |
11 files changed, 92 insertions, 56 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index 7ad414c61c..df6a8fc4f7 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -308,16 +308,16 @@ alarm_notify_new (void) } static void -cal_opened_cb (ECal *client, ECalendarStatus status, gpointer user_data) +cal_opened_cb (ECal *client, const GError *error, gpointer user_data) { AlarmNotifyPrivate *priv; AlarmNotify *an = ALARM_NOTIFY (user_data); priv = an->priv; - d (printf("%s:%d (cal_opened_cb) %s - Calendar Status %d\n", __FILE__, __LINE__, e_cal_get_uri (client), status)); + d (printf("%s:%d (cal_opened_cb) %s - Calendar Status %d%s%s%s\n", __FILE__, __LINE__, e_cal_get_uri (client), error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); - if (status == E_CALENDAR_STATUS_OK) + if (!error) alarm_queue_add_client (client); else { g_hash_table_remove (priv->uri_client_hash[e_cal_get_source_type (client)], @@ -389,7 +389,7 @@ alarm_notify_add_calendar (AlarmNotify *an, ECalSourceType source_type, ESource if (client) { d (printf("%s:%d (alarm_notify_add_calendar) %s - Calendar Open Async... %p\n", __FILE__, __LINE__, str_uri, client)); g_hash_table_insert (priv->uri_client_hash[source_type], g_strdup (str_uri), client); - g_signal_connect (G_OBJECT (client), "cal_opened", G_CALLBACK (cal_opened_cb), an); + g_signal_connect (G_OBJECT (client), "cal_opened_ex", G_CALLBACK (cal_opened_cb), an); /* to resolve floating DATE-TIME properly */ e_cal_set_default_timezone (client, config_data_get_timezone (), NULL); e_cal_open_async (client, FALSE); diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index f7ef6fdcf4..426d69ec55 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -597,14 +597,14 @@ load_alarms_for_today (ClientAlarms *ca) /* Called when a calendar client finished loading; we load its alarms */ static void -cal_opened_cb (ECal *client, ECalendarStatus status, gpointer data) +cal_opened_cb (ECal *client, const GError *error, gpointer data) { ClientAlarms *ca; ca = data; - d(printf("%s:%d (cal_opened_cb) - Opened Calendar %p (Status %d)\n",__FILE__, __LINE__, client, status==E_CALENDAR_STATUS_OK)); - if (status != E_CALENDAR_STATUS_OK) + d(printf("%s:%d (cal_opened_cb) - Opened Calendar %p (Status %d%s%s%s)\n",__FILE__, __LINE__, client, error ? error->code : 0, error ? " (" : "", error ? error->message : "", error ? ")" : "")); + if (error) return; load_alarms_for_today (ca); @@ -1999,7 +1999,7 @@ alarm_queue_add_async (struct _alarm_client_msg *msg) if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) { load_alarms_for_today (ca); } else { - g_signal_connect (client, "cal_opened", + g_signal_connect (client, "cal_opened_ex", G_CALLBACK (cal_opened_cb), ca); } diff --git a/calendar/gui/dialogs/delete-error.c b/calendar/gui/dialogs/delete-error.c index c312e16ada..9b9d22ae4c 100644 --- a/calendar/gui/dialogs/delete-error.c +++ b/calendar/gui/dialogs/delete-error.c @@ -39,7 +39,7 @@ * **/ void -delete_error_dialog (GError *error, ECalComponentVType vtype) +delete_error_dialog (const GError *error, ECalComponentVType vtype) { GtkWidget *dialog; const gchar *str; @@ -49,19 +49,23 @@ delete_error_dialog (GError *error, ECalComponentVType vtype) return; switch (error->code) { - case E_CALENDAR_STATUS_CORBA_EXCEPTION: + case E_CALENDAR_STATUS_DBUS_EXCEPTION: switch (vtype) { case E_CAL_COMPONENT_EVENT: - str = _("The event could not be deleted due to a corba error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The event could not be deleted due to a dbus error: %s"); break; case E_CAL_COMPONENT_TODO: - str = _("The task could not be deleted due to a corba error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The task could not be deleted due to a dbus error: %s"); break; case E_CAL_COMPONENT_JOURNAL: - str = _("The memo could not be deleted due to a corba error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The memo could not be deleted due to a dbus error: %s"); break; default: - str = _("The item could not be deleted due to a corba error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The item could not be deleted due to a dbus error: %s"); break; } break; @@ -84,16 +88,20 @@ delete_error_dialog (GError *error, ECalComponentVType vtype) case E_CALENDAR_STATUS_OTHER_ERROR: switch (vtype) { case E_CAL_COMPONENT_EVENT: - str = _("The event could not be deleted due to an error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The event could not be deleted due to an error: %s"); break; case E_CAL_COMPONENT_TODO: - str = _("The task could not be deleted due to an error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The task could not be deleted due to an error: %s"); break; case E_CAL_COMPONENT_JOURNAL: - str = _("The memo could not be deleted due to an error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The memo could not be deleted due to an error: %s"); break; default: - str = _("The item could not be deleted due to an error"); + /* Translators: The '%s' is replaced with a detailed error message */ + str = _("The item could not be deleted due to an error: %s"); break; } break; @@ -106,7 +114,7 @@ delete_error_dialog (GError *error, ECalComponentVType vtype) dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, "%s", str); + GTK_BUTTONS_OK, str, error->message); if (vtype == E_CAL_COMPONENT_EVENT) icon_name = "x-office-calendar"; else if (vtype == E_CAL_COMPONENT_TODO) diff --git a/calendar/gui/dialogs/delete-error.h b/calendar/gui/dialogs/delete-error.h index dab620541f..0353d188f2 100644 --- a/calendar/gui/dialogs/delete-error.h +++ b/calendar/gui/dialogs/delete-error.h @@ -30,6 +30,6 @@ #include <libecal/e-cal.h> #include <libecal/e-cal-component.h> -void delete_error_dialog (GError *error, ECalComponentVType vtype); +void delete_error_dialog (const GError *error, ECalComponentVType vtype); #endif diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c index e745d33810..d04c87ad93 100644 --- a/calendar/gui/e-cal-model.c +++ b/calendar/gui/e-cal-model.c @@ -136,7 +136,10 @@ enum { ROW_APPENDED, COMPS_DELETED, CAL_VIEW_PROGRESS, + #ifndef E_CAL_DISABLE_DEPRECATED CAL_VIEW_DONE, + #endif + CAL_VIEW_COMPLETE, STATUS_MESSAGE, TIMEZONE_CHANGED, LAST_SIGNAL @@ -394,6 +397,8 @@ e_cal_model_class_init (ECalModelClass *class) NULL, NULL, e_marshal_VOID__STRING_INT_INT, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); + + #ifndef E_CAL_DISABLE_DEPRECATED signals[CAL_VIEW_DONE] = g_signal_new ("cal_view_done", G_TYPE_FROM_CLASS (class), @@ -402,6 +407,16 @@ e_cal_model_class_init (ECalModelClass *class) NULL, NULL, e_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); + #endif + + signals[CAL_VIEW_COMPLETE] = + g_signal_new ("cal_view_complete", + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ECalModelClass, cal_view_complete), + NULL, NULL, + e_marshal_VOID__INT_STRING_INT, + G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_STRING, G_TYPE_INT); signals[STATUS_MESSAGE] = g_signal_new ( "status-message", @@ -2003,16 +2018,20 @@ e_cal_view_progress_cb (ECalView *query, const gchar *message, gint percent, gpo } static void -e_cal_view_done_cb (ECalView *query, ECalendarStatus status, gpointer user_data) +e_cal_view_complete_cb (ECalView *query, ECalendarStatus status, const gchar *error_msg, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; ECal *client = e_cal_view_get_client (query); g_return_if_fail (E_IS_CAL_MODEL (model)); + #ifndef E_CAL_DISABLE_DEPRECATED /* emit the signal on the model and let the view catch it to display */ g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_DONE], 0, status, e_cal_get_source_type (client)); + #endif + g_signal_emit (G_OBJECT (model), signals[CAL_VIEW_COMPLETE], 0, status, error_msg, + e_cal_get_source_type (client)); } static void @@ -2062,7 +2081,7 @@ try_again: g_signal_connect (client_data->query, "objects_modified", G_CALLBACK (e_cal_view_objects_modified_cb), model); g_signal_connect (client_data->query, "objects_removed", G_CALLBACK (e_cal_view_objects_removed_cb), model); g_signal_connect (client_data->query, "view_progress", G_CALLBACK (e_cal_view_progress_cb), model); - g_signal_connect (client_data->query, "view_done", G_CALLBACK (e_cal_view_done_cb), model); + g_signal_connect (client_data->query, "view_complete", G_CALLBACK (e_cal_view_complete_cb), model); e_cal_view_start (client_data->query); } @@ -2086,17 +2105,17 @@ backend_died_cb (ECal *client, gpointer user_data) } static void -cal_opened_cb (ECal *client, ECalendarStatus status, gpointer user_data) +cal_opened_cb (ECal *client, const GError *error, gpointer user_data) { ECalModel *model = (ECalModel *) user_data; ECalModelClient *client_data; - if (status == E_CALENDAR_STATUS_BUSY) { + if (g_error_matches (error, E_CALENDAR_ERROR, E_CALENDAR_STATUS_BUSY)) { e_cal_open_async (client, FALSE); return; } - if (status != E_CALENDAR_STATUS_OK) { + if (error) { e_cal_model_remove_client (model, client); e_cal_model_update_status_message (model, NULL, -1.0); return; @@ -2159,7 +2178,7 @@ add_new_client (ECalModel *model, ECal *client, gboolean do_query) e_cal_set_default_timezone (client, e_cal_model_get_timezone (model), NULL); - g_signal_connect (client, "cal_opened", G_CALLBACK (cal_opened_cb), model); + g_signal_connect (client, "cal_opened_ex", G_CALLBACK (cal_opened_cb), model); e_cal_open_async (client, TRUE); } diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h index 29c3335310..2750006f06 100644 --- a/calendar/gui/e-cal-model.h +++ b/calendar/gui/e-cal-model.h @@ -160,9 +160,15 @@ struct _ECalModelClass { const gchar *message, gint progress, ECalSourceType type); + #ifndef E_CAL_DISABLE_DEPRECATED void (*cal_view_done) (ECalModel *model, ECalendarStatus status, ECalSourceType type); + #endif + void (*cal_view_complete) (ECalModel *model, + ECalendarStatus status, + const gchar *error_msg, + ECalSourceType type); void (*status_message) (ECalModel *model, const gchar *message, gdouble percent); diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index fed200d34c..dd9516f7bf 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -142,7 +142,7 @@ set_ok_sens (EItipControl *itip) } static void -cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data) +cal_opened_cb (ECal *ecal, const GError *error, gpointer data) { EItipControl *itip = data; EItipControlPrivate *priv; @@ -156,7 +156,7 @@ cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data) g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, cal_opened_cb, NULL); - if (status != E_CALENDAR_STATUS_OK) { + if (error) { g_hash_table_remove (priv->ecals[source_type], e_source_peek_uid (source)); return; @@ -166,7 +166,7 @@ cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data) set_ok_sens (itip); } -typedef void (* EItipControlOpenFunc) (ECal *ecal, ECalendarStatus status, gpointer data); +typedef void (* EItipControlOpenFunc) (ECal *ecal, const GError *error, gpointer data); static ECal * start_calendar_server (EItipControl *itip, ESource *source, ECalSourceType type, EItipControlOpenFunc func, gpointer data) @@ -189,7 +189,7 @@ start_calendar_server (EItipControl *itip, ESource *source, ECalSourceType type, zone = calendar_config_get_icaltimezone (); e_cal_set_default_timezone (ecal, zone, NULL); - g_signal_connect (G_OBJECT (ecal), "cal_opened", G_CALLBACK (func), data); + g_signal_connect (G_OBJECT (ecal), "cal_opened_ex", G_CALLBACK (func), data); g_hash_table_insert (priv->ecals[type], g_strdup (e_source_peek_uid (source)), ecal); @@ -239,7 +239,7 @@ source_changed_cb (ESourceComboBox *escb, EItipControl *itip) } static void -find_cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data) +find_cal_opened_cb (ECal *ecal, const GError *error, gpointer data) { EShell *shell; EShellSettings *shell_settings; @@ -262,7 +262,7 @@ find_cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data) g_signal_handlers_disconnect_matched (ecal, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, find_cal_opened_cb, NULL); - if (status != E_CALENDAR_STATUS_OK) { + if (error) { g_hash_table_remove (priv->ecals[source_type], e_source_peek_uid (source)); goto cleanup; diff --git a/calendar/gui/e-memo-table.c b/calendar/gui/e-memo-table.c index a078fd140f..9888ec80d4 100644 --- a/calendar/gui/e-memo-table.c +++ b/calendar/gui/e-memo-table.c @@ -168,9 +168,10 @@ memo_table_model_cal_view_progress_cb (EMemoTable *memo_table, } static void -memo_table_model_cal_view_done_cb (EMemoTable *memo_table, - ECalendarStatus status, - ECalSourceType type) +memo_table_model_cal_view_complete_cb ( EMemoTable *memo_table, + ECalendarStatus status, + const gchar *error_msg, + ECalSourceType type) { memo_table_emit_status_message (memo_table, NULL, -1.0); } @@ -216,8 +217,8 @@ memo_table_set_model (EMemoTable *memo_table, memo_table); g_signal_connect_swapped ( - model, "cal-view-done", - G_CALLBACK (memo_table_model_cal_view_done_cb), + model, "cal-view-complete", + G_CALLBACK (memo_table_model_cal_view_complete_cb), memo_table); } diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c index 98d422aa16..f792ad3c66 100644 --- a/calendar/gui/e-task-table.c +++ b/calendar/gui/e-task-table.c @@ -246,9 +246,10 @@ task_table_model_cal_view_progress_cb (ETaskTable *task_table, } static void -task_table_model_cal_view_done_cb (ETaskTable *task_table, - ECalendarStatus status, - ECalSourceType type) +task_table_model_cal_view_complete_cb ( ETaskTable *task_table, + ECalendarStatus status, + const gchar *error_msg, + ECalSourceType type) { task_table_emit_status_message (task_table, NULL, -1.0); } @@ -294,8 +295,8 @@ task_table_set_model (ETaskTable *task_table, task_table); g_signal_connect_swapped ( - model, "cal-view-done", - G_CALLBACK (task_table_model_cal_view_done_cb), + model, "cal-view-complete", + G_CALLBACK (task_table_model_cal_view_complete_cb), task_table); } diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 38121c095c..5ecbf0a157 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -305,10 +305,11 @@ view_progress_cb (ECalModel *model, } static void -view_done_cb (ECalModel *model, - ECalendarStatus status, - ECalSourceType type, - GnomeCalendar *gcal) +view_complete_cb (ECalModel *model, + ECalendarStatus status, + const gchar *error_msg, + ECalSourceType type, + GnomeCalendar *gcal) { gcal_update_status_message (gcal, NULL, -1); } @@ -419,8 +420,8 @@ gnome_calendar_constructed (GObject *object) G_CALLBACK (view_progress_cb), gcal); g_signal_connect ( - model, "cal-view-done", - G_CALLBACK (view_done_cb), gcal); + model, "cal-view-complete", + G_CALLBACK (view_complete_cb), gcal); /* Day View */ calendar_view = e_day_view_new (model); @@ -807,11 +808,11 @@ dn_e_cal_view_objects_removed_cb (ECalView *query, GList *ids, gpointer data) /* Callback used when the calendar query is done */ static void -dn_e_cal_view_done_cb (ECalView *query, ECalendarStatus status, gpointer data) +dn_e_cal_view_complete_cb (ECalView *query, ECalendarStatus status, const gchar *error_msg, gpointer data) { /* FIXME Better error reporting */ if (status != E_CALENDAR_STATUS_OK) - g_warning (G_STRLOC ": Query did not successfully complete"); + g_warning (G_STRLOC ": Query did not successfully complete, code:%d (%s)", status, error_msg ? error_msg : "Unknown error"); } ECalendarView * @@ -1103,8 +1104,8 @@ try_again: G_CALLBACK (dn_e_cal_view_objects_modified_cb), gcal); g_signal_connect (new_query, "objects_removed", G_CALLBACK (dn_e_cal_view_objects_removed_cb), gcal); - g_signal_connect (new_query, "view_done", - G_CALLBACK (dn_e_cal_view_done_cb), gcal); + g_signal_connect (new_query, "view_complete", + G_CALLBACK (dn_e_cal_view_complete_cb), gcal); g_mutex_lock (priv->dn_query_lock); priv->dn_queries = g_list_append (priv->dn_queries, new_query); @@ -1487,7 +1488,7 @@ gnome_calendar_do_dispose (GObject *object) g_signal_handlers_disconnect_by_func ( priv->model, view_progress_cb, gcal); g_signal_handlers_disconnect_by_func ( - priv->model, view_done_cb, gcal); + priv->model, view_complete_cb, gcal); g_object_unref (priv->model); priv->model = NULL; } diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c index 77884da945..38db4cad92 100644 --- a/calendar/importers/icalendar-importer.c +++ b/calendar/importers/icalendar-importer.c @@ -319,9 +319,9 @@ ivcal_import_items(gpointer d) } static void -ivcal_opened(ECal *ecal, ECalendarStatus status, ICalImporter *ici) +ivcal_opened(ECal *ecal, const GError *error, ICalImporter *ici) { - if (!ici->cancelled && status == E_CALENDAR_STATUS_OK) { + if (!ici->cancelled && !error) { e_import_status(ici->import, ici->target, _("Importing..."), 0); ici->idle_id = g_idle_add(ivcal_import_items, ici); } else @@ -348,7 +348,7 @@ ivcal_import(EImport *ei, EImportTarget *target, icalcomponent *icalcomp) ici->client = client; ici->source_type = type; e_import_status(ei, target, _("Opening calendar"), 0); - g_signal_connect(client, "cal-opened", G_CALLBACK(ivcal_opened), ici); + g_signal_connect(client, "cal-opened-ex", G_CALLBACK(ivcal_opened), ici); e_cal_open_async(client, TRUE); return; } else { |