diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2004-01-16 02:24:56 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2004-01-16 02:24:56 +0800 |
commit | b282f92587ff44751e4e4720a5adf39e395e2ad7 (patch) | |
tree | 6c4954c75c925ce8e3b69aaac8bb698906fe12c7 /calendar/gui/alarm-notify/config-data.c | |
parent | c1f42ab2b0820cd1b52dc75ab1e7dfdaae6d604c (diff) | |
download | gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.tar gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.tar.gz gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.tar.bz2 gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.tar.lz gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.tar.xz gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.tar.zst gsoc2013-evolution-b282f92587ff44751e4e4720a5adf39e395e2ad7.zip |
removed.
2004-01-15 Rodrigo Moya <rodrigo@ximian.com>
* gui/alarm-notify/save.[ch]: removed.
* gui/alarm-notify/Makefile.am: removed save.[ch].
* gui/alarm-notify/notify-main.c: removed obsolete headers.
* gui/alarm-notify/config-data.[ch]
(config_data_set_last_notification_time,
config_data_get_last_notification_time,
config_data_save_blessed_program, config_data_is_blessed_program):
new functions.
* gui/alarm-notify/alarm-queue.c: dont use removed functions.
(alarm_trigger_cb, procedure_notification_dialog,
alarm_queue_init):
use config_data_* functions.
* gui/alarm-notify/alarm-notify.c: dont use removed functions.
svn path=/trunk/; revision=24249
Diffstat (limited to 'calendar/gui/alarm-notify/config-data.c')
-rw-r--r-- | calendar/gui/alarm-notify/config-data.c | 107 |
1 files changed, 106 insertions, 1 deletions
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; +} |