Re: [evolution-patches] Fix for the bug #61865 and 'delta' related issues[GW Calendar]



Resending the patch with the leaks fixed and an additional check for
handling icalid being null in some GW items (to handle server instances
that do not have the relevant fixes, gracefully).
kindly review the same


thanks,
harish
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/ChangeLog,v
retrieving revision 1.160
diff -u -p -r1.160 ChangeLog
--- ChangeLog	21 Sep 2004 22:39:33 -0000	1.160
+++ ChangeLog	22 Sep 2004 16:05:09 -0000
@@ -1,3 +1,10 @@
+2004-09-22  Harish Krishnaswamy  <kharish novell com>
+
+	* libedataserver/e-file-cache.[ch]: 
+	(e_file_cache_get_keys): utility function that allows to get 
+	 a list of the keys of all the items in the cache. Used by 
+	 the fix for bug #61865	
+
 2004-09-21  Hans Petter Jansson  <hpj ximian com>
 
 	* libdb/dbinc/mutex.h
Index: libedataserver/e-file-cache.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-file-cache.c,v
retrieving revision 1.10
diff -u -p -r1.10 e-file-cache.c
--- libedataserver/e-file-cache.c	25 Aug 2004 14:39:18 -0000	1.10
+++ libedataserver/e-file-cache.c	22 Sep 2004 16:05:09 -0000
@@ -366,6 +366,24 @@ e_file_cache_get_objects (EFileCache *ca
 }
 
 /**
+ * e_file_cache_get_keys:
+ */
+GSList *
+e_file_cache_get_keys (EFileCache *cache)
+{
+	EFileCachePrivate *priv;
+	GSList *list = NULL;
+
+	g_return_val_if_fail (E_IS_FILE_CACHE (cache), NULL);
+
+	priv = cache->priv;
+
+	e_xmlhash_foreach_key (priv->xml_hash, (EXmlHashFunc) add_key_to_list, &list);
+
+	return list;
+}
+
+/**
  * e_file_cache_add_object:
  */
 gboolean
Index: libedataserver/e-file-cache.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserver/e-file-cache.h,v
retrieving revision 1.4
diff -u -p -r1.4 e-file-cache.h
--- libedataserver/e-file-cache.h	27 May 2004 15:26:30 -0000	1.4
+++ libedataserver/e-file-cache.h	22 Sep 2004 16:05:09 -0000
@@ -51,6 +51,7 @@ gboolean    e_file_cache_clean (EFileCac
 
 const char *e_file_cache_get_object (EFileCache *cache, const char *key);
 GSList     *e_file_cache_get_objects (EFileCache *cache);
+GSList     *e_file_cache_get_keys (EFileCache *cache);
 gboolean    e_file_cache_add_object (EFileCache *cache, const char *key, const char *value);
 gboolean    e_file_cache_replace_object (EFileCache *cache, const char *key, const char *new_value);
 gboolean    e_file_cache_remove_object (EFileCache *cache, const char *key);
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.331
diff -u -p -r1.331 ChangeLog
--- calendar/ChangeLog	8 Sep 2004 11:38:58 -0000	1.331
+++ calendar/ChangeLog	22 Sep 2004 16:05:10 -0000
@@ -1,3 +1,31 @@
+2004-09-22  Harish Krishnaswamy  <kharish novell com>
+
+	* backends/groupwise/e-cal-backend-groupwise-utils.[ch]:
+	(e_gw_connection_send_appointment): Allow callers to get the 
+	sent item from the server to ensure the iCalId of the component
+	is in sync with the server - even if it had been obtained from
+	a different client via itip.
+	(e_gw_item_to_cal_component) : additional check to ensure icalid
+	is not null in the item, so we would not crash against server instances
+	that may not send this properly.
+
+	Fixes #61865	
+	* backends/groupwise/e-cal-backend-groupwise.c: 
+	(get_deltas) : Replace getDeltasRequest by getQuickMessages calls
+	and compute deltas like adds, modify and deletes.
+	(connect_to_server): Do not recreate cache everytime and use the 
+	getQuickMessages to pull in the changes from server. The existing
+	code was a work-around till this fix was in place.
+
+	(e_cal_backend_groupwise_create_object), (receive_object):
+	Use the modified  e_gw_connection_send_appointment calls and
+	update the cache and cal clients appropriately.
+
+	* libedata-cal/e-cal-backend-cache.[ch]:
+	(e_cal_backend_cache_get_keys): Adding a function that allows to 
+	retrieve a list of the keys of all components from the cache.
+	
+
 2004-09-08  Chenthill Palanisamy <pchenthill novell com>
 
 	* backends/groupwise/e-cal-backend-groupwise-utils.c
Index: calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c,v
retrieving revision 1.34
diff -u -p -r1.34 e-cal-backend-groupwise-utils.c
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	8 Sep 2004 11:38:58 -0000	1.34
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	22 Sep 2004 16:05:10 -0000
@@ -382,7 +382,7 @@ e_gw_item_to_cal_component (EGwItem *ite
 	ECalComponent *comp;
 	ECalComponentText text;
 	ECalComponentDateTime dt;
-	const char *description;
+	const char *description, *uid;
 	char *t, *name;
 	GList *category_ids, *categories;
 	GHashTable *categories_by_id;
@@ -427,8 +427,13 @@ e_gw_item_to_cal_component (EGwItem *ite
 	}
 
 	/* UID */
-	e_cal_component_set_uid (comp, e_gw_item_get_icalid (item));
-
+	uid = e_gw_item_get_icalid (item);
+	if (uid)
+		e_cal_component_set_uid (comp, e_gw_item_get_icalid (item));
+	else {
+		g_object_unref (comp);
+		return NULL;
+	}
 	/* summary */
 	text.value = e_gw_item_get_subject (item);
 	text.altrep = NULL;
@@ -670,13 +675,15 @@ e_gw_item_to_cal_component (EGwItem *ite
 }
 
 EGwConnectionStatus
-e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, ECalComponent *comp, icalproperty_method method, gboolean *remove)
+e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const char *container, ECalComponent *comp, icalproperty_method method, gboolean *remove, ECalComponent **created_comp)
 {
+	EGwConnection *cnc;
 	EGwConnectionStatus status;
 	icalparameter_partstat partstat;
 	char *item_id;
 	
 
+	cnc = e_cal_backend_groupwise_get_connection (cbgw);
 	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
 	g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
 
@@ -764,8 +771,14 @@ e_gw_connection_send_appointment (EGwCon
 		*remove = TRUE;
 		break;
 	default:
-		status = E_GW_CONNECTION_STATUS_INVALID_OBJECT;
-	}	
+		return E_GW_CONNECTION_STATUS_INVALID_OBJECT;
+	}
+	if (!*remove && status == E_GW_CONNECTION_STATUS_OK) {
+		EGwItem *item;
+
+		status = e_gw_connection_get_item (cnc, container, item_id, &item);
+		*created_comp = e_gw_item_to_cal_component (item, cbgw);
+	}
 
 	return status;
 }
Index: calendar/backends/groupwise/e-cal-backend-groupwise-utils.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise-utils.h,v
retrieving revision 1.11
diff -u -p -r1.11 e-cal-backend-groupwise-utils.h
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.h	10 Aug 2004 12:27:43 -0000	1.11
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.h	22 Sep 2004 16:05:10 -0000
@@ -44,7 +44,7 @@ void          e_gw_item_set_changes (EGw
  * Connection-related utility functions
  */
 EGwConnectionStatus e_gw_connection_create_appointment (EGwConnection *cnc, const char *container, ECalBackendGroupwise *cbgw, ECalComponent *comp, GSList **id_list);
-EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, ECalComponent *comp, icalproperty_method method, gboolean *remove);
+EGwConnectionStatus e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const char *container, ECalComponent *comp, icalproperty_method method, gboolean *remove, ECalComponent **created_comp);
 EGwConnectionStatus e_gw_connection_get_freebusy_info (EGwConnection *cnc, GList *users, time_t start, time_t end, GList **freebusy, icaltimezone *default_zone);
 
 /*
Index: calendar/backends/groupwise/e-cal-backend-groupwise.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise.c,v
retrieving revision 1.94
diff -u -p -r1.94 e-cal-backend-groupwise.c
--- calendar/backends/groupwise/e-cal-backend-groupwise.c	8 Sep 2004 07:48:31 -0000	1.94
+++ calendar/backends/groupwise/e-cal-backend-groupwise.c	22 Sep 2004 16:05:11 -0000
@@ -56,7 +56,6 @@ struct _ECalBackendGroupwisePrivate {
 	GHashTable *categories_by_id;
 	GHashTable *categories_by_name;
 
-
 	/* fields for storing info while offline */
 	char *user_email;
 };
@@ -68,7 +67,7 @@ static void e_cal_backend_groupwise_fina
 static ECalBackendClass *parent_class = NULL;
 
 /* Time interval in milliseconds for obtaining changes from server and refresh the cache. */
-#define CACHE_REFRESH_INTERVAL 600000
+#define CACHE_REFRESH_INTERVAL 60000
 #define CURSOR_ITEM_LIMIT 100
 
 EGwConnection *
@@ -114,7 +113,7 @@ populate_cache (ECalBackendGroupwise *cb
         ECalComponent *comp;
         GList *list = NULL, *l;
 	gboolean done = FALSE;
-	int cursor = 0;
+	int cursor = 100;
 	
 	priv = cbgw->priv;
 	
@@ -153,7 +152,12 @@ populate_cache (ECalBackendGroupwise *cb
 			comp = e_gw_item_to_cal_component (item, cbgw);
 			g_object_unref (item);
 			if (E_IS_CAL_COMPONENT (comp)) {
+				char *comp_str;
+				
 				e_cal_component_commit_sequence (comp);
+				comp_str = e_cal_component_get_as_string (comp);	
+				e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), comp_str);
+				g_free (comp_str);
 				e_cal_backend_cache_put_component (priv->cache, comp);
 				g_object_unref (comp);
 			}
@@ -175,61 +179,151 @@ static gboolean
 get_deltas (gpointer handle)
 {
  	ECalBackendGroupwise *cbgw;
+	ECalBackendGroupwisePrivate *priv;
 	EGwConnection *cnc; 
  	ECalBackendCache *cache; 
         EGwConnectionStatus status; 
-	GSList *deletes = NULL, *updates = NULL, *adds = NULL, *l;
+	GSList *item_list, *cache_keys, *l;
+	const char *cache_file_name;
+	char *comp_str;
+	static time_t mod_time = NULL;
+	GTimeVal time_val;
+	char time_string[100];
+	const struct tm *tm;
+	struct stat buf;
         
 	if (!handle)
 		return FALSE;
 	
 	cbgw = (ECalBackendGroupwise *) handle;
- 	cnc = cbgw->priv->cnc; 
- 	cache = cbgw->priv->cache; 
+	priv= cbgw->priv;
+ 	cnc = priv->cnc; 
+ 	cache = priv->cache; 
+	item_list = NULL;
+	
+	if (!mod_time) {
+		cache_file_name = e_file_cache_get_filename (E_FILE_CACHE (priv->cache));
+		printf ("%s %d\n", cache_file_name, stat (cache_file_name, &buf));
+		mod_time = buf.st_mtime;
+	}
 
-	/* Call e-gw-connection_get_deltas*/
-	status = e_gw_connection_get_deltas (cnc, &adds, &deletes, &updates);
+	tm = gmtime (&mod_time);
+	strftime (time_string, 100, "%Y-%m-%dT%H:%M:%SZ", tm);
+	
+	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id, "recipients message recipientStatus", time_string, "New", "CalendarItem", NULL,  -1,  &item_list);
+	if (status != E_GW_CONNECTION_STATUS_OK) {
+		e_cal_backend_groupwise_notify_error_code (cbgw, status);
+		return TRUE;
+	}
+	for (; item_list != NULL; item_list = g_slist_next(item_list)) {
+		EGwItem *item = E_GW_ITEM(item_list->data);
+		ECalComponent *comp = e_gw_item_to_cal_component (item, cbgw);
+		
+		e_cal_component_commit_sequence (comp);
 
+		if (comp) {
+			if (!e_cal_backend_cache_put_component (cache, comp)) 
+				g_message ("Could not add the component");
+			else  {
+				comp_str = e_cal_component_get_as_string (comp);	
+				e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), comp_str);
+				g_free (comp_str);
+			}
+		}
+		else 
+			g_message ("Invalid component returned");
+
+		g_object_unref (comp);
+		g_object_unref (item);
+	}
+	if (item_list) {
+		g_slist_free (item_list);
+		item_list = NULL;
+	}
+	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"recipients message recipientStatus iCalId", time_string, "Modified", "CalendarItem", NULL,  -1,  &item_list);
+	
 	if (status != E_GW_CONNECTION_STATUS_OK) {
 		e_cal_backend_groupwise_notify_error_code (cbgw, status);
-		return FALSE;
+		return TRUE;
 	}
 	
-	if (deletes) {
-		for (l = deletes; l != NULL; l = g_slist_next(l)) {
-			if (!e_cal_backend_cache_remove_component (cache, (char *)l->data, NULL)) 
-				g_message ("Could not remove %s", (char *)l->data);
-		}
+	for (; item_list != NULL; item_list = g_slist_next(item_list)) {
+		EGwItem *item = E_GW_ITEM(item_list->data);
+		ECalComponent *modified_comp, *cache_comp;
+		char *cache_comp_str;
+		
+		modified_comp = e_gw_item_to_cal_component (item, cbgw);
+		if (!modified_comp) {
+			g_message ("Invalid component returned in update");
+			continue;
+		}
+		cache_comp = e_cal_backend_cache_get_component (cache, e_gw_item_get_icalid (item), NULL);
+		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);
+		e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp_str, e_cal_component_get_as_string (modified_comp));
+		e_cal_backend_cache_remove_component (cache, e_gw_item_get_icalid (item), NULL);
+		e_cal_backend_cache_put_component (cache, modified_comp);
+		g_free (cache_comp_str);
+		g_object_unref (item);
+		g_object_unref (modified_comp);
+	}
+	if (item_list) {
+		g_slist_free (item_list);
+		item_list = NULL;
 	}
 
-	if (adds) {
-		for (l = adds; l != NULL; l = g_slist_next (l)) {
-			EGwItem *item = (EGwItem *) l->data;
-			ECalComponent *comp = e_gw_item_to_cal_component (item, cbgw);
-			if (!comp)
-				g_message ("Invalid component returned");
-			else if (!e_cal_backend_cache_put_component (cache, comp)) 
-				g_message ("Could not add the component");
-		}
-	}	
+	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"iCalId", NULL, "All", "CalendarItem", NULL,  -1,  &item_list);
+
+	if (status != E_GW_CONNECTION_STATUS_OK) {
+		e_cal_backend_groupwise_notify_error_code (cbgw, status);
+		return TRUE;
+	}
 
-	if (updates) {
-		for (l = updates; l != NULL; l = g_slist_next (l)) {
-			EGwItem *item = (EGwItem *) l->data;
-			ECalComponent *comp = e_cal_backend_cache_get_component (cache, e_gw_item_get_id (item), NULL);
-			if (!comp) /* FIXME  Error in updates. Skipping the element*/
-				continue;
-			/* FIXME  currently, just overwrite the fields with the
-			 * update.*/
-			e_cal_backend_cache_remove_component (cache, e_gw_item_get_id (item), NULL);
-			e_cal_backend_cache_put_component (cache, e_gw_item_to_cal_component (item, cbgw));
+	/* handle deleted items here by going over the entire cache and
+	 * checking for deleted items.*/
+	
+	cache_keys = e_cal_backend_cache_get_keys (cache);
+	for (l = item_list; l; l = g_slist_next (l)) {
+		/* this works assuming rid is null*/
+		cache_keys = g_slist_delete_link (cache_keys, 
+				g_slist_find_custom (cache_keys, l->data, (GCompareFunc) strcmp));
+		g_free (l->data);
+	}
+	
+	for (l = cache_keys; l ; l = g_slist_next (l)) {
+		/* assumes rid is null - which works for now */
+		ECalComponent *comp = NULL;
+		ECalComponentVType vtype;
+
+		comp = e_cal_backend_cache_get_component (cache, (const char *) l->data, NULL);	
+		vtype = e_cal_component_get_vtype (comp);
+		if ((vtype == E_CAL_COMPONENT_EVENT) ||
+				(vtype == E_CAL_COMPONENT_TODO)) {
+			comp_str = e_cal_component_get_as_string (comp);
+			e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), 
+								(char *) l->data, comp_str);
+			e_cal_backend_cache_remove_component (cache, (const char *) l->data, NULL);
+			g_free (comp_str);
 		}
+		g_object_unref (comp);
 	}
+	if (item_list) {
+		g_slist_free (item_list);
+		item_list = NULL;
+	}
+	if (cache_keys) {
+		g_slist_free (cache_keys);
+		item_list = NULL;
+	}
+		
+	g_get_current_time (&time_val);
+	mod_time = time_val.tv_sec;
 
         return TRUE;        
 }
 
-
 static char* 
 form_uri (ESource *source)
 {
@@ -327,38 +421,43 @@ connect_to_server (ECalBackendGroupwise 
 			} else
 				priv->container_id = NULL;
 
-				priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
-				if (!priv->cache) {
-					g_mutex_unlock (priv->mutex);
-					e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
-					return GNOME_Evolution_Calendar_OtherError;
-				}
+			priv->cache = e_cal_backend_cache_new (e_cal_backend_get_uri (E_CAL_BACKEND (cbgw)));
+			if (!priv->cache) {
+				g_mutex_unlock (priv->mutex);
+				e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Could not create cache file"));
+				return GNOME_Evolution_Calendar_OtherError;
+			}
 			
 			/* read the default timezone*/
 			priv->default_zone = e_cal_backend_cache_get_default_timezone (priv->cache);
 
-			/* Clear the cache before populating it */
-			e_file_cache_clean (E_FILE_CACHE (priv->cache));
-
-			if (priv->default_zone)
-				e_cal_backend_cache_put_default_timezone (priv->cache, priv->default_zone);
-	
-			/* Populate the cache for the first time.*/
-			/* start a timed polling thread set to 10 minutes*/
-			cnc_status = populate_cache (cbgw);
-			if (cnc_status != E_GW_CONNECTION_STATUS_OK) {
-				g_object_unref (priv->cnc);
-				g_object_unref (priv->cache);
-				priv->cnc = NULL;
-				priv->cache = NULL;
-				g_warning (G_STRLOC ": Could not populate the cache");
-				return GNOME_Evolution_Calendar_PermissionDenied;
+			/* We poke the cache for a default timezone. Its
+			 * absence indicates that the cache file has not been
+			 * populated before. */
+			if (!priv->default_zone) {
+				/* Populate the cache for the first time.*/
+				/* start a timed polling thread set to 10 minutes*/
+				cnc_status = populate_cache (cbgw);
+				if (cnc_status != E_GW_CONNECTION_STATUS_OK) {
+					g_warning (G_STRLOC ": Could not populate the cache");
+					/*FIXME  why dont we do a notify here */
+					return GNOME_Evolution_Calendar_PermissionDenied;
+				} else {
+					priv->timeout_id = g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas, (gpointer) cbgw);
+					priv->mode = CAL_MODE_REMOTE;
+					return GNOME_Evolution_Calendar_Success;
+				}
 			} else {
-				g_object_ref (priv->cnc);
-				g_object_ref (priv->cache);
-				priv->timeout_id = g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas, (gpointer) cbgw);
-				priv->mode = CAL_MODE_REMOTE;
-				return GNOME_Evolution_Calendar_Success;
+				/* get the deltas from the cache */
+				if (get_deltas (cbgw)) {
+					priv->timeout_id = g_timeout_add (CACHE_REFRESH_INTERVAL, (GSourceFunc) get_deltas, (gpointer) cbgw);
+					priv->mode = CAL_MODE_REMOTE;
+					return GNOME_Evolution_Calendar_Success;
+				} else {
+					g_warning (G_STRLOC ": Could not populate the cache");
+					/*FIXME  why dont we do a notify here */
+					return GNOME_Evolution_Calendar_PermissionDenied;	
+				}
 			}
 		} else {
 			e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
@@ -518,7 +617,7 @@ e_cal_backend_groupwise_get_static_capab
 	                          CAL_STATIC_CAPABILITY_NO_THISANDPRIOR "," \
 				  CAL_STATIC_CAPABILITY_NO_THISANDFUTURE "," \
 				  CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK "," \
-				  CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR "," \ 
+				  CAL_STATIC_CAPABILITY_NO_CONV_TO_RECUR "," \
 				  CAL_STATIC_CAPABILITY_SAVE_SCHEDULES);
 
 	return GNOME_Evolution_Calendar_Success;
@@ -1116,6 +1215,9 @@ e_cal_backend_groupwise_create_object (E
 			/* convert uid_list to GPtrArray and get the items in a list */
 			e_gw_connection_get_items_from_ids (priv->cnc, priv->container_id, "recipients message",
 					uid_array, &list);
+			/* FIXME  check if list is null and status may have
+			 * failed. */
+			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;
@@ -1315,7 +1417,7 @@ e_cal_backend_groupwise_remove_object (E
 static ECalBackendSyncStatus
 receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp)
 {
-	ECalComponent *comp;
+	ECalComponent *comp, *modif_comp;
 	ECalBackendGroupwisePrivate *priv;
 	icalproperty_method method;
 	EGwConnectionStatus status;
@@ -1327,7 +1429,7 @@ receive_object (ECalBackendGroupwise *cb
 	e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
 	method = icalcomponent_get_method (icalcomp);
 	
-	status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, comp, method, &remove);
+	status = e_gw_connection_send_appointment (cbgw, priv->container_id, comp, method, &remove, &modif_comp);
 
 	/* update the cache */
 	if (status == E_GW_CONNECTION_STATUS_OK) {
@@ -1337,24 +1439,27 @@ receive_object (ECalBackendGroupwise *cb
 			e_cal_component_get_uid (comp, (const char **) &uid);
 			e_cal_backend_cache_remove_component (priv->cache, uid, NULL);
 			e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), uid, e_cal_component_get_as_string (comp));
+			g_free (comp);
 		}
 		else {
-			char *cache_comp = NULL, *modif_comp, *temp;
+			char *cache_comp = NULL, *temp;
 			ECalComponent *cache_component;
 			
-			e_cal_component_get_uid (comp, &temp);	
+			e_cal_component_commit_sequence (modif_comp);
+			e_cal_component_get_uid (modif_comp, (const char **) &temp);	
 			cache_component = e_cal_backend_cache_get_component (priv->cache, temp, NULL);
 			
-			if (cache_component)
+			if (cache_component) {
+				e_cal_component_commit_sequence (cache_component);
 				cache_comp = e_cal_component_get_as_string (cache_component);
+			}
 
-			e_cal_backend_cache_put_component (priv->cache, comp);	
-			modif_comp = e_cal_component_get_as_string (comp);
+			e_cal_backend_cache_put_component (priv->cache, modif_comp);	
 			
 			if (cache_comp)
-				e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp, modif_comp);
+				e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp, e_cal_component_get_as_string (modif_comp));
 			else
-				e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), e_cal_component_get_as_string (comp));
+				e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), e_cal_component_get_as_string (modif_comp));
 				
 			g_free (cache_comp);
 			g_free (modif_comp);
Index: calendar/libedata-cal/e-cal-backend-cache.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend-cache.c,v
retrieving revision 1.16
diff -u -p -r1.16 e-cal-backend-cache.c
--- calendar/libedata-cal/e-cal-backend-cache.c	18 May 2004 17:16:54 -0000	1.16
+++ calendar/libedata-cal/e-cal-backend-cache.c	22 Sep 2004 16:05:11 -0000
@@ -582,3 +582,13 @@ e_cal_backend_cache_remove_timezone (ECa
 
 	return e_file_cache_remove_object (E_FILE_CACHE (cache), tzid);
 }
+
+GSList *
+e_cal_backend_cache_get_keys (ECalBackendCache *cache)
+{
+	char *comp_str;
+        
+        /* return null if cache is not a valid Backend Cache.  */
+	g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), NULL);
+        return e_file_cache_get_keys (E_FILE_CACHE (cache));
+}
Index: calendar/libedata-cal/e-cal-backend-cache.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend-cache.h,v
retrieving revision 1.10
diff -u -p -r1.10 e-cal-backend-cache.h
--- calendar/libedata-cal/e-cal-backend-cache.h	18 May 2004 17:16:54 -0000	1.10
+++ calendar/libedata-cal/e-cal-backend-cache.h	22 Sep 2004 16:05:11 -0000
@@ -56,12 +56,15 @@ gboolean            e_cal_backend_cache_
 							  const char *rid);
 GList              *e_cal_backend_cache_get_components (ECalBackendCache *cache);
 
+
 const icaltimezone *e_cal_backend_cache_get_timezone (ECalBackendCache *cache, const char *tzid);
 gboolean            e_cal_backend_cache_put_timezone (ECalBackendCache *cache, const icaltimezone *zone);
 gboolean            e_cal_backend_cache_remove_timezone (ECalBackendCache *cache, const char *tzid);
 
 gboolean            e_cal_backend_cache_put_default_timezone (ECalBackendCache *cache, icaltimezone *default_zone);
 icaltimezone       *e_cal_backend_cache_get_default_timezone (ECalBackendCache *cache);
+
+GSList             *e_cal_backend_cache_get_keys (ECalBackendCache *cache);
 
 
 G_END_DECLS
Index: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.65
diff -u -p -r1.65 ChangeLog
--- servers/groupwise/ChangeLog	8 Sep 2004 11:34:12 -0000	1.65
+++ servers/groupwise/ChangeLog	22 Sep 2004 16:05:11 -0000
@@ -1,3 +1,11 @@
+2004-09-22  Harish Krishnaswamy  <kharish novell com>
+
+	Fixes #61865	
+	* e-gw-connection.[ch]: 
+	(e_gw_connection_get_quick_messages): implements
+	sending a getQuickMessagesRequest to the server and
+	parsing the response.
+
 2004-09-08  Chenthill Palanisamy <pchenthill novell com>
 	
 	Fixes #64062
Index: servers/groupwise/e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.80
diff -u -p -r1.80 e-gw-connection.c
--- servers/groupwise/e-gw-connection.c	25 Aug 2004 14:39:18 -0000	1.80
+++ servers/groupwise/e-gw-connection.c	22 Sep 2004 16:05:11 -0000
@@ -1701,3 +1701,96 @@ e_gw_connection_read_cursor (EGwConnecti
 	g_object_unref (msg);
         return E_GW_CONNECTION_STATUS_OK;
 }
+
+EGwConnectionStatus e_gw_connection_get_quick_messages (EGwConnection *cnc, const char *container, const char *view, const char *start_date, const char *message_list, const char *item_types, const char *item_sources, int count, GSList **item_list)
+{
+	SoupSoapMessage *msg;
+	SoupSoapResponse *response;
+        EGwConnectionStatus status;
+	SoupSoapParameter *param, *subparam;
+	
+	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
+	g_return_val_if_fail (message_list != NULL, E_GW_CONNECTION_STATUS_UNKNOWN);
+
+	msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getQuickMessagesRequest");
+	e_gw_message_write_string_parameter (msg, "list", NULL, message_list);
+	if (start_date)
+		e_gw_message_write_string_parameter (msg, "startDate", NULL, start_date);
+	if (container)
+		e_gw_message_write_string_parameter (msg, "container", NULL, container);
+	if (item_types) 
+		e_gw_message_write_string_parameter (msg, "types", NULL, item_types);
+	if (item_sources)
+		e_gw_message_write_string_parameter (msg, "source", NULL, item_sources);
+	if (view)
+		e_gw_message_write_string_parameter (msg, "view", NULL, view);
+	if (count > 0)
+		e_gw_message_write_int_parameter (msg, "count", NULL, count);
+	
+	e_gw_message_write_footer (msg);
+
+	response = e_gw_connection_send_message (cnc, msg);
+        if (!response) {
+                g_object_unref (msg);
+                return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+        }
+	
+	status = e_gw_connection_parse_response_status (response);
+        if (status != E_GW_CONNECTION_STATUS_OK) {
+		g_object_unref (response);
+                g_object_unref (msg);
+		return status;
+	}
+
+	/* if status is OK - parse result. return the list */	
+	*item_list = NULL;
+	param = soup_soap_response_get_first_parameter_by_name (response, "items");
+        if (!param) {
+                g_object_unref (response);
+                g_object_unref (msg);
+                return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+        }
+
+	if (!strcmp (message_list, "All")) { 
+		/* We are  interested only in getting the ids */
+		for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
+	     	     subparam != NULL;
+	             subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
+			SoupSoapParameter *param_id;
+		     	char *id;
+			
+			param_id = soup_soap_parameter_get_first_child_by_name (subparam, "iCalId");
+			if (!param_id) {
+				g_object_unref (response);
+		                g_object_unref (msg);
+                		return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+			}
+		     
+			id = g_strdup (soup_soap_parameter_get_string_value (param_id));
+			if (id)
+				*item_list = g_slist_append (*item_list, id);
+		}
+		
+		g_object_unref (response);
+		g_object_unref (msg);
+		return E_GW_CONNECTION_STATUS_OK;
+
+	}
+
+	for (subparam = soup_soap_parameter_get_first_child_by_name (param, "item");
+	     subparam != NULL;
+	     subparam = soup_soap_parameter_get_next_child_by_name (subparam, "item")) {
+		EGwItem *item;
+
+		item = e_gw_item_new_from_soap_parameter (cnc->priv->user_email, container, subparam);
+		if (item)
+			*item_list = g_slist_append (*item_list, item);
+        }
+               
+	/* free memory */
+        g_object_unref (response);
+	g_object_unref (msg);
+        return E_GW_CONNECTION_STATUS_OK;
+	
+
+}
Index: servers/groupwise/e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.34
diff -u -p -r1.34 e-gw-connection.h
--- servers/groupwise/e-gw-connection.h	24 Aug 2004 16:07:41 -0000	1.34
+++ servers/groupwise/e-gw-connection.h	22 Sep 2004 16:05:11 -0000
@@ -111,6 +111,8 @@ EGwConnectionStatus e_gw_connection_crea
 EGwConnectionStatus e_gw_connection_destroy_cursor (EGwConnection *cnc, const char *container,  int cursor);
 EGwConnectionStatus e_gw_connection_read_cursor (EGwConnection *cnc, const char *container, int cursor, int forward, int count, GList **item_list);
 
+EGwConnectionStatus e_gw_connection_get_quick_messages (EGwConnection *cnc, const char *container, const char *view, const char *start_date, const char *message_list, const char *item_types, const char *item_sources, int count, GSList **item_list);
+
 G_END_DECLS
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]