[evolution-data-server/openismus-work-master: 9/10] Really implement e_cal_client_view_set_fields_of_interest().
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 9/10] Really implement e_cal_client_view_set_fields_of_interest().
- Date: Thu, 18 Aug 2011 17:44:42 +0000 (UTC)
commit dac6d9434d63735ac1bcc715b74c51b23a7b81f1
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Aug 17 18:58:08 2011 +0200
Really implement e_cal_client_view_set_fields_of_interest().
As discussed on bug https://bugzilla.gnome.org/show_bug.cgi?id=652180,
this patch adds many '_component' variants to functions that are named
with '_object', all the '_component' variants take an ECalComponent object
instead of an ical string.
The magic filtering happens in e_data_cal_view_get_component_string()
which creates an ical string representation while omitting properties
that are not mentioned in the fields of interest.
calendar/backends/caldav/e-cal-backend-caldav.c | 156 ++++++----
.../backends/contacts/e-cal-backend-contacts.c | 2 +-
calendar/backends/file/e-cal-backend-file.c | 223 +++++++++------
calendar/backends/http/e-cal-backend-http.c | 11 +-
calendar/libedata-cal/e-cal-backend-sync.c | 68 +++--
calendar/libedata-cal/e-cal-backend-sync.h | 12 +-
calendar/libedata-cal/e-cal-backend.c | 219 ++++++++++++++-
calendar/libedata-cal/e-cal-backend.h | 8 +
calendar/libedata-cal/e-data-cal-view.c | 296 +++++++++++++++++++-
calendar/libedata-cal/e-data-cal-view.h | 8 +
calendar/libedata-cal/e-data-cal.c | 19 +-
calendar/libedata-cal/e-data-cal.h | 6 +-
12 files changed, 806 insertions(+), 222 deletions(-)
---
diff --git a/calendar/backends/caldav/e-cal-backend-caldav.c b/calendar/backends/caldav/e-cal-backend-caldav.c
index 12d9c06..06e6931 100644
--- a/calendar/backends/caldav/e-cal-backend-caldav.c
+++ b/calendar/backends/caldav/e-cal-backend-caldav.c
@@ -3417,7 +3417,7 @@ replace_master (ECalBackendCalDAV *cbdav, icalcomponent *old_comp, icalcomponent
/* a busy_lock is supposed to be locked already, when calling this function */
static void
-do_create_object (ECalBackendCalDAV *cbdav, const gchar *in_calobj, gchar **uid, gchar **new_calobj, GError **perror)
+do_create_object (ECalBackendCalDAV *cbdav, const gchar *in_calobj, gchar **uid, ECalComponent **new_component, GError **perror)
{
ECalComponent *comp;
gboolean online, did_put = FALSE;
@@ -3499,13 +3499,18 @@ do_create_object (ECalBackendCalDAV *cbdav, const gchar *in_calobj, gchar **uid,
icalcomponent *master = get_master_comp (cbdav, icalcomp);
if (!master)
- *new_calobj = e_cal_component_get_as_string (comp);
- else
- *new_calobj = icalcomponent_as_ical_string_r (master);
+ *new_component = g_object_ref (comp);
+ else {
+ gchar *str = icalcomponent_as_ical_string_r (master);
+
+ *new_component = e_cal_component_new_from_string (str);
+
+ g_free (str);
+ }
icalcomponent_free (icalcomp);
} else {
- *new_calobj = e_cal_component_get_as_string (comp);
+ *new_component = g_object_ref (comp);
}
}
@@ -3514,7 +3519,7 @@ do_create_object (ECalBackendCalDAV *cbdav, const gchar *in_calobj, gchar **uid,
/* a busy_lock is supposed to be locked already, when calling this function */
static void
-do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
+do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error)
{
ECalBackendCalDAVPrivate *priv;
ECalComponent *comp;
@@ -3526,8 +3531,8 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
priv = cbdav->priv;
- if (new_object)
- *new_object = NULL;
+ if (new_component)
+ *new_component = NULL;
if (!check_state (cbdav, &online, error))
return;
@@ -3573,25 +3578,29 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
/*ecalcomp_set_synch_state (comp, ECALCOMP_LOCALLY_MODIFIED);*/
}
- if (old_object) {
- *old_object = NULL;
+ if (old_component) {
+ *old_component = NULL;
if (e_cal_component_is_instance (comp)) {
/* set detached instance as the old object, if any */
ECalComponent *old_instance = e_cal_backend_store_get_component (priv->store, id->uid, id->rid);
+ /* This will give a reference to 'old_component' */
if (old_instance) {
- *old_object = e_cal_component_get_as_string (old_instance);
- g_object_unref (old_instance);
+ *old_component = old_instance;
}
}
- if (!*old_object) {
+ if (!*old_component) {
icalcomponent *master = get_master_comp (cbdav, cache_comp);
if (master) {
/* set full component as the old object */
- *old_object = icalcomponent_as_ical_string_r (master);
+ gchar *str = icalcomponent_as_ical_string_r (master);
+
+ *old_component = e_cal_component_new_from_string (str);
+
+ g_free (str);
}
}
}
@@ -3603,8 +3612,8 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
icalcomponent *new_comp = e_cal_component_get_icalcomponent (comp);
/* new object is only this instance */
- if (new_object)
- *new_object = e_cal_component_get_as_string (comp);
+ if (new_component)
+ *new_component = g_object_ref (comp);
/* add the detached instance */
if (icalcomponent_isa (cache_comp) == ICAL_VCALENDAR_COMPONENT) {
@@ -3658,7 +3667,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
}
if (did_put) {
- if (new_object && !*new_object) {
+ if (new_component && !*new_component) {
/* read the comp from cache again, as some servers can modify it on put */
icalcomponent *newcomp = get_comp_from_cache (cbdav, id->uid, NULL, NULL, NULL), *master;
@@ -3667,8 +3676,13 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
master = get_master_comp (cbdav, newcomp);
- if (master)
- *new_object = icalcomponent_as_ical_string_r (master);
+ if (master) {
+ gchar *str = icalcomponent_as_ical_string_r (master);
+
+ *new_component = e_cal_component_new_from_string (str);
+
+ g_free (str);
+ }
if (cache_comp != newcomp)
icalcomponent_free (newcomp);
@@ -3684,7 +3698,7 @@ do_modify_object (ECalBackendCalDAV *cbdav, const gchar *calobj, CalObjModType m
/* a busy_lock is supposed to be locked already, when calling this function */
static void
-do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object, GError **perror)
+do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid, CalObjModType mod, ECalComponent **old_component, ECalComponent **component, GError **perror)
{
ECalBackendCalDAVPrivate *priv;
icalcomponent *cache_comp;
@@ -3693,8 +3707,8 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
priv = cbdav->priv;
- if (object)
- *object = NULL;
+ if (component)
+ *component = NULL;
if (!check_state (cbdav, &online, perror))
return;
@@ -3706,17 +3720,21 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
return;
}
- if (old_object) {
+ if (old_component) {
ECalComponent *old = e_cal_backend_store_get_component (priv->store, uid, rid);
if (old) {
- *old_object = e_cal_component_get_as_string (old);
- g_object_unref (old);
+ *old_component = old;
} else {
icalcomponent *master = get_master_comp (cbdav, cache_comp);
- if (master)
- *old_object = icalcomponent_as_ical_string_r (master);
+ if (master) {
+ gchar *str = icalcomponent_as_ical_string_r (master);
+
+ *old_component = e_cal_component_new_from_string (str);
+
+ g_free (str);
+ }
}
}
@@ -3726,11 +3744,16 @@ do_remove_object (ECalBackendCalDAV *cbdav, const gchar *uid, const gchar *rid,
if (rid && *rid) {
/* remove one instance from the component */
if (remove_instance (cbdav, cache_comp, icaltime_from_string (rid), mod, mod != CALOBJ_MOD_ONLY_THIS)) {
- if (object) {
+ if (component) {
icalcomponent *master = get_master_comp (cbdav, cache_comp);
- if (master)
- *object = icalcomponent_as_ical_string_r (master);
+ if (master) {
+ gchar *str = icalcomponent_as_ical_string_r (master);
+
+ *component = e_cal_component_new_from_string (str);
+
+ g_free (str);
+ }
}
} else {
/* this was the last instance, thus delete whole component */
@@ -3889,60 +3912,69 @@ process_object (ECalBackendCalDAV *cbdav,
is_declined = e_cal_backend_user_declined (e_cal_component_get_icalcomponent (ecomp));
if (is_in_cache) {
if (!is_declined) {
- gchar *new_object = NULL, *old_object = NULL;
+ ECalComponent *new_component = NULL, *old_component = NULL;
- do_modify_object (cbdav, new_obj_str, mod, &old_object, &new_object, &err);
+ do_modify_object (cbdav, new_obj_str, mod,
+ &old_component, &new_component, &err);
if (!err) {
- if (!old_object)
- e_cal_backend_notify_object_created (backend, new_object);
+ if (!old_component)
+ e_cal_backend_notify_component_created (backend, new_component);
else
- e_cal_backend_notify_object_modified (backend, old_object, new_object);
+ e_cal_backend_notify_component_modified (backend, old_component, new_component);
}
- g_free (new_object);
- g_free (old_object);
+ if (new_component)
+ g_object_unref (new_component);
+ if (old_component)
+ g_object_unref (old_component);
} else {
- gchar *new_object = NULL, *old_object = NULL;
+ ECalComponent *new_component = NULL, *old_component = NULL;
- do_remove_object (cbdav, id->uid, id->rid, mod, &old_object, &new_object, &err);
+ do_remove_object (cbdav, id->uid, id->rid, mod, &old_component, &new_component, &err);
if (!err) {
- if (new_object) {
- e_cal_backend_notify_object_modified (backend, old_object, new_object);
+ if (new_component) {
+ e_cal_backend_notify_component_modified (backend, old_component, new_component);
} else {
- e_cal_backend_notify_object_removed (backend, id, old_object, NULL);
+ e_cal_backend_notify_component_removed (backend, id, old_component, NULL);
}
}
- g_free (new_object);
- g_free (old_object);
+ if (new_component)
+ g_object_unref (new_component);
+ if (old_component)
+ g_object_unref (old_component);
}
} else if (!is_declined) {
- gchar *new_object = new_obj_str;
+ ECalComponent *new_component = NULL;
+
+ do_create_object (cbdav, new_obj_str, NULL, &new_component, &err);
- do_create_object (cbdav, new_object, NULL, &new_object, &err);
if (!err) {
- e_cal_backend_notify_object_created (backend, new_object);
+ e_cal_backend_notify_component_created (backend, new_component);
}
- if (new_object != new_obj_str)
- g_free (new_object);
+ if (new_component)
+ g_object_unref (new_component);
+
}
break;
case ICAL_METHOD_CANCEL:
if (is_in_cache) {
- gchar *old_object = NULL, *new_object = NULL;
+ ECalComponent *new_component = NULL, *old_component = NULL;
- do_remove_object (cbdav, id->uid, id->rid, CALOBJ_MOD_THIS, &old_object, &new_object, &err);
+ do_remove_object (cbdav, id->uid, id->rid, CALOBJ_MOD_THIS, &old_component, &new_component, &err);
if (!err) {
- if (new_object) {
- e_cal_backend_notify_object_modified (backend, old_object, new_object);
+ if (new_component) {
+ e_cal_backend_notify_component_modified (backend, old_component, new_component);
} else {
- e_cal_backend_notify_object_removed (backend, id, old_object, NULL);
+ e_cal_backend_notify_component_removed (backend, id, old_component, NULL);
}
}
- g_free (old_object);
- g_free (new_object);
+ if (new_component)
+ g_object_unref (new_component);
+ if (old_component)
+ g_object_unref (old_component);
} else {
err = EDC_ERROR (ObjectNotFound);
}
@@ -4060,16 +4092,16 @@ _func_name _params \
}
caldav_busy_stub (
- caldav_create_object, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *in_calobj, gchar **uid, gchar **new_calobj, GError **perror),
- do_create_object, (cbdav, in_calobj, uid, new_calobj, perror))
+ caldav_create_object, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *in_calobj, gchar **uid, ECalComponent **new_component, GError **perror),
+ do_create_object, (cbdav, in_calobj, uid, new_component, perror))
caldav_busy_stub (
- caldav_modify_object, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **perror),
- do_modify_object, (cbdav, calobj, mod, old_object, new_object, perror))
+ caldav_modify_object, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **perror),
+ do_modify_object, (cbdav, calobj, mod, old_component, new_component, perror))
caldav_busy_stub (
- caldav_remove_object, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **object, GError **perror),
- do_remove_object, (cbdav, uid, rid, mod, old_object, object, perror))
+ caldav_remove_object, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod, ECalComponent **old_component, ECalComponent **component, GError **perror),
+ do_remove_object, (cbdav, uid, rid, mod, old_component, component, perror))
caldav_busy_stub (
caldav_receive_objects, (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GError **perror),
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c
index afa5b7d..7e45242 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -1168,7 +1168,7 @@ e_cal_backend_contacts_init (ECalBackendContacts *cbc)
}
static void
-e_cal_backend_contacts_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, gchar **new_calobj, GError **perror)
+e_cal_backend_contacts_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, ECalComponent **new_component, GError **perror)
{
g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index 02f81d9..72f4d55 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -1048,18 +1048,14 @@ notify_adds_modifies_cb (gpointer key, gpointer value, gpointer data)
if (!old_obj_data) {
/* Object was added */
-
- new_icomp = e_cal_component_get_icalcomponent (new_obj_data->full_object);
- if (!new_icomp)
- return;
-
- new_obj_str = icalcomponent_as_ical_string_r (new_icomp);
- if (!new_obj_str)
- return;
-
- e_cal_backend_notify_object_created (context->backend, new_obj_str);
- g_free (new_obj_str);
+ e_cal_backend_notify_component_created (context->backend, new_obj_data->full_object);
} else {
+
+ /* Check the component internals and compare the serialized ical strings
+ * to check for the difference, This should probably be better handled
+ * with something like:
+ * gboolean e_cal_component_compare (component_a, component_b);
+ */
old_icomp = e_cal_component_get_icalcomponent (old_obj_data->full_object);
new_icomp = e_cal_component_get_icalcomponent (new_obj_data->full_object);
if (!old_icomp || !new_icomp)
@@ -1072,9 +1068,11 @@ notify_adds_modifies_cb (gpointer key, gpointer value, gpointer data)
if (strcmp (old_obj_str, new_obj_str)) {
/* Object was modified */
-
- e_cal_backend_notify_object_modified (context->backend, old_obj_str, new_obj_str);
+ e_cal_backend_notify_component_modified (context->backend,
+ old_obj_data->full_object,
+ new_obj_data->full_object);
}
+
g_free (old_obj_str);
g_free (new_obj_str);
}
@@ -1520,8 +1518,23 @@ typedef struct {
const gchar *query;
ECalBackendSExp *obj_sexp;
ECalBackend *backend;
+ EDataCalView *view;
} MatchObjectData;
+
+static GSList *
+append_component (GSList *list, MatchObjectData *match_data, ECalComponent *comp)
+{
+ gchar *str;
+
+ if (match_data->view)
+ str = e_data_cal_view_get_component_string (match_data->view, comp);
+ else
+ str = e_cal_component_get_as_string (comp);
+
+ return g_slist_append (list, str);
+}
+
static void
match_object_sexp_to_component (gpointer value, gpointer data)
{
@@ -1544,7 +1557,8 @@ match_object_sexp_to_component (gpointer value, gpointer data)
if ((!match_data->search_needed) ||
(e_cal_backend_sexp_match_comp (match_data->obj_sexp, comp, match_data->backend))) {
- match_data->obj_list = g_slist_append (match_data->obj_list, e_cal_component_get_as_string (comp));
+
+ match_data->obj_list = append_component (match_data->obj_list, match_data, comp);
}
}
@@ -1556,7 +1570,7 @@ match_recurrence_sexp (gpointer key, gpointer value, gpointer data)
if ((!match_data->search_needed) ||
(e_cal_backend_sexp_match_comp (match_data->obj_sexp, comp, match_data->backend))) {
- match_data->obj_list = g_slist_append (match_data->obj_list, e_cal_component_get_as_string (comp));
+ match_data->obj_list = append_component (match_data->obj_list, match_data, comp);
}
}
@@ -1568,8 +1582,11 @@ match_object_sexp (gpointer key, gpointer value, gpointer data)
if (obj_data->full_object) {
if ((!match_data->search_needed) ||
- (e_cal_backend_sexp_match_comp (match_data->obj_sexp, obj_data->full_object, match_data->backend))) {
- match_data->obj_list = g_slist_append (match_data->obj_list, e_cal_component_get_as_string (obj_data->full_object));
+ (e_cal_backend_sexp_match_comp (match_data->obj_sexp,
+ obj_data->full_object, match_data->backend))) {
+
+ match_data->obj_list =
+ append_component (match_data->obj_list, match_data, obj_data->full_object);
}
}
@@ -1585,7 +1602,7 @@ e_cal_backend_file_get_object_list (ECalBackendSync *backend, EDataCal *cal, GCa
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
- MatchObjectData match_data;
+ MatchObjectData match_data = { 0, };
time_t occur_start = -1, occur_end = -1;
gboolean prunning_by_time;
GList* objs_occuring_in_tw;
@@ -1760,14 +1777,16 @@ e_cal_backend_file_start_view (ECalBackend *backend, EDataCalView *query)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
- MatchObjectData match_data;
+ MatchObjectData match_data = { 0, };
time_t occur_start = -1, occur_end = -1;
gboolean prunning_by_time;
GList* objs_occuring_in_tw;
cbfile = E_CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
- d(g_message (G_STRLOC ": Starting query (%s)", e_data_cal_view_get_text (query)));
+ d(g_message (G_STRLOC ": Starting query (%s) has fields-of-interest %s",
+ e_data_cal_view_get_text (query),
+ e_data_cal_view_get_fields_of_interest (query) ? "yes" : "no"));
/* try to match all currently existing objects */
match_data.search_needed = TRUE;
@@ -1775,6 +1794,7 @@ e_cal_backend_file_start_view (ECalBackend *backend, EDataCalView *query)
match_data.obj_list = NULL;
match_data.backend = backend;
match_data.obj_sexp = e_data_cal_view_get_object_sexp (query);
+ match_data.view = query;
if (!strcmp (match_data.query, "#t"))
match_data.search_needed = FALSE;
@@ -1818,7 +1838,7 @@ e_cal_backend_file_start_view (ECalBackend *backend, EDataCalView *query)
/* notify listeners of all objects */
if (match_data.obj_list) {
- e_data_cal_view_notify_objects_added (query, match_data.obj_list);
+ e_data_cal_view_notify_components_added (query, match_data.obj_list);
/* free memory */
g_slist_foreach (match_data.obj_list, (GFunc) g_free, NULL);
@@ -2112,7 +2132,7 @@ sanitize_component (ECalBackendFile *cbfile, ECalComponent *comp)
}
static void
-e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *in_calobj, gchar **uid, gchar **new_object, GError **error)
+e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *in_calobj, gchar **uid, ECalComponent **new_component, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -2126,7 +2146,7 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, GCanc
e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
e_return_data_cal_error_if_fail (in_calobj != NULL, ObjectNotFound);
- e_return_data_cal_error_if_fail (new_object != NULL, ObjectNotFound);
+ e_return_data_cal_error_if_fail (new_component != NULL, ObjectNotFound);
/* Parse the icalendar text */
icalcomp = icalparser_parse_string (in_calobj);
@@ -2192,7 +2212,10 @@ e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, GCanc
/* Return the UID and the modified component */
if (uid)
*uid = g_strdup (comp_uid);
- *new_object = e_cal_component_get_as_string (comp);
+
+ /* Give a reference to the caller */
+ if (new_component)
+ *new_component = g_object_ref (comp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
}
@@ -2232,8 +2255,9 @@ remove_object_instance_cb (gpointer key, gpointer value, gpointer user_data)
}
static void
-e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj,
- CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
+e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable,
+ const gchar *calobj, CalObjModType mod,
+ ECalComponent **old_component, ECalComponent **new_component, GError **error)
{
RemoveRecurrenceData rrdata;
ECalBackendFile *cbfile;
@@ -2306,8 +2330,9 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
switch (mod) {
case CALOBJ_MOD_THIS :
if (!rid || !*rid) {
- if (old_object && obj_data->full_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+
+ if (old_component && obj_data->full_object)
+ *old_component = g_object_ref (obj_data->full_object);
/* replace only the full object */
if (obj_data->full_object) {
@@ -2327,8 +2352,8 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
save (cbfile);
- if (new_object)
- *new_object = e_cal_component_get_as_string (comp);
+ if (new_component)
+ *new_component = g_object_ref (comp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
g_free (rid);
@@ -2336,8 +2361,9 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
}
if (g_hash_table_lookup_extended (obj_data->recurrences, rid, (gpointer *)&real_rid, (gpointer *)&recurrence)) {
- if (old_object)
- *old_object = e_cal_component_get_as_string (recurrence);
+
+ if (old_component)
+ *old_component = g_object_ref (recurrence);
/* remove the component from our data */
icalcomponent_remove_component (priv->icalcomp,
@@ -2360,8 +2386,9 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
case CALOBJ_MOD_THISANDPRIOR :
case CALOBJ_MOD_THISANDFUTURE :
if (!rid || !*rid) {
- if (old_object && obj_data->full_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+
+ if (old_component && obj_data->full_object)
+ *old_component = g_object_ref (obj_data->full_object);
remove_component (cbfile, comp_uid, obj_data);
@@ -2382,8 +2409,9 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
/* now deal with the detached recurrence */
if (g_hash_table_lookup_extended (obj_data->recurrences, rid,
(gpointer *)&real_rid, (gpointer *)&recurrence)) {
- if (old_object)
- *old_object = e_cal_component_get_as_string (recurrence);
+
+ if (old_component && obj_data->full_object)
+ *old_component = g_object_ref (recurrence);
/* remove the component from our data */
icalcomponent_remove_component (priv->icalcomp,
@@ -2392,8 +2420,8 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
obj_data->recurrences_list = g_list_remove (obj_data->recurrences_list, recurrence);
g_hash_table_remove (obj_data->recurrences, rid);
} else {
- if (old_object && obj_data->full_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+ if (old_component && obj_data->full_object)
+ *old_component = g_object_ref (obj_data->full_object);
}
rrdata.cbfile = cbfile;
@@ -2423,8 +2451,8 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
break;
case CALOBJ_MOD_ALL :
/* Remove the old version */
- if (old_object && obj_data->full_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+ if (old_component && obj_data->full_object)
+ *old_component = g_object_ref (obj_data->full_object);
if (obj_data->recurrences_list) {
/* has detached components, preserve them */
@@ -2468,8 +2496,8 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
save (cbfile);
g_free (rid);
- if (new_object)
- *new_object = e_cal_component_get_as_string (comp);
+ if (new_component)
+ *new_component = g_object_ref (comp);
g_static_rec_mutex_unlock (&priv->idle_save_rmutex);
}
@@ -2492,7 +2520,7 @@ static ECalBackendFileObject *
remove_instance (ECalBackendFile *cbfile, ECalBackendFileObject *obj_data,
const gchar *uid, const gchar *rid,
CalObjModType mod,
- gchar **old_object, gchar **object,
+ ECalComponent **old_component, ECalComponent **component,
GError **error)
{
gchar *hash_rid;
@@ -2509,9 +2537,9 @@ remove_instance (ECalBackendFile *cbfile, ECalBackendFileObject *obj_data,
(gpointer *)&hash_rid, (gpointer *)&comp)) {
/* Removing without parent or not modifying parent?
Report removal to caller. */
- if (old_object &&
+ if (old_component &&
(!obj_data->full_object || mod == CALOBJ_MOD_ONLY_THIS))
- *old_object = e_cal_component_get_as_string (comp);
+ *old_component = g_object_ref (comp);
/* Reporting parent modification to caller?
Report directly instead of going via caller. */
@@ -2560,8 +2588,8 @@ remove_instance (ECalBackendFile *cbfile, ECalBackendFileObject *obj_data,
cbfile->priv->comp = g_list_remove (cbfile->priv->comp, obj_data->full_object);
/* add EXDATE or EXRULE to parent, report as update */
- if (old_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+ if (old_component)
+ *old_component = g_object_ref (obj_data->full_object);
e_cal_util_remove_instances (e_cal_component_get_icalcomponent (obj_data->full_object),
icaltime_from_string (rid), CALOBJ_MOD_THIS);
@@ -2571,8 +2599,8 @@ remove_instance (ECalBackendFile *cbfile, ECalBackendFileObject *obj_data,
e_cal_component_set_last_modified (obj_data->full_object, ¤t);
/* report update */
- if (object)
- *object = e_cal_component_get_as_string (obj_data->full_object);
+ if (component)
+ *component = g_object_ref (obj_data->full_object);
/* add the modified object to the beginning of the list,
so that it's always before any detached instance we
@@ -2601,8 +2629,8 @@ remove_instance (ECalBackendFile *cbfile, ECalBackendFileObject *obj_data,
cbfile->priv->comp = g_list_remove (cbfile->priv->comp, obj_data->full_object);
/* remove parent, report as removal */
- if (old_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+ if (old_component)
+ *old_component = g_object_ref (obj_data->full_object);
g_object_unref (obj_data->full_object);
obj_data->full_object = NULL;
@@ -2617,8 +2645,8 @@ remove_instance (ECalBackendFile *cbfile, ECalBackendFileObject *obj_data,
return obj_data;
}
-static gchar *
-get_object_string_from_fileobject (ECalBackendFileObject *obj_data, const gchar *rid)
+static ECalComponent *
+ref_object_from_fileobject (ECalBackendFileObject *obj_data, const gchar *rid)
{
ECalComponent *comp = obj_data->full_object;
gchar *real_rid;
@@ -2627,14 +2655,14 @@ get_object_string_from_fileobject (ECalBackendFileObject *obj_data, const gchar
return NULL;
if (!rid) {
- return e_cal_component_get_as_string (comp);
+ return g_object_ref (comp);
} else {
if (g_hash_table_lookup_extended (obj_data->recurrences, rid, (gpointer *)&real_rid, (gpointer *)&comp))
- return e_cal_component_get_as_string (comp);
+ return g_object_ref (comp);
else {
/* FIXME remove this once we delete an instance from master object through
modify request by setting exception */
- return e_cal_component_get_as_string (comp);
+ return g_object_ref (comp);
}
}
@@ -2644,9 +2672,8 @@ get_object_string_from_fileobject (ECalBackendFileObject *obj_data, const gchar
/* Remove_object handler for the file backend */
static void
e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable,
- const gchar *uid, const gchar *rid,
- CalObjModType mod, gchar **old_object,
- gchar **object, GError **error)
+ const gchar *uid, const gchar *rid, CalObjModType mod,
+ ECalComponent **old_component, ECalComponent **component, GError **error)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
@@ -2672,7 +2699,7 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
return;
}
- *old_object = *object = NULL;
+ *old_component = *component = NULL;
g_static_rec_mutex_lock (&priv->idle_save_rmutex);
@@ -2688,14 +2715,15 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
switch (mod) {
case CALOBJ_MOD_ALL :
- *old_object = get_object_string_from_fileobject (obj_data, recur_id);
+ *old_component = ref_object_from_fileobject (obj_data, recur_id);
+
remove_component (cbfile, uid, obj_data);
- *object = NULL;
+ *component = NULL;
break;
case CALOBJ_MOD_ONLY_THIS:
case CALOBJ_MOD_THIS :
- obj_data = remove_instance (cbfile, obj_data, uid, recur_id, mod, old_object, object, error);
+ obj_data = remove_instance (cbfile, obj_data, uid, recur_id, mod, old_component, component, error);
break;
case CALOBJ_MOD_THISANDPRIOR :
case CALOBJ_MOD_THISANDFUTURE :
@@ -2708,7 +2736,7 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
}
if (comp) {
- *old_object = e_cal_component_get_as_string (comp);
+ *old_component = e_cal_component_clone (comp);
/* remove the component from our data, temporarily */
icalcomponent_remove_component (priv->icalcomp,
@@ -2733,7 +2761,7 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
priv->comp = g_list_prepend (priv->comp, comp);
if (obj_data->full_object)
- *object = e_cal_component_get_as_string (obj_data->full_object);
+ *component = g_object_ref (obj_data->full_object);
break;
}
@@ -2743,7 +2771,7 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
}
static gboolean
-cancel_received_object (ECalBackendFile *cbfile, icalcomponent *icalcomp, gchar **old_object, gchar **new_object)
+cancel_received_object (ECalBackendFile *cbfile, icalcomponent *icalcomp, ECalComponent **old_component, ECalComponent **new_component)
{
ECalBackendFileObject *obj_data;
ECalBackendFilePrivate *priv;
@@ -2753,8 +2781,7 @@ cancel_received_object (ECalBackendFile *cbfile, icalcomponent *icalcomp, gchar
priv = cbfile->priv;
- *old_object = NULL;
- *new_object = NULL;
+ *old_component = *new_component = NULL;
/* Find the old version of the component. */
obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
@@ -2770,13 +2797,20 @@ cancel_received_object (ECalBackendFile *cbfile, icalcomponent *icalcomp, gchar
rid = e_cal_component_get_recurid_as_string (comp);
if (rid && *rid) {
- obj_data = remove_instance (cbfile, obj_data, uid, rid, CALOBJ_MOD_THIS, old_object, new_object, NULL);
- if (obj_data && obj_data->full_object)
- *new_object = e_cal_component_get_as_string (obj_data->full_object);
+ obj_data = remove_instance (cbfile, obj_data, uid, rid, CALOBJ_MOD_THIS,
+ old_component, new_component, NULL);
+
+ if (obj_data && obj_data->full_object) {
+ if (*new_component)
+ g_object_unref (*new_component);
+
+ *new_component = g_object_ref (obj_data->full_object);
+ }
+
} else {
- /* report as removal by keeping *new_object NULL */
+ /* report as removal by keeping *new_component NULL */
if (obj_data->full_object)
- *old_object = e_cal_component_get_as_string (obj_data->full_object);
+ *old_component = g_object_ref (obj_data->full_object);
remove_component (cbfile, uid, obj_data);
}
@@ -2982,8 +3016,9 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, GCa
/* Now we manipulate the components we care about */
for (l = comps; l; l = l->next) {
const gchar *uid;
- gchar *object, *old_object = NULL, *rid, *new_object;
+ gchar *rid;
ECalBackendFileObject *obj_data;
+ ECalComponent *old_component, *component;
gboolean is_declined;
subcomp = l->data;
@@ -3018,38 +3053,37 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, GCa
if (obj_data) {
if (rid) {
remove_instance (cbfile, obj_data, uid, rid, CALOBJ_MOD_THIS,
- &old_object, &new_object, NULL);
+ &old_component, &component, NULL);
} else {
if (obj_data->full_object)
- old_object = e_cal_component_get_as_string (obj_data->full_object);
+ old_component = g_object_ref (obj_data->full_object);
remove_component (cbfile, uid, obj_data);
}
if (!is_declined)
add_component (cbfile, comp, FALSE);
- object = e_cal_component_get_as_string (comp);
- if (!is_declined)
- e_cal_backend_notify_object_modified (E_CAL_BACKEND (backend), old_object, object);
- else {
+
+ if (!is_declined) {
+ e_cal_backend_notify_component_modified (E_CAL_BACKEND (backend), old_component, comp);
+
+ } else {
ECalComponentId *id = e_cal_component_get_id (comp);
if (rid)
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), id, old_object, object);
+ e_cal_backend_notify_component_removed (E_CAL_BACKEND (backend), id, old_component, comp);
else
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), id, old_object, NULL);
+ e_cal_backend_notify_component_removed (E_CAL_BACKEND (backend), id, old_component, NULL);
e_cal_component_free_id (id);
}
- g_free (object);
- g_free (old_object);
+ g_object_unref (old_component);
+ g_object_unref (component);
} else if (!is_declined) {
add_component (cbfile, comp, FALSE);
- object = e_cal_component_get_as_string (comp);
- e_cal_backend_notify_object_created (E_CAL_BACKEND (backend), object);
- g_free (object);
+ e_cal_backend_notify_component_created (E_CAL_BACKEND (backend), comp);
}
g_free (rid);
break;
@@ -3070,22 +3104,23 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, GCa
goto error;
break;
case ICAL_METHOD_CANCEL:
- old_object = NULL;
- new_object = NULL;
- if (cancel_received_object (cbfile, subcomp, &old_object, &new_object)) {
+ /* XXX */
+ old_component = component = NULL;
+
+ if (cancel_received_object (cbfile, subcomp, &old_component, &component)) {
ECalComponentId *id;
id = e_cal_component_get_id (comp);
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), id, old_object, new_object);
+ e_cal_backend_notify_component_removed (E_CAL_BACKEND (backend), id, old_component, component);
/* remove the component from the toplevel VCALENDAR */
icalcomponent_remove_component (toplevel_comp, subcomp);
icalcomponent_free (subcomp);
e_cal_component_free_id (id);
- g_free (new_object);
- g_free (old_object);
+ g_object_unref (old_component);
+ g_object_unref (component);
}
g_free (rid);
break;
@@ -3351,7 +3386,7 @@ e_cal_backend_file_reload (ECalBackendFile *cbfile, GError **perror)
static void
test_query_by_scanning_all_objects (ECalBackendFile* cbfile, const gchar *sexp, GSList **objects)
{
- MatchObjectData match_data;
+ MatchObjectData match_data = { 0, };
ECalBackendFilePrivate *priv;
priv = cbfile->priv;
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index 97a8fc6..4865ec8 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -1210,14 +1210,14 @@ e_cal_backend_http_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GCanc
}
static void
-e_cal_backend_http_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, gchar **new_calobj, GError **perror)
+e_cal_backend_http_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, ECalComponent **new_component, GError **perror)
{
g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
static void
e_cal_backend_http_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj,
- CalObjModType mod, gchar **old_object, gchar **new_object, GError **perror)
+ CalObjModType mod, ECalComponent **old_component, ECalComponent **component, GError **perror)
{
g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
@@ -1225,11 +1225,10 @@ e_cal_backend_http_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
/* Remove_object handler for the file backend */
static void
e_cal_backend_http_remove_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable,
- const gchar *uid, const gchar *rid,
- CalObjModType mod, gchar **old_object,
- gchar **object, GError **perror)
+ const gchar *uid, const gchar *rid, CalObjModType mod,
+ ECalComponent **old_component, ECalComponent **component, GError **perror)
{
- *old_object = *object = NULL;
+ *old_component = *component = NULL;
g_propagate_error (perror, EDC_ERROR (PermissionDenied));
}
diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c
index baf2602..5a25b51 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.c
+++ b/calendar/libedata-cal/e-cal-backend-sync.c
@@ -265,18 +265,18 @@ e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GCanc
* @cancellable: a #GCancellable for the operation
* @calobj: The object to be added.
* @uid: Placeholder for server-generated UID.
- * @new_object: Placeholder for server-calobj, if it changed. Can be left as is if it's same as @calobj.
+ * @new_component: (out) (transfer full): Placeholder for returned #ECalComponent.
* @error: Out parameter for a #GError.
*
* Calls the create_object_sync method on the given backend.
*/
void
-e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, gchar **new_object, GError **error)
+e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, ECalComponent **new_component, GError **error)
{
e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->create_object_sync != NULL, UnsupportedMethod);
- LOCK_WRAPPER (create_object_sync, (backend, cal, cancellable, calobj, uid, new_object, error));
+ LOCK_WRAPPER (create_object_sync, (backend, cal, cancellable, calobj, uid, new_component, error));
}
/**
@@ -286,9 +286,9 @@ e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, GCanc
* @cancellable: a #GCancellable for the operation
* @calobj: Object to be modified.
* @mod: Type of modification to be done.
- * @old_object: Placeholder for returning the old object as it was stored on the
+ * @old_component: (out) (transfer full): Placeholder for returning the old component as it was stored on the
* backend.
- * @new_object: Placeholder for returning the new object as it has been stored
+ * @new_component: (out) (transfer full): Placeholder for returning the new component as it has been stored
* on the backend.
* @error: Out parameter for a #GError.
*
@@ -296,12 +296,12 @@ e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, GCanc
*/
void
e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj,
- CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
+ CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error)
{
e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->modify_object_sync != NULL, UnsupportedMethod);
- LOCK_WRAPPER (modify_object_sync, (backend, cal, cancellable, calobj, mod, old_object, new_object, error));
+ LOCK_WRAPPER (modify_object_sync, (backend, cal, cancellable, calobj, mod, old_component, new_component, error));
}
/**
@@ -313,23 +313,23 @@ e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
* @rid: Recurrence ID of the instance to remove, or NULL if removing the
* whole object.
* @mod: Type of removal.
- * @old_object: Placeholder for returning the old object as it was stored on the
+ * @old_component: (out) (transfer full): Placeholder for returning the old component as it was stored on the
* backend.
- * @new_object: Placeholder for returning the object after it has been modified (when
- * removing individual instances). If removing the whole object, this will be
- * NULL.
+ * @new_component: (out) (transfer full): Placeholder for returning the new component as it has been stored
+ * on the backend (when removing individual instances). If removing the whole object,
+ * this will be set to %NULL.
* @error: Out parameter for a #GError.
*
* Calls the remove_object_sync method on the given backend.
*/
void
e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid,
- CalObjModType mod, gchar **old_object, gchar **new_object, GError **error)
+ CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error)
{
e_return_data_cal_error_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), InvalidArg);
e_return_data_cal_error_if_fail (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->remove_object_sync != NULL, UnsupportedMethod);
- LOCK_WRAPPER (remove_object_sync, (backend, cal, cancellable, uid, rid, mod, old_object, new_object, error));
+ LOCK_WRAPPER (remove_object_sync, (backend, cal, cancellable, uid, rid, mod, old_component, new_component, error));
}
/**
@@ -597,46 +597,60 @@ static void
cal_backend_create_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj)
{
GError *error = NULL;
- gchar *uid = NULL, *new_object = NULL;
+ gchar *uid = NULL;
+ ECalComponent *new_component = NULL;
- e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, cancellable, calobj, &uid, &new_object, &error);
+ e_cal_backend_sync_create_object (E_CAL_BACKEND_SYNC (backend), cal, cancellable, calobj, &uid, &new_component, &error);
- e_data_cal_respond_create_object (cal, opid, error, uid, new_object ? new_object : calobj);
+ if (!new_component)
+ new_component = e_cal_component_new_from_string (calobj);
+
+ e_data_cal_respond_create_object (cal, opid, error, uid, new_component);
g_free (uid);
- g_free (new_object);
+ g_object_unref (new_component);
}
static void
cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *calobj, CalObjModType mod)
{
GError *error = NULL;
- gchar *old_object = NULL, *new_object = NULL;
+ ECalComponent *old_component = NULL, *new_component = NULL;
+
+ e_cal_backend_sync_modify_object (E_CAL_BACKEND_SYNC (backend), cal, cancellable, calobj, mod, &old_component, &new_component, &error);
+
+ if (!old_component)
+ old_component = e_cal_component_new_from_string (calobj);
- e_cal_backend_sync_modify_object (E_CAL_BACKEND_SYNC (backend), cal, cancellable, calobj, mod, &old_object, &new_object, &error);
+ e_data_cal_respond_modify_object (cal, opid, error, old_component, new_component);
- e_data_cal_respond_modify_object (cal, opid, error, old_object ? old_object : calobj, new_object);
- g_free (old_object);
- g_free (new_object);
+ if (old_component)
+ g_object_unref (old_component);
+
+ if (new_component)
+ g_object_unref (new_component);
}
static void
cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, guint32 opid, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod)
{
GError *error = NULL;
- gchar *old_object = NULL, *new_object = NULL;
+ ECalComponent *old_component = NULL, *new_component = NULL;
ECalComponentId compid;
compid.uid = (gchar *) uid;
compid.rid = (gchar *) ((mod == CALOBJ_MOD_THIS || mod == CALOBJ_MOD_ONLY_THIS) ? rid : NULL);
- e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, cancellable, uid, rid, mod, &old_object, &new_object, &error);
+ e_cal_backend_sync_remove_object (E_CAL_BACKEND_SYNC (backend), cal, cancellable, uid, rid, mod, &old_component, &new_component, &error);
+
+ e_data_cal_respond_remove_object (cal, opid, error, &compid, old_component, new_component);
- e_data_cal_respond_remove_object (cal, opid, error, &compid, old_object, new_object);
+ if (old_component)
+ g_object_unref (old_component);
- g_free (old_object);
- g_free (new_object);
+ if (new_component)
+ g_object_unref (new_component);
}
static void
diff --git a/calendar/libedata-cal/e-cal-backend-sync.h b/calendar/libedata-cal/e-cal-backend-sync.h
index 1b64a50..3878dce 100644
--- a/calendar/libedata-cal/e-cal-backend-sync.h
+++ b/calendar/libedata-cal/e-cal-backend-sync.h
@@ -39,9 +39,9 @@ struct _ECalBackendSyncClass {
void (* get_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, gchar **calobj, GError **error);
void (* get_object_list_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *sexp, GSList **calobjs, GError **error);
void (* get_free_busy_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const GSList *users, time_t start, time_t end, GSList **freebusyobjs, GError **error);
- void (* create_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, gchar **new_object, GError **error);
- void (* modify_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **error);
- void (* remove_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **new_object, GError **error);
+ void (* create_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, ECalComponent **new_component, GError **error);
+ void (* modify_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error);
+ void (* remove_object_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error);
void (* receive_objects_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GError **error);
void (* send_objects_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GSList **users, gchar **modified_calobj, GError **error);
void (* get_attachment_uris_sync) (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, GSList **attachments, GError **error);
@@ -64,9 +64,9 @@ gboolean e_cal_backend_sync_set_backend_property (ECalBackendSync *backend, EDat
void e_cal_backend_sync_get_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, gchar **calobj, GError **error);
void e_cal_backend_sync_get_object_list (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *sexp, GSList **calobjs, GError **error);
void e_cal_backend_sync_get_free_busy (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const GSList *users, time_t start, time_t end, GSList **freebusyobjs, GError **error);
-void e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, gchar **new_object, GError **error);
-void e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, CalObjModType mod, gchar **old_object, gchar **new_object, GError **error);
-void e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod, gchar **old_object, gchar **new_object, GError **error);
+void e_cal_backend_sync_create_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, gchar **uid, ECalComponent **new_component, GError **error);
+void e_cal_backend_sync_modify_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error);
+void e_cal_backend_sync_remove_object (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, CalObjModType mod, ECalComponent **old_component, ECalComponent **new_component, GError **error);
void e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GError **error);
void e_cal_backend_sync_send_objects (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *calobj, GSList **users, gchar **modified_calobj, GError **error);
void e_cal_backend_sync_get_attachment_uris (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *uid, const gchar *rid, GSList **attachments, GError **error);
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index 3a6d6fc..6d37bb1 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -1437,8 +1437,202 @@ e_cal_backend_stop_view (ECalBackend *backend, EDataCalView *view)
}
static gboolean
-object_created_cb (EDataCalView *view, gpointer calobj)
+component_created_cb (EDataCalView *view, gpointer data)
{
+ ECalComponent *component = (ECalComponent *)data;
+
+ if (e_data_cal_view_component_matches (view, component))
+ e_data_cal_view_notify_components_added_1 (view, component);
+
+ return TRUE;
+}
+
+/**
+ * e_cal_backend_notify_component_created:
+ * @backend: an #ECalBackend
+ * @component: the newly created #ECalComponent
+ *
+ * Notifies each of the backend's listeners about a new object.
+ *
+ * Like e_cal_backend_notify_object_created() except takes an #ECalComponent
+ * instead of an ical string representation and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ **/
+void
+e_cal_backend_notify_component_created (ECalBackend *backend, ECalComponent *component)
+{
+ ECalBackendPrivate *priv;
+
+ priv = backend->priv;
+
+ if (priv->notification_proxy) {
+ e_cal_backend_notify_component_created (priv->notification_proxy, component);
+ return;
+ }
+
+ e_cal_backend_foreach_view (backend, component_created_cb, (gpointer) component);
+}
+
+/**
+ * e_cal_backend_notify_components_added:
+ *
+ * Like e_cal_backend_notify_objects_added() except take a list of #ECalComponents
+ * instead of ical string representations and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ **/
+void
+e_cal_backend_notify_components_added (ECalBackend *backend, EDataCalView *view, const GSList *objects)
+{
+ e_data_cal_view_notify_components_added (view, objects);
+}
+
+static void
+match_view_and_notify_component (EDataCalView *view, ECalComponent *old_component, ECalComponent *component)
+{
+ gboolean old_match = FALSE, new_match = FALSE;
+
+ if (old_component)
+ old_match = e_data_cal_view_component_matches (view, old_component);
+
+ new_match = e_data_cal_view_component_matches (view, component);
+ if (old_match && new_match)
+ e_data_cal_view_notify_components_modified_1 (view, component);
+ else if (new_match)
+ e_data_cal_view_notify_components_added_1 (view, component);
+ else if (old_match) {
+
+ ECalComponentId *id = e_cal_component_get_id (old_component);
+
+ e_data_cal_view_notify_objects_removed_1 (view, id);
+
+ e_cal_component_free_id (id);
+ }
+}
+
+struct component_call_data {
+ ECalComponent *old_component;
+ ECalComponent *component;
+ const ECalComponentId *id;
+};
+
+static gboolean
+call_match_and_notify_component (EDataCalView *view, gpointer user_data)
+{
+ struct component_call_data *cd = user_data;
+
+ g_return_val_if_fail (user_data != NULL, FALSE);
+
+ match_view_and_notify_component (view, cd->old_component, cd->component);
+
+ return TRUE;
+}
+
+/**
+ * e_cal_backend_notify_component_modified:
+ * @backend: an #ECalBackend
+ * @old_component: the #ECalComponent before the modification
+ * @component: the #ECalComponent after the modification
+ *
+ * Notifies each of the backend's listeners about a modified object.
+ *
+ * Like e_cal_backend_notify_object_modified() except takes an #ECalComponent
+ * instead of an ical string representation and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ **/
+void
+e_cal_backend_notify_component_modified (ECalBackend *backend,
+ ECalComponent *old_component,
+ ECalComponent *component)
+{
+ ECalBackendPrivate *priv;
+ struct component_call_data cd;
+
+ priv = backend->priv;
+
+ if (priv->notification_proxy) {
+ e_cal_backend_notify_component_modified (priv->notification_proxy, old_component, component);
+ return;
+ }
+
+ cd.old_component = old_component;
+ cd.component = component;
+ cd.id = NULL;
+
+ e_cal_backend_foreach_view (backend, call_match_and_notify_component, &cd);
+}
+
+/**
+ * e_cal_backend_notify_components_modified:
+ *
+ * Like e_cal_backend_notify_objects_modified() except takes a list of #ECalComponents
+ * instead of a ical string representations and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ **/
+void
+e_cal_backend_notify_components_modified (ECalBackend *backend, EDataCalView *view, const GSList *objects)
+{
+ e_data_cal_view_notify_components_modified (view, objects);
+}
+
+static gboolean
+component_removed_cb (EDataCalView *view, gpointer user_data)
+{
+ struct component_call_data *cd = user_data;
+
+ g_return_val_if_fail (user_data != NULL, FALSE);
+
+ if (cd->component == NULL) {
+ /* if object == NULL, it means the object has been completely
+ removed from the backend */
+ if (!cd->old_component || e_data_cal_view_component_matches (view, cd->old_component))
+ e_data_cal_view_notify_objects_removed_1 (view, cd->id);
+ } else
+ match_view_and_notify_component (view, cd->old_component, cd->component);
+
+ return TRUE;
+}
+
+/**
+ * e_cal_backend_notify_component_removed:
+ * @backend: an #ECalBackend
+ * @id: the Id of the removed object
+ * @old_component: the removed component
+ * @component: the component after the removal. This only applies to recurrent
+ * appointments that had an instance removed. In that case, this function notifies a
+ * modification instead of a removal.
+ *
+ * Notifies each of the backend's listeners about a removed object.
+ *
+ * Like e_cal_backend_notify_objects_added() except take an #ECalComponent
+ * instead of an ical string representation and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ **/
+void
+e_cal_backend_notify_component_removed (ECalBackend *backend, const ECalComponentId *id,
+ ECalComponent *old_component, ECalComponent *component)
+{
+ ECalBackendPrivate *priv;
+ struct component_call_data cd;
+
+ priv = backend->priv;
+
+ if (priv->notification_proxy) {
+ e_cal_backend_notify_component_removed (priv->notification_proxy, id, old_component, component);
+ return;
+ }
+
+ cd.old_component = old_component;
+ cd.component = component;
+ cd.id = id;
+
+ e_cal_backend_foreach_view (backend, component_removed_cb, &cd);
+}
+
+static gboolean
+object_created_cb (EDataCalView *view, gpointer data)
+{
+ const gchar *calobj = data;
+
if (e_data_cal_view_object_matches (view, calobj))
e_data_cal_view_notify_objects_added_1 (view, calobj);
@@ -1448,7 +1642,7 @@ object_created_cb (EDataCalView *view, gpointer calobj)
/**
* e_cal_backend_notify_object_created:
* @backend: an #ECalBackend
- * @calobj: iCalendar representation of new object
+ * @calobj: the newly created object
*
* Notifies each of the backend's listeners about a new object.
*
@@ -1474,7 +1668,6 @@ e_cal_backend_notify_object_created (ECalBackend *backend, const gchar *calobj)
/**
* e_cal_backend_notify_objects_added:
*
- * Since: 2.24
**/
void
e_cal_backend_notify_objects_added (ECalBackend *backend, EDataCalView *view, const GSList *objects)
@@ -1483,7 +1676,7 @@ e_cal_backend_notify_objects_added (ECalBackend *backend, EDataCalView *view, co
}
static void
-match_view_and_notify (EDataCalView *view, const gchar *old_object, const gchar *object)
+match_view_and_notify_object (EDataCalView *view, const gchar *old_object, const gchar *object)
{
gboolean old_match = FALSE, new_match = FALSE;
@@ -1510,20 +1703,20 @@ match_view_and_notify (EDataCalView *view, const gchar *old_object, const gchar
}
}
-struct call_data {
+struct object_call_data {
const gchar *old_object;
const gchar *object;
const ECalComponentId *id;
};
static gboolean
-call_match_and_notify (EDataCalView *view, gpointer user_data)
+call_match_and_notify_object (EDataCalView *view, gpointer user_data)
{
- struct call_data *cd = user_data;
+ struct object_call_data *cd = user_data;
g_return_val_if_fail (user_data != NULL, FALSE);
- match_view_and_notify (view, cd->old_object, cd->object);
+ match_view_and_notify_object (view, cd->old_object, cd->object);
return TRUE;
}
@@ -1544,7 +1737,7 @@ void
e_cal_backend_notify_object_modified (ECalBackend *backend, const gchar *old_object, const gchar *object)
{
ECalBackendPrivate *priv;
- struct call_data cd;
+ struct object_call_data cd;
priv = backend->priv;
@@ -1557,7 +1750,7 @@ e_cal_backend_notify_object_modified (ECalBackend *backend, const gchar *old_obj
cd.object = object;
cd.id = NULL;
- e_cal_backend_foreach_view (backend, call_match_and_notify, &cd);
+ e_cal_backend_foreach_view (backend, call_match_and_notify_object, &cd);
}
/**
@@ -1574,7 +1767,7 @@ e_cal_backend_notify_objects_modified (ECalBackend *backend, EDataCalView *view,
static gboolean
object_removed_cb (EDataCalView *view, gpointer user_data)
{
- struct call_data *cd = user_data;
+ struct object_call_data *cd = user_data;
g_return_val_if_fail (user_data != NULL, FALSE);
@@ -1584,7 +1777,7 @@ object_removed_cb (EDataCalView *view, gpointer user_data)
if (!cd->old_object || e_data_cal_view_object_matches (view, cd->old_object))
e_data_cal_view_notify_objects_removed_1 (view, cd->id);
} else
- match_view_and_notify (view, cd->old_object, cd->object);
+ match_view_and_notify_object (view, cd->old_object, cd->object);
return TRUE;
}
@@ -1609,7 +1802,7 @@ e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId
const gchar *old_object, const gchar *object)
{
ECalBackendPrivate *priv;
- struct call_data cd;
+ struct object_call_data cd;
priv = backend->priv;
diff --git a/calendar/libedata-cal/e-cal-backend.h b/calendar/libedata-cal/e-cal-backend.h
index f9f0da7..225f277 100644
--- a/calendar/libedata-cal/e-cal-backend.h
+++ b/calendar/libedata-cal/e-cal-backend.h
@@ -150,10 +150,18 @@ void e_cal_backend_get_revision (ECalBackend *backend, E
void e_cal_backend_start_view (ECalBackend *backend, EDataCalView *view);
void e_cal_backend_stop_view (ECalBackend *backend, EDataCalView *view);
+void e_cal_backend_notify_component_created (ECalBackend *backend, ECalComponent *component);
+void e_cal_backend_notify_components_added (ECalBackend *backend, EDataCalView *view, const GSList *components);
+void e_cal_backend_notify_component_modified (ECalBackend *backend, ECalComponent *old_component, ECalComponent *new_component);
+void e_cal_backend_notify_components_modified(ECalBackend *backend, EDataCalView *view, const GSList *components);
+
+void e_cal_backend_notify_component_removed (ECalBackend *backend, const ECalComponentId *id, ECalComponent *old_component, ECalComponent *component);
+
void e_cal_backend_notify_object_created (ECalBackend *backend, const gchar *calobj);
void e_cal_backend_notify_objects_added (ECalBackend *backend, EDataCalView *view, const GSList *objects);
void e_cal_backend_notify_object_modified (ECalBackend *backend, const gchar *old_object, const gchar *object);
void e_cal_backend_notify_objects_modified (ECalBackend *backend, EDataCalView *view, const GSList *objects);
+
void e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId *id, const gchar *old_object, const gchar *object);
void e_cal_backend_notify_objects_removed (ECalBackend *backend, EDataCalView *view, const GSList *ids);
diff --git a/calendar/libedata-cal/e-data-cal-view.c b/calendar/libedata-cal/e-data-cal-view.c
index 479692e..b8c2bfb 100644
--- a/calendar/libedata-cal/e-data-cal-view.c
+++ b/calendar/libedata-cal/e-data-cal-view.c
@@ -286,6 +286,29 @@ notify_add (EDataCalView *view, gchar *obj)
}
static void
+notify_add_component (EDataCalView *view, ECalComponent *comp)
+{
+ EDataCalViewPrivate *priv = view->priv;
+ gchar *obj;
+
+ obj = e_data_cal_view_get_component_string (view, comp);
+
+ send_pending_changes (view);
+ send_pending_removes (view);
+
+ if (priv->adds->len == THRESHOLD_ITEMS) {
+ send_pending_adds (view);
+ }
+ g_array_append_val (priv->adds, obj);
+
+ g_hash_table_insert (priv->ids,
+ e_cal_component_get_id (comp),
+ GUINT_TO_POINTER (1));
+
+ ensure_pending_flush_timeout (view);
+}
+
+static void
notify_change (EDataCalView *view, gchar *obj)
{
EDataCalViewPrivate *priv = view->priv;
@@ -303,6 +326,16 @@ notify_change (EDataCalView *view, gchar *obj)
}
static void
+notify_change_component (EDataCalView *view, ECalComponent *comp)
+{
+ gchar *obj;
+
+ obj = e_data_cal_view_get_component_string (view, comp);
+
+ notify_change (view, obj);
+}
+
+static void
notify_remove (EDataCalView *view, ECalComponentId *id)
{
EDataCalViewPrivate *priv = view->priv;
@@ -624,7 +657,7 @@ e_data_cal_view_get_object_sexp (EDataCalView *view)
/**
* e_data_cal_view_object_matches:
* @view: A view object.
- * @object: Object to match.
+ * @object: Object to match..
*
* Compares the given @object to the regular expression used for the
* given view.
@@ -646,6 +679,30 @@ e_data_cal_view_object_matches (EDataCalView *view, const gchar *object)
}
/**
+ * e_data_cal_view_component_matches:
+ * @view: A view object.
+ * @component: the #ECalComponent object to match.
+ *
+ * Compares the given @component to the regular expression used for the
+ * given view.
+ *
+ * Returns: TRUE if the object matches the expression, FALSE if not.
+ */
+gboolean
+e_data_cal_view_component_matches (EDataCalView *view, ECalComponent *component)
+{
+ EDataCalViewPrivate *priv;
+
+ g_return_val_if_fail (view != NULL, FALSE);
+ g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), FALSE);
+ g_return_val_if_fail (E_IS_CAL_COMPONENT (component), FALSE);
+
+ priv = view->priv;
+
+ return e_cal_backend_sexp_match_comp (priv->sexp, component, priv->backend);
+}
+
+/**
* e_data_cal_view_is_started:
* @view: A view object.
*
@@ -718,12 +775,240 @@ e_data_cal_view_get_fields_of_interest (EDataCalView *view)
return view->priv->fields_of_interest;
}
+
+
+static gboolean
+filter_component (icalcomponent *icomponent, GHashTable *fields_of_interest, GString *string)
+{
+ gchar *str;
+
+ /* RFC 2445 explicitly says that the newline is *ALWAYS* a \r\n (CRLF)!!!! */
+ const gchar newline[] = "\r\n";
+
+ icalcomponent_kind kind;
+ const gchar *kind_string;
+ icalproperty *prop;
+ icalcomponent *icomp;
+ gboolean fail = FALSE;
+
+ /* Open iCalendar string */
+ g_string_append (string, "BEGIN:");
+
+ kind = icalcomponent_isa (icomponent);
+
+ /* if (kind != ICAL_X_COMPONENT) { */
+ /* kind_string = icalcomponent_kind_to_string (kind); */
+ /* } else { */
+ /* kind_string = icomponent->x_name; */
+ /* } */
+
+ kind_string = icalcomponent_kind_to_string (kind);
+
+ g_string_append (string, kind_string);
+ g_string_append (string, newline);
+
+ for (prop = icalcomponent_get_first_property (icomponent, ICAL_ANY_PROPERTY);
+ prop;
+ prop = icalcomponent_get_next_property (icomponent, ICAL_ANY_PROPERTY)) {
+ const gchar *name;
+ gboolean is_field_of_interest;
+
+ name = icalproperty_get_property_name (prop);
+
+ if (!name) {
+ g_warning ("NULL ical property name encountered while serializing component");
+ fail = TRUE;
+ break;
+ }
+
+ is_field_of_interest = GPOINTER_TO_INT (g_hash_table_lookup (fields_of_interest, name));
+
+ /* Append any name that is mentioned in the fields-of-interest */
+ if (is_field_of_interest) {
+ str = icalproperty_as_ical_string_r (prop);
+ g_string_append (string, str);
+ g_free (str);
+ }
+ }
+
+ for (icomp = icalcomponent_get_first_component (icomponent, ICAL_ANY_COMPONENT);
+ fail == FALSE && icomp;
+ icomp = icalcomponent_get_next_component (icomponent, ICAL_ANY_COMPONENT)) {
+
+ if (!filter_component (icomp, fields_of_interest, string)) {
+ fail = TRUE;
+ break;
+ }
+ }
+
+ g_string_append (string, "END:");
+ g_string_append (string, icalcomponent_kind_to_string (kind));
+ g_string_append (string, newline);
+
+ return fail == FALSE;
+}
+
+/**
+ * e_data_cal_view_get_component_string:
+ * @view: A view object.
+ * @component: The #ECalComponent to get the string for.
+ *
+ * This function is similar to e_cal_component_get_as_string() except
+ * that it takes into account the fields-of-interest that @view is
+ * configured with and filters out any unneeded fields.
+ *
+ * Returns: (transfer full): A newly allocated string representation of @component suitable for @view.
+ */
+gchar *
+e_data_cal_view_get_component_string (EDataCalView *view, ECalComponent *component)
+{
+ GString *string;
+ icalcomponent *icomponent;
+
+ g_return_val_if_fail (E_IS_DATA_CAL_VIEW (view), NULL);
+ g_return_val_if_fail (E_IS_CAL_COMPONENT (component), NULL);
+
+ if (!view->priv->fields_of_interest)
+ return e_cal_component_get_as_string (component);
+
+ string = g_string_new ("");
+ icomponent = e_cal_component_get_icalcomponent (component);
+
+ if (filter_component (icomponent, view->priv->fields_of_interest, string)) {
+ return g_string_free (string, FALSE);
+ }
+
+ g_string_free (string, TRUE);
+
+ /* If an error occured, fall back to reporting the full component */
+ return e_cal_component_get_as_string (component);
+}
+
+/**
+ * e_data_cal_view_notify_components_added:
+ * @view: A view object.
+ * @components: List of components that have been added.
+ *
+ * Notifies all view listeners of the addition of a list of components.
+ *
+ * Like e_data_cal_view_notify_objects_added() except takes a list
+ * of #ECalComponents instead of ical string representations and uses the
+ * #EDataCalView's fields-of-interest to filter out unwanted information
+ * from ical strings sent over the bus.
+ */
+void
+e_data_cal_view_notify_components_added (EDataCalView *view, const GSList *components)
+{
+ EDataCalViewPrivate *priv;
+ const GSList *l;
+
+ g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+ priv = view->priv;
+
+ if (components == NULL)
+ return;
+
+ g_mutex_lock (priv->pending_mutex);
+
+ for (l = components; l; l = l->next) {
+ ECalComponent *comp = l->data;
+
+ notify_add_component (view, comp);
+ }
+
+ g_mutex_unlock (priv->pending_mutex);
+}
+
+/**
+ * e_data_cal_view_notify_components_added_1:
+ * @view: A view object.
+ * @component: The #ECalComponent that has been added.
+ *
+ * Notifies all the view listeners of the addition of a single object.
+ *
+ * Like e_data_cal_view_notify_objects_added_1() except takes an #ECalComponent
+ * instead of an ical string representation and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ */
+void
+e_data_cal_view_notify_components_added_1 (EDataCalView *view, ECalComponent *component)
+{
+ GSList l = {NULL,};
+
+ g_return_if_fail (E_IS_DATA_CAL_VIEW (view));
+ g_return_if_fail (E_IS_CAL_COMPONENT (component));
+
+ l.data = (gpointer) component;
+ e_data_cal_view_notify_components_added (view, &l);
+}
+
+/**
+ * e_data_cal_view_notify_components_modified:
+ * @view: A view object.
+ * @components: List of modified components.
+ *
+ * Notifies all view listeners of the modification of a list of components.
+ *
+ * Like e_data_cal_view_notify_objects_modified() except takes a list of #ECalComponents
+ * instead of a ical string representations and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ */
+void
+e_data_cal_view_notify_components_modified (EDataCalView *view, const GSList *components)
+{
+ EDataCalViewPrivate *priv;
+ const GSList *l;
+
+ g_return_if_fail (view && E_IS_DATA_CAL_VIEW (view));
+ priv = view->priv;
+
+ if (components == NULL)
+ return;
+
+ g_mutex_lock (priv->pending_mutex);
+
+ for (l = components; l; l = l->next) {
+ /* TODO: send add/remove/change as relevant, based on ->ids */
+ ECalComponent *comp = l->data;
+
+ notify_change_component (view, comp);
+ }
+
+ g_mutex_unlock (priv->pending_mutex);
+}
+
+/**
+ * e_data_cal_view_notify_components_modified_1:
+ * @view: A view object.
+ * @component: The modified #ECalComponent.
+ *
+ * Notifies all view listeners of the modification of @component.
+ *
+ * Like e_data_cal_view_notify_objects_modified_1() except takes an #ECalComponent
+ * instead of an ical string representation and uses the #EDataCalView's fields-of-interest
+ * to filter out unwanted information from ical strings sent over the bus.
+ */
+void
+e_data_cal_view_notify_components_modified_1 (EDataCalView *view, ECalComponent *component)
+{
+ GSList l = {NULL,};
+
+ g_return_if_fail (E_IS_DATA_CAL_VIEW (view));
+ g_return_if_fail (E_IS_CAL_COMPONENT (component));
+
+ l.data = (gpointer) component;
+ e_data_cal_view_notify_components_modified (view, &l);
+}
+
/**
* e_data_cal_view_notify_objects_added:
* @view: A view object.
* @objects: List of objects that have been added.
*
* Notifies all view listeners of the addition of a list of objects.
+ *
+ * If possible e_data_cal_view_notify_components_added() should be used
+ * instead.
*/
void
e_data_cal_view_notify_objects_added (EDataCalView *view, const GSList *objects)
@@ -752,6 +1037,9 @@ e_data_cal_view_notify_objects_added (EDataCalView *view, const GSList *objects)
* @object: The object that has been added.
*
* Notifies all the view listeners of the addition of a single object.
+ *
+ * If possible e_data_cal_view_notify_components_added_1() should be used
+ * instead.
*/
void
e_data_cal_view_notify_objects_added_1 (EDataCalView *view, const gchar *object)
@@ -771,6 +1059,9 @@ e_data_cal_view_notify_objects_added_1 (EDataCalView *view, const gchar *object)
* @objects: List of modified objects.
*
* Notifies all view listeners of the modification of a list of objects.
+ *
+ * If possible e_data_cal_view_notify_components_modified() should be used
+ * instead.
*/
void
e_data_cal_view_notify_objects_modified (EDataCalView *view, const GSList *objects)
@@ -800,6 +1091,9 @@ e_data_cal_view_notify_objects_modified (EDataCalView *view, const GSList *objec
* @object: The modified object.
*
* Notifies all view listeners of the modification of a single object.
+ *
+ * If possible e_data_cal_view_notify_components_modified_1() should be used
+ * instead.
*/
void
e_data_cal_view_notify_objects_modified_1 (EDataCalView *view, const gchar *object)
diff --git a/calendar/libedata-cal/e-data-cal-view.h b/calendar/libedata-cal/e-data-cal-view.h
index 06a0f2e..c95bc5e 100644
--- a/calendar/libedata-cal/e-data-cal-view.h
+++ b/calendar/libedata-cal/e-data-cal-view.h
@@ -52,11 +52,19 @@ guint e_data_cal_view_register_gdbus_object (EDataCalView *view, GDBusConnect
const gchar * e_data_cal_view_get_text (EDataCalView *view);
ECalBackendSExp * e_data_cal_view_get_object_sexp (EDataCalView *view);
gboolean e_data_cal_view_object_matches (EDataCalView *view, const gchar *object);
+gboolean e_data_cal_view_component_matches (EDataCalView *view, ECalComponent *component);
gboolean e_data_cal_view_is_started (EDataCalView *view);
gboolean e_data_cal_view_is_completed (EDataCalView *view);
gboolean e_data_cal_view_is_stopped (EDataCalView *view);
GHashTable * e_data_cal_view_get_fields_of_interest (EDataCalView *view);
+gchar *e_data_cal_view_get_component_string (EDataCalView *view, ECalComponent *component);
+
+void e_data_cal_view_notify_components_added (EDataCalView *view, const GSList *objects);
+void e_data_cal_view_notify_components_added_1 (EDataCalView *view, ECalComponent *component);
+void e_data_cal_view_notify_components_modified (EDataCalView *view, const GSList *objects);
+void e_data_cal_view_notify_components_modified_1 (EDataCalView *view, ECalComponent *component);
+
void e_data_cal_view_notify_objects_added (EDataCalView *view, const GSList *objects);
void e_data_cal_view_notify_objects_added_1 (EDataCalView *view, const gchar *object);
void e_data_cal_view_notify_objects_modified (EDataCalView *view, const GSList *objects);
diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c
index 0574158..67230cb 100644
--- a/calendar/libedata-cal/e-data-cal.c
+++ b/calendar/libedata-cal/e-data-cal.c
@@ -1102,13 +1102,13 @@ e_data_cal_respond_get_free_busy (EDataCal *cal, guint32 opid, GError *error)
* @cal: A calendar client interface.
* @error: Operation error, if any, automatically freed if passed it.
* @uid: UID of the object created.
- * @object: The object created as an iCalendar string.
+ * @component: The newly created #ECalComponent.
*
* Notifies listeners of the completion of the create_object method call.
*/
void
e_data_cal_respond_create_object (EDataCal *cal, guint32 opid, GError *error,
- const gchar *uid, const gchar *object)
+ const gchar *uid, ECalComponent *component)
{
gchar *gdbus_uid = NULL;
@@ -1123,7 +1123,7 @@ e_data_cal_respond_create_object (EDataCal *cal, guint32 opid, GError *error,
if (error)
g_error_free (error);
else
- e_cal_backend_notify_object_created (cal->priv->backend, object);
+ e_cal_backend_notify_component_created (cal->priv->backend, component);
}
/**
@@ -1137,7 +1137,7 @@ e_data_cal_respond_create_object (EDataCal *cal, guint32 opid, GError *error,
*/
void
e_data_cal_respond_modify_object (EDataCal *cal, guint32 opid, GError *error,
- const gchar *old_object, const gchar *object)
+ ECalComponent *old_component, ECalComponent *component)
{
op_complete (cal, opid);
@@ -1149,7 +1149,7 @@ e_data_cal_respond_modify_object (EDataCal *cal, guint32 opid, GError *error,
if (error)
g_error_free (error);
else
- e_cal_backend_notify_object_modified (cal->priv->backend, old_object, object);
+ e_cal_backend_notify_component_modified (cal->priv->backend, old_component, component);
}
/**
@@ -1157,15 +1157,16 @@ e_data_cal_respond_modify_object (EDataCal *cal, guint32 opid, GError *error,
* @cal: A calendar client interface.
* @error: Operation error, if any, automatically freed if passed it.
* @uid: UID of the removed object.
- * @old_object: The old object as an iCalendar string.
- * @object: The new object as an iCalendar string. This will not be NULL only
+ * @old_component: The old #ECalComponent.
+ * @component: The new #ECalComponent. This will not be NULL only
* when removing instances of a recurring appointment.
*
* Notifies listeners of the completion of the remove_object method call.
*/
void
e_data_cal_respond_remove_object (EDataCal *cal, guint32 opid, GError *error,
- const ECalComponentId *id, const gchar *old_object, const gchar *object)
+ const ECalComponentId *id,
+ ECalComponent *old_component, ECalComponent *component)
{
op_complete (cal, opid);
@@ -1177,7 +1178,7 @@ e_data_cal_respond_remove_object (EDataCal *cal, guint32 opid, GError *error,
if (error)
g_error_free (error);
else
- e_cal_backend_notify_object_removed (cal->priv->backend, id, old_object, object);
+ e_cal_backend_notify_component_removed (cal->priv->backend, id, old_component, component);
}
/**
diff --git a/calendar/libedata-cal/e-data-cal.h b/calendar/libedata-cal/e-data-cal.h
index c7f5ef6..265eb72 100644
--- a/calendar/libedata-cal/e-data-cal.h
+++ b/calendar/libedata-cal/e-data-cal.h
@@ -137,9 +137,9 @@ void e_data_cal_respond_set_backend_property (EDataCal *cal, guint32 opid, GEr
void e_data_cal_respond_get_object (EDataCal *cal, guint32 opid, GError *error, const gchar *object);
void e_data_cal_respond_get_object_list (EDataCal *cal, guint32 opid, GError *error, const GSList *objects);
void e_data_cal_respond_get_free_busy (EDataCal *cal, guint32 opid, GError *error);
-void e_data_cal_respond_create_object (EDataCal *cal, guint32 opid, GError *error, const gchar *uid, const gchar *object);
-void e_data_cal_respond_modify_object (EDataCal *cal, guint32 opid, GError *error, const gchar *old_object, const gchar *object);
-void e_data_cal_respond_remove_object (EDataCal *cal, guint32 opid, GError *error, const ECalComponentId *id, const gchar *old_object, const gchar *object);
+void e_data_cal_respond_create_object (EDataCal *cal, guint32 opid, GError *error, const gchar *uid, ECalComponent *component);
+void e_data_cal_respond_modify_object (EDataCal *cal, guint32 opid, GError *error, ECalComponent *old_component, ECalComponent *component);
+void e_data_cal_respond_remove_object (EDataCal *cal, guint32 opid, GError *error, const ECalComponentId *id, ECalComponent *old_component, ECalComponent *component);
void e_data_cal_respond_receive_objects (EDataCal *cal, guint32 opid, GError *error);
void e_data_cal_respond_send_objects (EDataCal *cal, guint32 opid, GError *error, const GSList *users, const gchar *calobj);
void e_data_cal_respond_get_attachment_uris (EDataCal *cal, guint32 opid, GError *error, const GSList *attachments);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]