aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar/e-cal-shell-sidebar.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-07-01 12:07:26 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-09-14 20:08:48 +0800
commitae9db3ed236b0c734fd12c8dc8c99764626bf0b8 (patch)
treebd45389467f43a96c36172d8a925dd5df041cf5b /modules/calendar/e-cal-shell-sidebar.c
parentdb969c7f664d0a1d901bedd794b0c7e0762ede33 (diff)
downloadgsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.tar
gsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.tar.gz
gsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.tar.bz2
gsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.tar.lz
gsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.tar.xz
gsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.tar.zst
gsoc2013-evolution-ae9db3ed236b0c734fd12c8dc8c99764626bf0b8.zip
Coding style and whitespace cleanup.
Diffstat (limited to 'modules/calendar/e-cal-shell-sidebar.c')
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c90
1 files changed, 65 insertions, 25 deletions
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index e296f6ff31..77c5639a78 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -165,7 +165,9 @@ cal_shell_sidebar_backend_error_cb (ECalShellSidebar *cal_shell_sidebar,
}
static void
-cal_shell_sidebar_retrieve_capabilies_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+cal_shell_sidebar_retrieve_capabilies_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ECalClient *client = E_CAL_CLIENT (source_object);
ECalShellSidebar *cal_shell_sidebar = user_data;
@@ -174,10 +176,12 @@ cal_shell_sidebar_retrieve_capabilies_cb (GObject *source_object, GAsyncResult *
g_return_if_fail (client != NULL);
g_return_if_fail (cal_shell_sidebar != NULL);
- e_client_retrieve_capabilities_finish (E_CLIENT (client), result, &capabilities, NULL);
+ e_client_retrieve_capabilities_finish (
+ E_CLIENT (client), result, &capabilities, NULL);
g_free (capabilities);
- cal_shell_sidebar_emit_status_message (cal_shell_sidebar, _("Loading calendars"));
+ cal_shell_sidebar_emit_status_message (
+ cal_shell_sidebar, _("Loading calendars"));
cal_shell_sidebar_emit_client_added (cal_shell_sidebar, client);
cal_shell_sidebar_emit_status_message (cal_shell_sidebar, NULL);
}
@@ -205,15 +209,20 @@ free_retry_open_data (gpointer data)
}
static void
-cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+cal_shell_sidebar_client_opened_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
ECalClient *client = E_CAL_CLIENT (source_object);
ECalShellSidebar *cal_shell_sidebar = user_data;
+ ESource *source;
EShellView *shell_view;
EShellContent *shell_content;
EShellSidebar *shell_sidebar;
GError *error = NULL;
+ source = e_client_get_source (E_CLIENT (client));
+
e_client_open_finish (E_CLIENT (client), result, &error);
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
@@ -227,7 +236,10 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result
e_client_utils_forget_password (E_CLIENT (client));
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
- e_client_open (E_CLIENT (client), FALSE, cal_shell_sidebar->priv->loading_clients, cal_shell_sidebar_client_opened_cb, user_data);
+ e_client_open (
+ E_CLIENT (client), FALSE,
+ cal_shell_sidebar->priv->loading_clients,
+ cal_shell_sidebar_client_opened_cb, user_data);
g_clear_error (&error);
return;
@@ -242,7 +254,10 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result
rod->cancellable = g_object_ref (cal_shell_sidebar->priv->loading_clients);
/* postpone for 1/2 of a second, backend is busy now */
- g_timeout_add_full (G_PRIORITY_DEFAULT, 500, cal_shell_sidebar_retry_open_timeout_cb, rod, free_retry_open_data);
+ g_timeout_add_full (
+ G_PRIORITY_DEFAULT, 500,
+ cal_shell_sidebar_retry_open_timeout_cb,
+ rod, free_retry_open_data);
g_clear_error (&error);
return;
@@ -258,7 +273,10 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result
break;
case E_CLIENT_ERROR_BUSY:
- g_debug ("%s: Cannot open '%s', it's busy (%s)", G_STRFUNC, e_source_peek_name (e_client_get_source (E_CLIENT (client))), error->message);
+ g_warning (
+ "%s: Cannot open '%s', it's busy (%s)",
+ G_STRFUNC, e_source_peek_name (source),
+ error->message);
g_clear_error (&error);
return;
@@ -287,7 +305,10 @@ cal_shell_sidebar_client_opened_cb (GObject *source_object, GAsyncResult *result
g_clear_error (&error);
/* to have them ready for later use */
- e_client_retrieve_capabilities (E_CLIENT (client), NULL, cal_shell_sidebar_retrieve_capabilies_cb, cal_shell_sidebar);
+ e_client_retrieve_capabilities (
+ E_CLIENT (client), NULL,
+ cal_shell_sidebar_retrieve_capabilies_cb,
+ cal_shell_sidebar);
}
static gboolean
@@ -303,14 +324,21 @@ cal_shell_sidebar_retry_open_timeout_cb (gpointer user_data)
if (g_cancellable_is_cancelled (rod->cancellable))
return FALSE;
- e_client_open (rod->client, FALSE, rod->cal_shell_sidebar->priv->loading_clients, cal_shell_sidebar_client_opened_cb, rod->cal_shell_sidebar);
+ e_client_open (
+ rod->client, FALSE,
+ rod->cal_shell_sidebar->priv->loading_clients,
+ cal_shell_sidebar_client_opened_cb,
+ rod->cal_shell_sidebar);
return FALSE;
}
static void
-cal_shell_sidebar_default_loaded_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+cal_shell_sidebar_default_loaded_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ ESource *source = E_SOURCE (source_object);
EShellSidebar *shell_sidebar = user_data;
ECalShellSidebarPrivate *priv;
EShellContent *shell_content;
@@ -322,21 +350,22 @@ cal_shell_sidebar_default_loaded_cb (GObject *source_object, GAsyncResult *resul
priv = E_CAL_SHELL_SIDEBAR (shell_sidebar)->priv;
- if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error))
- client = NULL;
+ shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ cal_shell_content = E_CAL_SHELL_CONTENT (shell_content);
+ model = e_cal_shell_content_get_model (cal_shell_content);
+
+ e_client_utils_open_new_finish (source, result, &client, &error);
+ /* Ignore cancellations. */
if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_CANCELLED) ||
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
- }
-
- shell_view = e_shell_sidebar_get_shell_view (shell_sidebar);
- shell_content = e_shell_view_get_shell_content (shell_view);
- cal_shell_content = E_CAL_SHELL_CONTENT (shell_content);
- model = e_cal_shell_content_get_model (cal_shell_content);
- if (error != NULL) {
+ } else if (error != NULL) {
+ g_warn_if_fail (client == NULL);
e_alert_submit (
E_ALERT_SINK (shell_content),
"calendar:failed-open-calendar",
@@ -352,7 +381,8 @@ cal_shell_sidebar_default_loaded_cb (GObject *source_object, GAsyncResult *resul
priv->default_client = E_CAL_CLIENT (client);
- e_cal_client_set_default_timezone (priv->default_client, e_cal_model_get_timezone (model));
+ e_cal_client_set_default_timezone (
+ priv->default_client, e_cal_model_get_timezone (model));
g_object_notify (G_OBJECT (shell_sidebar), "default-client");
@@ -401,9 +431,13 @@ cal_shell_sidebar_set_default (ECalShellSidebar *cal_shell_sidebar,
priv->loading_default_client = g_cancellable_new ();
- e_client_utils_open_new (source, E_CLIENT_SOURCE_TYPE_EVENTS, FALSE, priv->loading_default_client,
- e_client_utils_authenticate_handler, GTK_WINDOW (shell_window),
- cal_shell_sidebar_default_loaded_cb, g_object_ref (shell_sidebar));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_EVENTS,
+ FALSE, priv->loading_default_client,
+ e_client_utils_authenticate_handler,
+ GTK_WINDOW (shell_window),
+ cal_shell_sidebar_default_loaded_cb,
+ g_object_ref (shell_sidebar));
}
static void
@@ -1064,7 +1098,9 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
if (client == NULL) {
client = e_cal_client_new (source, source_type, NULL);
if (client)
- g_signal_connect (client, "authenticate", G_CALLBACK (e_client_utils_authenticate_handler), NULL);
+ g_signal_connect (
+ client, "authenticate",
+ G_CALLBACK (e_client_utils_authenticate_handler), NULL);
}
g_return_if_fail (client != NULL);
@@ -1099,7 +1135,11 @@ e_cal_shell_sidebar_add_source (ECalShellSidebar *cal_shell_sidebar,
timezone = e_cal_model_get_timezone (model);
e_cal_client_set_default_timezone (client, timezone);
- e_client_open (E_CLIENT (client), FALSE, cal_shell_sidebar->priv->loading_clients, cal_shell_sidebar_client_opened_cb, cal_shell_sidebar);
+
+ e_client_open (
+ E_CLIENT (client), FALSE,
+ cal_shell_sidebar->priv->loading_clients,
+ cal_shell_sidebar_client_opened_cb, cal_shell_sidebar);
}
void