Re: [evolution-patches] [calendar] patch for #57142



On Thu, 2004-07-15 at 14:35 +0200, Rodrigo Moya wrote:
> Updated patch for this, which makes ECalComponent use the same mechanism
> we use in the event editor to keep track of alarms that need a
> description. Whenever we change the component's summary, all the alarms'
> descriptions are updated if needed.

updated patch after some talk with JP on IRC, now including an evolution
part.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.296
diff -u -p -r1.296 ChangeLog
--- ChangeLog	14 Jul 2004 09:32:15 -0000	1.296
+++ ChangeLog	15 Jul 2004 17:44:34 -0000
@@ -1,10 +1,22 @@
+2004-07-15  Rodrigo Moya <rodrigo novell com>
+
+	Fixes #57142
+
+	* libecal/e-cal-component.c (ensure_alarm_properties_cb): add the
+	X-EVOLUTION-NEEDS-DESCRIPTION property to the alarms we create
+	with no description, and remove the property from the alarms with
+	a description already.
+
+	(e_cal_component_set_summary, set_alarm_description_cb): set the
+	description on the alarms when the summary changes and remove the
+	above property when we set a valid description.
+
 2004-07-14  Chenthill Palanisamy <pchenthill novell com>
 
        Fixes #60344
        * backends/groupwise/e-cal-backend-groupwise.c:
        (e_cal_backend_groupwise_internal_get_timezone):
        Send the timezone present in tzid instead of sending UTC timezone.
-
 
 2004-07-12  Harish Krishnaswamy  <kharish novell com>
 
Index: libecal/e-cal-component.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal-component.c,v
retrieving revision 1.8
diff -u -p -r1.8 e-cal-component.c
--- libecal/e-cal-component.c	7 May 2004 16:04:17 -0000	1.8
+++ libecal/e-cal-component.c	15 Jul 2004 17:44:36 -0000
@@ -1211,12 +1211,36 @@ ensure_alarm_properties_cb (gpointer key
 	case ICAL_ACTION_DISPLAY:
 		/* Ensure we have a DESCRIPTION property */
 		prop = icalcomponent_get_first_property (alarm, ICAL_DESCRIPTION_PROPERTY);
-		if (prop)
-			break;
+		if (prop) {
+			if (priv->summary.prop) {
+				icalproperty *xprop;
+
+				xprop = icalcomponent_get_first_property (alarm, ICAL_X_PROPERTY);
+				while (xprop) {
+					str = icalproperty_get_x_name (xprop);
+					if (!strcmp (str, "X-EVOLUTION-NEEDS-DESCRIPTION")) {
+						icalproperty_set_description (prop, priv->summary.prop);
+
+						icalcomponent_remove_property (alarm, xprop);
+						icalproperty_free (xprop);
+						break;
+					}
+
+					xprop = icalcomponent_get_next_property (alarm, ICAL_X_PROPERTY);
+				}
+
+				break;
+			}
+		}
 
-		if (!priv->summary.prop)
+		if (!priv->summary.prop) {
 			str = _("Untitled appointment");
-		else
+
+			/* add the X-EVOLUTION-NEEDS-DESCRIPTION property */
+			prop = icalproperty_new_x ("1");
+			icalproperty_set_x_name (prop, "X-EVOLUTION-NEEDS-DESCRIPTION");
+			icalcomponent_add_property (alarm, prop);
+		} else
 			str = icalproperty_get_summary (priv->summary.prop);
 
 		prop = icalproperty_new_description (str);
@@ -3802,6 +3826,42 @@ e_cal_component_get_summary (ECalCompone
 		summary->altrep = NULL;
 }
 
+static void
+set_alarm_description_cb (gpointer key, gpointer value, gpointer user_data)
+{
+	icalcomponent *alarm;
+	icalproperty *icalprop;
+	ECalComponentText *summary;
+
+	alarm = value;
+	summary = user_data;
+
+	/* set the new description on the alarm */
+	icalprop = icalcomponent_get_first_property (alarm, ICAL_DESCRIPTION_PROPERTY);
+	if (icalprop)
+		icalproperty_set_description (icalprop, summary->value);
+	else {
+		icalprop = icalproperty_new_description (summary->value);
+		icalcomponent_add_property (alarm, icalprop);
+	}
+
+	/* remove the X-EVOLUTION-NEEDS_DESCRIPTION property */
+	icalprop = icalcomponent_get_first_property (alarm, ICAL_X_PROPERTY);
+	while (icalprop) {
+		const char *x_name;
+
+		x_name = icalproperty_get_x_name (icalprop);
+		if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) {
+			icalcomponent_remove_property (alarm, icalprop);
+			icalproperty_free (icalprop);
+
+			break;
+		}
+
+		icalprop = icalcomponent_get_next_property (alarm, ICAL_X_PROPERTY);
+	}
+}
+
 /**
  * e_cal_component_set_summary:
  * @comp: A calendar component object.
@@ -3857,6 +3917,9 @@ e_cal_component_set_summary (ECalCompone
  		icalproperty_remove_parameter (priv->summary.prop, ICAL_ALTREP_PARAMETER);
  		priv->summary.altrep_param = NULL; 
 	}
+
+	/* look for alarms that need a description */
+	g_hash_table_foreach (priv->alarm_uid_hash, set_alarm_description_cb, summary);
 }
 
 /**
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2446
diff -u -p -r1.2446 ChangeLog
--- ChangeLog	15 Jul 2004 03:57:52 -0000	1.2446
+++ ChangeLog	15 Jul 2004 17:46:06 -0000
@@ -1,3 +1,18 @@
+2004-07-15  Rodrigo Moya <rodrigo novell com>
+
+	Fixes #57142
+
+	* gui/e-day-view.c (e_day_view_on_editing_stopped): commit the
+	sequence on the object before sending it to the backend.
+	(e_day_view_add_event): s/abort_sequence/commit_sequence.
+
+	* gui/e-week-view.c (e_week_view_on_editing_stopped): commit the
+	sequence here also.
+	(e_week_view_add_event): s/abort_sequence/commit_sequence.
+
+	* gui/comp-util.c (cal_comp_event_new_with_current_time): don't
+	commit the sequence here.
+
 2004-07-14  JP Rosevear  <jpr novell com>
 
 	Fixes #60678
Index: gui/comp-util.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/comp-util.c,v
retrieving revision 1.25
diff -u -p -r1.25 comp-util.c
--- gui/comp-util.c	15 Mar 2004 16:53:50 -0000	1.25
+++ gui/comp-util.c	15 Jul 2004 17:46:07 -0000
@@ -348,8 +348,6 @@ cal_comp_event_new_with_current_time (EC
 		e_cal_component_set_dtend (comp, &dt);
 	}
 
-	e_cal_component_commit_sequence (comp);
-
 	return comp;
 }
 
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.249
diff -u -p -r1.249 e-day-view.c
--- gui/e-day-view.c	14 Jul 2004 02:20:55 -0000	1.249
+++ gui/e-day-view.c	15 Jul 2004 17:46:10 -0000
@@ -4124,7 +4124,7 @@ e_day_view_add_event (ECalComponent *com
 		event.comp_data = g_new0 (ECalModelComponent, 1);
 
 		event.comp_data->client = g_object_ref (e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (add_event_data->day_view))));
-		e_cal_component_commit_sequence (comp);
+		e_cal_component_abort_sequence (comp);
 		event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
 	}
 
@@ -6045,6 +6045,7 @@ e_day_view_on_editing_stopped (EDayView 
 		summary.value = text;
 		summary.altrep = NULL;
 		e_cal_component_set_summary (comp, &summary);
+		e_cal_component_commit_sequence (comp);
 
 		if (!on_server) {
 			if (!e_cal_create_object (client, icalcomp, NULL, NULL))
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.217
diff -u -p -r1.217 e-week-view.c
--- gui/e-week-view.c	14 Jul 2004 02:20:55 -0000	1.217
+++ gui/e-week-view.c	15 Jul 2004 17:46:12 -0000
@@ -2419,7 +2419,7 @@ e_week_view_add_event (ECalComponent *co
 		event.comp_data = g_new0 (ECalModelComponent, 1);
 
 		event.comp_data->client = g_object_ref (e_cal_model_get_default_client (e_calendar_view_get_model (E_CALENDAR_VIEW (add_event_data->week_view))));
-		e_cal_component_commit_sequence (comp);
+		e_cal_component_abort_sequence (comp);
 		event.comp_data->icalcomp = icalcomponent_new_clone (e_cal_component_get_icalcomponent (comp));
 	}
 	event.start = start;
@@ -3329,6 +3329,7 @@ e_week_view_on_editing_stopped (EWeekVie
 		summary.value = text;
 		summary.altrep = NULL;
 		e_cal_component_set_summary (comp, &summary);
+		e_cal_component_commit_sequence (comp);
 		
 		if (!on_server) {
 			if (!e_cal_create_object (client, icalcomp, NULL, NULL))


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