aboutsummaryrefslogtreecommitdiffstats
path: root/modules/addressbook
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-07-01 12:07:26 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-08-13 23:27:51 +0800
commitf59681796df8fe0138a1754abbe8ec781bc1535e (patch)
tree0ced0c119ffed095713d7f64732686df9b2d9152 /modules/addressbook
parentbf4a1a13e3295deefc4031a446627ff9b1c95c7a (diff)
downloadgsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.tar
gsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.tar.gz
gsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.tar.bz2
gsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.tar.lz
gsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.tar.xz
gsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.tar.zst
gsoc2013-evolution-f59681796df8fe0138a1754abbe8ec781bc1535e.zip
Coding style and whitespace cleanup.
Diffstat (limited to 'modules/addressbook')
-rw-r--r--modules/addressbook/e-book-shell-backend.c92
-rw-r--r--modules/addressbook/e-book-shell-view-private.c52
2 files changed, 87 insertions, 57 deletions
diff --git a/modules/addressbook/e-book-shell-backend.c b/modules/addressbook/e-book-shell-backend.c
index d80d9554a0..c52b39b9fa 100644
--- a/modules/addressbook/e-book-shell-backend.c
+++ b/modules/addressbook/e-book-shell-backend.c
@@ -86,9 +86,13 @@ book_shell_backend_ensure_sources (EShellBackend *shell_backend)
priv = E_BOOK_SHELL_BACKEND (shell_backend)->priv;
- if (!e_book_client_get_sources (&priv->source_list, &error)) {
- g_warning ("Could not get addressbook sources: %s", error ? error->message : "Unknown error");
- g_clear_error (&error);
+ e_book_client_get_sources (&priv->source_list, &error);
+
+ if (error != NULL) {
+ g_warning (
+ "Could not get addressbook sources: %s",
+ error->message);
+ g_error_free (error);
return;
}
@@ -156,68 +160,82 @@ book_shell_backend_init_importers (void)
}
static void
-book_shell_backend_new_contact_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+book_shell_backend_new_contact_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ ESource *source = E_SOURCE (source_object);
EShell *shell = user_data;
EClient *client = NULL;
+ EContact *contact;
+ EABEditor *editor;
GError *error = NULL;
- if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
- client = NULL;
+ e_client_utils_open_new_finish (source, result, &client, &error);
/* XXX Handle errors better. */
- if (client == NULL) {
- g_debug ("%s: Failed to open book: %s", G_STRFUNC, error ? error->message : "Unknown error");
- g_clear_error (&error);
- } else {
- EBookClient *book_client = E_BOOK_CLIENT (client);
- EContact *contact;
- EABEditor *editor;
+ if (error != NULL) {
+ g_warn_if_fail (client == NULL);
+ g_warning (
+ "%s: Failed to open book: %s",
+ G_STRFUNC, error->message);
+ g_error_free (error);
+ goto exit;
+ }
- contact = e_contact_new ();
+ g_return_if_fail (E_IS_CLIENT (client));
- editor = e_contact_editor_new (
- shell, book_client, contact, TRUE, TRUE);
+ contact = e_contact_new ();
- eab_editor_show (editor);
+ editor = e_contact_editor_new (
+ shell, E_BOOK_CLIENT (client), contact, TRUE, TRUE);
- g_object_unref (contact);
- g_object_unref (book_client);
- }
+ eab_editor_show (editor);
+
+ g_object_unref (contact);
+ g_object_unref (client);
+exit:
g_object_unref (shell);
}
static void
-book_shell_backend_new_contact_list_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+book_shell_backend_new_contact_list_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ ESource *source = E_SOURCE (source_object);
EShell *shell = user_data;
EClient *client = NULL;
+ EContact *contact;
+ EABEditor *editor;
GError *error = NULL;
- if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
- client = NULL;
+ e_client_utils_open_new_finish (source, result, &client, &error);
/* XXX Handle errors better. */
- if (client == NULL) {
- g_debug ("%s: Failed to open book: %s", G_STRFUNC, error ? error->message : "Unknown error");
- g_clear_error (&error);
- } else {
- EBookClient *book_client = E_BOOK_CLIENT (client);
- EContact *contact;
- EABEditor *editor;
+ if (error != NULL) {
+ g_warn_if_fail (client == NULL);
+ g_warning (
+ "%s: Failed to open book: %s",
+ G_STRFUNC, error->message);
+ g_error_free (error);
+ goto exit;
+ }
- contact = e_contact_new ();
+ g_return_if_fail (E_IS_CLIENT (client));
- editor = e_contact_list_editor_new (
- shell, book_client, contact, TRUE, TRUE);
+ contact = e_contact_new ();
- eab_editor_show (editor);
+ editor = e_contact_list_editor_new (
+ shell, E_BOOK_CLIENT (client), contact, TRUE, TRUE);
- g_object_unref (contact);
- g_object_unref (book_client);
- }
+ eab_editor_show (editor);
+
+ g_object_unref (contact);
+ g_object_unref (client);
+exit:
g_object_unref (shell);
}
diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c
index c9a233df9f..20fd278f66 100644
--- a/modules/addressbook/e-book-shell-view-private.c
+++ b/modules/addressbook/e-book-shell-view-private.c
@@ -184,40 +184,48 @@ contacts_removed (EBookShellView *book_shell_view,
}
static void
-book_shell_view_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+book_shell_view_loaded_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ESource *source = E_SOURCE (source_object);
EAddressbookView *view = user_data;
EClient *client = NULL;
- EBookClient *book;
+ EAddressbookModel *model;
GError *error = NULL;
- if (!e_client_utils_open_new_finish (source, result, &client, &error))
- client = NULL;
-
- book = client ? E_BOOK_CLIENT (client) : NULL;
-
- if (book != NULL) {
- EAddressbookModel *model;
+ e_client_utils_open_new_finish (source, result, &client, &error);
- g_warn_if_fail (error == NULL);
- model = e_addressbook_view_get_model (view);
- e_addressbook_model_set_client (model, book);
- e_addressbook_model_force_folder_bar_message (model);
+ /* Ignore cancellations. */
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_warn_if_fail (client == NULL);
+ g_error_free (error);
+ goto exit;
- } else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ } else if (error != NULL) {
EShellView *shell_view;
+ EShellContent *shell_content;
EAlertSink *alert_sink;
+ g_warn_if_fail (client == NULL);
+
shell_view = e_addressbook_view_get_shell_view (view);
- alert_sink = E_ALERT_SINK (e_shell_view_get_shell_content (shell_view));
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ alert_sink = E_ALERT_SINK (shell_content);
eab_load_error_dialog (NULL, alert_sink, source, error);
- }
- if (error != NULL)
g_error_free (error);
+ goto exit;
+ }
+
+ g_return_if_fail (E_IS_CLIENT (client));
+
+ model = e_addressbook_view_get_model (view);
+ e_addressbook_model_set_client (model, E_BOOK_CLIENT (client));
+ e_addressbook_model_force_folder_bar_message (model);
+exit:
g_object_unref (view);
}
@@ -260,9 +268,13 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view,
if (e_addressbook_model_get_client (model) == NULL)
/* XXX No way to cancel this? */
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE, NULL,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- book_shell_view_loaded_cb, g_object_ref (view));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS,
+ FALSE, NULL,
+ e_client_utils_authenticate_handler,
+ GTK_WINDOW (shell_window),
+ book_shell_view_loaded_cb,
+ g_object_ref (view));
} else {
/* Create a view for this UID. */