aboutsummaryrefslogtreecommitdiffstats
path: root/mail/importers
diff options
context:
space:
mode:
authornobody <nobody@localhost>2003-12-09 09:57:09 +0800
committernobody <nobody@localhost>2003-12-09 09:57:09 +0800
commit56f2d7b21f78ef90bd59bc2b88e312a8480a5b4c (patch)
tree75bb0caf9afd4b94842023406d6a7938c5d8b2b7 /mail/importers
parent0031a7166cd0f3fc0cec0b60c468ca22a8c45b0b (diff)
downloadgsoc2013-evolution-GEDIT_2_5_92.tar
gsoc2013-evolution-GEDIT_2_5_92.tar.gz
gsoc2013-evolution-GEDIT_2_5_92.tar.bz2
gsoc2013-evolution-GEDIT_2_5_92.tar.lz
gsoc2013-evolution-GEDIT_2_5_92.tar.xz
gsoc2013-evolution-GEDIT_2_5_92.tar.zst
gsoc2013-evolution-GEDIT_2_5_92.zip
This commit was manufactured by cvs2svn to create tag 'GEDIT_2_5_92'.GEDIT_2_5_92
svn path=/tags/GEDIT_2_5_92/; revision=23726
Diffstat (limited to 'mail/importers')
-rw-r--r--mail/importers/.cvsignore15
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.server.in.in26
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Mbox_Importer.server.in.in29
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.server.in.in26
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Outlook_Importer.server.in.in29
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.server.in.in26
-rw-r--r--mail/importers/Makefile.am102
-rw-r--r--mail/importers/elm-importer.c593
-rw-r--r--mail/importers/evolution-mbox-importer.c335
-rw-r--r--mail/importers/evolution-outlook-importer.c318
-rw-r--r--mail/importers/mozilla-status-headers.h29
-rw-r--r--mail/importers/netscape-importer.c2162
-rw-r--r--mail/importers/pine-importer.c643
13 files changed, 0 insertions, 4333 deletions
diff --git a/mail/importers/.cvsignore b/mail/importers/.cvsignore
deleted file mode 100644
index ebc3104d83..0000000000
--- a/mail/importers/.cvsignore
+++ /dev/null
@@ -1,15 +0,0 @@
-.deps
-.libs
-.pure
-Makefile
-Makefile.in
-*.bb
-*.bbg
-*.da
-*.gcov
-*.server
-*.server.in
-*.lo
-*.la
-Mailer.h
-Mailer-*.c \ No newline at end of file
diff --git a/mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.server.in.in b/mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.server.in.in
deleted file mode 100644
index c9f1c985d1..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.server.in.in
+++ /dev/null
@@ -1,26 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory:@VERSION@"
- type="exe"
- location="@BINDIR@/evolution-@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Elm importer"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Elm importer"/>
-</oaf_server>
-</oaf_info>
diff --git a/mail/importers/GNOME_Evolution_Mail_Mbox_Importer.server.in.in b/mail/importers/GNOME_Evolution_Mail_Mbox_Importer.server.in.in
deleted file mode 100644
index 72e634bd6a..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Mbox_Importer.server.in.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Mbox_ImporterFactory:@VERSION@"
- type="exe"
- location="@BINDIR@/evolution-@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution mbox importer"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Mbox_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Mbox_ImporterFactory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Importer:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="evolution:menu_name" type="string"
- _value="MBox (mbox)"/>
- <oaf_attribute name="name" type="string"
- _value="Evolution mbox importer"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.server.in.in b/mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.server.in.in
deleted file mode 100644
index 83302a5402..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.server.in.in
+++ /dev/null
@@ -1,26 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer_Factory:@VERSION@"
- type="exe"
- location="@BINDIR@/evolution-@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Netscape Mail importer"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer_Factory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Netscape Mail importer"/>
-</oaf_server>
-</oaf_info>
diff --git a/mail/importers/GNOME_Evolution_Mail_Outlook_Importer.server.in.in b/mail/importers/GNOME_Evolution_Mail_Outlook_Importer.server.in.in
deleted file mode 100644
index 49963ca2a6..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Outlook_Importer.server.in.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Outlook_ImporterFactory:@VERSION@"
- type="exe"
- location="@BINDIR@/evolution-@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Outlook Express 4 importer"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Outlook_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Outlook_ImporterFactory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/Importer:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="evolution:menu_name" type="string"
- _value="Outlook Express 4 (.mbx)"/>
- <oaf_attribute name="name" type="string"
- _value="Evolution Outlook Express 4 importer"/>
-</oaf_server>
-
-</oaf_info>
diff --git a/mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.server.in.in b/mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.server.in.in
deleted file mode 100644
index b81789c291..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.server.in.in
+++ /dev/null
@@ -1,26 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer_Factory:@VERSION@"
- type="exe"
- location="@BINDIR@/evolution-@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Pine importer"/>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer:@VERSION@"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer_Factory:@VERSION@">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:@VERSION@"/>
- </oaf_attribute>
-
- <oaf_attribute name="name" type="string"
- _value="Evolution Pine importer"/>
-</oaf_server>
-</oaf_info>
diff --git a/mail/importers/Makefile.am b/mail/importers/Makefile.am
deleted file mode 100644
index 2e2f8881f2..0000000000
--- a/mail/importers/Makefile.am
+++ /dev/null
@@ -1,102 +0,0 @@
-importersdir = $(privlibdir)/evolution-mail-importers
-
-importers_LTLIBRARIES = liboutlook.la libmbox.la \
- libevolution-elm-importer.la \
- libevolution-pine-importer.la \
- libevolution-netscape-importer.la
-
-INCLUDES = -I.. \
- -I$(srcdir)/.. \
- -I$(top_srcdir) \
- -I$(top_srcdir)/shell \
- -I$(top_builddir)/shell \
- -DG_LOG_DOMAIN=\"evolution-mail-importer\" \
- -I$(top_srcdir)/addressbook/backend \
- -I$(top_builddir)/addressbook/backend \
- -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
- $(IMPORTERS_CFLAGS)
-
-liboutlook_la_SOURCES = \
- evolution-outlook-importer.c
-liboutlook_la_LDFLAGS = -avoid-version -module
-
-libmbox_la_SOURCES = evolution-mbox-importer.c \
- mozilla-status-headers.h
-libmbox_la_LDFLAGS = -avoid-version -module
-
-IDLS = \
- $(top_srcdir)/mail/Mailer.idl
-
-MAIL_GENERATED_H = \
- Mailer.h
-MAIL_GENERATED_C = \
- Mailer-common.c \
- Mailer-skels.c \
- Mailer-stubs.c
-MAIL_GENERATED = $(MAIL_GENERATED_C) $(MAIL_GENERATED_H)
-
-$(MAIL_GENERATED_H): $(IDLS)
- $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(top_srcdir)/mail/Mailer.idl
-$(MAIL_GENERATED_C): $(MAIL_GENERATED_H)
-
-libevolution_netscape_importer_la_SOURCES = \
- $(MAIL_GENERATED) \
- netscape-importer.c
-
-libevolution_netscape_importer_la_LDFLAGS = -avoid-version -module
-
-libevolution_netscape_importer_la_LIBADD = \
- $(top_builddir)/shell/importer/libevolution-importer.la \
- $(top_builddir)/camel/libcamel.la \
- $(top_builddir)/e-util/libeutil.la \
- $(top_builddir)/filter/libfilter.la \
- $(top_builddir)/shell/libeshell.la \
- $(IMPORTERS_LIBS)
-
-libevolution_elm_importer_la_SOURCES = \
- elm-importer.c
-
-libevolution_elm_importer_la_LDFLAGS = -avoid-version -module
-
-libevolution_elm_importer_la_LIBADD = \
- $(top_builddir)/shell/importer/libevolution-importer.la \
- $(top_builddir)/e-util/libeutil.la \
- $(IMPORTERS_LIBS)
-
-libevolution_pine_importer_la_SOURCES = \
- pine-importer.c
-
-libevolution_pine_importer_la_LDFLAGS = -avoid-version -module
-
-libevolution_pine_importer_la_LIBADD = \
- $(top_builddir)/shell/importer/libevolution-importer.la \
- $(top_builddir)/addressbook/backend/ebook/libebook.la \
- $(top_builddir)/camel/libcamel.la \
- $(IMPORTERS_LIBS)
-
-# evolution_gnomecard_importer_SOURCES = \
-# evolution-gnomecard-importer.c
-
-# evolution_gnomecard_importer_LDADD = \
-# $(top_builddir)/shell/importer/libevolution-importer.la \
-# $(top_builddir)/addressbook/backend/ebook/libebook.la \
-# $(top_builddir)/camel/libcamel.la \
-# $(IMPORTERS_LIBS)
-
-
-server_in_files = GNOME_Evolution_Mail_Mbox_Importer.server.in.in \
- GNOME_Evolution_Mail_Outlook_Importer.server.in.in \
- GNOME_Evolution_Mail_Netscape_Intelligent_Importer.server.in.in \
- GNOME_Evolution_Mail_Elm_Intelligent_Importer.server.in.in \
- GNOME_Evolution_Mail_Pine_Intelligent_Importer.server.in.in
-server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server)
-@EVO_SERVER_RULE@
-@INTLTOOL_SERVER_RULE@
-
-BUILT_SOURCES = $(MAIL_GENERATED) $(server_DATA)
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = $(server_in_files)
-
-dist-hook:
- cd $(distdir); rm -f $(BUILT_SOURCES)
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
deleted file mode 100644
index 1386e3a26f..0000000000
--- a/mail/importers/elm-importer.c
+++ /dev/null
@@ -1,593 +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. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <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 <gconf/gconf.h>
-#include <gconf/gconf-client.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 <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-moniker-util.h>
-
-#include <bonobo-activation/bonobo-activation.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/evolution-importer-client.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#include "mail/mail-importer.h"
-
-#define ELM_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory:" BASE_VERSION
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer:" BASE_VERSION
-#define KEY "elm-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- EvolutionIntelligentImporter *ii;
-
- GList *dir_list;
-
- int progress_count;
- int more;
- EvolutionImporterResult result;
-
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
-
- GtkWidget *mail;
- gboolean do_mail;
-
- GtkWidget *dialog;
- GtkWidget *label;
- GtkWidget *progressbar;
-} ElmImporter;
-
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
-} ElmFolder;
-
-static GHashTable *elm_prefs = NULL;
-
-void mail_importer_module_init (void);
-
-static void import_next (ElmImporter *importer);
-
-static GtkWidget *
-create_importer_gui (ElmImporter *importer)
-{
- GtkWidget *dialog;
-
- dialog = gnome_message_box_new (_("Evolution is importing your old Elm mail"), GNOME_MESSAGE_BOX_INFO, NULL);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Importing..."));
-
- importer->label = gtk_label_new (_("Please wait"));
- importer->progressbar = gtk_progress_bar_new ();
- gtk_progress_set_activity_mode (GTK_PROGRESS (importer->progressbar), TRUE);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), importer->label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), importer->progressbar, FALSE, FALSE, 0);
-
- return dialog;
-}
-
-static void
-elm_store_settings (ElmImporter *importer)
-{
- GConfClient *gconf;
-
- gconf = gconf_client_get_default ();
- gconf_client_set_bool (gconf, "/apps/evolution/importer/elm/mail", importer->do_mail, NULL);
-}
-
-static void
-elm_restore_settings (ElmImporter *importer)
-{
- GConfClient *gconf = gconf_client_get_default ();
-
- importer->do_mail = gconf_client_get_bool (gconf, "/apps/evolution/importer/elm/mail", NULL);
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- ElmImporter *importer = (ElmImporter *) data;
-
- importer->result = result;
- importer->more = more_items;
-}
-
-static gboolean
-elm_import_file (ElmImporter *importer,
- const char *path,
- const char *folderpath)
-{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
- char *str, *uri;
- struct stat st;
-
- str = g_strdup_printf (_("Importing %s as %s"), path, folderpath);
- gtk_label_set_text (GTK_LABEL (importer->label), str);
- g_free (str);
- while (g_main_context_iteration(NULL, FALSE))
- ;
-
- uri = mail_importer_make_local_folder(folderpath);
- if (!uri)
- return FALSE;
-
- /* if its a dir, we just create it, but dont add anything */
- if (lstat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
- g_free(uri);
- /* this is ok, we return false to say we haven't launched an async task */
- return FALSE;
- }
-
- CORBA_exception_init(&ev);
-
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path, uri, "", &ev);
- g_free(uri);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- /* process all items in a direct loop */
- importer->listener = evolution_importer_listener_new (importer_cb, importer);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- do {
- importer->progress_count++;
- if ((importer->progress_count & 0xf) == 0)
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar));
-
- importer->result = -1;
- GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- break;
- }
-
- while (importer->result == -1 || g_main_context_pending(NULL))
- g_main_context_iteration(NULL, TRUE);
- } while (importer->more);
-
- bonobo_object_unref((BonoboObject *)importer->listener);
-
- CORBA_exception_free (&ev);
-
- return FALSE;
-}
-
-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 *elmdir, *maildir, *aliasfile;
- char *elmrc;
- gboolean exists, mailexists, aliasexists;
- gboolean mail;
- struct stat st;
- GConfClient *gconf = gconf_client_get_default();
-
- mail = gconf_client_get_bool(gconf, "/apps/evolution/importer/elm/mail-imported", NULL);
- if (mail)
- return FALSE;
-
- importer->do_mail = !mail;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
-
- elmdir = gnome_util_prepend_user_home (".elm");
- exists = lstat(elmdir, &st) == 0 && S_ISDIR(st.st_mode);
-
- 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 = lstat(elmdir, &st) == 0 && S_ISDIR(st.st_mode);
- g_free (elmdir);
-
- aliasfile = gnome_util_prepend_user_home (".elm/aliases");
- aliasexists = lstat(aliasfile, &st) == 0 && S_ISREG(st.st_mode);
- g_free (aliasfile);
-
- exists = (aliasexists || mailexists);
-
- return exists;
-}
-
-static void
-import_next (ElmImporter *importer)
-{
- ElmFolder *data;
-
-trynext:
- if (importer->dir_list) {
- char *folder;
- GList *l;
- int ok;
-
- l = importer->dir_list;
- data = l->data;
-
- folder = g_concat_dir_and_file (data->parent, data->foldername);
-
- importer->dir_list = l->next;
- g_list_free_1(l);
-
- ok = 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);
- /* its ugly, but so is everything else in this file */
- if (!ok)
- goto trynext;
- } else {
- bonobo_object_unref((BonoboObject *)importer->ii);
- }
-}
-
-static void
-scan_dir (ElmImporter *importer,
- const char *orig_parent,
- const char *dirname)
-{
- DIR *maildir;
- struct stat buf;
- struct dirent *current;
- char *str;
-
- maildir = opendir (dirname);
- if (maildir == NULL) {
- g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno));
- return;
- }
-
- str = g_strdup_printf (_("Scanning %s"), dirname);
- gtk_label_set_text (GTK_LABEL (importer->label), str);
- g_free (str);
-
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
-
- 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;
-
- /* 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);
-
- if (importer->do_mail == TRUE) {
- char *elmdir;
- GConfClient *gconf = gconf_client_get_default();
-
- importer->dialog = create_importer_gui (importer);
- gtk_widget_show_all (importer->dialog);
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
-
- gconf_client_set_bool(gconf, "/apps/evolution/importer/elm/mail-imported", TRUE, NULL);
-
- 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, "/", elmdir);
- g_free (elmdir);
-
- /* Import them */
- import_next (importer);
- }
-
- bonobo_object_unref (BONOBO_OBJECT (ii));
-}
-
-static void
-elm_destroy_cb (ElmImporter *importer, GtkObject *object)
-{
- elm_store_settings (importer);
-
- if (importer->dialog)
- gtk_widget_destroy(importer->dialog);
-
- bonobo_object_release_unref (importer->importer, NULL);
-}
-
-/* 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 *hbox;
- BonoboControl *control;
-
- hbox = gtk_vbox_new (FALSE, 2);
-
- 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);
-
- gtk_box_pack_start (GTK_BOX (hbox), importer->mail, FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
- control = bonobo_control_new (hbox);
- return control;
-}
-
-static BonoboObject *
-elm_factory_fn (BonoboGenericFactory *_factory,
- const char *id,
- 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);
-
- CORBA_exception_init (&ev);
-
- elm_restore_settings (elm);
-
- elm->importer = bonobo_activation_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);
- return NULL;
- }
- CORBA_exception_free (&ev);
-
- importer = evolution_intelligent_importer_new (elm_can_import,
- elm_create_structure,
- _("Elm"),
- _(message), elm);
- g_object_weak_ref(G_OBJECT (importer), (GWeakNotify)elm_destroy_cb, elm);
- elm->ii = importer;
-
- control = create_checkboxes_control (elm);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
- return BONOBO_OBJECT (importer);
-}
-
-void
-mail_importer_module_init (void)
-{
- static gboolean initialised = FALSE;
- BonoboGenericFactory *factory;
-
- if (initialised == TRUE)
- return;
-
- factory = bonobo_generic_factory_new (ELM_INTELLIGENT_IMPORTER_IID,
- elm_factory_fn, NULL);
- if (factory == NULL)
- g_warning ("Could not initialise Elm Intelligent Mail Importer.");
- initialised = TRUE;
-}
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
deleted file mode 100644
index 83323703af..0000000000
--- a/mail/importers/evolution-mbox-importer.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* evolution-mbox-importer.c
- *
- * Authors: Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-
-#include <camel/camel-exception.h>
-#include <camel/camel-mime-message.h>
-#include <camel/camel-mime-parser.h>
-#include <camel/camel-mime-part.h>
-
-#include <importer/evolution-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#include "mozilla-status-headers.h"
-
-#include "mail/mail-importer.h"
-#include "mail-tools.h"
-
-#include "e-util/e-path.h"
-
-/* #define IMPORTER_DEBUG */
-#ifdef IMPORTER_DEBUG
-#define IN g_print ("=====> %s (%d)\n", G_GNUC_FUNCTION, __LINE__)
-#define OUT g_print ("<==== %s (%d)\n", G_GNUC_FUNCTION, __LINE__)
-#else
-#define IN
-#define OUT
-#endif
-
-#define MBOX_FACTORY_IID "OAFIID:GNOME_Evolution_Mail_Mbox_ImporterFactory:" BASE_VERSION
-
-typedef struct {
- MailImporter importer; /* Parent */
-
- char *filename;
- int num;
- GNOME_Evolution_Storage_Result create_result;
-
- CamelMimeParser *mp;
- gboolean is_folder;
-} MboxImporter;
-
-void mail_importer_module_init (void);
-
-/* EvolutionImporter methods */
-
-
-static CamelMessageInfo *
-get_info_from_mozilla (const char *mozilla_status,
- gboolean *deleted)
-{
- unsigned int status;
- CamelMessageInfo *info;
-
- *deleted = FALSE;
-
- status = strtoul (mozilla_status, NULL, 16);
- if (status == 0) {
- return camel_message_info_new ();
- }
-
- if (status & MSG_FLAG_EXPUNGED) {
- *deleted = TRUE;
-
- return NULL;
- }
-
- info = camel_message_info_new ();
-
- if (status & MSG_FLAG_READ)
- info->flags |= CAMEL_MESSAGE_SEEN;
-
- if (status & MSG_FLAG_MARKED)
- info->flags |= CAMEL_MESSAGE_FLAGGED;
-
- if (status & MSG_FLAG_REPLIED)
- info->flags |= CAMEL_MESSAGE_ANSWERED;
-
- return info;
-}
-
-static void
-process_item_fn (EvolutionImporter *eimporter,
- CORBA_Object listener,
- void *closure,
- CORBA_Environment *ev)
-{
- MboxImporter *mbi = (MboxImporter *) closure;
- MailImporter *importer = (MailImporter *) mbi;
- gboolean done = FALSE;
- CamelException *ex;
- const char *mozilla_status;
-
- if (importer->folder == NULL) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_BAD_FILE,
- FALSE, ev);
- }
-
- if (mbi->is_folder == TRUE) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_OK,
- FALSE, ev);
- return;
- }
-
- ex = camel_exception_new ();
- if (camel_mime_parser_step (mbi->mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) {
- /* Import the next message */
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
- gboolean deleted;
-
- IN;
- msg = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg), mbi->mp) == -1) {
- g_warning ("Failed message %d", mbi->num);
- camel_object_unref (CAMEL_OBJECT (msg));
- done = TRUE;
- } else {
- mozilla_status = camel_medium_get_header (CAMEL_MEDIUM (msg), "X-Mozilla-Status");
- if (mozilla_status != NULL) {
- info = get_info_from_mozilla (mozilla_status, &deleted);
- } else {
- deleted = FALSE;
- info = camel_message_info_new ();
- }
-
- if (deleted == FALSE) {
- /* write the mesg */
- camel_folder_append_message (importer->folder, msg, info, NULL, ex);
- }
-
- if (info)
- camel_message_info_free (info);
-
- camel_object_unref (msg);
- if (camel_exception_is_set (ex)) {
- g_warning ("Failed message %d", mbi->num);
- done = TRUE;
- }
- }
- OUT;
- } else {
- IN;
- /* all messages have now been imported */
- camel_folder_sync (importer->folder, FALSE, ex);
- camel_folder_thaw (importer->folder);
- importer->frozen = FALSE;
- done = TRUE;
- OUT;
- }
-
- if (!done)
- camel_mime_parser_step (mbi->mp, 0, 0);
-
- camel_exception_free (ex);
-
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_OK,
- !done, ev);
- return;
-}
-
-static gboolean
-support_format_fn (EvolutionImporter *importer,
- const char *filename,
- void *closure)
-{
- char signature[6];
- gboolean ret = FALSE;
- int fd, n;
-
- fd = open (filename, O_RDONLY);
- if (fd == -1)
- return FALSE;
-
- n = read (fd, signature, 5);
- if (n > 0) {
- signature[n] = '\0';
- if (!g_strncasecmp (signature, "From ", 5))
- ret = TRUE;
- }
-
- close (fd);
-
- return ret;
-}
-
-static void
-importer_destroy_cb (void *data, GObject *object)
-{
- MboxImporter *mbi = data;
- MailImporter *importer = data;
-
- if (importer->folder) {
- if (importer->frozen) {
- camel_folder_sync (importer->folder, FALSE, NULL);
- camel_folder_thaw (importer->folder);
- }
-
- camel_object_unref (importer->folder);
- }
-
- g_free (mbi->filename);
- if (mbi->mp)
- camel_object_unref (mbi->mp);
-
- g_free (mbi);
-}
-
-static gboolean
-load_file_fn (EvolutionImporter *eimporter,
- const char *filename,
- const char *uri,
- const char *folder_type,
- void *closure)
-{
- MboxImporter *mbi;
- MailImporter *importer;
- struct stat buf;
- int fd;
-
- mbi = (MboxImporter *) closure;
- importer = (MailImporter *) mbi;
-
- mbi->filename = g_strdup (filename);
-
- fd = open (filename, O_RDONLY);
- if (fd == -1) {
- g_warning ("Cannot open file");
- return FALSE;
- }
-
- fstat (fd, &buf);
- if (S_ISREG (buf.st_mode)) {
- mbi->mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mbi->mp, TRUE);
- if (camel_mime_parser_init_with_fd (mbi->mp, fd) == -1) {
- g_warning ("Unable to process spool folder");
- goto fail;
- }
- mbi->is_folder = FALSE;
- } else {
- mbi->is_folder = TRUE;
- }
-
- importer->mstream = NULL;
- if (uri == NULL || *uri == '\0')
- importer->folder = mail_tool_get_local_inbox (NULL);
- else
- importer->folder = mail_tool_uri_to_folder(uri, 0, NULL);
-
- if (importer->folder == NULL) {
- g_warning ("Bad folder\n");
- goto fail;
- }
-
- if (importer->folder != NULL) {
- camel_folder_freeze (importer->folder);
- importer->frozen = TRUE;
- }
-
- return TRUE;
-
- fail:
- camel_object_unref (mbi->mp);
- mbi->mp = NULL;
-
- return FALSE;
-}
-
-static BonoboObject *
-mbox_factory_fn (BonoboGenericFactory *_factory,
- const char *cid,
- void *closure)
-{
- EvolutionImporter *importer;
- MboxImporter *mbox;
-
- mbox = g_new0 (MboxImporter, 1);
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, mbox);
- g_object_weak_ref(G_OBJECT(importer), importer_destroy_cb, mbox);
-
- return BONOBO_OBJECT (importer);
-}
-
-/* Entry point */
-void
-mail_importer_module_init (void)
-{
- static gboolean initialised = FALSE;
- BonoboGenericFactory *factory;
-
- if (initialised == TRUE)
- return;
-
- factory = bonobo_generic_factory_new (MBOX_FACTORY_IID,
- mbox_factory_fn, NULL);
-
- if (factory == NULL)
- g_warning ("Could not initialise mbox importer factory.");
-
- initialised = TRUE;
-}
-
diff --git a/mail/importers/evolution-outlook-importer.c b/mail/importers/evolution-outlook-importer.c
deleted file mode 100644
index 62d99bb149..0000000000
--- a/mail/importers/evolution-outlook-importer.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* evolution-outlook-importer.c
- *
- * Authors: Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-
-#include <stdio.h>
-
-#include <importer/evolution-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#include <camel/camel-exception.h>
-
-#include "e-util/e-memory.h"
-
-#include "mail-importer.h"
-#include "mail-tools.h"
-
-
-#define OUTLOOK_FACTORY_IID "OAFIID:GNOME_Evolution_Mail_Outlook_ImporterFactory:" BASE_VERSION
-
-extern char *evolution_dir;
-typedef struct {
- MailImporter importer;
-
- char *filename;
- gboolean oe4; /* Is file OE4 or not? */
- FILE *handle;
- long pos;
- off_t size;
-
- gboolean busy;
-} OutlookImporter;
-
-struct oe_msg_segmentheader {
- int self;
- int increase;
- int include;
- int next;
- int usenet;
-};
-
-typedef struct oe_msg_segmentheader oe_msg_segmentheader;
-
-/* Prototype */
-
-void mail_importer_module_init (void);
-
-
-/* EvolutionImporter methods */
-
-/* Based on code from liboe 0.92 (STABLE)
- Copyright (C) 2000 Stephan B. Nedregård (stephan@micropop.com)
- Modified 2001 Iain Holmes <iain@ximian.com>
- Copyright (C) 2001 Ximian, Inc. */
-
-static void
-process_item_fn (EvolutionImporter *eimporter,
- CORBA_Object listener,
- void *closure,
- CORBA_Environment *ev)
-{
- OutlookImporter *oli = (OutlookImporter *) closure;
- MailImporter *importer = (MailImporter *) oli;
- oe_msg_segmentheader *header;
- gboolean more = TRUE;
- char *cb, *sfull, *s;
- long end_pos = 0;
- int i;
-
- if (oli->busy == TRUE) {
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_BUSY,
- more, ev);
- return;
- }
-
- oli->busy = TRUE;
- header = g_new (oe_msg_segmentheader, 1);
- fread (header, 16, 1, oli->handle);
-
- /* Write a From line */
- mail_importer_add_line (importer,
- "From evolution-outlook-importer", FALSE);
- end_pos = oli->pos + header->include;
- if (end_pos >= oli->size) {
- end_pos = oli->size;
- more = FALSE;
- }
-
- oli->pos += 4;
-
- cb = g_new (char, 4);
- sfull = g_new (char, 65536);
- s = sfull;
-
- while (oli->pos < end_pos) {
- fread (cb, 1, 4, oli->handle);
- for (i = 0; i < 4; i++, oli->pos++) {
- if (*(cb + i ) != 0x0d) {
- *s++ = *(cb + i);
-
- if (*(cb + i) == 0x0a) {
- *s = '\0';
- mail_importer_add_line (importer,
- sfull, FALSE);
- s = sfull;
- }
- }
- }
- }
-
- if (s != sfull) {
- *s = '\0';
- mail_importer_add_line (importer, sfull, FALSE);
- s = sfull;
- }
-
- mail_importer_add_line (importer, "\n", TRUE);
-
- oli->pos = end_pos;
- fseek (oli->handle, oli->pos, SEEK_SET);
-
- g_free (header);
- g_free (sfull);
- g_free (cb);
-
- GNOME_Evolution_ImporterListener_notifyResult (listener,
- GNOME_Evolution_ImporterListener_OK,
- more, ev);
- if (more == FALSE) {
- CamelException *ex;
-
- ex = camel_exception_new ();
- camel_folder_thaw (importer->folder);
- camel_folder_sync (importer->folder, FALSE, ex);
- camel_exception_free (ex);
- fclose (oli->handle);
- oli->handle = NULL;
- }
-
- oli->busy = FALSE;
- return;
-}
-
-
-/* EvolutionImporterFactory methods */
-
-static gboolean
-support_format_fn (EvolutionImporter *importer,
- const char *filename,
- void *closure)
-{
- FILE *handle;
- int signature[4];
-
- /* Outlook Express sniffer.
- Taken from liboe 0.92 (STABLE)
- Copyright (C) 2000 Stephan B. Nedregård (stephan@micropop.com) */
-
- handle = fopen (filename, "rb");
- if (handle == NULL)
- return FALSE; /* Can't open file: Can't support it :) */
-
- /* SIGNATURE */
- fread (&signature, 16, 1, handle);
- if ((signature[0]!=0xFE12ADCF) || /* OE 5 & OE 5 BETA SIGNATURE */
- (signature[1]!=0x6F74FDC5) ||
- (signature[2]!=0x11D1E366) ||
- (signature[3]!=0xC0004E9A)) {
- if ((signature[0]==0x36464D4A) &&
- (signature[1]==0x00010003)) /* OE4 SIGNATURE */ {
- fclose (handle);
- return TRUE; /* OE 4 */
- }
- fclose (handle);
- return FALSE; /* Not Outlook 4 or 5 */
- }
-
- fclose (handle);
- return FALSE; /* Can't handle OE 5 yet */
-}
-
-static void
-importer_destroy_cb (void *data, GObject *object)
-{
- OutlookImporter *oli = data;
- MailImporter *importer = data;
-
- if (importer->folder)
- camel_object_unref (importer->folder);
-
- g_free (oli->filename);
- if (oli->handle)
- fclose (oli->handle);
-
- g_free (oli);
-}
-
-static gboolean
-load_file_fn (EvolutionImporter *eimporter,
- const char *filename,
- const char *uri,
- const char *folder_type,
- void *closure)
-{
- OutlookImporter *oli;
- MailImporter *importer;
- struct stat buf;
- long pos = 0x54;
-
- oli = (OutlookImporter *) closure;
- importer = (MailImporter *) oli;
-
- oli->filename = g_strdup (filename);
- /* Will return TRUE if oe4 format */
- oli->oe4 = support_format_fn (NULL, filename, NULL);
- if (oli->oe4 == FALSE) {
- g_warning ("Not OE4 format");
- return FALSE;
- }
-
- oli->handle = fopen (filename, "rb");
- if (oli->handle == NULL) {
- g_warning ("Cannot open the file");
- return FALSE;
- }
-
- /* Get size of file */
- if (stat (filename, &buf) == -1) {
- g_warning ("Cannot stat file");
- return FALSE;
- }
-
- oli->size = buf.st_size;
-
- /* Set the fposition to the begining */
- fseek (oli->handle, pos, SEEK_SET);
- oli->pos = pos;
-
- importer->mstream = NULL;
-
- if (uri == NULL || *uri == 0)
- importer->folder = mail_tool_get_local_inbox (NULL);
- else
- importer->folder = mail_tool_uri_to_folder (uri, 0, NULL);
-
- if (importer->folder == NULL){
- g_warning ("Bad folder");
- return FALSE;
- }
-
- camel_folder_freeze (importer->folder);
- oli->busy = FALSE;
- return TRUE;
-}
-
-static BonoboObject *
-outlook_factory_fn (BonoboGenericFactory *_factory,
- const char *cid,
- void *closure)
-{
- EvolutionImporter *importer;
- OutlookImporter *oli;
-
- oli = g_new0 (OutlookImporter, 1);
-
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, oli);
- g_object_weak_ref((GObject *)importer, importer_destroy_cb, oli);
-
- return BONOBO_OBJECT (importer);
-}
-
-/* Entry point */
-void
-mail_importer_module_init (void)
-{
- static gboolean initialised = FALSE;
- BonoboGenericFactory *factory;
-
- if (initialised == TRUE)
- return;
-
- factory = bonobo_generic_factory_new (OUTLOOK_FACTORY_IID,
- outlook_factory_fn, NULL);
-
- if (factory == NULL)
- g_warning ("Could not initialise Outlook importer factory.");
-
- initialised = TRUE;
-}
-
-
diff --git a/mail/importers/mozilla-status-headers.h b/mail/importers/mozilla-status-headers.h
deleted file mode 100644
index f459d6ec8f..0000000000
--- a/mail/importers/mozilla-status-headers.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* mozilla-status-headers.h
- *
- * Authors: Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2001 Ximian, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* Defines copied from nsMsgMessageFlags.h in Mozilla source. */
-
-/* Evolution only cares about these headers I think */
-#define MSG_FLAG_READ 0x0001
-#define MSG_FLAG_REPLIED 0x0002
-#define MSG_FLAG_MARKED 0x0004
-#define MSG_FLAG_EXPUNGED 0x0008
diff --git a/mail/importers/netscape-importer.c b/mail/importers/netscape-importer.c
deleted file mode 100644
index a0610ca1b4..0000000000
--- a/mail/importers/netscape-importer.c
+++ /dev/null
@@ -1,2162 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* netscape-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- * Christian Kreibich <cK@whoop.org> (email filter import)
- *
- * Copyright 2001 Ximian, Inc. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <pwd.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.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 <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-moniker-util.h>
-
-#include <bonobo-activation/bonobo-activation.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include <importer/evolution-importer-client.h>
-
-#include <filter/filter-context.h>
-#include <filter/filter-filter.h>
-#include <filter/filter-rule.h>
-#include <filter/filter-option.h>
-#include <filter/filter-folder.h>
-#include <filter/filter-int.h>
-#include <shell/evolution-shell-client.h>
-
-#include "Mailer.h"
-#include "mail/mail-importer.h"
-
-static char *nsmail_dir = NULL;
-static GHashTable *user_prefs = NULL;
-
-/* This is rather ugly -- libfilter needs this symbol: */
-EvolutionShellClient *global_shell_client = NULL;
-
-static char *filter_name = N_("Priority Filter \"%s\"");
-
-#define FACTORY_IID "OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer_Factory:" BASE_VERSION
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer:" BASE_VERSION
-#define MAIL_CONFIG_IID "OAFIID:GNOME_Evolution_MailConfig:" BASE_VERSION
-
-#define KEY "netscape-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-#define MAXLEN 4096
-
-typedef struct {
- EvolutionIntelligentImporter *ii;
-
- GList *dir_list;
-
- int progress_count;
- int more;
- EvolutionImporterResult result;
-
- 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;
-
- /*Bonobo_ConfigDatabase db;*/
-
- /* GUI */
- GtkWidget *dialog;
- GtkWidget *label;
- GtkWidget *progressbar;
-} NsImporter;
-
-
-/* Email filter datastructures ---------------------------------------------- */
-
-
-typedef enum {
- MOVE_TO_FOLDER, CHANGE_PRIORITY, DELETE,
- MARK_READ, IGNORE_THREAD, WATCH_THREAD
-} NsFilterActionType;
-
-static char* ns_filter_action_types[] =
-{
- "Move to folder", "Change priority", "Delete",
- "Mark read", "Ignore thread", "Watch thread"
-};
-
-
-typedef enum {
- HIGHEST, HIGH, NORMAL, LOW, LOWEST, FREE, NONE
-} NsFilterActionValueType;
-
-static char *ns_filter_action_value_types[] =
-{
- "Highest", "High", "Normal", "Low", "Lowest"
-};
-
-
-typedef enum {
- FROM, SUBJECT, TO, CC, TO_OR_CC, BODY, DATE, PRIORITY,
- STATUS, AGE_IN_DAYS, X_MSG_HEADER
-} NsFilterConditionType;
-
-static char *ns_filter_condition_types[] =
-{
- "from", "subject", "to", "CC", "to or CC", "body", "date",
- "priority", "age in days"
-};
-
-
-typedef enum {
- CONTAINS, CONTAINS_NOT, IS, IS_NOT, BEGINS_WITH, ENDS_WITH,
- IS_BEFORE, IS_AFTER, IS_GREATER_THAN, IS_LESS_THAN, READ,
- REPLIED, IS_HIGHER_THAN, IS_LOWER_THAN
-} NsFilterConditionPropertyType;
-
-static char *ns_filter_condition_property_types[] =
-{
- "contains", "doesn't contain", "is", "isn't", "begins with",
- "ends with", "is before", "is after", "is greater than",
- "is less than", "read", "replied", "is higher than",
- "is lower than"
-};
-
-
-typedef struct
-{
- NsFilterConditionType type;
- NsFilterConditionPropertyType prop;
- NsFilterActionValueType prop_val_id; /* for dealing with priority levels */
- char *prop_val_str;
-} NsFilterCondition;
-
-typedef struct {
- char *name;
- char *description;
-
- gboolean enabled;
-
- NsFilterActionType action;
- NsFilterActionValueType action_val_id;
- char *action_val_str;
-
- enum _filter_grouping_t grouping;
- GList *conditions; /* List of NSFilterConditions */
-} NsFilter;
-
-
-/* Prototypes ------------------------------------------------------------- */
-void mail_importer_module_init (void);
-
-static void netscape_filter_cleanup (NsFilter *nsf);
-static char *fix_netscape_folder_names (const char *original_name);
-static void import_next (NsImporter *importer);
-
-
-/* Email filter stuff ----------------------------------------------------- */
-
-static gboolean
-netscape_filter_flatfile_get_entry (FILE *f, char *key, char *val)
-{
- char line[MAXLEN];
- char *ptr = NULL;
- char *ptr2 = NULL;
-
- if (fgets (line, MAXLEN, f)) {
-
- ptr = strchr(line, '=');
- *ptr = '\0';
-
- memcpy (key, line, strlen(line)+1);
-
- ptr += 2; /* Skip '=' and '"' */
- ptr2 = strrchr (ptr, '"');
- *ptr2 = '\0';
-
- memcpy (val, ptr, strlen(ptr)+1);
-
- d(g_warning ("Parsing key/val '%s' '%s'", key, val));
- return TRUE;
-
- }
-
- *key = '\0'; *val = '\0';
- return FALSE;
-}
-
-/* This function parses the filtering condition strings.
- Netscape describes the conditions that determine when
- to apply a filter through a string of the form
-
- " OR (type, property, value) OR (type, property, value) ... "
-
- or
- " AND (type, property, value) AND (type, property, value) ... "
-
- where type can be "subject", "from", "to", "CC" etc, property
- is "contains" etc, and value is the according pattern.
-*/
-static void
-netscape_filter_parse_conditions (NsFilter *nsf, FILE *f, char *condition)
-{
- char *ptr = condition, *ptr2 = NULL;
- char type[MAXLEN];
- char prop[MAXLEN];
- char val[MAXLEN];
- NsFilterCondition *cond;
-
- if ( (ptr = strstr (condition, "OR")) == NULL) {
- nsf->grouping = FILTER_GROUP_ALL;
- } else {
- nsf->grouping = FILTER_GROUP_ANY;
- }
-
- ptr = condition;
- while ( (ptr = strchr (ptr, '(')) != NULL) {
-
- /* Move ptr to start of type */
- ptr++;
-
- /* Move ptr2 up to next comma: */
- if ( (ptr2 = strchr (ptr, ',')) == NULL)
- continue;
-
- memcpy (type, ptr, ptr2-ptr);
- type[ptr2-ptr] = '\0';
-
- /* Move ptr to start of property */
- ptr = ptr2 + 1;
-
- /* Move ptr2 up to next comma: */
- if ( (ptr2 = strchr (ptr, ',')) == NULL)
- continue;
-
- memcpy (prop, ptr, ptr2-ptr);
- prop[ptr2-ptr] = '\0';
-
- /* Move ptr to start of value */
- ptr = ptr2 + 1;
-
- /* Move ptr2 to end of value: */
- if ( (ptr2 = strchr (ptr, ')')) == NULL)
- continue;
-
- memcpy (val, ptr, ptr2-ptr);
- val[ptr2-ptr] = '\0';
-
- cond = g_new0 (NsFilterCondition, 1);
-
- if (!strcmp (type, ns_filter_condition_types[FROM])) {
- cond->type = FROM;
- } else if (!strcmp (type, ns_filter_condition_types[SUBJECT])) {
- cond->type = SUBJECT;
- } else if (!strcmp (type, ns_filter_condition_types[TO])) {
- cond->type = TO;
- } else if (!strcmp (type, ns_filter_condition_types[CC])) {
- cond->type = CC;
- } else if (!strcmp (type, ns_filter_condition_types[TO_OR_CC])) {
- cond->type = TO_OR_CC;
- } else if (!strcmp (type, ns_filter_condition_types[BODY])) {
- cond->type = BODY;
- } else if (!strcmp (type, ns_filter_condition_types[DATE])) {
- cond->type = DATE;
- } else if (!strcmp (type, ns_filter_condition_types[PRIORITY])) {
- cond->type = PRIORITY;
- } else if (!strcmp (type, ns_filter_condition_types[STATUS])) {
- cond->type = STATUS;
- } else if (!strcmp (type, ns_filter_condition_types[AGE_IN_DAYS])) {
- cond->type = AGE_IN_DAYS;
- } else if (!strcmp (type, ns_filter_condition_types[X_MSG_HEADER])) {
- cond->type = X_MSG_HEADER;
- } else {
- d(g_warning ("Unknown condition type '%s' encountered -- skipping.", type));
- g_free (cond);
- continue;
- }
-
-
- if (!strcmp (prop, ns_filter_condition_property_types[CONTAINS])) {
- cond->prop = CONTAINS;
- } else if (!strcmp (prop, ns_filter_condition_property_types[CONTAINS_NOT])) {
- cond->prop = CONTAINS_NOT;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS])) {
- cond->prop = IS;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_NOT])) {
- cond->prop = IS_NOT;
- } else if (!strcmp (prop, ns_filter_condition_property_types[BEGINS_WITH])) {
- cond->prop = BEGINS_WITH;
- } else if (!strcmp (prop, ns_filter_condition_property_types[ENDS_WITH])) {
- cond->prop = ENDS_WITH;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_BEFORE])) {
- cond->prop = IS_BEFORE;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_AFTER])) {
- cond->prop = IS_AFTER;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_GREATER_THAN])) {
- cond->prop = IS_GREATER_THAN;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_LESS_THAN])) {
- cond->prop = IS_LESS_THAN;
- } else if (!strcmp (prop, ns_filter_condition_property_types[READ])) {
- cond->prop = READ;
- } else if (!strcmp (prop, ns_filter_condition_property_types[REPLIED])) {
- cond->prop = REPLIED;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_HIGHER_THAN])) {
- cond->prop = IS_HIGHER_THAN;
- } else if (!strcmp (prop, ns_filter_condition_property_types[IS_LOWER_THAN])) {
- cond->prop = IS_LOWER_THAN;
- } else {
- d(g_warning ("Unknown condition property '%s' encountered -- skipping.", prop));
- g_free (cond);
- continue;
- }
-
- cond->prop_val_id = FREE;
-
- if (!strcmp (val, ns_filter_action_value_types[LOWEST])) {
- cond->prop_val_id = LOWEST;
- } else if (!strcmp (val, ns_filter_action_value_types[LOW])) {
- cond->prop_val_id = LOW;
- } else if (!strcmp (val, ns_filter_action_value_types[NORMAL])) {
- cond->prop_val_id = NORMAL;
- } else if (!strcmp (val, ns_filter_action_value_types[HIGH])) {
- cond->prop_val_id = HIGH;
- } else if (!strcmp (val, ns_filter_action_value_types[HIGHEST])) {
- cond->prop_val_id = HIGHEST;
- }
-
- cond->prop_val_str = g_strdup (val);
- nsf->conditions = g_list_append (nsf->conditions, cond);
- }
-}
-
-
-static NsFilter *
-netscape_filter_read_next (FILE *mailrule_handle)
-{
- NsFilter *nsf;
- char key[MAXLEN];
- char val[MAXLEN];
-
- key[0] = '\0';
-
- for ( ; ; ) {
-
- /* Skip stuff at the beginning, until beginning of next filter
- is read: */
-
- do {
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- return NULL;
-
- } while (strcmp(key, "name"));
-
- nsf = g_new0 (NsFilter, 1);
- nsf->name = g_strdup (val);
-
-
- /* Read value for "enabled" setting */
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "enabled")) {
- goto cleanup;
- }
- if (strcmp (val, "true"))
- nsf->enabled = TRUE;
- else
- nsf->enabled = FALSE;
-
-
- /* Read filter description */
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "description")) {
- goto cleanup;
- }
- nsf->description = g_strdup (val);
-
-
- /* Skip one line -- it's a "type" entry and always seems to be "1"? */
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "type")) {
- goto cleanup;
- }
-
- /* Read filter action and handle action value accordingly */
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "action")) {
- goto cleanup;
- }
- if (!strcmp (val, ns_filter_action_types[MOVE_TO_FOLDER])) {
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "actionValue")) {
- goto cleanup;
- }
- nsf->action = MOVE_TO_FOLDER;
- nsf->action_val_id = FREE;
- nsf->action_val_str = g_strdup(val);
- }
- else if (!strcmp (val, ns_filter_action_types[CHANGE_PRIORITY])) {
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "actionValue")) {
- goto cleanup;
- }
-
- nsf->action = CHANGE_PRIORITY;
-
- if (!strcmp (val, ns_filter_action_value_types[LOWEST])) {
- nsf->action_val_id = LOWEST;
- } else if (!strcmp (val, ns_filter_action_value_types[LOW])) {
- nsf->action_val_id = LOW;
- } else if (!strcmp (val, ns_filter_action_value_types[NORMAL])) {
- nsf->action_val_id = NORMAL;
- } else if (!strcmp (val, ns_filter_action_value_types[HIGH])) {
- nsf->action_val_id = HIGH;
- } else if (!strcmp (val, ns_filter_action_value_types[HIGHEST])) {
- nsf->action_val_id = HIGHEST;
- } else {
- d(g_warning ("Unknown Netscape filter action value '%s' for action '%s'",
- val, ns_filter_action_types[CHANGE_PRIORITY]));
- goto cleanup;
- }
-
- nsf->action_val_str = NULL;
-
- }
- else if (!strcmp (val, ns_filter_action_types[DELETE])) {
-
- nsf->action = DELETE;
- nsf->action_val_id = NONE;
- }
- else if (!strcmp (val, ns_filter_action_types[MARK_READ])) {
-
- nsf->action = MARK_READ;
- nsf->action_val_id = NONE;
- }
- else if (!strcmp (val, ns_filter_action_types[IGNORE_THREAD])) {
-
- nsf->action = IGNORE_THREAD;
- nsf->action_val_id = NONE;
- }
- else if (!strcmp (val, ns_filter_action_types[WATCH_THREAD])) {
-
- nsf->action = WATCH_THREAD;
- nsf->action_val_id = NONE;
- }
- else {
- d(g_warning ("Unknown Netscape filter action '%s'", val));
- goto cleanup;
- }
-
-
- /* Read conditions, the fun part ... */
-
- if (!netscape_filter_flatfile_get_entry (mailrule_handle, key, val))
- goto cleanup;
- if (strcmp (key, "condition")) {
- goto cleanup;
- }
- netscape_filter_parse_conditions (nsf, mailrule_handle, val);
-
- return nsf;
-
- cleanup:
- netscape_filter_cleanup (nsf);
- }
-
- return NULL;
-}
-
-
-static void
-netscape_filter_cleanup (NsFilter *nsf)
-{
- GList *l;
-
- g_free (nsf->name);
- g_free (nsf->description);
- g_free (nsf->action_val_str);
-
- for (l = nsf->conditions; l; l = l->next) {
-
- NsFilterCondition *cond = (NsFilterCondition *)l->data;
-
- g_free (cond->prop_val_str);
- g_free (cond);
- }
-
- g_list_free (nsf->conditions);
- g_free (nsf);
-}
-
-
-static gboolean
-netscape_filter_set_opt_for_cond (NsFilterCondition *cond, FilterOption* op)
-{
- switch (cond->prop) {
- case CONTAINS:
- filter_option_set_current (op, "contains");
- break;
- case CONTAINS_NOT:
- filter_option_set_current (op, "does not contain");
- break;
- case IS:
- filter_option_set_current (op, "is");
- break;
- case IS_NOT:
- filter_option_set_current (op, "is not");
- break;
- case BEGINS_WITH:
- filter_option_set_current (op, "starts with");
- break;
- case ENDS_WITH:
- filter_option_set_current (op, "ends with");
- break;
- default:
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/* Translates a string of the form
- folder1.sbd/folder2.sbd/.../folderN.sbd/folder
-
- into one that looks like this:
-
- folder1/folder2/.../folderN/folder
-*/
-static char*
-netscape_filter_strip_sbd (char *ns_folder)
-{
- char *folder_copy;
- char s[MAXLEN];
- char *ptr, *ptr2;
- char *fixed_folder;
-
- folder_copy = g_strdup (ns_folder);
- ptr = folder_copy;
- s[0] = '\0';
-
- while (ptr) {
- if ( (ptr2 = strstr (ptr, ".sbd")) == NULL)
- break;
-
- *ptr2 = '\0';
- strcat (s, ptr);
-
- ptr = ptr2 + 4; /* skip ".sbd" */
- }
-
- fixed_folder = fix_netscape_folder_names (ptr);
- strcat (s, fixed_folder);
- g_free (folder_copy);
- g_free (fixed_folder);
-
- d(g_warning ("Stripped '%s' to '%s'", ns_folder, s));
-
- return g_strdup (s);
-}
-
-
-static char *
-netscape_filter_map_folder_to_uri (char *folder)
-{
- char *folder_copy;
- char s[MAXLEN];
- char *ptr, *ptr2;
-
- folder_copy = g_strdup (folder);
- ptr = folder_copy;
-
- g_snprintf (s, MAXLEN, "file://%s/evolution/local/", g_get_home_dir ());
-
- while (ptr) {
- if ( (ptr2 = strchr (ptr, '/')) == NULL)
- break;
-
- *ptr2 = '\0';
- strcat (s, ptr);
- strcat (s, "/subfolders/");
-
- ptr = ptr2 + 1;
- }
-
- strcat (s, ptr);
- g_free (folder_copy);
-
- d(g_warning ("Mapped '%s' to '%s'", folder, s));
-
- return g_strdup (s);
-}
-
-
-static void
-netscape_filter_change_priority_warning (void)
-{
- GtkWidget *dialog;
- static gboolean already_shown = FALSE;
-
- if (!already_shown) {
- already_shown = TRUE;
- dialog = gnome_ok_dialog (_("Some of your Netscape email filters are based on\n"
- "email priorities, which are not used in Evolution.\n"
- "Instead, Evolution provides scores in the range of\n"
- "-3 to 3 that can be assigned to emails and filtered\n"
- "accordingly.\n"
- "\n"
- "As a workaround, a set of filters called \"Priority Filter\"\n"
- "was added that converts Netscape's email priorities into\n"
- "Evolution's scores, and the affected filters use scores instead\n"
- "of priorities. Check the imported filters to make sure\n"
- "everything still works as intended."));
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
- }
-}
-
-
-static void
-netscape_filter_threads_action_not_supported (void)
-{
- GtkWidget *dialog;
- static gboolean already_shown = FALSE;
-
- if (!already_shown) {
- already_shown = TRUE;
- dialog = gnome_ok_dialog (_("Some of your Netscape email filters use\n"
- "the \"Ignore Thread\" or \"Watch Thread\"\n"
- "feature, which is not supported in Evolution.\n"
- "These filters will be dropped."));
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
- }
-}
-
-
-static void
-netscape_filter_body_is_not_supported (void)
-{
- GtkWidget *dialog;
- static gboolean already_shown = FALSE;
-
- if (!already_shown) {
- already_shown = TRUE;
- dialog = gnome_ok_dialog (_("Some of your Netscape email filters test the\n"
- "body of emails for (in)equality to a given string,\n"
- "which is not supported in Evolution. Those filters\n"
- "were modified to test whether that string is or is not\n"
- "contained in the message body."));
- gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
- }
-}
-
-
-static FilterRule*
-netscape_create_priority_converter (FilterContext *fc, NsFilterActionValueType priority)
-{
- FilterFilter *ff;
- FilterPart *fp;
- FilterRule *fr;
- FilterElement *el;
- char s[MAXLEN];
- int v;
-
- ff = filter_filter_new ();
- fr = FILTER_RULE(ff);
-
- g_snprintf (s, MAXLEN, filter_name, ns_filter_action_value_types[priority]);
- filter_rule_set_name (fr, s);
- filter_rule_set_source (fr, FILTER_SOURCE_INCOMING);
-
- fp = rule_context_create_part (RULE_CONTEXT(fc), "header");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "header-field");
- filter_input_set_value ((FilterInput*)el, "X-Priority");
- el = filter_part_find_element (fp, "header-type");
- filter_option_set_current ((FilterOption*)el, "contains");
- el = filter_part_find_element (fp, "word");
- filter_input_set_value ((FilterInput*)el,
- ns_filter_action_value_types[priority]);
-
- fp = filter_context_create_action (fc, "score");
- el = filter_part_find_element (fp, "score");
-
- switch (priority) {
- case LOWEST:
- v = -2;
- break;
- case LOW:
- v = -1;
- break;
- case NORMAL:
- v = 0;
- break;
- case HIGH:
- v = 1;
- break;
- case HIGHEST:
- v = 2;
- break;
- default:
- g_object_unref((ff));
- return NULL;
- }
-
- filter_int_set_value((FilterInt *)el, v);
- filter_filter_add_action (ff, fp);
-
- return FILTER_RULE(ff);
-}
-
-
-static void
-netscape_add_priority_workaround_filters (FilterContext *fc)
-{
- FilterRule *fr;
-
- fr = netscape_create_priority_converter (fc, LOWEST);
- rule_context_add_rule (RULE_CONTEXT(fc), FILTER_RULE(fr));
- rule_context_rank_rule (RULE_CONTEXT(fc), FILTER_RULE(fr), FILTER_SOURCE_INCOMING, 0);
-
- fr = netscape_create_priority_converter (fc, LOW);
- rule_context_add_rule (RULE_CONTEXT(fc), FILTER_RULE(fr));
- rule_context_rank_rule (RULE_CONTEXT(fc), FILTER_RULE(fr), FILTER_SOURCE_INCOMING, 1);
-
- fr = netscape_create_priority_converter (fc, HIGH);
- rule_context_add_rule (RULE_CONTEXT(fc), FILTER_RULE(fr));
- rule_context_rank_rule (RULE_CONTEXT(fc), FILTER_RULE(fr), FILTER_SOURCE_INCOMING, 2);
-
- fr = netscape_create_priority_converter (fc, HIGHEST);
- rule_context_add_rule (RULE_CONTEXT(fc), FILTER_RULE(fr));
- rule_context_rank_rule (RULE_CONTEXT(fc), FILTER_RULE(fr), FILTER_SOURCE_INCOMING, 3);
-}
-
-
-static gboolean
-netscape_filter_score_set (NsFilterCondition *cond, FilterInt *el)
-{
- int v;
-
- switch (cond->prop_val_id) {
- case LOWEST:
- v = -2;
- break;
- case LOW:
- v = -1;
- break;
- case NORMAL:
- v = 0;
- break;
- case HIGH:
- v = 1;
- break;
- case HIGHEST:
- v = 2;
- break;
- default:
- return FALSE;
- }
-
- filter_int_set_value(el, v);
-
- return TRUE;
-}
-
-
-static FilterFilter *
-netscape_filter_to_evol_filter (FilterContext *fc, NsFilter *nsf, gboolean *priority_needed)
-{
- RuleContext *rc = RULE_CONTEXT(fc);
- FilterFilter *ff = NULL;
- FilterPart *fp;
- FilterRule *fr;
- FilterElement *el;
- GList *l;
- gboolean part_added = FALSE, action_added = FALSE;
-
-
- ff = filter_filter_new ();
- fr = FILTER_RULE(ff);
-
- filter_rule_set_name (fr, nsf->name);
- filter_rule_set_source (fr, FILTER_SOURCE_INCOMING);
- fr->grouping = nsf->grouping;
-
-
- /* build and add partset */
-
- for (l = nsf->conditions; l; l = l->next) {
-
- NsFilterCondition *cond = (NsFilterCondition*) l->data;
-
- fp = NULL;
-
- switch (cond->type) {
- case FROM:
- fp = rule_context_create_part (rc, "sender");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "sender-type");
-
- if (!netscape_filter_set_opt_for_cond (cond, (FilterOption*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- el = filter_part_find_element (fp, "sender");
- filter_input_set_value ((FilterInput *)el, cond->prop_val_str);
- part_added = TRUE;
- break;
-
- case SUBJECT:
- fp = rule_context_create_part (rc, "subject");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "subject-type");
-
- if (!netscape_filter_set_opt_for_cond (cond, (FilterOption*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- el = filter_part_find_element (fp, "subject");
- filter_input_set_value ((FilterInput *)el, cond->prop_val_str);
- part_added = TRUE;
- break;
- case TO:
- case CC:
- case TO_OR_CC:
- fp = rule_context_create_part (rc, "to");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "recipient-type");
-
- if (!netscape_filter_set_opt_for_cond (cond, (FilterOption*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- el = filter_part_find_element (fp, "recipient");
- filter_input_set_value ((FilterInput *)el, cond->prop_val_str);
- part_added = TRUE;
- break;
- case BODY:
- fp = rule_context_create_part (rc, "body");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "body-type");
-
- switch (cond->prop) {
- case CONTAINS:
- filter_option_set_current ((FilterOption*)el, "contains");
- break;
- case CONTAINS_NOT:
- filter_option_set_current ((FilterOption*)el, "not contains");
- break;
- case IS:
- netscape_filter_body_is_not_supported ();
- filter_option_set_current ((FilterOption*)el, "contains");
- break;
- case IS_NOT:
- netscape_filter_body_is_not_supported ();
- filter_option_set_current ((FilterOption*)el, "not contains");
- break;
- default:
- g_warning("Body rule dropped");
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- el = filter_part_find_element (fp, "word");
- filter_input_set_value ((FilterInput *)el, cond->prop_val_str);
- part_added = TRUE;
- break;
- case DATE:
- fp = rule_context_create_part (rc, "sent-date");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "date-spec-type");
-
- switch (cond->prop) {
- case IS:
- filter_option_set_current ((FilterOption*)el, "is");
- break;
- case IS_NOT:
- filter_option_set_current ((FilterOption*)el, "is-not");
- break;
- case IS_BEFORE:
- filter_option_set_current ((FilterOption*)el, "before");
- break;
- case IS_AFTER:
- filter_option_set_current ((FilterOption*)el, "after");
- break;
- default:
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- el = filter_part_find_element (fp, "versus");
- filter_input_set_value ((FilterInput *)el, cond->prop_val_str);
- part_added = TRUE;
- break;
- case PRIORITY:
- switch (cond->prop) {
- case IS:
- *priority_needed = TRUE;
- fp = rule_context_create_part (rc, "score");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "score-type");
- filter_option_set_current ((FilterOption*)el, "is");
- el = filter_part_find_element (fp, "versus");
-
- if (!netscape_filter_score_set(cond, (FilterInt*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- break;
- case IS_NOT:
- *priority_needed = TRUE;
- fp = rule_context_create_part (rc, "score");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "score-type");
- filter_option_set_current ((FilterOption*)el, "is-not");
- el = filter_part_find_element (fp, "versus");
-
- if (!netscape_filter_score_set(cond, (FilterInt*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- break;
- case IS_HIGHER_THAN:
- *priority_needed = TRUE;
- fp = rule_context_create_part (rc, "score");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "score-type");
- filter_option_set_current ((FilterOption*)el, "greater-than");
- el = filter_part_find_element (fp, "versus");
-
- if (!netscape_filter_score_set(cond, (FilterInt*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
-
- break;
- case IS_LOWER_THAN:
- *priority_needed = TRUE;
- fp = rule_context_create_part (rc, "score");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "score-type");
- filter_option_set_current ((FilterOption*)el, "less-than");
- el = filter_part_find_element (fp, "versus");
-
- if (!netscape_filter_score_set(cond, (FilterInt*)el)) {
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
- break;
- default:
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
- part_added = TRUE;
- break;
-
- case STATUS:
- fp = rule_context_create_part (rc, "status");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "match-type");
-
- switch (cond->prop) {
- case IS:
- filter_option_set_current ((FilterOption*)el, "is");
- el = filter_part_find_element (fp, "flag");
-
- if (!strcmp (cond->prop_val_str,
- ns_filter_condition_property_types[READ])) {
- filter_option_set_current ((FilterOption*)el, "Seen");
- } else if (!strcmp (cond->prop_val_str,
- ns_filter_condition_property_types[REPLIED])) {
- filter_option_set_current ((FilterOption*)el, "Answered");
- }
- break;
- case IS_NOT:
- filter_option_set_current ((FilterOption*)el, "is not");
- el = filter_part_find_element (fp, "flag");
-
- if (!strcmp (cond->prop_val_str,
- ns_filter_condition_property_types[READ])) {
- filter_option_set_current ((FilterOption*)el, "Seen");
- } else if (!strcmp (cond->prop_val_str,
- ns_filter_condition_property_types[REPLIED])) {
- filter_option_set_current ((FilterOption*)el, "Answered");
- }
- default:
- filter_rule_remove_part (fr, fp);
- g_object_unref((fp));
- continue;
- }
- part_added = TRUE;
- break;
- case AGE_IN_DAYS:
- /* I guess we can skip that -- Netscape crashes anyway
- whenever you try to use that setting ... :) */
- break;
- case X_MSG_HEADER:
- fp = rule_context_create_part (rc, "header");
- filter_rule_add_part (fr, fp);
- el = filter_part_find_element (fp, "header-field");
- filter_input_set_value ((FilterInput *)el, cond->prop_val_str);
- el = filter_part_find_element (fp, "header-type");
- filter_option_set_current ((FilterOption*)el, "exists");
- part_added = TRUE;
- break;
- default:
- continue;
- }
- }
-
- if (!part_added) {
- g_object_unref((ff));
- return NULL;
- }
-
- /* build and add actionset */
-
- switch (nsf->action) {
- case MOVE_TO_FOLDER:
- {
- char *evol_folder;
- char *evol_folder_uri;
-
- fp = filter_context_create_action (fc, "move-to-folder");
- filter_filter_add_action (ff, fp);
- el = filter_part_find_element (fp, "folder");
-
- evol_folder = netscape_filter_strip_sbd (nsf->action_val_str);
- evol_folder_uri = netscape_filter_map_folder_to_uri (evol_folder);
- filter_folder_set_value ((FilterFolder *)el, evol_folder_uri);
- g_free (evol_folder);
- g_free (evol_folder_uri);
-
- action_added = TRUE;
- }
- break;
- case CHANGE_PRIORITY:
- fp = filter_context_create_action (fc, "score");
- el = filter_part_find_element (fp, "score");
-
- switch (nsf->action_val_id) {
- case LOWEST:
- filter_int_set_value((FilterInt *)el, -2);
- action_added = TRUE;
- break;
- case LOW:
- filter_int_set_value((FilterInt *)el, -1);
- action_added = TRUE;
- break;
- case NORMAL:
- filter_int_set_value((FilterInt *)el, 0);
- action_added = TRUE;
- break;
- case HIGH:
- filter_int_set_value((FilterInt *)el, 1);
- action_added = TRUE;
- break;
- case HIGHEST:
- filter_int_set_value((FilterInt *)el, 2);
- action_added = TRUE;
- break;
- default:
- g_object_unref((fp));
- }
- if (action_added) {
- *priority_needed = TRUE;
- filter_filter_add_action (ff, fp);
- }
- break;
- case DELETE:
- fp = filter_context_create_action (fc, "delete");
- filter_filter_add_action (ff, fp);
- action_added = TRUE;
- break;
- case MARK_READ:
- fp = filter_context_create_action (fc, "set-status");
- el = filter_part_find_element (fp, "flag");
- filter_option_set_current ((FilterOption *)el, "Seen");
- filter_filter_add_action (ff, fp);
- action_added = TRUE;
- break;
- case IGNORE_THREAD:
- case WATCH_THREAD:
- netscape_filter_threads_action_not_supported ();
- break;
- default:
- break;
- }
-
- if (!action_added) {
- g_object_unref((ff));
- return NULL;
- }
-
- return ff;
-}
-
-
-static void
-netscape_import_filters (NsImporter *importer)
-{
- FilterContext *fc;
- char *user, *system;
- FILE *mailrule_handle;
- char *ns_mailrule;
- NsFilter *nsf;
- FilterFilter *ff;
- gboolean priority_needed = FALSE;
-
- ns_mailrule = gnome_util_prepend_user_home (".netscape/mailrule");
- mailrule_handle = fopen (ns_mailrule, "r");
- g_free (ns_mailrule);
-
- if (mailrule_handle == NULL) {
- d(g_warning ("No .netscape/mailrule found."));
- user_prefs = NULL;
- return;
- }
-
- fc = filter_context_new ();
- user = g_concat_dir_and_file (g_get_home_dir (),
- "evolution/filters.xml");
- system = EVOLUTION_PRIVDATADIR "/filtertypes.xml";
-
- if (rule_context_load ((RuleContext *)fc, system, user) < 0) {
- g_warning ("Could not load rule context.");
- goto exit;
- }
-
- while ( (nsf = netscape_filter_read_next (mailrule_handle)) != NULL) {
-
- if ( (ff = netscape_filter_to_evol_filter (fc, nsf, &priority_needed)) != NULL)
- rule_context_add_rule (RULE_CONTEXT(fc), FILTER_RULE(ff));
- netscape_filter_cleanup (nsf);
- }
-
- if (priority_needed) {
- netscape_filter_change_priority_warning ();
- netscape_add_priority_workaround_filters (fc);
- }
-
- if (rule_context_save(RULE_CONTEXT(fc), user) < 0) {
- g_warning ("Could not save user's rule context.");
- }
-
- exit:
- g_free(user);
- g_object_unref((fc));
-
-}
-
-
-
-
-/* Email folder & accounts stuff ----------------------------------------------- */
-
-
-static GtkWidget *
-create_importer_gui (NsImporter *importer)
-{
- GtkWidget *dialog;
-
- dialog = gnome_message_box_new (_("Evolution is importing your old Netscape data"), GNOME_MESSAGE_BOX_INFO, NULL);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Importing..."));
-
- importer->label = gtk_label_new (_("Please wait"));
- importer->progressbar = gtk_progress_bar_new ();
- gtk_progress_set_activity_mode (GTK_PROGRESS (importer->progressbar), TRUE);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
- importer->label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
- importer->progressbar, FALSE, FALSE, 0);
-
- return dialog;
-}
-
-static void
-netscape_store_settings (NsImporter *importer)
-{
- GConfClient *gconf = gconf_client_get_default();
-
- gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/mail", importer->do_mail, NULL);
- gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/settings", importer->do_settings, NULL);
- gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/filters", importer->do_filters, NULL);
-}
-
-static void
-netscape_restore_settings (NsImporter *importer)
-{
- GConfClient *gconf = gconf_client_get_default();
-
- importer->do_mail = gconf_client_get_bool(gconf, "/apps/evolution/importer/netscape/mail", NULL);
- importer->do_settings = gconf_client_get_bool(gconf, "/apps/evolution/importer/netscape/settings", NULL);
- importer->do_filters = gconf_client_get_bool(gconf, "/apps/evolution/importer/netscape/filters", NULL);
-}
-
-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[MAXLEN];
-
- 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, MAXLEN, prefs_handle)) {
- char *key, *value;
-
- if (*line == 0) {
- continue;
- }
-
- if (*line == '/' && line[1] == '/') {
- continue;
- }
-
- key = netscape_get_key (line);
- value = netscape_get_value (line);
-
- if (key == NULL)
- continue;
-
- g_hash_table_insert (user_prefs, key, value);
- }
-
- return;
-}
-
-static char *
-get_user_fullname (void)
-{
- char *uname, *gecos, *special;
- struct passwd *pwd;
-
- uname = getenv ("USER");
- pwd = getpwnam (uname);
-
- if (strcmp (pwd->pw_gecos, "") == 0) {
- return g_strdup (uname);
- }
-
- special = strchr (pwd->pw_gecos, ',');
- if (special == NULL) {
- gecos = g_strdup (pwd->pw_gecos);
- } else {
- gecos = g_strndup (pwd->pw_gecos, special - pwd->pw_gecos);
- }
-
- special = strchr (gecos, '&');
- if (special == NULL) {
- return gecos;
- } else {
- char *capname, *expanded, *noamp;
-
- capname = g_strdup (uname);
- capname[0] = toupper ((int) capname[0]);
- noamp = g_strndup (gecos, special - gecos - 1);
- expanded = g_strconcat (noamp, capname, NULL);
-
- g_free (noamp);
- g_free (capname);
- g_free (gecos);
-
- return expanded;
- }
-}
-
-static void
-netscape_import_accounts (NsImporter *importer)
-{
- char *username;
- 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 = bonobo_activation_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");
- if (nstr != NULL) {
- username = g_strdup (nstr);
- } else {
- username = get_user_fullname ();
- }
-
- id.name = CORBA_string_dup (username);
- 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");
- /* FIXME rodo id.signature = CORBA_string_dup (nstr ? nstr : "");
- id.html_signature = CORBA_string_dup ("");
- id.has_html_signature = FALSE; */
-
- /* 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);
- } else {
- transport.url = CORBA_string_dup ("");
- transport.keep_on_server = FALSE;
- transport.auto_check = FALSE;
- transport.auto_check_time = 0;
- transport.save_passwd = FALSE;
- transport.enabled = FALSE;
- }
-
- /* Create account */
- account.name = CORBA_string_dup (username);
- account.id = id;
- account.transport = transport;
-
- account.drafts_folder_uri = 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;
- gboolean bool;
- 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);
- bool = netscape_get_boolean ("mail.leave_on_server");
- g_warning ("mail.leave_on_server: %s", bool ? "true" : "false");
- source.keep_on_server = netscape_get_boolean ("mail.leave_on_server");
- source.auto_check = TRUE;
- source.auto_check_time = 10;
- bool = netscape_get_boolean ("mail.remember_password");
- g_warning ("mail.remember_password: %s", bool ? "true" : "false");
- 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;
- } else {
- char *url, *path;
-
- /* Using Movemail */
- path = getenv ("MAIL");
- url = g_strconcat ("mbox://", path, NULL);
- source.url = CORBA_string_dup (url);
- g_free (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 = FALSE;
- }
- }
- account.source = source;
-
- 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 (username);
- CORBA_exception_free (&ev);
-}
-
-static gboolean
-is_dir_empty (const char *path)
-{
- DIR *base;
- struct stat buf;
- struct dirent *contents;
-
- base = opendir (path);
- if (base == NULL) {
- return TRUE; /* Can't open dir */
- }
-
- while ((contents = readdir(base)) != NULL) {
- char *fullpath;
-
- if (strcmp (contents->d_name, ".") == 0 ||
- strcmp (contents->d_name, "..") == 0) {
- continue;
- }
-
- fullpath = g_build_filename(path, contents->d_name, NULL);
- if (lstat (fullpath, &buf) == -1) {
- g_free(fullpath);
- continue;
- }
-
- if ((S_ISDIR (buf.st_mode) && !is_dir_empty (fullpath))
- || (S_ISREG(buf.st_mode) && buf.st_size != 0)) {
- g_free (fullpath);
- closedir (base);
- return FALSE;
- }
-
- g_free (fullpath);
- }
-
- closedir (base);
- return TRUE;
-}
-
-static gboolean
-netscape_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- if (user_prefs == NULL) {
- netscape_init_prefs ();
- }
-
- if (user_prefs == NULL) {
- d(g_warning ("No netscape dir"));
- return FALSE;
- }
-
- nsmail_dir = g_hash_table_lookup (user_prefs, "mail.directory");
- if (nsmail_dir == NULL) {
- return FALSE;
- } else {
- return !is_dir_empty (nsmail_dir);
- }
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- NsImporter *importer = (NsImporter *) data;
-
- importer->result = result;
- importer->more = more_items;
-}
-
-static gboolean
-netscape_import_file (NsImporter *importer,
- const char *path,
- const char *folderpath)
-{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
- char *str, *uri;
-
- /* Do import of mail folder */
- d(g_warning ("Importing %s as %s", path, folderpath));
-
- CORBA_exception_init (&ev);
-
- str = g_strdup_printf (_("Importing %s as %s"), path, folderpath);
- gtk_label_set_text (GTK_LABEL (importer->label), str);
- g_free (str);
- while (g_main_context_iteration(NULL, FALSE))
- ;
-
- uri = mail_importer_make_local_folder(folderpath);
- if (!uri)
- return FALSE;
-
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path, uri, "", &ev);
- g_free(uri);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s", CORBA_exception_id (&ev));
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- /* process all items in a direct loop */
- importer->listener = evolution_importer_listener_new (importer_cb, importer);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- do {
- importer->progress_count++;
- if ((importer->progress_count & 0xf) == 0)
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar));
-
- importer->result = -1;
- GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- break;
- }
-
- while (importer->result == -1 || g_main_context_pending(NULL))
- g_main_context_iteration(NULL, TRUE);
- } while (importer->more);
- bonobo_object_unref((BonoboObject *)importer->listener);
- CORBA_exception_free (&ev);
-
- return FALSE;
-}
-
-typedef struct {
- NsImporter *importer;
- char *parent;
- char *path;
- char *foldername;
-} NetscapeCreateDirectoryData;
-
-static void
-import_next (NsImporter *importer)
-{
- NetscapeCreateDirectoryData *data;
-
-trynext:
- if (importer->dir_list) {
- char *folder;
- GList *l;
- int ok;
-
- l = importer->dir_list;
- data = l->data;
-
- folder = g_build_filename(data->parent, data->foldername, NULL);
-
- importer->dir_list = l->next;
- g_list_free_1(l);
-
- ok = 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);
- if (!ok)
- goto trynext;
- } else {
- bonobo_object_unref((BonoboObject *)importer->ii);
- }
-}
-
-/* We don't allow any mail to be imported into a reservered Evolution folder name */
-static char *reserved_names[] = {
- N_("Trash"),
- N_("Calendar"),
- N_("Contacts"),
- N_("Tasks"),
- NULL
-};
-
-static char *
-fix_netscape_folder_names (const char *original_name)
-{
- int i;
-
- for (i = 0; reserved_names[i] != NULL; i++) {
- if (strcmp (original_name, _(reserved_names[i])) == 0) {
- return g_strdup_printf ("Netscape-%s",
- _(reserved_names[i]));
- }
- }
-
- 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 (NsImporter *importer,
- const char *orig_parent,
- const char *dirname)
-{
- DIR *nsmail;
- struct stat buf;
- struct dirent *current;
- char *str;
-
- nsmail = opendir (dirname);
- if (nsmail == NULL) {
- d(g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno)));
- return;
- }
-
- str = g_strdup_printf (_("Scanning %s"), dirname);
- gtk_label_set_text (GTK_LABEL (importer->label), str);
- g_free (str);
-
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
-
- 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 = fix_netscape_folder_names (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)
-{
- NsImporter *importer = closure;
- GConfClient *gconf = gconf_client_get_default();
-
- 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);
-
- /* Create a dialog if we're going to be active */
- /* Importing mail filters is not a criterion because it makes
- little sense to import the filters but not the mail folders. */
- if (importer->do_settings == TRUE ||
- importer->do_mail == TRUE) {
- importer->dialog = create_importer_gui (importer);
- gtk_widget_show_all (importer->dialog);
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
- }
-
- if (importer->do_settings == TRUE) {
- gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/settings-imported", TRUE, NULL);
- netscape_import_accounts (importer);
- }
-
- if (importer->do_mail == TRUE) {
-
- /* Import the mail filters if needed ... */
- if (importer->do_filters == TRUE) {
- gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/filters-imported", TRUE, NULL);
- gtk_label_set_text (GTK_LABEL (importer->label),
- _("Scanning mail filters"));
-
- netscape_import_filters (importer);
- }
-
- gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/mail-imported", TRUE, NULL);
-
- /* Scan the nsmail folder and find out what folders
- need to be imported */
-
- gtk_label_set_text (GTK_LABEL (importer->label),
- _("Scanning directory"));
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
-
- scan_dir (importer, "/", nsmail_dir);
-
- /* Import them */
- gtk_label_set_text (GTK_LABEL (importer->label),
- _("Starting import"));
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
- import_next (importer);
- }
-
- 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));
- }
-
- bonobo_object_unref (BONOBO_OBJECT (ii));
-}
-
-static void
-netscape_destroy_cb (NsImporter *importer, GObject *object)
-{
- netscape_store_settings (importer);
-
- if (importer->importer != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (importer->importer, NULL);
- }
-
- if (importer->dialog)
- gtk_widget_destroy(importer->dialog);
-
- g_free(importer);
-}
-
-/* Fun initialisation stuff */
-
-/* Fun with aggregation */
-static void
-checkbox_toggle_cb (GtkToggleButton *tb,
- NsImporter *importer)
-{
- /* Some extra logic here to make the filters choice
- depending on the mail choice */
- if (GTK_WIDGET(tb) == importer->mail) {
- importer->do_mail = gtk_toggle_button_get_active (tb);
-
- if (importer->do_mail == FALSE) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(importer->filters), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(importer->filters), FALSE);
- importer->do_filters = FALSE;
- } else {
- gtk_widget_set_sensitive(GTK_WIDGET(importer->filters), TRUE);
- }
-
- } else if (GTK_WIDGET(tb) == importer->settings) {
- importer->do_settings = gtk_toggle_button_get_active (tb);
-
- } else if (GTK_WIDGET(tb) == importer->filters) {
- importer->do_filters = gtk_toggle_button_get_active (tb);
-
- }
- /* *do_item = gtk_toggle_button_get_active (tb); */
-}
-
-static BonoboControl *
-create_checkboxes_control (NsImporter *importer)
-{
- GtkWidget *hbox;
- BonoboControl *control;
-
- hbox = gtk_hbox_new (FALSE, 2);
-
- importer->mail = gtk_check_button_new_with_label (_("Mail"));
- g_signal_connect((importer->mail), "toggled",
- G_CALLBACK (checkbox_toggle_cb),
- importer);
-
- importer->settings = gtk_check_button_new_with_label (_("Settings"));
- g_signal_connect((importer->settings), "toggled",
- G_CALLBACK (checkbox_toggle_cb),
- importer);
-
- importer->filters = gtk_check_button_new_with_label (_("Mail Filters"));
- gtk_widget_set_sensitive(GTK_WIDGET(importer->filters), FALSE);
- g_signal_connect((importer->filters), "toggled",
- G_CALLBACK (checkbox_toggle_cb),
- importer);
-
- gtk_box_pack_start (GTK_BOX (hbox), importer->mail, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), importer->settings, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), importer->filters, FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
- control = bonobo_control_new (hbox);
- return control;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- const char *iid,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- BonoboControl *control;
- NsImporter *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 (NsImporter, 1);
-
- CORBA_exception_init (&ev);
-
- netscape_restore_settings (netscape);
-
- netscape->importer = bonobo_activation_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",
- _(message), netscape);
- g_object_weak_ref(G_OBJECT (importer), (GWeakNotify)netscape_destroy_cb, netscape);
- netscape->ii = importer;
-
- control = create_checkboxes_control (netscape);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
- return BONOBO_OBJECT (importer);
-}
-
-void
-mail_importer_module_init (void)
-{
- BonoboGenericFactory *factory;
- static int init = FALSE;
-
- if (init)
- return;
-
- factory = bonobo_generic_factory_new (FACTORY_IID, factory_fn, NULL);
- if (factory == NULL)
- g_warning("Could not initialise Netscape intelligent mail importer");
- init = 1;
-}
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
deleted file mode 100644
index 89cfcc2fdc..0000000000
--- a/mail/importers/pine-importer.c
+++ /dev/null
@@ -1,643 +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. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <libgnomeui/gnome-messagebox.h>
-#include <gtk/gtk.h>
-
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.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 <bonobo/bonobo-exception.h>
-#include <bonobo/bonobo-moniker-util.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/evolution-importer-client.h>
-#include <importer/GNOME_Evolution_Importer.h>
-
-#include "mail/mail-importer.h"
-
-#include <ebook/e-book.h>
-#include <ebook/e-card-simple.h>
-
-#define PINE_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer_Factory:" BASE_VERSION
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer:" BASE_VERSION
-#define KEY "pine-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- EvolutionIntelligentImporter *ii;
-
- GList *dir_list;
-
- int progress_count;
- int more;
- EvolutionImporterResult result;
-
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
-
- GtkWidget *mail;
- gboolean do_mail;
- GtkWidget *address;
- gboolean do_address;
-
- EBook *book;
-
- /* GUI */
- GtkWidget *dialog;
- GtkWidget *label;
- GtkWidget *progressbar;
-} PineImporter;
-
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
- gboolean folder;
-} PineFolder;
-
-void mail_importer_module_init (void);
-
-static void import_next (PineImporter *importer);
-
-static GtkWidget *
-create_importer_gui (PineImporter *importer)
-{
- GtkWidget *dialog;
-
- dialog = gnome_message_box_new (_("Evolution is importing your old Pine data"), GNOME_MESSAGE_BOX_INFO, NULL);
- gtk_window_set_title (GTK_WINDOW (dialog), _("Importing..."));
-
- importer->label = gtk_label_new (_("Please wait"));
- importer->progressbar = gtk_progress_bar_new ();
- gtk_progress_set_activity_mode (GTK_PROGRESS (importer->progressbar), TRUE);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
- importer->label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox),
- importer->progressbar, FALSE, FALSE, 0);
- return dialog;
-}
-
-static void
-pine_store_settings (PineImporter *importer)
-{
- GConfClient *gconf = gconf_client_get_default ();
-
- gconf_client_set_bool (gconf, "/apps/evolution/importer/pine/mail", importer->do_mail, NULL);
- gconf_client_set_bool (gconf, "/apps/evolution/importer/pine/address", importer->do_address, NULL);
-}
-
-static void
-pine_restore_settings (PineImporter *importer)
-{
- GConfClient *gconf = gconf_client_get_default ();
-
- importer->do_mail = gconf_client_get_bool (gconf, "/apps/evolution/importer/pine/mail", NULL);
- importer->do_address = gconf_client_get_bool (gconf, "/apps/evolution/importer/pine/address", NULL);
-}
-
-static void
-add_card_cb (EBook *book,
- EBookStatus status,
- const char *id,
- gpointer closure)
-{
- g_object_unref (closure);
-}
-
-static void
-parse_line (EBook *book,
- char *line)
-{
- char **strings;
- ECardName *name;
- ECard *card;
- EList *list;
-
- card = e_card_new ("");
- strings = g_strsplit (line, "\t", 3);
- if (strings[0] && strings[1] && strings[2]) {
- name = e_card_name_from_string (strings[1]);
- g_object_set (card,
- "nickname", strings[0],
- "full_name", strings[1],
- "name", name, NULL);
- g_object_get (card,
- "email", &list,
- NULL);
- e_list_append (list, strings[2]);
- g_strfreev (strings);
- e_book_add_card (book, card, add_card_cb, card);
- }
-}
-
-static void
-import_addressfile (EBook *book,
- EBookStatus status,
- gpointer user_data)
-{
- char *addressbook;
- FILE *handle;
- char line[2 * 1024];
- int which = 0;
- char *lastline = NULL;
- PineImporter *importer = user_data;
-
- addressbook = g_build_filename(g_get_home_dir(), ".addressbook", NULL);
- handle = fopen (addressbook, "r");
- g_free (addressbook);
-
- if (handle == NULL) {
- g_warning ("Cannot open .addressbook");
- return;
- }
-
- while (fgets (line + which * 1024, 1024, handle)) {
- int length;
- char *thisline = line + which * 1024;
-
- importer->progress_count++;
- if ((importer->progress_count & 0xf) == 0)
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar));
-
- length = strlen (thisline);
- if (thisline[length - 1] == '\n') {
- line[--length] = 0;
- }
-
- if (lastline && *thisline && isspace ((int) *thisline)) {
- char *temp;
-
- while (*thisline && isspace ((int) *thisline)) {
- thisline++;
- }
- temp = lastline;
- lastline = g_strdup_printf ("%s%s", lastline, thisline);
- g_free (temp);
- continue;
- }
-
- if (lastline) {
- parse_line (book, lastline);
- g_free (lastline);
- }
-
- lastline = g_strdup (thisline);
- }
-
- if (lastline) {
- parse_line (book, lastline);
- g_free (lastline);
- }
-
- 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_build_filename(g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db", NULL);
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
-
- e_book_load_uri (importer->book, uri, import_addressfile, importer);
- g_free (uri);
-}
-
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- PineImporter *importer = (PineImporter *) data;
-
- importer->result = result;
- importer->more = more_items;
-}
-
-static gboolean
-pine_import_file (PineImporter *importer,
- const char *path,
- const char *folderpath,
- gboolean folder)
-{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
- char *str, *uri;
- struct stat st;
-
- CORBA_exception_init (&ev);
-
- str = g_strdup_printf (_("Importing %s as %s"), path, folderpath);
- gtk_label_set_text (GTK_LABEL (importer->label), str);
- g_free (str);
- while (g_main_context_iteration(NULL, FALSE))
- ;
-
- uri = mail_importer_make_local_folder(folderpath);
- if (!uri)
- return FALSE;
-
- /* only create dirs, dont try to import them */
- if (lstat(path, &st) == 0 && S_ISDIR(st.st_mode)) {
- g_free(uri);
- /* this is ok, we return false to say we haven't launched an async task */
- return FALSE;
- }
-
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path, uri, "", &ev);
- g_free(uri);
- if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
- g_warning ("Exception here: %s\n%s, %s", CORBA_exception_id (&ev), path, folderpath);
- CORBA_exception_free (&ev);
- return FALSE;
- }
-
- /* process all items in a direct loop */
- importer->listener = evolution_importer_listener_new (importer_cb, importer);
- objref = bonobo_object_corba_objref (BONOBO_OBJECT (importer->listener));
- do {
- importer->progress_count++;
- if ((importer->progress_count & 0xf) == 0)
- gtk_progress_bar_pulse(GTK_PROGRESS_BAR(importer->progressbar));
-
- importer->result = -1;
- GNOME_Evolution_Importer_processItem (importer->importer, objref, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_warning ("Exception: %s", CORBA_exception_id (&ev));
- break;
- }
-
- while (importer->result == -1 || g_main_context_pending(NULL))
- g_main_context_iteration(NULL, TRUE);
- } while (importer->more);
- bonobo_object_unref((BonoboObject *)importer->listener);
-
- CORBA_exception_free (&ev);
-
- return FALSE;
-}
-
-static gboolean
-pine_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- PineImporter *importer = closure;
- char *maildir, *addrfile;
- gboolean md_exists = FALSE, addr_exists = FALSE;
- struct stat st;
-
- maildir = g_build_filename(g_get_home_dir(), "mail", NULL);
- md_exists = lstat(maildir, &st) == 0 && S_ISDIR(st.st_mode);
- importer->do_mail = md_exists;
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail),
- importer->do_mail);
-
- gtk_widget_set_sensitive (importer->mail, md_exists);
- g_free (maildir);
-
- addrfile = g_build_filename(g_get_home_dir(), ".addressbook", NULL);
- addr_exists = lstat(addrfile, &st) == 0 && S_ISREG(st.st_mode);
- g_free (addrfile);
- gtk_widget_set_sensitive (importer->address, addr_exists);
-
- return md_exists || addr_exists;
-}
-
-static void
-import_next (PineImporter *importer)
-{
- PineFolder *data;
-
-trynext:
- if (importer->dir_list) {
- char *folder;
- GList *l;
- int ok;
-
- l = importer->dir_list;
- data = l->data;
- folder = g_build_filename(data->parent, data->foldername, NULL);
- importer->dir_list = l->next;
- g_list_free_1(l);
-
- ok = pine_import_file (importer, data->path, folder, data->folder);
-
- g_free (folder);
- g_free (data->parent);
- g_free (data->path);
- g_free (data->foldername);
- g_free (data);
- if (!ok)
- goto trynext;
- } else {
- bonobo_object_unref((BonoboObject *)importer->ii);
- }
-}
-
-/* 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;
- char *str;
-
- maildir = opendir (dirname);
- if (maildir == NULL) {
- g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno));
- return;
- }
-
- str = g_strdup_printf (_("Scanning %s"), dirname);
- gtk_label_set_text (GTK_LABEL (importer->label), str);
- g_free (str);
-
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
-
- 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_build_filename(dirname, current->d_name, NULL);
- 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);
- pf->folder = FALSE;
- 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 = g_strdup (fullname);
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (foldername);
- pf->folder = TRUE;
- importer->dir_list = g_list_append (importer->dir_list, pf);
-
- subdir = g_build_filename (orig_parent, foldername, NULL);
- 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;
- GConfClient *gconf = gconf_client_get_default ();
-
- bonobo_object_ref (BONOBO_OBJECT (ii));
- pine_store_settings (importer);
-
- /* Create a dialog */
- if (importer->do_address == TRUE ||
- importer->do_mail == TRUE) {
- importer->dialog = create_importer_gui (importer);
- gtk_widget_show_all (importer->dialog);
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
- }
-
- if (importer->do_address == TRUE) {
- gconf_client_set_bool(gconf, "/apps/evolution/importer/pine/address-imported", TRUE, NULL);
- import_addressbook (importer);
- }
-
- if (importer->do_mail == TRUE) {
- gconf_client_set_bool(gconf, "/apps/evolution/importer/pine/mail-imported", TRUE, NULL);
- maildir = g_build_filename(g_get_home_dir(), "mail", NULL);
- gtk_label_set_text (GTK_LABEL (importer->label),
- _("Scanning directory"));
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
-
- scan_dir (importer, maildir, "/");
- g_free (maildir);
-
- /* Import them */
- import_next (importer);
- }
-
- 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 */
- bonobo_object_unref (BONOBO_OBJECT (ii));
- }
- bonobo_object_unref (BONOBO_OBJECT (ii));
-}
-
-static void
-pine_destroy_cb (PineImporter *importer, GtkObject *object)
-{
- pine_store_settings (importer);
-
- if (importer->dialog)
- gtk_widget_destroy(importer->dialog);
-
- if (importer->importer != CORBA_OBJECT_NIL) {
- bonobo_object_release_unref (importer->importer, NULL);
- }
-}
-
-/* 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 *hbox;
- BonoboControl *control;
-
- hbox = gtk_hbox_new (FALSE, 2);
-
- 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->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);
-
- gtk_box_pack_start (GTK_BOX (hbox), importer->mail, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), importer->address, FALSE, FALSE, 0);
-
- gtk_widget_show_all (hbox);
- control = bonobo_control_new (hbox);
- return control;
-}
-
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- const char *iid,
- 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);
-
- CORBA_exception_init (&ev);
- pine_restore_settings (pine);
-
- pine->importer = bonobo_activation_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"),
- _(message), pine);
- g_object_weak_ref((GObject *)importer, (GWeakNotify)pine_destroy_cb, pine);
- pine->ii = importer;
-
- control = create_checkboxes_control (pine);
- bonobo_object_add_interface (BONOBO_OBJECT (importer),
- BONOBO_OBJECT (control));
- return BONOBO_OBJECT (importer);
-}
-
-void
-mail_importer_module_init (void)
-{
- BonoboGenericFactory *factory;
- static int init = FALSE;
-
- if (init)
- return;
-
- factory = bonobo_generic_factory_new (PINE_INTELLIGENT_IMPORTER_IID,
- factory_fn, NULL);
- if (factory == NULL)
- g_warning ("Could not initialise Pine Intelligent Mail Importer.");
- init = TRUE;
-}