aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-01-31 01:20:16 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-01-31 01:45:55 +0800
commit763081aa862908e845bc780b784d939a07abd508 (patch)
tree1a060b3cc1ae28e915348939cbbcdd28416a13b5 /addressbook
parent0ff254b3a8946244b645f2ea74316926aa109ab6 (diff)
downloadgsoc2013-evolution-763081aa862908e845bc780b784d939a07abd508.tar.gz
gsoc2013-evolution-763081aa862908e845bc780b784d939a07abd508.tar.zst
gsoc2013-evolution-763081aa862908e845bc780b784d939a07abd508.zip
Fix up error handling around e_book/cal_client_connect_finish().
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c44
-rw-r--r--addressbook/gui/contact-editor/e-contact-quick-add.c10
-rw-r--r--addressbook/gui/contact-list-editor/e-contact-list-editor.c31
-rw-r--r--addressbook/gui/widgets/e-addressbook-selector.c4
-rw-r--r--addressbook/gui/widgets/eab-gui-util.c4
5 files changed, 67 insertions, 26 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index a0bd221f94..0f3aef0739 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -63,6 +63,11 @@ enum {
NUM_IM_COLUMNS
};
+typedef struct {
+ EContactEditor *editor;
+ ESource *source;
+} ConnectClosure;
+
static void e_contact_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -196,6 +201,18 @@ static const gint email_default[] = { 0, 1, 2, 2 };
G_DEFINE_TYPE (EContactEditor, e_contact_editor, EAB_TYPE_EDITOR)
static void
+connect_closure_free (ConnectClosure *connect_closure)
+{
+ if (connect_closure->editor != NULL)
+ g_object_unref (connect_closure->editor);
+
+ if (connect_closure->source != NULL)
+ g_object_unref (connect_closure->source);
+
+ g_slice_free (ConnectClosure, connect_closure);
+}
+
+static void
e_contact_editor_contact_added (EABEditor *editor,
const GError *error,
EContact *contact)
@@ -3088,8 +3105,7 @@ contact_editor_client_connect_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EContactEditor *editor = user_data;
+ ConnectClosure *closure = user_data;
EClient *client;
GError *error = NULL;
@@ -3110,31 +3126,37 @@ contact_editor_client_connect_cb (GObject *source_object,
GtkWidget *source_combo_box;
GtkWindow *parent;
- parent = eab_editor_get_window (EAB_EDITOR (editor));
- eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error);
+ parent = eab_editor_get_window (EAB_EDITOR (closure->editor));
+
+ eab_load_error_dialog (
+ GTK_WIDGET (parent), NULL,
+ closure->source, error);
source_combo_box = e_builder_get_widget (
- editor->builder, "source-combo-box-source");
+ closure->editor->builder,
+ "source-combo-box-source");
e_source_combo_box_set_active (
- E_SOURCE_COMBO_BOX (source_combo_box), source);
+ E_SOURCE_COMBO_BOX (source_combo_box),
+ closure->source);
g_error_free (error);
goto exit;
}
/* FIXME Write a private contact_editor_set_target_client(). */
- g_object_set (editor, "target_client", client, NULL);
+ g_object_set (closure->editor, "target_client", client, NULL);
g_object_unref (client);
exit:
- g_object_unref (editor);
+ connect_closure_free (closure);
}
static void
source_changed (ESourceComboBox *source_combo_box,
EContactEditor *editor)
{
+ ConnectClosure *closure;
ESource *target_source;
ESource *source_source;
ESource *source;
@@ -3163,10 +3185,14 @@ source_changed (ESourceComboBox *source_combo_box,
editor->cancellable = g_cancellable_new ();
+ closure = g_slice_new0 (ConnectClosure);
+ closure->editor = g_object_ref (editor);
+ closure->source = g_object_ref (source);
+
e_book_client_connect (
source, editor->cancellable,
contact_editor_client_connect_cb,
- g_object_ref (editor));
+ closure);
exit:
g_object_unref (source);
diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c
index afbd817ac7..0bfa46b9a8 100644
--- a/addressbook/gui/contact-editor/e-contact-quick-add.c
+++ b/addressbook/gui/contact-editor/e-contact-quick-add.c
@@ -124,7 +124,6 @@ merge_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
QuickAdd *qa = user_data;
EClient *client;
GError *error = NULL;
@@ -156,12 +155,15 @@ merge_cb (GObject *source_object,
eab_merging_book_add_contact (
qa->registry, E_BOOK_CLIENT (client),
qa->contact, NULL, NULL);
- else
+ else {
+ ESource *source = e_client_get_source (client);
+
e_alert_run_dialog_for_args (
e_shell_get_active_window (NULL),
"addressbook:error-read-only",
e_source_get_display_name (source),
NULL);
+ }
if (qa->cb)
qa->cb (qa->contact, qa->closure);
@@ -299,9 +301,7 @@ ce_have_book (GObject *source_object,
}
if (error != NULL) {
- g_warning (
- "Couldn't open local address book (%s).",
- error->message);
+ g_warning ("%s", error->message);
quick_add_unref (qa);
g_error_free (error);
return;
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 6f92e511de..d160563d91 100644
--- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c
+++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c
@@ -134,8 +134,25 @@ struct _EContactListEditorPrivate {
guint in_async_call : 1;
};
+typedef struct {
+ EContactListEditor *editor;
+ ESource *source;
+} ConnectClosure;
+
G_DEFINE_TYPE (EContactListEditor, e_contact_list_editor, EAB_TYPE_EDITOR)
+static void
+connect_closure_free (ConnectClosure *connect_closure)
+{
+ if (connect_closure->editor != NULL)
+ g_object_unref (connect_closure->editor);
+
+ if (connect_closure->source != NULL)
+ g_object_unref (connect_closure->source);
+
+ g_slice_free (ConnectClosure, connect_closure);
+}
+
static EContactListEditor *
contact_list_editor_extract (GtkWidget *widget)
{
@@ -305,9 +322,8 @@ contact_list_editor_client_connect_cb (GObject *source_object,
GAsyncResult *result,
gpointer user_data)
{
- ESource *source = E_SOURCE (source_object);
- EContactListEditor *editor = user_data;
- EContactListEditorPrivate *priv = editor->priv;
+ ConnectClosure *closure = user_data;
+ EContactListEditor *editor = closure->editor;
EContactStore *contact_store;
ENameSelectorEntry *entry;
EClient *client;
@@ -325,11 +341,14 @@ contact_list_editor_client_connect_cb (GObject *source_object,
GtkWindow *parent;
parent = eab_editor_get_window (EAB_EDITOR (editor));
- eab_load_error_dialog (GTK_WIDGET (parent), NULL, source, error);
+
+ eab_load_error_dialog (
+ GTK_WIDGET (parent), NULL,
+ closure->source, error);
e_source_combo_box_set_active (
E_SOURCE_COMBO_BOX (WIDGET (SOURCE_MENU)),
- e_client_get_source (E_CLIENT (priv->book_client)));
+ closure->source);
g_error_free (error);
goto exit;
@@ -345,7 +364,7 @@ contact_list_editor_client_connect_cb (GObject *source_object,
g_object_unref (client);
exit:
- g_object_unref (editor);
+ connect_closure_free (closure);
}
static void
diff --git a/addressbook/gui/widgets/e-addressbook-selector.c b/addressbook/gui/widgets/e-addressbook-selector.c
index eedc776a6c..73a3334084 100644
--- a/addressbook/gui/widgets/e-addressbook-selector.c
+++ b/addressbook/gui/widgets/e-addressbook-selector.c
@@ -265,9 +265,7 @@ target_client_connect_cb (GObject *source_object,
((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warning (
- "%s: Failed to open targer client: %s",
- G_STRFUNC, error->message);
+ g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
}
diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c
index 2f0f29ea23..2967ca9e16 100644
--- a/addressbook/gui/widgets/eab-gui-util.c
+++ b/addressbook/gui/widgets/eab-gui-util.c
@@ -540,9 +540,7 @@ book_client_connect_cb (GObject *source_object,
((client == NULL) && (error != NULL)));
if (error != NULL) {
- g_warning (
- "%s: Failed to open destination client: %s",
- G_STRFUNC, error->message);
+ g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
goto exit;
}