[evolution-patches] patch for #66230 (calendar)
- From: Rodrigo Moya <rodrigo novell com>
- To: Evolution Patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] patch for #66230 (calendar)
- Date: Tue, 28 Sep 2004 17:21:12 +0200
--
Rodrigo Moya <rodrigo novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.324.2.4
diff -u -p -r1.324.2.4 ChangeLog
--- ChangeLog 24 Sep 2004 14:24:03 -0000 1.324.2.4
+++ ChangeLog 28 Sep 2004 15:19:55 -0000
@@ -1,3 +1,11 @@
+2004-09-28 Rodrigo Moya <rodrigo novell com>
+
+ Fixes #66230
+
+ * backends/http/e-cal-backend-http.c (retrieval_done): do a more clever
+ update of the cache, so that we correctly notify listeners of updates,
+ additions and removals.
+
2004-09-24 JP Rosevear <jpr novell com>
Fixes #66383, From David Malcolm <dmalcolm redhat com>
Index: backends/http/e-cal-backend-http.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/http/e-cal-backend-http.c,v
retrieving revision 1.19
diff -u -p -r1.19 e-cal-backend-http.c
--- backends/http/e-cal-backend-http.c 27 May 2004 15:27:42 -0000 1.19
+++ backends/http/e-cal-backend-http.c 28 Sep 2004 15:19:55 -0000
@@ -193,6 +193,18 @@ webcal_to_http_method (const gchar *webc
return g_strconcat ("http://", webcal_str + sizeof ("webcal://") - 1, NULL);
}
+static gboolean
+notify_and_remove_from_cache (gpointer key, gpointer value, gpointer user_data)
+{
+ const char *uid = key;
+ const char *calobj = value;
+ ECalBackendHttp *cbhttp = E_CAL_BACKEND_HTTP (user_data);
+
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbhttp), uid, calobj);
+
+ return TRUE;
+}
+
static void
retrieval_done (SoupMessage *msg, ECalBackendHttp *cbhttp)
{
@@ -201,6 +213,8 @@ retrieval_done (SoupMessage *msg, ECalBa
icalcomponent_kind kind;
const char *newuri;
char *str;
+ GHashTable *old_cache;
+ GList *comps_in_cache;
priv = cbhttp->priv;
@@ -258,7 +272,19 @@ retrieval_done (SoupMessage *msg, ECalBa
}
/* Update cache */
- e_file_cache_clean (E_FILE_CACHE (priv->cache));
+ old_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ comps_in_cache = e_cal_backend_cache_get_components (priv->cache);
+ while (comps_in_cache != NULL) {
+ const char *uid;
+ ECalComponent *comp = comps_in_cache->data;
+
+ e_cal_component_get_uid (comp, &uid);
+ g_hash_table_insert (old_cache, g_strdup (uid), e_cal_component_get_as_string (comp));
+
+ comps_in_cache = g_list_remove (comps_in_cache, comps_in_cache->data);
+ g_object_unref (comp);
+ }
kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbhttp));
subcomp = icalcomponent_get_first_component (icalcomp, ICAL_ANY_COMPONENT);
@@ -270,9 +296,20 @@ retrieval_done (SoupMessage *msg, ECalBa
if (subcomp_kind == kind) {
comp = e_cal_component_new ();
if (e_cal_component_set_icalcomponent (comp, subcomp)) {
+ const char *uid, *orig_key, *orig_value;
+
e_cal_backend_cache_put_component (priv->cache, comp);
- e_cal_backend_notify_object_created (E_CAL_BACKEND (cbhttp),
- icalcomponent_as_ical_string (subcomp));
+
+ e_cal_component_get_uid (comp, &uid);
+ if (g_hash_table_lookup_extended (old_cache, uid, &orig_key, &orig_value)) {
+ e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbhttp),
+ orig_value,
+ icalcomponent_as_ical_string (subcomp));
+ g_hash_table_remove (old_cache, uid);
+ } else {
+ e_cal_backend_notify_object_created (E_CAL_BACKEND (cbhttp),
+ icalcomponent_as_ical_string (subcomp));
+ }
}
g_object_unref (comp);
@@ -288,6 +325,10 @@ retrieval_done (SoupMessage *msg, ECalBa
subcomp = icalcomponent_get_next_component (icalcomp, kind);
}
+
+ /* notify the removals */
+ g_hash_table_foreach_remove (old_cache, (GHRFunc) notify_and_remove_from_cache, cbhttp);
+ g_hash_table_destroy (old_cache);
/* free memory */
icalcomponent_free (icalcomp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]