aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-04-13 02:21:48 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-04-13 06:35:11 +0800
commit1141e231478410ecd83c78507612e57f58f2ccf1 (patch)
treefe34c86bab52d1cbf624cde02464c12e06b18742
parentebef28545a2a74d675142afd6921f5e0e65b4b76 (diff)
downloadgsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar
gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.gz
gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.bz2
gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.lz
gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.xz
gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.tar.zst
gsoc2013-evolution-1141e231478410ecd83c78507612e57f58f2ccf1.zip
Add e_cal_model_list_clients().
Replaces e_cal_model_get_client_list(). Does the same thing, except the returned ECalClient instances are referenced for thread-safety.
-rw-r--r--calendar/gui/e-cal-model.c9
-rw-r--r--calendar/gui/e-cal-model.h2
-rw-r--r--calendar/gui/e-task-table.c4
-rw-r--r--calendar/gui/gnome-cal.c26
-rw-r--r--modules/calendar/e-cal-shell-view-private.c15
-rw-r--r--modules/calendar/e-task-shell-view-private.c10
6 files changed, 35 insertions, 31 deletions
diff --git a/calendar/gui/e-cal-model.c b/calendar/gui/e-cal-model.c
index 1ed0720bec..d990bdbaf0 100644
--- a/calendar/gui/e-cal-model.c
+++ b/calendar/gui/e-cal-model.c
@@ -2621,7 +2621,7 @@ e_cal_model_set_default_client (ECalModel *model,
}
GList *
-e_cal_model_get_client_list (ECalModel *model)
+e_cal_model_list_clients (ECalModel *model)
{
GQueue results = G_QUEUE_INIT;
GList *list, *link;
@@ -2635,14 +2635,17 @@ e_cal_model_get_client_list (ECalModel *model)
for (link = list; link != NULL; link = g_list_next (link)) {
ClientData *client_data = link->data;
+ ECalClient *client;
+
+ client = client_data->client;
/* Exclude the default client if we're not querying it. */
- if (client_data->client == default_client) {
+ if (client == default_client) {
if (!client_data->do_query)
continue;
}
- g_queue_push_tail (&results, client_data->client);
+ g_queue_push_tail (&results, g_object_ref (client));
}
g_list_free_full (list, (GDestroyNotify) client_data_unref);
diff --git a/calendar/gui/e-cal-model.h b/calendar/gui/e-cal-model.h
index f9eebad035..3827f25b18 100644
--- a/calendar/gui/e-cal-model.h
+++ b/calendar/gui/e-cal-model.h
@@ -253,7 +253,7 @@ void e_cal_model_set_work_day_start_minute
ECalClient * e_cal_model_get_default_client (ECalModel *model);
void e_cal_model_set_default_client (ECalModel *model,
ECalClient *client);
-GList * e_cal_model_get_client_list (ECalModel *model);
+GList * e_cal_model_list_clients (ECalModel *model);
ECalClient * e_cal_model_get_client_for_source
(ECalModel *model,
ESource *source);
diff --git a/calendar/gui/e-task-table.c b/calendar/gui/e-task-table.c
index e014fe117b..6f7fb83317 100644
--- a/calendar/gui/e-task-table.c
+++ b/calendar/gui/e-task-table.c
@@ -1873,7 +1873,7 @@ e_task_table_process_completed_tasks (ETaskTable *task_table,
if (!(hide_sexp && show_sexp))
show_sexp = g_strdup ("(is-completed?)");
- client_list = e_cal_model_get_client_list (model);
+ client_list = e_cal_model_list_clients (model);
/* Delete rows from model */
if (hide_sexp) {
@@ -1889,7 +1889,7 @@ e_task_table_process_completed_tasks (ETaskTable *task_table,
show_completed_rows_ready, model);
}
- g_list_free (client_list);
+ g_list_free_full (client_list, (GDestroyNotify) g_object_unref);
g_free (hide_sexp);
g_free (show_sexp);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index c464eef119..8716f5f927 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -1177,7 +1177,7 @@ update_query_async (struct _date_query_msg *msg)
GnomeCalendarPrivate *priv;
ECalClientView *new_view;
gchar *real_sexp;
- GList *list, *iter;
+ GList *list, *link;
priv = gcal->priv;
@@ -1191,12 +1191,11 @@ update_query_async (struct _date_query_msg *msg)
return; /* No time range is set, so don't start a query */
}
- list = e_cal_model_get_client_list (priv->model);
- g_list_foreach (list, (GFunc) g_object_ref, NULL);
+ list = e_cal_model_list_clients (priv->model);
/* create queries for each loaded client */
- for (iter = list; iter != NULL; iter = iter->next) {
- ECalClient *client = E_CAL_CLIENT (iter->data);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ECalClient *client = E_CAL_CLIENT (link->data);
GError *error = NULL;
new_view = NULL;
@@ -1232,8 +1231,7 @@ update_query_async (struct _date_query_msg *msg)
g_mutex_unlock (&priv->dn_query_lock);
}
- g_list_foreach (list, (GFunc) g_object_unref, NULL);
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
/* free memory */
g_free (real_sexp);
@@ -2332,11 +2330,14 @@ void
gnome_calendar_purge (GnomeCalendar *gcal,
time_t older_than)
{
+ ECalModel *model;
gchar *sexp, *start, *end;
- GList *clients, *l;
+ GList *list, *link;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+ model = gnome_calendar_get_model (gcal);
+
start = isodate_from_time_t (0);
end = isodate_from_time_t (older_than);
sexp = g_strdup_printf (
@@ -2346,9 +2347,10 @@ gnome_calendar_purge (GnomeCalendar *gcal,
gcal_update_status_message (gcal, _("Purging"), -1);
/* FIXME Confirm expunge */
- clients = e_cal_model_get_client_list (gnome_calendar_get_model (gcal));
- for (l = clients; l != NULL; l = l->next) {
- ECalClient *client = l->data;
+ list = e_cal_model_list_clients (model);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ECalClient *client = E_CAL_CLIENT (link->data);
GSList *objects, *m;
GError *error = NULL;
@@ -2424,7 +2426,7 @@ gnome_calendar_purge (GnomeCalendar *gcal,
g_slist_free (objects);
}
- g_list_free (clients);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
gcal_update_status_message (gcal, NULL, -1);
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 68b26942ce..8cafe21c49 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -1432,7 +1432,7 @@ static void
cal_iterate_searching (ECalShellView *cal_shell_view)
{
ECalShellViewPrivate *priv;
- GList *clients, *iter;
+ GList *list, *link;
ECalModel *model;
time_t new_time, range1, range2;
icaltimezone *timezone;
@@ -1517,9 +1517,9 @@ cal_iterate_searching (ECalShellView *cal_shell_view)
model = gnome_calendar_get_model (
e_cal_shell_content_get_calendar (
cal_shell_view->priv->cal_shell_content));
- clients = e_cal_model_get_client_list (model);
+ list = e_cal_model_list_clients (model);
- if (!clients) {
+ if (list == NULL) {
e_activity_set_state (
priv->searching_activity, E_ACTIVITY_COMPLETED);
g_object_unref (priv->searching_activity);
@@ -1560,19 +1560,18 @@ cal_iterate_searching (ECalShellView *cal_shell_view)
g_free (end);
cancellable = e_activity_get_cancellable (priv->searching_activity);
- g_list_foreach (clients, (GFunc) g_object_ref, NULL);
- priv->search_pending_count = g_list_length (clients);
+ priv->search_pending_count = g_list_length (list);
priv->search_time = new_time;
- for (iter = clients; iter; iter = iter->next) {
- ECalClient *client = iter->data;
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ECalClient *client = E_CAL_CLIENT (link);
e_cal_client_get_object_list (
client, sexp, cancellable,
cal_search_get_object_list_cb, cal_shell_view);
}
- g_list_free_full (clients, g_object_unref);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
g_free (sexp);
}
diff --git a/modules/calendar/e-task-shell-view-private.c b/modules/calendar/e-task-shell-view-private.c
index b204711977..bc538c6e75 100644
--- a/modules/calendar/e-task-shell-view-private.c
+++ b/modules/calendar/e-task-shell-view-private.c
@@ -544,7 +544,7 @@ e_task_shell_view_delete_completed (ETaskShellView *task_shell_view)
{
ETaskShellContent *task_shell_content;
ECalModel *model;
- GList *list, *iter;
+ GList *list, *link;
const gchar *sexp;
g_return_if_fail (E_IS_TASK_SHELL_VIEW (task_shell_view));
@@ -557,10 +557,10 @@ e_task_shell_view_delete_completed (ETaskShellView *task_shell_view)
e_task_shell_view_set_status_message (
task_shell_view, _("Expunging"), -1.0);
- list = e_cal_model_get_client_list (model);
+ list = e_cal_model_list_clients (model);
- for (iter = list; iter != NULL; iter = iter->next) {
- ECalClient *client = E_CAL_CLIENT (iter->data);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ECalClient *client = E_CAL_CLIENT (link->data);
GSList *objects, *obj;
GError *error = NULL;
@@ -599,7 +599,7 @@ e_task_shell_view_delete_completed (ETaskShellView *task_shell_view)
e_cal_client_free_icalcomp_slist (objects);
}
- g_list_free (list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
e_task_shell_view_set_status_message (task_shell_view, NULL, -1.0);
}