aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-07-27 23:06:20 +0800
committerMilan Crha <mcrha@redhat.com>2009-07-27 23:06:20 +0800
commit704ee96aa27011109be2b282517abc153657edaf (patch)
tree4025e5c25143db9b766192ec73f299d0e5b7a7ee /calendar/gui
parent5ea01cdeff88387ecfba874307fc938fbbfd1382 (diff)
downloadgsoc2013-evolution-704ee96aa27011109be2b282517abc153657edaf.tar.gz
gsoc2013-evolution-704ee96aa27011109be2b282517abc153657edaf.tar.zst
gsoc2013-evolution-704ee96aa27011109be2b282517abc153657edaf.zip
Bug #579646 - Remember alarm's last notified per calendar
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c24
-rw-r--r--calendar/gui/alarm-notify/config-data.c37
-rw-r--r--calendar/gui/alarm-notify/config-data.h5
3 files changed, 46 insertions, 20 deletions
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 066f295a7d..99e9a4f8e5 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -61,12 +61,6 @@ static AlarmNotificationsDialog *alarm_notifications_dialog = NULL;
/* Whether the queueing system has been initialized */
static gboolean alarm_queue_inited = FALSE;
-/* When the alarm queue system is inited, this gets set to the last time an
- * alarm notification was issued. This lets us present any notifications that
- * should have happened while the alarm daemon was not running.
- */
-static time_t saved_notification_time;
-
/* Clients we are monitoring for alarms */
static GHashTable *client_alarms_hash = NULL;
@@ -395,9 +389,8 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data)
cqa = data;
comp = cqa->alarms->comp;
- config_data_set_last_notification_time (trigger);
+ config_data_set_last_notification_time (cqa->parent_client->client, trigger);
d(printf("%s:%d (alarm_trigger_cb) - Setting Last notification time to %s\n",__FILE__, __LINE__, ctime (&trigger)));
- saved_notification_time = trigger;
qa = lookup_queued_alarm (cqa, alarm_id);
if (!qa)
@@ -577,11 +570,11 @@ load_alarms_for_today (ClientAlarms *ca)
day_start = time_day_begin_with_zone (now, zone);
/* 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
+ * 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 = MAX (config_data_get_last_notification_time () + 1, day_start);
+ from = MAX (config_data_get_last_notification_time (ca->client) + 1, day_start);
day_end = time_day_end_with_zone (now, zone);
d(printf("%s:%d (load_alarms_for_today) - From %s to %s\n",__FILE__, __LINE__, ctime (&from), ctime(&day_end)));
@@ -713,7 +706,7 @@ query_objects_changed_async (struct _query_msg *msg)
ca = msg->data;
objects = msg->objects;
- from = config_data_get_last_notification_time ();
+ from = config_data_get_last_notification_time (client);
if (from == -1)
from = time (NULL);
else
@@ -1845,11 +1838,10 @@ alarm_queue_init (gpointer data)
client_alarms_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
queue_midnight_refresh ();
- saved_notification_time = config_data_get_last_notification_time ();
- if (saved_notification_time == -1) {
- saved_notification_time = time (NULL);
- d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, ctime(&saved_notification_time)));
- config_data_set_last_notification_time (saved_notification_time);
+ if (config_data_get_last_notification_time (NULL) == -1) {
+ time_t tmval = time (NULL);
+ d(printf("%s:%d (alarm_queue_init) - Setting last notification time to %s\n",__FILE__, __LINE__, ctime(&tmval)));
+ config_data_set_last_notification_time (NULL, tmval);
}
/* install timeout handler (every 30 mins) for not missing the midnight refresh */
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
index 8f3b0aebc1..c66819f0c4 100644
--- a/calendar/gui/alarm-notify/config-data.c
+++ b/calendar/gui/alarm-notify/config-data.c
@@ -256,13 +256,30 @@ config_data_get_notify_with_tray (void)
* triggered while it was not running.
**/
void
-config_data_set_last_notification_time (time_t t)
+config_data_set_last_notification_time (ECal *cal, time_t t)
{
GConfClient *client;
time_t current_t, now = time (NULL);
g_return_if_fail (t != -1);
+ if (cal) {
+ ESource *source = e_cal_get_source (cal);
+ if (source) {
+ GTimeVal tmval = {0};
+ char *as_text;
+
+ tmval.tv_sec = (glong) t;
+ as_text = g_time_val_to_iso8601 (&tmval);
+
+ if (as_text) {
+ e_source_set_property (source, "last-notified", as_text);
+ g_free (as_text);
+ return;
+ }
+ }
+ }
+
if (!(client = config_data_get_conf_client ()))
return;
@@ -281,11 +298,27 @@ config_data_set_last_notification_time (time_t t)
* Return value: The last saved value, or -1 if no value had been saved before.
**/
time_t
-config_data_get_last_notification_time (void)
+config_data_get_last_notification_time (ECal *cal)
{
GConfValue *value;
GConfClient *client;
+ if (cal) {
+ ESource *source = e_cal_get_source (cal);
+ if (source) {
+ const gchar *last_notified = e_source_get_property (source, "last-notified");
+ GTimeVal tmval = {0};
+
+ if (last_notified && *last_notified && g_time_val_from_iso8601 (last_notified, &tmval)) {
+ time_t now = time (NULL), val = (time_t) tmval.tv_sec;
+
+ if (val > now)
+ val = now;
+ return val;
+ }
+ }
+ }
+
if (!(client = config_data_get_conf_client ()))
return -1;
diff --git a/calendar/gui/alarm-notify/config-data.h b/calendar/gui/alarm-notify/config-data.h
index 19086beb56..08f3915b83 100644
--- a/calendar/gui/alarm-notify/config-data.h
+++ b/calendar/gui/alarm-notify/config-data.h
@@ -28,6 +28,7 @@
#include <glib.h>
#include <libical/ical.h>
+#include <libecal/e-cal.h>
#include <gconf/gconf-client.h>
#include <libedataserver/e-source-list.h>
@@ -36,8 +37,8 @@ GConfClient *config_data_get_conf_client (void);
icaltimezone *config_data_get_timezone (void);
gboolean config_data_get_24_hour_format (void);
gboolean config_data_get_notify_with_tray (void);
-void config_data_set_last_notification_time (time_t t);
-time_t config_data_get_last_notification_time (void);
+void config_data_set_last_notification_time (ECal *cal, time_t t);
+time_t config_data_get_last_notification_time (ECal *cal);
void config_data_save_blessed_program (const gchar *program);
gboolean config_data_is_blessed_program (const gchar *program);
ESourceList *config_data_get_calendars (const gchar *);