Re: [evolution-patches] patch for getQm fix for getting new and modified items [calendar]



Resending the patch since the ChangeLog for the calendar part was not
added properly in the previous patch.

thanks, chenthill.

On Thu, 2005-02-24 at 05:26 -0800, chenthill wrote:
> Hi,
>    Now we use the time stamps returned from the server for
> getQuickmessages.
> 
> thanks, chenthill.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.426
diff -u -p -r1.426 ChangeLog
--- ChangeLog	24 Feb 2005 10:58:56 -0000	1.426
+++ ChangeLog	24 Feb 2005 14:08:56 -0000
@@ -1,3 +1,14 @@
+2005-02-24  Chenthill Palanisamy  <pchenthill novell com>
+
+	* backends/groupwise/e-cal-backend-groupwise.c: (get_deltas):
+	Changed the getQm calls since the function has been changed.
+	Send the time stamps received from the server.
+	* libedata-cal/e-cal-backend-cache.c:
+	(e_cal_backend_cache_put_server_utc_time),
+	(e_cal_backend_cache_get_server_utc_time):
+	* libedata-cal/e-cal-backend-cache.h:  Added functions
+	to put the server UTC time in cache.
+
 2005-02-22  Rodrigo Moya <rodrigo novell com>
 
 	* backends/http/e-cal-backend-http.c (e_cal_backend_http_init):
Index: 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.129
diff -u -p -r1.129 e-cal-backend-groupwise.c
--- backends/groupwise/e-cal-backend-groupwise.c	22 Feb 2005 05:10:19 -0000	1.129
+++ backends/groupwise/e-cal-backend-groupwise.c	24 Feb 2005 14:08:56 -0000
@@ -196,12 +196,9 @@ get_deltas (gpointer handle)
  	ECalBackendCache *cache; 
         EGwConnectionStatus status; 
 	GSList *item_list, *cache_keys, *l;
-	const char *cache_file_name;
 	char *comp_str;
-	static time_t mod_time = 0;
-	GTimeVal time_val;
-	char time_string[100];
-	const struct tm *tm;
+	char *time_string = NULL;
+	static char *t_str = NULL; 
 	struct stat buf;
         
 	if (!handle)
@@ -215,21 +212,30 @@ get_deltas (gpointer handle)
 	if (priv->mode == CAL_MODE_LOCAL)
 		return FALSE;
 
-	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;
+	if (!t_str) {
+		t_str = (char *) e_cal_backend_cache_get_server_utc_time (cache);
+		if (!t_str) {
+			icaltimetype temp;
+			time_t current_time;
+			const struct tm *tm;
+
+			g_warning (" Could not get the correct time stamp for using in getQuick Messages\n");
+			temp = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ());
+			current_time = icaltime_as_timet (temp);
+			tm = gmtime (&current_time);
+			strftime (t_str, 100, "%Y-%m-%dT%H:%M:%SZ", tm);
+		}
 	}
 
-	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, "attachments recipients message recipientStatus default", time_string, "New", "CalendarItem", NULL,  -1,  &item_list);
+	time_string = g_strdup (t_str);
+	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id, "attachments recipients message recipientStatus default", &time_string, "New", "CalendarItem", NULL,  -1,  &item_list);
 	
 	if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
-		status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id, "recipients message recipientStatus default", time_string, "New", "CalendarItem", NULL,  -1,  &item_list);
+		status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id, "recipients message recipientStatus default", &time_string, "New", "CalendarItem", NULL,  -1,  &item_list);
 	
+	g_free (time_string), time_string = NULL;
 	if (status != E_GW_CONNECTION_STATUS_OK) {
+		g_free (t_str), t_str = NULL;
 				
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) 
 			return TRUE;
@@ -265,14 +271,20 @@ get_deltas (gpointer handle)
 		item_list = NULL;
 	}
 	e_file_cache_thaw_changes (E_FILE_CACHE (cache));
+	
+	/******* We must use the same timestamp used for getQm call with message list New *********/ 
+	time_string = g_strdup (t_str);
 
-	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"attachments recipients message recipientStatus  default", time_string, "Modified", "CalendarItem", NULL,  -1,  &item_list);
+	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"attachments recipients message recipientStatus  default", &time_string, "Modified", "CalendarItem", NULL,  -1,  &item_list);
 	
 	if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
-		status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"recipients message recipientStatus  default", time_string, "Modified", "CalendarItem", NULL,  -1,  &item_list);
+		status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"recipients message recipientStatus  default", &time_string, "Modified", "CalendarItem", NULL,  -1,  &item_list);
 
 		
+	g_free (t_str), t_str = NULL;
 	if (status != E_GW_CONNECTION_STATUS_OK) {
+		g_free (time_string), time_string = NULL;
+
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) 
 			return TRUE;
 
@@ -281,6 +293,10 @@ get_deltas (gpointer handle)
 	}
 
 	e_file_cache_freeze_changes (E_FILE_CACHE (cache));
+	
+	e_cal_backend_cache_put_server_utc_time (cache, time_string);
+	t_str = time_string;
+
 	for (; item_list != NULL; item_list = g_slist_next(item_list)) {
 		EGwItem *item = E_GW_ITEM(item_list->data);
 		ECalComponent *modified_comp, *cache_comp;
@@ -308,11 +324,11 @@ get_deltas (gpointer handle)
 		g_slist_free (item_list);
 		item_list = NULL;
 	}
-
-	status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"iCalId", NULL, "All", "CalendarItem", NULL,  -1,  &item_list);
+	
+	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_INVALID_CONNECTION)
-		status = e_gw_connection_get_quick_messages (cnc, cbgw->priv->container_id,"iCalId", NULL, "All", "CalendarItem", NULL,  -1,  &item_list);
+		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) {
 		if (status == E_GW_CONNECTION_STATUS_NO_RESPONSE) 
@@ -366,9 +382,6 @@ get_deltas (gpointer handle)
 		item_list = NULL;
 	}
 		
-	g_get_current_time (&time_val);
-	mod_time = time_val.tv_sec;
-
         return TRUE;        
 }
 
@@ -450,7 +463,12 @@ cache_init (ECalBackendGroupwise *cbgw)
 			/*FIXME  why dont we do a notify here */
 			return GNOME_Evolution_Calendar_PermissionDenied;
 		} else {
+			char *utc_str;
+			
+			utc_str = (char *) e_gw_connection_get_server_time (priv->cnc);
 			e_cal_backend_cache_set_marker (priv->cache);
+			e_cal_backend_cache_put_server_utc_time (priv->cache, utc_str);
+
 			/*  Set up deltas only if it is a Calendar backend */
 			if (kind == ICAL_VEVENT_COMPONENT)
 				priv->timeout_id = g_timeout_add (time_interval, (GSourceFunc) get_deltas, (gpointer) cbgw);
 
 /* Open handler for the file backend */
Index: 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.19
diff -u -p -r1.19 e-cal-backend-cache.c
--- libedata-cal/e-cal-backend-cache.c	18 Jan 2005 17:53:44 -0000	1.19
+++ libedata-cal/e-cal-backend-cache.c	24 Feb 2005 14:08:56 -0000
@@ -614,3 +614,28 @@ e_cal_backend_cache_get_marker (ECalBack
 		return "";
 	return NULL;
 }
+
+gboolean
+e_cal_backend_cache_put_server_utc_time (ECalBackendCache *cache, char *utc_str)
+{
+	char *value;
+	gboolean ret_val = FALSE;
+	
+	g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), FALSE);
+
+	value = g_strdup (utc_str);
+
+	if (!(ret_val = e_file_cache_add_object (E_FILE_CACHE (cache), "server_utc_time", value)))
+		ret_val = e_file_cache_replace_object (E_FILE_CACHE (cache), "server_utc_time", value);
+
+	return ret_val;
+}
+
+const char *
+e_cal_backend_cache_get_server_utc_time (ECalBackendCache *cache)
+{
+
+	g_return_val_if_fail (E_IS_CAL_BACKEND_CACHE (cache), NULL);
+	
+       	return	e_file_cache_get_object (E_FILE_CACHE (cache), "server_utc_time");
+}
Index: 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.12
diff -u -p -r1.12 e-cal-backend-cache.h
--- libedata-cal/e-cal-backend-cache.h	13 Oct 2004 09:34:47 -0000	1.12
+++ libedata-cal/e-cal-backend-cache.h	24 Feb 2005 14:08:56 -0000
@@ -69,6 +69,9 @@ GSList             *e_cal_backend_cache_
 const char         *e_cal_backend_cache_get_marker (ECalBackendCache *cache);
 void                e_cal_backend_cache_set_marker (ECalBackendCache *cache);
 
+gboolean e_cal_backend_cache_put_server_utc_time (ECalBackendCache *cache, char *utc_str);
+const char * e_cal_backend_cache_get_server_utc_time (ECalBackendCache *cache);
+
 G_END_DECLS
 
 #endif
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.125
diff -u -p -r1.125 ChangeLog
--- ChangeLog	22 Feb 2005 05:45:15 -0000	1.125
+++ ChangeLog	24 Feb 2005 13:03:08 -0000
@@ -1,3 +1,10 @@
+2005-02-24  Chenthill Palanisamy  <pchenthill novell com>
+
+	* e-gw-connection.c: (e_gw_connection_get_quick_messages):
+	* e-gw-connection.h: Changed the function to get the argument
+	startdate as double pointer to give the utc time sent by server
+	back to the callers.
+
 2005-02-22  Parthasarathi Susarla <sparthasarathi novell com>
 	
 	* e-gw-item.c (e_gw_item_append_to_soap_message): 
Index: e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.109
diff -u -p -r1.109 e-gw-connection.c
--- e-gw-connection.c	17 Feb 2005 10:14:34 -0000	1.109
+++ e-gw-connection.c	24 Feb 2005 13:03:11 -0000
@@ -2119,7 +2119,7 @@ e_gw_connection_read_cursor (EGwConnecti
         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)
+EGwConnectionStatus e_gw_connection_get_quick_messages (EGwConnection *cnc, const char *container, const char *view, char **start_date, const char *message_list, const char *item_types, const char *item_sources, int count, GSList **item_list)
 {
 	SoupSoapMessage *msg;
 	SoupSoapResponse *response;
@@ -2132,7 +2132,7 @@ EGwConnectionStatus e_gw_connection_get_
 	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);
+		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) 
@@ -2170,6 +2170,20 @@ EGwConnectionStatus e_gw_connection_get_
                 return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
         }
 
+	if (start_date && *start_date) {
+		subparam = soup_soap_response_get_first_parameter_by_name (response, "startDate");
+		if (subparam) {
+			char *date;
+
+			date = soup_soap_parameter_get_string_value (subparam);
+			if (date)
+				g_free (*start_date), *start_date = date;
+			else 
+				return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+		} else 
+			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");
Index: e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.55
diff -u -p -r1.55 e-gw-connection.h
--- e-gw-connection.h	17 Feb 2005 10:14:34 -0000	1.55
+++ e-gw-connection.h	24 Feb 2005 13:03:11 -0000
@@ -119,7 +119,7 @@ EGwConnectionStatus e_gw_connection_dest
 EGwConnectionStatus e_gw_connection_read_cursor (EGwConnection *cnc, const char *container, int cursor, gboolean forward, int count, GList **item_list);
 EGwConnectionStatus e_gw_connection_position_cursor (EGwConnection *cnc, const char *container, int cursor, const char *seek, int offset);
 
-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);
+EGwConnectionStatus e_gw_connection_get_quick_messages (EGwConnection *cnc, const char *container, const char *view, char **start_date, const char *message_list, const char *item_types, const char *item_sources, int count, GSList **item_list);
 
 EGwConnectionStatus e_gw_connection_create_folder(EGwConnection *cnc, const char *parent_name,const char *folder_name, char **container_id) ;
 EGwConnectionStatus
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/ChangeLog,v
retrieving revision 1.25
diff -u -p -r1.25 ChangeLog
--- ChangeLog	24 Feb 2005 10:51:52 -0000	1.25
+++ ChangeLog	24 Feb 2005 12:46:03 -0000
@@ -1,3 +1,11 @@
+2005-02-24  Chenthill Palanisamy  <pchenthill novell com>
+
+	* camel-groupwise-folder.c: (groupwise_refresh_info):
+	* camel-groupwise-store.c: (groupwise_get_folder):
+	Made changes since the getQm function has been changed 
+	to take the fourth argument (startdate) as double pointer.
+
 2005-02-23  Sankar P <psankar novell com>
 
        * camel-groupwise-folder.c: (groupwise_folder_get_message):
Index: camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.28
diff -u -p -r1.28 camel-groupwise-folder.c
--- camel-groupwise-folder.c	23 Feb 2005 15:39:10 -0000	1.28
+++ camel-groupwise-folder.c	24 Feb 2005 12:46:03 -0000
@@ -606,7 +606,7 @@ groupwise_refresh_info(CamelFolder *fold
 	char *container_id = NULL ;
 	char *cache_file_name ;
 	time_t mod_time = time (0) ;
-	char time_string[100] = {0} ;
+	char time_string[100] = {0}, *t_str ;
 	const struct tm *tm ;
 	struct stat buf ;
 
@@ -632,12 +632,15 @@ groupwise_refresh_info(CamelFolder *fold
 
 	tm = gmtime (&mod_time) ;
 	strftime (time_string, 100, "%Y-%m-%dT%H:%M:%SZ", tm) ;
+	t_str = g_strdup (time_string);
 	
 	CAMEL_SERVICE_LOCK (gw_store, connect_lock);
-
+	/* FIXME send the time stamp which the server sends */
 	status = e_gw_connection_get_quick_messages (cnc, container_id,
 					"distribution created attachments subject",
-					time_string, "New", "Mail", NULL, -1, &slist) ;
+					&t_str, "New", "Mail", NULL, -1, &slist) ;
+	
+	g_free (t_str), t_str = NULL;
 	if (status != E_GW_CONNECTION_STATUS_OK) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
 		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
@@ -650,9 +653,12 @@ groupwise_refresh_info(CamelFolder *fold
 	}
 	g_slist_free (slist);
 	slist = NULL;
+	t_str = g_strdup (time_string);
+	/* FIXME send the time stamp which the server sends */
 	status = e_gw_connection_get_quick_messages (cnc, container_id,
 				"distribution created attachments subject",
-				time_string, "Modified", "Mail", NULL, -1, &slist) ;
+				&t_str, "Modified", "Mail", NULL, -1, &slist) ;
+	g_free (t_str), t_str = NULL;
 	if (status != E_GW_CONNECTION_STATUS_OK) {
 		camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
 		CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
Index: camel-groupwise-store.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-store.c,v
retrieving revision 1.32
diff -u -p -r1.32 camel-groupwise-store.c
--- camel-groupwise-store.c	17 Feb 2005 10:42:03 -0000	1.32
+++ camel-groupwise-store.c	24 Feb 2005 12:46:03 -0000
@@ -535,7 +535,7 @@ groupwise_get_folder (CamelStore *store,
 	if(summary_count) {
 		char *cache_file_name ;
 		time_t mod_time = time (0) ;
-		char time_string[100] = {0} ;
+		char time_string[100] = {0}, *t_str;
 		const struct tm *tm ;
 		struct stat buf;
 		
@@ -548,10 +548,13 @@ groupwise_get_folder (CamelStore *store,
 		tm = gmtime (&mod_time);
 		strftime (time_string, 100, "%Y-%m-%dT%H:%M:%SZ", tm);
 		camel_operation_start (NULL, _("Fetching summary information for new messages"));
+		t_str = g_strdup (time_string);
 
+		/* FIXME send the time stamp which the server sends */
 		status = e_gw_connection_get_quick_messages (priv->cnc, container_id,
 				"distribution attachments subject created",
-				time_string, "New", "Mail", NULL, -1, &slist) ;
+				&t_str, "New", "Mail", NULL, -1, &slist) ;
+		g_free (t_str), t_str = NULL;
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			//camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
 			CAMEL_SERVICE_UNLOCK (gw_store, connect_lock) ;
@@ -571,9 +574,12 @@ groupwise_get_folder (CamelStore *store,
 
 		g_slist_free (slist);
 		slist = NULL;
+		t_str = g_strdup (time_string);
+		/* FIXME send the time stamp which the server sends */
 		status = e_gw_connection_get_quick_messages (priv->cnc, container_id,
 					"distribution attachments subject created",
-					time_string, "Modified", "Mail", NULL, -1, &slist) ; 
+					&t_str, "Modified", "Mail", NULL, -1, &slist) ; 
+		g_free (t_str), t_str = NULL;
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			//camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
 			CAMEL_SERVICE_UNLOCK (gw_store, connect_lock) ;



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