aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
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
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')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c84
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c16
-rw-r--r--addressbook/gui/contact-editor/eab-editor.c18
-rw-r--r--addressbook/gui/contact-editor/eab-editor.h12
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c48
-rw-r--r--addressbook/gui/merging/eab-contact-compare.c16
-rw-r--r--addressbook/gui/merging/eab-contact-merging.c44
-rw-r--r--addressbook/gui/merging/eab-contact-merging.h6
-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
-rw-r--r--addressbook/printing/e-contact-print.c9
-rw-r--r--addressbook/util/addressbook.c68
-rw-r--r--addressbook/util/addressbook.h4
-rw-r--r--addressbook/util/eab-book-util.c8
-rw-r--r--addressbook/util/eab-book-util.h4
23 files changed, 255 insertions, 266 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 2cb975725f..6ce890c999 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -197,44 +197,44 @@ static const gint email_default [] = { 0, 1, 2, 2 };
static void
e_contact_editor_contact_added (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
return;
- if (status == E_BOOK_ERROR_CANCELLED)
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
return;
- eab_error_dialog (_("Error adding contact"), status);
+ eab_error_dialog (_("Error adding contact"), error);
}
static void
e_contact_editor_contact_modified (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
return;
- if (status == E_BOOK_ERROR_CANCELLED)
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
return;
- eab_error_dialog (_("Error modifying contact"), status);
+ eab_error_dialog (_("Error modifying contact"), error);
}
static void
e_contact_editor_contact_deleted (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
return;
- if (status == E_BOOK_ERROR_CANCELLED)
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
return;
- eab_error_dialog (_("Error removing contact"), status);
+ eab_error_dialog (_("Error removing contact"), error);
}
static void
@@ -2691,15 +2691,15 @@ init_all (EContactEditor *editor)
}
static void
-new_target_cb (EBook *new_book, EBookStatus status, EContactEditor *editor)
+new_target_cb (EBook *new_book, const GError *error, EContactEditor *editor)
{
editor->load_source_id = 0;
editor->load_book = NULL;
- if (status != E_BOOK_ERROR_OK || new_book == NULL) {
+ if (error || new_book == NULL) {
GtkWidget *source_combo_box;
- eab_load_error_dialog (NULL, e_book_get_source (new_book), status);
+ eab_load_error_dialog (NULL, e_book_get_source (new_book), error);
source_combo_box = e_builder_get_widget (
editor->builder, "source-combo-box-source");
@@ -2747,7 +2747,7 @@ source_changed (ESourceComboBox *source_combo_box, EContactEditor *editor)
editor->load_book = e_book_new (source, NULL);
editor->load_source_id = addressbook_load (editor->load_book,
- (EBookCallback) new_target_cb, editor);
+ (EBookExCallback) new_target_cb, editor);
}
static void
@@ -3025,7 +3025,7 @@ typedef struct {
} EditorCloseStruct;
static void
-contact_moved_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
+contact_moved_cb (EBook *book, const GError *error, EditorCloseStruct *ecs)
{
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
@@ -3035,7 +3035,7 @@ contact_moved_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
e_contact_set (ce->contact, E_CONTACT_UID, ecs->new_id);
- eab_editor_contact_deleted (EAB_EDITOR (ce), status, ce->contact);
+ eab_editor_contact_deleted (EAB_EDITOR (ce), error, ce->contact);
ce->is_new_contact = FALSE;
@@ -3058,16 +3058,16 @@ contact_moved_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
}
static void
-contact_added_cb (EBook *book, EBookStatus status, const gchar *id, EditorCloseStruct *ecs)
+contact_added_cb (EBook *book, const GError *error, const gchar *id, EditorCloseStruct *ecs)
{
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
if (ce->source_book != ce->target_book && e_book_is_writable (ce->source_book) &&
- status == E_BOOK_ERROR_OK && ce->is_new_contact == FALSE) {
+ !error && ce->is_new_contact == FALSE) {
ecs->new_id = g_strdup (id);
- e_book_async_remove_contact (ce->source_book, ce->contact,
- (EBookCallback) contact_moved_cb, ecs);
+ e_book_async_remove_contact_ex (ce->source_book, ce->contact,
+ (EBookExCallback) contact_moved_cb, ecs);
return;
}
@@ -3076,9 +3076,9 @@ contact_added_cb (EBook *book, EBookStatus status, const gchar *id, EditorCloseS
e_contact_set (ce->contact, E_CONTACT_UID, (gchar *) id);
- eab_editor_contact_added (EAB_EDITOR (ce), status, ce->contact);
+ eab_editor_contact_added (EAB_EDITOR (ce), error, ce->contact);
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
ce->is_new_contact = FALSE;
if (should_close) {
@@ -3095,7 +3095,7 @@ contact_added_cb (EBook *book, EBookStatus status, const gchar *id, EditorCloseS
}
static void
-contact_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
+contact_modified_cb (EBook *book, const GError *error, EditorCloseStruct *ecs)
{
EContactEditor *ce = ecs->ce;
gboolean should_close = ecs->should_close;
@@ -3103,9 +3103,9 @@ contact_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs)
gtk_widget_set_sensitive (ce->app, TRUE);
ce->in_async_call = FALSE;
- eab_editor_contact_modified (EAB_EDITOR (ce), status, ce->contact);
+ eab_editor_contact_modified (EAB_EDITOR (ce), error, ce->contact);
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
if (should_close) {
eab_editor_close (EAB_EDITOR (ce));
}
@@ -3137,14 +3137,14 @@ real_save_contact (EContactEditor *ce, gboolean should_close)
if (ce->source_book != ce->target_book) {
/* Two-step move; add to target, then remove from source */
eab_merging_book_add_contact (ce->target_book, ce->contact,
- (EBookIdCallback) contact_added_cb, ecs);
+ (EBookIdExCallback) contact_added_cb, ecs);
} else {
if (ce->is_new_contact)
eab_merging_book_add_contact (ce->target_book, ce->contact,
- (EBookIdCallback) contact_added_cb, ecs);
+ (EBookIdExCallback) contact_added_cb, ecs);
else
eab_merging_book_commit_contact (ce->target_book, ce->contact,
- (EBookCallback) contact_modified_cb, ecs);
+ (EBookExCallback) contact_modified_cb, ecs);
}
}
@@ -3641,7 +3641,7 @@ e_contact_editor_dispose (GObject *object)
}
static void
-supported_fields_cb (EBook *book, EBookStatus status,
+supported_fields_cb (EBook *book, const GError *error,
EList *fields, EContactEditor *ce)
{
if (!g_slist_find (eab_editor_get_all_editors (), ce)) {
@@ -3659,7 +3659,7 @@ supported_fields_cb (EBook *book, EBookStatus status,
}
static void
-required_fields_cb (EBook *book, EBookStatus status,
+required_fields_cb (EBook *book, const GError *error,
EList *fields, EContactEditor *ce)
{
@@ -3697,8 +3697,8 @@ e_contact_editor_new (EShell *shell,
NULL);
if (book)
- e_book_async_get_supported_fields (
- book, (EBookEListCallback)supported_fields_cb, editor);
+ e_book_async_get_supported_fields_ex (
+ book, (EBookEListExCallback)supported_fields_cb, editor);
return editor;
}
@@ -3751,10 +3751,10 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
editor->target_editable_id = g_signal_connect (editor->target_book, "writable_status",
G_CALLBACK (writable_changed), editor);
- e_book_async_get_supported_fields (editor->target_book,
- (EBookEListCallback) supported_fields_cb, editor);
- e_book_async_get_required_fields (editor->target_book,
- (EBookEListCallback) required_fields_cb, editor);
+ e_book_async_get_supported_fields_ex (editor->target_book,
+ (EBookEListExCallback) supported_fields_cb, editor);
+ e_book_async_get_required_fields_ex (editor->target_book,
+ (EBookEListExCallback) required_fields_cb, editor);
}
writable = e_book_is_writable (editor->target_book);
@@ -3790,11 +3790,11 @@ e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *val
editor->target_editable_id = g_signal_connect (editor->target_book, "writable_status",
G_CALLBACK (writable_changed), editor);
- e_book_async_get_supported_fields (editor->target_book,
- (EBookEListCallback) supported_fields_cb, editor);
+ e_book_async_get_supported_fields_ex (editor->target_book,
+ (EBookEListExCallback) supported_fields_cb, editor);
- e_book_async_get_required_fields (editor->target_book,
- (EBookEListCallback) required_fields_cb, editor);
+ e_book_async_get_required_fields_ex (editor->target_book,
+ (EBookEListExCallback) required_fields_cb, editor);
if (!editor->is_new_contact)
editor->changed = TRUE;
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index 0feced4ca0..032f4ac475 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -121,11 +121,11 @@ quick_add_set_vcard (QuickAdd *qa, const gchar *vcard)
}
static void
-merge_cb (EBook *book, EBookStatus status, gpointer closure)
+merge_cb (EBook *book, const GError *error, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
if (e_book_is_writable (book))
eab_merging_book_add_contact (book, qa->contact, NULL, NULL);
else
@@ -186,14 +186,14 @@ editor_closed_cb (GtkWidget *w, gpointer closure)
}
static void
-ce_have_contact (EBook *book, EBookStatus status, EContact *contact, gpointer closure)
+ce_have_contact (EBook *book, const GError *error, EContact *contact, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
if (book)
g_object_unref (book);
- g_warning ("Failed to find contact, status %d.", status);
+ g_warning ("Failed to find contact, status %d (%s).", error->code, error->message);
quick_add_unref (qa);
} else {
EShell *shell;
@@ -235,14 +235,14 @@ ce_have_contact (EBook *book, EBookStatus status, EContact *contact, gpointer cl
}
static void
-ce_have_book (EBook *book, EBookStatus status, gpointer closure)
+ce_have_book (EBook *book, const GError *error, gpointer closure)
{
QuickAdd *qa = (QuickAdd *) closure;
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
if (book)
g_object_unref (book);
- g_warning ("Couldn't open local address book.");
+ g_warning ("Couldn't open local address book (%s).", error->message);
quick_add_unref (qa);
} else {
eab_merging_book_find_contact (book, qa->contact, ce_have_contact, qa);
diff --git a/addressbook/gui/contact-editor/eab-editor.c b/addressbook/gui/contact-editor/eab-editor.c
index f53ecc30cd..f2765f40a6 100644
--- a/addressbook/gui/contact-editor/eab-editor.c
+++ b/addressbook/gui/contact-editor/eab-editor.c
@@ -181,7 +181,7 @@ eab_editor_class_init (EABEditorClass *class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EABEditorClass, contact_added),
NULL, NULL,
- e_marshal_NONE__INT_OBJECT,
+ e_marshal_NONE__POINTER_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
@@ -191,7 +191,7 @@ eab_editor_class_init (EABEditorClass *class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EABEditorClass, contact_modified),
NULL, NULL,
- e_marshal_NONE__INT_OBJECT,
+ e_marshal_NONE__POINTER_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
@@ -201,7 +201,7 @@ eab_editor_class_init (EABEditorClass *class)
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (EABEditorClass, contact_deleted),
NULL, NULL,
- e_marshal_NONE__INT_OBJECT,
+ e_marshal_NONE__POINTER_OBJECT,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_OBJECT);
@@ -385,35 +385,35 @@ eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window)
void
eab_editor_contact_added (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
g_return_if_fail (E_IS_CONTACT (contact));
- g_signal_emit (editor, signals[CONTACT_ADDED], 0, status, contact);
+ g_signal_emit (editor, signals[CONTACT_ADDED], 0, error, contact);
}
void
eab_editor_contact_modified (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
g_return_if_fail (E_IS_CONTACT (contact));
- g_signal_emit (editor, signals[CONTACT_MODIFIED], 0, status, contact);
+ g_signal_emit (editor, signals[CONTACT_MODIFIED], 0, error, contact);
}
void
eab_editor_contact_deleted (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
g_return_if_fail (EAB_IS_EDITOR (editor));
g_return_if_fail (E_IS_CONTACT (contact));
- g_signal_emit (editor, signals[CONTACT_DELETED], 0, status, contact);
+ g_signal_emit (editor, signals[CONTACT_DELETED], 0, error, contact);
}
void
diff --git a/addressbook/gui/contact-editor/eab-editor.h b/addressbook/gui/contact-editor/eab-editor.h
index f3803e7341..5623aa5bd4 100644
--- a/addressbook/gui/contact-editor/eab-editor.h
+++ b/addressbook/gui/contact-editor/eab-editor.h
@@ -72,9 +72,9 @@ struct _EABEditorClass {
GtkWindow* (* get_window) (EABEditor *editor);
/* signals */
- void (* contact_added) (EABEditor *editor, EBookStatus status, EContact *contact);
- void (* contact_modified) (EABEditor *editor, EBookStatus status, EContact *contact);
- void (* contact_deleted) (EABEditor *editor, EBookStatus status, EContact *contact);
+ void (* contact_added) (EABEditor *editor, const GError *error, EContact *contact);
+ void (* contact_modified) (EABEditor *editor, const GError *error, EContact *contact);
+ void (* contact_deleted) (EABEditor *editor, const GError *error, EContact *contact);
void (* editor_closed) (EABEditor *editor);
};
@@ -98,13 +98,13 @@ gboolean eab_editor_prompt_to_save_changes
/* these four generate EABEditor signals */
void eab_editor_contact_added (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact);
void eab_editor_contact_modified (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact);
void eab_editor_contact_deleted (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact);
void eab_editor_closed (EABEditor *editor);
diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
index cc734d2035..dc31d3c1fe 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -208,7 +208,7 @@ contact_list_editor_add_email (EContactListEditor *editor)
static void
contact_list_editor_book_loaded (EBook *new_book,
- EBookStatus status,
+ const GError *error,
EContactListEditor *editor)
{
EContactListEditorPrivate *priv = editor->priv;
@@ -218,9 +218,9 @@ contact_list_editor_book_loaded (EBook *new_book,
priv->load_source_id = 0;
priv->load_book = NULL;
- if (status != E_BOOK_ERROR_OK || new_book == NULL) {
+ if (error || new_book == NULL) {
eab_load_error_dialog (
- NULL, e_book_get_source (new_book), status);
+ NULL, e_book_get_source (new_book), error);
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)),
e_book_get_source (priv->book));
@@ -266,7 +266,7 @@ contact_list_editor_contact_exists (EContactListModel *model,
static void
contact_list_editor_list_added_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
const gchar *id,
EditorCloseStruct *ecs)
{
@@ -280,9 +280,9 @@ contact_list_editor_list_added_cb (EBook *book,
e_contact_set (priv->contact, E_CONTACT_UID, (gchar *) id);
eab_editor_contact_added (
- EAB_EDITOR (editor), status, priv->contact);
+ EAB_EDITOR (editor), error, priv->contact);
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
priv->is_new_list = FALSE;
if (should_close)
@@ -297,7 +297,7 @@ contact_list_editor_list_added_cb (EBook *book,
static void
contact_list_editor_list_modified_cb (EBook *book,
- EBookStatus status,
+ const GError *error,
EditorCloseStruct *ecs)
{
EContactListEditor *editor = ecs->editor;
@@ -308,9 +308,9 @@ contact_list_editor_list_modified_cb (EBook *book,
priv->in_async_call = FALSE;
eab_editor_contact_modified (
- EAB_EDITOR (editor), status, priv->contact);
+ EAB_EDITOR (editor), error, priv->contact);
- if (status == E_BOOK_ERROR_OK) {
+ if (!error) {
if (should_close)
eab_editor_close (EAB_EDITOR (editor));
}
@@ -816,7 +816,7 @@ contact_list_editor_source_menu_changed_cb (GtkWidget *widget)
editor->priv->load_book = e_book_new (source, NULL);
editor->priv->load_source_id = addressbook_load (
- editor->priv->load_book, (EBookCallback)
+ editor->priv->load_book, (EBookExCallback)
contact_list_editor_book_loaded, editor);
}
@@ -1113,11 +1113,11 @@ contact_list_editor_save_contact (EABEditor *eab_editor,
if (priv->is_new_list)
eab_merging_book_add_contact (
- priv->book, contact, (EBookIdCallback)
+ priv->book, contact, (EBookIdExCallback)
contact_list_editor_list_added_cb, ecs);
else
eab_merging_book_commit_contact (
- priv->book, contact, (EBookCallback)
+ priv->book, contact, (EBookExCallback)
contact_list_editor_list_modified_cb, ecs);
priv->changed = FALSE;
@@ -1152,44 +1152,44 @@ contact_list_editor_get_window (EABEditor *editor)
static void
contact_list_editor_contact_added (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
return;
- if (status == E_BOOK_ERROR_CANCELLED)
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
return;
- eab_error_dialog (_("Error adding list"), status);
+ eab_error_dialog (_("Error adding list"), error);
}
static void
contact_list_editor_contact_modified (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
return;
- if (status == E_BOOK_ERROR_CANCELLED)
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
return;
- eab_error_dialog (_("Error modifying list"), status);
+ eab_error_dialog (_("Error modifying list"), error);
}
static void
contact_list_editor_contact_deleted (EABEditor *editor,
- EBookStatus status,
+ const GError *error,
EContact *contact)
{
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
return;
- if (status == E_BOOK_ERROR_CANCELLED)
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED))
return;
- eab_error_dialog (_("Error removing list"), status);
+ eab_error_dialog (_("Error removing list"), error);
}
static void
diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c
index b341d77fc9..aad7c52f89 100644
--- a/addressbook/gui/merging/eab-contact-compare.c
+++ b/addressbook/gui/merging/eab-contact-compare.c
@@ -565,7 +565,7 @@ match_search_info_free (MatchSearchInfo *info)
}
static void
-query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
+query_cb (EBook *book, const GError *error, GList *contacts, gpointer closure)
{
/* XXX we need to free contacts */
MatchSearchInfo *info = (MatchSearchInfo *) closure;
@@ -574,7 +574,7 @@ query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
GList *remaining_contacts = NULL;
const GList *i;
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure);
match_search_info_free (info);
return;
@@ -626,7 +626,7 @@ query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure)
#define MAX_QUERY_PARTS 10
static void
-use_common_book_cb (EBook *book, gpointer closure)
+use_common_book_cb (EBook *book, const GError *error, gpointer closure)
{
MatchSearchInfo *info = (MatchSearchInfo *) closure;
EContact *contact = info->contact;
@@ -707,9 +707,9 @@ use_common_book_cb (EBook *book, gpointer closure)
}
if (query)
- e_book_async_get_contacts (book, query, query_cb, info);
+ e_book_async_get_contacts_ex (book, query, query_cb, info);
else
- query_cb (book, E_BOOK_ERROR_OK, NULL, info);
+ query_cb (book, NULL, NULL, info);
g_free (qj);
if (query)
@@ -731,7 +731,7 @@ eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gp
info->closure = closure;
info->avoid = NULL;
- addressbook_load_default_book ((EBookCallback) use_common_book_cb, info);
+ addressbook_load_default_book ((EBookExCallback) use_common_book_cb, info);
}
/**
@@ -762,8 +762,8 @@ eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EAB
g_list_foreach (info->avoid, (GFunc) g_object_ref, NULL);
if (book)
- use_common_book_cb (book, info);
+ use_common_book_cb (book, NULL, info);
else
- addressbook_load_default_book ((EBookCallback) use_common_book_cb, info);
+ addressbook_load_default_book ((EBookExCallback) use_common_book_cb, info);
}
diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c
index ec37972b46..70a1aa462b 100644
--- a/addressbook/gui/merging/eab-contact-merging.c
+++ b/addressbook/gui/merging/eab-contact-merging.c
@@ -49,9 +49,9 @@ typedef struct {
/*match is the duplicate contact already existing in the addressbook*/
EContact *match;
GList *avoid;
- EBookIdCallback id_cb;
- EBookCallback cb;
- EBookContactCallback c_cb;
+ EBookIdExCallback id_cb;
+ EBookExCallback cb;
+ EBookContactExCallback c_cb;
gpointer closure;
} EContactMergingLookup;
@@ -110,12 +110,12 @@ free_lookup (EContactMergingLookup *lookup)
}
static void
-final_id_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
+final_id_cb (EBook *book, const GError *error, const gchar *id, gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->id_cb)
- lookup->id_cb (lookup->book, status, id, lookup->closure);
+ lookup->id_cb (lookup->book, error, id, lookup->closure);
free_lookup (lookup);
@@ -123,12 +123,12 @@ final_id_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure)
}
static void
-final_cb_as_id (EBook *book, EBookStatus status, gpointer closure)
+final_cb_as_id (EBook *book, const GError *error, gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->id_cb)
- lookup->id_cb (lookup->book, status, lookup->contact ? e_contact_get_const (lookup->contact, E_CONTACT_UID) : NULL, lookup->closure);
+ lookup->id_cb (lookup->book, error, lookup->contact ? e_contact_get_const (lookup->contact, E_CONTACT_UID) : NULL, lookup->closure);
free_lookup (lookup);
@@ -136,12 +136,12 @@ final_cb_as_id (EBook *book, EBookStatus status, gpointer closure)
}
static void
-final_cb (EBook *book, EBookStatus status, gpointer closure)
+final_cb (EBook *book, const GError *error, gpointer closure)
{
EContactMergingLookup *lookup = closure;
if (lookup->cb)
- lookup->cb (lookup->book, status, lookup->closure);
+ lookup->cb (lookup->book, error, lookup->closure);
free_lookup (lookup);
@@ -153,21 +153,25 @@ doit (EContactMergingLookup *lookup, gboolean force_commit)
{
if (lookup->op == E_CONTACT_MERGING_ADD) {
if (force_commit)
- e_book_async_commit_contact (lookup->book, lookup->contact, final_cb_as_id, lookup);
+ e_book_async_commit_contact_ex (lookup->book, lookup->contact, final_cb_as_id, lookup);
else
- e_book_async_add_contact (lookup->book, lookup->contact, final_id_cb, lookup);
+ e_book_async_add_contact_ex (lookup->book, lookup->contact, final_id_cb, lookup);
} else if (lookup->op == E_CONTACT_MERGING_COMMIT)
- e_book_async_commit_contact (lookup->book, lookup->contact, final_cb, lookup);
+ e_book_async_commit_contact_ex (lookup->book, lookup->contact, final_cb, lookup);
}
static void
cancelit (EContactMergingLookup *lookup)
{
+ GError *error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED, _("Cancelled"));
+
if (lookup->op == E_CONTACT_MERGING_ADD) {
- final_id_cb (lookup->book, E_BOOK_ERROR_CANCELLED, NULL, lookup);
+ final_id_cb (lookup->book, error, NULL, lookup);
} else if (lookup->op == E_CONTACT_MERGING_COMMIT) {
- final_cb (lookup->book, E_BOOK_ERROR_CANCELLED, lookup);
+ final_cb (lookup->book, error, lookup);
}
+
+ g_error_free (error);
}
static void
@@ -371,8 +375,8 @@ mergeit (EContactMergingLookup *lookup)
{
case GTK_RESPONSE_OK:
lookup->contact = lookup->match;
- e_book_async_remove_contact (lookup->book, lookup->match, NULL, lookup);
- e_book_async_add_contact (lookup->book, lookup->contact, final_id_cb, lookup);
+ e_book_async_remove_contact_ex (lookup->book, lookup->match, NULL, lookup);
+ e_book_async_add_contact_ex (lookup->book, lookup->contact, final_id_cb, lookup);
value = 1;
break;
case GTK_RESPONSE_CANCEL:
@@ -466,7 +470,7 @@ match_query_callback (EContact *contact, EContact *match, EABContactMatchType ty
if (lookup->op == E_CONTACT_MERGING_FIND) {
if (lookup->c_cb)
- lookup->c_cb (lookup->book, E_BOOK_ERROR_OK, (gint) type <= (gint) EAB_CONTACT_MATCH_VAGUE ? NULL : match, lookup->closure);
+ lookup->c_cb (lookup->book, NULL, (gint) type <= (gint) EAB_CONTACT_MATCH_VAGUE ? NULL : match, lookup->closure);
free_lookup (lookup);
finished_lookup ();
@@ -543,7 +547,7 @@ match_query_callback (EContact *contact, EContact *match, EABContactMatchType ty
gboolean
eab_merging_book_add_contact (EBook *book,
EContact *contact,
- EBookIdCallback cb,
+ EBookIdExCallback cb,
gpointer closure)
{
EContactMergingLookup *lookup;
@@ -566,7 +570,7 @@ eab_merging_book_add_contact (EBook *book,
gboolean
eab_merging_book_commit_contact (EBook *book,
EContact *contact,
- EBookCallback cb,
+ EBookExCallback cb,
gpointer closure)
{
EContactMergingLookup *lookup;
@@ -589,7 +593,7 @@ eab_merging_book_commit_contact (EBook *book,
gboolean
eab_merging_book_find_contact (EBook *book,
EContact *contact,
- EBookContactCallback cb,
+ EBookContactExCallback cb,
gpointer closure)
{
EContactMergingLookup *lookup;
diff --git a/addressbook/gui/merging/eab-contact-merging.h b/addressbook/gui/merging/eab-contact-merging.h
index fe1457f4e7..eacfcf734a 100644
--- a/addressbook/gui/merging/eab-contact-merging.h
+++ b/addressbook/gui/merging/eab-contact-merging.h
@@ -32,15 +32,15 @@ G_BEGIN_DECLS
gboolean eab_merging_book_add_contact (EBook *book,
EContact *contact,
- EBookIdCallback cb,
+ EBookIdExCallback cb,
gpointer closure);
gboolean eab_merging_book_commit_contact (EBook *book,
EContact *contact,
- EBookCallback cb,
+ EBookExCallback cb,
gpointer closure);
gboolean eab_merging_book_find_contact (EBook *book,
EContact *contact,
- EBookContactCallback cb,
+ EBookContactExCallback cb,
gpointer closure);
G_END_DECLS
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,
diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c
index 7eb955bba7..37b2837b5c 100644
--- a/addressbook/printing/e-contact-print.c
+++ b/addressbook/printing/e-contact-print.c
@@ -397,8 +397,7 @@ contacts_added (EBookView *book_view, const GList *contact_list,
}
static void
-sequence_complete (EBookView *book_view, const GList *contact_list,
- EFlag *book_view_started)
+view_complete (EBookView *book_view, EBookViewStatus status, const gchar *error_msg, EFlag *book_view_started)
{
e_flag_set (book_view_started);
}
@@ -596,8 +595,8 @@ load_contacts (EContactPrintContext *ctxt)
book_view, "contacts_added",
G_CALLBACK (contacts_added), ctxt);
g_signal_connect (
- book_view, "sequence_complete",
- G_CALLBACK (sequence_complete), book_view_started);
+ book_view, "view_complete",
+ G_CALLBACK (view_complete), book_view_started);
e_book_view_start (book_view);
@@ -609,7 +608,7 @@ load_contacts (EContactPrintContext *ctxt)
g_signal_handlers_disconnect_by_func (
book_view, G_CALLBACK (contacts_added), ctxt);
g_signal_handlers_disconnect_by_func (
- book_view, G_CALLBACK (sequence_complete), book_view_started);
+ book_view, G_CALLBACK (view_complete), book_view_started);
}
static void
diff --git a/addressbook/util/addressbook.c b/addressbook/util/addressbook.c
index b394319c0f..2185434d00 100644
--- a/addressbook/util/addressbook.c
+++ b/addressbook/util/addressbook.c
@@ -37,11 +37,11 @@
#define d(x)
static void addressbook_authenticate (EBook *book, gboolean previous_failure,
- ESource *source, EBookCallback cb, gpointer closure);
+ ESource *source, EBookExCallback cb, gpointer closure);
static void auth_required_cb (EBook *book, gpointer data);
typedef struct {
- EBookCallback cb;
+ EBookExCallback cb;
ESource *source;
gpointer closure;
guint cancelled : 1;
@@ -71,7 +71,7 @@ remove_parameters_from_uri (const gchar *uri)
}
static void
-load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
+load_source_auth_cb (EBook *book, const GError *error, gpointer closure)
{
LoadSourceData *data = closure;
gboolean was_in = g_object_get_data (G_OBJECT (book), "authenticated") != NULL;
@@ -83,10 +83,10 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
return;
}
- if (status != E_BOOK_ERROR_OK) {
+ if (error) {
/* the user clicked cancel in the password dialog */
- if (status == E_BOOK_ERROR_CANCELLED) {
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED)) {
if (e_book_check_static_capability (book, "anon-access")) {
@@ -103,20 +103,20 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
"%s", _("Accessing LDAP Server anonymously"));
g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
- status = E_BOOK_ERROR_OK;
+ error = NULL;
goto done;
}
- } else if (status == E_BOOK_ERROR_INVALID_SERVER_VERSION) {
+ } else if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_INVALID_SERVER_VERSION)) {
e_alert_run_dialog_for_args (e_shell_get_active_window (NULL),
"addressbook:server-version",
NULL);
- status = E_BOOK_ERROR_OK;
+ error = NULL;
goto done;
- } else if (status == E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) {
+ } else if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD)) {
goto done;
} else {
- if (status == E_BOOK_ERROR_AUTHENTICATION_FAILED) {
+ if (g_error_matches (error, E_BOOK_ERROR, E_BOOK_ERROR_AUTHENTICATION_FAILED)) {
const gchar *uri = e_book_get_uri (book);
gchar *stripped_uri = remove_parameters_from_uri (uri);
const gchar *auth_domain = e_source_get_property (data->source, "auth-domain");
@@ -142,7 +142,7 @@ load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
done:
if (data->cb)
- data->cb (book, status, data->closure);
+ data->cb (book, error, data->closure);
free_load_source_data (data);
}
@@ -168,7 +168,7 @@ set_remember_password (ESource *source, gboolean value)
static void
addressbook_authenticate (EBook *book, gboolean previous_failure, ESource *source,
- EBookCallback cb, gpointer closure)
+ EBookExCallback cb, gpointer closure)
{
const gchar *password = NULL;
gchar *pass_dup = NULL;
@@ -231,14 +231,18 @@ addressbook_authenticate (EBook *book, gboolean previous_failure, ESource *sourc
}
if (password || pass_dup) {
- e_book_async_authenticate_user (book, user, password ? password : pass_dup,
- e_source_get_property (source, "auth"),
- cb, closure);
+ e_book_async_authenticate_user_ex (book, user, password ? password : pass_dup,
+ e_source_get_property (source, "auth"),
+ cb, closure);
g_free (pass_dup);
}
else {
+ GError *error = g_error_new (E_BOOK_ERROR, E_BOOK_ERROR_CANCELLED, _("Cancelled"));
+
/* they hit cancel */
- cb (book, E_BOOK_ERROR_CANCELLED, closure);
+ cb (book, error, closure);
+
+ g_error_free (error);
}
g_free (uri);
@@ -256,7 +260,7 @@ auth_required_cb (EBook *book, gpointer data)
}
static void
-load_source_cb (EBook *book, EBookStatus status, gpointer closure)
+load_source_cb (EBook *book, const GError *error, gpointer closure)
{
LoadSourceData *load_source_data = closure;
@@ -265,7 +269,7 @@ load_source_cb (EBook *book, EBookStatus status, gpointer closure)
return;
}
- if (status == E_BOOK_ERROR_OK && book != NULL) {
+ if (!error && book != NULL) {
const gchar *auth;
auth = e_source_get_property (load_source_data->source, "auth");
@@ -279,13 +283,13 @@ load_source_cb (EBook *book, EBookStatus status, gpointer closure)
}
}
}
- load_source_data->cb (book, status, load_source_data->closure);
+ load_source_data->cb (book, error, load_source_data->closure);
free_load_source_data (load_source_data);
}
guint
addressbook_load (EBook *book,
- EBookCallback cb, gpointer closure)
+ EBookExCallback cb, gpointer closure)
{
LoadSourceData *load_source_data = g_new0 (LoadSourceData, 1);
@@ -294,7 +298,7 @@ addressbook_load (EBook *book,
load_source_data->source = g_object_ref (g_object_ref (e_book_get_source (book)));
load_source_data->cancelled = FALSE;
- e_book_async_open (book, FALSE, load_source_cb, load_source_data);
+ e_book_async_open_ex (book, FALSE, load_source_cb, load_source_data);
return GPOINTER_TO_UINT (load_source_data);
}
@@ -308,33 +312,33 @@ addressbook_load_cancel (guint id)
}
static void
-default_book_cb (EBook *book, EBookStatus status, gpointer closure)
+default_book_cb (EBook *book, const GError *error, gpointer closure)
{
LoadSourceData *load_source_data = closure;
- if (status == E_BOOK_ERROR_OK)
+ if (!error)
load_source_data->source = g_object_ref (e_book_get_source (book));
- load_source_cb (book, status, closure);
+ load_source_cb (book, error, closure);
}
void
-addressbook_load_default_book (EBookCallback cb, gpointer closure)
+addressbook_load_default_book (EBookExCallback cb, gpointer closure)
{
LoadSourceData *load_source_data = g_new (LoadSourceData, 1);
EBook *book;
+ GError *error = NULL;
load_source_data->cb = cb;
load_source_data->source = NULL;
load_source_data->closure = closure;
load_source_data->cancelled = FALSE;
- book = e_book_new_default_addressbook (NULL);
- if (!book)
- /* XXX We should just use a GError and its error code here. */
- load_source_cb (
- NULL, E_BOOK_ERROR_OTHER_ERROR, load_source_data);
- else
- e_book_async_open (
+ book = e_book_new_default_addressbook (&error);
+ if (!book) {
+ load_source_cb (NULL, error, load_source_data);
+ g_error_free (error);
+ } else
+ e_book_async_open_ex (
book, FALSE, default_book_cb, load_source_data);
}
diff --git a/addressbook/util/addressbook.h b/addressbook/util/addressbook.h
index 7bc92ee344..fca409ed8c 100644
--- a/addressbook/util/addressbook.h
+++ b/addressbook/util/addressbook.h
@@ -24,8 +24,8 @@
#include <libebook/e-book.h>
-guint addressbook_load (EBook *book, EBookCallback cb, gpointer closure);
+guint addressbook_load (EBook *book, EBookExCallback cb, gpointer closure);
void addressbook_load_cancel (guint id);
-void addressbook_load_default_book (EBookCallback open_response, gpointer closure);
+void addressbook_load_default_book (EBookExCallback open_response, gpointer closure);
#endif /* __ADDRESSBOOK_H__ */
diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c
index 40180d4631..2b1966684e 100644
--- a/addressbook/util/eab-book-util.c
+++ b/addressbook/util/eab-book-util.c
@@ -58,7 +58,7 @@ guint
eab_name_and_email_query (EBook *book,
const gchar *name,
const gchar *email,
- EBookListCallback cb,
+ EBookListExCallback cb,
gpointer closure)
{
gchar *email_query=NULL, *name_query=NULL;
@@ -119,7 +119,7 @@ eab_name_and_email_query (EBook *book,
else
return 0;
- tag = e_book_async_get_contacts (book, query, cb, closure);
+ tag = e_book_async_get_contacts_ex (book, query, cb, closure);
g_free (email_query);
g_free (name_query);
@@ -136,7 +136,7 @@ eab_name_and_email_query (EBook *book,
guint
eab_nickname_query (EBook *book,
const gchar *nickname,
- EBookListCallback cb,
+ EBookListExCallback cb,
gpointer closure)
{
EBookQuery *query;
@@ -154,7 +154,7 @@ eab_nickname_query (EBook *book,
query = e_book_query_from_string (query_string);
- retval = e_book_async_get_contacts (book, query, cb, closure);
+ retval = e_book_async_get_contacts_ex (book, query, cb, closure);
g_free (query_string);
e_book_query_unref (query);
diff --git a/addressbook/util/eab-book-util.h b/addressbook/util/eab-book-util.h
index 9f8a79eae1..edc7c3ebe6 100644
--- a/addressbook/util/eab-book-util.h
+++ b/addressbook/util/eab-book-util.h
@@ -34,11 +34,11 @@ typedef void (*EABHaveAddressCallback) (EBook *book, const gchar *addr, EContact
guint eab_name_and_email_query (EBook *book,
const gchar *name,
const gchar *email,
- EBookListCallback cb,
+ EBookListExCallback cb,
gpointer closure);
guint eab_nickname_query (EBook *book,
const gchar *nickname,
- EBookListCallback cb,
+ EBookListExCallback cb,
gpointer closure);
GList *eab_contact_list_from_string (const gchar *str);