[evolution-patches] patch for bug #57127 calendar



Hi,
    Attached a patch which solves the categories defect. There was no
implementation to send/receive categories to/from the server, so
reffered the Address book and implemented the same in calendar. 

Thanks,chenthill.
? patch_categ.diff
? servers/groupwise/patch.diff
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.293
diff -u -r1.293 ChangeLog
--- calendar/ChangeLog	5 Jul 2004 06:21:48 -0000	1.293
+++ calendar/ChangeLog	7 Jul 2004 05:41:31 -0000
@@ -1,3 +1,23 @@
+2004-07-06  Chenthill Palanisamy <pchenthill novell com>
+	
+	Fixes #57127
+	* backends/groupwise/e-cal-backend-groupwise.c:
+	(ECalBackendGroupwisePrivate): Added two hash tables
+	for the category ids and names.
+	(e_cal_backend_groupwise_get_connection), 
+	(e_cal_backend_groupwise_get_default_zone), 
+	(e_cal_backend_groupwise_get_categories_by_id),
+	(e_cal_backend_groupwise_get_categories_by_name):
+	Added to access the ECalBackendGroupwisePrivate structure.
+	* backends/groupwise/e-cal-backend-groupwise-utils.c: 
+	(e_gw_item_new_from_cal_component), (e_gw_item_to_cal_component),
+	(e_gw_connection_send_appointment), (set_properties_from_cal_component):
+	Changed the argument from icaltimezone to ECalBackendGroupwise to 
+	access ECalBackendGroupwisePrivate structure for storing categories 
+	to calendar components.
+	(set_categories_for_gw_item): Added to store the categories in GW item.
+	(set_categories_changes): Added to update the category changes.
+	
 2004-06-28  Chenthill Palanisamy <pchenthill novell com>
 	
 	Fixes #60463
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.23
diff -u -r1.23 e-cal-backend-groupwise-utils.c
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	5 Jul 2004 06:21:48 -0000	1.23
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	7 Jul 2004 05:41:32 -0000
@@ -28,6 +28,8 @@
 #include <libecal/e-cal-time-util.h>
 #include "e-cal-backend-groupwise-utils.h"
 
+static void set_categories_for_gw_item (EGwItem *item, GList *categories, ECalBackendGroupwise *cbgw);
+
 static gboolean 
 get_recur_instance (ECalComponent *comp, time_t instance_start, time_t instance_end, gpointer data)
 {
@@ -48,19 +50,68 @@
 	return NULL;
 }
 
+static void 
+set_categories_for_gw_item (EGwItem *item, GList *category_names, ECalBackendGroupwise *cbgw)
+{
+	GHashTable *categories_by_name, *categories_by_id;
+	EGwConnection *cnc;
+	GList *category_ids;
+	char *id;
+	int status;
+
+	category_ids = NULL;
+	id = NULL;
+
+	categories_by_name = e_cal_backend_groupwise_get_categories_by_name (cbgw);
+	categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
+	cnc = e_cal_backend_groupwise_get_connection (cbgw);
+	
+	for (; category_names != NULL; category_names = g_list_next (category_names)) {
+                     if (!category_names->data || strlen(category_names->data) == 0 )
+                             continue;
+                     id = g_hash_table_lookup (categories_by_name, category_names->data);
+                     if (id)
+                             category_ids = g_list_append (category_ids, g_strdup (id));
+                     else {
+                             EGwItem *category_item;
+                             category_item = e_gw_item_new_empty();
+                             e_gw_item_set_item_type (category_item,  E_GW_ITEM_TYPE_CATEGORY);
+                             e_gw_item_set_category_name (category_item, category_names->data);
+                             status = e_gw_connection_create_item (cnc, category_item, &id);
+                             if (status == E_GW_CONNECTION_STATUS_OK && id != NULL) {
+                                     char **components = g_strsplit (id, "@", -1);
+                                     char *temp_id = components[0];
+    
+                                     g_hash_table_insert (categories_by_name, g_strdup (category_names->data), g_strdup(temp_id));
+                                     g_hash_table_insert (categories_by_id, g_strdup(temp_id), g_strdup (category_names->data));
+                                     category_ids = g_list_append (category_ids, g_strdup(temp_id));
+                                     g_free (id);
+                                     g_strfreev(components);
+                             }
+                             g_object_unref (category_item);
+                     }
+             }
+             e_gw_item_set_categories (item, category_ids);
+}
+
+
 static EGwItem *
-set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, const icaltimezone *default_zone)
+set_properties_from_cal_component (EGwItem *item, ECalComponent *comp, ECalBackendGroupwise *cbgw)
 {
 	const char *uid, *location;
+	GList *categories;
 	ECalComponentDateTime dt;
 	ECalComponentClassification classif;
 	ECalComponentTransparency transp;
 	ECalComponentText text;
+	icaltimezone *default_zone;
 	int *priority;
 	GSList *slist, *sl;
 	icalproperty *prop;
 	struct icaltimetype itt_utc;
 
+	default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
+
 	/* first set specific properties */
 	switch (e_cal_component_get_vtype (comp)) {
 	case E_CAL_COMPONENT_EVENT :
@@ -77,6 +128,10 @@
 		e_cal_component_get_location (comp, &location);
 		e_gw_item_set_place (item, location);
 
+		/* categories */
+		e_cal_component_get_categories_list (comp, &categories);
+		set_categories_for_gw_item (item, categories, cbgw);
+		
 		/* alarms */
 		if (e_cal_component_has_alarms (comp)) {
 			ECalComponentAlarm *alarm;
@@ -297,7 +352,7 @@
 }
 
 EGwItem *
-e_gw_item_new_from_cal_component (const char *container, const icaltimezone *default_zone, ECalComponent *comp)
+e_gw_item_new_from_cal_component (const char *container, ECalBackendGroupwise *cbgw, ECalComponent *comp)
 {
 	EGwItem *item;
 
@@ -306,17 +361,20 @@
 	item = e_gw_item_new_empty ();
 	e_gw_item_set_container_id (item, container);
 	
-	return set_properties_from_cal_component (item, comp, default_zone);
+	return set_properties_from_cal_component (item, comp, cbgw);
 }
 
 ECalComponent *
-e_gw_item_to_cal_component (EGwItem *item, icaltimezone *default_zone)
+e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw)
 {
 	ECalComponent *comp;
 	ECalComponentText text;
+	icaltimezone *default_zone;
 	ECalComponentDateTime dt;
 	const char *description;
-	char *t;
+	char *t, *name;
+	GList *category_ids, *categories;
+	GHashTable *categories_by_id;
 	struct icaltimetype itt, itt_utc;
 	int priority;
 	int percent;
@@ -327,6 +385,9 @@
 
 	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
 
+	default_zone = e_cal_backend_groupwise_get_default_zone (cbgw);
+	categories_by_id = e_cal_backend_groupwise_get_categories_by_id (cbgw);
+
 	comp = e_cal_component_new ();
 
 	item_type = e_gw_item_get_item_type (item);
@@ -486,6 +547,21 @@
 		/* location */
 		e_cal_component_set_location (comp, e_gw_item_get_place (item));
 
+		/* categories */
+		category_ids = e_gw_item_get_categories (item);
+		categories = NULL;
+		if (category_ids) {
+			for (; category_ids != NULL; category_ids = g_list_next (category_ids)) {
+				name = g_hash_table_lookup (categories_by_id, category_ids->data);
+				if (name)
+					categories = g_list_append (categories, name);
+			}
+			if (categories) {
+				e_cal_component_set_categories_list (comp,categories);
+				g_list_free (categories);
+			}
+		}
+
 		/* end date */
 		t = e_gw_item_get_end_date (item);
 		if (t) {
@@ -574,7 +650,7 @@
 }
 
 EGwConnectionStatus
-e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, icaltimezone *default_zone, ECalComponent *comp, char **id)
+e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, ECalBackendGroupwise *cbgw, ECalComponent *comp, char **id)
 {
 	EGwItem *item;
 	EGwConnectionStatus status;
@@ -582,7 +658,7 @@
 	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);
 
-	item = e_gw_item_new_from_cal_component (container, default_zone, comp);
+	item = e_gw_item_new_from_cal_component (container, cbgw, comp);
 	e_gw_item_set_container_id (item, container);
 	status = e_gw_connection_send_item (cnc, item, id);
 	g_object_unref (item);
@@ -855,6 +931,47 @@
         return close_freebusy_session (cnc, session);
 }
 
+static void 
+set_categories_changes (EGwItem *new_item, EGwItem *old_item)
+{
+	GList *old_category_list;
+	GList *new_category_list;
+	GList *temp, *old_categories_copy, *added_categories = NULL;
+	gboolean categories_matched;
+	char *category1, *category2;
+	old_category_list = e_gw_item_get_categories (old_item);
+	new_category_list = e_gw_item_get_categories (new_item);
+	if (old_category_list && new_category_list) {
+		old_categories_copy = g_list_copy (old_category_list);
+		for ( ; new_category_list != NULL; new_category_list = g_list_next (new_category_list)) {
+			
+			category1  = new_category_list->data;
+			temp = old_category_list;
+			categories_matched  = FALSE;
+			for(; temp != NULL; temp = g_list_next (temp)) {
+				category2 = temp->data;
+				if ( g_str_equal (category1, category2)) {
+					categories_matched = TRUE;
+					old_categories_copy = g_list_remove (old_categories_copy, category2);
+					break;
+				}
+				
+			}
+			if (!categories_matched)
+				added_categories = g_list_append (added_categories, category1);
+		}
+		
+		e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, "categories", added_categories);
+		e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_DELETE, "categories", old_categories_copy);
+
+	} else if (!new_category_list && old_category_list) {
+		e_gw_item_set_change (new_item,  E_GW_ITEM_CHANGE_TYPE_DELETE, "categories", old_category_list);
+	} else if (new_category_list && !old_category_list) {
+		e_gw_item_set_change (new_item, E_GW_ITEM_CHANGE_TYPE_ADD, "categories", new_category_list);
+	}
+
+}
+
 #define SET_DELTA(fieldname) G_STMT_START{                                                                \
 	fieldname = e_gw_item_get_##fieldname (item);                                                       \
 	cache_##fieldname = e_gw_item_get_##fieldname (cache_item);                                           \
@@ -887,6 +1004,8 @@
 
 	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));
+
+	set_categories_changes (item, cache_item);
 	
 	/*FIXME  recipient_list modifications need go here after server starts
 	 * supporting retraction */
@@ -898,8 +1017,8 @@
 		SET_DELTA(place);
 		trigger = e_gw_item_get_trigger (item);
 		cache_trigger = e_gw_item_get_trigger (cache_item);
-		if (cache_trigger) {                                                                            
-			if (!trigger)                                                                               
+		if (cache_trigger) {                                                     
+			if (!trigger)      
 				e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_DELETE, "alarm", &cache_trigger);
 			else if (trigger != cache_trigger)
 				e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "alarm", &trigger);
@@ -918,4 +1037,4 @@
 			e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "completed", &completed);
 		SET_DELTA (priority);
 	}
-}
+}	
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.6
diff -u -r1.6 e-cal-backend-groupwise-utils.h
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.h	5 Jul 2004 06:21:48 -0000	1.6
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.h	7 Jul 2004 05:41:32 -0000
@@ -26,20 +26,21 @@
 
 #include <e-gw-connection.h>
 #include <libecal/e-cal-component.h>
+#include <e-cal-backend-groupwise.h>
 
 G_BEGIN_DECLS
 
 /*
  * Items management
  */
-EGwItem       *e_gw_item_new_from_cal_component (const char *container, const icaltimezone *default_zone, ECalComponent *comp);
-ECalComponent *e_gw_item_to_cal_component (EGwItem *item, icaltimezone *default_zone);
+EGwItem       *e_gw_item_new_from_cal_component (const char *container, ECalBackendGroupwise *cbgw, ECalComponent *comp);
+ECalComponent *e_gw_item_to_cal_component (EGwItem *item, ECalBackendGroupwise *cbgw);
 void          e_gw_item_set_changes (EGwItem *item, EGwItem *cached_item);
 
 /*
  * Connection-related utility functions
  */
-EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, icaltimezone *default_zone, ECalComponent *comp, char **id);
+EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, ECalBackendGroupwise *cbgw, ECalComponent *comp, char **id);
 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.73
diff -u -r1.73 e-cal-backend-groupwise.c
--- calendar/backends/groupwise/e-cal-backend-groupwise.c	5 Jul 2004 06:21:48 -0000	1.73
+++ calendar/backends/groupwise/e-cal-backend-groupwise.c	7 Jul 2004 05:41:33 -0000
@@ -52,7 +52,9 @@
 	char *container_id;
 	CalMode mode;
 	icaltimezone *default_zone;
-
+	GHashTable *categories_by_id;
+	GHashTable *categories_by_name;
+	
 	/* fields for storing info while offline */
 	char *user_email;
 };
@@ -66,6 +68,38 @@
 /* Time interval in milliseconds for obtaining changes from server and refresh the cache. */
 #define CACHE_REFRESH_INTERVAL 600000
 
+EGwConnection *
+e_cal_backend_groupwise_get_connection (ECalBackendGroupwise *cbgw) {
+
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_InvalidObject);
+
+	return cbgw->priv->cnc;
+}
+
+GHashTable *
+e_cal_backend_groupwise_get_categories_by_id (ECalBackendGroupwise *cbgw) {
+	
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_InvalidObject);
+	
+	return cbgw->priv->categories_by_id;
+}
+
+GHashTable *
+e_cal_backend_groupwise_get_categories_by_name (ECalBackendGroupwise *cbgw) {
+
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_InvalidObject);
+
+	return cbgw->priv->categories_by_name;
+}
+
+icaltimezone *
+e_cal_backend_groupwise_get_default_zone (ECalBackendGroupwise *cbgw) {
+
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw), GNOME_Evolution_Calendar_InvalidObject);
+
+	return cbgw->priv->default_zone;
+}
+
 /* Initialy populate the cache from the server */
 static EGwConnectionStatus
 populate_cache (ECalBackendGroupwise *cbgw)
@@ -79,6 +113,14 @@
 
 	priv = cbgw->priv;
 
+	/* get the list of category ids and corresponding names from the server */
+	status = e_gw_connection_get_categories (priv->cnc, priv->categories_by_id, priv->categories_by_name);
+	if (status != E_GW_CONNECTION_STATUS_OK) {
+                g_list_free (list);
+		e_cal_backend_groupwise_notify_error_code (cbgw, status);
+                return status;
+        }
+
         /* get all the objects from the server */
         status = e_gw_connection_get_items (priv->cnc, priv->container_id, "recipients message recipientStatus", NULL, &list);
         if (status != E_GW_CONNECTION_STATUS_OK) {
@@ -91,7 +133,7 @@
 		EGwItem *item;
 
 		item = E_GW_ITEM (l->data);
-		comp = e_gw_item_to_cal_component (item, priv->default_zone);
+		comp = e_gw_item_to_cal_component (item, cbgw);
 		g_object_unref (item);
 		if (E_IS_CAL_COMPONENT (comp)) {
 			e_cal_component_commit_sequence (comp);
@@ -156,7 +198,7 @@
 	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->priv->default_zone);
+			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)) 
@@ -173,7 +215,7 @@
 			/* 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->priv->default_zone));
+			e_cal_backend_cache_put_component (cache, e_gw_item_to_cal_component (item, cbgw));
 		}
 	}
 
@@ -340,6 +382,16 @@
 		priv->container_id = NULL;
 	}
 
+	if (priv->categories_by_id) {
+	        g_hash_table_destroy (priv->categories_by_id);
+		priv->categories_by_id = NULL;
+	}
+
+	if (priv->categories_by_name) {
+	        g_hash_table_destroy (priv->categories_by_name);
+	        priv->categories_by_name = NULL;
+	}
+		
 	if (priv->user_email) {
 		g_free (priv->user_email);
 		priv->user_email = NULL;
@@ -976,7 +1028,7 @@
 	case CAL_MODE_ANY :
 	case CAL_MODE_REMOTE :
 		/* when online, send the item to the server */
-		status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, priv->default_zone, comp, &server_uid);
+		status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, cbgw, comp, &server_uid);
 		if (status != E_GW_CONNECTION_STATUS_OK) {
 			g_object_unref (comp);
 			return GNOME_Evolution_Calendar_OtherError;
@@ -1047,7 +1099,7 @@
 
 	comp = e_cal_component_new ();
 	e_cal_component_set_icalcomponent (comp, icalcomp);
-	item = e_gw_item_new_from_cal_component (priv->container_id, priv->default_zone, comp);
+	item = e_gw_item_new_from_cal_component (priv->container_id, cbgw, comp);
 
 	/* check if the object exists */
 	switch (priv->mode) {
@@ -1060,7 +1112,7 @@
 			return GNOME_Evolution_Calendar_ObjectNotFound;
 		}
 
-		cache_item =  e_gw_item_new_from_cal_component (priv->container_id, priv->default_zone, cache_comp);
+		cache_item =  e_gw_item_new_from_cal_component (priv->container_id, cbgw, cache_comp);
 		e_gw_item_set_changes (item, cache_item); 
 		g_object_unref (cache_comp);
 
@@ -1251,7 +1303,7 @@
 	case CAL_MODE_ANY :
 	case CAL_MODE_REMOTE :
 		/* when online, send the item to the server */
-		status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, priv->default_zone, comp, NULL);
+		status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, cbgw, comp, NULL);
 		break;
 	case CAL_MODE_LOCAL :
 		/* in offline mode, we just update the cache */
@@ -1325,6 +1377,9 @@
 
 	priv = g_new0 (ECalBackendGroupwisePrivate, 1);
 
+	priv->categories_by_id = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+	priv->categories_by_name = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+		 
 	/* create the mutex for thread safety */
 	priv->mutex = g_mutex_new ();
 
Index: calendar/backends/groupwise/e-cal-backend-groupwise.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise.h,v
retrieving revision 1.3
diff -u -r1.3 e-cal-backend-groupwise.h
--- calendar/backends/groupwise/e-cal-backend-groupwise.h	19 Mar 2004 18:44:12 -0000	1.3
+++ calendar/backends/groupwise/e-cal-backend-groupwise.h	7 Jul 2004 05:41:33 -0000
@@ -52,6 +52,10 @@
 };
 
 GType   e_cal_backend_groupwise_get_type (void);
+EGwConnection* e_cal_backend_groupwise_get_connection (ECalBackendGroupwise *cbgw);
+GHashTable* e_cal_backend_groupwise_get_categories_by_id (ECalBackendGroupwise *cbgw);
+GHashTable* e_cal_backend_groupwise_get_categories_by_name (ECalBackendGroupwise *cbgw);
+icaltimezone* e_cal_backend_groupwise_get_default_zone (ECalBackendGroupwise *cbgw);
 void    e_cal_backend_groupwise_notify_error_code (ECalBackendGroupwise *cbgw, EGwConnectionStatus status);
 
 G_END_DECLS
Index: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.55
diff -u -r1.55 ChangeLog
--- servers/groupwise/ChangeLog	15 Jun 2004 15:59:07 -0000	1.55
+++ servers/groupwise/ChangeLog	7 Jul 2004 05:41:50 -0000
@@ -1,3 +1,10 @@
+2004-07-06  Chenthill Palanisamy <pchenthill novell com>
+	Fixes #57127
+	* e-gw-item.c
+	(e_gw_item_new_from_soap_parameter),(e_gw_item_append_to_soap_message), 
+	(append_event_changes_to_soap_message): Made the required changes to 
+        send/receive the category information to/from the soap message.
+       
 2004-06-15  Harish Krishnaswamy  <kharish novell com>
 
 	Fixes #59352
Index: servers/groupwise/e-gw-item.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.c,v
retrieving revision 1.39
diff -u -r1.39 e-gw-item.c
--- servers/groupwise/e-gw-item.c	15 Jun 2004 15:59:07 -0000	1.39
+++ servers/groupwise/e-gw-item.c	7 Jul 2004 05:41:52 -0000
@@ -1242,7 +1242,7 @@
 {
 	EGwItem *item;
         char *item_type;
-	SoupSoapParameter *subparam, *child;
+	SoupSoapParameter *subparam, *child, *category_param;
 	
 	g_return_val_if_fail (param != NULL, NULL);
 
@@ -1372,7 +1372,22 @@
 			formatted_date = e_gw_connection_format_date_string (value);
 			e_gw_item_set_end_date (item, formatted_date);
 			g_free (value);
-			g_free (formatted_date); 
+			g_free (formatted_date);
+		
+		} else if (!g_ascii_strcasecmp (name, "categories")) { 
+			for (category_param = soup_soap_parameter_get_first_child_by_name (child, "category");
+		     	     category_param != NULL;
+		    	     category_param = soup_soap_parameter_get_next_child_by_name (category_param, "category")) {
+
+					value = soup_soap_parameter_get_string_value (category_param);
+					if (value) {
+						char **components = g_strsplit (value, "@", -1);
+						g_free (value);
+						value = components[0];
+						item->priv->category_list = g_list_append (item->priv->category_list, g_strdup (value));
+						g_strfreev(components);
+					}
+			  }
 
 		} else if (!g_ascii_strcasecmp (name, "iCalId"))
 			item->priv->icalid = soup_soap_parameter_get_string_value (child);
@@ -1835,7 +1850,18 @@
 			e_gw_message_write_string_parameter (msg, "endDate", NULL, priv->end_date);
 		} else
 			e_gw_message_write_string_parameter (msg, "endDate", NULL, "");
-		
+		if (priv->category_list) {
+			soup_soap_message_start_element (msg, "categories", NULL, NULL);
+			
+			if (priv->category_list && priv->category_list->data) 
+				soup_soap_message_add_attribute (msg, "types:primary", priv->category_list->data, NULL, NULL);
+			
+			for (; priv->category_list != NULL; priv->category_list = g_list_next (priv->category_list)) 
+				if (priv->category_list->data) {
+					e_gw_message_write_string_parameter (msg, "category", NULL, priv->category_list->data);
+				}
+			soup_soap_message_end_element (msg);
+		}	
 		break;
 
 	case E_GW_ITEM_TYPE_TASK :
@@ -2029,6 +2055,21 @@
 			e_gw_message_write_string_parameter (msg, "endDate", NULL, priv->end_date);
 		}
 	}
+	if (g_hash_table_lookup (changes, "categories")){
+		GList *list;	
+		list = g_hash_table_lookup (changes, "categories");
+
+		soup_soap_message_start_element (msg, "categories", NULL, NULL);
+		if (list != NULL && list->data) 
+			soup_soap_message_add_attribute (msg, "types:primary",list->data, NULL, NULL);
+			for (; list != NULL; list = g_list_next (list)) 
+				if (list->data) {
+					e_gw_message_write_string_parameter (msg, "category", NULL, list->data);
+				}
+		soup_soap_message_end_element (msg);
+		g_list_free (list);
+	}
+	
 	if (g_hash_table_lookup (changes, "message")) {
 		soup_soap_message_start_element (msg, "message", NULL, NULL);
 		if (priv->message) {


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