aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/alarm-notify/save.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2002-08-26 23:56:05 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2002-08-26 23:56:05 +0800
commit4e8966108728859537ec045decb368251bf078dc (patch)
tree17066ea78b122d70ec7deb6594cd33d828c0d18b /calendar/gui/alarm-notify/save.c
parentf95a4634519d4e41c4d1f29ab4f6cf0503a37995 (diff)
downloadgsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.tar
gsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.tar.gz
gsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.tar.bz2
gsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.tar.lz
gsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.tar.xz
gsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.tar.zst
gsoc2013-evolution-4e8966108728859537ec045decb368251bf078dc.zip
Fixes #12326
2002-08-26 Rodrigo Moya <rodrigo@ximian.com> Fixes #12326 * gui/alarm-notify/config-data.c (ensure_inited): create a EConfigListener for configuration access. (do_cleanup): g_atexit installed function, to clean up configuration database resources. (config_data_get_timezone): retrieve the configuration for the EConfigListener object. (config_data_get_listener): new function. * gui/alarm-notify/save.c (get_config_db, discard_config_db): removed. Use EConfigListener instead. (save_notification_time, get_saved_notification_time, save_calendars_to_load, get_calendars_to_load, save_blessed_program, is_blessed_program): use EConfigListener. * gui/alarm-notify/notify-main.c (init_alarm_notify_service): removed. (alarm_notify_factory_fn): create here the alarm_notify_service if it hasn't been created yet. (load_calendars): likewise. (main): don't call init_alarm_notify_service. svn path=/trunk/; revision=17859
Diffstat (limited to 'calendar/gui/alarm-notify/save.c')
-rw-r--r--calendar/gui/alarm-notify/save.c126
1 files changed, 24 insertions, 102 deletions
diff --git a/calendar/gui/alarm-notify/save.c b/calendar/gui/alarm-notify/save.c
index 92dc94b65a..455af7f883 100644
--- a/calendar/gui/alarm-notify/save.c
+++ b/calendar/gui/alarm-notify/save.c
@@ -26,6 +26,7 @@
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
#include "evolution-calendar.h"
+#include "config-data.h"
#include "save.h"
@@ -40,48 +41,6 @@
-/* Tries to get the config database object; returns CORBA_OBJECT_NIL on failure. */
-Bonobo_ConfigDatabase
-get_config_db (void)
-{
- CORBA_Environment ev;
- Bonobo_ConfigDatabase db;
-
- CORBA_exception_init (&ev);
-
- db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
- if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
- g_message ("get_config_db(): Could not get the config database object");
- db = CORBA_OBJECT_NIL;
- }
-
- CORBA_exception_free (&ev);
- return db;
-}
-
-/* Syncs a database and unrefs it */
-void
-discard_config_db (Bonobo_ConfigDatabase db)
-{
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
-
- Bonobo_ConfigDatabase_sync (db, &ev);
- if (BONOBO_EX (&ev))
- g_message ("discard_config_db(): Got an exception during the sync command");
-
- CORBA_exception_free (&ev);
-
- CORBA_exception_init (&ev);
-
- bonobo_object_release_unref (db, &ev);
- if (BONOBO_EX (&ev))
- g_message ("discard_config_db(): Could not release/unref the database");
-
- CORBA_exception_free (&ev);
-}
-
/**
* save_notification_time:
* @t: A time value.
@@ -93,24 +52,14 @@ discard_config_db (Bonobo_ConfigDatabase db)
void
save_notification_time (time_t t)
{
- Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
+ EConfigListener *cl;
g_return_if_fail (t != -1);
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
+ if (!(cl = config_data_get_listener ()))
return;
- CORBA_exception_init (&ev);
-
- bonobo_config_set_long (db, KEY_LAST_NOTIFICATION_TIME, (long) t, &ev);
- if (BONOBO_EX (&ev))
- g_message ("save_notification_time(): Could not save the value");
-
- CORBA_exception_free (&ev);
-
- discard_config_db (db);
+ e_config_listener_set_long (cl, KEY_LAST_NOTIFICATION_TIME, (long) t);
}
/**
@@ -123,16 +72,13 @@ save_notification_time (time_t t)
time_t
get_saved_notification_time (void)
{
- Bonobo_ConfigDatabase db;
+ EConfigListener *cl;
long t;
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
+ if (!(cl = config_data_get_listener ()))
return -1;
- t = bonobo_config_get_long_with_default (db, KEY_LAST_NOTIFICATION_TIME, -1, NULL);
-
- discard_config_db (db);
+ t = e_config_listener_get_long_with_default (cl, KEY_LAST_NOTIFICATION_TIME, -1, NULL);
return (time_t) t;
}
@@ -147,23 +93,17 @@ get_saved_notification_time (void)
void
save_calendars_to_load (GPtrArray *uris)
{
- Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
+ EConfigListener *cl;
int len, i;
g_return_if_fail (uris != NULL);
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
+ if (!(cl = config_data_get_listener ()))
return;
len = uris->len;
- CORBA_exception_init (&ev);
-
- bonobo_config_set_long (db, KEY_NUM_CALENDARS_TO_LOAD, len, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", KEY_NUM_CALENDARS_TO_LOAD, BONOBO_EX_ID (&ev));
+ e_config_listener_set_long (cl, KEY_NUM_CALENDARS_TO_LOAD, len);
for (i = 0; i < len; i++) {
const char *uri;
@@ -172,15 +112,9 @@ save_calendars_to_load (GPtrArray *uris)
uri = uris->pdata[i];
key = g_strdup_printf ("%s%d", BASE_KEY_CALENDAR_TO_LOAD, i);
- bonobo_config_set_string (db, key, uri, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev));
+ e_config_listener_set_string (cl, key, uri);
g_free (key);
}
-
- CORBA_exception_free (&ev);
-
- discard_config_db (db);
}
/**
@@ -194,19 +128,18 @@ save_calendars_to_load (GPtrArray *uris)
GPtrArray *
get_calendars_to_load (void)
{
- Bonobo_ConfigDatabase db;
+ EConfigListener *cl;
GPtrArray *uris;
int len, i;
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
+ if (!(cl = config_data_get_listener ()))
return NULL;
/* Getting the default value below is not necessarily an error, as we
* may not have saved the list of calendar yet.
*/
- len = bonobo_config_get_long_with_default (db, KEY_NUM_CALENDARS_TO_LOAD, 0, NULL);
+ len = e_config_listener_get_long_with_default (cl, KEY_NUM_CALENDARS_TO_LOAD, 0, NULL);
uris = g_ptr_array_new ();
g_ptr_array_set_size (uris, len);
@@ -216,7 +149,7 @@ get_calendars_to_load (void)
gboolean used_default;
key = g_strdup_printf ("%s%d", BASE_KEY_CALENDAR_TO_LOAD, i);
- uris->pdata[i] = bonobo_config_get_string_with_default (db, key, "", &used_default);
+ uris->pdata[i] = e_config_listener_get_string_with_default (cl, key, "", &used_default);
if (used_default)
g_message ("get_calendars_to_load(): Could not read calendar name %d", i);
@@ -235,35 +168,25 @@ get_calendars_to_load (void)
void
save_blessed_program (const char *program)
{
- Bonobo_ConfigDatabase db;
- CORBA_Environment ev;
+ EConfigListener *cl;
char *key;
int len;
g_return_if_fail (program != NULL);
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
+ if (!(cl = config_data_get_listener ()))
return;
/* Up the number saved */
- len = bonobo_config_get_long_with_default (db, KEY_NUM_BLESSED_PROGRAMS, 0, NULL);
+ len = e_config_listener_get_long_with_default (cl, KEY_NUM_BLESSED_PROGRAMS, 0, NULL);
len++;
- bonobo_config_set_long (db, KEY_NUM_BLESSED_PROGRAMS, len, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", KEY_NUM_BLESSED_PROGRAMS, BONOBO_EX_ID (&ev));
+ e_config_listener_set_long (cl, KEY_NUM_BLESSED_PROGRAMS, len);
/* Save the program name */
key = g_strdup_printf ("%s%d", BASE_KEY_BLESSED_PROGRAM, len - 1);
- bonobo_config_set_string (db, key, program, &ev);
- if (BONOBO_EX (&ev))
- g_warning ("Cannot save config key %s -- %s", key, BONOBO_EX_ID (&ev));
+ e_config_listener_set_string (cl, key, program);
g_free (key);
-
- CORBA_exception_free (&ev);
-
- discard_config_db (db);
}
/**
@@ -277,27 +200,26 @@ save_blessed_program (const char *program)
gboolean
is_blessed_program (const char *program)
{
- Bonobo_ConfigDatabase db;
+ EConfigListener *cl;
int len, i;
g_return_val_if_fail (program != NULL, FALSE);
- db = get_config_db ();
- if (db == CORBA_OBJECT_NIL)
+ if (!(cl = config_data_get_listener ()))
return FALSE;
/* Getting the default value below is not necessarily an error, as we
* may not have saved the list of calendar yet.
*/
- len = bonobo_config_get_long_with_default (db, KEY_NUM_BLESSED_PROGRAMS, 0, NULL);
+ len = e_config_listener_get_long_with_default (cl, KEY_NUM_BLESSED_PROGRAMS, 0, NULL);
for (i = 0; i < len; i++) {
char *key, *value;
gboolean used_default;
key = g_strdup_printf ("%s%d", BASE_KEY_BLESSED_PROGRAM, i);
- value = bonobo_config_get_string_with_default (db, key, "", &used_default);
+ value = e_config_listener_get_string_with_default (cl, key, "", &used_default);
if (used_default)
g_message ("get_calendars_to_load(): Could not read calendar name %d", i);