Commit 1531d030 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement import mailtransport

parent 14394aa6
Pipeline #21671 passed with stage
in 6 minutes and 35 seconds
[General]
default-transport=2
[Transport 1]
authenticationType=0
encryption=1
host=smtp.foo.fr
localHostname=
name=transportname1
port=465
precommand=
requiresAuthentication=false
senderOverwriteAddress=bla@foo.fr
specifyHostname=false
specifySenderOverwriteAddress=true
storePassword=true
userName=vla@bla.fr
[Transport 2]
authenticationType=0
encryption=1
host=smtp.bla.org
localHostname=
name=transportname2
port=587
precommand=
requiresAuthentication=true
senderOverwriteAddress=
specifyHostname=false
specifySenderOverwriteAddress=false
storePassword=true
userName=foo@bla.org
......@@ -34,7 +34,7 @@ ImportMailJobInterfaceTestImpl::ImportMailJobInterfaceTestImpl(QObject *parent,
ImportMailJobInterfaceTestImpl::~ImportMailJobInterfaceTestImpl()
{
QVERIFY(QDir(extractPath()).removeRecursively());
//QVERIFY(QDir(extractPath()).removeRecursively());
}
void ImportMailJobInterfaceTestImpl::start()
......@@ -137,19 +137,40 @@ void ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const SmtpMailTrans
qDebug() << "ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) not implement yet";
qDebug() << " defaultTransport " << defaultTransport << " transportId " << transportId;
KConfig config(QStringLiteral("/tmp/mailtransport/config/mailtransports"));
#if 0
smtpMailTransport.name();
smtpMailTransport.host();
smtpMailTransport.port();
smtpMailTransport.userName();
smtpMailTransport.precommand();
smtpMailTransport.requiresAuthentication();
smtpMailTransport.specifyHostname();
smtpMailTransport.localHostname();
smtpMailTransport.specifySenderOverwriteAddress();
smtpMailTransport.storePassword();
smtpMailTransport.senderOverwriteAddress();
smtpMailTransport.encryption();
smtpMailTransport.authenticationType();
#endif
//TODO use transportId ?
const int transportValue = mMailTransportId;
mMailTransportId++;
KConfigGroup grp = config.group(QStringLiteral("Transport %1").arg(transportValue));
const auto name = smtpMailTransport.name();
grp.writeEntry(QStringLiteral("name"), name);
const auto host = smtpMailTransport.host();
grp.writeEntry(QStringLiteral("host"), host);
const auto port = smtpMailTransport.port();
grp.writeEntry(QStringLiteral("port"), port);
const auto userName = smtpMailTransport.userName();
grp.writeEntry(QStringLiteral("userName"), userName);
const auto precommand = smtpMailTransport.precommand();
grp.writeEntry(QStringLiteral("precommand"), precommand);
const auto requiresAuthentication = smtpMailTransport.requiresAuthentication();
grp.writeEntry(QStringLiteral("requiresAuthentication"), requiresAuthentication);
const auto specifyHostname = smtpMailTransport.specifyHostname();
grp.writeEntry(QStringLiteral("specifyHostname"), specifyHostname);
const auto localHostname = smtpMailTransport.localHostname();
grp.writeEntry(QStringLiteral("localHostname"), localHostname);
const auto specifySenderOverwriteAddress = smtpMailTransport.specifySenderOverwriteAddress();
grp.writeEntry(QStringLiteral("specifySenderOverwriteAddress"), specifySenderOverwriteAddress);
const auto storePassword = smtpMailTransport.storePassword();
grp.writeEntry(QStringLiteral("storePassword"), storePassword);
const auto senderOverwriteAddress = smtpMailTransport.senderOverwriteAddress();
grp.writeEntry(QStringLiteral("senderOverwriteAddress"), senderOverwriteAddress);
const auto encryption = smtpMailTransport.encryption();
grp.writeEntry(QStringLiteral("encryption"), encryption);
const auto authenticationType = smtpMailTransport.authenticationType();
grp.writeEntry(QStringLiteral("authenticationType"), authenticationType);
if (transportId == defaultTransport) {
KConfigGroup generalGrp = config.group(QStringLiteral("General"));
generalGrp.writeEntry(QStringLiteral("default-transport"), transportValue);
}
}
......@@ -48,6 +48,7 @@ protected:
private:
Q_REQUIRED_RESULT QString uniqueIdentityName(const QString &name);
uint mIdentityUoid = 1;
uint mMailTransportId = 1;
};
#endif // IMPORTMAILJOBINTERFACETESTIMPL_H
......@@ -154,8 +154,9 @@ void ImportMailJobInterface::importMailTransport(const QString &tempDirName)
defaultTransport = group.readEntry(QStringLiteral("default-transport"), -1);
}
const QStringList transportList = transportConfig->groupList().filter(QRegularExpression(QStringLiteral("Transport \\d+")));
for (const QString &transport : transportList) {
QStringList transportList = transportConfig->groupList().filter(QRegularExpression(QStringLiteral("Transport \\d+")));
std::sort(transportList.begin(), transportList.end());
for (const QString &transport : qAsConst(transportList)) {
KConfigGroup group = transportConfig->group(transport);
const int transportId = group.readEntry(QStringLiteral("id"), -1);
if (transportId == -1) {
......
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