Re: [evolution-patches] Fix for reloading/unloading calendars when source list changes



On Fri, 2004-08-27 at 17:04 +0200, Rodrigo Moya wrote:
> On Fri, 2004-08-27 at 09:19 -0400, JP Rosevear wrote:
> > Rodrigo's alarm daemon patch will conflict with this now, in
> > load_calendars_cb.  list_changed_cb would blow away the sources for the
> > source types it wasn't processing.
> > 
> your patch and mines attached to this message fix the problems we were
> trying to fix, so approved.
>
updated alarm queue patch
-- 
Rodrigo Moya <rodrigo novell com>
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2497
diff -u -p -r1.2497 ChangeLog
--- ChangeLog	27 Aug 2004 15:41:04 -0000	1.2497
+++ ChangeLog	27 Aug 2004 15:56:24 -0000
@@ -1,3 +1,9 @@
+2004-08-27  Rodrigo Moya <rodrigo novell com>
+
+	* gui/alarm-notify/alarm-queue.c (load_alarms): use the
+	new 'has-alarms-in-range' query.
+	(alarm_queu_add_client): make sure we don't add twice the same alarm.
+
 2004-08-27  JP Rosevear  <jpr novell com>
 
 	* gui/alarm-notify/alarm-notify.h: update proto
@@ -23,7 +29,7 @@
 	record correctly, should fix copy to/from problems when syncing
 
 	* conduits/calendar/calendar-conduit.c (for_each): ditto
-	
+
 2004-08-25  Frederic Crozat  <fcrozat mandrakesoft com>
 
 	* gui/dialogs/recur-comp.c: (recur_component_dialog):
Index: gui/alarm-notify/alarm-queue.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/alarm-queue.c,v
retrieving revision 1.69
diff -u -p -r1.69 alarm-queue.c
--- gui/alarm-notify/alarm-queue.c	10 Aug 2004 14:14:43 -0000	1.69
+++ gui/alarm-notify/alarm-queue.c	27 Aug 2004 15:56:24 -0000
@@ -390,20 +390,38 @@ load_alarms (ClientAlarms *ca, time_t st
 {
 	/* create the live query */
 	if (!ca->query) {
-		/* FIXME: handle errors */
-		if (!e_cal_get_query (ca->client, "(has-alarms?)", &ca->query, NULL)) {
-			g_warning (G_STRLOC ": Could not get query for client");
+		char *str_query, *iso_start, *iso_end;
+
+		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;
 		}
 
-		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);
+
+		/* 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);
+		}
 
-		e_cal_view_start (ca->query);
+		g_free (str_query);
 	}
 }
 
@@ -1292,14 +1310,13 @@ alarm_queue_add_client (ECal *client)
 
 	ca->uid_alarms_hash = g_hash_table_new (g_str_hash, g_str_equal);
 
-	if (e_cal_get_load_state (client) != E_CAL_LOAD_LOADED)
-		g_signal_connect (client, "cal_opened",
-				  G_CALLBACK (cal_opened_cb),
-				  ca);
-
 	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),
+				  ca);
 	}
 }
 


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