aboutsummaryrefslogtreecommitdiffstats
path: root/importers
diff options
context:
space:
mode:
Diffstat (limited to 'importers')
-rw-r--r--importers/.cvsignore19
-rw-r--r--importers/ChangeLog72
-rw-r--r--importers/GNOME_Evolution_Elm_Intelligent_Importer.oaf.in21
-rw-r--r--importers/GNOME_Evolution_GnomeCard_Intelligent_Importer.oaf.in21
-rw-r--r--importers/GNOME_Evolution_Netscape_Intelligent_Importer.oaf.in21
-rw-r--r--importers/GNOME_Evolution_Pine_Intelligent_Importer.oaf.in21
-rw-r--r--importers/Makefile.am81
-rw-r--r--importers/elm-importer.c625
-rw-r--r--importers/evolution-gnomecard-importer.c344
-rw-r--r--importers/netscape-importer.c909
-rw-r--r--importers/pine-importer.c768
11 files changed, 0 insertions, 2902 deletions
diff --git a/importers/.cvsignore b/importers/.cvsignore
deleted file mode 100644
index 2779188267..0000000000
--- a/importers/.cvsignore
+++ /dev/null
@@ -1,19 +0,0 @@
-.deps
-.libs
-.pure
-Makefile
-Makefile.in
-*.bb
-*.bbg
-*.da
-*.gcov
-*.oaf
-*.lo
-*.la
-Mail-stubs.c
-Mail-skels.c
-Mail-common.c
-Mail.h
-evolution-elm-importer
-evolution-pine-importer
-evolution-netscape-importer
diff --git a/importers/ChangeLog b/importers/ChangeLog
deleted file mode 100644
index 288dbb8267..0000000000
--- a/importers/ChangeLog
+++ /dev/null
@@ -1,72 +0,0 @@
-2001-05-16 Iain Holmes <iain@ximian.com>
-
- * evolution-gnomecard-importer.c: Converted the old importer into an
- intelligent importer that uses the VCard importer to do it's dirty work.
-
- * Makefile.am: Create the gnomecard importer.
-
- * GNOME_Evolution_GnomeCard_Intelligent_Importer.oaf.in: OAF file.
-
-2001-05-14 Iain Holmes <iain@ximian.com>
-
- * elm-importer.c (elm_store_settings): Store the elm settings.
- (elm_restore_settings): Restore all the settings.
- (elm_can_import): Check the importer settings, handle the don't ask me
- again stuff.
- (scan_dir): Switch the arguments to match the other importers.
- (destroy_cb): Store the settings.
- (elm_create_structure): Set all the settings, handle the new location
- of the elm mail.
- (create_checkboxes_control): Add a "Don't ask me again" box.
-
-2001-05-09 Iain Holmes <iain@ximian.com>
-
- * pine-importer.c (import_addressfile): Free memory leaks.
- Fix spewage.
-
- * netscape-importer.c: Fix spewage.
-
-2001-05-09 Iain Holmes <iain@ximian.com>
-
- * elm-importer.c (elm_can_import): Check the elm rc file for the mail dir.
- Handle if the aliases file exists too.
- (parse_elm_rc): Parse the elmrc file into a hash table.
- (elm_get_rc_value): Get the value out of the hash table.
-
-2001-05-09 Christopher James Lahey <clahey@ximian.com>
-
- * .cvsignore: Added .cvsignore.
-
-2001-05-09 Christopher James Lahey <clahey@ximian.com>
-
- * elm-importer.c, netscape-importer.c, pine-importer.c: Include
- bonobo-context.h.
-
- * netscape-importer.c (netscape_import_accounts): Made a bunch of
- const char *s here.
- (importer_cb): Replaced CORBA_OBJECT_NIL with CORBA_NO_EXCEPTION
- in a error check here.
- (netscape_create_structure): Removed unused data variable here.
- Added BONOBO_OBJECT casts.
- (importer_init): Changed factory to be a BonoboGenericFactory *
- instead of a BonoboObject *.
-
- * pine-importer.c (import_addressfile): Changed signature to match
- EBookCallback signature. Added char *email variable. Removed
- EList since we only need to deal with one email for now. Changed
- this to not set the file as to the fullname.
- (pine_can_import): Removed unused settings and addressbook
- variables.
- (pine_create_structure): Added BONOBO_OBJECT casts.
-
-2001-05-08 Iain Holmes <iain@ximian.com>
-
- * *: Added everything to CVS.
-
-2001-04-26 Iain Holmes <iain@ximian.com>
-
- * elm-importer.c:
- pine-importer.c:
- netscape-importer.c: Moved these files to their own toplevel.
- Made them use the mbox importer component instead of doing it themselves.
- Made them quit correctly, and store their settings.
diff --git a/importers/GNOME_Evolution_Elm_Intelligent_Importer.oaf.in b/importers/GNOME_Evolution_Elm_Intelligent_Importer.oaf.in
deleted file mode 100644
index 6676042bf6..0000000000
--- a/importers/GNOME_Evolution_Elm_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Elm_Intelligent_Importer_Factory"
- type="exe"
- location="evolution-elm-importer">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Elm_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Elm_Intelligent_Importer_Factory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/importers/GNOME_Evolution_GnomeCard_Intelligent_Importer.oaf.in b/importers/GNOME_Evolution_GnomeCard_Intelligent_Importer.oaf.in
deleted file mode 100644
index e80bbcacbf..0000000000
--- a/importers/GNOME_Evolution_GnomeCard_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_GnomeCard_Intelligent_ImporterFactory"
- type="exe"
- location="evolution-gnomecard-importer">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_GnomeCard_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_GnomeCard_Intelligent_ImporterFactory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/importers/GNOME_Evolution_Netscape_Intelligent_Importer.oaf.in b/importers/GNOME_Evolution_Netscape_Intelligent_Importer.oaf.in
deleted file mode 100644
index a53d9bad6c..0000000000
--- a/importers/GNOME_Evolution_Netscape_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Netscape_Intelligent_Importer_Factory"
- type="exe"
- location="evolution-netscape-importer">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Netscape_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Netscape_Intelligent_Importer_Factory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/importers/GNOME_Evolution_Pine_Intelligent_Importer.oaf.in b/importers/GNOME_Evolution_Pine_Intelligent_Importer.oaf.in
deleted file mode 100644
index 00d15710f4..0000000000
--- a/importers/GNOME_Evolution_Pine_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Pine_Intelligent_Importer_Factory"
- type="exe"
- location="evolution-pine-importer">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Pine_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Pine_Intelligent_Importer_Factory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/importers/Makefile.am b/importers/Makefile.am
deleted file mode 100644
index febf8c65e5..0000000000
--- a/importers/Makefile.am
+++ /dev/null
@@ -1,81 +0,0 @@
-bin_PROGRAMS = evolution-netscape-importer \
- evolution-elm-importer \
- evolution-pine-importer \
- evolution-gnomecard-importer
-
-INCLUDES = \
- -DGNOMELOCALEDIR=\""$(localedir)"\" \
- -DG_LOG_DOMAIN=\"Evolution-Importer\" \
- -I$(top_srcdir) \
- -I$(top_builddir)/shell \
- -I$(top_srcdir)/shell \
- -I$(top_srcdir)/addressbook/backend/ebook \
- $(BONOBO_GNOME_CFLAGS) \
- $(EXTRA_GNOME_CFLAGS)
-
-IDLS = \
- $(top_srcdir)/mail/Mail.idl
-
-MAIL_GENERATED = \
- Mail.h \
- Mail-common.c \
- Mail-skels.c \
- Mail-stubs.c
-
-$(MAIL_GENERATED): $(IDLS)
- $(ORBIT_IDL) -I $(srcdir) `$(GNOME_CONFIG) --cflags idl` $(top_srcdir)/mail/Mail.idl
-
-evolution_netscape_importer_SOURCES = \
- $(MAIL_GENERATED) \
- netscape-importer.c
-
-evolution_netscape_importer_LDADD = \
- $(BONOBO_GNOME_LIBS) \
- $(EXTRA_GNOME_LIBS) \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/shell/importer/libevolution-importer.la
-
-evolution_elm_importer_SOURCES = \
- elm-importer.c
-
-evolution_elm_importer_LDADD = \
- $(BONOBO_GNOME_LIBS) \
- $(EXTRA_GNOME_LIBS) \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/shell/importer/libevolution-importer.la
-
-evolution_pine_importer_SOURCES = \
- pine-importer.c
-
-evolution_pine_importer_LDADD = \
- $(BONOBO_GNOME_LIBS) \
- $(EXTRA_GNOME_LIBS) \
- $(top_builddir)/addressbook/backend/ebook/libebook.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.la \
- $(top_builddir)/shell/importer/libevolution-importer.la
-
-evolution_gnomecard_importer_SOURCES = \
- evolution-gnomecard-importer.c
-
-evolution_gnomecard_importer_LDADD = \
- $(BONOBO_GNOME_LIBS) \
- $(EXTRA_GNOME_LIBS) \
- $(top_builddir)/addressbook/backend/ebook/libebook.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/e-util/ename/libename.la \
- $(top_builddir)/libversit/libversit.la \
- $(top_builddir)/shell/importer/libevolution-importer.la
-
-oafdir = $(datadir)/oaf
-oaf_in_files = GNOME_Evolution_Netscape_Intelligent_Importer.oaf.in \
- GNOME_Evolution_Elm_Intelligent_Importer.oaf.in \
- GNOME_Evolution_Pine_Intelligent_Importer.oaf.in \
- GNOME_Evolution_GnomeCard_Intelligent_Importer.oaf.in
-
-oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
-
-EXTRA_DIST = $(oaf_in_files) $(oaf_DATA)
-
-@XML_I18N_MERGE_OAF_RULE@
diff --git a/importers/elm-importer.c b/importers/elm-importer.c
deleted file mode 100644
index 58e3ad7ff9..0000000000
--- a/importers/elm-importer.c
+++ /dev/null
@@ -1,625 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* elm-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-main.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/evolution-importer-client.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#define ELM_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Elm_Intelligent_Importer_Factory"
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer"
-#define KEY "elm-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- GList *dir_list;
-
- int num;
-
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
-
- GtkWidget *mail;
- gboolean do_mail;
- GtkWidget *alias;
- gboolean do_alias;
-
- GtkWidget *ask;
- gboolean ask_again;
-} ElmImporter;
-
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
-} ElmFolder;
-
-static GHashTable *elm_prefs = NULL;
-
-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 ();
-}
-
-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);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- 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 ();
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- ElmImporter *importer = (ElmImporter *) data;
- CORBA_Object objref;
- CORBA_Environment ev;
-
- g_print ("Processed.....\n");
- if (more_items) {
- g_print ("Processing.....\n");
-
- CORBA_exception_init (&ev);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- GNOME_Evolution_Importer_processItem (importer->importer,
- objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
- return;
- }
-
- import_next (importer);
-}
-
-static gboolean
-elm_import_file (ElmImporter *importer,
- const char *path,
- const char *folderpath)
-{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
-
- g_warning ("Importing %s as %s", path, folderpath);
-
- CORBA_exception_init (&ev);
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path,
- folderpath, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s", CORBA_exception_id (&ev));
- CORBA_Object_release (importer->importer, &ev);
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- importer->listener = evolution_importer_listener_new (importer_cb,
- importer);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return FALSE;
- }
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-static void
-parse_elm_rc (const char *elmrc)
-{
- static gboolean parsed = FALSE;
- char line[4096];
- FILE *handle;
- gboolean exists;
-
- if (parsed == TRUE)
- return;
-
- elm_prefs = g_hash_table_new (g_str_hash, g_str_equal);
-
- exists = g_file_exists (elmrc);
- if (exists == FALSE) {
- parsed = TRUE;
- return;
- }
-
- handle = fopen (elmrc, "r");
- if (handle == NULL) {
- parsed = TRUE;
- return;
- }
-
- while (fgets (line, 4096, handle) != NULL) {
- char *linestart, *end;
- char *key, *value;
- if (*line == '#' &&
- (line[1] != '#' && line[2] != '#')) {
- continue;
- } else if (*line == '\n') {
- continue;
- } else if (*line == '#' && line[1] == '#' && line[2] == '#') {
- linestart = line + 4;
- } else {
- linestart = line;
- }
-
- end = strstr (linestart, " = ");
- if (end == NULL) {
- g_warning ("Broken line");
- continue;
- }
-
- *end = 0;
- key = g_strdup (linestart);
-
- linestart = end + 3;
- end = strchr (linestart, '\n');
- if (end == NULL) {
- g_warning ("Broken line");
- g_free (key);
- continue;
- }
-
- *end = 0;
- value = g_strdup (linestart);
-
- g_hash_table_insert (elm_prefs, key, value);
- }
-
- parsed = TRUE;
- fclose (handle);
-}
-
-static char *
-elm_get_rc_value (const char *value)
-{
- if (elm_prefs == NULL)
- return NULL;
-
- return g_hash_table_lookup (elm_prefs, value);
-}
-
-static gboolean
-elm_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- ElmImporter *importer = closure;
- char *key, *elmdir, *maildir, *evolution_dir, *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 = gnome_config_get_bool ("mail-imported");
- alias = gnome_config_get_bool ("alias-importer");
-
- if (alias && mail) {
- gnome_config_pop_prefix ();
- return FALSE;
- }
- gnome_config_pop_prefix ();
-
- importer->do_mail = !mail;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
- importer->do_alias = !alias;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->alias),
- importer->do_alias);
-
- if (importer->ask_again == TRUE) {
- return FALSE;
- }
-
- elmdir = gnome_util_prepend_user_home (".elm");
- exists = g_file_exists (elmdir);
-
- g_free (elmdir);
- if (exists == FALSE)
- return FALSE;
-
- elmrc = gnome_util_prepend_user_home (".elm/elmrc");
- parse_elm_rc (elmrc);
-
- maildir = elm_get_rc_value ("maildir");
- if (maildir == NULL) {
- maildir = g_strdup ("Mail");
- } else {
- maildir = g_strdup (maildir);
- }
-
- if (!g_path_is_absolute (maildir)) {
- elmdir = gnome_util_prepend_user_home (maildir);
- } else {
- elmdir = g_strdup (maildir);
- }
-
- g_free (maildir);
-
- mailexists = g_file_exists (elmdir);
- g_free (elmdir);
-
- aliasfile = gnome_util_prepend_user_home (".elm/aliases");
- aliasexists = g_file_exists (aliasfile);
- g_free (aliasfile);
-
- exists = (aliasexists || mailexists);
-
- return exists;
-}
-
-static void
-import_next (ElmImporter *importer)
-{
- ElmFolder *data;
-
- if (importer->dir_list) {
- char *folder;
-
- data = importer->dir_list->data;
-
- folder = g_concat_dir_and_file (data->parent, data->foldername);
- elm_import_file (importer, data->path, folder);
- g_free (folder);
- g_free (data->parent);
- g_free (data->path);
- g_free (data->foldername);
- g_free (data);
- importer->dir_list = importer->dir_list->next;
- }
-}
-
-static void
-scan_dir (ElmImporter *importer,
- const char *orig_parent,
- const char *dirname)
-{
- DIR *maildir;
- struct stat buf;
- struct dirent *current;
-
- maildir = opendir (dirname);
- if (maildir == NULL) {
- g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno));
- return;
- }
-
- current = readdir (maildir);
- while (current) {
- ElmFolder *pf;
- char *fullname;
-
- /* Ignore . and .. */
- if (current->d_name[0] == '.') {
- if (current->d_name[1] == '\0' ||
- (current->d_name[1] == '.' && current->d_name[2] == '\0')) {
- current = readdir (maildir);
- continue;
- }
- }
-
- fullname = g_concat_dir_and_file (dirname, current->d_name);
- if (stat (fullname, &buf) == -1) {
- g_warning ("Could not stat %s\nstat returned: %s",
- fullname, g_strerror (errno));
- current = readdir (maildir);
- g_free (fullname);
- continue;
- }
-
- if (S_ISREG (buf.st_mode)) {
- pf = g_new (ElmFolder, 1);
- pf->path = g_strdup (fullname);
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (current->d_name);
- importer->dir_list = g_list_append (importer->dir_list, pf);
- } else if (S_ISDIR (buf.st_mode)) {
- char *subdir;
-
- pf = g_new (ElmFolder, 1);
- pf->path = NULL;
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (current->d_name);
- importer->dir_list = g_list_append (importer->dir_list, pf);
-
- subdir = g_concat_dir_and_file (orig_parent, current->d_name);
- scan_dir (importer, subdir, fullname);
- g_free (subdir);
- }
-
- g_free (fullname);
- current = readdir (maildir);
- }
-}
-
-static void
-elm_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- ElmImporter *importer = closure;
- char *maildir, *key, *evolution_dir;
-
- /* 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 */
- }
-
- if (importer->do_mail == TRUE) {
- char *elmdir;
- gnome_config_set_bool ("mail-importer", TRUE);
-
- maildir = elm_get_rc_value ("maildir");
- if (maildir == NULL) {
- maildir = g_strdup ("Mail");
- } else {
- maildir = g_strdup (maildir);
- }
-
- if (!g_path_is_absolute (maildir)) {
- elmdir = gnome_util_prepend_user_home (maildir);
- } else {
- elmdir = g_strdup (maildir);
- }
-
- g_free (maildir);
-
- scan_dir (importer, "/", maildir);
- g_free (maildir);
-
- /* Import them */
- import_next (importer);
- }
-
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-
- if (importer->do_mail == FALSE) {
- bonobo_object_unref (BONOBO_OBJECT (ii));
- }
-}
-
-static void
-elm_destroy_cb (GtkObject *object,
- ElmImporter *importer)
-{
- 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);
- gtk_main_quit ();
-}
-
-/* Fun initialisation stuff */
-/* Fun control stuff */
-static void
-checkbox_toggle_cb (GtkToggleButton *tb,
- gboolean *do_item)
-{
- *do_item = gtk_toggle_button_get_active (tb);
-}
-
-static BonoboControl *
-create_checkboxes_control (ElmImporter *importer)
-{
- GtkWidget *container, *vbox, *sep;
- BonoboControl *control;
-
- container = gtk_frame_new (_("Import"));
- vbox = gtk_vbox_new (FALSE, 2);
- gtk_container_set_border_width (GTK_CONTAINER (container), 2);
- gtk_container_add (GTK_CONTAINER (container), vbox);
-
- importer->mail = gtk_check_button_new_with_label (_("Mail"));
- gtk_signal_connect (GTK_OBJECT (importer->mail), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_mail);
- importer->alias = gtk_check_button_new_with_label (_("Elm Aliases"));
- gtk_signal_connect (GTK_OBJECT (importer->alias), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_alias);
-
- sep = gtk_hseparator_new ();
-
- importer->ask = gtk_check_button_new_with_label (_("Don't ask me again"));
- gtk_signal_connect (GTK_OBJECT (importer->ask), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->ask_again);
-
- gtk_box_pack_start (GTK_BOX (vbox), importer->mail, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->alias, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->ask, FALSE, FALSE, 0);
-
- /* Disable the things that can't be done */
- gtk_widget_set_sensitive (importer->alias, FALSE);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->alias),
- importer->do_alias);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->ask),
- importer->ask_again);
-
- gtk_widget_show_all (container);
- control = bonobo_control_new (container);
- return control;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- BonoboControl *control;
- ElmImporter *elm;
- CORBA_Environment ev;
- char *message = N_("Evolution has found Elm mail files\n"
- "Would you like to import them into Evolution?");
-
- elm = g_new0 (ElmImporter, 1);
- elm_restore_settings (elm);
-
- CORBA_exception_init (&ev);
- elm->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));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- importer = evolution_intelligent_importer_new (elm_can_import,
- elm_create_structure,
- _("Elm mail"),
- _(message), elm);
- gtk_signal_connect (GTK_OBJECT (importer), "destroy",
- GTK_SIGNAL_FUNC (elm_destroy_cb), elm);
-
- control = create_checkboxes_control (elm);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
- return BONOBO_OBJECT (importer);
-}
-
-/* Entry point */
-static void
-importer_init (void)
-{
- BonoboGenericFactory *factory;
-
- factory = bonobo_generic_factory_new (ELM_INTELLIGENT_IMPORTER_IID,
- factory_fn, NULL);
- if (factory == NULL) {
- g_error ("Could not initialise Elm Intelligent Mail Importer.");
- exit (0);
- }
-
- bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
-}
-
-int
-main (int argc,
- char **argv)
-{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Evolution-Elm-Importer",
- VERSION, argc, argv, oaf_popt_options, 0,
- NULL);
- orb = oaf_init (argc, argv);
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialise Bonobo");
- exit (0);
- }
-
- importer_init ();
- bonobo_main ();
-
- return 0;
-}
diff --git a/importers/evolution-gnomecard-importer.c b/importers/evolution-gnomecard-importer.c
deleted file mode 100644
index 13e7683647..0000000000
--- a/importers/evolution-gnomecard-importer.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* evolution-gnomecard-intelligent-importer.c
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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.
- *
- * Author: Iain Holmes <iain@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-
-#include <liboaf/liboaf.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-control.h>
-
-#include <e-book.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include <importer/evolution-importer-listener.h>
-
-#define COMPONENT_FACTORY_IID "OAFIID:GNOME_Evolution_GnomeCard_Intelligent_ImporterFactory"
-#define VCARD_IMPORTER_IID "OAFIID:GNOME_Evolution_Addressbook_VCard_Importer"
-
-typedef struct {
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
-
- GtkWidget *addresses;
- gboolean do_addresses;
-
- GtkWidget *ask;
- gboolean ask_again;
-} 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 ();
-}
-
-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->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
-}
-
-static gboolean
-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);
-
- gnome_config_push_prefix (key);
- g_free (key);
-
- address = gnome_config_get_bool ("address-imported");
- if (address == TRUE) {
- gnome_config_pop_prefix ();
- 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);
- g_free (gnomecard);
-
- return result;
-}
-
-static gboolean
-importer_timeout_fn (gpointer data)
-{
- GnomeCardImporter *gci = (GnomeCardImporter *) data;
- CORBA_Object objref;
- CORBA_Environment ev;
-
- CORBA_exception_init (&ev);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (gci->listener));
- GNOME_Evolution_Importer_processItem (gci->importer, objref, &ev);
- CORBA_exception_free (&ev);
-
- return FALSE;
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- if (result == EVOLUTION_IMPORTER_NOT_READY ||
- result == EVOLUTION_IMPORTER_BUSY) {
- gtk_timeout_add (5000, importer_timeout_fn, data);
- return;
- }
-
- if (more_items) {
- g_idle_add_full (G_PRIORITY_LOW, importer_timeout_fn, data, NULL);
- return;
- }
-
- /* Quit Here */
-}
-
-static void
-gnomecard_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- CORBA_boolean result;
- GnomeCardImporter *gci = closure;
- CORBA_Object objref;
- CORBA_Environment ev;
- char *gnomecard;
-
- gnomecard = gnome_util_home_file ("GnomeCard.gcrd");
-
- /* Reference our object so when the shell release_unrefs us
- we will still exist and not go byebye */
- bonobo_object_ref (BONOBO_OBJECT (ii));
-
- gnomecard_store_settings (gci);
- if (gci->do_addresses == TRUE) {
-
- CORBA_exception_init (&ev);
- result = GNOME_Evolution_Importer_loadFile (gci->importer,
- gnomecard,
- "", &ev);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s",
- CORBA_exception_id (&ev));
- CORBA_Object_release (gci->importer, &ev);
- CORBA_exception_free (&ev);
- return;
- }
-
- gci->listener = evolution_importer_listener_new (importer_cb,
- gci);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (gci->listener));
- GNOME_Evolution_Importer_processItem (gci->importer, objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- return;
- }
-
- CORBA_exception_free (&ev);
-
- return;
- } else {
- bonobo_object_unref (BONOBO_OBJECT (ii));
- return;
- }
-}
-
-static void
-gnomecard_destroy_cb (GtkObject *object,
- GnomeCardImporter *importer)
-{
- /* 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);
- gtk_main_quit ();
-}
-
-/* Fun with aggregation */
-static void
-checkbox_toggle_cb (GtkToggleButton *tb,
- gboolean *do_item)
-{
- *do_item = gtk_toggle_button_get_active (tb);
-}
-
-static BonoboControl *
-create_checkboxes_control (GnomeCardImporter *importer)
-{
- GtkWidget *container, *vbox, *sep;
- BonoboControl *control;
-
- container = gtk_frame_new (_("Import"));
- vbox = gtk_vbox_new (FALSE, 2);
- gtk_container_set_border_width (GTK_CONTAINER (container), 2);
- gtk_container_add (GTK_CONTAINER (container), vbox);
-
- importer->addresses = gtk_check_button_new_with_label (_("Addressbook"));
- gtk_signal_connect (GTK_OBJECT (importer->addresses), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_addresses);
-
- sep = gtk_hseparator_new ();
-
- importer->ask = gtk_check_button_new_with_label (_("Don't ask me again"));
- gtk_signal_connect (GTK_OBJECT (importer->ask), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->ask_again);
-
- gtk_box_pack_start (GTK_BOX (vbox), importer->addresses, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->ask, FALSE, FALSE, 0);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->addresses),
- importer->do_addresses);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->ask),
- importer->ask_again);
-
- gtk_widget_show_all (container);
- control = bonobo_control_new (container);
- return control;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- GnomeCardImporter *gci;
- char *message = N_("Evolution has found GnomeCard files.\n"
- "Would you like them to be imported into Evolution?");
- CORBA_Environment ev;
- BonoboControl *control;
-
- gci = g_new (GnomeCardImporter, 1);
- gnomecard_restore_settings (gci);
-
- CORBA_exception_init (&ev);
- 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",
- CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- importer = evolution_intelligent_importer_new (gnomecard_can_import,
- gnomecard_import,
- "GnomeCard",
- _(message), gci);
-
- gtk_signal_connect (GTK_OBJECT (importer), "destroy",
- GTK_SIGNAL_FUNC (gnomecard_destroy_cb), gci);
-
- control = create_checkboxes_control (gci);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
-
- return BONOBO_OBJECT (importer);
-}
-
-static void
-importer_init (void)
-{
- BonoboObject *factory;
-
- factory = bonobo_generic_factory_new (COMPONENT_FACTORY_IID,
- factory_fn, NULL);
- if (factory == NULL) {
- g_error ("Unable to create factory");
- exit (0);
- }
-
- bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
-}
-
-int
-main (int argc,
- char **argv)
-{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Evolution-GnomeCard-Intelligent-Importer",
- VERSION, argc, argv, oaf_popt_options, 0,
- NULL);
- orb = oaf_init (argc, argv);
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialize Bonobo.");
- exit (0);
- }
-
- importer_init ();
- bonobo_main ();
-
- return 0;
-}
-
-
diff --git a/importers/netscape-importer.c b/importers/netscape-importer.c
deleted file mode 100644
index ab20d31188..0000000000
--- a/importers/netscape-importer.c
+++ /dev/null
@@ -1,909 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* netscape-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-context.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include <importer/evolution-importer-client.h>
-
-#include "Mail.h"
-
-static char *nsmail_dir = NULL;
-static GHashTable *user_prefs = NULL;
-
-#define FACTORY_IID "OAFIID:GNOME_Evolution_Netscape_Intelligent_Importer_Factory"
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer"
-#define MAIL_CONFIG_IID "OAFIID:GNOME_Evolution_MailConfig"
-
-#define KEY "netscape-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- GList *dir_list;
-
- int num;
-
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
-
- /* Checkboxes */
- GtkWidget *mail;
- gboolean do_mail;
- GtkWidget *addrs;
- gboolean do_addrs;
- GtkWidget *filters;
- gboolean do_filters;
- GtkWidget *settings;
- gboolean do_settings;
-
- GtkWidget *ask;
- gboolean ask_again;
-} NetscapeImporter;
-
-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 ();
-}
-
-static void
-netscape_restore_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);
-
- 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->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
-}
-
-static const char *
-netscape_get_string (const char *strname)
-{
- return g_hash_table_lookup (user_prefs, strname);
-}
-
-static int
-netscape_get_integer (const char *strname)
-{
- char *intstr;
-
- intstr = g_hash_table_lookup (user_prefs, strname);
- if (intstr == NULL) {
- return 0;
- } else {
- return atoi (intstr);
- }
-}
-
-static gboolean
-netscape_get_boolean (const char *strname)
-{
- char *boolstr;
-
- boolstr = g_hash_table_lookup (user_prefs, strname);
-
- if (boolstr == NULL) {
- return FALSE;
- } else {
- if (strcasecmp (boolstr, "false") == 0) {
- return FALSE;
- } else if (strcasecmp (boolstr, "true") == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static char *
-netscape_get_key (const char *line)
-{
- char *line_dup;
- char *start, *end;
- char *key;
-
- line_dup = g_strdup (line);
- start = strchr (line_dup, '\"');
- if (start == NULL)
- goto die;
- start++;
- if (*start == '\0')
- goto die;
-
- end = strchr (start, '\"');
- if (end == NULL)
- goto die;
- *end = '\0';
-
- key = g_strdup (start);
- g_free (line_dup);
-
- d(g_warning ("Found key: %s", key));
- return key;
-
- die:
- g_free (line_dup);
- g_warning ("Broken line: %s", line);
- return NULL;
-}
-
-static char *
-netscape_get_value (const char *line)
-{
- char *line_dup;
- char *start, *end;
- char *value;
-
- line_dup = g_strdup (line);
- start = strchr (line_dup, ',');
- if (start == NULL)
- goto die;
- start++;
- if (*start == '\0')
- goto die;
-
- if (*start == ' ')
- start++;
- if (*start == '\0')
- goto die;
-
- if (*start == '\"')
- start++;
- if (*start == '\0')
- goto die;
-
- /* Start should now be the start of the value */
- end = strrchr (start, ')');
- if (end == NULL)
- goto die;
- *end = '\0';
- if (*(end - 1) == '\"')
- *(end - 1) = '\0';
-
- if (start == (end - 1)) {
- g_free (line_dup);
- return NULL;
- }
-
- value = g_strdup (start);
- g_free (line_dup);
-
- d(g_warning ("Found value: %s", value));
- return value;
-
- die:
- g_free (line_dup);
- g_warning ("Broken line: %s", line);
- return NULL;
-}
-
-static void
-netscape_init_prefs (void)
-{
- FILE *prefs_handle;
- char *nsprefs;
- char line[4096];
-
- user_prefs = g_hash_table_new (g_str_hash, g_str_equal);
-
- nsprefs = gnome_util_prepend_user_home (".netscape/preferences.js");
- prefs_handle = fopen (nsprefs, "r");
- g_free (nsprefs);
-
- if (prefs_handle == NULL) {
- d(g_warning ("No .netscape/preferences.js"));
- g_hash_table_destroy (user_prefs);
- user_prefs = NULL;
- return;
- }
-
- /* Find the user mail dir */
- while (fgets (line, 4096, prefs_handle)) {
- char *key, *value;
-
- key = netscape_get_key (line);
- value = netscape_get_value (line);
-
- if (key == NULL)
- continue;
-
- g_hash_table_insert (user_prefs, key, value);
- }
-
- return;
-}
-
-static void
-netscape_import_accounts (NetscapeImporter *importer)
-{
- const char *nstr;
- const char *imap;
- GNOME_Evolution_MailConfig_Account account;
- GNOME_Evolution_MailConfig_Service source, transport;
- GNOME_Evolution_MailConfig_Identity id;
- CORBA_Object objref;
- CORBA_Environment ev;
-
- if (user_prefs == NULL) {
- netscape_init_prefs ();
- if (user_prefs == NULL)
- return;
- }
-
- CORBA_exception_init (&ev);
- objref = oaf_activate_from_id (MAIL_CONFIG_IID, 0, NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Error starting mail config");
- CORBA_exception_free (&ev);
- return;
- }
-
- if (objref == CORBA_OBJECT_NIL) {
- g_warning ("Error activating mail config");
- return;
- }
-
- /* Create identify structure */
- nstr = netscape_get_string ("mail.identity.username");
- id.name = CORBA_string_dup (nstr ? nstr : "John Doe");
- nstr = netscape_get_string ("mail.identity.useremail");
- id.address = CORBA_string_dup (nstr ? nstr : "");
- nstr = netscape_get_string ("mail.identity.organization");
- id.organization = CORBA_string_dup (nstr ? nstr : "");
- nstr = netscape_get_string ("mail.signature_file");
- id.signature = CORBA_string_dup (nstr ? nstr : "");
-
- /* Create transport */
- nstr = netscape_get_string ("network.hosts.smtp_server");
- if (nstr != NULL) {
- char *url;
- const char *nstr2;
-
- nstr2 = netscape_get_string ("mail.smtp_name");
- if (nstr2) {
- url = g_strconcat ("smtp://", nstr2, "@", nstr, NULL);
- } else {
- url = g_strconcat ("smtp://", nstr, NULL);
- }
- transport.url = CORBA_string_dup (url);
- transport.keep_on_server = FALSE;
- transport.auto_check = FALSE;
- transport.auto_check_time = 10;
- transport.save_passwd = FALSE;
- transport.enabled = TRUE;
- g_free (url);
- }
-
- /* Create account */
- nstr = netscape_get_string ("mail.identity.username");
- account.name = CORBA_string_dup (nstr ? nstr : "");
- account.default_account = FALSE;
- account.id = id;
- account.source = source;
- account.transport = transport;
-
- account.drafts_folder_name = CORBA_string_dup ("");
- account.drafts_folder_uri = CORBA_string_dup ("");
- account.sent_folder_name = CORBA_string_dup ("");
- account.sent_folder_uri = CORBA_string_dup ("");
-
- /* Create POP3 source */
- nstr = netscape_get_string ("network.hosts.pop_server");
- if (nstr != NULL && *nstr != 0) {
- char *url;
- const char *nstr2;
-
- nstr2 = netscape_get_string ("mail.pop_name");
- if (nstr2) {
- url = g_strconcat ("pop://", nstr2, "@", nstr, NULL);
- } else {
- url = g_strconcat ("pop://", nstr, NULL);
- }
- source.url = CORBA_string_dup (url);
- source.keep_on_server = netscape_get_boolean ("mail.leave_on_server");
- source.auto_check = TRUE;
- source.auto_check_time = 10;
- source.save_passwd = netscape_get_boolean ("mail.remember_password");
- source.enabled = TRUE;
- g_free (url);
- } else {
- /* Are there IMAP accounts? */
- imap = netscape_get_string ("network.hosts.imap_servers");
- if (imap != NULL) {
- char **servers;
- int i;
-
- servers = g_strsplit (imap, ",", 1024);
- for (i = 0; servers[i] != NULL; i++) {
- GNOME_Evolution_MailConfig_Service imapsource;
- char *serverstr, *name, *url;
- const char *username;
-
- /* Create a server for each of these */
- serverstr = g_strdup_printf ("mail.imap.server.%s.", servers[i]);
- name = g_strconcat (serverstr, "userName", NULL);
- username = netscape_get_string (name);
- g_free (name);
-
- if (username)
- url = g_strconcat ("imap://", username,
- "@", servers[i], NULL);
- else
- url = g_strconcat ("imap://", servers[i], NULL);
-
- imapsource.url = CORBA_string_dup (url);
-
- imapsource.keep_on_server = netscape_get_boolean ("mail.leave_on_server");
-
- name = g_strconcat (serverstr, "check_new_mail", NULL);
- imapsource.auto_check = netscape_get_boolean (name);
- g_free (name);
-
- name = g_strconcat (serverstr, "check_time", NULL);
- imapsource.auto_check_time = netscape_get_integer (name);
- g_free (name);
-
- name = g_strconcat (serverstr, "remember_password", NULL);
- imapsource.save_passwd = netscape_get_boolean (name);
- g_free (name);
- imapsource.enabled = TRUE;
-
- account.source = imapsource;
-
- GNOME_Evolution_MailConfig_addAccount (objref, &account, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Error setting account: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return;
- }
-
- g_free (url);
- g_free (serverstr);
- }
-
- CORBA_exception_free (&ev);
- g_strfreev (servers);
- return;
- }
- }
-
- GNOME_Evolution_MailConfig_addAccount (objref, &account, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Error setting account: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-}
-
-static gboolean
-netscape_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- 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");
-
- if (settings && mail) {
- gnome_config_pop_prefix ();
- return FALSE;
- }
- gnome_config_pop_prefix ();
-
- importer->do_mail = !mail;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
- importer->do_settings = !settings;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->settings),
- importer->do_settings);
-
- if (importer->ask_again == TRUE) {
- return FALSE;
- }
-
- if (user_prefs == NULL) {
- netscape_init_prefs ();
- }
-
- nsmail_dir = g_hash_table_lookup (user_prefs, "mail.directory");
- if (nsmail_dir == NULL)
- return FALSE;
- else
- return TRUE;
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- NetscapeImporter *importer = (NetscapeImporter *) data;
- CORBA_Object objref;
- CORBA_Environment ev;
-
- g_print ("Processed....\n");
- if (more_items) {
- g_print ("Processing...\n");
-
- CORBA_exception_init (&ev);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- GNOME_Evolution_Importer_processItem (importer->importer,
- objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
- return;
- }
-
- if (importer->dir_list) {
- import_next (importer);
- } else {
- gtk_main_quit ();
- }
-}
-
-static gboolean
-netscape_import_file (NetscapeImporter *importer,
- const char *path,
- const char *folderpath)
-{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
-
- /* Do import */
- d(g_warning ("Importing %s as %s\n", path, folderpath));
-
- CORBA_exception_init (&ev);
-
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path,
- folderpath, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s", CORBA_exception_id (&ev));
- CORBA_Object_release (importer->importer, &ev);
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- importer->listener = evolution_importer_listener_new (importer_cb,
- importer);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- d(g_print ("%s:Processing...\n", __FUNCTION__));
- CORBA_exception_init (&ev);
- GNOME_Evolution_Importer_processItem (importer->importer,
- objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return FALSE;
- }
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-typedef struct {
- NetscapeImporter *importer;
- char *parent;
- char *path;
- char *foldername;
-} NetscapeCreateDirectoryData;
-
-static void
-import_next (NetscapeImporter *importer)
-{
- NetscapeCreateDirectoryData *data;
-
- if (importer->dir_list) {
- char *folder;
-
- /* Do the next in the list */
- data = importer->dir_list->data;
-
- folder = g_concat_dir_and_file (data->parent, data->foldername);
- netscape_import_file (importer, data->path, folder);
- g_free (folder);
- g_free (data->parent);
- g_free (data->path);
- g_free (data->foldername);
- g_free (data);
- importer->dir_list = importer->dir_list->next;
- }
-}
-
-static char *
-maybe_replace_name (const char *original_name)
-{
- if (strcmp (original_name, "Trash") == 0) {
- return g_strdup ("Netscape-Trash"); /* Trash is an invalid name */
- } else if (strcmp (original_name, "Unsent Messages") == 0) {
- return g_strdup ("Outbox");
- }
-
- return g_strdup (original_name);
-}
-
-/* This function basically flattens the tree structure.
- It makes a list of all the directories that are to be imported. */
-static void
-scan_dir (NetscapeImporter *importer,
- const char *orig_parent,
- const char *dirname)
-{
- DIR *nsmail;
- struct stat buf;
- struct dirent *current;
-
- nsmail = opendir (dirname);
- if (nsmail == NULL) {
- d(g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno)));
- return;
- }
-
- current = readdir (nsmail);
- while (current) {
- char *fullname, *foldername;
-
- /* Ignore things which start with .
- which should be ., .., and the summaries. */
- if (current->d_name[0] =='.') {
- current = readdir (nsmail);
- continue;
- }
-
- if (*orig_parent == '/') {
- foldername = maybe_replace_name (current->d_name);
- } else {
- foldername = g_strdup (current->d_name);
- }
-
- fullname = g_concat_dir_and_file (dirname, current->d_name);
- if (stat (fullname, &buf) == -1) {
- d(g_warning ("Could not stat %s\nstat returned:%s",
- fullname, g_strerror (errno)));
- current = readdir (nsmail);
- g_free (fullname);
- continue;
- }
-
- if (S_ISREG (buf.st_mode)) {
- char *sbd, *parent;
- NetscapeCreateDirectoryData *data;
-
- d(g_print ("File: %s\n", fullname));
-
- data = g_new0 (NetscapeCreateDirectoryData, 1);
- data->importer = importer;
- data->parent = g_strdup (orig_parent);
- data->path = g_strdup (fullname);
- data->foldername = g_strdup (foldername);
-
- importer->dir_list = g_list_append (importer->dir_list,
- data);
-
-
- parent = g_concat_dir_and_file (orig_parent,
- data->foldername);
-
- /* Check if a .sbd folder exists */
- sbd = g_strconcat (fullname, ".sbd", NULL);
- if (g_file_exists (sbd)) {
- scan_dir (importer, parent, sbd);
- }
-
- g_free (parent);
- g_free (sbd);
- }
-
- g_free (fullname);
- g_free (foldername);
- current = readdir (nsmail);
- }
-}
-
-static void
-netscape_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- NetscapeImporter *importer = closure;
- char *key, *evolution_dir;
-
- g_return_if_fail (nsmail_dir != NULL);
-
- /* Reference our object so when the shell release_unrefs us
- we will still exist and not go byebye */
- 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);
- netscape_import_accounts (importer);
- }
-
- if (importer->do_mail == TRUE) {
- gnome_config_set_bool ("mail-imported", TRUE);
- /* Scan the nsmail folder and find out what folders
- need to be imported */
- scan_dir (importer, "/", nsmail_dir);
-
- /* Import them */
- import_next (importer);
- }
-
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-
- if (importer->do_mail == FALSE) {
- /* Destroy it here if we weren't importing mail
- otherwise the mail importer destroys itself
- once the mail in imported */
- bonobo_object_unref (BONOBO_OBJECT (ii));
- }
-}
-
-static void
-netscape_destroy_cb (GtkObject *object,
- NetscapeImporter *importer)
-{
- /* Save the state of the checkboxes */
- g_print ("\n-------Settings-------\n");
- g_print ("Mail - %s\n", importer->do_mail ? "Yes" : "No");
- g_print ("Addressbook - %s\n", importer->do_addrs ? "Yes" : "No");
- g_print ("Filters - %s\n", importer->do_filters ? "Yes" : "No");
- g_print ("Settings - %s\n", importer->do_settings ? "Yes" : "No");
-
- netscape_store_settings (importer);
- gtk_main_quit ();
-}
-
-/* Fun initialisation stuff */
-
-/* Fun with aggregation */
-static void
-checkbox_toggle_cb (GtkToggleButton *tb,
- gboolean *do_item)
-{
- *do_item = gtk_toggle_button_get_active (tb);
-}
-
-static BonoboControl *
-create_checkboxes_control (NetscapeImporter *importer)
-{
- GtkWidget *container, *vbox, *sep;
- BonoboControl *control;
-
- container = gtk_frame_new (_("Import"));
- vbox = gtk_vbox_new (FALSE, 2);
- gtk_container_set_border_width (GTK_CONTAINER (container), 2);
- gtk_container_add (GTK_CONTAINER (container), vbox);
-
- importer->mail = gtk_check_button_new_with_label (_("Mail"));
- gtk_signal_connect (GTK_OBJECT (importer->mail), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_mail);
-
- importer->settings = gtk_check_button_new_with_label (_("Settings"));
- gtk_signal_connect (GTK_OBJECT (importer->settings), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_settings);
-
- importer->filters = gtk_check_button_new_with_label (_("Filters"));
- gtk_signal_connect (GTK_OBJECT (importer->filters), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_filters);
-
- importer->addrs = gtk_check_button_new_with_label (_("Addressbooks"));
- gtk_signal_connect (GTK_OBJECT (importer->addrs), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_addrs);
-
- sep = gtk_hseparator_new ();
-
- importer->ask = gtk_check_button_new_with_label (_("Don't ask me again"));
- gtk_signal_connect (GTK_OBJECT (importer->ask), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->ask_again);
-
- gtk_box_pack_start (GTK_BOX (vbox), importer->mail, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->settings, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->filters, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->addrs, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->ask, FALSE, FALSE, 0);
-
- /* Disable the things that can't be done yet :) */
- gtk_widget_set_sensitive (importer->filters, FALSE);
- gtk_widget_set_sensitive (importer->addrs, FALSE);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->settings),
- importer->do_settings);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->filters),
- importer->do_filters);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->addrs),
- importer->do_addrs);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->ask),
- importer->ask_again);
-
- gtk_widget_show_all (container);
- control = bonobo_control_new (container);
- return control;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- BonoboControl *control;
- NetscapeImporter *netscape;
- CORBA_Environment ev;
- char *message = N_("Evolution has found Netscape mail files.\n"
- "Would you like them to be imported into Evolution?");
-
- netscape = g_new0 (NetscapeImporter, 1);
- netscape_restore_settings (netscape);
-
- CORBA_exception_init (&ev);
- 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));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- importer = evolution_intelligent_importer_new (netscape_can_import,
- netscape_create_structure,
- "Netscape mail",
- _(message), netscape);
- gtk_signal_connect (GTK_OBJECT (importer), "destroy",
- GTK_SIGNAL_FUNC (netscape_destroy_cb), netscape);
-
- control = create_checkboxes_control (netscape);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
- return BONOBO_OBJECT (importer);
-}
-
-static void
-importer_init (void)
-{
- BonoboGenericFactory *factory;
-
- g_print ("Hi");
- factory = bonobo_generic_factory_new (FACTORY_IID, factory_fn, NULL);
- if (factory == NULL) {
- g_error ("Unable to create factory");
- exit (0);
- }
-
- bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
-}
-
-int
-main (int argc,
- char **argv)
-{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Evolution-Netscape-Importer",
- VERSION, argc, argv, oaf_popt_options, 0,
- NULL);
- orb = oaf_init (argc, argv);
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialise Bonobo");
- exit (0);
- }
-
- importer_init ();
- bonobo_main ();
-
- return 0;
-}
diff --git a/importers/pine-importer.c b/importers/pine-importer.c
deleted file mode 100644
index 787b9f78f7..0000000000
--- a/importers/pine-importer.c
+++ /dev/null
@@ -1,768 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* pine-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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 <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <bonobo/bonobo-control.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-main.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/evolution-importer-client.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#include <e-book.h>
-#include <e-card-simple.h>
-
-#define PINE_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Pine_Intelligent_Importer_Factory"
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer"
-#define KEY "pine-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- GList *dir_list;
-
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
-
- GtkWidget *mail;
- gboolean do_mail;
- GtkWidget *settings;
- gboolean do_settings;
- GtkWidget *address;
- gboolean do_address;
-
- GtkWidget *ask;
- gboolean ask_again;
-
- EBook *book;
-} PineImporter;
-
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
-} PineFolder;
-
-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 ();
-}
-
-static void
-pine_restore_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);
-
- 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->ask_again = gnome_config_get_bool ("ask-again=False");
- gnome_config_pop_prefix ();
-}
-
-/* Pass in handle so we can get the next line if we need to */
-static char *
-get_field (char **start,
- FILE *handle)
-{
- char line[4096];
- char *end, *field;
- int length;
-
- /* if this was the last line, just return */
- if (*start == NULL) {
- return NULL;
- }
-
- /* if start is just \n then we need the next line */
- if (**start == '\n') {
- d(g_warning ("Need next line"));
- if (fgets (line, 4096, handle) == NULL) {
- g_warning ("Hmmm, no next line");
- return NULL;
- }
-
- if (line[0] != ' ' || line[1] != ' ' || line[2] != ' ') {
- g_warning ("Next line was not a continuation line\n"
- "Oppps: %s", line);
- return NULL;
- }
-
- *start = line + 3;
- }
-
- if (**start == '\t') {
- /* Blank field */
-
- *start += 1;
- return NULL;
- }
-
- end = strchr (*start, '\t');
- if (end == NULL) {
- /* the line was the last comment, so just return the line */
- length = strlen (line);
- line[length - 1] = 0;
-
- field = g_strdup (*start);
-
- *start = NULL;
- } else {
- /* Null the end */
- *end = 0;
-
- field = g_strdup (*start);
- *start = end + 1;
- }
-
- d(g_warning ("Found %s", field));
- return field;
-}
-
-/* A very basic address spliter.
- Returns the first email address
- denoted by <address> */
-static char *
-parse_address (const char *address)
-{
- char *addr_dup, *result, *start, *end;
-
- addr_dup = g_strdup (address);
- start = strchr (addr_dup, '<');
- if (start == NULL) {
- /* Whole line is an address */
- return addr_dup;
- }
-
- start += 1;
- end = strchr (start, '>');
- if (end == NULL) {
- result = g_strdup (start);
- g_free (addr_dup);
-
- return result;
- }
-
- *end = 0;
- result = strdup (start);
- g_free (addr_dup);
-
- return result;
-}
-
-static void
-import_addressfile (EBook *book,
- EBookStatus status,
- gpointer user_data)
-{
- char *addressbook;
- FILE *handle;
- char line[4096];
-
- PineImporter *importer = user_data;
-
- addressbook = gnome_util_prepend_user_home (".addressbook");
- handle = fopen (addressbook, "r");
- g_free (addressbook);
-
- if (handle == NULL) {
- g_warning ("Cannot open .addressbook");
- return;
- }
-
- while (fgets (line, 4096, handle) != NULL) {
- char *nick, *fullname, *address, *comment, *fcc, *email = NULL;
- char *start;
- gboolean distrib = FALSE;
-
- start = line;
- nick = get_field (&start, handle);
- d(g_print ("Nick: %s\n", nick));
-
- fullname = get_field (&start, handle);
- d(g_print ("Fullname: %s\n", fullname));
-
- address = get_field (&start, handle);
- d(g_print ("Address: %s\n", address));
-
- if (*address == '(') {
- char nextline[4096];
- /* Fun, it's a distribution list */
- distrib = TRUE;
-
- /* if the last char of address == ) then this is the
- full list */
- while (fgets (nextline, 4096, handle)) {
- char *bracket;
- if (nextline[0] != ' ' ||
- nextline[1] != ' ' ||
- nextline[2] != ' ') {
- /* Not a continuation line */
- start = nextline;
- break;
- }
-
- bracket = strchr (nextline, ')');
- if (bracket != NULL &&
- *(bracket + 1) == '\t') {
-
- *(bracket + 1) = 0;
- d(g_print ("More addresses: %s\n", nextline));
- start = bracket + 2;
- break;
- } else {
- d(g_print ("More addresses: %s\n", nextline));
- }
- }
- } else {
- email = parse_address (address);
- }
-
- fcc = get_field (&start, handle);
- d(g_print ("FCC: %s\n", fcc));
-
- comment = get_field (&start, handle);
- d(g_print ("Comment: %s\n", comment));
-
- if (distrib == FALSE) {
- /* This was not a distribution list...
- Evolution doesn't handle that yet (070501)
- Fixme when it does */
- ECard *card = e_card_new ("");
- ECardSimple *simple = e_card_simple_new (card);
-
- if (fullname != NULL)
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_FULL_NAME,
- fullname);
- else
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_FILE_AS,
- nick);
-
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_EMAIL,
- email);
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_NOTE,
- comment);
- e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_NICKNAME,
- nick);
- e_book_add_card (importer->book, simple->card, NULL, NULL);
- }
-
- g_free (nick);
- g_free (email);
- g_free (address);
- g_free (comment);
- g_free (fcc);
- g_free (fullname);
- }
-
- fclose (handle);
-}
-
-static void
-import_addressbook (PineImporter *importer)
-{
- char *path, *uri;
-
- importer->book = e_book_new ();
- if (importer->book == NULL) {
- g_warning ("Could not create EBook.");
- return;
- }
-
- path = g_concat_dir_and_file (g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db");
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- if (!e_book_load_uri (importer->book, uri, import_addressfile, importer)) {
- g_warning ("Error calling load_uri");
- }
- g_free (uri);
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- PineImporter *importer = (PineImporter *) data;
- CORBA_Object objref;
- CORBA_Environment ev;
-
- g_print ("Processed.....\n");
- if (more_items) {
- g_print ("Processing.....\n");
-
- CORBA_exception_init (&ev);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- GNOME_Evolution_Importer_processItem (importer->importer,
- objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
- return;
- }
-
- if (importer->dir_list) {
- import_next (importer);
- } else {
- gtk_main_quit ();
- }
-}
-
-static gboolean
-pine_import_file (PineImporter *importer,
- const char *path,
- const char *folderpath)
-{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
-
- g_warning ("Importing %s as %s", path, folderpath);
-
- CORBA_exception_init (&ev);
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path,
- folderpath, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s", CORBA_exception_id (&ev));
- CORBA_Object_release (importer->importer, &ev);
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- importer->listener = evolution_importer_listener_new (importer_cb,
- importer);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- }
- CORBA_exception_free (&ev);
-
- return TRUE;
-}
-
-static gboolean
-pine_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- PineImporter *importer = closure;
- char *key, *maildir, *evolution_dir, *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 = gnome_config_get_bool ("mail-imported");
-
- if (mail) {
- gnome_config_pop_prefix ();
- return FALSE;
- }
- gnome_config_pop_prefix ();
-
- importer->do_mail = !mail;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
-
- if (importer->ask_again == TRUE)
- return FALSE;
-
- maildir = gnome_util_prepend_user_home ("mail");
- md_exists = g_file_exists (maildir);
- gtk_widget_set_sensitive (importer->mail, md_exists);
- g_free (maildir);
-
- addrfile = gnome_util_prepend_user_home (".addressbook");
- addr_exists = g_file_exists (addrfile);
- g_free (addrfile);
- gtk_widget_set_sensitive (importer->address, addr_exists);
-
- return md_exists || addr_exists;
-}
-
-static void
-import_next (PineImporter *importer)
-{
- PineFolder *data;
-
- if (importer->dir_list) {
- char *folder;
-
- data = importer->dir_list->data;
-
- folder = g_concat_dir_and_file (data->parent, data->foldername);
- pine_import_file (importer, data->path, folder);
- g_free (folder);
- g_free (data->parent);
- g_free (data->path);
- g_free (data->foldername);
- g_free (data);
- importer->dir_list = importer->dir_list->next;
- }
-
-}
-
-/* Pine uses sent-mail and saved-mail whereas Evolution uses Sent and Drafts */
-static char *
-maybe_replace_name (const char *original_name)
-{
- if (strcmp (original_name, "sent-mail") == 0) {
- return g_strdup ("Sent");
- } else if (strcmp (original_name, "saved-messages") == 0) {
- return g_strdup ("Drafts");
- }
-
- return g_strdup (original_name);
-}
-
-static void
-scan_dir (PineImporter *importer,
- const char *dirname,
- const char *orig_parent)
-{
- DIR *maildir;
- struct stat buf;
- struct dirent *current;
-
- maildir = opendir (dirname);
- if (maildir == NULL) {
- g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno));
- return;
- }
-
- current = readdir (maildir);
- while (current) {
- PineFolder *pf;
- char *fullname, *foldername;
-
- /* Ignore . and .. */
- if (current->d_name[0] == '.') {
- if (current->d_name[1] == '\0' ||
- (current->d_name[1] == '.' && current->d_name[2] == '\0')) {
- current = readdir (maildir);
- continue;
- }
- }
-
- if (*orig_parent == '/') {
- foldername = maybe_replace_name (current->d_name);
- } else {
- foldername = g_strdup (current->d_name);
- }
-
- fullname = g_concat_dir_and_file (dirname, current->d_name);
- if (stat (fullname, &buf) == -1) {
- g_warning ("Could not stat %s\nstat returned: %s",
- fullname, g_strerror (errno));
- current = readdir (maildir);
- g_free (fullname);
- continue;
- }
-
- if (S_ISREG (buf.st_mode)) {
- pf = g_new (PineFolder, 1);
- pf->path = g_strdup (fullname);
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (foldername);
- importer->dir_list = g_list_append (importer->dir_list, pf);
- } else if (S_ISDIR (buf.st_mode)) {
- char *subdir;
-
- pf = g_new (PineFolder, 1);
- pf->path = NULL;
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (foldername);
- importer->dir_list = g_list_append (importer->dir_list, pf);
-
- subdir = g_concat_dir_and_file (orig_parent, foldername);
- scan_dir (importer, fullname, subdir);
- g_free (subdir);
- }
-
- g_free (fullname);
- g_free (foldername);
- current = readdir (maildir);
- }
-}
-
-static void
-pine_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- PineImporter *importer = closure;
- char *maildir, *key, *evolution_dir;
-
- 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);
-
- import_addressbook (importer);
- }
-
- if (importer->do_mail == TRUE) {
- gnome_config_set_bool ("mail-imported", TRUE);
-
- maildir = gnome_util_prepend_user_home ("mail");
- scan_dir (importer, maildir, "/");
- g_free (maildir);
-
- /* Import them */
- import_next (importer);
- }
-
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-
- if (importer->do_mail == FALSE && importer->do_address == FALSE) {
- /* Destroy it here if we weren't importing mail
- otherwise the mail importer destroys itself
- once the mail is imported */
-
- /* Hmmm, this needs fixed badly */
- bonobo_object_unref (BONOBO_OBJECT (ii));
- }
-}
-
-static void
-pine_destroy_cb (GtkObject *object,
- PineImporter *importer)
-{
- 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);
- gtk_main_quit ();
-}
-
-/* Fun inity stuff */
-
-/* Fun control stuff */
-static void
-checkbox_toggle_cb (GtkToggleButton *tb,
- gboolean *do_item)
-{
- *do_item = gtk_toggle_button_get_active (tb);
-}
-
-static BonoboControl *
-create_checkboxes_control (PineImporter *importer)
-{
- GtkWidget *container, *vbox, *sep;
- BonoboControl *control;
-
- container = gtk_frame_new (_("Import"));
- vbox = gtk_vbox_new (FALSE, 2);
- gtk_container_set_border_width (GTK_CONTAINER (container), 2);
- gtk_container_add (GTK_CONTAINER (container), vbox);
-
- importer->mail = gtk_check_button_new_with_label (_("Mail"));
- gtk_signal_connect (GTK_OBJECT (importer->mail), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_mail);
-
- importer->settings = gtk_check_button_new_with_label (_("Settings"));
- gtk_signal_connect (GTK_OBJECT (importer->settings), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_settings);
-
- importer->address = gtk_check_button_new_with_label (_("Addressbook"));
- gtk_signal_connect (GTK_OBJECT (importer->address), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->do_address);
-
- sep = gtk_hseparator_new ();
-
- importer->ask = gtk_check_button_new_with_label (_("Don't ask me again"));
- gtk_signal_connect (GTK_OBJECT (importer->ask), "toggled",
- GTK_SIGNAL_FUNC (checkbox_toggle_cb),
- &importer->ask_again);
-
- gtk_box_pack_start (GTK_BOX (vbox), importer->mail, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->settings, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->address, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), importer->ask, FALSE, FALSE, 0);
-
- /* Disable the don't do anythings */
- gtk_widget_set_sensitive (importer->settings, FALSE);
- gtk_widget_set_sensitive (importer->address, FALSE);
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->settings),
- importer->do_settings);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->address),
- importer->do_address);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->ask),
- importer->ask_again);
-
- gtk_widget_show_all (container);
- control = bonobo_control_new (container);
- return control;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- BonoboControl *control;
- PineImporter *pine;
- CORBA_Environment ev;
- char *message = N_("Evolution has found Pine mail files.\n"
- "Would you like to import them into Evolution?");
-
- pine = g_new0 (PineImporter, 1);
- pine_restore_settings (pine);
-
- CORBA_exception_init (&ev);
- 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",
- CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- importer = evolution_intelligent_importer_new (pine_can_import,
- pine_create_structure,
- _("Pine mail"),
- _(message), pine);
- gtk_signal_connect (GTK_OBJECT (importer), "destroy",
- GTK_SIGNAL_FUNC (pine_destroy_cb), pine);
-
- control = create_checkboxes_control (pine);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
- return BONOBO_OBJECT (importer);
-}
-
-static void
-importer_init (void)
-{
- BonoboGenericFactory *factory;
-
- factory = bonobo_generic_factory_new (PINE_INTELLIGENT_IMPORTER_IID,
- factory_fn, NULL);
- if (factory == NULL) {
- g_warning ("Could not initialise Pine Intelligent Mail Importer.");
- exit (0);
- }
-
- bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
-}
-
-int
-main (int argc,
- char **argv)
-{
- CORBA_ORB orb;
-
- gnome_init_with_popt_table ("Evolution-Pine-Importer",
- VERSION, argc, argv, oaf_popt_options, 0,
- NULL);
- orb = oaf_init (argc, argv);
- if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) {
- g_error ("Could not initialise Bonobo");
- exit (0);
- }
-
- importer_init ();
- bonobo_main ();
-
- return 0;
-}