summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2013-07-22 18:04:11 +0200
committerMilan Crha <mcrha@redhat.com>2013-07-22 18:04:11 +0200
commit7166a792fe94aaf48bac3665cb6fc9aa47c9c94d (patch)
tree3c9159ed97f3823b5d8bfc09325e2850fbb54880
parent86d11ac2e520cc205e0ead86fd2bde4e2a026270 (diff)
downloadevolution-data-server-7166a792fe94aaf48bac3665cb6fc9aa47c9c94d.tar.gz
Bug #704618 - Missing detached instances in get_object() response
-rw-r--r--calendar/backends/http/e-cal-backend-http.c20
-rw-r--r--calendar/libedata-cal/e-cal-backend-store.c52
-rw-r--r--calendar/libedata-cal/e-cal-backend-store.h3
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 eef1f8b1e..5800a042b 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 1fa11207d..2184bd88b 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 7816cfd23..79152fd95 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