Commit a1127af1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement autotest import mailtransport

parent 3754de2f
......@@ -89,6 +89,11 @@ void ImportMailJobInterfaceTestImpl::importCustomMailTransport(const QString &id
qDebug() << "importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) not implemented yet";
}
void ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId)
{
qDebug() << "ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) not implement yet";
}
ImportMailJobInterfaceTest::ImportMailJobInterfaceTest(QObject *parent)
: QObject(parent)
{
......@@ -129,4 +134,3 @@ void ImportMailJobInterfaceTest::importMail()
delete file;
}
......@@ -44,6 +44,7 @@ protected:
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
void addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) override;
void importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) override;
void importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) override;
};
class ImportMailJobInterfaceTest : public QObject
......
......@@ -169,71 +169,7 @@ void ImportMailJobInterface::importMailTransport(const QString &tempDirName)
const QString identifierValue = group.readEntry(identifierStr);
importCustomMailTransport(identifierValue, group, defaultTransport, transportId);
} else {
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
}
addMailTransport(mt, defaultTransport, transportId);
importSmtpMailTransport(group, defaultTransport, transportId);
}
}
}
......
......@@ -60,6 +60,7 @@ protected:
virtual Q_REQUIRED_RESULT QString adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) = 0;
virtual void addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) = 0;
virtual void importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) = 0;
virtual void importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) = 0;
void addMailTransport(MailTransport::Transport *mt, int defaultTransport, int transportId);
QHash<int, uint> mHashIdentity;
......
......@@ -131,3 +131,73 @@ void ImportMailJobInterfaceImpl::importCustomMailTransport(const QString &identi
qCWarning(PIMDATAEXPORTERCORE_LOG) << "identifier value is empty";
}
}
void ImportMailJobInterfaceImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId)
{
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
}
addMailTransport(mt, defaultTransport, transportId);
}
......@@ -49,6 +49,7 @@ protected:
Q_REQUIRED_RESULT QString adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) override;
void addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) override;
void importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) override;
void importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) override;
private:
Q_REQUIRED_RESULT QString uniqueIdentityName(const QString &name);
};
......
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