[evolution/wip/webkit2] Use EClientCache to open calendars in plugins



commit 8662087356b31da5c9776f69cc473e136b0cd605
Author: Milan Crha <mcrha redhat com>
Date:   Tue Nov 25 19:09:19 2014 +0100

    Use EClientCache to open calendars in plugins
    
    This partly fixes bug #721712 (Writeable calendars can report
    as read-only after open), because the EClientCache always returns
    the same EClient, which has internal properties properly updated
    (at the second and following calls).

 plugins/mail-to-task/mail-to-task.c            |    9 +++++++--
 plugins/publish-calendar/publish-format-fb.c   |    8 +++++---
 plugins/publish-calendar/publish-format-ical.c |    8 +++++---
 plugins/save-calendar/csv-format.c             |    6 +++---
 plugins/save-calendar/format-handler.h         |    2 +-
 plugins/save-calendar/ical-format.c            |    6 +++---
 plugins/save-calendar/rdf-format.c             |    6 +++---
 plugins/save-calendar/save-calendar.c          |   19 +++++++++++--------
 8 files changed, 38 insertions(+), 26 deletions(-)
---
diff --git a/plugins/mail-to-task/mail-to-task.c b/plugins/mail-to-task/mail-to-task.c
index a07feed..ceaa01f 100644
--- a/plugins/mail-to-task/mail-to-task.c
+++ b/plugins/mail-to-task/mail-to-task.c
@@ -824,7 +824,9 @@ do_manage_comp_idle (struct _manage_comp *mc)
 }
 
 typedef struct {
+       EClientCache *client_cache;
        ESource *source;
+       const gchar *extension_name;
        ECalClientSourceType source_type;
        CamelFolder *folder;
        GPtrArray *uids;
@@ -840,8 +842,8 @@ do_mail_to_event (AsyncData *data)
        GPtrArray *uids = data->uids;
        GError *error = NULL;
 
-       client = e_cal_client_connect_sync (
-               data->source, data->source_type, NULL, &error);
+       client = e_client_cache_get_client_sync (data->client_cache,
+               data->source, data->extension_name, NULL, &error);
 
        /* Sanity check. */
        g_return_val_if_fail (
@@ -1036,6 +1038,7 @@ do_mail_to_event (AsyncData *data)
        g_ptr_array_unref (uids);
        g_object_unref (folder);
 
+       g_object_unref (data->client_cache);
        g_object_unref (data->source);
        g_free (data);
        data = NULL;
@@ -1193,7 +1196,9 @@ mail_to_event (ECalClientSourceType source_type,
 
                /* Fill the elements in AsynData */
                data = g_new0 (AsyncData, 1);
+               data->client_cache = g_object_ref (e_shell_get_client_cache (shell));
                data->source = g_object_ref (source);
+               data->extension_name = extension_name;
                data->source_type = source_type;
                data->folder = e_mail_reader_ref_folder (reader);
                data->uids = g_ptr_array_ref (uids);
diff --git a/plugins/publish-calendar/publish-format-fb.c b/plugins/publish-calendar/publish-format-fb.c
index caa88c4..0a064a9 100644
--- a/plugins/publish-calendar/publish-format-fb.c
+++ b/plugins/publish-calendar/publish-format-fb.c
@@ -88,9 +88,11 @@ write_calendar (const gchar *uid,
        source = e_source_registry_ref_source (registry, uid);
 
        if (source != NULL) {
-               client = e_cal_client_connect_sync (
-                       source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
-                       NULL, error);
+               EClientCache *client_cache;
+
+               client_cache = e_shell_get_client_cache (shell);
+               client = e_client_cache_get_client_sync (client_cache, source, E_SOURCE_EXTENSION_CALENDAR, 
NULL, error);
+
                g_object_unref (source);
        } else {
                g_set_error (
diff --git a/plugins/publish-calendar/publish-format-ical.c b/plugins/publish-calendar/publish-format-ical.c
index 33cc45d..06215a6 100644
--- a/plugins/publish-calendar/publish-format-ical.c
+++ b/plugins/publish-calendar/publish-format-ical.c
@@ -91,9 +91,11 @@ write_calendar (const gchar *uid,
        source = e_source_registry_ref_source (registry, uid);
 
        if (source != NULL) {
-               client = e_cal_client_connect_sync (
-                       source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS,
-                       NULL, error);
+               EClientCache *client_cache;
+
+               client_cache = e_shell_get_client_cache (shell);
+               client = e_client_cache_get_client_sync (client_cache, source, E_SOURCE_EXTENSION_CALENDAR, 
NULL, error);
+
                g_object_unref (source);
        } else {
                g_set_error (
diff --git a/plugins/save-calendar/csv-format.c b/plugins/save-calendar/csv-format.c
index 650d01b..498f5e5 100644
--- a/plugins/save-calendar/csv-format.c
+++ b/plugins/save-calendar/csv-format.c
@@ -303,7 +303,7 @@ userstring_to_systemstring (const gchar *userstring)
 static void
 do_save_calendar_csv (FormatHandler *handler,
                       ESourceSelector *selector,
-                      ECalClientSourceType type,
+                     EClientCache *client_cache,
                       gchar *dest_uri)
 {
 
@@ -331,8 +331,8 @@ do_save_calendar_csv (FormatHandler *handler,
 
        /* open source client */
        primary_source = e_source_selector_ref_primary_selection (selector);
-       source_client = e_cal_client_connect_sync (
-               primary_source, type, NULL, &error);
+       source_client = e_client_cache_get_client_sync (client_cache,
+               primary_source, e_source_selector_get_extension_name (selector), NULL, &error);
        g_object_unref (primary_source);
 
        /* Sanity check. */
diff --git a/plugins/save-calendar/format-handler.h b/plugins/save-calendar/format-handler.h
index 88946e8..dd5ec64 100644
--- a/plugins/save-calendar/format-handler.h
+++ b/plugins/save-calendar/format-handler.h
@@ -37,7 +37,7 @@ struct _FormatHandler
 
        void    (*save)         (FormatHandler *handler,
                                 ESourceSelector *selector,
-                                ECalClientSourceType type,
+                                EClientCache *client_cache,
                                 gchar *dest_uri);
 };
 
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index 617405f..fb79479 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -89,7 +89,7 @@ append_tz_to_comp (gpointer key,
 static void
 do_save_calendar_ical (FormatHandler *handler,
                        ESourceSelector *selector,
-                       ECalClientSourceType type,
+                      EClientCache *client_cache,
                        gchar *dest_uri)
 {
        ESource *primary_source;
@@ -103,8 +103,8 @@ do_save_calendar_ical (FormatHandler *handler,
 
        /* open source client */
        primary_source = e_source_selector_ref_primary_selection (selector);
-       source_client = e_cal_client_connect_sync (
-               primary_source, type, NULL, &error);
+       source_client = e_client_cache_get_client_sync (client_cache,
+               primary_source, e_source_selector_get_extension_name (selector), NULL, &error);
        g_object_unref (primary_source);
 
        /* Sanity check. */
diff --git a/plugins/save-calendar/rdf-format.c b/plugins/save-calendar/rdf-format.c
index c967b9c..947c4ff 100644
--- a/plugins/save-calendar/rdf-format.c
+++ b/plugins/save-calendar/rdf-format.c
@@ -173,7 +173,7 @@ add_string_to_rdf (xmlNodePtr node,
 static void
 do_save_calendar_rdf (FormatHandler *handler,
                       ESourceSelector *selector,
-                      ECalClientSourceType type,
+                     EClientCache *client_cache,
                       gchar *dest_uri)
 {
 
@@ -198,8 +198,8 @@ do_save_calendar_rdf (FormatHandler *handler,
 
        /* open source client */
        primary_source = e_source_selector_ref_primary_selection (selector);
-       source_client = e_cal_client_connect_sync (
-               primary_source, type, NULL, &error);
+       source_client = e_client_cache_get_client_sync (client_cache,
+               primary_source, e_source_selector_get_extension_name (selector), NULL, &error);
        g_object_unref (primary_source);
 
        /* Sanity check. */
diff --git a/plugins/save-calendar/save-calendar.c b/plugins/save-calendar/save-calendar.c
index c5d373e..723a1c2 100644
--- a/plugins/save-calendar/save-calendar.c
+++ b/plugins/save-calendar/save-calendar.c
@@ -110,7 +110,7 @@ format_handlers_foreach_free (gpointer data)
 
 static void
 ask_destination_and_save (ESourceSelector *selector,
-                          ECalClientSourceType type)
+                         EClientCache *client_cache)
 {
        FormatHandler *handler = NULL;
 
@@ -219,7 +219,7 @@ ask_destination_and_save (ESourceSelector *selector,
                                dest_uri = temp;
                        }
 
-                       handler->save (handler, selector, type, dest_uri);
+                       handler->save (handler, selector, client_cache, dest_uri);
                } else {
                        g_warn_if_reached ();
                }
@@ -291,17 +291,20 @@ open_for_writing (GtkWindow *parent,
 }
 
 static void
-save_general (EShellView *shell_view,
-              ECalClientSourceType type)
+save_general (EShellView *shell_view)
 {
        EShellSidebar *shell_sidebar;
+       EShellBackend *shell_backend;
+       EShell *shell;
        ESourceSelector *selector = NULL;
 
+       shell_backend = e_shell_view_get_shell_backend (shell_view);
        shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+       shell = e_shell_backend_get_shell (shell_backend);
        g_object_get (shell_sidebar, "selector", &selector, NULL);
        g_return_if_fail (selector != NULL);
 
-       ask_destination_and_save (selector, type);
+       ask_destination_and_save (selector, e_shell_get_client_cache (shell));
 
        g_object_unref (selector);
 }
@@ -310,21 +313,21 @@ static void
 action_calendar_save_as_cb (GtkAction *action,
                             EShellView *shell_view)
 {
-       save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_EVENTS);
+       save_general (shell_view);
 }
 
 static void
 action_memo_list_save_as_cb (GtkAction *action,
                              EShellView *shell_view)
 {
-       save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_MEMOS);
+       save_general (shell_view);
 }
 
 static void
 action_task_list_save_as_cb (GtkAction *action,
                              EShellView *shell_view)
 {
-       save_general (shell_view, E_CAL_CLIENT_SOURCE_TYPE_TASKS);
+       save_general (shell_view);
 }
 
 gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]