Commit 3d278178 authored by Laurent Montel's avatar Laurent Montel 😁

Rewrite code to allow to autotest it

parent a910f2ea
......@@ -35,9 +35,19 @@
#include <QRegularExpression>
BalsaAddressBook::BalsaAddressBook(const QString &filename, ImportWizard *parent)
: AbstractAddressBook(parent)
: AbstractAddressBook(parent),
mFileName(filename)
{
KConfig config(filename);
}
BalsaAddressBook::~BalsaAddressBook()
{
}
void BalsaAddressBook::importAddressBook()
{
KConfig config(mFileName);
const QStringList addressBookList = config.groupList().filter(QRegularExpression("address-book-\\d+"));
if (addressBookList.isEmpty()) {
addAddressBookImportInfo(i18n("No addressbook found"));
......@@ -49,11 +59,6 @@ BalsaAddressBook::BalsaAddressBook(const QString &filename, ImportWizard *parent
}
}
BalsaAddressBook::~BalsaAddressBook()
{
}
void BalsaAddressBook::readAddressBook(const KConfigGroup &grp)
{
const QString type = grp.readEntry(QStringLiteral("Type"));
......
......@@ -31,8 +31,10 @@ public:
explicit BalsaAddressBook(const QString &filename, ImportWizard *parent);
~BalsaAddressBook();
void importAddressBook();
private:
void readAddressBook(const KConfigGroup &grp);
QString mFileName;
};
#endif // BalsaAddressBook_H
......@@ -73,6 +73,7 @@ bool BalsaImportData::importAddressBook()
{
const QString addressbookFile(mPath + QStringLiteral("config"));
BalsaAddressBook addressbook(addressbookFile, mImportWizard);
addressbook.importAddressBook();
return true;
}
......
......@@ -74,6 +74,7 @@ bool ClawsMailImportData::importAddressBook()
{
const QDir addressbookDir(mPath + QLatin1String("addrbook/"));
ClawsMailAddressBook account(addressbookDir, mImportWizard);
account.importAddressBook();
return true;
}
......
......@@ -26,7 +26,6 @@
EvolutionAddressBook::EvolutionAddressBook(ImportWizard *parent)
: AbstractAddressBook(parent)
{
exportEvolutionAddressBook();
}
EvolutionAddressBook::~EvolutionAddressBook()
......
......@@ -30,9 +30,7 @@ class EvolutionAddressBook: public AbstractAddressBook
public:
explicit EvolutionAddressBook(ImportWizard *parent);
~EvolutionAddressBook();
private:
void exportEvolutionAddressBook();
};
#endif // ABSTRACTADDRESSBOOK_H
......@@ -97,6 +97,7 @@ bool Evolutionv3ImportData::importFilters()
bool Evolutionv3ImportData::importAddressBook()
{
EvolutionAddressBook addressbook(mImportWizard);
addressbook.exportEvolutionAddressBook();
return true;
}
......
......@@ -32,3 +32,8 @@ GearyAddressBook::GearyAddressBook(const QString &filename, ImportWizard *parent
GearyAddressBook::~GearyAddressBook()
{
}
void GearyAddressBook::importAddressBook()
{
}
......@@ -31,6 +31,7 @@ class GearyAddressBook : public AbstractAddressBook
public:
explicit GearyAddressBook(const QString &filename, ImportWizard *parent);
~GearyAddressBook();
void importAddressBook();
};
#endif /* GearyAddressBook_H */
......
......@@ -63,6 +63,7 @@ bool IcedoveImportData::importAddressBook()
{
const QDir addressbookDir(mPath + defaultProfile());
ThunderBirdAddressBook account(addressbookDir, mImportWizard);
account.importAddressBook();
return true;
}
......
......@@ -25,11 +25,16 @@
#include <QFile>
OperaAddressBook::OperaAddressBook(const QString &filename, ImportWizard *parent)
: AbstractAddressBook(parent)
: AbstractAddressBook(parent),
mFileName(filename)
{
QFile file(filename);
}
void OperaAddressBook::importAddressBook()
{
QFile file(mFileName);
if (!file.open(QIODevice::ReadOnly)) {
qCDebug(IMPORTWIZARD_LOG) << " We can't open file" << filename;
qCDebug(IMPORTWIZARD_LOG) << " We can't open file" << mFileName;
return;
}
......
......@@ -30,8 +30,10 @@ public:
explicit OperaAddressBook(const QString &filename, ImportWizard *parent);
~OperaAddressBook();
void importAddressBook();
private:
void appendContact(KContacts::Addressee *contact);
QString mFileName;
};
#endif // OPERAADDRESSBOOK_H
......@@ -73,6 +73,7 @@ bool OperaImportData::importAddressBook()
{
const QString addressbookFile(mPath + QLatin1String("bookmarks.adr"));
OperaAddressBook addressbook(addressbookFile, mImportWizard);
addressbook.importAddressBook();
return true;
}
......@@ -80,6 +81,7 @@ bool OperaImportData::importSettings()
{
const QString settingFile(mPath + QLatin1String("mail/accounts.ini"));
OperaSettings settings(settingFile, mImportWizard);
settings.importSettings();
return true;
}
......
......@@ -33,10 +33,15 @@
#include <QRegularExpression>
OperaSettings::OperaSettings(const QString &filename, ImportWizard *parent)
: AbstractSettings(parent)
: AbstractSettings(parent),
mFileName(filename)
{
if (QFile(filename).exists()) {
KConfig config(filename);
}
void OperaSettings::importSettings()
{
if (QFile(mFileName).exists()) {
KConfig config(mFileName);
KConfigGroup grp = config.group(QStringLiteral("Accounts"));
readGlobalAccount(grp);
const QStringList accountList = config.groupList().filter(QRegularExpression(QStringLiteral("Account\\d+")));
......
......@@ -31,11 +31,13 @@ public:
explicit OperaSettings(const QString &filename, ImportWizard *parent);
~OperaSettings();
void importSettings();
private:
void readAccount(const KConfigGroup &grp);
void readTransport(const KConfigGroup &grp);
void readGlobalAccount(const KConfigGroup &grp);
void readIdentity(const KConfigGroup &grp);
QString mFileName;
};
#endif // OPERASETTINGS_H
......@@ -75,6 +75,7 @@ bool PMailImportData::importSettings()
//TODO verify path
const QString settingFile(mPath + QLatin1String("pmail.ini"));
PMailSettings settings(settingFile, mImportWizard);
settings.importSettings();
return true;
}
......
......@@ -32,10 +32,16 @@
#include <QRegularExpression>
PMailSettings::PMailSettings(const QString &filename, ImportWizard *parent)
: AbstractSettings(parent)
: AbstractSettings(parent),
mFileName(filename)
{
if (QFile(filename).exists()) {
KConfig config(filename);
}
void PMailSettings::importSettings()
{
if (QFile(mFileName).exists()) {
KConfig config(mFileName);
const QStringList accountList = config.groupList().filter(QRegularExpression(QStringLiteral("WinPMail Identity - *")));
const QStringList::const_iterator end(accountList.constEnd());
......
......@@ -31,8 +31,10 @@ public:
explicit PMailSettings(const QString &filename, ImportWizard *parent);
~PMailSettings();
void importSettings();
private:
void readIdentity(const KConfigGroup &group);
QString mFileName;
};
#endif // ClawsMailSettings_H
......@@ -28,22 +28,28 @@
#include <QDomDocument>
SylpheedAddressBook::SylpheedAddressBook(const QDir &dir, ImportWizard *parent)
: AbstractAddressBook(parent)
: AbstractAddressBook(parent),
mDir(dir)
{
const QStringList files = dir.entryList(QStringList(QStringLiteral("addrbook-[0-9]*.xml")), QDir::Files, QDir::Name);
}
SylpheedAddressBook::~SylpheedAddressBook()
{
}
void SylpheedAddressBook::importAddressBook()
{
const QStringList files = mDir.entryList(QStringList(QStringLiteral("addrbook-[0-9]*.xml")), QDir::Files, QDir::Name);
if (files.isEmpty()) {
addAddressBookImportInfo(i18n("No addressbook found"));
}
for (const QString &file : files) {
readAddressBook(dir.path() + QLatin1Char('/') + file);
} else {
for (const QString &file : files) {
readAddressBook(mDir.path() + QLatin1Char('/') + file);
}
}
cleanUp();
}
SylpheedAddressBook::~SylpheedAddressBook()
{
}
void SylpheedAddressBook::readAddressBook(const QString &filename)
{
......
......@@ -22,7 +22,7 @@
#include "abstractaddressbook.h"
#include <QHash>
class QDir;
#include <QDir>
class QString;
class ImportWizard;
......@@ -34,9 +34,11 @@ public:
explicit SylpheedAddressBook(const QDir &dir, ImportWizard *parent);
~SylpheedAddressBook();
void importAddressBook();
private:
void readAddressBook(const QString &filename);
QHash<QString, QStringList > mAddressBookUid;
QDir mDir;
};
#endif /* SYLPHEEDADDRESSBOOK_H */
......
......@@ -92,6 +92,7 @@ bool SylpheedImportData::importAddressBook()
{
const QDir addressbookDir(mPath);
SylpheedAddressBook account(addressbookDir, mImportWizard);
account.importAddressBook();
return true;
}
......
......@@ -26,29 +26,35 @@
#include "importwizard_debug.h"
ThunderBirdAddressBook::ThunderBirdAddressBook(const QDir &dir, ImportWizard *parent)
: AbstractAddressBook(parent)
: AbstractAddressBook(parent),
mDir(dir)
{
readAddressBook(dir.path() + QLatin1String("/impab.mab"));
const QStringList filesimportab = dir.entryList(QStringList(QStringLiteral("impab-[0-9]*.map")), QDir::Files, QDir::Name);
}
ThunderBirdAddressBook::~ThunderBirdAddressBook()
{
}
void ThunderBirdAddressBook::importAddressBook()
{
const QString path = mDir.path();
readAddressBook(path + QLatin1String("/impab.mab"));
const QStringList filesimportab = mDir.entryList(QStringList(QStringLiteral("impab-[0-9]*.map")), QDir::Files, QDir::Name);
for (const QString &file : filesimportab) {
readAddressBook(dir.path() + QLatin1Char('/') + file);
readAddressBook(path + QLatin1Char('/') + file);
}
readAddressBook(dir.path() + QLatin1String("/abook.mab"));
readAddressBook(path + QLatin1String("/abook.mab"));
const QStringList files = dir.entryList(QStringList(QStringLiteral("abook-[0-9]*.map")), QDir::Files, QDir::Name);
const QStringList files = mDir.entryList(QStringList(QStringLiteral("abook-[0-9]*.map")), QDir::Files, QDir::Name);
for (const QString &file : files) {
readAddressBook(dir.path() + QLatin1Char('/') + file);
readAddressBook(path + QLatin1Char('/') + file);
}
readAddressBook(dir.path() + QLatin1String("/history.mab"));
readAddressBook(path + QLatin1String("/history.mab"));
cleanUp();
}
ThunderBirdAddressBook::~ThunderBirdAddressBook()
{
}
void ThunderBirdAddressBook::readAddressBook(const QString &filename)
{
MorkParser mork;
......
......@@ -32,8 +32,10 @@ public:
explicit ThunderBirdAddressBook(const QDir &dir, ImportWizard *parent);
~ThunderBirdAddressBook();
void importAddressBook();
private:
void readAddressBook(const QString &filename);
QDir mDir;
};
#endif // THUNDERBIRDADDRESSBOOK_H
......@@ -62,6 +62,7 @@ bool ThunderbirdImportData::importAddressBook()
{
const QDir addressbookDir(mPath + defaultProfile());
ThunderBirdAddressBook account(addressbookDir, mImportWizard);
account.importAddressBook();
return true;
}
......
......@@ -29,7 +29,6 @@ TrojitaAddressBook::TrojitaAddressBook(const QString &filename, ImportWizard *pa
{
settings = new QSettings(filename, QSettings::IniFormat, this);
settings->setIniCodec("UTF-8");
readAddressBook();
}
TrojitaAddressBook::~TrojitaAddressBook()
......
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