aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-05-09 06:53:41 +0800
committerIain Holmes <iain@src.gnome.org>2001-05-09 06:53:41 +0800
commitc64eccfe004f5c30932fe571bb506626bb0c186d (patch)
tree2260477f72c474e00ae9f2b0afa7f5242e60c5a5 /mail
parent9bcfef421b420061f7342e5517d226aa9f58dbdd (diff)
downloadgsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.gz
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.bz2
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.lz
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.xz
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.tar.zst
gsoc2013-evolution-c64eccfe004f5c30932fe571bb506626bb0c186d.zip
Importer changes
svn path=/trunk/; revision=9722
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog37
-rw-r--r--mail/GNOME_Evolution_Mail.oaf.in21
-rw-r--r--mail/Mail.idl42
-rw-r--r--mail/component-factory.c2
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf.in21
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf.in21
-rw-r--r--mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf.in21
-rw-r--r--mail/importers/Makefile.am17
-rw-r--r--mail/importers/elm-importer.c451
-rw-r--r--mail/importers/evolution-mbox-importer.c63
-rw-r--r--mail/importers/netscape-importer.c473
-rw-r--r--mail/importers/pine-importer.c416
-rw-r--r--mail/mail-account-gui.c3
-rw-r--r--mail/mail-callbacks.c2
-rw-r--r--mail/mail-config.c110
-rw-r--r--mail/mail-config.h18
16 files changed, 297 insertions, 1421 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 16307a3e04..e6138ebde0 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,40 @@
+2001-05-08 Iain Holmes <iain@ximian.com>
+
+ * mail-callbacks.c (filter_edit): Set the title of the dialog.
+
+ * GNOME_Evolution_Mail.oaf.in: Add a reference for the MailConfig
+ interface stuff.
+
+ * Mail.idl: Add the MailConfig interface, and a MailFilter interface.
+
+ * component-factory.c (component_factory_init): Call
+ evolution_mail_config_factory_init.
+
+ * mail-account-gui.c (setup_service): Just return if url == NULL,
+ don't crash.
+
+ * mail-config.c: #include bonobo-object.h, #include Mail.h and define
+ the Config factory IID.
+ Implement the MailConfig interface with a BonoboObject.
+ (impl_GNOME_Evolution_MailConfig_addAccount): Convert the CORBA struct
+ into the correct MailConfig structures and add the account.
+ (evolution_mail_config_class_init): Initialise the class.
+ (evolution_mail_config_init): This function is intentionally left blank.
+
+ (evolution_mail_config_factory_fn): Create an EvolutionMailConfig object
+ and return it.
+ (evolution_mail_config_factory_init): Set up the bonobo factory.
+
+ * mail-config.h: #include bonobo-xobject.h and Mail.h
+ Declare the object structures.
+
+ * importers/Makefile.am: Remove the intelligent importers.
+
+ * importers/evolution-mbox-importer.c (folder_created_cb): Callback
+ from when the folder is created. Opens the folder and unrefs the
+ listener.
+ (load_file_fn): Create the folder if it doesn't exist.
+
2001-05-08 Jeffrey Stedfast <fejj@ximian.com>
* mail-tools.c (mail_tool_forward_message): Convert the Subject
diff --git a/mail/GNOME_Evolution_Mail.oaf.in b/mail/GNOME_Evolution_Mail.oaf.in
index a30155258e..58a32dcfaa 100644
--- a/mail/GNOME_Evolution_Mail.oaf.in
+++ b/mail/GNOME_Evolution_Mail.oaf.in
@@ -102,4 +102,25 @@
_value="Evolution mail composer."/>
</oaf_server>
+<oaf_server iid="OAFIID:GNOME_Evolution_MailConfig_Factory"
+ type="exe"
+ location="evolution-mail">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+</oaf_server>
+
+<oaf_server iid="OAFIID:GNOME_Evolution_MailConfig"
+ type="factory"
+ location="OAFIID:GNOME_Evolution_MailConfig_Factory">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Evolution/MailConfig:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="description" type="string"
+ _value="Mail configuration interface"/>
+</oaf_server>
+
</oaf_info>
diff --git a/mail/Mail.idl b/mail/Mail.idl
index 14e17b3993..09a625e4b0 100644
--- a/mail/Mail.idl
+++ b/mail/Mail.idl
@@ -27,6 +27,48 @@ module Evolution {
interface FolderBrowser : Bonobo::Unknown {
MessageList getMessageList ();
};
+
+ interface MailConfig : Bonobo::Unknown {
+
+ struct Identity {
+ string name;
+ string address;
+ string organization;
+ string signature;
+ };
+
+ struct Service {
+ string url;
+ boolean keep_on_server;
+ boolean auto_check;
+ long auto_check_time;
+ boolean save_passwd;
+ boolean enabled;
+ };
+
+ struct Account {
+ string name;
+ boolean default_account;
+
+ Identity id;
+ Service source;
+ Service transport;
+
+ string drafts_folder_name;
+ string drafts_folder_uri;
+ string sent_folder_name;
+ string sent_folder_uri;
+ };
+
+ void addAccount (in Account acc);
+ };
+
+ interface MailFilter : Bonobo::Unknown {
+
+ void addFilter (in string rule);
+
+ void removeFilter (in string rule);
+ };
};
};
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 239611bd6a..759d7294f1 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -324,6 +324,8 @@ component_factory_init (void)
summary_factory = bonobo_generic_factory_new (SUMMARY_FACTORY_ID,
summary_fn, NULL);
+ evolution_mail_config_factory_init ();
+
if (component_factory == NULL || summary_factory == NULL) {
e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
_("Cannot initialize Evolution's mail component."));
diff --git a/mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf.in b/mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf.in
deleted file mode 100644
index 7d75c1148d..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory"
- type="exe"
- location="evolution-mail">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf.in b/mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf.in
deleted file mode 100644
index db3f820d7b..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer_Factory"
- type="exe"
- location="evolution-mail">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer_Factory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf.in b/mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf.in
deleted file mode 100644
index 1e1c5b79f8..0000000000
--- a/mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf.in
+++ /dev/null
@@ -1,21 +0,0 @@
-<oaf_info>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer_Factory"
- type="exe"
- location="evolution-mail">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/ObjectFactory:1.0"/>
- </oaf_attribute>
-</oaf_server>
-
-<oaf_server iid="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer"
- type="factory"
- location="OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer_Factory">
-
- <oaf_attribute name="repo_ids" type="stringv">
- <item value="IDL:GNOME/Evolution/IntelligentImporter:1.0"/>
- </oaf_attribute>
-
-</oaf_server>
-</oaf_info>
diff --git a/mail/importers/Makefile.am b/mail/importers/Makefile.am
index eb35101291..48200aa909 100644
--- a/mail/importers/Makefile.am
+++ b/mail/importers/Makefile.am
@@ -1,7 +1,6 @@
importersdir = $(pkglibdir)/evolution-mail-importers/$(VERSION)
-importers_LTLIBRARIES = liboutlook.la libmbox.la libiinetscape.la \
- libiipine.la libiielm.la
+importers_LTLIBRARIES = liboutlook.la libmbox.la
INCLUDES = -I.. \
-I$(srcdir)/.. \
@@ -19,21 +18,9 @@ liboutlook_la_LDFLAGS = -version-info 0:0:0
libmbox_la_SOURCES = evolution-mbox-importer.c
libmbox_la_LDFLAGS = -version-info 0:0:0
-libiinetscape_la_SOURCES = netscape-importer.c
-libiinetscape_la_LDFLAGS = -version-info 0:0:0
-
-libiipine_la_SOURCES = pine-importer.c
-libiipine_la_LDFLAGS = -version-info 0:0:0
-
-libiielm_la_SOURCES = elm-importer.c
-libiielm_la_LDFLAGS = -version-info 0:0:0
-
oafdir = $(datadir)/oaf
oaf_in_files = GNOME_Evolution_Mail_Mbox_Importer.oaf.in \
- GNOME_Evolution_Mail_Outlook_Importer.oaf.in \
- GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf.in \
- GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf.in \
- GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf.in
+ GNOME_Evolution_Mail_Outlook_Importer.oaf.in
oaf_DATA = $(oaf_in_files:.oaf.in=.oaf)
diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c
deleted file mode 100644
index 1394d0f279..0000000000
--- a/mail/importers/elm-importer.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* elm-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-#include <gnome.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <camel/camel-mime-message.h>
-#include <camel/camel-mime-part.h>
-#include <camel/camel-exception.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include "mail-importer.h"
-#include "mail-tools.h"
-
-extern char *evolution_dir;
-
-#define ELM_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Elm_Intelligent_Importer_Factory"
-#define KEY "elm-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- MailImporter importer;
- GList *dir_list;
-
- int num;
- CamelMimeParser *mp;
- BonoboListener *listener;
-} ElmImporter;
-
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
-} ElmFolder;
-
-static gboolean
-elm_is_mbox (const char *filename)
-{
- char sig[5];
- int fd;
-
- fd = open (filename, O_RDONLY);
- if (read (fd, sig, 5) != 5) {
- close (fd);
- return FALSE;
- }
-
- close (fd);
- if (strncmp (sig, "From ", 5) != 0) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-elm_import_mbox (CamelFolder *folder,
- const char *filename)
-{
- gboolean done = FALSE;
- CamelException *ex;
- CamelMimeParser *mp;
- int fd, n = 0;
-
- fd = open (filename, O_RDONLY);
- if (fd == -1) {
- g_warning ("Cannot open %s", filename);
- return FALSE;
- }
-
- camel_object_ref (CAMEL_OBJECT (folder));
- camel_folder_freeze (folder);
-
- ex = camel_exception_new ();
- mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mp, TRUE);
- if (camel_mime_parser_init_with_fd (mp, fd) == -1) {
- g_warning ("Unable to process file %s", filename);
- camel_object_unref (CAMEL_OBJECT (mp));
- camel_folder_thaw (folder);
- camel_object_unref (CAMEL_OBJECT (folder));
- return FALSE;
- }
-
- while (camel_mime_parser_step (mp, 0, 0) == HSCAN_FROM) {
- /* Import the next message */
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
-
- msg = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg),
- mp) == -1) {
- g_warning ("Failed message %d", n);
- camel_object_unref (CAMEL_OBJECT (msg));
- done = TRUE;
- }
-
- info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (folder, msg, info, ex);
- g_free (info);
- camel_object_unref (CAMEL_OBJECT (msg));
- if (camel_exception_is_set (ex)) {
- g_warning ("Failed message %d", n);
- done = TRUE;
- }
-
- if (!done) {
- n++;
- camel_mime_parser_step (mp, 0, 0);
- }
- }
-
- camel_folder_sync (folder, FALSE, ex);
- camel_folder_thaw (folder);
- camel_object_unref (CAMEL_OBJECT (folder));
- done = TRUE;
-
- camel_exception_free (ex);
- return done;
-}
-
-static void
-elm_import_file (ElmImporter *importer,
- const char *path,
- const char *fullpath)
-{
- char *protocol;
- CamelException *ex;
- CamelFolder *folder;
-
- g_warning ("Importing %s into %s", path, fullpath);
- protocol = g_strconcat ("file://", fullpath, NULL);
- ex = camel_exception_new ();
- folder = mail_tool_uri_to_folder (protocol, ex);
- g_free (protocol);
-
- if (camel_exception_is_set (ex)) {
- camel_exception_free (ex);
- return;
- }
- camel_exception_free (ex);
-
- if (folder == NULL) {
- return;
- }
-
- elm_import_mbox (folder, path);
-}
-
-static gboolean
-is_kmail (const char *maildir)
-{
- char *names[5] =
- {
- "inbox",
- "outbox",
- "sent-mail",
- "trash",
- "drafts"
- };
- int i;
-
- for (i = 0; i < 5; i++) {
- char *file, *index, *tmp;
-
- file = g_concat_dir_and_file (maildir, names[i]);
- tmp = g_strdup_printf (".%s.index", names[i]);
- index = g_concat_dir_and_file (maildir, tmp);
- g_free (tmp);
-
- if (!g_file_exists (file) ||
- !g_file_exists (index)) {
- g_free (index);
- g_free (file);
- return FALSE;
- }
-
- g_free (index);
- g_free (file);
- }
-
- return TRUE;
-}
-
-static gboolean
-elm_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- ElmImporter *importer = closure;
- FILE *prefs_handle;
- char *key, *maildir;
- gboolean exists;
-
- /* Already imported */
- key = g_strdup_printf ("=%s/config/Mail=/importers/", evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
-
- if (gnome_config_get_bool (KEY) == TRUE) {
- gnome_config_pop_prefix ();
- return FALSE;
- }
- gnome_config_pop_prefix ();
-
- /* Elm uses ~/Mail
- Alas so does MH and KMail. */
- maildir = gnome_util_prepend_user_home ("Mail");
- exists = g_file_exists (maildir);
-
- if (exists) {
- char *mh, *mhdir;
-
- /* Check for some other files to work out what it is. */
-
- /* MH? */
- mh = g_concat_dir_and_file (maildir, "context");
- mhdir = g_concat_dir_and_file (maildir, "inbox");
- if (g_file_exists (mh) &&
- g_file_test (mhdir, G_FILE_TEST_ISDIR)) {
- exists = FALSE; /* Probably MH */
- }
-
- g_free (mh);
- g_free (mhdir);
- }
-
- if (exists) {
- /* Check for KMail stuff */
- exists = !is_kmail (maildir);
- }
-
- g_free (maildir);
-
- return exists;
-}
-
-static void
-scan_dir (ElmImporter *importer,
- const char *dirname,
- const char *orig_parent)
-{
- DIR *maildir;
- struct stat buf;
- struct dirent *current;
-
- maildir = opendir (dirname);
- if (maildir == NULL) {
- g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno));
- return;
- }
-
- current = readdir (maildir);
- while (current) {
- 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, fullname, subdir);
- g_free (subdir);
- }
-
- g_free (fullname);
- current = readdir (maildir);
- }
-}
-
-static void
-folder_created_cb (BonoboListener *listener,
- const char *event_name,
- const BonoboArg *event_data,
- CORBA_Environment *ev,
- ElmImporter *importer)
-{
- ElmFolder *folder;
- GList *l;
- GNOME_Evolution_Storage_FolderResult *result;
- char *fullpath;
-
- if (strcmp (event_name, "evolution-shell:folder_created") != 0) {
- return; /* Unknown event notification */
- }
-
- result = event_data->_value;
- fullpath = result->path;
-
- l = importer->dir_list;
- importer->dir_list = g_list_remove_link (importer->dir_list, l);
- folder = l->data;
- g_list_free_1 (l);
-
- /* We got the folder, so try to import the file into it. */
- if (folder->path != NULL && elm_is_mbox (folder->path)) {
- elm_import_file (importer, folder->path, fullpath);
- }
-
- g_free (folder->path);
- g_free (folder->parent);
- g_free (folder->foldername);
- g_free (folder);
-
- if (importer->dir_list) {
- /* Do the next in the list */
- folder = importer->dir_list->data;
- mail_importer_create_folder (folder->parent, folder->foldername,
- NULL, importer->listener);
- }
-}
-
-static void
-elm_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- ElmFolder *folder;
- ElmImporter *importer = closure;
- char *maildir, *key;
-
- maildir = gnome_util_prepend_user_home ("Mail");
- scan_dir (importer, maildir, "/");
- g_free (maildir);
-
- if (importer->dir_list == NULL)
- return;
-
- folder = importer->dir_list->data;
- mail_importer_create_folder (folder->parent, folder->foldername, NULL,
- importer->listener);
-
- key = g_strdup_printf ("=%s/config/Mail=/importers/", evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool (KEY, TRUE);
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-}
-
-static BonoboObject *
-elm_factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- ElmImporter *elm;
- char *message = N_("Evolution has found Elm mail files.\n"
- "Would you like to import them into Evolution?");
-
- elm = g_new0 (ElmImporter, 1);
- elm->listener = bonobo_listener_new (NULL, NULL);
- gtk_signal_connect (GTK_OBJECT (elm->listener), "event_notify",
- GTK_SIGNAL_FUNC (folder_created_cb), elm);
-
- importer = evolution_intelligent_importer_new (elm_can_import,
- elm_create_structure,
- _("Elm mail"),
- _(message), elm);
-
- 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 (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 dcdf0f75ad..ef9b9f1ca5 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -115,6 +115,7 @@ process_item_fn (EvolutionImporter *eimporter,
}
camel_exception_free (ex);
+ g_print ("Notifying...\n");
GNOME_Evolution_ImporterListener_notifyResult (listener,
GNOME_Evolution_ImporterListener_OK,
!done, ev);
@@ -168,6 +169,40 @@ importer_destroy_cb (GtkObject *object,
g_free (mbi);
}
+static void
+folder_created_cb (BonoboListener *listener,
+ const char *event_name,
+ const BonoboArg *event_data,
+ CORBA_Environment *ev,
+ MailImporter *importer)
+{
+ char *fullpath;
+ GNOME_Evolution_Storage_FolderResult *result;
+ CamelException *ex;
+
+ if (strcmp (event_name, "evolution-shell:folder_created") != 0) {
+ return; /* Unknown event */
+ }
+
+ result = event_data->_value;
+ fullpath = g_strconcat ("file://", result->path, NULL);
+
+ ex = camel_exception_new ();
+ importer->folder = mail_tool_uri_to_folder (fullpath, ex);
+
+ if (camel_exception_is_set (ex)) {
+ g_warning ("Error opening %s", fullpath);
+ camel_exception_free (ex);
+
+ g_free (fullpath);
+ return;
+ }
+
+ g_warning ("%s created", fullpath);
+ g_free (fullpath);
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+}
+
static gboolean
load_file_fn (EvolutionImporter *eimporter,
const char *filename,
@@ -178,6 +213,7 @@ load_file_fn (EvolutionImporter *eimporter,
MailImporter *importer;
int fd;
+ g_warning ("%s", __FUNCTION__);
mbi = (MboxImporter *) closure;
importer = (MailImporter *) mbi;
@@ -199,8 +235,28 @@ load_file_fn (EvolutionImporter *eimporter,
importer->mstream = NULL;
if (folderpath == NULL || *folderpath == '\0')
importer->folder = mail_tool_get_local_inbox (NULL);
- else
- importer->folder = mail_tool_uri_to_folder (folderpath, NULL);
+ else {
+ char *parent, *name;
+ BonoboListener *listener;
+
+ /* Make a new directory */
+ name = strrchr (folderpath, '/');
+ if (name == NULL) {
+ parent = g_strdup ("/");
+ name = folderpath;
+ } else {
+ name += 1;
+ parent = g_dirname (folderpath);
+ }
+
+ listener = bonobo_listener_new (NULL, NULL);
+ gtk_signal_connect (GTK_OBJECT (listener), "event-notify",
+ GTK_SIGNAL_FUNC (folder_created_cb),
+ importer);
+
+ mail_importer_create_folder (parent, name, NULL, listener);
+ g_free (parent);
+ }
if (importer->folder == NULL){
g_print ("Bad folder\n");
@@ -232,7 +288,8 @@ mbox_factory_fn (BonoboGenericFactory *_factory,
process_item_fn, NULL, mbox);
gtk_signal_connect (GTK_OBJECT (importer), "destroy",
GTK_SIGNAL_FUNC (importer_destroy_cb), mbox);
-
+
+ g_warning ("Returning");
return BONOBO_OBJECT (importer);
}
diff --git a/mail/importers/netscape-importer.c b/mail/importers/netscape-importer.c
deleted file mode 100644
index 64effc7b4d..0000000000
--- a/mail/importers/netscape-importer.c
+++ /dev/null
@@ -1,473 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* netscape-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <camel/camel-mime-message.h>
-#include <camel/camel-mime-part.h>
-#include <camel/camel-exception.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include <evolution-storage.h>
-
-#include "mail-importer.h"
-#include "mail-tools.h"
-
-static char *nsmail_dir = NULL;
-
-extern char *evolution_dir;
-
-#define NETSCAPE_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Netscape_Intelligent_Importer_Factory"
-#define MBOX_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Mbox_ImporterFactory"
-#define KEY "netscape-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- MailImporter importer;
- GList *dir_list;
-
- int num;
- CamelMimeParser *mp;
- BonoboListener *listener;
-} NetscapeImporter;
-
-void mail_importer_module_init (void);
-void g_module_unload (void);
-
-static gboolean
-netscape_import_mbox (CamelFolder *folder,
- const char *filename)
-{
- gboolean done = FALSE;
- CamelException *ex;
- CamelMimeParser *mp;
- int fd, n = 0;
-
- fd = open (filename, O_RDONLY);
- if (fd == -1) {
- g_warning ("Cannot open %s", filename);
- return FALSE;
- }
-
- camel_object_ref (CAMEL_OBJECT (folder));
- camel_folder_freeze (folder);
-
- ex = camel_exception_new ();
- mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mp, TRUE);
- if (camel_mime_parser_init_with_fd (mp, fd) == -1) {
- g_warning ("Unable to process file %s", filename);
- camel_object_unref (CAMEL_OBJECT (mp));
- camel_folder_thaw (folder);
- camel_object_unref (CAMEL_OBJECT (folder));
- return FALSE;
- }
-
- while (camel_mime_parser_step (mp, 0, 0) == HSCAN_FROM) {
- /* Import the next message */
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
-
- msg = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg),
- mp) == -1) {
- g_warning ("Failed message %d", n);
- camel_object_unref (CAMEL_OBJECT (msg));
- done = TRUE;
- }
-
- info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (folder, msg, info, ex);
- g_free (info);
- camel_object_unref (CAMEL_OBJECT (msg));
- if (camel_exception_is_set (ex)) {
- g_warning ("Failed message %d", n);
- done = TRUE;
- }
-
- if (!done) {
- n++;
- camel_mime_parser_step (mp, 0, 0);
- }
- }
-
- camel_folder_sync (folder, FALSE, ex);
- camel_folder_thaw (folder);
- camel_object_unref (CAMEL_OBJECT (folder));
- done = TRUE;
-
- camel_exception_free (ex);
- return done;
-}
-
-static void
-netscape_clean_up (void)
-{
- if (nsmail_dir == NULL)
- return;
-
- g_free (nsmail_dir);
- nsmail_dir = NULL;
-}
-
-static gboolean
-netscape_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- char *nsprefs;
- FILE *prefs_handle;
- char *key;
-
- /* Already imported */
- key = g_strdup_printf ("=%s/config/Mail=/importers/", evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
-
- if (gnome_config_get_bool (KEY) == TRUE) {
- gnome_config_pop_prefix ();
- return FALSE;
- }
- gnome_config_pop_prefix ();
-
- 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"));
- return FALSE;
- }
-
- /* Find the user mail dir */
- while (1) {
- char line[4096];
-
- fgets (line, 4096, prefs_handle);
- if (line == NULL) {
- g_warning ("No mail.directory entry");
- fclose (prefs_handle);
- return FALSE;
- }
-
- if (strstr (line, "mail.directory") != NULL) {
- char *sep, *start, *end;
- /* Found the line */
-
- sep = strchr (line, ',');
- if (sep == NULL) {
- g_warning ("Bad line %s", line);
- fclose (prefs_handle);
- return FALSE;
- }
-
- start = strchr (sep, '\"') + 1;
- if (start == NULL) {
- g_warning ("Bad line %s", line);
- fclose (prefs_handle);
- return FALSE;
- }
-
- end = strrchr (sep, '\"');
- if (end == NULL) {
- g_warning ("Bad line %s", line);
- fclose (prefs_handle);
- return FALSE;
- }
-
- nsmail_dir = g_strndup (start, end - start);
- d(g_warning ("Got nsmail_dir: %s", nsmail_dir));
- fclose (prefs_handle);
- return TRUE;
- }
- }
-}
-
-static void
-netscape_import_file (NetscapeImporter *importer,
- const char *path,
- const char *fullpath)
-{
- char *protocol;
- CamelException *ex;
- CamelFolder *folder;
-
- /* Do import */
- d(g_warning ("Importing %s as %s\n", filename, fullpath));
-
- ex = camel_exception_new ();
- protocol = g_strconcat ("file://", fullpath, NULL);
- folder = mail_tool_uri_to_folder (protocol, ex);
- if (camel_exception_is_set (ex)) {
- g_free (protocol);
- camel_exception_free (ex);
- return;
- }
-
- g_free (protocol);
-
- if (folder == NULL) {
- g_warning ("Folder for %s is NULL", fullpath);
- camel_exception_free (ex);
- return;
- }
-
- camel_exception_free (ex);
-
- netscape_import_mbox (folder, path);
-}
-
-typedef struct {
- NetscapeImporter *importer;
- char *parent;
- char *path;
- char *foldername;
-} NetscapeCreateDirectoryData;
-
-static void
-netscape_dir_created (BonoboListener *listener,
- const char *event_name,
- const BonoboArg *event_data,
- CORBA_Environment *ev,
- NetscapeImporter *importer)
-{
- EvolutionStorageResult storage_result;
- NetscapeCreateDirectoryData *data;
- GList *l;
- GNOME_Evolution_Storage_FolderResult *result;
- char *fullpath;
-
- if (strcmp (event_name, "evolution-shell:folder_created") != 0) {
- return; /* Unknown event notification */
- }
-
- result = event_data->_value;
- storage_result = result->result;
- fullpath = result->path;
-
- g_warning ("path: %s\tresult: %d", fullpath, storage_result);
-
- l = importer->dir_list;
- importer->dir_list = g_list_remove_link (importer->dir_list, l);
- data = l->data;
- g_list_free_1 (l);
-
- /* Import the file */
- /* We got the folder, so try to import the file into it. */
- if (fullpath != NULL || *fullpath != '\0')
- netscape_import_file (data->importer, data->path, fullpath);
-
- g_free (data->parent);
- g_free (data->path);
- g_free (data->foldername);
- g_free (data);
-
- if (importer->dir_list) {
- /* Do the next in the list */
- data = importer->dir_list->data;
- mail_importer_create_folder (data->parent, data->foldername,
- NULL, importer->listener);
- }
-}
-
-static char *
-maybe_replace_name (const char *original_name)
-{
- if (strcmp (original_name, "Trash") == 0) {
- return g_strdup ("Netscape-Trash"); /* Trash is an invalid name */
- } else if (strcmp (original_name, "Unsent Messages") == 0) {
- return g_strdup ("Outbox");
- }
-
- return g_strdup (original_name);
-}
-
-/* This function basically flattens the tree structure.
- It makes a list of all the directories that are to be imported. */
-static void
-scan_dir (NetscapeImporter *importer,
- const char *orig_parent,
- const char *dirname)
-{
- DIR *nsmail;
- struct stat buf;
- struct dirent *current;
-
- nsmail = opendir (dirname);
- if (nsmail == NULL) {
- d(g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno)));
- return;
- }
-
- current = readdir (nsmail);
- while (current) {
- char *fullname, *foldername;
-
- /* Ignore things which start with .
- which should be ., .., and the summaries. */
- if (current->d_name[0] =='.') {
- current = readdir (nsmail);
- continue;
- }
-
- if (*orig_parent == '/') {
- foldername = maybe_replace_name (current->d_name);
- } else {
- foldername = g_strdup (current->d_name);
- }
-
- fullname = g_concat_dir_and_file (dirname, current->d_name);
- if (stat (fullname, &buf) == -1) {
- d(g_warning ("Could not stat %s\nstat returned:%s",
- fullname, g_strerror (errno)));
- current = readdir (nsmail);
- g_free (fullname);
- continue;
- }
-
- if (S_ISREG (buf.st_mode)) {
- char *sbd, *parent;
- NetscapeCreateDirectoryData *data;
-
- d(g_print ("File: %s\n", fullname));
-
- data = g_new0 (NetscapeCreateDirectoryData, 1);
- data->importer = importer;
- data->parent = g_strdup (orig_parent);
- data->path = g_strdup (fullname);
- data->foldername = g_strdup (foldername);
-
- importer->dir_list = g_list_append (importer->dir_list,
- data);
-
-
- parent = g_concat_dir_and_file (orig_parent,
- data->foldername);
-
- /* Check if a .sbd folder exists */
- sbd = g_strconcat (fullname, ".sbd", NULL);
- if (g_file_exists (sbd)) {
- scan_dir (importer, parent, sbd);
- }
-
- g_free (parent);
- g_free (sbd);
- }
-
- g_free (fullname);
- g_free (foldername);
- current = readdir (nsmail);
- }
-}
-
-static void
-netscape_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- NetscapeImporter *importer = closure;
- NetscapeCreateDirectoryData *data;
- char *key;
-
- g_return_if_fail (nsmail_dir != NULL);
-
- scan_dir (importer, "/", nsmail_dir);
-
- importer->listener = bonobo_listener_new (NULL, NULL);
- gtk_signal_connect (GTK_OBJECT (importer->listener), "event_notify",
- GTK_SIGNAL_FUNC (netscape_dir_created), importer);
- data = importer->dir_list->data;
- mail_importer_create_folder (data->parent, data->foldername, NULL,
- importer->listener);
-
- key = g_strdup_printf ("=%s/config/Mail=/importers/", evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool (KEY, TRUE);
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-}
-
-static BonoboObject *
-netscape_factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- NetscapeImporter *netscape;
- char *message = N_("Evolution has found Netscape mail files.\n"
- "Would you like them to be imported into Evolution?");
-
- netscape = g_new0 (NetscapeImporter, 1);
- importer = evolution_intelligent_importer_new (netscape_can_import,
- netscape_create_structure,
- "Netscape mail",
- message, netscape);
- 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 (NETSCAPE_INTELLIGENT_IMPORTER_IID,
- netscape_factory_fn, NULL);
- if (factory == NULL)
- g_warning ("Could not initialise Netscape Intelligent Mail Importer.");
- initialised = TRUE;
-}
-
-/* GModule g_module_unload routine */
-void
-g_module_unload (void)
-{
- netscape_clean_up ();
-}
diff --git a/mail/importers/pine-importer.c b/mail/importers/pine-importer.c
deleted file mode 100644
index 310eea3483..0000000000
--- a/mail/importers/pine-importer.c
+++ /dev/null
@@ -1,416 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* pine-importer.c
- *
- * Authors:
- * Iain Holmes <iain@ximian.com>
- *
- * Copyright 2001 Ximian, Inc. (http://www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
-
-#include <glib.h>
-
-#include <bonobo/bonobo-object.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <camel/camel-mime-message.h>
-#include <camel/camel-mime-part.h>
-#include <camel/camel-exception.h>
-
-#include <importer/evolution-intelligent-importer.h>
-#include <importer/GNOME_Evolution_Importer.h>
-#include "mail-importer.h"
-#include "mail-tools.h"
-
-extern char *evolution_dir;
-
-#define PINE_INTELLIGENT_IMPORTER_IID "OAFIID:GNOME_Evolution_Mail_Pine_Intelligent_Importer_Factory"
-#define KEY "pine-mail-imported"
-
-/*#define SUPER_IMPORTER_DEBUG*/
-#ifdef SUPER_IMPORTER_DEBUG
-#define d(x) x
-#else
-#define d(x)
-#endif
-
-typedef struct {
- MailImporter importer;
- GList *dir_list;
-
- int num;
- CamelMimeParser *mp;
- BonoboListener *listener;
-} PineImporter;
-
-typedef struct {
- char *parent;
- char *foldername;
- char *path;
-} PineFolder;
-
-/* Prototype */
-
-void mail_importer_module_init (void);
-
-
-static gboolean
-pine_is_mbox (const char *filename)
-{
- char sig[5];
- int fd;
-
- fd = open (filename, O_RDONLY);
- if (read (fd, sig, 5) != 5) {
- close (fd);
- return FALSE;
- }
-
- close (fd);
- if (strncmp (sig, "From ", 5) != 0) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-static gboolean
-pine_import_mbox (CamelFolder *folder,
- const char *filename)
-{
- gboolean done = FALSE;
- CamelException *ex;
- CamelMimeParser *mp;
- int fd, n = 0;
-
- fd = open (filename, O_RDONLY);
- if (fd == -1) {
- g_warning ("Cannot open %s", filename);
- return FALSE;
- }
-
- camel_object_ref (CAMEL_OBJECT (folder));
- camel_folder_freeze (folder);
-
- ex = camel_exception_new ();
- mp = camel_mime_parser_new ();
- camel_mime_parser_scan_from (mp, TRUE);
- if (camel_mime_parser_init_with_fd (mp, fd) == -1) {
- g_warning ("Unable to process file %s", filename);
- camel_object_unref (CAMEL_OBJECT (mp));
- camel_folder_thaw (folder);
- camel_object_unref (CAMEL_OBJECT (folder));
- return FALSE;
- }
-
- while (camel_mime_parser_step (mp, 0, 0) == HSCAN_FROM) {
- /* Import the next message */
- CamelMimeMessage *msg;
- CamelMessageInfo *info;
-
- msg = camel_mime_message_new ();
- if (camel_mime_part_construct_from_parser (CAMEL_MIME_PART (msg),
- mp) == -1) {
- g_warning ("Failed message %d", n);
- camel_object_unref (CAMEL_OBJECT (msg));
- done = TRUE;
- }
-
- info = g_new0 (CamelMessageInfo, 1);
- camel_folder_append_message (folder, msg, info, ex);
- g_free (info);
- camel_object_unref (CAMEL_OBJECT (msg));
- if (camel_exception_is_set (ex)) {
- g_warning ("Failed message %d", n);
- done = TRUE;
- }
-
- if (!done) {
- n++;
- camel_mime_parser_step (mp, 0, 0);
- }
- }
-
- camel_folder_sync (folder, FALSE, ex);
- camel_folder_thaw (folder);
- camel_object_unref (CAMEL_OBJECT (folder));
- done = TRUE;
-
- camel_exception_free (ex);
- return done;
-}
-
-static void
-pine_import_file (PineImporter *importer,
- const char *path,
- const char *fullpath)
-{
- char *protocol;
- CamelException *ex;
- CamelFolder *folder;
-
- g_warning ("Importing %s into %s", path, fullpath);
- protocol = g_strconcat ("file://", fullpath, NULL);
- ex = camel_exception_new ();
- folder = mail_tool_uri_to_folder (protocol, ex);
- g_free (protocol);
-
- if (camel_exception_is_set (ex)) {
- camel_exception_free (ex);
- return;
- }
- camel_exception_free (ex);
-
- if (folder == NULL) {
- return;
- }
-
- pine_import_mbox (folder, path);
-}
-
-static gboolean
-pine_can_import (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- PineImporter *importer = closure;
- FILE *prefs_handle;
- char *key, *maildir;
- gboolean exists;
-
- /* Already imported */
- key = g_strdup_printf ("=%s/config/Mail=/importers/", evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
-
- if (gnome_config_get_bool (KEY) == TRUE) {
- gnome_config_pop_prefix ();
- return FALSE;
- }
- gnome_config_pop_prefix ();
-
- maildir = gnome_util_prepend_user_home ("mail");
- exists = g_file_exists (maildir);
- g_free (maildir);
-
- return exists;
-}
-
-/* Pine uses sent-mail and saved-mail whereas Evolution uses Sent and Drafts */
-static char *
-maybe_replace_name (const char *original_name)
-{
- if (strcmp (original_name, "sent-mail") == 0) {
- return g_strdup ("Sent");
- } else if (strcmp (original_name, "saved-messages") == 0) {
- return g_strdup ("Drafts");
- }
-
- return g_strdup (original_name);
-}
-
-static void
-scan_dir (PineImporter *importer,
- const char *dirname,
- const char *orig_parent)
-{
- DIR *maildir;
- struct stat buf;
- struct dirent *current;
-
- maildir = opendir (dirname);
- if (maildir == NULL) {
- g_warning ("Could not open %s\nopendir returned: %s",
- dirname, g_strerror (errno));
- return;
- }
-
- current = readdir (maildir);
- while (current) {
- PineFolder *pf;
- char *fullname, *foldername;
-
- /* Ignore . and .. */
- if (current->d_name[0] == '.') {
- if (current->d_name[1] == '\0' ||
- (current->d_name[1] == '.' && current->d_name[2] == '\0')) {
- current = readdir (maildir);
- continue;
- }
- }
-
- if (*orig_parent == '/') {
- foldername = maybe_replace_name (current->d_name);
- } else {
- foldername = g_strdup (current->d_name);
- }
-
- fullname = g_concat_dir_and_file (dirname, current->d_name);
- if (stat (fullname, &buf) == -1) {
- g_warning ("Could not stat %s\nstat returned: %s",
- fullname, g_strerror (errno));
- current = readdir (maildir);
- g_free (fullname);
- continue;
- }
-
- if (S_ISREG (buf.st_mode)) {
- pf = g_new (PineFolder, 1);
- pf->path = g_strdup (fullname);
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (foldername);
- importer->dir_list = g_list_append (importer->dir_list, pf);
- } else if (S_ISDIR (buf.st_mode)) {
- char *subdir;
-
- pf = g_new (PineFolder, 1);
- pf->path = NULL;
- pf->parent = g_strdup (orig_parent);
- pf->foldername = g_strdup (foldername);
- importer->dir_list = g_list_append (importer->dir_list, pf);
-
- subdir = g_concat_dir_and_file (orig_parent, foldername);
- scan_dir (importer, fullname, subdir);
- g_free (subdir);
- }
-
- g_free (fullname);
- g_free (foldername);
- current = readdir (maildir);
- }
-}
-
-static void
-folder_created_cb (BonoboListener *listener,
- const char *event_name,
- const BonoboArg *event_data,
- CORBA_Environment *ev,
- PineImporter *importer)
-{
- PineFolder *folder;
- GList *l;
- GNOME_Evolution_Storage_FolderResult *result;
- char *fullpath;
-
- if (strcmp (event_name, "evolution-shell:folder_created") != 0) {
- return; /* Unknown event notification */
- }
-
- result = event_data->_value;
- fullpath = result->path;
-
- l = importer->dir_list;
- importer->dir_list = g_list_remove_link (importer->dir_list, l);
- folder = l->data;
- g_list_free_1 (l);
-
- /* We got the folder, so try to import the file into it. */
- if (folder->path != NULL && pine_is_mbox (folder->path)) {
- pine_import_file (importer, folder->path, fullpath);
- }
-
- g_free (folder->path);
- g_free (folder->parent);
- g_free (folder->foldername);
- g_free (folder);
-
- if (importer->dir_list) {
- /* Do the next in the list */
- folder = importer->dir_list->data;
- mail_importer_create_folder (folder->parent, folder->foldername,
- NULL, importer->listener);
- }
-}
-
-static void
-pine_create_structure (EvolutionIntelligentImporter *ii,
- void *closure)
-{
- PineFolder *folder;
- PineImporter *importer = closure;
- char *maildir, *key;
-
- maildir = gnome_util_prepend_user_home ("mail");
- scan_dir (importer, maildir, "/");
- g_free (maildir);
-
- if (importer->dir_list == NULL)
- return;
-
- folder = importer->dir_list->data;
- mail_importer_create_folder (folder->parent, folder->foldername, NULL,
- importer->listener);
-
- key = g_strdup_printf ("=%s/config/Mail=/importers/", evolution_dir);
- gnome_config_push_prefix (key);
- g_free (key);
-
- gnome_config_set_bool (KEY, TRUE);
- gnome_config_pop_prefix ();
-
- gnome_config_sync ();
- gnome_config_drop_all ();
-
-}
-
-static BonoboObject *
-pine_factory_fn (BonoboGenericFactory *_factory,
- void *closure)
-{
- EvolutionIntelligentImporter *importer;
- PineImporter *pine;
- char *message = N_("Evolution has found Pine mail files.\n"
- "Would you like to import them into Evolution?");
-
- pine = g_new0 (PineImporter, 1);
- pine->listener = bonobo_listener_new (NULL, NULL);
- gtk_signal_connect (GTK_OBJECT (pine->listener), "event_notify",
- GTK_SIGNAL_FUNC (folder_created_cb), pine);
-
- importer = evolution_intelligent_importer_new (pine_can_import,
- pine_create_structure,
- _("Pine mail"),
- _(message), pine);
-
- 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 (PINE_INTELLIGENT_IMPORTER_IID,
- pine_factory_fn, NULL);
- if (factory == NULL)
- g_warning ("Could not initialise Pine Intelligent Mail Importer.");
- initialised = TRUE;
-}
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index 434634c5c6..971d83773c 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -702,6 +702,9 @@ setup_service (MailAccountGuiService *gsvc, MailConfigService *service)
CamelURL *url = camel_url_new (service->url, NULL);
gboolean has_auth = FALSE;
+ if (url == NULL)
+ return;
+
if (url->user && CAMEL_PROVIDER_ALLOWS (gsvc->provider, CAMEL_URL_PART_USER))
gtk_entry_set_text (gsvc->username, url->user);
if (url->host && CAMEL_PROVIDER_ALLOWS (gsvc->provider, CAMEL_URL_PART_HOST)) {
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 98c8350903..4e1741db63 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -1463,6 +1463,8 @@ filter_edit (BonoboUIComponent *uih, void *user_data, const char *path)
}
dialog = (GtkWidget *)filter_editor_new (fc, filter_source_names);
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Filters"));
+
gtk_object_set_data_full (GTK_OBJECT (dialog), "context", fc, (GtkDestroyNotify)gtk_object_unref);
gtk_signal_connect (GTK_OBJECT (dialog), "clicked", filter_druid_clicked, fb);
gtk_widget_show (GTK_WIDGET (dialog));
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 52f8e5306c..46ffe62e2a 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -35,6 +35,8 @@
#include <gtkhtml/gtkhtml.h>
#include <glade/glade.h>
+#include <bonobo/bonobo-object.h>
+
#include <gal/util/e-util.h>
#include <e-util/e-html-utils.h>
#include <e-util/e-url.h>
@@ -43,6 +45,8 @@
#include "mail-ops.h"
#include "mail-mt.h"
+#include "Mail.h"
+
typedef struct {
gboolean thread_list;
gboolean view_source;
@@ -64,6 +68,8 @@ typedef struct {
static const char GCONFPATH[] = "/apps/Evolution/Mail";
static MailConfig *config = NULL;
+#define MAIL_CONFIG_IID "OAFIID:GNOME_Evolution_MailConfig_Factory"
+
/* Prototypes */
static void config_read (void);
@@ -1136,3 +1142,107 @@ mail_config_check_service (const char *url, CamelProviderType type, GList **auth
return ret;
}
+
+/* MailConfig Bonobo object */
+#define PARENT_TYPE BONOBO_X_OBJECT_TYPE
+static BonoboObjectClass *parent_class = NULL;
+
+static void
+impl_GNOME_Evolution_MailConfig_addAccount (PortableServer_Servant servant,
+ const GNOME_Evolution_MailConfig_Account *account,
+ CORBA_Environment *ev)
+{
+ GNOME_Evolution_MailConfig_Service source, transport;
+ GNOME_Evolution_MailConfig_Identity id;
+ MailConfigAccount *mail_account;
+ MailConfigService *mail_service;
+ MailConfigIdentity *mail_id;
+
+ mail_account = g_new0 (MailConfigAccount, 1);
+ mail_account->name = g_strdup (account->name);
+ mail_account->default_account = account->default_account;
+
+ /* Copy ID */
+ id = account->id;
+ mail_id = g_new0 (MailConfigIdentity, 1);
+ mail_id->name = g_strdup (id.name);
+ mail_id->address = g_strdup (id.address);
+ mail_id->organization = g_strdup (id.organization);
+ mail_id->signature = g_strdup (id.signature);
+
+ mail_account->id = mail_id;
+
+ /* Copy source */
+ source = account->source;
+ mail_service = g_new0 (MailConfigService, 1);
+ mail_service->url = g_strdup (source.url);
+ mail_service->keep_on_server = source.keep_on_server;
+ mail_service->auto_check = source.auto_check;
+ mail_service->auto_check_time = source.auto_check_time;
+ mail_service->save_passwd = source.save_passwd;
+ mail_service->enabled = source.enabled;
+
+ mail_account->source = mail_service;
+
+ /* Copy transport */
+ transport = account->transport;
+ mail_service = g_new0 (MailConfigService, 1);
+ mail_service->url = g_strdup (transport.url);
+ mail_service->keep_on_server = transport.keep_on_server;
+ mail_service->auto_check = transport.auto_check;
+ mail_service->auto_check_time = transport.auto_check_time;
+ mail_service->save_passwd = transport.save_passwd;
+ mail_service->enabled = transport.enabled;
+
+ mail_account->transport = mail_service;
+
+ /* Add new account */
+ mail_config_add_account (mail_account);
+}
+
+static void
+evolution_mail_config_class_init (EvolutionMailConfigClass *klass)
+{
+ POA_GNOME_Evolution_MailConfig__epv *epv = &klass->epv;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+ epv->addAccount = impl_GNOME_Evolution_MailConfig_addAccount;
+}
+
+static void
+evolution_mail_config_init (EvolutionMailConfig *config)
+{
+}
+
+BONOBO_X_TYPE_FUNC_FULL (EvolutionMailConfig,
+ GNOME_Evolution_MailConfig,
+ PARENT_TYPE,
+ evolution_mail_config);
+
+static BonoboObject *
+evolution_mail_config_factory_fn (BonoboObject *factory,
+ void *closure)
+{
+ EvolutionMailConfig *config;
+
+ g_warning ("Made");
+ config = gtk_type_new (evolution_mail_config_get_type ());
+ return BONOBO_OBJECT (config);
+}
+
+void
+evolution_mail_config_factory_init (void)
+{
+ BonoboObject *factory;
+
+ g_warning ("Starting mail config");
+ factory = bonobo_generic_factory_new (MAIL_CONFIG_IID,
+ evolution_mail_config_factory_fn,
+ NULL);
+ if (factory == NULL) {
+ g_warning ("Error starting MailConfig");
+ }
+
+ g_warning ("Registered");
+ bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
+}
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 10c403389f..896b914249 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -26,6 +26,10 @@
#include <glib.h>
#include <camel/camel.h>
+#include <bonobo/bonobo-xobject.h>
+
+#include "Mail.h"
+
#ifdef __cplusplus
extern "C" {
#pragma }
@@ -139,6 +143,20 @@ char *mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix);
gboolean mail_config_check_service (const char *url, CamelProviderType type, GList **authtypes);
+/* For the bonobo object */
+typedef struct _EvolutionMailConfig EvolutionMailConfig;
+typedef struct _EvolutionMailConfigClass EvolutionMailConfigClass;
+
+struct _EvolutionMailConfig {
+ BonoboXObject parent;
+};
+
+struct _EvolutionMailConfigClass {
+ BonoboXObjectClass parent_class;
+
+ POA_GNOME_Evolution_MailConfig__epv epv;
+};
+
#ifdef __cplusplus
}
#endif /* __cplusplus */