Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 92373f4c authored by Laurent Montel's avatar Laurent Montel 😁

Fix Bug 342834 - ImportWizard fails to detect Icedove email client even while it is running

FIXED-IN: 14.12.2
BUG: 342834
parent 7869ab32
......@@ -55,6 +55,7 @@ trojita/trojitaimportdata.cpp
trojita/trojitaaddressbook.cpp
kmail1/kmail1importdata.cpp
kmail1/kmail1settings.cpp
icedove/icedoveimportdata.cpp
)
include_directories(${CMAKE_SOURCE_DIR}/mailimporter
......
/*
Copyright (c) 2012-2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "icedoveimportdata.h"
#include "importfilterinfogui.h"
#include "thunderbird/thunderbirdsettings.h"
#include "thunderbird/thunderbirdaddressbook.h"
#include "mailimporter/filtericedove.h"
#include "mailimporter/filterinfo.h"
#include "mailcommon/filter/filterimporterexporter.h"
#include "importwizard.h"
#include <KLocale>
#include <KConfig>
#include <QDir>
IcedoveImportData::IcedoveImportData(ImportWizard*parent)
:AbstractImporter(parent)
{
mPath = MailImporter::FilterIcedove::defaultSettingsPath();
}
IcedoveImportData::~IcedoveImportData()
{
}
QString IcedoveImportData::defaultProfile()
{
if (mDefaultProfile.isEmpty()) {
mDefaultProfile = MailImporter::FilterThunderbird::defaultProfile(mImportWizard);
}
return mDefaultProfile;
}
bool IcedoveImportData::foundMailer() const
{
QDir directory( mPath );
if ( directory.exists() )
return true;
return false;
}
bool IcedoveImportData::importAddressBook()
{
const QDir addressbookDir(mPath+defaultProfile());
ThunderBirdAddressBook account( addressbookDir, mImportWizard );
return true;
}
QString IcedoveImportData::name() const
{
return QLatin1String("Icedove");
}
bool IcedoveImportData::importSettings()
{
const QString accountFile = mPath + defaultProfile() + QLatin1String("/prefs.js");
if ( QFile( accountFile ).exists() ) {
ThunderbirdSettings account( accountFile, mImportWizard );
} else {
addImportSettingsInfo(i18n("Thunderbird settings not found."));
}
return true;
}
bool IcedoveImportData::importMails()
{
//* This should be usually ~/.icedove/xxxx.default/Mail/Local Folders/
MailImporter::FilterInfo *info = initializeInfo();
MailImporter::FilterThunderbird thunderbird;
thunderbird.setFilterInfo( info );
info->clear();
info->setStatusMessage(i18n("Import in progress"));
const QString mailsPath = mPath + defaultProfile() + QLatin1String("/Mail/Local Folders/");
QDir directory(mailsPath);
if (directory.exists())
thunderbird.importMails(mailsPath);
else
thunderbird.import();
info->setStatusMessage(i18n("Import finished"));
delete info;
return true;
}
bool IcedoveImportData::importFilters()
{
const QString path(mPath + defaultProfile());
QDir dir(path);
bool filtersAdded = false;
const QStringList subDir = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
if (subDir.isEmpty())
return true;
Q_FOREACH ( const QString& mailPath, subDir ) {
const QString subMailPath(path + QLatin1Char('/') + mailPath);
QDir dirMail(subMailPath);
const QStringList subDirMail = dirMail.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
bool foundFilterFile = false;
Q_FOREACH ( const QString& file, subDirMail ) {
const QString filterFile(subMailPath +QLatin1Char('/')+ file + QLatin1String("/msgFilterRules.dat"));
if (QFile(filterFile).exists()) {
foundFilterFile = true;
const bool added = addFilters( filterFile, MailCommon::FilterImporterExporter::ThunderBirdFilter );
if (!filtersAdded && added) {
filtersAdded = true;
}
}
}
if (!foundFilterFile)
return true;
}
return filtersAdded;
}
AbstractImporter::TypeSupportedOptions IcedoveImportData::supportedOption()
{
TypeSupportedOptions options;
options |=AbstractImporter::Mails;
options |=AbstractImporter::Filters;
options |=AbstractImporter::Settings;
options |=AbstractImporter::AddressBooks;
return options;
}
/*
Copyright (c) 2012-2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef IcedoveImportData_H
#define IcedoveImportData_H
#include "abstractimporter.h"
class ImportWizard;
class IcedoveImportData : public AbstractImporter
{
public:
explicit IcedoveImportData(ImportWizard *parent);
~IcedoveImportData();
TypeSupportedOptions supportedOption();
bool foundMailer() const;
bool importSettings();
bool importMails();
bool importFilters();
bool importAddressBook();
QString name() const;
private:
QString defaultProfile();
QString mDefaultProfile;
};
#endif /* IcedoveImportData_H */
......@@ -31,6 +31,7 @@
#include "evolutionv3/evolutionv3importdata.h"
#include "evolutionv2/evolutionv2importdata.h"
#include "evolutionv1/evolutionv1importdata.h"
#include "icedove/icedoveimportdata.h"
#include "opera/operaimportdata.h"
#include "oe/oeimportdata.h"
#include "mailapp/mailappimportdata.h"
......@@ -100,6 +101,7 @@ ImportWizard::ImportWizard(QWidget *parent)
//Import module
addImportModule(new ThunderbirdImportData(this));
addImportModule(new IcedoveImportData(this));
addImportModule(new SylpheedImportData(this));
addImportModule(new Evolutionv3ImportData(this));
addImportModule(new Evolutionv2ImportData(this));
......@@ -228,7 +230,6 @@ void ImportWizard::setAppropriatePage(AbstractImporter::TypeSupportedOptions opt
setAppropriate(mPage5,(options & AbstractImporter::Settings));
setAppropriate(mPage6,(options & AbstractImporter::AddressBooks));
setAppropriate(mPage7,(options & AbstractImporter::Calendars));
}
void ImportWizard::next()
......
......@@ -34,6 +34,7 @@
#include <filter_thebat.h>
#include <filter_lnotes.h>
#include <filter_mailmangzip.h>
#include <filtericedove.h>
#include <filters.h>
......@@ -76,6 +77,7 @@ KSelFilterPage::KSelFilterPage(QWidget *parent )
addFilter(new MailImporter::FilterOpera);
addFilter(new MailImporter::FilterSylpheed);
addFilter(new MailImporter::FilterThunderbird);
addFilter(new MailImporter::FilterIcedove);
addFilter(new MailImporter::FilterTheBat);
addFilter(new MailImporter::FilterOE);
addFilter(new MailImporter::FilterPMail);
......
......@@ -55,6 +55,7 @@
#include "mailimporter/filter_sylpheed.h"
#include "mailimporter/filter_thunderbird.h"
#include "mailimporter/filter_opera.h"
#include "mailimporter/filtericedove.h"
#include "mailimporter/othermailerutil.h"
#include <incidenceeditor-ng/globalsettings.h>
......@@ -444,6 +445,7 @@ bool MailCommon::Util::foundMailer()
lst << MailImporter::FilterSylpheed::defaultSettingsPath();
lst << MailImporter::FilterThunderbird::defaultSettingsPath();
lst << MailImporter::OtherMailerUtil::trojitaDefaultPath();
lst << MailImporter::FilterIcedove::defaultSettingsPath();
Q_FOREACH(const QString& path, lst) {
QDir directory( path );
......
......@@ -47,3 +47,4 @@ target_link_libraries(mailimporter
set_target_properties(mailimporter PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION})
install(TARGETS mailimporter ${INSTALL_TARGETS_DEFAULT_ARGS})
add_subdirectory(autotests)
macro(mailimporter_unittest _source)
set(_test ${_source} )
get_filename_component(_name ${_source} NAME_WE)
kde4_add_unit_test(${_name} TESTNAME mailimporter-${_name} ${_test} )
target_link_libraries( ${_name}
mailimporter
${QT_QTTEST_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${KDE4_KDEUI_LIBS}
)
endmacro ()
mailimporter_unittest(filterthunderbirdtest.cpp)
mailimporter_unittest(filtericedovetest.cpp)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "filtericedovetest.h"
#include "mailimporter/filtericedove.h"
#include <qtest_kde.h>
class FilterIcecoveAbstract : public MailImporter::FilterIcedove
{
public:
FilterIcecoveAbstract() {
}
QString settingsPath() {
return MailImporter::FilterIcedove::settingsPath();
}
};
FilterIcedoveTest::FilterIcedoveTest(QObject *parent)
: QObject(parent)
{
}
FilterIcedoveTest::~FilterIcedoveTest()
{
}
void FilterIcedoveTest::shouldHaveDefaultSettingsPath()
{
FilterIcecoveAbstract filter;
QCOMPARE(filter.settingsPath(), MailImporter::FilterIcedove::defaultSettingsPath() );
}
QTEST_KDEMAIN(FilterIcedoveTest, GUI)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FILTERICEDOVETEST_H
#define FILTERICEDOVETEST_H
#include <QObject>
class FilterIcedoveTest : public QObject
{
Q_OBJECT
public:
explicit FilterIcedoveTest(QObject *parent = 0);
~FilterIcedoveTest();
private slots:
void shouldHaveDefaultSettingsPath();
};
#endif // FILTERICEDOVETEST_H
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "filterthunderbirdtest.h"
#include "mailimporter/filter_thunderbird.h"
#include <qtest_kde.h>
class FilterThunderBirdAbstract : public MailImporter::FilterThunderbird
{
public:
FilterThunderBirdAbstract() {
}
QString settingsPath() {
return MailImporter::FilterThunderbird::settingsPath();
}
};
FilterThunderBirdTest::FilterThunderBirdTest(QObject *parent)
: QObject(parent)
{
}
FilterThunderBirdTest::~FilterThunderBirdTest()
{
}
void FilterThunderBirdTest::shouldHaveDefaultSettingsPath()
{
FilterThunderBirdAbstract filter;
QCOMPARE(filter.settingsPath(), MailImporter::FilterThunderbird::defaultSettingsPath() );
}
QTEST_KDEMAIN(FilterThunderBirdTest, GUI)
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, 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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FILTERTHUNDERBIRDTEST_H
#define FILTERTHUNDERBIRDTEST_H
#include <QObject>
class FilterThunderBirdTest : public QObject
{
Q_OBJECT
public:
explicit FilterThunderBirdTest(QObject *parent = 0);
~FilterThunderBirdTest();
private Q_SLOTS:
void shouldHaveDefaultSettingsPath();
};
#endif // FILTERTHUNDERBIRDTEST_H
......@@ -105,6 +105,11 @@ QMap<QString,QString> FilterThunderbird::listProfile(QString&currentProfile)
}
QString FilterThunderbird::defaultInstallFolder() const
{
return QLatin1String("Thunderbird-Import/");
}
QString FilterThunderbird::settingsPath()
{
return FilterThunderbird::defaultSettingsPath();
......@@ -299,9 +304,9 @@ void FilterThunderbird::importMBox(const QString &mboxName, const QString &rootD
if(!targetDir.isNull()) {
if(_targetDir.contains(".sbd"))
_targetDir.remove(".sbd");
destFolder += "Thunderbird-Import/" + _targetDir + '/' + filenameInfo.completeBaseName();// mboxName;
destFolder += defaultInstallFolder() + _targetDir + '/' + filenameInfo.completeBaseName();// mboxName;
} else {
destFolder = "Thunderbird-Import/" + rootDir;
destFolder = defaultInstallFolder() + rootDir;
if(destFolder.contains(".sbd"))
destFolder.remove(".sbd");
}
......
......@@ -22,7 +22,7 @@
#include "filters.h"
/**
* Imports Thinderbird mail folder recursively, keeping the folder structure.
* Imports Thunderbird mail folder recursively, keeping the folder structure.
* @author Danny Kukawka
*/
namespace MailImporter {
......@@ -40,6 +40,7 @@ public:
static QMap<QString, QString> listProfile(QString&currentProfile);
protected:
virtual QString defaultInstallFolder() const;
virtual QString settingsPath();
private:
void importDirContents(const QString&, const QString&, const QString&);
......
......@@ -16,11 +16,21 @@
*/
#include "filtericedove.h"
#include <KLocalizedString>
using namespace MailImporter;
FilterIcedove::FilterIcedove()
: FilterThunderbird()
{
setName(i18n( "Import Icedove Mails and Folder Structure" ));
setAuthor("Laurent Montel");
setInfo(i18n("<p><b>Icedove import filter</b></p>"
"<p>Select your base Icedove mailfolder"
" (usually ~/.icedove/*.default/Mail/Local Folders/).</p>"
"<p><b>Note:</b> Never choose a Folder which <u>does not</u> contain mbox-files (for example,"
" a maildir): if you do, you will get many new folders.</p>"
"<p>Since it is possible to recreate the folder structure, the folders "
"will be stored under: \"Icedove-Import\".</p>"));
}
......@@ -38,3 +48,8 @@ QString FilterIcedove::defaultSettingsPath()
{
return QDir::homePath() + QLatin1String( "/.icedove/" );
}
QString FilterIcedove::defaultInstallFolder() const
{
return QLatin1String("Icedove-Import/");
}
......@@ -28,6 +28,7 @@ public:
static QString defaultSettingsPath();
protected:
QString defaultInstallFolder() const;
QString settingsPath();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment