diff --git a/core/autotests/mail/data/import/identities/references/identities/emailidentities b/core/autotests/mail/data/import/identities/references/identities/emailidentities index e69de29..55a634c 100644 --- a/core/autotests/mail/data/import/identities/references/identities/emailidentities +++ b/core/autotests/mail/data/import/identities/references/identities/emailidentities @@ -0,0 +1,60 @@ +[General] +Default Identity=2 + +[Identity #0] +Attach Vcard=false +Autocorrection Language=fr_FR +Bcc=dd@foo.com +Default Domain=9td +Dictionary=français (France) +Disable Fcc=false +Drafts=3730 +Email Address=dd@foo.com +Email Aliases=dde@foo.com +Fcc=3734 +Identity=Kolab +Image Location= +Inline Signature=OpenGL Experts\n +Inlined Html=false +Name=Bla Bli +Pgp Auto Encrypt=false +Pgp Auto Sign=false +Preferred Crypto Message Format=s/mime +SMIME Encryption Key=E225DBF44009243D1F177F552D5397C +SMIME Signing Key=9243D1F177F552D5397C +Signature Enabled=true +Signature Type=inline +Templates=3735 +Transport=1960518839 +X-FaceEnabled=true +uoid=1 + +[Identity #1] +Attach Vcard=false +Autocorrection Language=fr_FR +Bcc=foo@kde.org +Default Domain=zym0 +Dictionary=American English (United States) +Disable Fcc=false +Drafts=3730 +Email Address=foo@kde.org +Email Aliases= +Fcc=3734 +Identity=Default +Image Location= +Inline Signature=olutions\s +Inlined Html=false +Name=kd +Organization=kde +PGP Encryption Key=CDF87D8A5BAA692D34B30D1065D31 +PGP Signing Key=F87D8A5BAA692D34B30D1065D31 +Pgp Auto Encrypt=false +Pgp Auto Sign=false +Preferred Crypto Message Format=openpgp/mime +Reply-To Address=foo@kde.org +Signature Enabled=true +Signature Type=inline +Templates=3735 +Transport=1701481874 +X-FaceEnabled=false +uoid=2 diff --git a/core/autotests/mail/importmailjobinterfacetestimpl.cpp b/core/autotests/mail/importmailjobinterfacetestimpl.cpp index 0448dd6..9ba9b59 100644 --- a/core/autotests/mail/importmailjobinterfacetestimpl.cpp +++ b/core/autotests/mail/importmailjobinterfacetestimpl.cpp @@ -1,136 +1,139 @@ /* Copyright (C) 2020 Laurent Montel 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 "importmailjobinterfacetestimpl.h" #include "archivestorage.h" #include "resourceconvertertest.h" #include "testimportfile.h" #include "utils.h" #include "mail/smtpmailtransport.h" #include #include #include ImportMailJobInterfaceTestImpl::ImportMailJobInterfaceTestImpl(QObject *parent, Utils::StoredTypes typeSelected, ArchiveStorage *archiveStorage, int numberOfStep) : ImportMailJobInterface(parent, typeSelected, archiveStorage, numberOfStep) { } ImportMailJobInterfaceTestImpl::~ImportMailJobInterfaceTestImpl() { QVERIFY(QDir(extractPath()).removeRecursively()); } void ImportMailJobInterfaceTestImpl::start() { QDir().mkpath(extractPath()); //Create temporary file for identities ImportMailJobInterface::start(); } Akonadi::Collection::Id ImportMailJobInterfaceTestImpl::convertFolderPathToCollectionId(const QString &path) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.convertFolderPathToCollectionId(path); } void ImportMailJobInterfaceTestImpl::synchronizeResource(const QStringList &lst) { mLogCreateResource->logSynchronizeResource(lst); slotNextStep(); } QString ImportMailJobInterfaceTestImpl::createResource(const QString &resources, const QString &name, const QMap &settings, bool synchronizeTree) { return mLogCreateResource->logCreateResource(resources, name, settings, synchronizeTree); } void ImportMailJobInterfaceTestImpl::registerSpecialCollection(Akonadi::SpecialMailCollections::Type type, qint64 colId) { mLogCreateResource->logRegisterSpecialCollection(type, colId); } void ImportMailJobInterfaceTestImpl::importFilters(const QVector &filters) { qDebug() << " void ImportMailJobInterfaceTestImpl::importFilters(const QVector &filters)"; } QString ImportMailJobInterfaceTestImpl::adaptResourcePath(const KSharedConfigPtr &resourceConfig, const QString &storedData) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptResourcePath(resourceConfig, storedData); } QString ImportMailJobInterfaceTestImpl::adaptNewResourceUrl(bool overwriteResources, const KSharedConfig::Ptr &resourceConfig, const QString &storePath) { ResourceConverterTest resourceConverterTest; resourceConverterTest.setTestPath(mPathConfig); return resourceConverterTest.adaptNewResourceUrl(overwriteResources, resourceConfig, storePath); } void ImportMailJobInterfaceTestImpl::addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) { + //qDebug() << " void ImportMailJobInterfaceTestImpl::addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) not implemented yet" << oldUid << " name " << name; const QString uniqueName = uniqueIdentityName(name); - qDebug() << " void ImportMailJobInterfaceTestImpl::addNewIdentity(const QString &name, KConfigGroup &group, int defaultIdentities, int oldUid) not implemented yet" << oldUid << " name " << name; KIdentityManagement::Identity identity; - identity.setUoid(mIdentityUoid++); + uint value = mIdentityUoid; + mIdentityUoid++; + identity.setUoid(value); group.writeEntry(QStringLiteral("Name"), uniqueName); group.sync(); + //TODO ???? + KConfig config(QStringLiteral("/tmp/identities//identities/emailidentities")); + identity.readConfig(group); if (oldUid != -1) { mHashIdentity.insert(oldUid, identity.uoid()); if (oldUid == defaultIdentities) { - //TODO - //mIdentityManager->setAsDefault(identity->uoid()); + KConfigGroup grpGeneral = config.group(QStringLiteral("General")); + grpGeneral.writeEntry("Default Identity", identity.uoid()); } } -// identity.writeConfig(); - //TODO write identity ? - //TODO log it. - //mIdentityManager->commit(); + KConfigGroup grp = config.group(QStringLiteral("Identity #%1").arg(value-1)); + identity.writeConfig(grp); } QString ImportMailJobInterfaceTestImpl::uniqueIdentityName(const QString &name) { QString newName(name); int i = 0; const QStringList existingIdentityNames{QStringLiteral("identity1"), QStringLiteral("identity2")}; while (existingIdentityNames.contains(newName)) { newName = QStringLiteral("%1_%2").arg(name).arg(i); ++i; } return newName; } void ImportMailJobInterfaceTestImpl::importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) { qDebug() << "importCustomMailTransport(const QString &identifierValue, const KConfigGroup &group, int defaultTransport, int transportId) not implemented yet"; } void ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const SmtpMailTransport &smtpMailTransport, int defaultTransport, int transportId) { qDebug() << "ImportMailJobInterfaceTestImpl::importSmtpMailTransport(const KConfigGroup &group, int defaultTransport, int transportId) not implement yet"; qDebug() << " defaultTransport " << defaultTransport << " transportId " << transportId; }