[evolution-patches] patch for evolution 2.0 (calendar)



This fixes bug http://bugzilla.ximian.com/show_bug.cgi?id=62374 for
evolution 2.0.

The patch is about missing some alarms, specially when getting to
midnight, where we were not redoing the query to the calendars to get
alarms for the new day.
-- 
Rodrigo Moya <rodrigo novell com>
? gui/apps_evolution_calendar-2.0.schemas
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2500.2.2
diff -u -p -r1.2500.2.2 ChangeLog
--- ChangeLog	3 Sep 2004 16:38:54 -0000	1.2500.2.2
+++ ChangeLog	10 Sep 2004 16:48:13 -0000
@@ -1,3 +1,17 @@
+2004-09-10  Rodrigo Moya <rodrigo novell com>
+
+	Fixes #62374
+
+	* gui/alarm-notify/alarm-queue.c (load_missed_alarms): removed this
+	function.
+	(cal_opened_cb): no need to call load_missed_alarms,
+	load_alarms_for_today will do everything.
+	(alarm_queue_add_client): ditto.
+	(load_alarms_for_today): take into account the last saved notification
+	time.
+	(load_alarms): unref the previous query, this function should now
+	only be called once per time range.
+
 2004-08-31  Rodrigo Moya <rodrigo novell com>
 
 	Fixes #62392
Index: gui/alarm-notify/alarm-queue.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/alarm-queue.c,v
retrieving revision 1.71.2.1
diff -u -p -r1.71.2.1 alarm-queue.c
--- gui/alarm-notify/alarm-queue.c	3 Sep 2004 16:38:54 -0000	1.71.2.1
+++ gui/alarm-notify/alarm-queue.c	10 Sep 2004 16:48:13 -0000
@@ -388,76 +388,66 @@ add_component_alarms (ClientAlarms *ca, 
 static void
 load_alarms (ClientAlarms *ca, time_t start, time_t end)
 {
-	/* create the live query */
-	if (!ca->query) {
-		char *str_query, *iso_start, *iso_end;
+	char *str_query, *iso_start, *iso_end;
 
-		iso_start = isodate_from_time_t (start);
-		if (!iso_start)
-			return;
+	iso_start = isodate_from_time_t (start);
+	if (!iso_start)
+		return;
                                                                                
-		iso_end = isodate_from_time_t (end);
-		if (!iso_end) {
-			g_free (iso_start);
-			return;
-		}
-
-		str_query = g_strdup_printf ("(has-alarms-in-range? (make-time \"%s\") (make-time \"%s\"))",
-					     iso_start, iso_end);
+	iso_end = isodate_from_time_t (end);
+	if (!iso_end) {
 		g_free (iso_start);
-		g_free (iso_end);
+		return;
+	}
 
-		/* FIXME: handle errors */
-		if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) {
-			g_warning (G_STRLOC ": Could not get query for client");
-		} else {
-			g_signal_connect (G_OBJECT (ca->query), "objects_added",
-					  G_CALLBACK (query_objects_changed_cb), ca);
-			g_signal_connect (G_OBJECT (ca->query), "objects_modified",
-					  G_CALLBACK (query_objects_changed_cb), ca);
-			g_signal_connect (G_OBJECT (ca->query), "objects_removed",
-					  G_CALLBACK (query_objects_removed_cb), ca);
+	str_query = g_strdup_printf ("(has-alarms-in-range? (make-time \"%s\") (make-time \"%s\"))",
+				     iso_start, iso_end);
+	g_free (iso_start);
+	g_free (iso_end);
 
-			e_cal_view_start (ca->query);
-		}
+	/* create the live query */
+	if (ca->query) {
+		g_object_unref (ca->query);
+		ca->query = NULL;
+	}
 
-		g_free (str_query);
+	/* FIXME: handle errors */
+	if (!e_cal_get_query (ca->client, str_query, &ca->query, NULL)) {
+		g_warning (G_STRLOC ": Could not get query for client");
+	} else {
+		g_signal_connect (G_OBJECT (ca->query), "objects_added",
+				  G_CALLBACK (query_objects_changed_cb), ca);
+		g_signal_connect (G_OBJECT (ca->query), "objects_modified",
+				  G_CALLBACK (query_objects_changed_cb), ca);
+		g_signal_connect (G_OBJECT (ca->query), "objects_removed",
+				  G_CALLBACK (query_objects_removed_cb), ca);
+
+		e_cal_view_start (ca->query);
 	}
+
+	g_free (str_query);
 }
 
 /* Loads today's remaining alarms for a client */
 static void
 load_alarms_for_today (ClientAlarms *ca)
 {
-	time_t now, day_end;
+	time_t now, from, day_end;
 	icaltimezone *zone;
 
 	now = time (NULL);
 
+	/* Make sure we don't miss some events from the last notification.
+	 * We add 1 to the saved_notification_time to make the time ranges
+	 * half-open; we do not want to display the "last" displayed alarm
+	 * twice, once when it occurs and once when the alarm daemon restarts.
+	 */
+	from = MIN (config_data_get_last_notification_time () + 1, now);
 	zone = config_data_get_timezone ();
 
 	g_message ("Loading alarms for today");
 	day_end = time_day_end_with_zone (now, zone);
-	load_alarms (ca, now, day_end);
-}
-
-/* Adds any alarms that should have occurred while the alarm daemon was not
- * running.
- */
-static void
-load_missed_alarms (ClientAlarms *ca)
-{
-	time_t now;
-
-	now = time (NULL);
-
-	g_assert (saved_notification_time != -1);
-
-	/* We add 1 to the saved_notification_time to make the time ranges
-	 * half-open; we do not want to display the "last" displayed alarm
-	 * twice, once when it occurs and once when the alarm daemon restarts.
-	 */
-	load_alarms (ca, saved_notification_time + 1, now);
+	load_alarms (ca, from, day_end);
 }
 
 /* Called when a calendar client finished loading; we load its alarms */
@@ -472,7 +462,6 @@ cal_opened_cb (ECal *client, ECalendarSt
 		return;
 
 	load_alarms_for_today (ca);
-	load_missed_alarms (ca);
 }
 
 /* Looks up a component's queued alarm structure in a client alarms structure */
@@ -591,16 +580,16 @@ query_objects_changed_cb (ECal *client, 
 			ECalComponentAlarmInstance *instance;
 			gpointer alarm_id;
 			QueuedAlarm *qa;
-			
+
 			instance = sl->data;
-			
+
 			alarm_id = alarm_add (instance->trigger, alarm_trigger_cb, cqa, NULL);
 			if (!alarm_id) {
 				g_message (G_STRLOC ": Could not schedule a trigger for "
 					   "%ld, discarding...", (long) instance->trigger);
 				continue;
 			}
-			
+
 			qa = g_new (QueuedAlarm, 1);
 			qa->alarm_id = alarm_id;
 			qa->instance = instance;
@@ -1312,7 +1301,6 @@ alarm_queue_add_client (ECal *client)
 
 	if (e_cal_get_load_state (client) == E_CAL_LOAD_LOADED) {
 		load_alarms_for_today (ca);
-		load_missed_alarms (ca);
 	} else {
 		g_signal_connect (client, "cal_opened",
 				  G_CALLBACK (cal_opened_cb),


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