[evolution/gnome-3-8] Remove e_cal_model_get_client_for_source().



commit 6172096d30099361bd5e94891ac84f3155525584
Author: Matthew Barnes <mbarnes redhat com>
Date:   Fri Apr 12 14:54:15 2013 -0400

    Remove e_cal_model_get_client_for_source().
    
    Was not thread-safe because it did not reference the return value.
    
    The function was only used to implement the Refresh action on the
    sidebar menu.  e_client_selector_ref_cached_client() works better
    for this anyway.
    
    (cherry picked from commit 1df4952769b3211b90aecb3a359d8ae484fd1363)

 calendar/gui/e-cal-model.c                   |   36 --------------------------
 calendar/gui/e-cal-model.h                   |    3 --
 modules/calendar/e-cal-shell-view-actions.c  |   23 +++++++---------
 modules/calendar/e-memo-shell-view-actions.c |   23 +++++++---------
 modules/calendar/e-task-shell-view-actions.c |   23 +++++++---------
 5 files changed, 30 insertions(+), 78 deletions(-)
---
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 982337c..8c41055 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2351,42 +2351,6 @@ e_cal_model_list_clients (ECalModel *model)
        return g_queue_peek_head_link (&results);
 }
 
-/**
- * e_cal_model_get_client_for_source:
- * @model: an #ECalModel
- * @source: an #ESource
- */
-ECalClient *
-e_cal_model_get_client_for_source (ECalModel *model,
-                                   ESource *source)
-{
-       ECalClient *match = NULL;
-       GList *list, *link;
-
-       g_return_val_if_fail (E_IS_CAL_MODEL (model), NULL);
-       g_return_val_if_fail (E_IS_SOURCE (source), NULL);
-
-       list = cal_model_clients_list (model);
-
-       for (link = list; link != NULL; link = g_list_next (link)) {
-               ClientData *client_data = link->data;
-               ESource *client_source;
-               EClient *client;
-
-               client = E_CLIENT (client_data->client);
-               client_source = e_client_get_source (client);
-
-               if (e_source_equal (source, client_source)) {
-                       match = client_data->client;
-                       break;
-               }
-       }
-
-       g_list_free_full (list, (GDestroyNotify) client_data_unref);
-
-       return match;
-}
-
 static ECalModelComponent *
 search_by_id_and_client (ECalModelPrivate *priv,
                          ECalClient *client,
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index 58d1613..d3a4fcc 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -247,9 +247,6 @@ ECalClient *        e_cal_model_get_default_client  (ECalModel *model);
 void           e_cal_model_set_default_client  (ECalModel *model,
                                                 ECalClient *client);
 GList *                e_cal_model_list_clients        (ECalModel *model);
-ECalClient *   e_cal_model_get_client_for_source
-                                               (ECalModel *model,
-                                                ESource *source);
 void           e_cal_model_add_client          (ECalModel *model,
                                                 ECalClient *cal_client);
 void           e_cal_model_remove_client       (ECalModel *model,
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index f9fdf1c..9a54b06 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -371,32 +371,29 @@ static void
 action_calendar_refresh_cb (GtkAction *action,
                            ECalShellView *cal_shell_view)
 {
-       ECalShellContent *cal_shell_content;
        ECalShellSidebar *cal_shell_sidebar;
        ESourceSelector *selector;
-       ECalClient *client;
-       ECalModel *model;
+       EClient *client = NULL;
        ESource *source;
        GError *error = NULL;
 
-       cal_shell_content = cal_shell_view->priv->cal_shell_content;
        cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
-
-       model = e_cal_shell_content_get_model (cal_shell_content);
        selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
 
        source = e_source_selector_ref_primary_selection (selector);
-       g_return_if_fail (source != NULL);
 
-       client = e_cal_model_get_client_for_source (model, source);
-       if (client == NULL) {
+       if (source != NULL) {
+               client = e_client_selector_ref_cached_client (
+                       E_CLIENT_SELECTOR (selector), source);
                g_object_unref (source);
-               return;
        }
 
-       g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client)));
+       if (client == NULL)
+               return;
 
-       e_client_refresh_sync (E_CLIENT (client), NULL, &error);
+       g_return_if_fail (e_client_check_refresh_supported (client));
+
+       e_client_refresh_sync (client, NULL, &error);
 
        if (error != NULL) {
                g_warning (
@@ -406,7 +403,7 @@ action_calendar_refresh_cb (GtkAction *action,
                g_error_free (error);
        }
 
-       g_object_unref (source);
+       g_object_unref (client);
 }
 
 static void
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 0e0d28e..5e30e24 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -294,32 +294,29 @@ static void
 action_memo_list_refresh_cb (GtkAction *action,
                              EMemoShellView *memo_shell_view)
 {
-       EMemoShellContent *memo_shell_content;
        EMemoShellSidebar *memo_shell_sidebar;
        ESourceSelector *selector;
-       ECalClient *client;
-       ECalModel *model;
+       EClient *client = NULL;
        ESource *source;
        GError *error = NULL;
 
-       memo_shell_content = memo_shell_view->priv->memo_shell_content;
        memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
-
-       model = e_memo_shell_content_get_memo_model (memo_shell_content);
        selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
 
        source = e_source_selector_ref_primary_selection (selector);
-       g_return_if_fail (source != NULL);
 
-       client = e_cal_model_get_client_for_source (model, source);
-       if (client == NULL) {
+       if (source != NULL) {
+               client = e_client_selector_ref_cached_client (
+                       E_CLIENT_SELECTOR (selector), source);
                g_object_unref (source);
-               return;
        }
 
-       g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client)));
+       if (client == NULL)
+               return;
 
-       e_client_refresh_sync (E_CLIENT (client), NULL, &error);
+       g_return_if_fail (e_client_check_refresh_supported (client));
+
+       e_client_refresh_sync (client, NULL, &error);
 
        if (error != NULL) {
                g_warning (
@@ -329,7 +326,7 @@ action_memo_list_refresh_cb (GtkAction *action,
                g_error_free (error);
        }
 
-       g_object_unref (source);
+       g_object_unref (client);
 }
 
 static void
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 6709a6e..0c3ab2e 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -317,32 +317,29 @@ static void
 action_task_list_refresh_cb (GtkAction *action,
                              ETaskShellView *task_shell_view)
 {
-       ETaskShellContent *task_shell_content;
        ETaskShellSidebar *task_shell_sidebar;
        ESourceSelector *selector;
-       ECalClient *client;
-       ECalModel *model;
+       EClient *client = NULL;
        ESource *source;
        GError *error = NULL;
 
-       task_shell_content = task_shell_view->priv->task_shell_content;
        task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
-
-       model = e_task_shell_content_get_task_model (task_shell_content);
        selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
 
        source = e_source_selector_ref_primary_selection (selector);
-       g_return_if_fail (source != NULL);
 
-       client = e_cal_model_get_client_for_source (model, source);
-       if (client == NULL) {
+       if (source != NULL) {
+               client = e_client_selector_ref_cached_client (
+                       E_CLIENT_SELECTOR (selector), source);
                g_object_unref (source);
-               return;
        }
 
-       g_return_if_fail (e_client_check_refresh_supported (E_CLIENT (client)));
+       if (client == NULL)
+               return;
 
-       e_client_refresh_sync (E_CLIENT (client), NULL, &error);
+       g_return_if_fail (e_client_check_refresh_supported (client));
+
+       e_client_refresh_sync (client, NULL, &error);
 
        if (error != NULL) {
                g_warning (
@@ -352,7 +349,7 @@ action_task_list_refresh_cb (GtkAction *action,
                g_error_free (error);
        }
 
-       g_object_unref (source);
+       g_object_unref (client);
 }
 
 static void


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