[almanah] Bug 683570 - Fails to build against evolution-data-server 3.5.91
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [almanah] Bug 683570 - Fails to build against evolution-data-server 3.5.91
- Date: Mon, 10 Sep 2012 06:20:03 +0000 (UTC)
commit ed8c002455c2495e0aed74517893d24b505c8144
Author: Milan Crha <mcrha redhat com>
Date: Mon Sep 10 08:19:17 2012 +0200
Bug 683570 - Fails to build against evolution-data-server 3.5.91
configure.ac | 4 +-
src/event-factories/calendar-client.c | 241 ++++++++++------------
src/event-factories/calendar-client.h | 2 +-
src/event-factories/calendar-sources.c | 341 ++++++++-----------------------
src/events/calendar-task.c | 2 +-
5 files changed, 201 insertions(+), 389 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8718d6c..b4c35d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -83,13 +83,13 @@ AC_SUBST(STANDARD_CFLAGS)
AC_SUBST(STANDARD_LIBS)
dnl Evolution
-PKG_CHECK_MODULES(EVO, libecal-1.2 libedataserver-1.2 libedataserverui-3.0 gconf-2.0, have_evo=yes, have_evo=no)
+PKG_CHECK_MODULES(EVO, libecal-1.2 libedataserver-1.2 libedataserverui-3.0, have_evo=yes, have_evo=no)
if test "x$have_evo" = "xyes"; then
- AM_GCONF_SOURCE_2
AC_DEFINE(HAVE_EVO, 1, [Defined if libecal-1.2 is installed])
fi
AM_CONDITIONAL([HAVE_EVO], [test x$have_evo = xyes])
+EVO_CFLAGS="$EVO_CFLAGS -DE_BOOK_DISABLE_DEPRECATED -DE_CAL_DISABLE_DEPRECATED"
AC_SUBST(EVO_CFLAGS)
AC_SUBST(EVO_LIBS)
diff --git a/src/event-factories/calendar-client.c b/src/event-factories/calendar-client.c
index b506114..ea21bd9 100644
--- a/src/event-factories/calendar-client.c
+++ b/src/event-factories/calendar-client.c
@@ -30,18 +30,13 @@
#include <libintl.h>
#include <string.h>
#define HANDLE_LIBICAL_MEMORY
-#include <libecal/e-cal.h>
-#include <libecal/e-cal-time-util.h>
-#include <libecal/e-cal-recur.h>
+#include <libecal/libecal.h>
#include "calendar-sources.h"
#undef CALENDAR_ENABLE_DEBUG
#include "calendar-debug.h"
-#define CALENDAR_CONFIG_PREFIX "/apps/evolution/calendar"
-#define CALENDAR_CONFIG_TIMEZONE CALENDAR_CONFIG_PREFIX "/display/timezone"
-
#ifndef _
#define _(x) gettext(x)
#endif
@@ -57,14 +52,14 @@ typedef struct _CalendarClientSource CalendarClientSource;
struct _CalendarClientQuery
{
- ECalView *view;
+ ECalClientView *view;
GHashTable *events;
};
struct _CalendarClientSource
{
CalendarClient *client;
- ECal *source;
+ ECalClient *cal_client;
CalendarClientQuery completed_query;
CalendarClientQuery in_progress_query;
@@ -85,7 +80,7 @@ struct _CalendarClientPrivate
icaltimezone *zone;
guint zone_listener;
- GConfClient *gconf_client;
+ GSettings *settings;
guint day;
guint month;
@@ -236,24 +231,25 @@ calendar_client_class_init (CalendarClientClass *klass)
/* The current timezone, e.g. "Europe/London". It may be NULL, in which case
you should assume UTC. */
static gchar *
-calendar_client_config_get_timezone (GConfClient *gconf_client)
+calendar_client_config_get_timezone (GSettings *settings)
{
char *location;
- location = gconf_client_get_string (gconf_client,
- CALENDAR_CONFIG_TIMEZONE,
- NULL);
+ if (g_settings_get_boolean (settings, "use-system-timezone"))
+ location = e_cal_util_get_system_timezone_location ();
+ else
+ location = g_settings_get_string (settings, "timezone");
return location;
}
static icaltimezone *
-calendar_client_config_get_icaltimezone (GConfClient *gconf_client)
+calendar_client_config_get_icaltimezone (GSettings *settings)
{
char *location;
icaltimezone *zone = NULL;
- location = calendar_client_config_get_timezone (gconf_client);
+ location = calendar_client_config_get_timezone (settings);
if (!location)
return icaltimezone_get_utc_timezone ();
@@ -269,47 +265,52 @@ calendar_client_set_timezone (CalendarClient *client)
GSList *l;
GSList *esources;
- client->priv->zone = calendar_client_config_get_icaltimezone (client->priv->gconf_client);
+ client->priv->zone = calendar_client_config_get_icaltimezone (client->priv->settings);
esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources);
for (l = esources; l; l = l->next) {
- ECal *source = l->data;
+ ECalClient *source = l->data;
- e_cal_set_default_timezone (source, client->priv->zone, NULL);
+ e_cal_client_set_default_timezone (source, client->priv->zone);
}
}
static void
-calendar_client_timezone_changed_cb (GConfClient *gconf_client,
- guint id,
- GConfEntry *entry,
+calendar_client_timezone_changed_cb (GSettings *settings,
+ const gchar *key,
CalendarClient *client)
{
- calendar_client_set_timezone (client);
+ if (g_strcmp0 (key, "timezone") == 0 ||
+ g_strcmp0 (key, "use-system-timezone") == 0)
+ calendar_client_set_timezone (client);
}
static void
-cal_opened_cb (ECal *ecal,
- ECalendarStatus status,
- CalendarClientSource *cl_source)
+cal_opened_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
- ECalSourceType s_type;
+ EClient *ecal = E_CLIENT (source_object);
+ CalendarClientSource *cl_source = user_data;
+ ECalClientSourceType s_type;
CalendarClient *client = cl_source->client;
+ GError *error = NULL;
- s_type = e_cal_get_source_type (ecal);
+ e_client_open_finish (ecal, result, &error);
- if (status == E_CALENDAR_STATUS_BUSY &&
- e_cal_get_load_state (ecal) == E_CAL_LOAD_NOT_LOADED)
+ s_type = e_cal_client_get_source_type (E_CAL_CLIENT (ecal));
+
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_BUSY) &&
+ !e_client_is_opened (ecal))
{
- e_cal_open_async (ecal, FALSE);
+ g_clear_error (&error);
+ e_client_open (ecal, TRUE, NULL, cal_opened_cb, cl_source);
return;
}
-
- g_signal_handlers_disconnect_by_func (ecal, cal_opened_cb, cl_source);
- if (status != E_CALENDAR_STATUS_OK)
+ if (error)
{
- if (s_type == E_CAL_SOURCE_TYPE_EVENT)
+ if (s_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
client->priv->appointment_sources = g_slist_remove (client->priv->appointment_sources,
cl_source);
else
@@ -319,10 +320,11 @@ cal_opened_cb (ECal *ecal,
calendar_client_source_finalize (cl_source);
g_free (cl_source);
+ g_clear_error (&error);
return;
}
- if (s_type == E_CAL_SOURCE_TYPE_EVENT)
+ if (s_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS)
calendar_client_update_appointments (client);
else
calendar_client_update_tasks (client);
@@ -349,17 +351,15 @@ load_calendars (CalendarClient *client,
for (l = clients; l != NULL; l = l->next)
{
- ECal *ecal;
+ EClient *ecal;
CalendarClientSource *cl_source = l->data;
- ecal = cl_source->source;
+ ecal = E_CLIENT (cl_source->cal_client);
- if (e_cal_get_load_state (ecal) == E_CAL_LOAD_LOADED)
+ if (e_client_is_opened (ecal))
continue;
- g_signal_connect (G_OBJECT (ecal), "cal_opened",
- G_CALLBACK (cal_opened_cb), cl_source);
- e_cal_open_async (ecal, TRUE);
+ e_client_open (ecal, TRUE, NULL, cal_opened_cb, cl_source);
}
}
@@ -371,7 +371,7 @@ calendar_client_init (CalendarClient *client)
client->priv = CALENDAR_CLIENT_GET_PRIVATE (client);
client->priv->calendar_sources = calendar_sources_get ();
- client->priv->gconf_client = gconf_client_get_default ();
+ client->priv->settings = g_settings_new ("org.gnome.evolution.calendar");
esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources);
client->priv->appointment_sources =
@@ -395,15 +395,9 @@ calendar_client_init (CalendarClient *client)
G_CALLBACK (calendar_client_task_sources_changed),
client);
- gconf_client_add_dir (client->priv->gconf_client,
- CALENDAR_CONFIG_PREFIX,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
-
- client->priv->zone_listener = gconf_client_notify_add (client->priv->gconf_client,
- CALENDAR_CONFIG_TIMEZONE,
- (GConfClientNotifyFunc) calendar_client_timezone_changed_cb,
- client, NULL, NULL);
+ client->priv->zone_listener = g_signal_connect (client->priv->settings, "changed",
+ G_CALLBACK (calendar_client_timezone_changed_cb),
+ client);
client->priv->day = G_MAXUINT;
client->priv->month = G_MAXUINT;
@@ -418,18 +412,14 @@ calendar_client_finalize (GObject *object)
if (client->priv->zone_listener)
{
- gconf_client_notify_remove (client->priv->gconf_client,
+ g_signal_handler_disconnect (client->priv->settings,
client->priv->zone_listener);
client->priv->zone_listener = 0;
}
- gconf_client_remove_dir (client->priv->gconf_client,
- CALENDAR_CONFIG_PREFIX,
- NULL);
-
- if (client->priv->gconf_client)
- g_object_unref (client->priv->gconf_client);
- client->priv->gconf_client = NULL;
+ if (client->priv->settings)
+ g_object_unref (client->priv->settings);
+ client->priv->settings = NULL;
for (l = client->priv->appointment_sources; l; l = l->next)
{
@@ -735,40 +725,29 @@ get_ical_priority (icalcomponent *ical)
}
static char *
-get_source_color (ECal *esource)
+color_from_extension (ESourceSelectable *selectable)
{
- ESource *source;
-
- g_return_val_if_fail (E_IS_CAL (esource), NULL);
+ g_return_val_if_fail (selectable != NULL, NULL);
- source = e_cal_get_source (esource);
-
- return g_strdup (e_source_peek_color_spec (source));
+ return e_source_selectable_dup_color (selectable);
}
-static gchar *
-get_source_uri (ECal *esource)
+static char *
+get_source_color (ECalClient *esource)
{
- ESource *source;
- gchar *string;
- gchar **list;
+ ESource *source;
- g_return_val_if_fail (E_IS_CAL (esource), NULL);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (esource), NULL);
- source = e_cal_get_source (esource);
- string = g_strdup (e_source_get_uri (source));
- if (string) {
- list = g_strsplit (string, ":", 2);
- g_free (string);
+ source = e_client_get_source (E_CLIENT (esource));
- if (list[0]) {
- string = g_strdup (list[0]);
- g_strfreev (list);
- return string;
- }
- g_strfreev (list);
- }
- return NULL;
+ if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR))
+ return color_from_extension (e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR));
+ if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST))
+ return color_from_extension (e_source_get_extension (source, E_SOURCE_EXTENSION_MEMO_LIST));
+ if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST))
+ return color_from_extension (e_source_get_extension (source, E_SOURCE_EXTENSION_TASK_LIST));
+ return NULL;
}
static inline gboolean
@@ -792,7 +771,7 @@ calendar_appointment_equal (CalendarAppointment *a,
return
g_strcmp0 (a->uid, b->uid) == 0 &&
- g_strcmp0 (a->uri, b->uri) == 0 &&
+ g_strcmp0 (a->source_uid, b->source_uid) == 0 &&
g_strcmp0 (a->summary, b->summary) == 0 &&
g_strcmp0 (a->description, b->description) == 0 &&
g_strcmp0 (a->color_string, b->color_string) == 0 &&
@@ -824,7 +803,7 @@ calendar_appointment_copy (CalendarAppointment *appointment,
}
appointment_copy->uid = g_strdup (appointment->uid);
- appointment_copy->uri = g_strdup (appointment->uri);
+ appointment_copy->source_uid = g_strdup (appointment->source_uid);
appointment_copy->summary = g_strdup (appointment->summary);
appointment_copy->description = g_strdup (appointment->description);
appointment_copy->color_string = g_strdup (appointment->color_string);
@@ -849,8 +828,8 @@ calendar_appointment_finalize (CalendarAppointment *appointment)
g_free (appointment->rid);
appointment->rid = NULL;
- g_free (appointment->uri);
- appointment->uri = NULL;
+ g_free (appointment->source_uid);
+ appointment->source_uid = NULL;
g_free (appointment->summary);
appointment->summary = NULL;
@@ -873,10 +852,10 @@ calendar_appointment_init (CalendarAppointment *appointment,
{
appointment->uid = get_ical_uid (ical);
appointment->rid = get_ical_rid (ical);
- appointment->uri = get_source_uri (source->source);
+ appointment->source_uid = e_source_dup_uid (e_client_get_source (E_CLIENT (source->cal_client)));
appointment->summary = get_ical_summary (ical);
appointment->description = get_ical_description (ical);
- appointment->color_string = get_source_color (source->source);
+ appointment->color_string = get_source_color (source->cal_client);
appointment->start_time = get_ical_start_time (ical, default_zone);
appointment->end_time = get_ical_end_time (ical, default_zone);
appointment->is_all_day = get_ical_is_all_day (ical,
@@ -886,14 +865,15 @@ calendar_appointment_init (CalendarAppointment *appointment,
static icaltimezone *
resolve_timezone_id (const char *tzid,
- ECal *source)
+ gpointer user_data)
{
icaltimezone *retval;
+ ECalClient *source = user_data;
retval = icaltimezone_get_builtin_timezone_from_tzid (tzid);
if (!retval)
{
- e_cal_get_timezone (source, tzid, &retval, NULL);
+ e_cal_client_get_timezone_sync (source, tzid, &retval, NULL, NULL);
}
return retval;
@@ -920,7 +900,7 @@ calendar_appointment_collect_occurrence (ECalComponent *component,
static void
calendar_appointment_generate_ocurrences (CalendarAppointment *appointment,
icalcomponent *ical,
- ECal *source,
+ ECalClient *source,
time_t start,
time_t end,
icaltimezone *default_zone)
@@ -938,7 +918,7 @@ calendar_appointment_generate_ocurrences (CalendarAppointment *appointment,
end,
calendar_appointment_collect_occurrence,
&appointment->occurrences,
- (ECalRecurResolveTimezoneFn) resolve_timezone_id,
+ resolve_timezone_id,
source,
default_zone);
@@ -1008,7 +988,7 @@ calendar_task_init (CalendarTask *task,
task->uid = get_ical_uid (ical);
task->summary = get_ical_summary (ical);
task->description = get_ical_description (ical);
- task->color_string = get_source_color (source->source);
+ task->color_string = get_source_color (source->cal_client);
task->start_time = get_ical_start_time (ical, default_zone);
task->due_time = get_ical_due_time (ical, default_zone);
task->percent_complete = get_ical_percent_complete (ical);
@@ -1180,7 +1160,7 @@ calendar_event_equal (CalendarEvent *a,
static void
calendar_event_generate_ocurrences (CalendarEvent *event,
icalcomponent *ical,
- ECal *source,
+ ECalClient *source,
time_t start,
time_t end,
icaltimezone *default_zone)
@@ -1286,7 +1266,7 @@ calendar_event_debug_dump (CalendarEvent *event)
static inline CalendarClientQuery *
goddamn_this_is_crack (CalendarClientSource *source,
- ECalView *view,
+ ECalClientView *view,
gboolean *emit_signal)
{
g_assert (view != NULL);
@@ -1311,19 +1291,19 @@ goddamn_this_is_crack (CalendarClientSource *source,
static void
calendar_client_handle_query_completed (CalendarClientSource *source,
- ECalendarStatus status,
- ECalView *view)
+ const GError *error,
+ ECalClientView *view)
{
CalendarClientQuery *query;
query = goddamn_this_is_crack (source, view, NULL);
- dprintf ("Query %p completed: %s\n", query, e_cal_get_error_message (status));
+ dprintf ("Query %p completed: %s\n", query, error ? error->message : "Success");
- if (status != E_CALENDAR_STATUS_OK)
+ if (error)
{
g_warning ("Calendar query failed: %s\n",
- e_cal_get_error_message (status));
+ error->message);
calendar_client_stop_query (source->client, source, query);
return;
}
@@ -1345,14 +1325,14 @@ calendar_client_handle_query_completed (CalendarClientSource *source,
static void
calendar_client_handle_query_result (CalendarClientSource *source,
- GList *objects,
- ECalView *view)
+ const GSList *objects,
+ ECalClientView *view)
{
CalendarClientQuery *query;
CalendarClient *client;
gboolean emit_signal;
gboolean events_changed;
- GList *l;
+ const GSList *l;
time_t month_begin;
time_t month_end;
@@ -1385,7 +1365,7 @@ calendar_client_handle_query_result (CalendarClientSource *source,
calendar_event_generate_ocurrences (event,
ical,
- source->source,
+ source->cal_client,
month_begin,
month_end,
client->priv->zone);
@@ -1440,13 +1420,13 @@ check_object_remove (gpointer key,
static void
calendar_client_handle_objects_removed (CalendarClientSource *source,
- GList *ids,
- ECalView *view)
+ const GSList *ids,
+ ECalClientView *view)
{
CalendarClientQuery *query;
gboolean emit_signal;
gboolean events_changed;
- GList *l;
+ const GSList *l;
query = goddamn_this_is_crack (source, view, &emit_signal);
@@ -1529,10 +1509,10 @@ calendar_client_start_query (CalendarClient *client,
CalendarClientSource *source,
const char *query)
{
- ECalView *view = NULL;
+ ECalClientView *view = NULL;
GError *error = NULL;
- if (!e_cal_get_query (source->source, query, &view, &error))
+ if (!e_cal_client_get_view_sync (source->cal_client, query, &view, NULL, &error))
{
g_warning ("Error preparing the query: '%s': %s\n",
query, error->message);
@@ -1564,11 +1544,11 @@ calendar_client_start_query (CalendarClient *client,
g_signal_connect_swapped (view, "objects-removed",
G_CALLBACK (calendar_client_handle_objects_removed),
source);
- g_signal_connect_swapped (view, "view-done",
+ g_signal_connect_swapped (view, "complete",
G_CALLBACK (calendar_client_handle_query_completed),
source);
- e_cal_view_start (view);
+ e_cal_client_view_start (view, NULL);
}
static void
@@ -1599,7 +1579,7 @@ calendar_client_update_appointments (CalendarClient *client)
{
CalendarClientSource *cs = l->data;
- if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED)
+ if (!e_client_is_opened (E_CLIENT (cs->cal_client)))
continue;
calendar_client_start_query (client, cs, query);
@@ -1666,7 +1646,7 @@ calendar_client_update_tasks (CalendarClient *client)
{
CalendarClientSource *cs = l->data;
- if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED)
+ if (!e_client_is_opened (E_CLIENT (cs->cal_client)))
continue;
calendar_client_start_query (client, cs, query);
@@ -1684,12 +1664,9 @@ calendar_client_source_finalize (CalendarClientSource *source)
{
source->client = NULL;
- if (source->source) {
- g_signal_handlers_disconnect_by_func (source->source,
- cal_opened_cb, source);
- g_object_unref (source->source);
- }
- source->source = NULL;
+ if (source->cal_client)
+ g_object_unref (source->cal_client);
+ source->cal_client = NULL;
calendar_client_query_finalize (&source->completed_query);
calendar_client_query_finalize (&source->in_progress_query);
@@ -1702,7 +1679,7 @@ static int
compare_calendar_sources (CalendarClientSource *s1,
CalendarClientSource *s2)
{
- return (s1->source == s2->source) ? 0 : 1;
+ return (s1->cal_client == s2->cal_client) ? 0 : 1;
}
static GSList *
@@ -1720,12 +1697,12 @@ calendar_client_update_sources_list (CalendarClient *client,
CalendarClientSource dummy_source;
CalendarClientSource *new_source;
GSList *s;
- ECal *esource = l->data;
+ ECalClient *esource = l->data;
- dummy_source.source = esource;
+ dummy_source.cal_client = esource;
dprintf ("update_sources_list: adding client %s: ",
- e_source_peek_uid (e_cal_get_source (esource)));
+ e_source_get_uid (e_client_get_source (E_CLIENT (esource))));
if ((s = g_slist_find_custom (sources,
&dummy_source,
@@ -1740,7 +1717,7 @@ calendar_client_update_sources_list (CalendarClient *client,
dprintf ("added\n");
new_source = g_new0 (CalendarClientSource, 1);
new_source->client = client;
- new_source->source = g_object_ref (esource);
+ new_source->cal_client = g_object_ref (esource);
new_source->changed_signal_id = changed_signal_id;
}
@@ -1752,7 +1729,7 @@ calendar_client_update_sources_list (CalendarClient *client,
CalendarClientSource *source = l->data;
dprintf ("Removing client %s from list\n",
- e_source_peek_uid (e_cal_get_source (source->source)));
+ e_source_get_uid (e_client_get_source (E_CLIENT (source->cal_client))));
calendar_client_source_finalize (source);
g_free (source);
@@ -2109,7 +2086,7 @@ calendar_client_set_task_completed (CalendarClient *client,
guint percent_complete)
{
GSList *l;
- ECal *esource;
+ ECalClient *esource;
icalcomponent *ical;
icalproperty *prop;
icalproperty_status status;
@@ -2124,8 +2101,8 @@ calendar_client_set_task_completed (CalendarClient *client,
{
CalendarClientSource *source = l->data;
- esource = source->source;
- e_cal_get_object (esource, task_uid, NULL, &ical, NULL);
+ esource = source->cal_client;
+ e_cal_client_get_object_sync (esource, task_uid, NULL, &ical, NULL, NULL);
if (ical)
break;
}
@@ -2187,5 +2164,5 @@ calendar_client_set_task_completed (CalendarClient *client,
icalproperty_new_status (status));
}
- e_cal_modify_object (esource, ical, CALOBJ_MOD_ALL, NULL);
+ e_cal_client_modify_object_sync (esource, ical, CALOBJ_MOD_ALL, NULL, NULL);
}
diff --git a/src/event-factories/calendar-client.h b/src/event-factories/calendar-client.h
index 3ae3b2f..49f46cd 100644
--- a/src/event-factories/calendar-client.h
+++ b/src/event-factories/calendar-client.h
@@ -73,7 +73,7 @@ typedef struct
{
char *uid;
char *rid;
- char *uri;
+ char *source_uid;
char *summary;
char *description;
char *color_string;
diff --git a/src/event-factories/calendar-sources.c b/src/event-factories/calendar-sources.c
index fa1fcac..217327d 100644
--- a/src/event-factories/calendar-sources.c
+++ b/src/event-factories/calendar-sources.c
@@ -29,11 +29,10 @@
#include <libintl.h>
#include <string.h>
-#include <gconf/gconf-client.h>
#define HANDLE_LIBICAL_MEMORY
-#include <libecal/e-cal.h>
-#include <libedataserver/e-source-list.h>
-#include <libedataserverui/e-passwords.h>
+#include <libecal/libecal.h>
+#include <libedataserver/libedataserver.h>
+#include <libedataserverui/libedataserverui.h>
#undef CALENDAR_ENABLE_DEBUG
#include "calendar-debug.h"
@@ -48,28 +47,16 @@
#define CALENDAR_SOURCES_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CALENDAR_TYPE_SOURCES, CalendarSourcesPrivate))
-#define CALENDAR_SOURCES_EVO_DIR "/apps/evolution"
-#define CALENDAR_SOURCES_APPOINTMENT_SOURCES_KEY CALENDAR_SOURCES_EVO_DIR "/calendar/sources"
-#define CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_DIR CALENDAR_SOURCES_EVO_DIR "/calendar/display"
-#define CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_KEY CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_DIR "/selected_calendars"
-#define CALENDAR_SOURCES_TASK_SOURCES_KEY CALENDAR_SOURCES_EVO_DIR "/tasks/sources"
-#define CALENDAR_SOURCES_SELECTED_TASK_SOURCES_DIR CALENDAR_SOURCES_EVO_DIR "/calendar/tasks"
-#define CALENDAR_SOURCES_SELECTED_TASK_SOURCES_KEY CALENDAR_SOURCES_SELECTED_TASK_SOURCES_DIR "/selected_tasks"
-
typedef struct _CalendarSourceData CalendarSourceData;
struct _CalendarSourceData
{
- ECalSourceType source_type;
+ ECalClientSourceType client_type;
CalendarSources *sources;
guint changed_signal;
GSList *clients;
- GSList *selected_sources;
- ESourceList *esource_list;
-
- guint selected_sources_listener;
- char *selected_sources_dir;
+ ESourceSelector *esource_selector;
guint timeout_id;
@@ -81,16 +68,15 @@ struct _CalendarSourcesPrivate
CalendarSourceData appointment_sources;
CalendarSourceData task_sources;
- GConfClient *gconf_client;
+ ESourceRegistry *esource_registry;
};
static void calendar_sources_class_init (CalendarSourcesClass *klass);
static void calendar_sources_init (CalendarSources *sources);
static void calendar_sources_finalize (GObject *object);
-static void backend_died_cb (ECal *client, CalendarSourceData *source_data);
-static void calendar_sources_esource_list_changed (ESourceList *source_list,
- CalendarSourceData *source_data);
+static void backend_died_cb (ECalClient *client, CalendarSourceData *source_data);
+static void calendar_sources_selection_changed_cb (ESourceSelector *selector, CalendarSourceData *source_data);
enum
{
@@ -170,19 +156,26 @@ calendar_sources_class_init (CalendarSourcesClass *klass)
static void
calendar_sources_init (CalendarSources *sources)
{
+ GError *error = NULL;
+
sources->priv = CALENDAR_SOURCES_GET_PRIVATE (sources);
- sources->priv->appointment_sources.source_type = E_CAL_SOURCE_TYPE_EVENT;
+ sources->priv->appointment_sources.client_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
sources->priv->appointment_sources.sources = sources;
sources->priv->appointment_sources.changed_signal = signals [APPOINTMENT_SOURCES_CHANGED];
sources->priv->appointment_sources.timeout_id = 0;
- sources->priv->task_sources.source_type = E_CAL_SOURCE_TYPE_TODO;
+ sources->priv->task_sources.client_type = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
sources->priv->task_sources.sources = sources;
sources->priv->task_sources.changed_signal = signals [TASK_SOURCES_CHANGED];
sources->priv->task_sources.timeout_id = 0;
- sources->priv->gconf_client = gconf_client_get_default ();
+ sources->priv->esource_registry = e_source_registry_new_sync (NULL, &error);
+
+ if (error) {
+ g_warning ("%s: Failed to create ESourceRegistry: %s", G_STRFUNC, error->message);
+ g_clear_error (&error);
+ }
}
static void
@@ -193,23 +186,6 @@ calendar_sources_finalize_source_data (CalendarSources *sources,
{
GSList *l;
- if (source_data->selected_sources_dir)
- {
- gconf_client_remove_dir (sources->priv->gconf_client,
- source_data->selected_sources_dir,
- NULL);
-
- g_free (source_data->selected_sources_dir);
- source_data->selected_sources_dir = NULL;
- }
-
- if (source_data->selected_sources_listener)
- {
- gconf_client_notify_remove (sources->priv->gconf_client,
- source_data->selected_sources_listener);
- source_data->selected_sources_listener = 0;
- }
-
for (l = source_data->clients; l; l = l->next)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (l->data),
@@ -220,19 +196,14 @@ calendar_sources_finalize_source_data (CalendarSources *sources,
g_slist_free (source_data->clients);
source_data->clients = NULL;
- if (source_data->esource_list)
+ if (source_data->esource_selector)
{
- g_signal_handlers_disconnect_by_func (source_data->esource_list,
- G_CALLBACK (calendar_sources_esource_list_changed),
+ g_signal_handlers_disconnect_by_func (source_data->esource_selector,
+ G_CALLBACK (calendar_sources_selection_changed_cb),
source_data);
- g_object_unref (source_data->esource_list);
+ g_object_unref (source_data->esource_selector);
}
- source_data->esource_list = NULL;
-
- for (l = source_data->selected_sources; l; l = l->next)
- g_free (l->data);
- g_slist_free (source_data->selected_sources);
- source_data->selected_sources = NULL;
+ source_data->esource_selector = NULL;
if (source_data->timeout_id != 0)
{
@@ -252,9 +223,9 @@ calendar_sources_finalize (GObject *object)
calendar_sources_finalize_source_data (sources, &sources->priv->appointment_sources);
calendar_sources_finalize_source_data (sources, &sources->priv->task_sources);
- if (sources->priv->gconf_client)
- g_object_unref (sources->priv->gconf_client);
- sources->priv->gconf_client = NULL;
+ if (sources->priv->esource_registry)
+ g_object_unref (sources->priv->esource_registry);
+ sources->priv->esource_registry = NULL;
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -275,50 +246,14 @@ calendar_sources_get (void)
return calendar_sources_singleton;
}
-static gboolean
-is_source_selected (ESource *esource,
- GSList *selected_sources)
-{
- const char *uid;
- GSList *l;
-
- uid = e_source_peek_uid (esource);
-
- for (l = selected_sources; l; l = l->next)
- {
- const char *source = l->data;
-
- if (!strcmp (source, uid))
- return TRUE;
- }
-
- return FALSE;
-}
-
-static char *
-auth_func_cb (ECal *ecal,
- const char *prompt,
- const char *key,
- gpointer user_data)
-{
- ESource *source;
- const gchar *auth_domain;
- const gchar *component_name;
-
- source = e_cal_get_source (ecal);
- auth_domain = e_source_get_property (source, "auth-domain");
- component_name = auth_domain ? auth_domain : "Calendar";
-
- return e_passwords_get_password (component_name, key);
-}
-
/* The clients are just created here but not loaded */
-static ECal *
-get_ecal_from_source (ESource *esource,
- ECalSourceType source_type,
- GSList *existing_clients)
+static ECalClient *
+get_ecal_from_source (ESource *esource,
+ ECalClientSourceType client_type,
+ GSList *existing_clients)
{
- ECal *retval;
+ ECalClient *retval;
+ GError *error = NULL;
if (existing_clients)
{
@@ -326,9 +261,9 @@ get_ecal_from_source (ESource *esource,
for (l = existing_clients; l; l = l->next)
{
- ECal *client = E_CAL (l->data);
+ ECalClient *client = E_CAL_CLIENT (l->data);
- if (e_source_equal (esource, e_cal_get_source (client)))
+ if (g_strcmp0 (e_source_get_uid (esource), e_source_get_uid (e_client_get_source (E_CLIENT (client)))))
{
dprintf (" load_esource: found existing source ... returning that\n");
@@ -337,17 +272,16 @@ get_ecal_from_source (ESource *esource,
}
}
- retval = e_cal_new (esource, source_type);
+ retval = e_cal_client_new (esource, client_type, &error);
if (!retval)
{
- g_warning ("Could not load source '%s' from '%s'\n",
- e_source_peek_name (esource),
- e_source_peek_relative_uri (esource));
+ g_warning ("Could not load source '%s' from '%s': %s",
+ e_source_get_display_name (esource),
+ e_source_get_uid (esource),
+ error ? error->message : "Unknown error");
return NULL;
}
- e_cal_set_auth_func (retval, auth_func_cb, NULL);
-
return retval;
}
@@ -374,23 +308,6 @@ compare_ecal_lists (GSList *a,
}
static inline void
-debug_dump_selected_sources (GSList *selected_sources)
-{
-#ifdef CALENDAR_ENABLE_DEBUG
- GSList *l;
-
- dprintf ("Selected sources:\n");
- for (l = selected_sources; l; l = l->next)
- {
- char *source = l->data;
-
- dprintf (" %s\n", source);
- }
- dprintf ("\n");
-#endif
-}
-
-static inline void
debug_dump_ecal_list (GSList *ecal_list)
{
#ifdef CALENDAR_ENABLE_DEBUG
@@ -399,26 +316,25 @@ debug_dump_ecal_list (GSList *ecal_list)
dprintf ("Loaded clients:\n");
for (l = ecal_list; l; l = l->next)
{
- ECal *client = l->data;
- ESource *source = e_cal_get_source (client);
+ ECalClient *client = l->data;
+ ESource *source = e_client_get_source (E_CLIENT (client));
- dprintf (" %s %s %s\n",
- e_source_peek_uid (source),
- e_source_peek_name (source),
- e_cal_get_uri (client));
+ dprintf (" %s %s\n",
+ e_source_get_uid (source),
+ e_source_get_display_name (source));
}
#endif
}
static void
-calendar_sources_load_esource_list (CalendarSourceData *source_data);
+calendar_sources_load_esources (CalendarSourceData *source_data);
static gboolean
backend_restart (gpointer data)
{
CalendarSourceData *source_data = data;
- calendar_sources_load_esource_list (source_data);
+ calendar_sources_load_esources (source_data);
source_data->timeout_id = 0;
@@ -426,9 +342,9 @@ backend_restart (gpointer data)
}
static void
-backend_died_cb (ECal *client, CalendarSourceData *source_data)
+backend_died_cb (ECalClient *client, CalendarSourceData *source_data)
{
- const char *uristr;
+ ESource *source;
source_data->clients = g_slist_remove (source_data->clients, client);
if (g_slist_length (source_data->clients) < 1)
@@ -436,8 +352,8 @@ backend_died_cb (ECal *client, CalendarSourceData *source_data)
g_slist_free (source_data->clients);
source_data->clients = NULL;
}
- uristr = e_cal_get_uri (client);
- g_warning ("The calendar backend for %s has crashed.", uristr);
+ source = e_client_get_source (E_CLIENT (client));
+ g_warning ("The calendar backend for '%s/%s' has crashed.", e_source_get_uid (source), e_source_get_display_name (source));
if (source_data->timeout_id != 0)
{
@@ -450,57 +366,46 @@ backend_died_cb (ECal *client, CalendarSourceData *source_data)
}
static void
-calendar_sources_load_esource_list (CalendarSourceData *source_data)
+calendar_sources_load_esources (CalendarSourceData *source_data)
{
GSList *clients = NULL;
- GSList *groups, *l;
+ GSList *sources, *s;
gboolean emit_signal = FALSE;
- g_return_if_fail (source_data->esource_list != NULL);
+ g_return_if_fail (source_data->esource_selector != NULL);
- debug_dump_selected_sources (source_data->selected_sources);
-
- dprintf ("Source groups:\n");
- groups = e_source_list_peek_groups (source_data->esource_list);
- for (l = groups; l; l = l->next)
+ dprintf ("Sources:\n");
+ sources = e_source_selector_get_selection (source_data->esource_selector);
+ for (s = sources; s; s = s->next)
{
- GSList *esources, *s;
-
- dprintf (" %s\n", e_source_group_peek_uid (l->data));
- dprintf (" sources:\n");
-
- esources = e_source_group_peek_sources (l->data);
- for (s = esources; s; s = s->next)
- {
- ESource *esource = E_SOURCE (s->data);
- ECal *client;
-
- dprintf (" type = '%s' uid = '%s', name = '%s', relative uri = '%s': \n",
- source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task",
- e_source_peek_uid (esource),
- e_source_peek_name (esource),
- e_source_peek_relative_uri (esource));
-
- if (is_source_selected (esource, source_data->selected_sources) &&
- (client = get_ecal_from_source (esource, source_data->source_type, source_data->clients)))
- {
- clients = g_slist_prepend (clients, client);
- }
- }
+ ESource *esource = E_SOURCE (s->data);
+ ECalClient *client;
+
+ dprintf (" type = '%s' uid = '%s', name = '%s': \n",
+ source_data->client_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? "appointment" : "task",
+ e_source_get_uid (esource),
+ e_source_get_display_name (esource));
+
+ if ((client = get_ecal_from_source (esource, source_data->client_type, source_data->clients)) != NULL)
+ {
+ clients = g_slist_prepend (clients, client);
+ }
}
dprintf ("\n");
+ e_source_selector_free_selection (sources);
+
if (source_data->loaded &&
!compare_ecal_lists (source_data->clients, clients))
emit_signal = TRUE;
- for (l = source_data->clients; l; l = l->next)
+ for (s = source_data->clients; s; s = s->next)
{
- g_signal_handlers_disconnect_by_func (G_OBJECT (l->data),
+ g_signal_handlers_disconnect_by_func (G_OBJECT (s->data),
G_CALLBACK (backend_died_cb),
source_data);
- g_object_unref (l->data);
+ g_object_unref (s->data);
}
g_slist_free (source_data->clients);
source_data->clients = g_slist_reverse (clients);
@@ -508,16 +413,16 @@ calendar_sources_load_esource_list (CalendarSourceData *source_data)
/* connect to backend_died after we disconnected the previous signal
* handlers. If we do it before, we'll lose some handlers (for clients that
* were already there before) */
- for (l = source_data->clients; l; l = l->next)
+ for (s = source_data->clients; s; s = s->next)
{
- g_signal_connect (G_OBJECT (l->data), "backend_died",
+ g_signal_connect (G_OBJECT (s->data), "backend-died",
G_CALLBACK (backend_died_cb), source_data);
}
if (emit_signal)
{
dprintf ("Emitting %s-sources-changed signal\n",
- source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task");
+ source_data->client_type == E_CAL_CLIENT_SOURCE_TYPE_EVENTS ? "appointment" : "task");
g_signal_emit (source_data->sources, source_data->changed_signal, 0);
}
@@ -525,98 +430,32 @@ calendar_sources_load_esource_list (CalendarSourceData *source_data)
}
static void
-calendar_sources_esource_list_changed (ESourceList *source_list,
+calendar_sources_selection_changed_cb (ESourceSelector *source_selector,
CalendarSourceData *source_data)
{
- dprintf ("ESourceList changed, reloading\n");
-
- calendar_sources_load_esource_list (source_data);
-}
-
-static void
-calendar_sources_selected_sources_notify (GConfClient *client,
- guint cnx_id,
- GConfEntry *entry,
- CalendarSourceData *source_data)
-{
- GSList *l;
-
- if (!entry->value ||
- entry->value->type != GCONF_VALUE_LIST ||
- gconf_value_get_list_type (entry->value) != GCONF_VALUE_STRING)
- return;
+ dprintf ("ESourceSelector selection-changed, reloading\n");
- dprintf ("Selected sources key (%s) changed, reloading\n", entry->key);
-
- for (l = source_data->selected_sources; l; l = l->next)
- g_free (l->data);
- source_data->selected_sources = NULL;
-
- for (l = gconf_value_get_list (entry->value); l; l = l->next)
- {
- const char *source = gconf_value_get_string (l->data);
-
- source_data->selected_sources =
- g_slist_prepend (source_data->selected_sources,
- g_strdup (source));
- }
- source_data->selected_sources =
- g_slist_reverse (source_data->selected_sources);
-
- calendar_sources_load_esource_list (source_data);
+ calendar_sources_load_esources (source_data);
}
static void
calendar_sources_load_sources (CalendarSources *sources,
CalendarSourceData *source_data,
- const char *sources_key,
- const char *selected_sources_key,
- const char *selected_sources_dir)
+ const char *sources_extension)
{
- GConfClient *gconf_client;
- GError *error;
+ g_return_if_fail (sources->priv->esource_registry != NULL);
dprintf ("---------------------------\n");
dprintf ("Loading sources:\n");
- dprintf (" sources_key: %s\n", sources_key);
- dprintf (" selected_sources_key: %s\n", selected_sources_key);
- dprintf (" selected_sources_dir: %s\n", selected_sources_dir);
-
- gconf_client = sources->priv->gconf_client;
-
- error = NULL;
- source_data->selected_sources = gconf_client_get_list (gconf_client,
- selected_sources_key,
- GCONF_VALUE_STRING,
- &error);
- if (error)
- {
- g_warning ("Failed to get selected sources from '%s': %s\n",
- selected_sources_key,
- error->message);
- g_error_free (error);
- return;
- }
+ dprintf (" sources_extension: %s\n", sources_extension);
- gconf_client_add_dir (gconf_client,
- selected_sources_dir,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
- source_data->selected_sources_dir = g_strdup (selected_sources_dir);
-
- source_data->selected_sources_listener =
- gconf_client_notify_add (gconf_client,
- selected_sources_dir,
- (GConfClientNotifyFunc) calendar_sources_selected_sources_notify,
- source_data, NULL, NULL);
-
- source_data->esource_list = e_source_list_new_for_gconf (gconf_client, sources_key);
- g_signal_connect (source_data->esource_list, "changed",
- G_CALLBACK (calendar_sources_esource_list_changed),
+ source_data->esource_selector = E_SOURCE_SELECTOR (e_source_selector_new (sources->priv->esource_registry, sources_extension));
+ g_signal_connect (source_data->esource_selector, "selection-changed",
+ G_CALLBACK (calendar_sources_selection_changed_cb),
source_data);
- calendar_sources_load_esource_list (source_data);
+ calendar_sources_load_esources (source_data);
source_data->loaded = TRUE;
@@ -632,9 +471,7 @@ calendar_sources_get_appointment_sources (CalendarSources *sources)
{
calendar_sources_load_sources (sources,
&sources->priv->appointment_sources,
- CALENDAR_SOURCES_APPOINTMENT_SOURCES_KEY,
- CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_KEY,
- CALENDAR_SOURCES_SELECTED_APPOINTMENT_SOURCES_DIR);
+ E_SOURCE_EXTENSION_CALENDAR);
}
return sources->priv->appointment_sources.clients;
@@ -649,9 +486,7 @@ calendar_sources_get_task_sources (CalendarSources *sources)
{
calendar_sources_load_sources (sources,
&sources->priv->task_sources,
- CALENDAR_SOURCES_TASK_SOURCES_KEY,
- CALENDAR_SOURCES_SELECTED_TASK_SOURCES_KEY,
- CALENDAR_SOURCES_SELECTED_TASK_SOURCES_DIR);
+ E_SOURCE_EXTENSION_TASK_LIST);
}
return sources->priv->task_sources.clients;
diff --git a/src/events/calendar-task.c b/src/events/calendar-task.c
index 351e2f7..080656f 100644
--- a/src/events/calendar-task.c
+++ b/src/events/calendar-task.c
@@ -50,7 +50,7 @@ almanah_calendar_task_event_class_init (AlmanahCalendarTaskEventClass *klass)
event_class->name = _("Calendar Task");
event_class->description = _("A task on an Evolution calendar.");
- event_class->icon_name = "stock_task";
+ event_class->icon_name = "evolution-tasks";
event_class->format_value = almanah_calendar_task_event_format_value;
event_class->format_time = almanah_calendar_task_event_format_time;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]