aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r--calendar/gui/alarm-notify/Makefile.am2
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c1
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c11
-rw-r--r--calendar/gui/alarm-notify/config-data.c107
-rw-r--r--calendar/gui/alarm-notify/config-data.h10
-rw-r--r--calendar/gui/alarm-notify/notify-main.c1
-rw-r--r--calendar/gui/alarm-notify/save.c144
-rw-r--r--calendar/gui/alarm-notify/save.h35
8 files changed, 118 insertions, 193 deletions
diff --git a/calendar/gui/alarm-notify/Makefile.am b/calendar/gui/alarm-notify/Makefile.am
index 8d1772b6b7..fdfc0443b0 100644
--- a/calendar/gui/alarm-notify/Makefile.am
+++ b/calendar/gui/alarm-notify/Makefile.am
@@ -43,8 +43,6 @@ evolution_alarm_notify_SOURCES = \
config-data.c \
config-data.h \
notify-main.c \
- save.c \
- save.h \
util.c \
util.h
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index a88cfccb91..4b956ec93c 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -26,7 +26,6 @@
#include <libecal/e-cal.h>
#include "alarm-notify.h"
#include "alarm-queue.h"
-#include "save.h"
#include "common/authentication.h"
#include "e-util/e-url.h"
diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c
index 24c89ce0d4..ddf9666ebb 100644
--- a/calendar/gui/alarm-notify/alarm-queue.c
+++ b/calendar/gui/alarm-notify/alarm-queue.c
@@ -48,7 +48,6 @@
#include "alarm-notify-dialog.h"
#include "alarm-queue.h"
#include "config-data.h"
-#include "save.h"
#include "util.h"
@@ -274,7 +273,7 @@ alarm_trigger_cb (gpointer alarm_id, time_t trigger, gpointer data)
cqa = data;
comp = cqa->alarms->comp;
- save_notification_time (trigger);
+ config_data_set_last_notification_time (trigger);
saved_notification_time = trigger;
qa = lookup_queued_alarm (cqa, alarm_id);
@@ -1097,7 +1096,7 @@ procedure_notification_dialog (const char *cmd, const char *url)
char *str;
int btn;
- if (is_blessed_program (url))
+ if (config_data_is_blessed_program (url))
return TRUE;
dialog = gtk_dialog_new_with_buttons (_("Warning"),
@@ -1128,7 +1127,7 @@ procedure_notification_dialog (const char *cmd, const char *url)
/* Run the dialog */
btn = gtk_dialog_run (GTK_DIALOG (dialog));
if (btn == GTK_RESPONSE_OK && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)))
- save_blessed_program (url);
+ config_data_save_blessed_program (url);
gtk_widget_destroy (dialog);
return (btn == GTK_RESPONSE_OK);
@@ -1213,10 +1212,10 @@ alarm_queue_init (void)
client_alarms_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
queue_midnight_refresh ();
- saved_notification_time = get_saved_notification_time ();
+ saved_notification_time = config_data_get_last_notification_time ();
if (saved_notification_time == -1) {
saved_notification_time = time (NULL);
- save_notification_time (saved_notification_time);
+ config_data_set_last_notification_time (saved_notification_time);
}
alarm_queue_inited = TRUE;
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
index 3cad23d5cd..afa8a8f7f4 100644
--- a/calendar/gui/alarm-notify/config-data.c
+++ b/calendar/gui/alarm-notify/config-data.c
@@ -22,12 +22,15 @@
#include <config.h>
#endif
+#include <string.h>
#include <libedataserver/e-source-list.h>
#include "config-data.h"
-#include "save.h"
+#define KEY_LAST_NOTIFICATION_TIME "/apps/evolution/calendar/notify/last_notification_time"
+#define KEY_PROGRAMS "/apps/evolution/calendar/notify/programs"
+
/* Whether we have initied ourselves by reading the data from the configuration engine */
static gboolean inited = FALSE;
static GConfClient *conf_client = NULL;
@@ -166,3 +169,105 @@ config_data_get_calendars_to_load (void)
return cals;
}
+
+/**
+ * config_data_set_last_notification_time:
+ * @t: A time value.
+ *
+ * Saves the last notification time so that it can be fetched the next time the
+ * alarm daemon is run. This way the daemon can show alarms that should have
+ * triggered while it was not running.
+ **/
+void
+config_data_set_last_notification_time (time_t t)
+{
+ GConfClient *conf_client;
+ time_t current_t;
+
+ g_return_if_fail (t != -1);
+
+ if (!(conf_client = config_data_get_conf_client ()))
+ return;
+
+ /* we only store the new notification time if it is bigger
+ than the already stored one */
+ current_t = gconf_client_get_int (conf_client, KEY_LAST_NOTIFICATION_TIME, NULL);
+ if (t > current_t)
+ gconf_client_set_int (conf_client, KEY_LAST_NOTIFICATION_TIME, t, NULL);
+}
+
+/**
+ * config_data_get_last_notification_time:
+ *
+ * Queries the last saved value for alarm notification times.
+ *
+ * Return value: The last saved value, or -1 if no value had been saved before.
+ **/
+time_t
+config_data_get_last_notification_time (void)
+{
+ GConfClient *conf_client;
+ GConfValue *value;
+
+ if (!(conf_client = config_data_get_conf_client ()))
+ return -1;
+
+ value = gconf_client_get_without_default (conf_client, KEY_LAST_NOTIFICATION_TIME, NULL);
+ if (value)
+ return (time_t) gconf_value_get_int (value);
+
+ return time (NULL);
+}
+
+/**
+ * config_data_save_blessed_program:
+ * @program: a program name
+ *
+ * Saves a program name as "blessed"
+ **/
+void
+config_data_save_blessed_program (const char *program)
+{
+ GConfClient *conf_client;
+ GSList *l;
+
+ if (!(conf_client = config_data_get_conf_client ()))
+ return;
+
+ l = gconf_client_get_list (conf_client, KEY_PROGRAMS, GCONF_VALUE_STRING, NULL);
+ l = g_slist_append (l, g_strdup (program));
+ gconf_client_set_list (conf_client, KEY_PROGRAMS, GCONF_VALUE_STRING, l, NULL);
+ g_slist_foreach (l, (GFunc) g_free, NULL);
+ g_slist_free (l);
+}
+
+/**
+ * config_data_is_blessed_program:
+ * @program: a program name
+ *
+ * Checks to see if a program is blessed
+ *
+ * Return value: TRUE if program is blessed, FALSE otherwise
+ **/
+gboolean
+config_data_is_blessed_program (const char *program)
+{
+ GConfClient *conf_client;
+ GSList *l, *n;
+ gboolean found = FALSE;
+
+ if (!(conf_client = config_data_get_conf_client ()))
+ return FALSE;
+
+ l = gconf_client_get_list (conf_client, KEY_PROGRAMS, GCONF_VALUE_STRING, NULL);
+ while (l) {
+ n = l->next;
+ if (!found)
+ found = strcmp ((char *) l->data, program) == 0;
+ g_free (l->data);
+ g_slist_free_1 (l);
+ l = n;
+ }
+
+ return found;
+}
diff --git a/calendar/gui/alarm-notify/config-data.h b/calendar/gui/alarm-notify/config-data.h
index 26b5dc111f..f5af885653 100644
--- a/calendar/gui/alarm-notify/config-data.h
+++ b/calendar/gui/alarm-notify/config-data.h
@@ -25,10 +25,14 @@
#include <libical/ical.h>
#include <gconf/gconf-client.h>
-GConfClient *config_data_get_conf_client (void);
+GConfClient *config_data_get_conf_client (void);
icaltimezone *config_data_get_timezone (void);
-gboolean config_data_get_24_hour_format (void);
-GPtrArray *config_data_get_calendars_to_load (void);
+gboolean config_data_get_24_hour_format (void);
+GPtrArray *config_data_get_calendars_to_load (void);
+void config_data_set_last_notification_time (time_t t);
+time_t config_data_get_last_notification_time (void);
+void config_data_save_blessed_program (const char *program);
+gboolean config_data_is_blessed_program (const char *program);
#endif
diff --git a/calendar/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c
index 79a2468f8a..f9bae936fa 100644
--- a/calendar/gui/alarm-notify/notify-main.c
+++ b/calendar/gui/alarm-notify/notify-main.c
@@ -42,7 +42,6 @@
#include "alarm-queue.h"
#include "alarm-notify.h"
#include "config-data.h"
-#include "save.h"
diff --git a/calendar/gui/alarm-notify/save.c b/calendar/gui/alarm-notify/save.c
deleted file mode 100644
index 5433cac806..0000000000
--- a/calendar/gui/alarm-notify/save.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Evolution calendar - Functions to save alarm notification times
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-#include <bonobo/bonobo-arg.h>
-#include <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-moniker-util.h>
-#include "evolution-calendar.h"
-#include "config-data.h"
-#include "save.h"
-#include <gconf/gconf-client.h>
-
-
-
-/* Key names for the configuration values */
-
-#define KEY_LAST_NOTIFICATION_TIME "/apps/evolution/calendar/notify/last_notification_time"
-#define KEY_CALENDARS "/apps/evolution/calendar/notify/calendars"
-#define KEY_PROGRAMS "/apps/evolution/calendar/notify/programs"
-
-
-
-/**
- * save_notification_time:
- * @t: A time value.
- *
- * Saves the last notification time so that it can be fetched the next time the
- * alarm daemon is run. This way the daemon can show alarms that should have
- * triggered while it was not running.
- **/
-void
-save_notification_time (time_t t)
-{
- GConfClient *conf_client;
- time_t current_t;
-
- g_return_if_fail (t != -1);
-
- if (!(conf_client = config_data_get_conf_client ()))
- return;
-
- /* we only store the new notification time if it is bigger
- than the already stored one */
- current_t = gconf_client_get_int (conf_client, KEY_LAST_NOTIFICATION_TIME, NULL);
- if (t > current_t)
- gconf_client_set_int (conf_client, KEY_LAST_NOTIFICATION_TIME, t, NULL);
-}
-
-/**
- * get_saved_notification_time:
- *
- * Queries the last saved value for alarm notification times.
- *
- * Return value: The last saved value, or -1 if no value had been saved before.
- **/
-time_t
-get_saved_notification_time (void)
-{
- GConfClient *conf_client;
- GConfValue *value;
-
- if (!(conf_client = config_data_get_conf_client ()))
- return -1;
-
- value = gconf_client_get_without_default (conf_client, KEY_LAST_NOTIFICATION_TIME, NULL);
- if (value)
- return (time_t) gconf_value_get_int (value);
-
- return time (NULL);
-}
-
-/**
- * save_blessed_program:
- * @program: a program name
- *
- * Saves a program name as "blessed"
- **/
-void
-save_blessed_program (const char *program)
-{
- GConfClient *conf_client;
- GSList *l;
-
- if (!(conf_client = config_data_get_conf_client ()))
- return;
-
- l = gconf_client_get_list (conf_client, KEY_PROGRAMS, GCONF_VALUE_STRING, NULL);
- l = g_slist_append (l, g_strdup (program));
- gconf_client_set_list (conf_client, KEY_PROGRAMS, GCONF_VALUE_STRING, l, NULL);
- g_slist_foreach (l, (GFunc) g_free, NULL);
- g_slist_free (l);
-}
-
-/**
- * is_blessed_program:
- * @program: a program name
- *
- * Checks to see if a program is blessed
- *
- * Return value: TRUE if program is blessed, FALSE otherwise
- **/
-gboolean
-is_blessed_program (const char *program)
-{
- GConfClient *conf_client;
- GSList *l, *n;
- gboolean found = FALSE;
-
- if (!(conf_client = config_data_get_conf_client ()))
- return FALSE;
-
- l = gconf_client_get_list (conf_client, KEY_PROGRAMS, GCONF_VALUE_STRING, NULL);
- while (l) {
- n = l->next;
- if (!found)
- found = strcmp ((char *) l->data, program) == 0;
- g_free (l->data);
- g_slist_free_1 (l);
- l = n;
- }
-
- return found;
-}
diff --git a/calendar/gui/alarm-notify/save.h b/calendar/gui/alarm-notify/save.h
deleted file mode 100644
index f7cc75955c..0000000000
--- a/calendar/gui/alarm-notify/save.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Evolution calendar - Functions to save alarm notification times
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Authors: Federico Mena-Quintero <federico@ximian.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef SAVE_H
-#define SAVE_H
-
-#include <time.h>
-
-void save_notification_time (time_t t);
-time_t get_saved_notification_time (void);
-
-void save_calendars_to_load (GPtrArray *uris);
-GPtrArray *get_calendars_to_load (void);
-
-void save_blessed_program (const char *program);
-gboolean is_blessed_program (const char *program);
-
-#endif