[evolution-data-server] Fixes bug 184554 (bnc) - multiple groupwise open noticies
- From: Chenthill Palanisamy <pchen src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-data-server] Fixes bug 184554 (bnc) - multiple groupwise open noticies
- Date: Wed, 20 May 2009 06:26:15 -0400 (EDT)
commit 491efa22e6fed4da60292edf5aaabcde857fd1e2
Author: Chenthill Palanisamy <pchenthill novell com>
Date: Wed May 20 15:22:22 2009 +0530
Fixes bug 184554 (bnc) - multiple groupwise open noticies
Store the last modified time from the server to avoid false
notifications.
---
.../groupwise/e-cal-backend-groupwise-utils.c | 12 ++-
.../backends/groupwise/e-cal-backend-groupwise.c | 161 ++++++++++++--------
servers/groupwise/e-gw-item.c | 32 ++++
servers/groupwise/e-gw-item.h | 2 +
4 files changed, 141 insertions(+), 66 deletions(-)
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
index a993880..d1b3192 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
@@ -766,6 +766,7 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
value = icaltime_as_ical_string_r (itt_utc);
e_gw_item_set_creation_date (item, value);
g_free (value);
+ e_cal_component_free_icaltimetype (dt.value);
} else {
struct icaltimetype itt;
@@ -775,7 +776,6 @@ set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBacke
g_free (value);
}
- e_cal_component_free_icaltimetype (dt.value);
dt.value = NULL;
/* classification */
@@ -1127,6 +1127,16 @@ e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw)
e_cal_component_set_created (comp, &itt_utc);
e_cal_component_set_dtstamp (comp, &itt_utc);
}
+
+ t = e_gw_item_get_modified_date (item);
+ if (t) {
+ itt_utc = icaltime_from_string (t);
+
+ icaltimezone_convert_time (&itt_utc, (icaltimezone*) icaltime_get_timezone (itt_utc), icaltimezone_get_utc_timezone ());
+ icaltime_set_timezone (&itt_utc, icaltimezone_get_utc_timezone ());
+
+ e_cal_component_set_last_modified (comp, &itt_utc);
+ }
/* categories */
category_ids = e_gw_item_get_categories (item);
diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c
index 5ef5669..a5dd96b 100644
--- a/calendar/backends/groupwise/e-cal-backend-groupwise.c
+++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c
@@ -420,6 +420,7 @@ get_deltas (gpointer handle)
EGwItem *item = NULL;
ECalComponent *modified_comp = NULL, *cache_comp = NULL;
char *cache_comp_str = NULL, *modif_comp_str, *rid = NULL;
+ icaltimetype *tt = NULL, *c_tt = NULL;
const char *uid;
int r_key;
@@ -435,20 +436,41 @@ get_deltas (gpointer handle)
e_cal_component_get_uid (modified_comp, &uid);
cache_comp = e_cal_backend_cache_get_component (cache, uid, rid);
e_cal_component_commit_sequence (modified_comp);
- e_cal_component_commit_sequence (cache_comp);
- cache_comp_str = e_cal_component_get_as_string (cache_comp);
- modif_comp_str = e_cal_component_get_as_string (modified_comp);
- e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp_str, modif_comp_str);
- g_free (modif_comp_str);
- g_free (cache_comp_str);
- g_free (rid);
- cache_comp_str = NULL;
- e_cal_backend_cache_put_component (cache, modified_comp);
+ e_cal_component_get_last_modified (modified_comp, &tt);
+
+ if (cache_comp) {
+ e_cal_component_get_last_modified (cache_comp, &c_tt);
+ e_cal_component_commit_sequence (cache_comp);
+ }
+
+ if (!c_tt || icaltime_compare (*tt, *c_tt) == 1)
+ {
+ modif_comp_str = e_cal_component_get_as_string (modified_comp);
+
+ if (cache_comp) {
+ cache_comp_str = e_cal_component_get_as_string (cache_comp);
+ e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp_str, modif_comp_str);
+ } else {
+ e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), modif_comp_str);
+ }
+
+ g_free (modif_comp_str);
+ g_free (cache_comp_str);
+ g_free (rid);
+ cache_comp_str = NULL;
+ e_cal_backend_cache_put_component (cache, modified_comp);
+ }
+ e_cal_component_free_icaltimetype (tt);
+
+ if (c_tt)
+ e_cal_component_free_icaltimetype (c_tt);
g_object_unref (item);
g_object_unref (modified_comp);
- g_object_unref (cache_comp);
+
+ if (cache_comp)
+ g_object_unref (cache_comp);
}
e_file_cache_thaw_changes (E_FILE_CACHE (cache));
@@ -1936,6 +1958,65 @@ sanitize_component (ECalBackendSync *backend, ECalComponent *comp, char *server_
g_string_free (str, TRUE);
}
+static EGwConnectionStatus
+update_from_server (ECalBackendGroupwise *cbgw, GSList *uid_list, char **calobj, ECalComponent *comp)
+{
+ EGwConnectionStatus stat;
+ ECalBackendGroupwisePrivate *priv;
+ ECalBackendSync *backend;
+ GList *list = NULL, *tmp;
+ GSList *l;
+ GPtrArray *uid_array = g_ptr_array_new ();
+ int i;
+
+ priv = cbgw->priv;
+ backend = E_CAL_BACKEND_SYNC (cbgw);
+
+ for (l = uid_list; l; l = g_slist_next (l)) {
+ g_ptr_array_add (uid_array, l->data);
+ }
+
+ /* convert uid_list to GPtrArray and get the items in a list */
+ stat = e_gw_connection_get_items_from_ids (priv->cnc,
+ priv->container_id,
+ "attachments recipients message recipientStatus default peek",
+ uid_array, &list);
+
+ if (stat != E_GW_CONNECTION_STATUS_OK || (list == NULL) || (g_list_length (list) == 0)) {
+ g_ptr_array_free (uid_array, TRUE);
+ return GNOME_Evolution_Calendar_OtherError;
+ }
+
+ comp = g_object_ref ( (ECalComponent *) list->data );
+ /* convert items into components and add them to the cache */
+ for (i=0, tmp = list; tmp ; tmp = g_list_next (tmp), i++) {
+ ECalComponent *e_cal_comp;
+ EGwItem *item;
+
+ item = (EGwItem *) tmp->data;
+ e_cal_comp = e_gw_item_to_cal_component (item, cbgw);
+ e_cal_component_commit_sequence (e_cal_comp);
+ sanitize_component (backend, e_cal_comp, g_ptr_array_index (uid_array, i));
+ e_cal_backend_cache_put_component (priv->cache, e_cal_comp);
+
+ if (i == 0) {
+ *calobj = e_cal_component_get_as_string (e_cal_comp);
+ }
+
+ if (i != 0) {
+ char *temp;
+ temp = e_cal_component_get_as_string (e_cal_comp);
+ e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), temp);
+ g_free (temp);
+ }
+
+ g_object_unref (e_cal_comp);
+ }
+ g_ptr_array_free (uid_array, TRUE);
+
+ return E_GW_CONNECTION_STATUS_OK;
+}
+
static ECalBackendSyncStatus
e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal, char **calobj, char **uid)
{
@@ -1944,9 +2025,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
icalcomponent *icalcomp;
ECalComponent *comp;
EGwConnectionStatus status;
- char *server_uid = NULL;
- GSList *uid_list = NULL, *l;
- int i;
+ GSList *uid_list = NULL;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
@@ -1998,59 +2077,11 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
return GNOME_Evolution_Calendar_Success;
}
- if (g_slist_length (uid_list) == 1) {
- server_uid = (char *) uid_list->data;
- sanitize_component (backend, comp, server_uid);
- g_free (server_uid);
- /* if successful, update the cache */
- e_cal_backend_cache_put_component (priv->cache, comp);
- *calobj = e_cal_component_get_as_string (comp);
- } else {
- EGwConnectionStatus stat;
- GList *list = NULL, *tmp;
- GPtrArray *uid_array = g_ptr_array_new ();
- for (l = uid_list; l; l = g_slist_next (l)) {
- g_ptr_array_add (uid_array, l->data);
- }
-
- /* convert uid_list to GPtrArray and get the items in a list */
- stat = e_gw_connection_get_items_from_ids (priv->cnc,
- priv->container_id,
- "attachments recipients message recipientStatus default peek",
- uid_array, &list);
-
- if (stat != E_GW_CONNECTION_STATUS_OK || (list == NULL) || (g_list_length (list) == 0)) {
- g_ptr_array_free (uid_array, TRUE);
- return GNOME_Evolution_Calendar_OtherError;
- }
-
- comp = g_object_ref ( (ECalComponent *) list->data );
- /* convert items into components and add them to the cache */
- for (i=0, tmp = list; tmp ; tmp = g_list_next (tmp), i++) {
- ECalComponent *e_cal_comp;
- EGwItem *item;
-
- item = (EGwItem *) tmp->data;
- e_cal_comp = e_gw_item_to_cal_component (item, cbgw);
- e_cal_component_commit_sequence (e_cal_comp);
- sanitize_component (backend, e_cal_comp, g_ptr_array_index (uid_array, i));
- e_cal_backend_cache_put_component (priv->cache, e_cal_comp);
-
- if (i == 0) {
- *calobj = e_cal_component_get_as_string (e_cal_comp);
- }
-
- if (i != 0) {
- char *temp;
- temp = e_cal_component_get_as_string (e_cal_comp);
- e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), temp);
- g_free (temp);
- }
+ /* Get the item back from server to update the last-modified time */
+ status = update_from_server (cbgw, uid_list, calobj, comp);
+ if (status != E_GW_CONNECTION_STATUS_OK)
+ return GNOME_Evolution_Calendar_OtherError;
- g_object_unref (e_cal_comp);
- }
- g_ptr_array_free (uid_array, TRUE);
- }
break;
default :
break;
diff --git a/servers/groupwise/e-gw-item.c b/servers/groupwise/e-gw-item.c
index 7aa3b7d..5c5517c 100644
--- a/servers/groupwise/e-gw-item.c
+++ b/servers/groupwise/e-gw-item.c
@@ -45,6 +45,7 @@ struct _EGwItemPrivate {
char *end_date;
char *due_date;
char *completed_date;
+ char *modified_date;
gboolean completed;
gboolean is_allday_event;
char *subject;
@@ -467,6 +468,11 @@ e_gw_item_dispose (GObject *object)
priv->delivered_date = NULL;
}
+ if (priv->modified_date) {
+ g_free (priv->modified_date);
+ priv->modified_date = NULL;
+ }
+
if (priv->start_date) {
g_free (priv->start_date);
priv->start_date = NULL;
@@ -526,6 +532,7 @@ e_gw_item_init (EGwItem *item, EGwItemClass *klass)
priv->item_type = E_GW_ITEM_TYPE_UNKNOWN;
priv->creation_date = NULL;
priv->delivered_date = NULL;
+ priv->modified_date = NULL;
priv->start_date = NULL;
priv->end_date = NULL;
priv->due_date = NULL;
@@ -1848,6 +1855,13 @@ e_gw_item_new_from_soap_parameter (const char *email, const char *container, Sou
g_free (value);
g_free (formatted_date);
+ } else if (!g_ascii_strcasecmp (name, "modified")) {
+ char *formatted_date;
+ value = soup_soap_parameter_get_string_value (child);
+ formatted_date = e_gw_connection_format_date_string (value);
+ e_gw_item_set_modified_date (item, formatted_date);
+ g_free (value);
+ g_free (formatted_date);
} else if (!g_ascii_strcasecmp (name, "distribution")) {
SoupSoapParameter *tp;
@@ -2207,6 +2221,24 @@ e_gw_item_set_delivered_date (EGwItem *item, const char *new_date)
item->priv->delivered_date = g_strdup (new_date);
}
+const char *
+e_gw_item_get_modified_date (EGwItem *item)
+{
+ g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
+
+ return item->priv->modified_date;
+}
+
+void
+e_gw_item_set_modified_date (EGwItem *item, const char *new_date)
+{
+ g_return_if_fail (E_IS_GW_ITEM (item));
+
+ if (item->priv->modified_date)
+ g_free (item->priv->modified_date);
+ item->priv->modified_date = g_strdup (new_date);
+}
+
char *
e_gw_item_get_start_date (EGwItem *item)
{
diff --git a/servers/groupwise/e-gw-item.h b/servers/groupwise/e-gw-item.h
index 4d14f20..f40441e 100644
--- a/servers/groupwise/e-gw-item.h
+++ b/servers/groupwise/e-gw-item.h
@@ -173,6 +173,8 @@ char *e_gw_item_get_creation_date (EGwItem *item);
void e_gw_item_set_creation_date (EGwItem *item, const char *new_date);
char *e_gw_item_get_delivered_date (EGwItem *item);
void e_gw_item_set_delivered_date (EGwItem *item, const char *new_date);
+const char *e_gw_item_get_modified_date (EGwItem *item);
+void e_gw_item_set_modified_date (EGwItem *item, const char *new_date);
char *e_gw_item_get_start_date (EGwItem *item);
void e_gw_item_set_start_date (EGwItem *item, const char *new_date);
char *e_gw_item_get_completed_date (EGwItem *item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]