Commit 365477c5 authored by Laurent Montel's avatar Laurent Montel 😁

Move plugins from importwizard

parent fe4fd6ad
add_definitions(-DTRANSLATION_DOMAIN=\"importwizard_plugins\")
add_subdirectory(evolutionv1)
add_subdirectory(evolutionv2)
add_subdirectory(geary)
add_subdirectory(mailapp)
add_subdirectory(oe)
add_subdirectory(opera)
add_subdirectory(pmail)
add_subdirectory(thebat)
set(gearyimporter_SRCS
gearyaddressbook.cpp
gearyimportdata.cpp
gearysettings.cpp
)
ecm_qt_declare_logging_category(gearyimporter_SRCS HEADER gearyplugin_debug.h IDENTIFIER GEARYPLUGIN_LOG CATEGORY_NAME org.kde.pim.importwizard.gearyplugin)
kcoreaddons_add_plugin(gearyimporterplugin JSON gearyimporter.json SOURCES
${gearyimporter_SRCS} INSTALL_NAMESPACE importwizard)
target_link_libraries(gearyimporterplugin
KPim::ImportWizard
KF5::XmlGui
KF5::I18n
KF5::Contacts
KF5::MailImporterAkonadi
KF5::MailTransport
KF5::IdentityManagement
KF5::MailCommon
)
/*
Copyright (C) 2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "gearyaddressbook.h"
#include <KContacts/Addressee>
#include <QUrl>
#include <QSettings>
GearyAddressBook::GearyAddressBook(const QString &filename)
{
}
GearyAddressBook::~GearyAddressBook()
{
}
void GearyAddressBook::importAddressBook()
{
}
/*
Copyright (C) 2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GearyAddressBook_H
#define GearyAddressBook_H
#include <ImportWizard/AbstractAddressBook>
#include <QHash>
class GearyAddressBook : public LibImportWizard::AbstractAddressBook
{
public:
explicit GearyAddressBook(const QString &filename);
~GearyAddressBook();
void importAddressBook();
};
#endif /* GearyAddressBook_H */
/*
Copyright (C) 2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "gearyimportdata.h"
#include "gearysettings.h"
#include "gearyaddressbook.h"
#include "mailimporter/filterinfo.h"
#include "mailimporter/othermailerutil.h"
#include "gearyplugin_debug.h"
#include <kpluginfactory.h>
#include <QDir>
K_PLUGIN_FACTORY_WITH_JSON(GearyImporterFactory, "gearyimporter.json", registerPlugin<GearyImportData>();
)
GearyImportData::GearyImportData(QObject *parent, const QList<QVariant> &)
: LibImportWizard::AbstractImporter(parent)
{
mPath = MailImporter::OtherMailerUtil::gearyDefaultPath();
}
GearyImportData::~GearyImportData()
{
}
bool GearyImportData::foundMailer() const
{
QDir directory(mPath);
if (directory.exists()) {
return true;
}
return false;
}
QString GearyImportData::name() const
{
return QStringLiteral("Geary");
}
bool GearyImportData::importMails()
{
return false;
}
bool GearyImportData::importSettings()
{
QDir directory(mPath);
const QStringList lstDir = directory.entryList(QDir::AllDirs);
qCDebug(GEARYPLUGIN_LOG) << "Number of directory " << lstDir.count();
const QString configName = QStringLiteral("geary.ini");
for (int i = 0; i < lstDir.count(); ++i) {
const QString fullPath = lstDir.at(i) + QDir::separator() + configName;
if (QFileInfo::exists(fullPath)) {
GearySettings setting(fullPath);
setting.setAbstractDisplayInfo(mAbstractDisplayInfo);
setting.importSettings();
}
}
return true;
}
bool GearyImportData::importAddressBook()
{
return false;
}
LibImportWizard::AbstractImporter::TypeSupportedOptions GearyImportData::supportedOption()
{
TypeSupportedOptions options;
//options |=LibImportWizard::AbstractImporter::Mails;
options |= LibImportWizard::AbstractImporter::Settings;
//options |= LibImportWizard::AbstractImporter::AddressBooks;
return options;
}
#include "gearyimportdata.moc"
/*
Copyright (C) 2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GearyImportData_H
#define GearyImportData_H
#include <ImportWizard/AbstractImporter>
class GearyImportData : public LibImportWizard::AbstractImporter
{
public:
explicit GearyImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~GearyImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
bool foundMailer() const Q_DECL_OVERRIDE;
bool importMails() Q_DECL_OVERRIDE;
bool importSettings() Q_DECL_OVERRIDE;
bool importAddressBook() Q_DECL_OVERRIDE;
QString name() const Q_DECL_OVERRIDE;
};
#endif /* TrojiraImportData_H */
{
"KPlugin": {
"Id": "gearyimporter",
"Name": "Geary Importer",
"Name[ca@valencia]": "Importador del Geary",
"Name[ca]": "Importador del Geary",
"Name[es]": "Importador Geary",
"Name[it]": "Importatore da Geary",
"Name[nl]": "Geary-importeur",
"Name[pl]": "Importer Geary",
"Name[pt]": "Importador do Geary",
"Name[sk]": "Importér Geary",
"Name[sv]": "Geary-importverktyg",
"Name[uk]": "Засіб імпортування з Geary",
"Name[x-test]": "xxGeary Importerxx",
"ServiceTypes": [
"ImportWizard/PluginMailImporter"
],
"Version": "1.0"
}
}
/*
Copyright (C) 2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "gearysettings.h"
#include <ImportWizard/ImportWizardUtil>
#include <mailtransport/transportmanager.h>
#include <KIdentityManagement/kidentitymanagement/identity.h>
#include <KIdentityManagement/kidentitymanagement/signature.h>
#include <QSettings>
GearySettings::GearySettings(const QString &filename)
{
settings = new QSettings(filename, QSettings::IniFormat, this);
}
GearySettings::~GearySettings()
{
delete settings;
}
void GearySettings::importSettings()
{
readImapAccount();
readTransport();
readIdentity();
readGlobalSettings();
}
void GearySettings::readImapAccount()
{
QMap<QString, QVariant> newSettings;
QString name;
name = settings->value(QStringLiteral("imap_host")).toString();
if (!name.isEmpty()) {
newSettings.insert(QStringLiteral("ImapServer"), name);
}
const int port = settings->value(QStringLiteral("imap_port"), -1).toInt();
if (port > -1) {
newSettings.insert(QStringLiteral("ImapPort"), port);
}
if (settings->contains(QStringLiteral("imap_starttls"))) {
const bool useTLS = settings->value(QStringLiteral("imap_starttls")).toBool();
if (useTLS) {
newSettings.insert(QStringLiteral("Safety"), QStringLiteral("STARTTLS"));
}
}
const QString userName = settings->value(QStringLiteral("imap_username")).toString();
if (!userName.isEmpty()) {
newSettings.insert(QStringLiteral("Username"), userName);
}
if (!name.isEmpty()) {
const QString agentIdentifyName = LibImportWizard::AbstractBase::createResource(QStringLiteral("akonadi_imap_resource"), name, newSettings);
//Check by default
addCheckMailOnStartup(agentIdentifyName, true);
}
}
void GearySettings::readTransport()
{
const QString host = settings->value(QStringLiteral("smtp_host")).toString();
if (!host.isEmpty()) {
MailTransport::Transport *mt = createTransport();
mt->setType(MailTransport::Transport::EnumType::SMTP);
mt->setHost(host);
const int port = settings->value(QStringLiteral("msa.smtp.port"), -1).toInt();
if (port != -1) {
mt->setPort(port);
}
//ADD more settings
storeTransport(mt, true); //only one smtp for the moment
}
#if 0
smtp_host = smtp.bla.bla
smtp_port = 465
smtp_ssl = true
smtp_starttls = false
smtp_use_imap_credentials = false
smtp_noauth = true
#endif
#if 0
const QString smtpMethod = settings->value(QStringLiteral("msa.method")).toString();
if (!smtpMethod.isEmpty()) {
MailTransport::Transport *mt = createTransport();
if (smtpMethod == QLatin1String("IMAP-SENDMAIL")) {
//see http://tools.ietf.org/html/draft-kundrat-imap-submit-01
} else if (smtpMethod == QLatin1String("SMTP") || smtpMethod == QLatin1String("SSMTP")) {
if (settings->contains(QStringLiteral("msa.smtp.host"))) {
mt->setHost(settings->value(QStringLiteral("msa.smtp.host")).toString());
}
if (settings->contains(QStringLiteral("msa.smtp.port"))) {
mt->setPort(settings->value(QStringLiteral("msa.smtp.port")).toInt());
}
if (settings->contains(QStringLiteral("msa.smtp.auth"))) {
if (settings->value(QStringLiteral("msa.smtp.auth")).toBool()) {
if (settings->contains(QStringLiteral("msa.smtp.auth.user"))) {
mt->setUserName(settings->value(QStringLiteral("msa.smtp.auth.user")).toString());
}
if (settings->contains(QStringLiteral("msa.smtp.auth.pass"))) {
mt->setPassword(settings->value(QStringLiteral("msa.smtp.auth.pass")).toString());
}
}
}
if (settings->contains(QStringLiteral("msa.smtp.starttls"))) {
if (settings->value(QStringLiteral("msa.smtp.starttls")).toBool()) {
mt->setEncryption(MailTransport::Transport::EnumEncryption::TLS);
}
}
mt->setType(MailTransport::Transport::EnumType::SMTP);
} else {
qCWarning(IMPORTWIZARD_LOG) << " smtpMethod unknown " << smtpMethod;
}
storeTransport(mt, true); //only one smtp for the moment
}
#endif
}
void GearySettings::readIdentity()
{
QString realName = settings->value(QStringLiteral("realName")).toString();
if (!realName.isEmpty()) {
KIdentityManagement::Identity *identity = createIdentity(realName);
identity->setFullName(realName);
identity->setIdentityName(realName);
const QString address = settings->value(QStringLiteral("primary_email")).toString();
identity->setPrimaryEmailAddress(address);
const QString alias = settings->value(QStringLiteral("alternate_emails")).toString();
if (!alias.isEmpty()) {
identity->setEmailAliases(alias.split(QLatin1Char(';'), QString::SkipEmptyParts));
}
const QString signatureStr = settings->value(QStringLiteral("email_signature")).toString();
if (!signatureStr.isEmpty()) {
KIdentityManagement::Signature signature;
signature.setType(KIdentityManagement::Signature::Inlined);
signature.setText(signatureStr);
const bool useSignature = settings->value(QStringLiteral("use_email_signature"), true).toBool();
signature.setEnabledSignature(useSignature);
identity->setSignature(signature);
}
//TODO add "nickname=bli@kde.org"
storeIdentity(identity);
}
}
void GearySettings::readGlobalSettings()
{
//TODO
}
/*
Copyright (C) 2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GearySettings_H
#define GearySettings_H
#include <ImportWizard/AbstractSettings>
class QSettings;
class GearySettings : public AbstractSettings
{
public:
explicit GearySettings(const QString &filename);
~GearySettings();
void importSettings();
private:
void readImapAccount();
void readIdentity();
void readGlobalSettings();
void readTransport();
QSettings *settings;
};
#endif // ClawsMailSettings_H
set(mailappimporter_SRCS
mailappimportdata.cpp
)
kcoreaddons_add_plugin(mailappimporterplugin JSON mailappimporter.json SOURCES
${mailappimporter_SRCS} INSTALL_NAMESPACE importwizard)
target_link_libraries(mailappimporterplugin
KPim::ImportWizard
KF5::XmlGui
KF5::I18n
KF5::Contacts
KF5::MailImporterAkonadi
KF5::MailTransport
KF5::IdentityManagement
KF5::MailCommon
)
/*
Copyright (C) 2012-2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "mailappimportdata.h"
#include "mailimporter/filtermailapp.h"
#include "mailimporter/filterinfo.h"
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <QDir>
K_PLUGIN_FACTORY_WITH_JSON(MailAppImporterFactory, "mailappimporter.json", registerPlugin<MailAppImportData>();
)
MailAppImportData::MailAppImportData(QObject *parent, const QList<QVariant> &)
: LibImportWizard::AbstractImporter(parent)
{
mPath = QDir::homePath();
}
MailAppImportData::~MailAppImportData()
{
}
bool MailAppImportData::foundMailer() const
{
#ifdef Q_OS_MAC
//TODO find a method to search it. Perhaps look at binary.
QDir directory(mPath);
if (directory.exists()) {
return true;
}
#endif
return false;
}
QString MailAppImportData::name() const
{
return QStringLiteral("Mail App");
}
bool MailAppImportData::importMails()
{
MailImporter::FilterMailApp mailapp;
initializeFilter(mailapp);
mailapp.filterInfo()->setStatusMessage(i18n("Import in progress"));
QDir directory(mPath);
if (directory.exists()) {
mailapp.importMails(mPath);
} else {
mailapp.import();
}
mailapp.filterInfo()->setStatusMessage(i18n("Import finished"));
return true;
}
LibImportWizard::AbstractImporter::TypeSupportedOptions MailAppImportData::supportedOption()
{
TypeSupportedOptions options;
options |= LibImportWizard::AbstractImporter::Mails;
return options;
}
#include "mailappimportdata.moc"
/*
Copyright (C) 2012-2017 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 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; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef MailAppImportData_H
#define MailAppImportData_H
#include <ImportWizard/AbstractImporter>
class MailAppImportData : public LibImportWizard::AbstractImporter
{
public:
explicit MailAppImportData(QObject *parent, const QList<QVariant> & = QList<QVariant>());
~MailAppImportData();
TypeSupportedOptions supportedOption() Q_DECL_OVERRIDE;
bool foundMailer() const Q_DECL_OVERRIDE;
bool importMails() Q_DECL_OVERRIDE;
QString name() const Q_DECL_OVERRIDE;
};
#endif /* MailApp ImportData_H */
{
"KPlugin": {
"Id": "mailappimporter",
"Name": "MailApp Importer",
"Name[ca@valencia]":