Commit 8b293d60 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use smtpmailtransport

parent eb8a553f
Pipeline #21310 passed with stage
in 6 minutes and 43 seconds
......@@ -22,6 +22,7 @@
#include "resourceconvertertest.h"
#include "testimportfile.h"
#include "utils.h"
#include "mail/smtpmailtransport.h"
#include <KConfigGroup>
#include <KIdentityManagement/Identity>
#include <QSignalSpy>
......@@ -111,6 +112,7 @@ void ImportMailJobInterfaceTestImpl::importCustomMailTransport(const QString &id
void ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId)
{
SmtpMailTransport smtpMailTransport(group);
qDebug() << "ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) not implement yet";
qDebug() << " defaultTransport " << defaultTransport << " transportId " << transportId;
}
......
......@@ -26,6 +26,7 @@
#include <KIdentityManagement/Identity>
#include <KIdentityManagement/IdentityManager>
#include <MailTransport/TransportManager>
#include "smtpmailtransport.h"
using namespace Akonadi;
ImportMailJobInterfaceImpl::ImportMailJobInterfaceImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep)
......@@ -134,70 +135,21 @@ void ImportMailJobInterfaceImpl::importCustomMailTransport(const QString &identi
void ImportMailJobInterfaceImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId)
{
SmtpMailTransport smtpMailTransport(group);
MailTransport::Transport *mt = MailTransport::TransportManager::self()->createTransport();
mt->setName(group.readEntry(QStringLiteral("name")));
const QString hostStr(QStringLiteral("host"));
if (group.hasKey(hostStr)) {
mt->setHost(group.readEntry(hostStr));
}
const QString portStr(QStringLiteral("port"));
if (group.hasKey(portStr)) {
mt->setPort(group.readEntry(portStr, -1));
}
const QString userNameStr(QStringLiteral("user"));
if (group.hasKey(userNameStr)) {
mt->setUserName(group.readEntry(userNameStr));
}
const QString precommandStr(QStringLiteral("precommand"));
if (group.hasKey(precommandStr)) {
mt->setPrecommand(group.readEntry(precommandStr));
}
const QString requiresAuthenticationStr(QStringLiteral("auth"));
if (group.hasKey(requiresAuthenticationStr)) {
mt->setRequiresAuthentication(group.readEntry(requiresAuthenticationStr, false));
}
const QString specifyHostnameStr(QStringLiteral("specifyHostname"));
if (group.hasKey(specifyHostnameStr)) {
mt->setSpecifyHostname(group.readEntry(specifyHostnameStr, false));
}
const QString localHostnameStr(QStringLiteral("localHostname"));
if (group.hasKey(localHostnameStr)) {
mt->setLocalHostname(group.readEntry(localHostnameStr));
}
const QString specifySenderOverwriteAddressStr(QStringLiteral("specifySenderOverwriteAddress"));
if (group.hasKey(specifySenderOverwriteAddressStr)) {
mt->setSpecifySenderOverwriteAddress(group.readEntry(specifySenderOverwriteAddressStr, false));
}
const QString storePasswordStr(QStringLiteral("storepass"));
if (group.hasKey(storePasswordStr)) {
mt->setStorePassword(group.readEntry(storePasswordStr, false));
}
const QString senderOverwriteAddressStr(QStringLiteral("senderOverwriteAddress"));
if (group.hasKey(senderOverwriteAddressStr)) {
mt->setSenderOverwriteAddress(group.readEntry(senderOverwriteAddressStr));
}
const QString encryptionStr(QStringLiteral("encryption"));
if (group.hasKey(encryptionStr)) {
const QString encryptionType = group.readEntry(encryptionStr, QString());
if (!encryptionType.isEmpty()) {
if (encryptionType == QLatin1String("TLS")) {
mt->setEncryption(static_cast<int>(MailTransport::TransportBase::EnumEncryption::TLS));
} else if (encryptionType == QLatin1String("SSL")) {
mt->setEncryption(static_cast<int>(MailTransport::TransportBase::EnumEncryption::SSL));
} else if (encryptionType == QLatin1String("None")) {
mt->setEncryption(static_cast<int>(MailTransport::TransportBase::EnumEncryption::None));
} else {
qCWarning(PIMDATAEXPORTERCORE_LOG) << "Unknown encryption type " << encryptionType;
}
} else {
qCWarning(PIMDATAEXPORTERCORE_LOG) << "Encryption type is empty. It's a bug";
}
mt->setEncryption(group.readEntry(encryptionStr, 1)); //TODO verify
}
const QString authenticationTypeStr(QStringLiteral("authtype"));
if (group.hasKey(authenticationTypeStr)) {
mt->setAuthenticationType(group.readEntry(authenticationTypeStr, 1)); //TODO verify
}
mt->setName(smtpMailTransport.name());
mt->setHost(smtpMailTransport.host());
mt->setPort(smtpMailTransport.port());
mt->setUserName(smtpMailTransport.userName());
mt->setPrecommand(smtpMailTransport.precommand());
mt->setRequiresAuthentication(smtpMailTransport.requiresAuthentication());
mt->setSpecifyHostname(smtpMailTransport.specifyHostname());
mt->setLocalHostname(smtpMailTransport.localHostname());
mt->setSpecifySenderOverwriteAddress(smtpMailTransport.specifySenderOverwriteAddress());
mt->setStorePassword(smtpMailTransport.storePassword());
mt->setSenderOverwriteAddress(smtpMailTransport.senderOverwriteAddress());
mt->setEncryption(smtpMailTransport.encryption());
mt->setAuthenticationType(smtpMailTransport.authenticationType());
addMailTransport(mt, defaultTransport, transportId);
}
......
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