aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets/eab-gui-util.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-07-09 20:29:51 +0800
committerMilan Crha <mcrha@redhat.com>2010-07-09 20:29:51 +0800
commit03d626856b294bc98919ac244e04e9b8821a681d (patch)
tree62433e158f1791aa6b9222ecbe05d164c4703f6c /addressbook/gui/widgets/eab-gui-util.c
parent6d4ce8571ff62a3e489999d2feeac1691e06c59a (diff)
downloadgsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar
gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.gz
gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.bz2
gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.lz
gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.xz
gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.tar.zst
gsoc2013-evolution-03d626856b294bc98919ac244e04e9b8821a681d.zip
Bug #623204 - Be able to report detailed errors from backends
Diffstat (limited to 'addressbook/gui/widgets/eab-gui-util.c')
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c80
1 files changed, 28 insertions, 52 deletions
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index d127d50786..a7642625e3 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -47,52 +47,17 @@
#include "addressbook/util/addressbook.h"
-/* the NULL's in this table correspond to the status codes
- that should *never* be generated by a backend */
-static const gchar *status_to_string[] = {
- /* E_BOOK_ERROR_OK */ N_("Success"),
- /* E_BOOK_ERROR_INVALID_ARG */ NULL,
- /* E_BOOK_ERROR_BUSY */ N_("Backend busy"),
- /* E_BOOK_ERROR_REPOSITORY_OFFLINE */ N_("Repository offline"),
- /* E_BOOK_ERROR_NO_SUCH_BOOK */ N_("Address Book does not exist"),
- /* E_BOOK_ERROR_NO_SELF_CONTACT */ N_("No Self Contact defined"),
- /* E_BOOK_ERROR_URI_NOT_LOADED */ NULL,
- /* E_BOOK_ERROR_URI_ALREADY_LOADED */ NULL,
- /* E_BOOK_ERROR_PERMISSION_DENIED */ N_("Permission denied"),
- /* E_BOOK_ERROR_CONTACT_NOT_FOUND */ N_("Contact not found"),
- /* E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS */ N_("Contact ID already exists"),
- /* E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED */ N_("Protocol not supported"),
- /* E_BOOK_ERROR_CANCELLED */ N_("Canceled"),
- /* E_BOOK_ERROR_COULD_NOT_CANCEL */ N_("Could not cancel"),
- /* E_BOOK_ERROR_AUTHENTICATION_FAILED */ N_("Authentication Failed"),
- /* E_BOOK_ERROR_AUTHENTICATION_REQUIRED */ N_("Authentication Required"),
- /* E_BOOK_ERROR_TLS_NOT_AVAILABLE */ N_("TLS not Available"),
- /* E_BOOK_ERROR_CORBA_EXCEPTION */ NULL,
- /* E_BOOK_ERROR_NO_SUCH_SOURCE */ N_("No such source"),
- /* E_BOOK_ERROR_OFFLINE_UNAVAILABLE */ N_("Not available in offline mode"),
- /* E_BOOK_ERROR_OTHER_ERROR */ N_("Other error"),
- /* E_BOOK_ERROR_INVALID_SERVER_VERSION */ N_("Invalid server version"),
- /* E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD */ N_("Unsupported authentication method")
-};
-
void
-eab_error_dialog (const gchar *msg, EBookStatus status)
+eab_error_dialog (const gchar *msg, const GError *error)
{
- const gchar *status_str;
-
- if (status >= G_N_ELEMENTS (status_to_string))
- status_str = "Other error";
- else
- status_str = status_to_string [status];
-
- if (status_str)
+ if (error && error->message)
e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
"addressbook:generic-error",
- msg, _(status_str), NULL);
+ msg, error->message, NULL);
}
void
-eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status)
+eab_load_error_dialog (GtkWidget *parent, ESource *source, const GError *error)
{
gchar *label_string, *label = NULL, *uri;
GtkWidget *dialog;
@@ -102,7 +67,7 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status)
uri = e_source_get_uri (source);
- if (status == E_BOOK_ERROR_OFFLINE_UNAVAILABLE) {
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_OFFLINE_UNAVAILABLE)) {
can_detail_error = FALSE;
label_string = _("This address book cannot be opened. This either means this "
"book is not marked for offline usage or not yet downloaded "
@@ -141,8 +106,8 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status)
if (can_detail_error) {
/* do not show repository offline message, it's kind of generic error */
- if (status != E_BOOK_ERROR_REPOSITORY_OFFLINE && status > 0 && status < G_N_ELEMENTS (status_to_string) && status_to_string [status]) {
- label = g_strconcat (label_string, "\n\n", _("Detailed error message:"), " ", _(status_to_string [status]), NULL);
+ if (error && !g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_REPOSITORY_OFFLINE)) {
+ label = g_strconcat (label_string, "\n\n", _("Detailed error message:"), " ", error->message, NULL);
label_string = label;
}
}
@@ -157,7 +122,8 @@ eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status)
void
eab_search_result_dialog (GtkWidget *parent,
- EBookViewStatus status)
+ EBookViewStatus status,
+ const gchar *error_msg)
{
gchar *str = NULL;
@@ -169,27 +135,37 @@ eab_search_result_dialog (GtkWidget *parent,
"configured to return or Evolution is configured to display.\n"
"Please make your search more specific or raise the result limit in\n"
"the directory server preferences for this address book.");
+ str = g_strdup (str);
break;
case E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED:
str = _("The time to execute this query exceeded the server limit or the limit\n"
"configured for this address book. Please make your search\n"
"more specific or raise the time limit in the directory server\n"
"preferences for this address book.");
+ str = g_strdup (str);
break;
case E_BOOK_VIEW_ERROR_INVALID_QUERY:
- str = _("The backend for this address book was unable to parse this query.");
+ /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
+ str = _("The backend for this address book was unable to parse this query. %s");
+ str = g_strdup_printf (str, error_msg ? error_msg : "");
break;
case E_BOOK_VIEW_ERROR_QUERY_REFUSED:
- str = _("The backend for this address book refused to perform this query.");
+ /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
+ str = _("The backend for this address book refused to perform this query. %s");
+ str = g_strdup_printf (str, error_msg ? error_msg : "");
break;
case E_BOOK_VIEW_ERROR_OTHER_ERROR:
- str = _("This query did not complete successfully.");
+ /* Translators: %s is replaced with a detailed error message, or an empty string, if not provided */
+ str = _("This query did not complete successfully. %s");
+ str = g_strdup_printf (str, error_msg ? error_msg : "");
break;
default:
g_return_if_reached ();
}
e_alert_run_dialog_for_args ((GtkWindow *) parent, "addressbook:search-error", str, NULL);
+
+ g_free (str);
}
gint
@@ -368,15 +344,15 @@ process_unref (ContactCopyProcess *process)
}
static void
-contact_added_cb (EBook* book, EBookStatus status, const gchar *id, gpointer user_data)
+contact_added_cb (EBook* book, const GError *error, const gchar *id, gpointer user_data)
{
ContactCopyProcess *process = user_data;
- if (status != E_BOOK_ERROR_OK && status != E_BOOK_ERROR_CANCELLED) {
+ if (error && !g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
process->book_status = FALSE;
- eab_error_dialog (_("Error adding contact"), status);
+ eab_error_dialog (_("Error adding contact"), error);
}
- else if (status == E_BOOK_ERROR_CANCELLED) {
+ else if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
process->book_status = FALSE;
}
else {
@@ -403,11 +379,11 @@ do_copy (gpointer data, gpointer user_data)
}
static void
-got_book_cb (EBook *book, EBookStatus status, gpointer closure)
+got_book_cb (EBook *book, const GError *error, gpointer closure)
{
ContactCopyProcess *process;
process = closure;
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
process->destination = book;
process->book_status = TRUE;
g_object_ref (book);