aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook/gui/widgets')
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c34
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h3
-rw-r--r--addressbook/gui/widgets/e-addressbook-reflow-adapter.c1
-rw-r--r--addressbook/gui/widgets/e-addressbook-selector.c14
-rw-r--r--addressbook/gui/widgets/e-addressbook-table-adapter.c6
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c29
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c8
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h2
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c80
-rw-r--r--addressbook/gui/widgets/eab-gui-util.h7
10 files changed, 83 insertions, 101 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index e323d3d8a5..b469e8200d 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include "e-addressbook-model.h"
+#include <e-util/e-marshal.h>
#include <e-util/e-util.h>
#include "eab-gui-util.h"
@@ -46,7 +47,7 @@ struct _EAddressbookModelPrivate {
gulong modify_contact_id;
gulong status_message_id;
gulong writable_status_id;
- gulong sequence_complete_id;
+ gulong view_complete_id;
gulong backend_died_id;
guint search_in_progress : 1;
@@ -109,16 +110,16 @@ remove_book_view(EAddressbookModel *model)
g_signal_handler_disconnect (
model->priv->book_view,
model->priv->status_message_id);
- if (model->priv->book_view && model->priv->sequence_complete_id)
+ if (model->priv->book_view && model->priv->view_complete_id)
g_signal_handler_disconnect (
model->priv->book_view,
- model->priv->sequence_complete_id);
+ model->priv->view_complete_id);
model->priv->create_contact_id = 0;
model->priv->remove_contact_id = 0;
model->priv->modify_contact_id = 0;
model->priv->status_message_id = 0;
- model->priv->sequence_complete_id = 0;
+ model->priv->view_complete_id = 0;
model->priv->search_in_progress = FALSE;
@@ -266,13 +267,14 @@ status_message (EBookView *book_view,
}
static void
-sequence_complete (EBookView *book_view,
+view_complete (EBookView *book_view,
EBookViewStatus status,
+ const gchar *error_msg,
EAddressbookModel *model)
{
model->priv->search_in_progress = FALSE;
status_message (book_view, NULL, model);
- g_signal_emit (model, signals[SEARCH_RESULT], 0, status);
+ g_signal_emit (model, signals[SEARCH_RESULT], 0, status, error_msg);
g_signal_emit (model, signals[STOP_STATE_CHANGED], 0);
}
@@ -297,14 +299,14 @@ backend_died (EBook *book,
static void
book_view_loaded (EBook *book,
- EBookStatus status,
+ const GError *error,
EBookView *book_view,
gpointer closure)
{
EAddressbookModel *model = closure;
- if (status != E_BOOK_ERROR_OK) {
- eab_error_dialog (_("Error getting book view"), status);
+ if (error) {
+ eab_error_dialog (_("Error getting book view"), error);
return;
}
@@ -327,9 +329,9 @@ book_view_loaded (EBook *book,
model->priv->status_message_id = g_signal_connect (
model->priv->book_view, "status-message",
G_CALLBACK (status_message), model);
- model->priv->sequence_complete_id = g_signal_connect (
- model->priv->book_view, "sequence-complete",
- G_CALLBACK (sequence_complete), model);
+ model->priv->view_complete_id = g_signal_connect (
+ model->priv->book_view, "view-complete",
+ G_CALLBACK (view_complete), model);
model->priv->search_in_progress = TRUE;
g_signal_emit (model, signals[MODEL_CHANGED], 0);
@@ -361,7 +363,7 @@ addressbook_model_idle_cb (EAddressbookModel *model)
model->priv->first_get_view = FALSE;
if (e_book_check_static_capability (model->priv->book, "do-initial-query")) {
- e_book_async_get_book_view (
+ e_book_async_get_book_view_ex (
model->priv->book, model->priv->query,
NULL, limit, book_view_loaded, model);
} else {
@@ -373,7 +375,7 @@ addressbook_model_idle_cb (EAddressbookModel *model)
signals[STOP_STATE_CHANGED], 0);
}
} else
- e_book_async_get_book_view (
+ e_book_async_get_book_view_ex (
model->priv->book, model->priv->query,
NULL, limit, book_view_loaded, model);
@@ -570,8 +572,8 @@ addressbook_model_class_init (EAddressbookModelClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EAddressbookModelClass, search_result),
NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
+ e_marshal_VOID__UINT_STRING,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
signals[FOLDER_BAR_MESSAGE] =
g_signal_new ("folder_bar_message",
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index b42de48dbc..8dcc4060e0 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -63,7 +63,8 @@ struct _EAddressbookModelClass {
gboolean writable);
void (*search_started) (EAddressbookModel *model);
void (*search_result) (EAddressbookModel *model,
- EBookViewStatus status);
+ EBookViewStatus status,
+ const gchar *error_msg);
void (*status_message) (EAddressbookModel *model,
const gchar *message);
void (*folder_bar_message) (EAddressbookModel *model,
diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
index 8953e3705e..f167075886 100644
--- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c
@@ -337,6 +337,7 @@ search_started (EAddressbookModel *model,
static void
search_result (EAddressbookModel *model,
EBookViewStatus status,
+ const gchar *error_msg,
EAddressbookReflowAdapter *adapter)
{
EAddressbookReflowAdapterPrivate *priv = adapter->priv;
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index 690ad007ba..8ae7bc6bbb 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -102,7 +102,7 @@ merge_context_free (MergeContext *merge_context)
static void
addressbook_selector_removed_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
MergeContext *merge_context)
{
merge_context->pending_removals--;
@@ -118,16 +118,16 @@ addressbook_selector_removed_cb (EBook *book,
static void
addressbook_selector_merge_next_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
const gchar *id,
MergeContext *merge_context)
{
- if (merge_context->remove_from_source && status == E_BOOK_ERROR_OK) {
+ if (merge_context->remove_from_source && !error) {
/* Remove previous contact from source. */
- e_book_async_remove_contact (
+ e_book_async_remove_contact_ex (
merge_context->source_book,
merge_context->current_contact,
- (EBookCallback) addressbook_selector_removed_cb,
+ (EBookExCallback) addressbook_selector_removed_cb,
merge_context);
merge_context->pending_removals++;
}
@@ -139,7 +139,7 @@ addressbook_selector_merge_next_cb (EBook *book,
eab_merging_book_add_contact (
merge_context->target_book,
merge_context->current_contact,
- (EBookIdCallback) addressbook_selector_merge_next_cb,
+ (EBookIdExCallback) addressbook_selector_merge_next_cb,
merge_context);
} else if (merge_context->pending_removals == 0)
@@ -319,7 +319,7 @@ addressbook_selector_data_dropped (ESourceSelector *selector,
eab_merging_book_add_contact (
target_book, merge_context->current_contact,
- (EBookIdCallback) addressbook_selector_merge_next_cb,
+ (EBookIdExCallback) addressbook_selector_merge_next_cb,
merge_context);
return TRUE;
diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c
index d3c122ef19..88e6554299 100644
--- a/addressbook/gui/widgets/e-addressbook-table-adapter.c
+++ b/addressbook/gui/widgets/e-addressbook-table-adapter.c
@@ -143,11 +143,11 @@ addressbook_value_at (ETableModel *etc, gint col, gint row)
/* This function sets the value at a particular point in our ETableModel. */
static void
-contact_modified_cb (EBook* book, EBookStatus status,
+contact_modified_cb (EBook* book, const GError *error,
gpointer user_data)
{
- if (status != E_BOOK_ERROR_OK)
- eab_error_dialog (_("Error modifying card"), status);
+ if (error)
+ eab_error_dialog (_("Error modifying card"), error);
}
static void
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 70c3c2334e..187b08b290 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -67,7 +67,7 @@
#define d(x)
static void status_message (EAddressbookView *view, const gchar *status);
-static void search_result (EAddressbookView *view, EBookViewStatus status);
+static void search_result (EAddressbookView *view, EBookViewStatus status, const gchar *error_msg);
static void folder_bar_message (EAddressbookView *view, const gchar *status);
static void stop_state_changed (GtkObject *object, EAddressbookView *view);
static void backend_died (EAddressbookView *view);
@@ -1084,14 +1084,15 @@ status_message (EAddressbookView *view,
static void
search_result (EAddressbookView *view,
- EBookViewStatus status)
+ EBookViewStatus status,
+ const gchar *error_msg)
{
EShellView *shell_view;
EShellWindow *shell_window;
shell_view = e_addressbook_view_get_shell_view (view);
shell_window = e_shell_view_get_shell_window (shell_view);
- eab_search_result_dialog (GTK_WIDGET (shell_window), status);
+ eab_search_result_dialog (GTK_WIDGET (shell_window), status, error_msg);
}
static void
@@ -1252,9 +1253,9 @@ e_addressbook_view_print (EAddressbookView *view,
* which a user doesnt have write permission
*/
static void
-delete_contacts_cb (EBook *book, EBookStatus status, gpointer closure)
+delete_contacts_cb (EBook *book, const GError *error, gpointer closure)
{
- switch (status) {
+ switch (error ? error->code : E_BOOK_ERROR_OK) {
case E_BOOK_ERROR_OK :
case E_BOOK_ERROR_CANCELLED :
break;
@@ -1265,7 +1266,7 @@ delete_contacts_cb (EBook *book, EBookStatus status, gpointer closure)
break;
default :
/* Unknown error */
- eab_error_dialog (_("Failed to delete contact"), status);
+ eab_error_dialog (_("Failed to delete contact"), error);
break;
}
}
@@ -1391,10 +1392,10 @@ e_addressbook_view_delete_selection(EAddressbookView *view, gboolean is_delete)
}
/* Remove the cards all at once. */
- e_book_async_remove_contacts (book,
- ids,
- delete_contacts_cb,
- NULL);
+ e_book_async_remove_contacts_ex (book,
+ ids,
+ delete_contacts_cb,
+ NULL);
g_list_free (ids);
}
@@ -1402,10 +1403,10 @@ e_addressbook_view_delete_selection(EAddressbookView *view, gboolean is_delete)
for (l=list;l;l=g_list_next(l)) {
contact = l->data;
/* Remove the card. */
- e_book_async_remove_contact (book,
- contact,
- delete_contacts_cb,
- NULL);
+ e_book_async_remove_contact_ex (book,
+ contact,
+ delete_contacts_cb,
+ NULL);
}
}
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index b69f842d63..ba9c1b5b26 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -456,7 +456,7 @@ e_minicard_view_selection_event (EReflow *reflow,
typedef struct {
EMinicardView *view;
- EBookCallback cb;
+ EBookExCallback cb;
gpointer closure;
} ViewCbClosure;
@@ -467,7 +467,7 @@ do_remove (gint i, gpointer user_data)
EContact *contact;
ViewCbClosure *viewcbclosure = user_data;
EMinicardView *view = viewcbclosure->view;
- EBookCallback cb = viewcbclosure->cb;
+ EBookExCallback cb = viewcbclosure->cb;
gpointer closure = viewcbclosure->closure;
g_object_get (view->adapter,
@@ -476,7 +476,7 @@ do_remove (gint i, gpointer user_data)
contact = e_addressbook_reflow_adapter_get_contact (view->adapter, i);
- e_book_async_remove_contact(book, contact, cb, closure);
+ e_book_async_remove_contact_ex (book, contact, cb, closure);
g_object_unref (contact);
}
@@ -624,7 +624,7 @@ e_minicard_view_get_type (void)
void
e_minicard_view_remove_selection(EMinicardView *view,
- EBookCallback cb,
+ EBookExCallback cb,
gpointer closure)
{
ViewCbClosure viewcbclosure;
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index babfddd0c3..e8fc9fc21f 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -85,7 +85,7 @@ struct _EMinicardViewClass
GType e_minicard_view_get_type (void);
void e_minicard_view_remove_selection (EMinicardView *view,
- EBookCallback cb,
+ EBookExCallback cb,
gpointer closure);
void e_minicard_view_jump_to_letter (EMinicardView *view,
gunichar letter);
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);
diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h
index ffa43ef94f..5f8890feb2 100644
--- a/addressbook/gui/widgets/eab-gui-util.h
+++ b/addressbook/gui/widgets/eab-gui-util.h
@@ -30,12 +30,13 @@
G_BEGIN_DECLS
void eab_error_dialog (const gchar *msg,
- EBookStatus status);
+ const GError *error);
void eab_load_error_dialog (GtkWidget *parent,
ESource *source,
- EBookStatus status);
+ const GError *error);
void eab_search_result_dialog (GtkWidget *parent,
- EBookViewStatus status);
+ EBookViewStatus status,
+ const gchar *error_msg);
gint eab_prompt_save_dialog (GtkWindow *parent);
void eab_transfer_contacts (EBook *source,