aboutsummaryrefslogtreecommitdiffstats
path: root/importers
diff options
context:
space:
mode:
authorDietmar Maurer <dietmar@ximian.com>2001-07-04 02:15:31 +0800
committerDietmar Maurer <dietmar@src.gnome.org>2001-07-04 02:15:31 +0800
commitb7dede1a279b72d74cf52d2e194525426e6d144d (patch)
tree201a2dc644a3a52550b6a3310b205e90bd27ed2e /importers
parent838d0849f248ed5e1b7793c3a5968c678749c81b (diff)
downloadgsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.tar
gsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.tar.gz
gsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.tar.bz2
gsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.tar.lz
gsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.tar.xz
gsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.tar.zst
gsoc2013-evolution-b7dede1a279b72d74cf52d2e194525426e6d144d.zip
use bonobo-conf everywhere
2001-07-03 Dietmar Maurer <dietmar@ximian.com> * *: use bonobo-conf everywhere svn path=/trunk/; revision=10760
Diffstat (limited to 'importers')
-rw-r--r--importers/Makefile.am1
-rw-r--r--importers/elm-importer.c110
-rw-r--r--importers/evolution-gnomecard-importer.c88
-rw-r--r--importers/netscape-importer.c124
-rw-r--r--importers/pine-importer.c110
5 files changed, 216 insertions, 217 deletions
diff --git a/importers/Makefile.am b/importers/Makefile.am
index a4e8a0e3c8..ca23b7b210 100644
--- a/importers/Makefile.am
+++ b/importers/Makefile.am
@@ -11,6 +11,7 @@ INCLUDES = \
-I$(top_srcdir)/shell \
-I$(top_srcdir)/addressbook/backend/ebook \
$(BONOBO_GNOME_CFLAGS) \
+ $(BONOBO_CONF_CFLAGS) \
$(EXTRA_GNOME_CFLAGS)
IDLS = \
diff --git a/importers/elm-importer.c b/importers/elm-importer.c
index 9692c2500c..d2341a012d 100644
--- a/importers/elm-importer.c
+++ b/importers/elm-importer.c
@@ -41,6 +41,9 @@
#include <bonobo/bonobo-context.h>
#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-main.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <importer/evolution-intelligent-importer.h>
#include <importer/evolution-importer-client.h>
@@ -72,6 +75,8 @@ typedef struct {
GtkWidget *ask;
gboolean ask_again;
+
+ Bonobo_ConfigDatabase db;
} ElmImporter;
typedef struct {
@@ -87,41 +92,25 @@ static void import_next (ElmImporter *importer);
static void
elm_store_settings (ElmImporter *importer)
{
- char *evolution_dir, *key;
-
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Elm-Importer=/settings/",
- evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool ("mail", importer->do_mail);
- gnome_config_set_bool ("alias", importer->do_alias);
-
- gnome_config_set_bool ("ask-again", importer->ask_again);
- gnome_config_pop_prefix ();
+ bonobo_config_set_boolean (importer->db, "/Importer/Elm/mail",
+ importer->do_mail, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Elm/alias",
+ importer->do_alias, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Elm/ask-again",
+ importer->ask_again, NULL);
}
static void
elm_restore_settings (ElmImporter *importer)
{
- char *evolution_dir, *key;
-
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Elm-Importer=/settings/",
- evolution_dir);
- g_free (evolution_dir);
+ importer->do_mail = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Elm/mail", TRUE, NULL);
- gnome_config_push_prefix (key);
- g_free (key);
+ importer->do_alias = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Elm/alias", TRUE, NULL);
- importer->do_mail = gnome_config_get_bool ("mail=True");
- importer->do_alias = gnome_config_get_bool ("alias=True");
-
- importer->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
+ importer->ask_again = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Elm/ask-again", FALSE, NULL);
}
static void
@@ -269,28 +258,20 @@ elm_can_import (EvolutionIntelligentImporter *ii,
void *closure)
{
ElmImporter *importer = closure;
- char *key, *elmdir, *maildir, *evolution_dir, *aliasfile;
+ char *elmdir, *maildir, *aliasfile;
char *elmrc;
gboolean exists, mailexists, aliasexists;
gboolean mail, alias;
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- /* Already imported */
- key = g_strdup_printf ("=%s/config/Importers=/elm-importers/", evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
+ mail = bonobo_config_get_boolean_with_default (importer->db,
+ "/Importer/Elm/mail-imported", FALSE, NULL);
- mail = gnome_config_get_bool ("mail-imported");
- alias = gnome_config_get_bool ("alias-importer");
+ alias = bonobo_config_get_boolean_with_default (importer->db,
+ "/Importer/Elm/alias-imported", FALSE, NULL);
- if (alias && mail) {
- gnome_config_pop_prefix ();
+ if (alias && mail)
return FALSE;
- }
- gnome_config_pop_prefix ();
-
+
importer->do_mail = !mail;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
importer->do_mail);
@@ -428,19 +409,15 @@ static void
elm_create_structure (EvolutionIntelligentImporter *ii,
void *closure)
{
+ CORBA_Environment ev;
ElmImporter *importer = closure;
- char *maildir, *key, *evolution_dir;
+ char *maildir;
/* Reference our object so when the shell release_unrefs us
we will still exist and not go byebye */
bonobo_object_ref (BONOBO_OBJECT (ii));
elm_store_settings (importer);
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Importers=/elm-importers/", evolution_dir);
- g_free (evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
if (importer->do_alias == TRUE) {
/* Do the aliases */
@@ -448,7 +425,9 @@ elm_create_structure (EvolutionIntelligentImporter *ii,
if (importer->do_mail == TRUE) {
char *elmdir;
- gnome_config_set_bool ("mail-importer", TRUE);
+
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Elm/mail-imported", TRUE, NULL);
maildir = elm_get_rc_value ("maildir");
if (maildir == NULL) {
@@ -472,10 +451,9 @@ elm_create_structure (EvolutionIntelligentImporter *ii,
import_next (importer);
}
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
if (importer->do_mail == FALSE) {
bonobo_object_unref (BONOBO_OBJECT (ii));
@@ -486,11 +464,22 @@ static void
elm_destroy_cb (GtkObject *object,
ElmImporter *importer)
{
+ CORBA_Environment ev;
+
g_print ("\n----------Settings-------\n");
g_print ("Mail - %s\n", importer->do_mail ? "Yes" : "No");
g_print ("Alias - %s\n", importer->do_alias ? "Yes" : "No");
elm_store_settings (importer);
+
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
+
+ if (importer->db != CORBA_OBJECT_NIL)
+ bonobo_object_release_unref (importer->db, NULL);
+ importer->db = CORBA_OBJECT_NIL;
+
gtk_main_quit ();
}
@@ -562,11 +551,22 @@ factory_fn (BonoboGenericFactory *_factory,
"Would you like to import them into Evolution?");
elm = g_new0 (ElmImporter, 1);
- elm_restore_settings (elm);
CORBA_exception_init (&ev);
+
+ elm->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || elm->db == CORBA_OBJECT_NIL) {
+ g_free (elm);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ elm_restore_settings (elm);
+
elm->importer = oaf_activate_from_id (MBOX_IMPORTER_IID, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
+ g_free (elm);
g_warning ("Could not start MBox importer\n%s",
CORBA_exception_id (&ev));
CORBA_exception_free (&ev);
diff --git a/importers/evolution-gnomecard-importer.c b/importers/evolution-gnomecard-importer.c
index 13e7683647..20385a79b6 100644
--- a/importers/evolution-gnomecard-importer.c
+++ b/importers/evolution-gnomecard-importer.c
@@ -31,6 +31,9 @@
#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <e-book.h>
@@ -50,44 +53,29 @@ typedef struct {
GtkWidget *ask;
gboolean ask_again;
+
+ Bonobo_ConfigDatabase db;
} GnomeCardImporter;
static void
gnomecard_store_settings (GnomeCardImporter *importer)
{
- char *evolution_dir, *key;
-
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Gnomecard-Importer=/settings/",
- evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool ("address", importer->do_addresses);
-
- gnome_config_set_bool ("ask-again", importer->ask_again);
- gnome_config_pop_prefix ();
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Gnomecard/address",
+ importer->do_addresses, NULL);
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Gnomecard/ask-again",
+ importer->ask_again, NULL);
}
static void
gnomecard_restore_settings (GnomeCardImporter *importer)
{
- char *evolution_dir, *key;
-
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Gnomecard-Importer=/settings/",
- evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- importer->do_addresses = gnome_config_get_bool ("address=True");
+ importer->do_addresses = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Gnomecard/address", TRUE, NULL);
- importer->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
+ importer->ask_again = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Gnomecard/ask-again", FALSE, NULL);
}
static gboolean
@@ -95,28 +83,14 @@ gnomecard_can_import (EvolutionIntelligentImporter *ii,
void *closure)
{
GnomeCardImporter *importer = closure;
- char *evolution_dir;
char *gnomecard;
- char *key;
gboolean result, address;
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Importers=/gnomecard-importers/", evolution_dir);
- g_free (evolution_dir);
+ address = bonobo_config_get_boolean_with_default (importer->db,
+ "/Importer/Gnomecard/address-imported", FALSE, NULL);
- gnome_config_push_prefix (key);
- g_free (key);
-
- address = gnome_config_get_bool ("address-imported");
- if (address == TRUE) {
- gnome_config_pop_prefix ();
+ if (address == TRUE || importer->ask_again == TRUE)
return FALSE;
- }
- gnome_config_pop_prefix ();
-
- if (importer->ask_again == TRUE) {
- return FALSE;
- }
gnomecard = gnome_util_home_file ("GnomeCard.gcrd");
result = g_file_exists (gnomecard);
@@ -177,6 +151,7 @@ gnomecard_import (EvolutionIntelligentImporter *ii,
bonobo_object_ref (BONOBO_OBJECT (ii));
gnomecard_store_settings (gci);
+
if (gci->do_addresses == TRUE) {
CORBA_exception_init (&ev);
@@ -213,11 +188,22 @@ static void
gnomecard_destroy_cb (GtkObject *object,
GnomeCardImporter *importer)
{
+ CORBA_Environment ev;
+
/* save the state of the checkboxes */
g_print ("\n---------Settings-------\n");
g_print ("Addressbook - %s\n", importer->do_addresses? "Yes" : "No");
gnomecard_store_settings (importer);
+
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
+
+ if (importer->db != CORBA_OBJECT_NIL)
+ bonobo_object_release_unref (importer->db, NULL);
+ importer->db = CORBA_OBJECT_NIL;
+
gtk_main_quit ();
}
@@ -278,9 +264,19 @@ factory_fn (BonoboGenericFactory *_factory,
BonoboControl *control;
gci = g_new (GnomeCardImporter, 1);
- gnomecard_restore_settings (gci);
CORBA_exception_init (&ev);
+
+ gci->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || gci->db == CORBA_OBJECT_NIL) {
+ g_free (gci);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ gnomecard_restore_settings (gci);
+
gci->importer = oaf_activate_from_id (VCARD_IMPORTER_IID, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("Could not start VCard importer: %s",
@@ -308,7 +304,7 @@ factory_fn (BonoboGenericFactory *_factory,
static void
importer_init (void)
{
- BonoboObject *factory;
+ BonoboGenericFactory *factory;
factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
factory_fn, NULL);
diff --git a/importers/netscape-importer.c b/importers/netscape-importer.c
index 424ef1dca2..e2093c8a0c 100644
--- a/importers/netscape-importer.c
+++ b/importers/netscape-importer.c
@@ -41,6 +41,9 @@
#include <bonobo/bonobo-generic-factory.h>
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-context.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <importer/evolution-intelligent-importer.h>
#include <importer/GNOME_Evolution_Importer.h>
@@ -84,6 +87,8 @@ typedef struct {
GtkWidget *ask;
gboolean ask_again;
+
+ Bonobo_ConfigDatabase db;
} NetscapeImporter;
static void import_next (NetscapeImporter *importer);
@@ -91,44 +96,36 @@ static void import_next (NetscapeImporter *importer);
static void
netscape_store_settings (NetscapeImporter *importer)
{
- char *evolution_dir, *key;
-
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Netscape-Importer=/settings/",
- evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool ("mail", importer->do_mail);
- gnome_config_set_bool ("address", importer->do_addrs);
- gnome_config_set_bool ("filters", importer->do_filters);
- gnome_config_set_bool ("settings", importer->do_settings);
-
- gnome_config_set_bool ("ask-again", importer->ask_again);
- gnome_config_pop_prefix ();
+ bonobo_config_set_boolean (importer->db, "/Importer/Netscape/mail",
+ importer->do_mail, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Netscape/address",
+ importer->do_addrs, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Netscape/filters",
+ importer->do_filters, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Netscape/settings",
+ importer->do_settings, NULL);
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Netscape/ask-again",
+ importer->ask_again, NULL);
}
static void
netscape_restore_settings (NetscapeImporter *importer)
{
- char *evolution_dir, *key;
+ importer->do_mail = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Netscape/mail", TRUE, NULL);
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Netscape-Importer=/settings/", evolution_dir);
- g_free (evolution_dir);
+ importer->do_addrs = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Netscape/address", TRUE, NULL);
- gnome_config_push_prefix (key);
- g_free (key);
+ importer->do_filters = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Netscape/filters", TRUE, NULL);
- importer->do_mail = gnome_config_get_bool ("mail=True");
- importer->do_addrs = gnome_config_get_bool ("address=True");
- importer->do_filters = gnome_config_get_bool ("filters=True");
- importer->do_settings = gnome_config_get_bool ("setting=True");
+ importer->do_settings = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Netscape/settings", TRUE, NULL);
- importer->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
+ importer->ask_again = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Netscape/ask-again", FALSE, NULL);
}
static const char *
@@ -458,27 +455,14 @@ netscape_can_import (EvolutionIntelligentImporter *ii,
{
NetscapeImporter *importer = closure;
gboolean mail, settings;
- char *evolution_dir;
- char *key;
-
- /* Probably shouldn't hard code this, but there's no way yet to change
- the home dir. FIXME */
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- /* Already imported */
- key = g_strdup_printf ("=%s/config/Importers=/netscape-importers/", evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
- mail = gnome_config_get_bool ("mail-imported");
- settings = gnome_config_get_bool ("settings-imported");
+ mail = bonobo_config_get_boolean_with_default (importer->db,
+ "/Importer/Netscape/mail-imported", FALSE, NULL);
+ settings = bonobo_config_get_boolean_with_default (importer->db,
+ "/Importer/Netscape/settings-imported", FALSE, NULL);
- if (settings && mail) {
- gnome_config_pop_prefix ();
+ if (settings && mail)
return FALSE;
- }
- gnome_config_pop_prefix ();
importer->do_mail = !mail;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
@@ -700,8 +684,8 @@ static void
netscape_create_structure (EvolutionIntelligentImporter *ii,
void *closure)
{
+ CORBA_Environment ev;
NetscapeImporter *importer = closure;
- char *key, *evolution_dir;
g_return_if_fail (nsmail_dir != NULL);
@@ -710,21 +694,16 @@ netscape_create_structure (EvolutionIntelligentImporter *ii,
bonobo_object_ref (BONOBO_OBJECT (ii));
netscape_store_settings (importer);
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- /* Set that we've imported the folders so we won't import them again */
- key = g_strdup_printf ("=%s/config/Importers=/netscape-importers/", evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
if (importer->do_settings == TRUE) {
- gnome_config_set_bool ("settings-imported", TRUE);
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Netscape/settings-imported", TRUE, NULL);
netscape_import_accounts (importer);
}
if (importer->do_mail == TRUE) {
- gnome_config_set_bool ("mail-imported", TRUE);
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Netscape/mail-imported", TRUE, NULL);
/* Scan the nsmail folder and find out what folders
need to be imported */
scan_dir (importer, "/", nsmail_dir);
@@ -733,10 +712,9 @@ netscape_create_structure (EvolutionIntelligentImporter *ii,
import_next (importer);
}
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
if (importer->do_mail == FALSE) {
/* Destroy it here if we weren't importing mail
@@ -750,6 +728,8 @@ static void
netscape_destroy_cb (GtkObject *object,
NetscapeImporter *importer)
{
+ CORBA_Environment ev;
+
/* Save the state of the checkboxes */
g_print ("\n-------Settings-------\n");
g_print ("Mail - %s\n", importer->do_mail ? "Yes" : "No");
@@ -758,6 +738,15 @@ netscape_destroy_cb (GtkObject *object,
g_print ("Settings - %s\n", importer->do_settings ? "Yes" : "No");
netscape_store_settings (importer);
+
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
+
+ if (importer->db != CORBA_OBJECT_NIL)
+ bonobo_object_release_unref (importer->db, NULL);
+ importer->db = CORBA_OBJECT_NIL;
+
gtk_main_quit ();
}
@@ -848,9 +837,20 @@ factory_fn (BonoboGenericFactory *_factory,
"Would you like them to be imported into Evolution?");
netscape = g_new0 (NetscapeImporter, 1);
- netscape_restore_settings (netscape);
CORBA_exception_init (&ev);
+
+ netscape->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase",
+ &ev);
+
+ if (BONOBO_EX (&ev) || netscape->db == CORBA_OBJECT_NIL) {
+ g_free (netscape);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ netscape_restore_settings (netscape);
+
netscape->importer = oaf_activate_from_id (MBOX_IMPORTER_IID, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("Could not start MBox importer\n%s", CORBA_exception_id (&ev));
diff --git a/importers/pine-importer.c b/importers/pine-importer.c
index 858d9adbff..10124408cf 100644
--- a/importers/pine-importer.c
+++ b/importers/pine-importer.c
@@ -40,6 +40,9 @@
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-context.h>
#include <bonobo/bonobo-main.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo-conf/bonobo-config-database.h>
#include <importer/evolution-intelligent-importer.h>
#include <importer/evolution-importer-client.h>
@@ -76,6 +79,8 @@ typedef struct {
gboolean ask_again;
EBook *book;
+
+ Bonobo_ConfigDatabase db;
} PineImporter;
typedef struct {
@@ -89,41 +94,30 @@ static void import_next (PineImporter *importer);
static void
pine_store_settings (PineImporter *importer)
{
- char *evolution_dir, *key;
-
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Pine-Importer=/settings/", evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool ("mail", importer->do_mail);
- gnome_config_set_bool ("settings", importer->do_settings);
- gnome_config_set_bool ("address", importer->do_address);
-
- gnome_config_set_bool ("ask-again", importer->ask_again);
- gnome_config_pop_prefix ();
+ bonobo_config_set_boolean (importer->db, "/Importer/Pine/mail",
+ importer->do_mail, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Pine/settings",
+ importer->do_settings, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Pine/address",
+ importer->do_address, NULL);
+ bonobo_config_set_boolean (importer->db, "/Importer/Pine/ask-again",
+ importer->ask_again, NULL);
}
static void
pine_restore_settings (PineImporter *importer)
{
- char *evolution_dir, *key;
+ importer->do_mail = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Pine/mail", TRUE, NULL);
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Pine-Importer=/settings/", evolution_dir);
- g_free (evolution_dir);
+ importer->do_settings = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Pine/settings", TRUE, NULL);
- gnome_config_push_prefix (key);
- g_free (key);
-
- importer->do_mail = gnome_config_get_bool ("mail=True");
- importer->do_settings = gnome_config_get_bool ("settings=True");
- importer->do_address = gnome_config_get_bool ("address=True");
+ importer->do_address = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Pine/address", TRUE, NULL);
- importer->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
+ importer->ask_again = bonobo_config_get_boolean_with_default (
+ importer->db, "/Importer/Pine/ask-again", FALSE, NULL);
}
/* Pass in handle so we can get the next line if we need to */
@@ -419,25 +413,17 @@ pine_can_import (EvolutionIntelligentImporter *ii,
void *closure)
{
PineImporter *importer = closure;
- char *key, *maildir, *evolution_dir, *addrfile;
+ char *maildir, *addrfile;
gboolean mail;
gboolean md_exists, addr_exists;
/* Already imported */
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Importers=/pine-importer/", evolution_dir);
- g_free (evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
+ mail = bonobo_config_get_boolean_with_default (importer->db,
+ "/Importer/Pine/mail-imported", FALSE, NULL);
- mail = gnome_config_get_bool ("mail-imported");
-
- if (mail) {
- gnome_config_pop_prefix ();
+ if (mail)
return FALSE;
- }
- gnome_config_pop_prefix ();
importer->do_mail = !mail;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
@@ -569,27 +555,23 @@ static void
pine_create_structure (EvolutionIntelligentImporter *ii,
void *closure)
{
+ CORBA_Environment ev;
PineImporter *importer = closure;
- char *maildir, *key, *evolution_dir;
+ char *maildir;
bonobo_object_ref (BONOBO_OBJECT (ii));
pine_store_settings (importer);
- evolution_dir = gnome_util_prepend_user_home ("evolution");
- key = g_strdup_printf ("=%s/config/Importers=/pine-importer/", evolution_dir);
- g_free (evolution_dir);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
if (importer->do_address == TRUE) {
- gnome_config_set_bool ("address-imported", TRUE);
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Pine/address-imported", TRUE, NULL);
import_addressbook (importer);
}
if (importer->do_mail == TRUE) {
- gnome_config_set_bool ("mail-imported", TRUE);
+ bonobo_config_set_boolean (importer->db,
+ "/Importer/Pine/mail-imported", TRUE, NULL);
maildir = gnome_util_prepend_user_home ("mail");
scan_dir (importer, maildir, "/");
@@ -599,10 +581,9 @@ pine_create_structure (EvolutionIntelligentImporter *ii,
import_next (importer);
}
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
if (importer->do_mail == FALSE && importer->do_address == FALSE) {
/* Destroy it here if we weren't importing mail
@@ -618,12 +599,23 @@ static void
pine_destroy_cb (GtkObject *object,
PineImporter *importer)
{
+ CORBA_Environment ev;
+
g_print ("\n-------Settings-------\n");
g_print ("Mail - %s\n", importer->do_mail ? "Yes" : "No");
g_print ("Settings - %s\n", importer->do_settings ? "Yes" : "No");
g_print ("Address - %s\n", importer->do_address ? "Yes" : "No");
pine_store_settings (importer);
+
+ CORBA_exception_init (&ev);
+ Bonobo_ConfigDatabase_sync (importer->db, &ev);
+ CORBA_exception_free (&ev);
+
+ if (importer->db != CORBA_OBJECT_NIL)
+ bonobo_object_release_unref (importer->db, NULL);
+ importer->db = CORBA_OBJECT_NIL;
+
gtk_main_quit ();
}
@@ -706,9 +698,19 @@ factory_fn (BonoboGenericFactory *_factory,
"Would you like to import them into Evolution?");
pine = g_new0 (PineImporter, 1);
- pine_restore_settings (pine);
CORBA_exception_init (&ev);
+
+ pine->db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", &ev);
+
+ if (BONOBO_EX (&ev) || pine->db == CORBA_OBJECT_NIL) {
+ g_free (pine);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ pine_restore_settings (pine);
+
pine->importer = oaf_activate_from_id (MBOX_IMPORTER_IID, 0, NULL, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_warning ("Could not start MBox importer\n%s",