[evolution-patches] Fix for saving alarm info in the GW server



hi, 

The following patch is a fix for #56535 that allows alarm info in the
GUI to be saved in the GW server along with the event.
Kindly review this.

harish

Index: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.35
diff -u -p -r1.35 ChangeLog
--- servers/groupwise/ChangeLog	23 Apr 2004 10:48:41 -0000	1.35
+++ servers/groupwise/ChangeLog	27 Apr 2004 06:46:57 -0000
@@ -1,3 +1,14 @@
+2004-04-27  Harish Krishnaswamy  <kharish novell com>
+
+	Fixes #56535.
+
+	* e-gw-item.c: (e_gw_item_init),
+	(e_gw_item_new_from_soap_parameter), (e_gw_item_get_trigger),
+	(e_gw_item_set_trigger), (e_gw_item_append_to_soap_message):
+	Added support for saving Alarms in the GW server as well as 
+	read the alarm information during retrieval.
+	* e-gw-item.h: Added get/set functions for alarm trigger.
+
 2004-04-23 Sivaiah Nallagatla   <snallagatla novell com>
 	
 	* e_gw_item.c ( append_group_fields_to_soap_message) : add id,
distType
Index: servers/groupwise/e-gw-item.h
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.h,v
retrieving revision 1.9
diff -u -p -r1.9 e-gw-item.h
--- servers/groupwise/e-gw-item.h	27 Mar 2004 13:12:36 -0000	1.9
+++ servers/groupwise/e-gw-item.h	27 Apr 2004 06:46:57 -0000
@@ -160,6 +160,9 @@ void        e_gw_item_set_accept_level (
 const char *e_gw_item_get_priority (EGwItem *item);
 void        e_gw_item_set_priority (EGwItem *item, const char
*new_priority);
 
+int e_gw_item_get_trigger (EGwItem *item);
+void e_gw_item_set_trigger (EGwItem *item, int trigger);
+
 typedef struct {
 	char *email;
 	char *display_name;
Index: servers/groupwise/e-gw-item.c
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.c,v
retrieving revision 1.24
diff -u -p -r1.24 e-gw-item.c
--- servers/groupwise/e-gw-item.c	23 Apr 2004 10:48:41 -0000	1.24
+++ servers/groupwise/e-gw-item.c	27 Apr 2004 06:46:57 -0000
@@ -50,6 +50,7 @@ struct _EGwItemPrivate {
 	char *priority;
 	char *place;
 	GSList *recipient_list;
+	int trigger; /* alarm */
 
 	/* properties for tasks/calendars */
 	char *icalid;
@@ -285,6 +286,7 @@ e_gw_item_init (EGwItem *item, EGwItemCl
 	priv->start_date = -1;
 	priv->end_date = -1;
 	priv->due_date = -1;
+	priv->trigger = 0;
 	priv->im_list = NULL;
 	priv->email_list = NULL;
 	priv->member_list = NULL;
@@ -1246,6 +1248,17 @@ e_gw_item_new_from_soap_parameter (const
 
 		} else if (!g_ascii_strcasecmp (name, "subject"))
 			item->priv->subject = soup_soap_parameter_get_string_value (child);
+		else if (!g_ascii_strcasecmp (name, "alarm")) {
+			const char *enabled;
+			enabled = soup_soap_parameter_get_property (child, "enabled");
+			if (!g_ascii_strcasecmp (enabled, "true") ) {
+				const char *value;
+				value = soup_soap_parameter_get_string_value (child);
+				/* convert it into integer */
+				item->priv->trigger = atoi (value);
+				g_free (value);
+			}
+		}
 		
 	}
 
@@ -1510,6 +1523,22 @@ e_gw_item_set_priority (EGwItem *item, c
 	item->priv->priority = g_strdup (new_priority);
 }
 
+int
+e_gw_item_get_trigger (EGwItem *item)
+{
+	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
+
+	return item->priv->trigger;
+}
+
+void
+e_gw_item_set_trigger (EGwItem *item, int trigger)
+{
+	g_return_if_fail (E_IS_GW_ITEM (item));
+
+	item->priv->trigger = trigger;
+}
+
 static char *
 timet_to_string (time_t t)
 {
@@ -1526,6 +1555,7 @@ e_gw_item_append_to_soap_message (EGwIte
 {
 	EGwItemPrivate *priv;
 	char *dtstring;
+	char *alarm;
 
 	g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
 	g_return_val_if_fail (SOUP_IS_SOAP_MESSAGE (msg), FALSE);
@@ -1541,8 +1571,16 @@ e_gw_item_append_to_soap_message (EGwIte
 		e_gw_message_write_string_parameter (msg, "acceptLevel", NULL,
priv->accept_level ? priv->accept_level : "");
 		e_gw_message_write_string_parameter (msg, "iCalId", NULL,
priv->icalid ? priv->icalid : "");
 		e_gw_message_write_string_parameter (msg, "place", NULL, priv->place
? priv->place : "");
+		if (priv->trigger != -1) {
+			alarm = g_malloc (5); 
+			/* 5 is the max length required as GW does allows values upto
12*60*60 only*/
+			sprintf (alarm, "%d", priv->trigger);
+			e_gw_message_write_string_parameter_with_attribute (msg, "alarm",
NULL, alarm, "enabled", "true");
+			g_free (alarm);
+		}
 		/* FIXME: distribution */
 		break;
+
 	case E_GW_ITEM_TYPE_TASK :
 		soup_soap_message_add_attribute (msg, "type", "Task", "xsi", NULL);
 
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.247
diff -u -p -r1.247 ChangeLog
--- calendar/ChangeLog	23 Apr 2004 20:24:19 -0000	1.247
+++ calendar/ChangeLog	27 Apr 2004 06:46:58 -0000
@@ -1,3 +1,13 @@
+2004-04-27  Harish Krishnaswamy  <kharish novell com>
+
+	Fixes #56535
+
+	* backends/groupwise/e-cal-backend-groupwise-utils.c:
+	(set_properties_from_cal_component), (e_gw_item_to_cal_component):
+	Added support for saving Alarms in the GW server as well as 
+	read the alarm information during retrieval.
+
+
 2004-04-23  Jeffrey Stedfast  <fejj ximian com>
 
 	* libedata-cal/e-data-cal.c (e_data_cal_notify_changes): Fixed a
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.14
diff -u -p -r1.14 e-cal-backend-groupwise-utils.c
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	12 Apr
2004 06:16:01 -0000	1.14
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	27 Apr
2004 06:46:58 -0000
@@ -54,6 +54,19 @@ set_properties_from_cal_component (EGwIt
 		e_cal_component_get_location (comp, &location);
 		e_gw_item_set_place (item, location);
 
+		/* alarms */
+		if (e_cal_component_has_alarms (comp)) {
+			ECalComponentAlarm *alarm;
+			ECalComponentAlarmTrigger trigger;
+			int duration;
+			GList *l = e_cal_component_get_alarm_uids (comp);
+
+			alarm = e_cal_component_get_alarm (comp, l->data);
+			e_cal_component_alarm_get_trigger (alarm, &trigger);
+			duration = abs (icaldurationtype_as_int (trigger.u.rel_duration));
+			e_gw_item_set_trigger (item, duration);
+		}
+		
 		/* FIXME: attendee list, set_distribution */
 		break;
 
@@ -211,6 +224,7 @@ e_gw_item_to_cal_component (EGwItem *ite
 	time_t t;
 	struct icaltimetype itt;
 	int priority;
+	int alarm_duration;
 	EGwItemType item_type;
 
 	g_return_val_if_fail (E_IS_GW_ITEM (item), NULL);
@@ -310,6 +324,21 @@ e_gw_item_to_cal_component (EGwItem *ite
 
 		/* location */
 		e_cal_component_set_location (comp, e_gw_item_get_place (item));
+
+		/* alarms*/
+		/* we negate the value as GW supports only "before" the start of
event alarms */
+		alarm_duration = 0 - e_gw_item_get_trigger (item);
+		if (alarm_duration != 0) {
+			ECalComponentAlarm *alarm;
+			ECalComponentAlarmTrigger trigger;
+			
+			alarm = e_cal_component_alarm_new ();
+			e_cal_component_alarm_set_action (alarm,
E_CAL_COMPONENT_ALARM_DISPLAY);
+			trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START;
+			trigger.u.rel_duration = (struct icaldurationtype)
icaldurationtype_from_int (alarm_duration);
+			e_cal_component_alarm_set_trigger (alarm, trigger);
+			e_cal_component_add_alarm (comp, alarm);
+		}
 
 		/* FIXME: attendee list, get_distribution */
 		break;




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