[evolution-patches] Patch for adding support to Recurrences in GW events



hi,

the following patch contains the code for supporting recurrences in GW
events plus minor code changes to support assignment of tasks to
multiple users.


regards,
harishIndex: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.288
diff -u -p -r1.288 ChangeLog
--- calendar/ChangeLog	2 Jun 2004 16:15:00 -0000	1.288
+++ calendar/ChangeLog	10 Jun 2004 18:34:27 -0000
@@ -1,3 +1,16 @@
+2004-06-10  Harish Krishnaswamy  <kharish novell com>
+
+
+	* backends/groupwise/e-cal-backend-groupwise-utils.c:
+	(get_recur_instance), (resolve_tzid_cb) : add support for recurrences 
+	in events.
+	(set_properties_from_cal_component), (e_gw_item_to_cal_component),
+	(e_gw_item_set_changes): Recipient_list handling code is now common to
+	both events and todos.
+	* backends/groupwise/e-cal-backend-groupwise.c: (populate_cache): Add
+	recipientStatus to the view element.
+	(receive_object): Send found_comp as argument to modify_object.
+
 2004-06-02  Rodrigo Moya <rodrigo novell com>
 
 	* libecal/e-cal.c (e_cal_generate_instances,
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.20
diff -u -p -r1.20 e-cal-backend-groupwise-utils.c
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	28 May
2004 06:18:40 -0000	1.20
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	10 Jun
2004 18:34:28 -0000
@@ -24,8 +24,30 @@
 #include <string.h>
 #include <e-gw-connection.h>
 #include <e-gw-message.h>
+#include <libecal/e-cal-recur.h>
+#include <libecal/e-cal-time-util.h>
 #include "e-cal-backend-groupwise-utils.h"
 
+static gboolean 
+get_recur_instance (ECalComponent *comp, time_t instance_start, time_t
instance_end, gpointer data)
+{
+	GSList **recur_dates = (GSList **) data;
+	char *rdate;
+
+	rdate = isodate_from_time_t (instance_start);
+	// convert this into a date
+	rdate[8] ='\0';
+	*recur_dates = g_slist_append (*recur_dates, rdate);
+	return TRUE;
+}
+
+static icaltimezone *
+resolve_tzid_cb (const char *tzid, gpointer data)
+{
+	// do nothing.. since we are interested only in the event date
+	return NULL;
+}
+
 static EGwItem *
 set_properties_from_cal_component (EGwItem *item, ECalComponent *comp,
const icaltimezone *default_zone)
 {
@@ -68,30 +90,7 @@ set_properties_from_cal_component (EGwIt
 			e_gw_item_set_trigger (item, duration);
 		}
 		
-		/* get_attendee_list from cal comp and convert into
-		 * egwitemrecipient and set it on recipient_list*/
-		if (e_cal_component_has_attendees (comp)) {
-			GSList *attendee_list, *recipient_list = NULL, *al;
-
-		 	e_cal_component_get_attendee_list (comp, &attendee_list);	
-			for (al = attendee_list; al != NULL; al = al->next) {
-				ECalComponentAttendee *attendee = (ECalComponentAttendee *)
al->data;
-				EGwItemRecipient *recipient = g_new0 (EGwItemRecipient, 1);
-				
-				/* len (MAILTO:) + 1 = 7 */
-				recipient->email = g_strdup (attendee->value + 7);
-				if (attendee->cn != NULL)
-					recipient->display_name = g_strdup (attendee->cn);
-				if (attendee->role == ICAL_ROLE_REQPARTICIPANT) 
-					recipient->type = E_GW_ITEM_RECIPIENT_TO;
-				else if (attendee->role == ICAL_ROLE_OPTPARTICIPANT)
-					recipient->type = E_GW_ITEM_RECIPIENT_CC;
-				else recipient->type = E_GW_ITEM_RECIPIENT_NONE;
-
-				recipient_list = g_slist_append (recipient_list, recipient);
-			}
-			e_gw_item_set_recipient_list (item, recipient_list);
-		}
+		
 
 		/* end date */
 		e_cal_component_get_dtend (comp, &dt);
@@ -233,6 +232,52 @@ set_properties_from_cal_component (EGwIt
 		e_gw_item_set_classification (item, NULL);
 	}
 
+	/* get_attendee_list from cal comp and convert into
+	 * egwitemrecipient and set it on recipient_list*/
+	if (e_cal_component_has_attendees (comp)) {
+		GSList *attendee_list, *recipient_list = NULL, *al;
+
+		e_cal_component_get_attendee_list (comp, &attendee_list);	
+		for (al = attendee_list; al != NULL; al = al->next) {
+			ECalComponentAttendee *attendee = (ECalComponentAttendee *)
al->data;
+			EGwItemRecipient *recipient = g_new0 (EGwItemRecipient, 1);
+			
+			/* len (MAILTO:) + 1 = 7 */
+			recipient->email = g_strdup (attendee->value + 7);
+			if (attendee->cn != NULL)
+				recipient->display_name = g_strdup (attendee->cn);
+			if (attendee->role == ICAL_ROLE_REQPARTICIPANT) 
+				recipient->type = E_GW_ITEM_RECIPIENT_TO;
+			else if (attendee->role == ICAL_ROLE_OPTPARTICIPANT)
+				recipient->type = E_GW_ITEM_RECIPIENT_CC;
+			else recipient->type = E_GW_ITEM_RECIPIENT_NONE;
+
+			if (attendee->status == ICAL_PARTSTAT_ACCEPTED)
+				recipient->status = E_GW_ITEM_STAT_ACCEPTED;
+			else if (attendee->status == ICAL_PARTSTAT_DECLINED)
+				recipient->status = E_GW_ITEM_STAT_DECLINED;
+			else 
+				recipient->status = E_GW_ITEM_STAT_NONE;
+
+			recipient_list = g_slist_append (recipient_list, recipient);
+		}
+				
+		e_gw_item_set_recipient_list (item, recipient_list);
+	}
+	/* check if recurrences exist and update the item */
+	if (e_cal_component_has_recurrences (comp)) {
+
+		GSList *recur_dates = NULL, *tmp;
+		
+
+		e_cal_recur_generate_instances (comp, -1, -1,
+				get_recur_instance, &recur_dates, resolve_tzid_cb, NULL, 
+				default_zone);		
+		recur_dates = g_slist_delete_link (recur_dates, recur_dates);
+		
+		e_gw_item_set_recurrence_dates (item, recur_dates);
+	    }
+
 	return item;
 }
 
@@ -259,6 +304,7 @@ e_gw_item_to_cal_component (EGwItem *ite
 	char *t;
 	struct icaltimetype itt, itt_utc;
 	int priority;
+	int percent;
 	int alarm_duration;
 	GSList *recipient_list, *rl, *attendee_list = NULL;
 	EGwItemType item_type;
@@ -366,6 +412,38 @@ e_gw_item_to_cal_component (EGwItem *ite
 	} else
 		e_cal_component_set_classification (comp,
E_CAL_COMPONENT_CLASS_NONE);
 
+	recipient_list = e_gw_item_get_recipient_list (item);
+	if (recipient_list != NULL) {
+		for (rl = recipient_list; rl != NULL; rl = rl->next) {
+			EGwItemRecipient *recipient = (EGwItemRecipient *) rl->data;
+			ECalComponentAttendee *attendee = g_new0 (ECalComponentAttendee, 1);
+
+			attendee->cn = g_strdup (recipient->display_name);
+			attendee->value = g_strconcat("MAILTO:", recipient->email, NULL);
+			if (recipient->type == E_GW_ITEM_RECIPIENT_TO)
+				attendee->role = ICAL_ROLE_REQPARTICIPANT;
+			else if (recipient->type == E_GW_ITEM_RECIPIENT_CC)
+				attendee->role = ICAL_ROLE_OPTPARTICIPANT;
+			else 
+				attendee->role = ICAL_ROLE_NONE;
+			/* FIXME  needs a server fix on the interface 
+			 * for getting cutype and the status */
+			attendee->cutype = ICAL_CUTYPE_INDIVIDUAL;
+			 
+			if (recipient->status == E_GW_ITEM_STAT_ACCEPTED)
+				attendee->status = ICAL_PARTSTAT_ACCEPTED;
+			else if (recipient->status == E_GW_ITEM_STAT_DECLINED)
+				attendee->status = ICAL_PARTSTAT_DECLINED;
+			else
+				attendee->status = ICAL_PARTSTAT_NEEDSACTION;	
+				
+			
+			attendee_list = g_slist_append (attendee_list, attendee);				
+		}
+
+		e_cal_component_set_attendee_list (comp, attendee_list);
+	}
+
 	/* set specific properties */
 	switch (item_type) {
 	case E_GW_ITEM_TYPE_APPOINTMENT :
@@ -416,29 +494,7 @@ e_gw_item_to_cal_component (EGwItem *ite
 			e_cal_component_add_alarm (comp, alarm);
 		}
 
-		recipient_list = e_gw_item_get_recipient_list (item);
-		if (recipient_list != NULL) {
-			for (rl = recipient_list; rl != NULL; rl = rl->next) {
-				EGwItemRecipient *recipient = (EGwItemRecipient *) rl->data;
-				ECalComponentAttendee *attendee = g_new0 (ECalComponentAttendee,
1);
-
-				attendee->cn = g_strdup (recipient->display_name);
-				attendee->value = g_strconcat("MAILTO:", recipient->email, NULL);
-				if (recipient->type == E_GW_ITEM_RECIPIENT_TO)
-					attendee->role = ICAL_ROLE_REQPARTICIPANT;
-				else if (recipient->type == E_GW_ITEM_RECIPIENT_CC)
-					attendee->role = ICAL_ROLE_OPTPARTICIPANT;
-				else 
-					attendee->role = ICAL_ROLE_NONE;
-				/* FIXME  needs a server fix on the interface 
-				 * for getting cutype and the status */
-				attendee->cutype = ICAL_CUTYPE_INDIVIDUAL;
-				attendee->status = ICAL_PARTSTAT_NEEDSACTION; 
-				attendee_list = g_slist_append (attendee_list, attendee);				
-			}
-
-			e_cal_component_set_attendee_list (comp, attendee_list);
-		}
+		
 
 		break;
 	case E_GW_ITEM_TYPE_TASK :
@@ -475,7 +531,13 @@ e_gw_item_to_cal_component (EGwItem *ite
 
 		e_cal_component_set_priority (comp, &priority);
 
-		/* FIXME: EGwItem's completed is a boolean */
+		/* EGwItem's completed is a boolean */
+		if (e_gw_item_get_completed (item)) 
+			percent = 100;
+		else 
+			percent =0;
+		e_cal_component_set_percent (comp, &percent);
+
 		break;
 	default :
 		return NULL;
@@ -793,7 +855,9 @@ e_gw_item_set_changes (EGwItem *item, EG
 	if (strcmp (e_gw_item_get_start_date (item), e_gw_item_get_start_date
(cache_item)))
 		e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE,
"startDate", e_gw_item_get_start_date (item));
 	
-	if ( e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT) {
+	/*FIXME  recipient_list modifications need go here after server starts
+	 * supporting retraction */
+	if (e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT) {
 
 		if (strcmp (e_gw_item_get_end_date (item), e_gw_item_get_end_date
(cache_item)))
 			e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "endDate",
e_gw_item_get_end_date (item));
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.71
diff -u -p -r1.71 e-cal-backend-groupwise.c
--- calendar/backends/groupwise/e-cal-backend-groupwise.c	25 May 2004
18:19:23 -0000	1.71
+++ calendar/backends/groupwise/e-cal-backend-groupwise.c	10 Jun 2004
18:34:28 -0000
@@ -80,7 +80,7 @@ populate_cache (ECalBackendGroupwise *cb
 	priv = cbgw->priv;
 
         /* get all the objects from the server */
-        status = e_gw_connection_get_items (priv->cnc,
priv->container_id, "recipients message", NULL, &list);
+        status = e_gw_connection_get_items (priv->cnc,
priv->container_id, "recipients message recipientStatus", NULL, &list);
         if (status != E_GW_CONNECTION_STATUS_OK) {
                 g_list_free (list);
 		e_cal_backend_groupwise_notify_error_code (cbgw, status);
@@ -1184,7 +1184,7 @@ receive_object (ECalBackendGroupwise *cb
 	found_comp = e_cal_backend_cache_get_component (priv->cache, uid,
rid);
 	if (found_comp) {
 		status = e_cal_backend_groupwise_modify_object (E_CAL_BACKEND_SYNC
(cbgw), cal, comp_str,
-								CALOBJ_MOD_THIS, NULL);
+								CALOBJ_MOD_THIS, found_comp);
 	} else
 		status = e_cal_backend_groupwise_create_object (E_CAL_BACKEND_SYNC
(cbgw), cal, &comp_str, NULL);
 
Index: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.51
diff -u -p -r1.51 ChangeLog
--- servers/groupwise/ChangeLog	1 Jun 2004 06:58:22 -0000	1.51
+++ servers/groupwise/ChangeLog	10 Jun 2004 18:34:28 -0000
@@ -1,3 +1,15 @@
+2004-06-10  Harish Krishnaswamy  <kharish novell com>
+
+	* e-gw-item.c: (e_gw_item_dispose), (e_gw_item_init),
+	(set_recipient_list_from_soap_parameter),
+	(e_gw_item_get_recurrence_dates), (e_gw_item_set_recurrence_dates),
+	(e_gw_item_append_to_soap_message):
+	Add support for recurrence in events.
+	(add_distribution_to_soap_message): Make recipient list handling code
+	common to both calendar and task items to support assignment in tasks.
+	* e-gw-item.h: add get/set methods for recurrences, status field to 
+	EGwRecipient.
+
 2004-06-01  Sivaiah Nallagatla <snallagatla novell com>
 
 	* e-gw-connection.[ch]  (e_gw_connection_remove_items):
Index: servers/groupwise/e-gw-item.c
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.c,v
retrieving revision 1.36
diff -u -p -r1.36 e-gw-item.c
--- servers/groupwise/e-gw-item.c	31 May 2004 13:52:43 -0000	1.36
+++ servers/groupwise/e-gw-item.c	10 Jun 2004 18:34:28 -0000
@@ -50,6 +50,7 @@ struct _EGwItemPrivate {
 	char *priority;
 	char *place;
 	GSList *recipient_list;
+	GSList *recurrence_dates;
 	int trigger; /* alarm */
 
 	/* properties for tasks/calendars */
@@ -224,6 +225,10 @@ e_gw_item_dispose (GObject *object)
 			g_slist_foreach (priv->recipient_list, (GFunc) free_recipient,
NULL);
 			priv->recipient_list = NULL;
 		}	
+		if (priv->recurrence_dates) {
+			g_slist_foreach (priv->recurrence_dates, free_string, NULL);
+			priv->recurrence_dates = NULL;
+		}
 		if (priv->full_name) {
 			free_full_name (priv->full_name);
 			priv->full_name = NULL;
@@ -310,6 +315,7 @@ e_gw_item_init (EGwItem *item, EGwItemCl
 	priv->due_date = NULL; 
 	priv->trigger = 0;
 	priv->recipient_list = NULL;
+	priv->recurrence_dates = NULL;
 	priv->completed = FALSE;
 	priv->im_list = NULL;
 	priv->email_list = NULL;
@@ -393,6 +399,23 @@ set_recipient_list_from_soap_parameter (
                 }
 		/*FIXME  gw recipientTypes need to be added after the server is
fixed. */
 
+		// FIXME  is it safe to assume 'from; is the organizer.
+		
+		// update Recipient Status
+		// look for accepted/declined and update the item else set it
+		// to none.
+		subparam = soup_soap_parameter_get_first_child_by_name
(param_recipient, "recipientType");
+                if (subparam) {
+                        const char *recip_type;
+                        recip_type =
soup_soap_parameter_get_string_value (subparam);
+                        if (!strcmp (recip_type, "accepted")) 
+				recipient->status = E_GW_ITEM_STAT_ACCEPTED;
+                        else if (!strcmp (recip_type, "deleted"))
+                                recipient->status =
E_GW_ITEM_STAT_DECLINED;
+                        else
+				recipient->status = E_GW_ITEM_RECIPIENT_NONE;
+                }
+		
                 *list = g_slist_append (*list, recipient);
         }        
 }
@@ -1654,6 +1677,21 @@ e_gw_item_set_recipient_list (EGwItem  *
 	item->priv->recipient_list = new_recipient_list;
 }
 
+GSList *
+e_gw_item_get_recurrence_dates (EGwItem *item)
+{
+	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
+	return item->priv->recurrence_dates;
+}
+
+void
+e_gw_item_set_recurrence_dates (EGwItem  *item, GSList
*new_recurrence_dates)
+{
+	/* free old list and set a new one*/
+	g_slist_foreach (item->priv->recurrence_dates, free_string, NULL);
+	item->priv->recurrence_dates = new_recurrence_dates;
+}
+
 int
 e_gw_item_get_trigger (EGwItem *item)
 {
@@ -1682,6 +1720,8 @@ add_distribution_to_soap_message (GSList
 	// add each recipient
 	for (rl = recipient_list; rl != NULL; rl = rl->next) {
 		char *dist_type;
+		char *status;
+
 		EGwItemRecipient *recipient = (EGwItemRecipient *) rl->data;
 		
 		soup_soap_message_start_element (msg, "recipient", NULL, NULL);
@@ -1694,6 +1734,15 @@ add_distribution_to_soap_message (GSList
 		else 
 			dist_type ="";
 		e_gw_message_write_string_parameter (msg, "distType", NULL,
dist_type);
+		// add recip_status
+		if (recipient->status == E_GW_ITEM_STAT_ACCEPTED)
+			status = "accepted";
+		else if (recipient->status == E_GW_ITEM_STAT_DECLINED)
+			status = "declined";
+		else
+			status = "";
+		e_gw_message_write_string_parameter (msg, "recipientStatus", NULL,
status);
+		
 		soup_soap_message_end_element (msg);		
 	}
 	
@@ -1815,6 +1864,15 @@ e_gw_item_append_to_soap_message (EGwIte
 	else
 		e_gw_message_write_string_parameter (msg, "class", NULL, "");
 
+	/* handle recurrences */
+	if (item->priv->recurrence_dates) {
+		GSList *date;
+		soup_soap_message_start_element (msg, "rdate", NULL, NULL);
+		for (date = item->priv->recurrence_dates; date != NULL; date =
g_slist_next (date)) {
+			e_gw_message_write_string_parameter (msg, "date", NULL, (char *)
date->data);
+		}
+		soup_soap_message_end_element (msg);
+	}
 	/* finalize the SOAP element */
 	soup_soap_message_end_element (msg);
 
Index: servers/groupwise/e-gw-item.h
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.h,v
retrieving revision 1.13
diff -u -p -r1.13 e-gw-item.h
--- servers/groupwise/e-gw-item.h	18 May 2004 17:16:54 -0000	1.13
+++ servers/groupwise/e-gw-item.h	10 Jun 2004 18:34:29 -0000
@@ -168,6 +168,10 @@ void        e_gw_item_set_priority (EGwI
 GSList *e_gw_item_get_recipient_list (EGwItem *item);
 void e_gw_item_set_recipient_list (EGwItem *item, GSList
*new_recipient_list);
 
+GSList *e_gw_item_get_recurrence_dates (EGwItem *item);
+void e_gw_item_set_recurrence_dates (EGwItem  *item, GSList
*new_recurrence_dates);
+
+
 int e_gw_item_get_trigger (EGwItem *item);
 void e_gw_item_set_trigger (EGwItem *item, int trigger);
 
@@ -179,6 +183,12 @@ typedef struct {
 		E_GW_ITEM_RECIPIENT_CC,
 		E_GW_ITEM_RECIPIENT_NONE
 	} type;
+
+	enum {
+		E_GW_ITEM_STAT_ACCEPTED,
+		E_GW_ITEM_STAT_DECLINED,
+		E_GW_ITEM_STAT_NONE
+	} status;
 } EGwItemRecipient;
 
 gboolean    e_gw_item_append_to_soap_message (EGwItem *item,
SoupSoapMessage *msg);




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