summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-05-17 09:45:24 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2011-05-17 10:45:42 +0200
commita391ae860a24cdf11551ea8f6ccccbd73835034e (patch)
tree006de741c3c561bc7e70f32cdd1665e601ce2206
parentccaa11856590745aea28532cce67a66af06daa18 (diff)
downloadevolution-data-server-pohly-gnome-2-32.tar.gz
calendar: include rid in "objects-removed" ECalView signalpohly-gnome-2-32
Since migration to D-Bus for libecal<->EDS communication, the RECURRENCE-ID (rid) has not been sent in the "objects-removed" signal. As a result, a backend could not communicate the removal of specific recurrences. This patch adds the rid after a newline to the string stored internally and transferred via D-Bus. Because the newline is only added when needed, traditional uid-only removals look the same as before and continue to work with older versions of libecal. A uid+rid combination will look like an unknown uid to an older libecal which does not know how to split them. Therefore the D-Bus API is considered unchanged and the interface number is not increased. Whether clients really interpret "objects-removed" with empty rid (= parent removed) or valid rid (= child removed) correctly is outside the scope of this patch.
-rw-r--r--calendar/libecal/e-cal-view.c17
-rw-r--r--calendar/libedata-cal/e-data-cal-view.c19
2 files changed, 27 insertions, 9 deletions
diff --git a/calendar/libecal/e-cal-view.c b/calendar/libecal/e-cal-view.c
index af132ca17..6319c58ca 100644
--- a/calendar/libecal/e-cal-view.c
+++ b/calendar/libecal/e-cal-view.c
@@ -92,9 +92,18 @@ build_id_list (const gchar * const *seq)
list = NULL;
for (i = 0; seq[i]; i++) {
ECalComponentId *id;
+ const gchar * eol;
+
id = g_new (ECalComponentId, 1);
- id->uid = g_strdup (seq[i]);
- id->rid = NULL; /* TODO */
+ /* match encoding as in notify_remove() in e-data-cal-view.c: <uid>[\n<rid>] */
+ eol = strchr (seq[i], '\n');
+ if (eol) {
+ id->uid = g_strndup (seq[i], eol - seq[i]);
+ id->rid = g_strdup (eol + 1);
+ } else {
+ id->uid = g_strdup (seq[i]);
+ id->rid = NULL;
+ }
list = g_list_prepend (list, id);
}
@@ -138,14 +147,14 @@ objects_modified_cb (EGdbusCalView *gdbus_calview, const gchar * const *objects,
}
static void
-objects_removed_cb (EGdbusCalView *gdbus_calview, const gchar * const *uids, ECalView *view)
+objects_removed_cb (EGdbusCalView *gdbus_calview, const gchar * const *seq, ECalView *view)
{
GList *list;
g_return_if_fail (E_IS_CAL_VIEW (view));
g_object_ref (view);
- list = build_id_list (uids);
+ list = build_id_list (seq);
g_signal_emit (G_OBJECT (view), signals[OBJECTS_REMOVED], 0, list);
diff --git a/calendar/libedata-cal/e-data-cal-view.c b/calendar/libedata-cal/e-data-cal-view.c
index 394acf0d9..7fc4a4dcb 100644
--- a/calendar/libedata-cal/e-data-cal-view.c
+++ b/calendar/libedata-cal/e-data-cal-view.c
@@ -189,7 +189,7 @@ send_pending_removes (EDataCalView *view)
if (priv->removes->len == 0)
return;
- /* TODO: send ECalComponentIds as a list of pairs */
+ /* send ECalComponentIds as <uid>[\n<rid>], as encoded in notify_remove() */
e_gdbus_cal_view_emit_objects_removed (view->priv->gdbus_object, (const gchar * const *) priv->removes->data);
reset_array (priv->removes);
}
@@ -268,7 +268,8 @@ static void
notify_remove (EDataCalView *view, ECalComponentId *id)
{
EDataCalViewPrivate *priv = view->priv;
- gchar *uid;
+ gchar *ids;
+ size_t uid_len, rid_len;
send_pending_adds (view);
send_pending_changes (view);
@@ -277,9 +278,17 @@ notify_remove (EDataCalView *view, ECalComponentId *id)
send_pending_removes (view);
}
- /* TODO: store ECalComponentId instead of just uid*/
- uid = g_strdup (id->uid);
- g_array_append_val (priv->removes, uid);
+ /* store ECalComponentId as <uid>[\n<rid>] (matches D-Bus API) */
+ uid_len = id->uid ? strlen (id->uid) : 0;
+ rid_len = id->rid ? strlen (id->rid) : 0;
+ ids = g_malloc (uid_len + rid_len + (rid_len ? 2 : 1));
+ if (uid_len)
+ strcpy (ids, id->uid);
+ if (rid_len) {
+ ids[uid_len] = '\n';
+ strcpy (ids + uid_len + 1, id->rid);
+ }
+ g_array_append_val (priv->removes, ids);
g_hash_table_remove (priv->ids, id);