[evolution-data-server/gnome-3-8] Bug #704618 - Missing detached instances in get_object() response
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-8] Bug #704618 - Missing detached instances in get_object() response
- Date: Mon, 22 Jul 2013 16:04:31 +0000 (UTC)
commit 7166a792fe94aaf48bac3665cb6fc9aa47c9c94d
Author: Milan Crha <mcrha redhat com>
Date: Mon Jul 22 18:04:11 2013 +0200
Bug #704618 - Missing detached instances in get_object() response
calendar/backends/http/e-cal-backend-http.c | 20 +++++++----
calendar/libedata-cal/e-cal-backend-store.c | 52 +++++++++++++++++++++++++++
calendar/libedata-cal/e-cal-backend-store.h | 3 ++
3 files changed, 68 insertions(+), 7 deletions(-)
---
diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c
index eef1f8b..5800a04 100644
--- a/calendar/backends/http/e-cal-backend-http.c
+++ b/calendar/backends/http/e-cal-backend-http.c
@@ -1034,14 +1034,20 @@ e_cal_backend_http_get_object (ECalBackendSync *backend,
return;
}
- comp = e_cal_backend_store_get_component (priv->store, uid, rid);
- if (!comp) {
- g_propagate_error (error, EDC_ERROR (ObjectNotFound));
- return;
- }
+ if (rid && *rid) {
+ comp = e_cal_backend_store_get_component (priv->store, uid, rid);
+ if (!comp) {
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ return;
+ }
- *object = e_cal_component_get_as_string (comp);
- g_object_unref (comp);
+ *object = e_cal_component_get_as_string (comp);
+ g_object_unref (comp);
+ } else {
+ *object = e_cal_backend_store_get_components_by_uid_as_ical_string (priv->store, uid);
+ if (!*object)
+ g_propagate_error (error, EDC_ERROR (ObjectNotFound));
+ }
}
/* Add_timezone handler for the file backend */
diff --git a/calendar/libedata-cal/e-cal-backend-store.c b/calendar/libedata-cal/e-cal-backend-store.c
index 1fa1120..2184bd8 100644
--- a/calendar/libedata-cal/e-cal-backend-store.c
+++ b/calendar/libedata-cal/e-cal-backend-store.c
@@ -1313,6 +1313,58 @@ e_cal_backend_store_get_components_by_uid (ECalBackendStore *store,
}
/**
+ * e_cal_backend_store_get_components_by_uid_as_ical_string:
+ * @store: an #ECalBackendStore
+ * @uid: a component UID
+ *
+ * Returns: Newly allocated ical string containing all
+ * instances with given @uid. Free returned pointer with g_free(),
+ * when no longer needed.
+ *
+ * Since: 3.8.4
+ **/
+gchar *
+e_cal_backend_store_get_components_by_uid_as_ical_string (ECalBackendStore *store,
+ const gchar *uid)
+{
+ GSList *comps;
+ gchar *ical_string = NULL;
+
+ g_return_val_if_fail (E_IS_CAL_BACKEND_STORE (store), NULL);
+ g_return_val_if_fail (uid != NULL, NULL);
+
+ comps = e_cal_backend_store_get_components_by_uid (store, uid);
+ if (!comps)
+ return NULL;
+
+ if (!comps->next) {
+ ical_string = e_cal_component_get_as_string (comps->data);
+ } else {
+ GSList *citer;
+ icalcomponent *icalcomp;
+
+ /* if we have detached recurrences, return a VCALENDAR */
+ icalcomp = e_cal_util_new_top_level ();
+
+ for (citer = comps; citer; citer = g_slist_next (citer)) {
+ ECalComponent *comp = citer->data;
+
+ icalcomponent_add_component (
+ icalcomp,
+ icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp)));
+ }
+
+ ical_string = icalcomponent_as_ical_string_r (icalcomp);
+
+ icalcomponent_free (icalcomp);
+ }
+
+ g_slist_free_full (comps, g_object_unref);
+
+ return ical_string;
+}
+
+/**
* e_cal_backend_store_get_components:
*
* Since: 2.28
diff --git a/calendar/libedata-cal/e-cal-backend-store.h b/calendar/libedata-cal/e-cal-backend-store.h
index 7816cfd..79152fd 100644
--- a/calendar/libedata-cal/e-cal-backend-store.h
+++ b/calendar/libedata-cal/e-cal-backend-store.h
@@ -138,6 +138,9 @@ gboolean e_cal_backend_store_set_default_timezone
GSList * e_cal_backend_store_get_components_by_uid
(ECalBackendStore *store,
const gchar *uid);
+gchar * e_cal_backend_store_get_components_by_uid_as_ical_string
+ (ECalBackendStore *store,
+ const gchar *uid);
GSList * e_cal_backend_store_get_components
(ECalBackendStore *store);
GSList * e_cal_backend_store_get_components_occuring_in_range
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]