aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-02-17 23:37:47 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-02-18 02:36:38 +0800
commit7454ee0f7c7ed7f91c542f962820dab683f21898 (patch)
tree55f53148116546227872118fb2a50bd1ce4e3aa5 /modules
parent2e858dc05e7e759971f9ec46af87afdbe4c92569 (diff)
downloadgsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.tar
gsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.tar.gz
gsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.tar.bz2
gsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.tar.lz
gsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.tar.xz
gsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.tar.zst
gsoc2013-evolution-7454ee0f7c7ed7f91c542f962820dab683f21898.zip
ECalShellBackend: Use EClientCache to obtain an EClient.
Diffstat (limited to 'modules')
-rw-r--r--modules/calendar/e-cal-shell-backend.c129
1 files changed, 85 insertions, 44 deletions
diff --git a/modules/calendar/e-cal-shell-backend.c b/modules/calendar/e-cal-shell-backend.c
index f2453e9714..d26c2cdea9 100644
--- a/modules/calendar/e-cal-shell-backend.c
+++ b/modules/calendar/e-cal-shell-backend.c
@@ -61,34 +61,15 @@ G_DEFINE_DYNAMIC_TYPE (
E_TYPE_SHELL_BACKEND)
static void
-cal_shell_backend_new_event (ESource *source,
- GAsyncResult *result,
+cal_shell_backend_new_event (ECalClient *cal_client,
EShell *shell,
CompEditorFlags flags,
gboolean all_day)
{
- EClient *client;
- ECalClient *cal_client;
ECalComponent *comp;
EShellSettings *shell_settings;
CompEditor *editor;
- GError *error = NULL;
-
- client = e_cal_client_connect_finish (result, &error);
-
- /* Sanity check. */
- g_return_if_fail (
- ((client != NULL) && (error == NULL)) ||
- ((client == NULL) && (error != NULL)));
-
- /* XXX Handle errors better. */
- if (error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- return;
- }
- cal_client = E_CAL_CLIENT (client);
shell_settings = e_shell_get_shell_settings (shell);
editor = event_editor_new (cal_client, shell, flags);
@@ -108,22 +89,39 @@ cal_shell_backend_new_event (ESource *source,
gtk_window_present (GTK_WINDOW (editor));
g_object_unref (comp);
- g_object_unref (client);
}
static void
cal_shell_backend_event_new_cb (GObject *source_object,
GAsyncResult *result,
- gpointer shell)
+ gpointer user_data)
{
+ EShell *shell = E_SHELL (user_data);
+ EClient *client;
CompEditorFlags flags = 0;
gboolean all_day = FALSE;
+ GError *error = NULL;
flags |= COMP_EDITOR_NEW_ITEM;
flags |= COMP_EDITOR_USER_ORG;
- cal_shell_backend_new_event (
- E_SOURCE (source_object), result, shell, flags, all_day);
+ client = e_client_cache_get_client_finish (
+ E_CLIENT_CACHE (source_object), result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (client != NULL) {
+ cal_shell_backend_new_event (
+ E_CAL_CLIENT (client), shell, flags, all_day);
+ g_object_unref (client);
+ } else {
+ /* XXX Handle errors better. */
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
g_object_unref (shell);
}
@@ -131,16 +129,34 @@ cal_shell_backend_event_new_cb (GObject *source_object,
static void
cal_shell_backend_event_all_day_new_cb (GObject *source_object,
GAsyncResult *result,
- gpointer shell)
+ gpointer user_data)
{
+ EShell *shell = E_SHELL (user_data);
+ EClient *client;
CompEditorFlags flags = 0;
gboolean all_day = TRUE;
+ GError *error = NULL;
flags |= COMP_EDITOR_NEW_ITEM;
flags |= COMP_EDITOR_USER_ORG;
- cal_shell_backend_new_event (
- E_SOURCE (source_object), result, shell, flags, all_day);
+ client = e_client_cache_get_client_finish (
+ E_CLIENT_CACHE (source_object), result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (client != NULL) {
+ cal_shell_backend_new_event (
+ E_CAL_CLIENT (client), shell, flags, all_day);
+ g_object_unref (client);
+ } else {
+ /* XXX Handle errors better. */
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
g_object_unref (shell);
}
@@ -148,17 +164,35 @@ cal_shell_backend_event_all_day_new_cb (GObject *source_object,
static void
cal_shell_backend_event_meeting_new_cb (GObject *source_object,
GAsyncResult *result,
- gpointer shell)
+ gpointer user_data)
{
+ EShell *shell = E_SHELL (user_data);
+ EClient *client;
CompEditorFlags flags = 0;
gboolean all_day = FALSE;
+ GError *error = NULL;
flags |= COMP_EDITOR_NEW_ITEM;
flags |= COMP_EDITOR_USER_ORG;
flags |= COMP_EDITOR_MEETING;
- cal_shell_backend_new_event (
- E_SOURCE (source_object), result, shell, flags, all_day);
+ client = e_client_cache_get_client_finish (
+ E_CLIENT_CACHE (source_object), result, &error);
+
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
+
+ if (client != NULL) {
+ cal_shell_backend_new_event (
+ E_CAL_CLIENT (client), shell, flags, all_day);
+ g_object_unref (client);
+ } else {
+ /* XXX Handle errors better. */
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ }
g_object_unref (shell);
}
@@ -172,10 +206,11 @@ action_event_new_cb (GtkAction *action,
EShellBackend *shell_backend;
ESource *source;
ESourceRegistry *registry;
- ECalClientSourceType source_type;
+ EClientCache *client_cache;
const gchar *action_name;
shell = e_shell_window_get_shell (shell_window);
+ client_cache = e_shell_get_client_cache (shell);
action_name = gtk_action_get_name (action);
@@ -215,29 +250,32 @@ action_event_new_cb (GtkAction *action,
/* This callback is used for both appointments and meetings. */
- source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
-
registry = e_shell_get_registry (shell);
source = e_source_registry_ref_default_calendar (registry);
shell_backend = e_shell_get_backend_by_name (shell, "calendar");
g_object_set (G_OBJECT (shell_backend), "prefer-new-item", action_name, NULL);
- /* Use a callback function appropriate for the action.
- * FIXME Need to obtain a better default time zone. */
+ /* Use a callback function appropriate for the action. */
if (strcmp (action_name, "event-all-day-new") == 0)
- e_cal_client_connect (
- source, source_type, NULL,
+ e_client_cache_get_client (
+ client_cache, source,
+ E_SOURCE_EXTENSION_CALENDAR,
+ NULL,
cal_shell_backend_event_all_day_new_cb,
g_object_ref (shell));
else if (strcmp (action_name, "event-meeting-new") == 0)
- e_cal_client_connect (
- source, source_type, NULL,
+ e_client_cache_get_client (
+ client_cache, source,
+ E_SOURCE_EXTENSION_CALENDAR,
+ NULL,
cal_shell_backend_event_meeting_new_cb,
g_object_ref (shell));
else
- e_cal_client_connect (
- source, source_type, NULL,
+ e_client_cache_get_client (
+ client_cache, source,
+ E_SOURCE_EXTENSION_CALENDAR,
+ NULL,
cal_shell_backend_event_new_cb,
g_object_ref (shell));
@@ -346,10 +384,10 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
CompEditor *editor;
CompEditorFlags flags = 0;
EClient *client;
+ EClientCache *client_cache;
ECalComponent *comp;
ESource *source;
ESourceRegistry *registry;
- ECalClientSourceType source_type;
SoupURI *soup_uri;
icalcomponent *icalcomp;
icalproperty *icalprop;
@@ -363,8 +401,8 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
gboolean handled = FALSE;
GError *error = NULL;
- source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
shell = e_shell_backend_get_shell (shell_backend);
+ client_cache = e_shell_get_client_cache (shell);
shell_settings = e_shell_get_shell_settings (shell);
zone = e_shell_settings_get_pointer (shell_settings, "cal-timezone");
@@ -456,7 +494,10 @@ cal_shell_backend_handle_uri_cb (EShellBackend *shell_backend,
goto exit;
}
- client = e_cal_client_connect_sync (source, source_type, NULL, &error);
+ client = e_client_cache_get_client_sync (
+ client_cache, source,
+ E_SOURCE_EXTENSION_CALENDAR,
+ NULL, &error);
/* Sanity check. */
g_return_val_if_fail (