From 4590eb4220de4935a55b3cc82cc4b96d2c9a8436 Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Mon, 2 Apr 2001 21:16:39 +0000 Subject: Check for KMail files. svn path=/trunk/; revision=9103 --- mail/ChangeLog | 11 ++++++++ mail/importers/elm-importer.c | 60 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 183887dfea..921f31a7cb 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,14 @@ +2001-04-02 Iain Holmes + + * importers/elm-importer.c (elm_can_import): Call is_kmail to check for + KMail files. + (is_kmail): Checks if the given directory is a KMail directory. + +2001-04-02 Iain Holmes + + * importers/elm-importer.c (elm_can_import): Check for some MH files + to make sure that the dir really is an Elm dir. + 2001-04-02 Dan Winship * mail-account-gui.c: Add a "provider_type" arg to diff --git a/mail/importers/elm-importer.c b/mail/importers/elm-importer.c index 426120a1b1..1394d0f279 100644 --- a/mail/importers/elm-importer.c +++ b/mail/importers/elm-importer.c @@ -188,6 +188,41 @@ elm_import_file (ElmImporter *importer, 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) @@ -208,8 +243,33 @@ elm_can_import (EvolutionIntelligentImporter *ii, } 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; -- cgit v1.2.3