aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-02-11 16:26:58 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-02-11 16:26:58 +0800
commit06b08adb257351bf8080d960fb98b4265cc43081 (patch)
tree9f429f497d47c5b933d2c4c98a1058566233a7dc /mail
parent136b8ea938580f3c1d4fb9f92093c4631ec6038b (diff)
downloadgsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.tar
gsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.tar.gz
gsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.tar.bz2
gsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.tar.lz
gsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.tar.xz
gsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.tar.zst
gsoc2013-evolution-06b08adb257351bf8080d960fb98b4265cc43081.zip
Basically rewrote this, the import tasks run in another thread. It tells
2004-02-11 Not Zed <NotZed@Ximian.com> * importers/pine-importer.c: Basically rewrote this, the import tasks run in another thread. It tells you more about what's going on, and its cancellable. (pine_store_settings): changed the meaning of the settings slightly, if set it means we've processed them already. * mail-component-factory.c (factory): hook in importer factory callback. 2004-02-10 Not Zed <NotZed@Ximian.com> * importers/*-importer.c: removed module init, just provide a new method. Updates for api changes. * Makefile.am: link mail importers in directly. * mail-importer.c: changed to do stuff in-memory with linked stuff, moved to importers/. * importers/GNOME_Evolution_Mail_Importers.server.in.in: merge all importer .server info's here, point them all to the mailer factory. Removed the others. * importers/Makefile.am: remove Mailer.idl stuff. Move all importers to a single library. svn path=/trunk/; revision=24701
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog28
-rw-r--r--mail/Makefile.am12
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.server.in.in26
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Importers.server.in.in66
-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.am88
-rw-r--r--mail/importers/elm-importer.c32
-rw-r--r--mail/importers/evolution-mbox-importer.c50
-rw-r--r--mail/importers/evolution-outlook-importer.c47
-rw-r--r--mail/importers/mail-importer.c390
-rw-r--r--mail/importers/mail-importer.h88
-rw-r--r--mail/importers/netscape-importer.c42
-rw-r--r--mail/importers/pine-importer.c659
-rw-r--r--mail/mail-component-factory.c18
-rw-r--r--mail/mail-component.c3
-rw-r--r--mail/mail-component.h18
-rw-r--r--mail/mail-importer.c288
-rw-r--r--mail/mail-importer.h53
21 files changed, 903 insertions, 1115 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 7924b6c630..96357f39da 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,31 @@
+2004-02-11 Not Zed <NotZed@Ximian.com>
+
+ * importers/pine-importer.c: Basically rewrote this, the import
+ tasks run in another thread. It tells you more about what's going
+ on, and its cancellable.
+ (pine_store_settings): changed the meaning of the settings
+ slightly, if set it means we've processed them already.
+
+ * mail-component-factory.c (factory): hook in importer factory
+ callback.
+
+2004-02-10 Not Zed <NotZed@Ximian.com>
+
+ * importers/*-importer.c: removed module init, just provide a new
+ method. Updates for api changes.
+
+ * Makefile.am: link mail importers in directly.
+
+ * mail-importer.c: changed to do stuff in-memory with linked
+ stuff, moved to importers/.
+
+ * importers/GNOME_Evolution_Mail_Importers.server.in.in: merge all
+ importer .server info's here, point them all to the mailer
+ factory. Removed the others.
+
+ * importers/Makefile.am: remove Mailer.idl stuff. Move all
+ importers to a single library.
+
2004-02-09 Not Zed <NotZed@Ximian.com>
* em-folder-tree.c (tree_drag_data_delete): merged in code from
diff --git a/mail/Makefile.am b/mail/Makefile.am
index 97a9b33498..4dd75db8d8 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -1,6 +1,4 @@
-SUBDIRS = default # importers FIXME
-
-importerdir = $(privlibdir)/evolution-mail-importers
+SUBDIRS = default importers
INCLUDES = \
-I$(top_srcdir)/widgets \
@@ -29,7 +27,6 @@ INCLUDES = \
-DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
-DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \
-DCAMEL_PROVIDERDIR=\""$(camel_providerdir)"\" \
- -DMAIL_IMPORTERSDIR=\""$(importerdir)"\" \
-DPREFIX=\""$(prefix)"\" \
-DG_LOG_DOMAIN=\"evolution-mail\"
@@ -163,13 +160,9 @@ libevolution_mail_la_SOURCES = \
message-tag-followup.h \
mail.h
-# EPFIXME: Functionality to be brought back to life.
-#
-# mail-local.c
-# mail-local.h
-
libevolution_mail_la_LIBADD = \
$(top_builddir)/shell/importer/libevolution-importer.la \
+ $(top_builddir)/mail/importers/libevolution-mail-importers.la\
$(top_builddir)/camel/libcamel.la \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/shell/libeshell.la \
@@ -183,7 +176,6 @@ libevolution_mail_la_LIBADD = \
libevolution_mail_la_LDFLAGS = \
-avoid-version -module
-
# .server files
server_in_files = GNOME_Evolution_Mail.server.in.in
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_Importers.server.in.in b/mail/importers/GNOME_Evolution_Mail_Importers.server.in.in
new file mode 100644
index 0000000000..e3c5f91e6b
--- /dev/null
+++ b/mail/importers/GNOME_Evolution_Mail_Importers.server.in.in
@@ -0,0 +1,66 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer:@VERSION@"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Mail_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_server iid="OAFIID:GNOME_Evolution_Mail_Mbox_Importer:@VERSION@"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Mail_Factory:@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_server iid="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer:@VERSION@"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Mail_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_server iid="OAFIID:GNOME_Evolution_Mail_Outlook_Importer:@VERSION@"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Mail_Factory:@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_server iid="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer:@VERSION@"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_Mail_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/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
index 2e2f8881f2..e713241f59 100644
--- a/mail/importers/Makefile.am
+++ b/mail/importers/Makefile.am
@@ -1,9 +1,5 @@
-importersdir = $(privlibdir)/evolution-mail-importers
-importers_LTLIBRARIES = liboutlook.la libmbox.la \
- libevolution-elm-importer.la \
- libevolution-pine-importer.la \
- libevolution-netscape-importer.la
+privlib_LTLIBRARIES = libevolution-mail-importers.la
INCLUDES = -I.. \
-I$(srcdir)/.. \
@@ -16,84 +12,30 @@ INCLUDES = -I.. \
-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 \
+libevolution_mail_importers_la_SOURCES = \
+ mail-importer.c \
+ mail-importer.h \
+ elm-importer.c \
+ pine-importer.c \
+ netscape-importer.c \
+ evolution-outlook-importer.c \
+ evolution-mbox-importer.c
+
+libevolution_mail_importers_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_in_files = \
+ GNOME_Evolution_Mail_Importers.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)
+BUILT_SOURCES = $(server_DATA)
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(server_in_files)
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
index 1386e3a26f..63f282fd48 100644
--- a/mail/importers/elm-importer.c
+++ b/mail/importers/elm-importer.c
@@ -52,10 +52,8 @@
#include <importer/evolution-importer-client.h>
#include <importer/GNOME_Evolution_Importer.h>
-#include "mail/mail-importer.h"
+#include "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*/
@@ -93,8 +91,6 @@ typedef struct {
static GHashTable *elm_prefs = NULL;
-void mail_importer_module_init (void);
-
static void import_next (ElmImporter *importer);
static GtkWidget *
@@ -121,6 +117,7 @@ elm_store_settings (ElmImporter *importer)
gconf = gconf_client_get_default ();
gconf_client_set_bool (gconf, "/apps/evolution/importer/elm/mail", importer->do_mail, NULL);
+ g_object_unref(gconf);
}
static void
@@ -172,8 +169,9 @@ elm_import_file (ElmImporter *importer,
}
CORBA_exception_init(&ev);
+#warning "loadFile needs a destination path"
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path, uri, "", &ev);
+ result = GNOME_Evolution_Importer_loadFile (importer->importer, path, &ev);
g_free(uri);
if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
g_warning ("Exception here: %s", CORBA_exception_id (&ev));
@@ -535,10 +533,8 @@ create_checkboxes_control (ElmImporter *importer)
return control;
}
-static BonoboObject *
-elm_factory_fn (BonoboGenericFactory *_factory,
- const char *id,
- void *closure)
+BonoboObject *
+elm_intelligent_importer_new(void)
{
EvolutionIntelligentImporter *importer;
BonoboControl *control;
@@ -575,19 +571,3 @@ elm_factory_fn (BonoboGenericFactory *_factory,
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
index 83323703af..a7691b38f0 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -39,13 +39,13 @@
#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 "mail/mail-tools.h"
+#include "mail/mail-component.h"
#include "e-util/e-path.h"
+#include "mail-importer.h"
+
/* #define IMPORTER_DEBUG */
#ifdef IMPORTER_DEBUG
#define IN g_print ("=====> %s (%d)\n", G_GNUC_FUNCTION, __LINE__)
@@ -55,24 +55,18 @@
#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)
@@ -240,14 +234,13 @@ importer_destroy_cb (void *data, GObject *object)
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;
+ char *uri;
mbi = (MboxImporter *) closure;
importer = (MailImporter *) mbi;
@@ -274,8 +267,10 @@ load_file_fn (EvolutionImporter *eimporter,
}
importer->mstream = NULL;
+#warning "No destination uri"
+ uri = NULL;
if (uri == NULL || *uri == '\0')
- importer->folder = mail_tool_get_local_inbox (NULL);
+ importer->folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_INBOX);
else
importer->folder = mail_tool_uri_to_folder(uri, 0, NULL);
@@ -298,38 +293,15 @@ load_file_fn (EvolutionImporter *eimporter,
return FALSE;
}
-static BonoboObject *
-mbox_factory_fn (BonoboGenericFactory *_factory,
- const char *cid,
- void *closure)
+BonoboObject *
+mbox_importer_new(void)
{
EvolutionImporter *importer;
MboxImporter *mbox;
mbox = g_new0 (MboxImporter, 1);
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, mbox);
+ importer = evolution_importer_new(NULL, 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
index 62d99bb149..8233c82ca5 100644
--- a/mail/importers/evolution-outlook-importer.c
+++ b/mail/importers/evolution-outlook-importer.c
@@ -36,12 +36,10 @@
#include <camel/camel-exception.h>
#include "e-util/e-memory.h"
+#include "mail/mail-tools.h"
+#include "mail/mail-component.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 {
@@ -66,10 +64,6 @@ struct oe_msg_segmentheader {
typedef struct oe_msg_segmentheader oe_msg_segmentheader;
-/* Prototype */
-
-void mail_importer_module_init (void);
-
/* EvolutionImporter methods */
@@ -224,14 +218,13 @@ importer_destroy_cb (void *data, GObject *object)
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;
+ char *uri;
oli = (OutlookImporter *) closure;
importer = (MailImporter *) oli;
@@ -264,8 +257,10 @@ load_file_fn (EvolutionImporter *eimporter,
importer->mstream = NULL;
+#warning "no uri for load file fn"
+ uri = NULL;
if (uri == NULL || *uri == 0)
- importer->folder = mail_tool_get_local_inbox (NULL);
+ importer->folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_INBOX);
else
importer->folder = mail_tool_uri_to_folder (uri, 0, NULL);
@@ -279,40 +274,16 @@ load_file_fn (EvolutionImporter *eimporter,
return TRUE;
}
-static BonoboObject *
-outlook_factory_fn (BonoboGenericFactory *_factory,
- const char *cid,
- void *closure)
+BonoboObject *
+outlook_importer_new(void)
{
EvolutionImporter *importer;
OutlookImporter *oli;
oli = g_new0 (OutlookImporter, 1);
- importer = evolution_importer_new (support_format_fn, load_file_fn,
- process_item_fn, NULL, oli);
+ importer = evolution_importer_new (NULL, 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/mail-importer.c b/mail/importers/mail-importer.c
new file mode 100644
index 0000000000..1aab7ac2c8
--- /dev/null
+++ b/mail/importers/mail-importer.c
@@ -0,0 +1,390 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* mail-importer.c
+ *
+ * Authors: Iain Holmes <iain@ximian.com>
+ * Michael Zucchi <notzed@ximian.com>
+ *
+ * Copyright (C) 2001-2003 Ximian, Inc.
+ * Copyright (C) 2004 Novell 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 <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <gmodule.h>
+#include <libgnome/gnome-util.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-store.h>
+#include <camel/camel-mime-message.h>
+#include <camel/camel-mime-parser.h>
+#include <camel/camel-exception.h>
+#include <e-util/e-path.h>
+
+#include "mail/mail-mt.h"
+#include "mail/mail-component.h"
+#include "mail/mail-tools.h"
+
+#include "mail-importer.h"
+
+/**
+ * mail_importer_make_local_folder:
+ * @folderpath:
+ *
+ * Check a local folder exists at path @folderpath, and if not, create it.
+ *
+ * Return value: The physical uri of the folder, or NULL if the folder did
+ * not exist and could not be created.
+ **/
+char *
+mail_importer_make_local_folder(const char *folderpath)
+{
+ return g_strdup_printf("mbox:/home/notzed/.evolution/mail/local/%s", folderpath);
+}
+
+/**
+ * mail_importer_add_line:
+ * importer: A MailImporter structure.
+ * str: Next line of the mbox.
+ * finished: TRUE if @str is the last line of the message.
+ *
+ * Adds lines to the message until it is finished, and then adds
+ * the complete message to the folder.
+ */
+void
+mail_importer_add_line (MailImporter *importer,
+ const char *str,
+ gboolean finished)
+{
+ CamelMimeMessage *msg;
+ CamelMessageInfo *info;
+ CamelException *ex;
+
+ if (importer->mstream == NULL)
+ importer->mstream = CAMEL_STREAM_MEM (camel_stream_mem_new ());
+
+ camel_stream_write (CAMEL_STREAM (importer->mstream), str, strlen (str));
+
+ if (finished == FALSE)
+ return;
+
+ camel_stream_reset (CAMEL_STREAM (importer->mstream));
+ info = g_new0 (CamelMessageInfo, 1);
+ info->flags = CAMEL_MESSAGE_SEEN;
+
+ msg = camel_mime_message_new ();
+ camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg),
+ CAMEL_STREAM (importer->mstream));
+
+ camel_object_unref (importer->mstream);
+ importer->mstream = NULL;
+
+ ex = camel_exception_new ();
+ camel_folder_append_message (importer->folder, msg, info, NULL, ex);
+ camel_object_unref (msg);
+
+ camel_exception_free (ex);
+ g_free (info);
+}
+
+struct _BonoboObject *mail_importer_factory_cb(struct _BonoboGenericFactory *factory, const char *iid, void *data)
+{
+ if (strcmp(iid, ELM_INTELLIGENT_IMPORTER_IID) == 0)
+ return elm_intelligent_importer_new();
+ else if (strcmp(iid, PINE_INTELLIGENT_IMPORTER_IID) == 0)
+ return pine_intelligent_importer_new();
+ else if (strcmp(iid, NETSCAPE_INTELLIGENT_IMPORTER_IID) == 0)
+ return netscape_intelligent_importer_new();
+ else if (strcmp(iid, MBOX_IMPORTER_IID) == 0)
+ return mbox_importer_new();
+ else if (strcmp(iid, OUTLOOK_IMPORTER_IID) == 0)
+ return outlook_importer_new();
+
+ return NULL;
+}
+
+struct _import_mbox_msg {
+ struct _mail_msg msg;
+
+ char *path;
+ char *uri;
+ CamelOperation *cancel;
+};
+
+static char *
+import_mbox_describe(struct _mail_msg *mm, int complete)
+{
+ return g_strdup (_("Importing mailbox"));
+}
+
+static struct {
+ char tag;
+ guint32 mozflag;
+ guint32 flag;
+} status_flags[] = {
+ { 'F', MSG_FLAG_MARKED, CAMEL_MESSAGE_FLAGGED },
+ { 'A', MSG_FLAG_REPLIED, CAMEL_MESSAGE_ANSWERED },
+ { 'D', MSG_FLAG_EXPUNGED, CAMEL_MESSAGE_DELETED },
+ { 'R', MSG_FLAG_READ, CAMEL_MESSAGE_SEEN },
+};
+
+static guint32
+decode_status(const char *status)
+{
+ const char *p;
+ char c;
+ guint32 flags = 0;
+ int i;
+
+ p = status;
+ while ((c = *p++)) {
+ for (i=0;i<sizeof(status_flags)/sizeof(status_flags[0]);i++)
+ if (status_flags[i].tag == *p)
+ flags |= status_flags[i].flag;
+ }
+
+ return flags;
+}
+
+static guint32
+decode_mozilla_status(const char *tmp)
+{
+ unsigned long status = strtoul(tmp, NULL, 16);
+ guint32 flags = 0;
+ int i;
+
+ for (i=0;i<sizeof(status_flags)/sizeof(status_flags[0]);i++)
+ if (status_flags[i].mozflag & status)
+ flags |= status_flags[i].flag;
+ return flags;
+}
+
+static void
+import_mbox_import(struct _mail_msg *mm)
+{
+ struct _import_mbox_msg *m = (struct _import_mbox_msg *) mm;
+ CamelFolder *folder;
+ CamelMimeParser *mp = NULL;
+ struct stat st;
+ int fd;
+ CamelMessageInfo *info;
+
+ if (stat(m->path, &st) == -1) {
+ g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
+ return;
+ }
+
+ if (m->uri == NULL || m->uri[0] == 0)
+ folder = mail_component_get_folder(NULL, MAIL_COMPONENT_FOLDER_INBOX);
+ else
+ folder = mail_tool_uri_to_folder(m->uri, CAMEL_STORE_FOLDER_CREATE, &mm->ex);
+
+ if (folder == NULL)
+ return;
+
+ if (S_ISREG(st.st_mode)) {
+ fd = open(m->path, O_RDONLY);
+ if (fd == -1) {
+ g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
+ goto fail1;
+ }
+
+ mp = camel_mime_parser_new();
+ camel_mime_parser_scan_from(mp, TRUE);
+ if (camel_mime_parser_init_with_fd(mp, fd) == -1) {
+ goto fail2;
+ }
+
+ if (m->cancel)
+ camel_operation_register(m->cancel);
+
+ camel_operation_start(NULL, _("Importing `%s'"), folder->full_name);
+ camel_folder_freeze(folder);
+ while (camel_mime_parser_step(mp, 0, 0) == CAMEL_MIME_PARSER_STATE_FROM) {
+ CamelMimeMessage *msg;
+ const char *tmp;
+ int pc;
+
+ if (st.st_size > 0)
+ pc = (int)(100.0 * ((double)camel_mime_parser_tell(mp) / (double)st.st_size));
+ camel_operation_progress(NULL, pc);
+
+ msg = camel_mime_message_new();
+ if (camel_mime_part_construct_from_parser((CamelMimePart *)msg, mp) == -1) {
+ /* set exception? */
+ camel_object_unref(msg);
+ break;
+ }
+
+ info = camel_message_info_new();
+
+ tmp = camel_medium_get_header((CamelMedium *)msg, "X-Mozilla-Status");
+ if (tmp)
+ info->flags |= decode_mozilla_status(tmp);
+ tmp = camel_medium_get_header((CamelMedium *)msg, "Status");
+ if (tmp)
+ info->flags |= decode_status(tmp);
+ tmp = camel_medium_get_header((CamelMedium *)msg, "X-Status");
+ if (tmp)
+ info->flags |= decode_status(tmp);
+
+ camel_folder_append_message(folder, msg, info, NULL, &mm->ex);
+ camel_message_info_free(info);
+ camel_object_unref(msg);
+
+ if (camel_exception_is_set(&mm->ex))
+ break;
+
+ camel_mime_parser_step(mp, 0, 0);
+ }
+ camel_folder_sync(folder, FALSE, &mm->ex);
+ camel_folder_thaw(folder);
+ camel_operation_end(NULL);
+ if (m->cancel)
+ camel_operation_unregister(m->cancel);
+ fail2:
+ camel_object_unref(mp);
+ }
+fail1:
+ camel_folder_sync(folder, FALSE, &mm->ex);
+ camel_object_unref(folder);
+}
+
+static void
+import_mbox_done(struct _mail_msg *mm)
+{
+}
+
+static void
+import_mbox_free (struct _mail_msg *mm)
+{
+ struct _import_mbox_msg *m = (struct _import_mbox_msg *)mm;
+
+ if (m->cancel)
+ camel_operation_unref(m->cancel);
+ g_free(m->uri);
+ g_free(m->path);
+}
+
+static struct _mail_msg_op import_mbox_op = {
+ import_mbox_describe,
+ import_mbox_import,
+ import_mbox_done,
+ import_mbox_free,
+};
+
+int
+mail_importer_import_mbox(const char *path, const char *folderuri, CamelOperation *cancel)
+{
+ struct _import_mbox_msg *m;
+ int id;
+
+ m = mail_msg_new(&import_mbox_op, NULL, sizeof (*m));
+ m->path = g_strdup(path);
+ m->uri = g_strdup(folderuri);
+ if (cancel) {
+ m->cancel = cancel;
+ camel_operation_ref(cancel);
+ }
+
+ id = m->msg.seq;
+ e_thread_put(mail_thread_queued, (EMsg *)m);
+
+ return id;
+}
+
+void
+mail_importer_import_mbox_sync(const char *path, const char *folderuri, CamelOperation *cancel)
+{
+ struct _import_mbox_msg *m;
+
+ m = mail_msg_new(&import_mbox_op, NULL, sizeof (*m));
+ m->path = g_strdup(path);
+ m->uri = g_strdup(folderuri);
+ if (cancel) {
+ m->cancel = cancel;
+ camel_operation_ref(cancel);
+ }
+
+ import_mbox_import(&m->msg);
+ import_mbox_done(&m->msg);
+ mail_msg_free(&m->msg);
+}
+
+/* This should probably take a list of all folders, otherwise we need to duplicate it for netscape folders */
+
+/* pass folderparent = NULL first time */
+void
+mail_importer_import_folders_sync(const char *filepath, const char *folderparent, MailImporterSpecial special_folders[], CamelOperation *cancel)
+{
+ DIR *dir;
+ struct dirent *d;
+ struct stat st;
+ char *filefull, *foldersub, *uri;
+ const char *folder;
+
+ dir = opendir(filepath);
+ if (dir == NULL)
+ return;
+
+ camel_operation_start(NULL, _("Scanning %s"), filepath);
+
+ while ( (d=readdir(dir)) ) {
+ if (strcmp(d->d_name, ".") == 0
+ || strcmp(d->d_name, "..") == 0)
+ continue;
+
+ filefull = g_build_filename(filepath, d->d_name, NULL);
+ if (stat(filefull, &st) == -1
+ || !(S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))) {
+ g_free(filefull);
+ continue;
+ }
+
+ folder = d->d_name;
+ if (folderparent == NULL) {
+ int i;
+
+ for (i=0;special_folders[i].orig;i++)
+ if (strcmp(special_folders[i].orig, folder) == 0) {
+ folder = special_folders[i].new;
+ break;
+ }
+ /* FIXME: need a better way to get default store location */
+ uri = g_strdup_printf("mbox:%s/mail/local#%s", mail_component_peek_base_directory(NULL), folder);
+ } else {
+ uri = g_strdup_printf("mbox:%s/mail/local#%s/%s", mail_component_peek_base_directory(NULL), folderparent, folder);
+ }
+
+ printf("importing to uri %s\n", uri);
+ mail_importer_import_mbox_sync(filefull, uri, cancel);
+ g_free(uri);
+
+ if (S_ISDIR(st.st_mode)) {
+ foldersub = folderparent?g_strdup_printf("%s/%s", folderparent, folder):g_strdup(folder);
+ import_folders(filefull, foldersub, special_folders, cancel);
+ g_free(foldersub);
+ }
+
+ g_free(filefull);
+ }
+
+ camel_operation_end(NULL);
+}
diff --git a/mail/importers/mail-importer.h b/mail/importers/mail-importer.h
new file mode 100644
index 0000000000..2f28538a80
--- /dev/null
+++ b/mail/importers/mail-importer.h
@@ -0,0 +1,88 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* mail-importer.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.
+ */
+
+#ifndef __MAIL_IMPORTER_H__
+#define __MAIL_IMPORTER_H__
+
+struct _MailComponent *mc;
+
+typedef struct _MailImporter MailImporter;
+struct _MailImporter {
+ struct _CamelFolder *folder;
+ struct _CamelStreamMem *mstream;
+
+ gboolean frozen; /* Is folder frozen? */
+};
+
+void mail_importer_init (struct _MailComponent *mc);
+void mail_importer_uninit (void);
+
+void mail_importer_add_line (MailImporter *importer,
+ const char *str,
+ gboolean finished);
+void mail_importer_create_folder (const char *parent_path,
+ const char *name,
+ const char *description);
+
+/* creates a folder at folderpath on the local storage */
+char *mail_importer_make_local_folder(const char *folderpath);
+
+struct _BonoboObject;
+struct _BonoboGenericFactory;
+struct _CamelOperation;
+
+#define ELM_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer:" BASE_VERSION
+#define PINE_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer:" BASE_VERSION
+#define NETSCAPE_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer:" BASE_VERSION
+
+#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_Importer:" BASE_VERSION
+#define OUTLOOK_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Outlook_Importer:" BASE_VERSION
+
+struct _BonoboObject *elm_intelligent_importer_new(void);
+struct _BonoboObject *pine_intelligent_importer_new(void);
+struct _BonoboObject *netscape_intelligent_importer_new(void);
+
+struct _BonoboObject *mbox_importer_new(void);
+struct _BonoboObject *outlook_importer_new(void);
+
+struct _BonoboObject *mail_importer_factory_cb(struct _BonoboGenericFactory *factory, const char *iid, void *data);
+
+
+/* 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
+
+int mail_importer_import_mbox(const char *path, const char *folderuri, struct _CamelOperation *cancel);
+void mail_importer_import_mbox_sync(const char *path, const char *folderuri, struct _CamelOperation *cancel);
+
+struct _MailImporterSpecial {
+ char *orig, *new;
+};
+typedef struct _MailImporterSpecial MailImporterSpecial;
+
+/* api in flux */
+void mail_importer_import_folders_sync(const char *filepath, const char *folderparent, MailImporterSpecial special_folders[], CamelOperation *cancel);
+
+#endif
diff --git a/mail/importers/netscape-importer.c b/mail/importers/netscape-importer.c
index a0610ca1b4..4ce1570b8c 100644
--- a/mail/importers/netscape-importer.c
+++ b/mail/importers/netscape-importer.c
@@ -61,21 +61,14 @@
#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"
+#include "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"
@@ -196,15 +189,11 @@ typedef struct {
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
@@ -1472,6 +1461,7 @@ get_user_fullname (void)
}
}
+#if 0
static void
netscape_import_accounts (NsImporter *importer)
{
@@ -1667,6 +1657,7 @@ netscape_import_accounts (NsImporter *importer)
g_free (username);
CORBA_exception_free (&ev);
}
+#endif
static gboolean
is_dir_empty (const char *path)
@@ -1766,7 +1757,8 @@ netscape_import_file (NsImporter *importer,
if (!uri)
return FALSE;
- result = GNOME_Evolution_Importer_loadFile (importer->importer, path, uri, "", &ev);
+#warning "load file dest path"
+ result = GNOME_Evolution_Importer_loadFile (importer->importer, path, &ev);
g_free(uri);
if (ev._major != CORBA_NO_EXCEPTION || result == FALSE) {
g_warning ("Exception here: %s", CORBA_exception_id (&ev));
@@ -1983,7 +1975,8 @@ netscape_create_structure (EvolutionIntelligentImporter *ii,
if (importer->do_settings == TRUE) {
gconf_client_set_bool(gconf, "/apps/evolution/importer/netscape/settings-imported", TRUE, NULL);
- netscape_import_accounts (importer);
+#warning "import netscape accounts"
+ /*netscape_import_accounts (importer);*/
}
if (importer->do_mail == TRUE) {
@@ -2107,10 +2100,8 @@ create_checkboxes_control (NsImporter *importer)
return control;
}
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- const char *iid,
- void *closure)
+BonoboObject *
+netscape_intelligent_importer_new(void)
{
EvolutionIntelligentImporter *importer;
BonoboControl *control;
@@ -2145,18 +2136,3 @@ factory_fn (BonoboGenericFactory *_factory,
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
index 89cfcc2fdc..9ce7f4520a 100644
--- a/mail/importers/pine-importer.c
+++ b/mail/importers/pine-importer.c
@@ -3,8 +3,10 @@
*
* Authors:
* Iain Holmes <iain@ximian.com>
+ * Michael Zucchi <notzed@ximian.com>
*
* Copyright 2001 Ximian, Inc. (www.ximian.com)
+ * Copyright 2004 Novell, 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
@@ -54,13 +56,13 @@
#include <importer/evolution-importer-client.h>
#include <importer/GNOME_Evolution_Importer.h>
-#include "mail/mail-importer.h"
+#include "mail-importer.h"
-#include <ebook/e-book.h>
-#include <ebook/e-card-simple.h>
+#include "mail/mail-mt.h"
+#include "mail/mail-component.h"
+
+#include <libebook/e-book.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*/
@@ -73,21 +75,19 @@
typedef struct {
EvolutionIntelligentImporter *ii;
- GList *dir_list;
-
- int progress_count;
- int more;
- EvolutionImporterResult result;
-
- GNOME_Evolution_Importer importer;
- EvolutionImporterListener *listener;
+ GMutex *status_lock;
+ char *status_what;
+ int status_pc;
+ int status_timeout_id;
+ CamelOperation *cancel; /* cancel/status port */
GtkWidget *mail;
- gboolean do_mail;
GtkWidget *address;
- gboolean do_address;
- EBook *book;
+ gboolean do_mail;
+ gboolean done_mail;
+ gboolean do_address;
+ gboolean done_address;
/* GUI */
GtkWidget *dialog;
@@ -95,32 +95,32 @@ typedef struct {
GtkWidget *progressbar;
} PineImporter;
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
- gboolean folder;
-} PineFolder;
-
-void mail_importer_module_init (void);
+static void
+pine_importer_response(GtkWidget *w, guint button, void *data)
+{
+ PineImporter *importer = data;
-static void import_next (PineImporter *importer);
+ if (button == GTK_RESPONSE_CANCEL
+ && importer->cancel)
+ camel_operation_cancel(importer->cancel);
+}
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);
+ dialog = gtk_message_dialog_new(NULL, 0/*GTK_DIALOG_NO_SEPARATOR*/,
+ GTK_MESSAGE_INFO, GTK_BUTTONS_CANCEL,
+ _("Evolution is importing your old Pine data"));
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);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), importer->label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), importer->progressbar, FALSE, FALSE, 0);
+ g_signal_connect(dialog, "response", G_CALLBACK(pine_importer_response), importer);
+
return dialog;
}
@@ -129,8 +129,9 @@ 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);
+ gconf_client_set_bool (gconf, "/apps/evolution/importer/pine/mail", importer->done_mail, NULL);
+ gconf_client_set_bool (gconf, "/apps/evolution/importer/pine/address", importer->done_address, NULL);
+ g_object_unref(gconf);
}
static void
@@ -138,403 +139,287 @@ 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);
+ importer->done_mail = gconf_client_get_bool (gconf, "/apps/evolution/importer/pine/mail", NULL);
+ importer->done_address = gconf_client_get_bool (gconf, "/apps/evolution/importer/pine/address", NULL);
+ g_object_unref(gconf);
}
-static void
-add_card_cb (EBook *book,
- EBookStatus status,
- const char *id,
- gpointer closure)
+static gboolean
+pine_can_import (EvolutionIntelligentImporter *ii, void *closure)
{
- g_object_unref (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);
+ g_free (maildir);
-static void
-parse_line (EBook *book,
- char *line)
-{
- char **strings;
- ECardName *name;
- ECard *card;
- EList *list;
+ importer->do_mail = md_exists && !importer->done_mail;
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (importer->mail), importer->do_mail);
+ gtk_widget_set_sensitive (importer->mail, md_exists);
- 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);
- }
+ 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_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;
- }
+/*
+See: http://www.washington.edu/pine/tech-notes/low-level.html
- 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;
- }
+addressbook line is:
+ <nickname>TAB<fullname>TAB<address>TAB<fcc>TAB<comments>
+lists, address is:
+ "(" <address>, <address>, <address>, ... ")"
- if (lastline && *thisline && isspace ((int) *thisline)) {
- char *temp;
+<address> is rfc822 address, or alias address.
+if rfc822 address includes a phrase, then that overrides <fullname>
- while (*thisline && isspace ((int) *thisline)) {
- thisline++;
- }
- temp = lastline;
- lastline = g_strdup_printf ("%s%s", lastline, thisline);
- g_free (temp);
- continue;
- }
+FIXME: we dont handle aliases in lists.
+*/
- if (lastline) {
- parse_line (book, lastline);
- g_free (lastline);
+static void
+import_contact(EBook *book, char *line)
+{
+ char **strings, *addr, **addrs;
+ int i;
+ GList *list;
+ /*EContactName *name;*/
+ EContact *card;
+ size_t len;
+
+ card = e_contact_new();
+ strings = g_strsplit(line, "\t", 5);
+ if (strings[0] && strings[1] && strings[2]) {
+ e_contact_set(card, E_CONTACT_NICKNAME, strings[0]);
+ e_contact_set(card, E_CONTACT_FULL_NAME, strings[1]);
+
+ addr = strings[2];
+ len = strlen(addr);
+ if (addr[0] == '(' && addr[len-1] == ')') {
+ addr[0] = 0;
+ addr[len-1] = 0;
+ addrs = g_strsplit(addr+1, ",", 0);
+ list = NULL;
+ for (i=0;addrs[i];i++)
+ list = g_list_append(list, addrs[i]);
+ e_contact_set(card, E_CONTACT_EMAIL, list);
+ g_strfreev(addrs);
+ e_contact_set(card, E_CONTACT_IS_LIST, GINT_TO_POINTER(TRUE));
+ } else {
+ e_contact_set(card, E_CONTACT_EMAIL_1, strings[2]);
}
- lastline = g_strdup (thisline);
- }
+ /*name = e_contact_name_from_string(strings[1]);*/
- if (lastline) {
- parse_line (book, lastline);
- g_free (lastline);
- }
+ if (strings[3] && strings[4])
+ e_contact_set(card, E_CONTACT_NOTE, strings[4]);
- fclose (handle);
+ /* FIXME Error checking */
+ e_book_add_contact(book, card, NULL);
+ g_object_unref(card);
+ }
+ g_strfreev (strings);
}
static void
-import_addressbook (PineImporter *importer)
+import_contacts(PineImporter *importer)
{
- char *path, *uri;
+ ESource *primary;
+ ESourceList *source_list;
+ EBook *book;
+ char *name;
+ GString *line;
+ FILE *fp;
+ size_t offset;
+
+ printf("importing pine addressbook\n");
+
+ if (!e_book_get_addressbooks(&source_list, NULL))
+ return;
- importer->book = e_book_new ();
- if (importer->book == NULL) {
+ name = g_build_filename(g_get_home_dir(), ".addressbook", NULL);
+ fp = fopen(name, "r");
+ g_free(name);
+ if (fp == NULL)
+ return;
+
+ /* FIXME Better error handling */
+ if ((book = e_book_new()) == NULL) {
+ fclose(fp);
g_warning ("Could not create EBook.");
return;
}
+
+ primary = e_source_list_peek_source_any(source_list);
+ e_book_load_source(book, primary, TRUE, NULL);
+ g_object_unref(primary);
+ g_object_unref(source_list);
+
+ line = g_string_new("");
+ g_string_set_size(line, 256);
+ offset = 0;
+ while (fgets(line->str+offset, 256, fp)) {
+ size_t len;
+
+ len = strlen(line->str+offset)+offset;
+ if (line->str[len-1] == '\n')
+ g_string_truncate(line, len-1);
+ else if (!feof(fp)) {
+ offset = len;
+ g_string_set_size(line, len+256);
+ continue;
+ } else {
+ g_string_truncate(line, len);
+ }
- path = g_build_filename(g_get_home_dir (),
- "evolution/local/Contacts/addressbook.db", NULL);
- uri = g_strdup_printf ("file://%s", path);
- g_free (path);
+ import_contact(book, line->str);
+ offset = 0;
+ }
- e_book_load_uri (importer->book, uri, import_addressfile, importer);
- g_free (uri);
+ g_string_free(line, TRUE);
+ fclose(fp);
+ g_object_unref(book);
}
-static void
-importer_cb (EvolutionImporterListener *listener,
- EvolutionImporterResult result,
- gboolean more_items,
- void *data)
-{
- PineImporter *importer = (PineImporter *) data;
+struct _pine_import_msg {
+ struct _mail_msg msg;
- importer->result = result;
- importer->more = more_items;
-}
+ PineImporter *importer;
+};
-static gboolean
-pine_import_file (PineImporter *importer,
- const char *path,
- const char *folderpath,
- gboolean folder)
+static char *
+pine_import_describe (struct _mail_msg *mm, int complete)
{
- CORBA_boolean result;
- CORBA_Environment ev;
- CORBA_Object objref;
- char *str, *uri;
- struct stat st;
+ return g_strdup (_("Importing Pine data"));
+}
- CORBA_exception_init (&ev);
+static MailImporterSpecial pine_special_folders[] = {
+ { "sent-mail", "Sent" }, /* pine */
+ { "saved-messages", "Drafts" }, /* pine */
+ { 0 },
+};
- 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))
- ;
+static void
+pine_import_import(struct _mail_msg *mm)
+{
+ struct _pine_import_msg *m = (struct _pine_import_msg *) mm;
- uri = mail_importer_make_local_folder(folderpath);
- if (!uri)
- return FALSE;
+ if (m->importer->do_address)
+ import_contacts(m->importer);
- /* 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;
- }
+ if (m->importer->do_mail) {
+ char *path;
- 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;
+ path = g_build_filename(g_get_home_dir(), "mail", NULL);
+ mail_importer_import_folders_sync(path, NULL, pine_special_folders, m->importer->cancel);
+ g_free(path);
}
-
- /* 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)
+static void
+pine_import_imported(struct _mail_msg *mm)
{
- 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)
+pine_import_free(struct _mail_msg *mm)
{
- 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);
- }
+ /*struct _pine_import_msg *m = (struct _pine_import_msg *)mm;*/
}
-/* Pine uses sent-mail and saved-mail whereas Evolution uses Sent and Drafts */
-static char *
-maybe_replace_name (const char *original_name)
+static struct _mail_msg_op pine_import_op = {
+ pine_import_describe,
+ pine_import_import,
+ pine_import_imported,
+ pine_import_free,
+};
+
+static int
+mail_importer_pine_import(PineImporter *importer)
{
- if (strcmp (original_name, "sent-mail") == 0) {
- return g_strdup ("Sent");
- } else if (strcmp (original_name, "saved-messages") == 0) {
- return g_strdup ("Drafts");
- }
+ struct _pine_import_msg *m;
+ int id;
+
+ m = mail_msg_new(&pine_import_op, NULL, sizeof (*m));
+ m->importer = importer;
- return g_strdup (original_name);
+ id = m->msg.seq;
+
+ e_thread_put(mail_thread_queued, (EMsg *) m);
+
+ return id;
}
static void
-scan_dir (PineImporter *importer,
- const char *dirname,
- const char *orig_parent)
+pine_status(CamelOperation *op, const char *what, int pc, void *data)
{
- 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);
+ PineImporter *importer = data;
+
+ if (pc == CAMEL_OPERATION_START)
+ pc = 0;
+ else if (pc == CAMEL_OPERATION_END)
+ pc = 100;
+
+ g_mutex_lock(importer->status_lock);
+ g_free(importer->status_what);
+ importer->status_what = g_strdup(what);
+ importer->status_pc = pc;
+ g_mutex_unlock(importer->status_lock);
+}
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
+static gboolean
+pine_status_timeout(void *data)
+{
+ PineImporter *importer = data;
+ int pc;
+ char *what;
- 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 (!importer->status_what)
+ return TRUE;
- 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);
- }
+ g_mutex_lock(importer->status_lock);
+ what = importer->status_what;
+ importer->status_what = NULL;
+ pc = importer->status_pc;
+ g_mutex_unlock(importer->status_lock);
+
+ gtk_progress_bar_set_fraction((GtkProgressBar *)importer->progressbar, (gfloat)(pc/100.0));
+ gtk_progress_bar_set_text((GtkProgressBar *)importer->progressbar, what);
+
+ return TRUE;
}
static void
-pine_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
+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) {
+ if (importer->do_address || importer->do_mail) {
importer->dialog = create_importer_gui (importer);
gtk_widget_show_all (importer->dialog);
- while (gtk_events_pending ()) {
- gtk_main_iteration ();
- }
- }
+ importer->status_timeout_id = g_timeout_add(100, pine_status_timeout, importer);
+ importer->cancel = camel_operation_new(pine_status, importer);
- if (importer->do_address == TRUE) {
- gconf_client_set_bool(gconf, "/apps/evolution/importer/pine/address-imported", TRUE, NULL);
- import_addressbook (importer);
- }
+ mail_msg_wait(mail_importer_pine_import(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);
+ camel_operation_unref(importer->cancel);
+ g_source_remove(importer->status_timeout_id);
+ importer->status_timeout_id = 0;
- /* Import them */
- import_next (importer);
+ if (importer->do_address)
+ importer->done_address = TRUE;
+ if (importer->do_mail)
+ importer->done_mail = TRUE;
}
- 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));
- }
+ pine_store_settings (importer);
+
bonobo_object_unref (BONOBO_OBJECT (ii));
}
@@ -543,22 +428,21 @@ pine_destroy_cb (PineImporter *importer, GtkObject *object)
{
pine_store_settings (importer);
+ if (importer->status_timeout_id)
+ g_source_remove(importer->status_timeout_id);
+ g_mutex_free(importer->status_lock);
+
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)
+checkbox_toggle_cb(GtkToggleButton *tb, gboolean *do_item)
{
- *do_item = gtk_toggle_button_get_active (tb);
+ *do_item = gtk_toggle_button_get_active(tb);
}
static BonoboControl *
@@ -587,31 +471,20 @@ create_checkboxes_control (PineImporter *importer)
return control;
}
-static BonoboObject *
-factory_fn (BonoboGenericFactory *_factory,
- const char *iid,
- void *closure)
+BonoboObject *
+pine_intelligent_importer_new(void)
{
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->status_lock = g_mutex_new();
- 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);
+ pine_restore_settings (pine);
importer = evolution_intelligent_importer_new (pine_can_import,
pine_create_structure,
@@ -625,19 +498,3 @@ factory_fn (BonoboGenericFactory *_factory,
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;
-}
diff --git a/mail/mail-component-factory.c b/mail/mail-component-factory.c
index 04782b9a16..ef7e8e85b8 100644
--- a/mail/mail-component-factory.c
+++ b/mail/mail-component-factory.c
@@ -37,11 +37,14 @@
#include "mail-config.h"
#include "mail-mt.h"
+#include "importers/mail-importer.h"
+
#include <bonobo-activation/bonobo-activation.h>
#include <bonobo/bonobo-shlib-factory.h>
#include <string.h>
+/* TODO: clean up these definitions */
#define FACTORY_ID "OAFIID:GNOME_Evolution_Mail_Factory:" BASE_VERSION
#define COMPONENT_ID "OAFIID:GNOME_Evolution_Mail_Component:" BASE_VERSION
@@ -51,14 +54,10 @@
#define MAIL_CONFIG_ID "OAFIID:GNOME_Evolution_MailConfig:" BASE_VERSION
#define WIZARD_ID "OAFIID:GNOME_Evolution_Mail_Wizard:" BASE_VERSION
-
static BonoboObject *
-factory (BonoboGenericFactory *factory,
- const char *component_id,
- void *closure)
+factory(BonoboGenericFactory *factory, const char *component_id, void *closure)
{
- /* EPFIXME this is messy. The IDs are defined all over the place
- without a logic... */
+ BonoboObject *o;
if (strcmp (component_id, COMPONENT_ID) == 0) {
MailComponent *component = mail_component_peek ();
@@ -80,8 +79,11 @@ factory (BonoboGenericFactory *factory,
return (BonoboObject *) evolution_composer_new (em_utils_composer_send_cb, em_utils_composer_save_draft_cb);
}
- g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
- return NULL;
+ o = mail_importer_factory_cb(factory, component_id, NULL);
+ if (o == NULL)
+ g_warning (FACTORY_ID ": Don't know what to do with %s", component_id);
+
+ return o;
}
static Bonobo_Unknown
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 53dbe55484..2efe4d7a75 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -44,6 +44,7 @@
#include "em-folder-selection.h"
#include "em-migrate.h"
+#include "filter/rule-context.h"
#include "mail-config.h"
#include "mail-component.h"
#include "mail-folder-cache.h"
@@ -55,6 +56,8 @@
#include "mail-session.h"
#include "mail-offline-handler.h"
+#include "e-activity-handler.h"
+
#include "composer/e-msg-composer.h"
#include "e-task-bar.h"
diff --git a/mail/mail-component.h b/mail/mail-component.h
index 5f32dd110b..0cd9229232 100644
--- a/mail/mail-component.h
+++ b/mail/mail-component.h
@@ -26,13 +26,11 @@
#ifndef _MAIL_COMPONENT_H_
#define _MAIL_COMPONENT_H_
-#include <camel/camel-store.h>
-#include <filter/rule-context.h>
#include <bonobo/bonobo-object.h>
-#include "e-activity-handler.h"
+#include "shell/Evolution.h"
-#include "Evolution.h"
+struct _CamelStore;
#define MAIL_TYPE_COMPONENT (mail_component_get_type ())
#define MAIL_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_COMPONENT, MailComponent))
@@ -72,18 +70,18 @@ MailComponent *mail_component_peek (void);
/* NOTE: Using NULL as the component implies using the default component */
const char *mail_component_peek_base_directory (MailComponent *component);
-RuleContext *mail_component_peek_search_context (MailComponent *component);
-EActivityHandler *mail_component_peek_activity_handler (MailComponent *component);
+struct _RuleContext *mail_component_peek_search_context (MailComponent *component);
+struct _EActivityHandler *mail_component_peek_activity_handler (MailComponent *component);
void mail_component_add_store (MailComponent *component,
- CamelStore *store,
+ struct _CamelStore *store,
const char *name);
-CamelStore *mail_component_load_store_by_uri (MailComponent *component,
+struct _CamelStore *mail_component_load_store_by_uri (MailComponent *component,
const char *uri,
const char *name);
void mail_component_remove_store (MailComponent *component,
- CamelStore *store);
+ struct _CamelStore *store);
void mail_component_remove_store_by_uri (MailComponent *component,
const char *uri);
@@ -92,7 +90,7 @@ void mail_component_stores_foreach (MailComponent *component,
GHFunc func,
void *data);
-void mail_component_remove_folder (MailComponent *component, CamelStore *store, const char *path);
+void mail_component_remove_folder (MailComponent *component, struct _CamelStore *store, const char *path);
struct _EMFolderTreeModel *mail_component_peek_tree_model (MailComponent *component);
diff --git a/mail/mail-importer.c b/mail/mail-importer.c
deleted file mode 100644
index 46804fc295..0000000000
--- a/mail/mail-importer.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* mail-importer.c
- *
- * Authors: Iain Holmes <iain@ximian.com>
- *
- * Copyright (C) 2001-2003 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 <string.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <gmodule.h>
-#include <libgnome/gnome-util.h>
-#include <evolution-storage.h>
-#include <camel/camel-folder.h>
-#include <camel/camel-mime-message.h>
-#include <camel/camel-stream-mem.h>
-#include <camel/camel-exception.h>
-#include <e-util/e-path.h>
-
-#include "mail-component.h"
-#include "mail-importer.h"
-#include "mail.h"
-
-static GList *importer_modules = NULL;
-static GNOME_Evolution_Storage local_storage = NULL;
-
-void mail_importer_uninit (void);
-
-struct _create_data {
- GNOME_Evolution_Storage_Result create_result;
- int create_done:1;
-};
-
-static void
-folder_created_cb(BonoboListener *listener, const char *event_name, const BonoboArg *event_data,
- CORBA_Environment *ev, struct _create_data *data)
-{
- GNOME_Evolution_Storage_FolderResult *result;
-
- data->create_done = TRUE;
-
- if (strcmp (event_name, "evolution-shell:folder_created") != 0) {
- return; /* Unknown event */
- }
-
- result = event_data->_value;
- data->create_result = result->result;
-}
-
-/**
- * mail_importer_make_local_folder:
- * @folderpath:
- *
- * Check a local folder exists at path @folderpath, and if not, create it.
- *
- * Return value: The physical uri of the folder, or NULL if the folder did
- * not exist and could not be created.
- **/
-char *
-mail_importer_make_local_folder(const char *folderpath)
-{
- CORBA_Environment ev;
- char *uri = NULL, *tmp;
- GNOME_Evolution_Folder *fi;
- BonoboListener *listener;
-
- CORBA_exception_init (&ev);
-
- /* first, check, does this folder exist, if so, use the right path */
- fi = GNOME_Evolution_Storage_getFolderAtPath(local_storage, folderpath, &ev);
- if (fi) {
- printf("folder %s exists @ %s\n", folderpath, fi->physicalUri);
- uri = g_strdup(fi->physicalUri);
- CORBA_free(fi);
- } else {
- struct _create_data data = { GNOME_Evolution_Storage_GENERIC_ERROR, FALSE };
-
- tmp = g_strdup_printf("file://%s/local",
- mail_component_peek_base_directory (mail_component_peek ()));
- uri = e_path_to_physical(tmp, folderpath);
- g_free(tmp);
- tmp = strrchr(uri, '/');
- tmp[0] = 0;
-
- printf("Creating folder %s, parent %s\n", folderpath, uri);
-
- listener = bonobo_listener_new (NULL, NULL);
- g_signal_connect(listener, "event-notify", G_CALLBACK (folder_created_cb), &data);
-
- GNOME_Evolution_Storage_asyncCreateFolder(local_storage, folderpath, "mail", "", uri,
- bonobo_object_corba_objref((BonoboObject *)listener), &ev);
-
- while (!data.create_done)
- g_main_context_iteration(NULL, TRUE);
-
- bonobo_object_unref((BonoboObject *)listener);
-
- if (data.create_result != GNOME_Evolution_Storage_OK) {
- g_free(uri);
- uri = NULL;
- } else {
- *tmp = '/';
- }
- }
-
- CORBA_exception_free (&ev);
-
- return uri;
-}
-
-/**
- * mail_importer_add_line:
- * importer: A MailImporter structure.
- * str: Next line of the mbox.
- * finished: TRUE if @str is the last line of the message.
- *
- * Adds lines to the message until it is finished, and then adds
- * the complete message to the folder.
- */
-void
-mail_importer_add_line (MailImporter *importer,
- const char *str,
- gboolean finished)
-{
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
- CamelException *ex;
-
- if (importer->mstream == NULL)
- importer->mstream = CAMEL_STREAM_MEM (camel_stream_mem_new ());
-
- camel_stream_write (CAMEL_STREAM (importer->mstream), str, strlen (str));
-
- if (finished == FALSE)
- return;
-
- camel_stream_reset (CAMEL_STREAM (importer->mstream));
- info = g_new0 (CamelMessageInfo, 1);
- info->flags = CAMEL_MESSAGE_SEEN;
-
- msg = camel_mime_message_new ();
- camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (msg),
- CAMEL_STREAM (importer->mstream));
-
- camel_object_unref (importer->mstream);
- importer->mstream = NULL;
-
- ex = camel_exception_new ();
- camel_folder_append_message (importer->folder, msg, info, NULL, ex);
- camel_object_unref (msg);
-
- camel_exception_free (ex);
- g_free (info);
-}
-
-/* module management */
-static GList *
-get_importer_list (void)
-{
- DIR *dir;
- struct dirent *d;
- GList *importers_ret = NULL;
-
- dir = opendir (MAIL_IMPORTERSDIR);
- if (!dir) {
- g_warning ("No importers dir: %s", MAIL_IMPORTERSDIR);
- return NULL;
- }
-
- while ((d = readdir (dir))) {
- char *path, *ext;
-
- ext = strchr (d->d_name, '.');
- if (!ext || strcmp (ext, ".so") != 0)
- continue;
-
- path = g_build_filename (MAIL_IMPORTERSDIR, d->d_name, NULL);
- importers_ret = g_list_prepend (importers_ret, path);
- }
-
- closedir (dir);
- return importers_ret;
-}
-
-static void
-free_importer_list (GList *list)
-{
- for (; list; list = list->next) {
- g_free (list->data);
- }
-
- g_list_free (list);
-}
-
-/**
- * mail_importer_init:
- *
- * Initialises all the importers
- */
-void
-mail_importer_init (EvolutionShellClient *client)
-{
- GList *importers, *l;
-
- if (importer_modules != NULL) {
- return;
- }
-
- local_storage = evolution_shell_client_get_local_storage (client);
-
- if (!g_module_supported ()) {
- g_warning ("Could not initialise the importers as module loading"
- " is not supported on this system");
- return;
- }
-
- importers = get_importer_list ();
- if (importers == NULL)
- return;
-
- for (l = importers; l; l = l->next) {
- GModule *module;
-
- module = g_module_open (l->data, 0);
- if (!module) {
- g_warning ("Could not load: %s: %s", (char *) l->data,
- g_module_error ());
- } else {
- void *(*mail_importer_module_init) ();
-
- if (!g_module_symbol (module, "mail_importer_module_init",
- (gpointer *)&mail_importer_module_init)) {
- g_warning ("Could not load %s: No initialisation",
- (char *) l->data);
- g_module_close (module);
- }
-
- mail_importer_module_init ();
- importer_modules = g_list_prepend (importer_modules, module);
- }
- }
-
- free_importer_list (importers);
-}
-
-/**
- * mail_importer_uninit:
- *
- * Unloads all the modules.
- */
-void
-mail_importer_uninit (void)
-{
- CORBA_Environment ev;
- GList *l;
-
- for (l = importer_modules; l; l = l->next) {
- g_module_close (l->data);
- }
-
- g_list_free (importer_modules);
- importer_modules = NULL;
-
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (local_storage, &ev);
- local_storage = NULL;
- CORBA_exception_free (&ev);
-}
-
diff --git a/mail/mail-importer.h b/mail/mail-importer.h
deleted file mode 100644
index 66b4441e1d..0000000000
--- a/mail/mail-importer.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* mail-importer.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.
- */
-
-#ifndef __MAIL_IMPORTER_H__
-#define __MAIL_IMPORTER_H__
-
-#include <bonobo/bonobo-listener.h>
-#include <camel/camel-folder.h>
-#include <camel/camel-stream-mem.h>
-#include <evolution-shell-client.h>
-
-typedef struct _MailImporter MailImporter;
-struct _MailImporter {
- CamelFolder *folder;
- CamelStreamMem *mstream;
-
- gboolean frozen; /* Is folder frozen? */
-};
-
-void mail_importer_init (EvolutionShellClient *client);
-void mail_importer_uninit (void);
-
-void mail_importer_add_line (MailImporter *importer,
- const char *str,
- gboolean finished);
-void mail_importer_create_folder (const char *parent_path,
- const char *name,
- const char *description,
- const BonoboListener *listener);
-
-/* creates a folder at folderpath on the local storage */
-char *mail_importer_make_local_folder(const char *folderpath);
-
-#endif