File indexing completed on 2024-12-22 04:52:49
0001 /* 0002 SPDX-FileCopyrightText: 2012-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "evolutionsettings.h" 0008 #include "evolutionutil.h" 0009 #include "importwizardutil.h" 0010 #include <MailCommon/MailUtil> 0011 0012 #include <KIdentityManagementCore/Identity> 0013 0014 #include <MailTransport/TransportManager> 0015 0016 #include "evolutionv3plugin_debug.h" 0017 0018 #include <QDir> 0019 #include <QDomDocument> 0020 #include <QDomElement> 0021 #include <QFile> 0022 0023 EvolutionSettings::EvolutionSettings() = default; 0024 0025 EvolutionSettings::~EvolutionSettings() = default; 0026 0027 void EvolutionSettings::loadAccount(const QString &filename) 0028 { 0029 // Read gconf file 0030 QFile file(filename); 0031 if (!file.open(QIODevice::ReadOnly)) { 0032 qCDebug(EVOLUTIONPLUGIN_LOG) << " We can't open file" << filename; 0033 return; 0034 } 0035 QDomDocument doc; 0036 if (!EvolutionUtil::loadInDomDocument(&file, doc)) { 0037 return; 0038 } 0039 QDomElement config = doc.documentElement(); 0040 0041 if (config.isNull()) { 0042 qCDebug(EVOLUTIONPLUGIN_LOG) << "No config found in filename " << filename; 0043 return; 0044 } 0045 for (QDomElement e = config.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { 0046 const QString tag = e.tagName(); 0047 if (tag == QLatin1StringView("entry")) { 0048 if (e.hasAttribute(QStringLiteral("name"))) { 0049 const QString attr = e.attribute(QStringLiteral("name")); 0050 if (attr == QLatin1StringView("accounts")) { 0051 readAccount(e); 0052 } else if (attr == QLatin1StringView("signatures")) { 0053 readSignatures(e); 0054 } else if (attr == QLatin1StringView("send_recv_all_on_start")) { 0055 // TODO: implement it. 0056 } else if (attr == QLatin1StringView("send_recv_on_start")) { 0057 // TODO: implement it. 0058 } else { 0059 qCDebug(EVOLUTIONPLUGIN_LOG) << " attr unknown " << attr; 0060 } 0061 } 0062 } 0063 } 0064 } 0065 0066 void EvolutionSettings::loadLdap(const QString &filename) 0067 { 0068 QFile file(filename); 0069 if (!file.open(QIODevice::ReadOnly)) { 0070 qCDebug(EVOLUTIONPLUGIN_LOG) << " We can't open file" << filename; 0071 return; 0072 } 0073 QDomDocument doc; 0074 if (!EvolutionUtil::loadInDomDocument(&file, doc)) { 0075 return; 0076 } 0077 QDomElement ldapConfig = doc.documentElement(); 0078 for (QDomElement e = ldapConfig.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { 0079 const QString tag = e.tagName(); 0080 if (tag == QLatin1StringView("entry")) { 0081 for (QDomElement serverConfig = e.firstChildElement(); !serverConfig.isNull(); serverConfig = serverConfig.nextSiblingElement()) { 0082 if (serverConfig.tagName() == QLatin1StringView("li")) { 0083 QDomElement ldapValue = serverConfig.firstChildElement(); 0084 readLdap(ldapValue.text()); 0085 } 0086 } 0087 } 0088 } 0089 } 0090 0091 void EvolutionSettings::readLdap(const QString &ldapStr) 0092 { 0093 qCDebug(EVOLUTIONPLUGIN_LOG) << " ldap " << ldapStr; 0094 QDomDocument ldap; 0095 if (!EvolutionUtil::loadInDomDocument(ldapStr, ldap)) { 0096 return; 0097 } 0098 0099 QDomElement domElement = ldap.documentElement(); 0100 0101 if (domElement.isNull()) { 0102 qCDebug(EVOLUTIONPLUGIN_LOG) << "ldap not found"; 0103 return; 0104 } 0105 // Ldap server 0106 if (domElement.attribute(QStringLiteral("base_uri")) == QLatin1StringView("ldap://")) { 0107 for (QDomElement e = domElement.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { 0108 // const QString name = e.attribute( QLatin1StringView( "name" ) ); We don't use it in kmail 0109 0110 ldapStruct ldap; 0111 const QString relative_uri = e.attribute(QStringLiteral("relative_uri")); 0112 const QString uri = e.attribute(QStringLiteral("uri")); 0113 QUrl url(uri); 0114 ldap.port = url.port(); 0115 ldap.ldapUrl = url; 0116 qCDebug(EVOLUTIONPLUGIN_LOG) << " relative_uri" << relative_uri; 0117 0118 QDomElement propertiesElement = e.firstChildElement(); 0119 if (!propertiesElement.isNull()) { 0120 for (QDomElement property = propertiesElement.firstChildElement(); !property.isNull(); property = property.nextSiblingElement()) { 0121 const QString propertyTag = property.tagName(); 0122 if (propertyTag == QLatin1StringView("property")) { 0123 if (property.hasAttribute(QStringLiteral("name"))) { 0124 const QString propertyName = property.attribute(QStringLiteral("name")); 0125 if (propertyName == QLatin1StringView("timeout")) { 0126 ldap.timeout = property.attribute(QStringLiteral("value")).toInt(); 0127 } else if (propertyName == QLatin1StringView("ssl")) { 0128 const QString value = property.attribute(QStringLiteral("value")); 0129 if (value == QLatin1StringView("always")) { 0130 ldap.useSSL = true; 0131 } else if (value == QLatin1StringView("whenever_possible")) { 0132 ldap.useTLS = true; 0133 } else { 0134 qCDebug(EVOLUTIONPLUGIN_LOG) << " ssl attribute unknown" << value; 0135 } 0136 } else if (propertyName == QLatin1StringView("limit")) { 0137 ldap.limit = property.attribute(QStringLiteral("value")).toInt(); 0138 } else if (propertyName == QLatin1StringView("binddn")) { 0139 ldap.dn = property.attribute(QStringLiteral("value")); 0140 } else if (propertyName == QLatin1StringView("auth")) { 0141 const QString value = property.attribute(QStringLiteral("value")); 0142 if (value == QLatin1StringView("ldap/simple-email")) { 0143 // TODO: 0144 } else if (value == QLatin1StringView("none")) { 0145 // TODO: 0146 } else if (value == QLatin1StringView("ldap/simple-binddn")) { 0147 // TODO: 0148 } else { 0149 qCDebug(EVOLUTIONPLUGIN_LOG) << " Unknown auth value " << value; 0150 } 0151 qCDebug(EVOLUTIONPLUGIN_LOG) << " auth" << value; 0152 } else { 0153 qCDebug(EVOLUTIONPLUGIN_LOG) << " property unknown :" << propertyName; 0154 } 0155 } 0156 } else { 0157 qCDebug(EVOLUTIONPLUGIN_LOG) << " tag unknown :" << propertyTag; 0158 } 0159 } 0160 ImportWizardUtil::mergeLdap(ldap); 0161 } 0162 } 0163 } 0164 } 0165 0166 void EvolutionSettings::readSignatures(const QDomElement &account) 0167 { 0168 for (QDomElement signatureConfig = account.firstChildElement(); !signatureConfig.isNull(); signatureConfig = signatureConfig.nextSiblingElement()) { 0169 if (signatureConfig.tagName() == QLatin1StringView("li")) { 0170 QDomElement stringValue = signatureConfig.firstChildElement(); 0171 extractSignatureInfo(stringValue.text()); 0172 } 0173 } 0174 } 0175 0176 void EvolutionSettings::extractSignatureInfo(const QString &info) 0177 { 0178 // qCDebug(EVOLUTIONPLUGIN_LOG)<<" signature info "<<info; 0179 QDomDocument signature; 0180 if (!EvolutionUtil::loadInDomDocument(info, signature)) { 0181 return; 0182 } 0183 0184 QDomElement domElement = signature.documentElement(); 0185 0186 if (domElement.isNull()) { 0187 qCDebug(EVOLUTIONPLUGIN_LOG) << "Signature not found"; 0188 return; 0189 } 0190 for (QDomElement e = domElement.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { 0191 KIdentityManagementCore::Signature signature; 0192 0193 const QString tag = e.tagName(); 0194 const QString uid = e.attribute(QStringLiteral("uid")); 0195 const QString signatureName = e.attribute(QStringLiteral("name")); // Use it ? 0196 const QString format = e.attribute(QStringLiteral("text")); 0197 const bool automatic = (e.attribute(QStringLiteral("auto")) == QLatin1StringView("true")); 0198 if (automatic) { 0199 // TODO: 0200 } else { 0201 if (format == QLatin1StringView("text/html")) { 0202 signature.setInlinedHtml(true); 0203 } else if (format == QLatin1StringView("text/plain")) { 0204 signature.setInlinedHtml(false); 0205 } 0206 0207 if (tag == QLatin1StringView("filename")) { 0208 if (e.hasAttribute(QStringLiteral("script")) && e.attribute(QStringLiteral("script")) == QLatin1StringView("true")) { 0209 signature.setPath(e.text(), true); 0210 signature.setType(KIdentityManagementCore::Signature::FromCommand); 0211 } else { 0212 signature.setPath(QDir::homePath() + QLatin1StringView("/.local/share/evolution/signatures/") + e.text(), false); 0213 signature.setType(KIdentityManagementCore::Signature::FromFile); 0214 } 0215 } 0216 } 0217 mMapSignature.insert(uid, signature); 0218 0219 qCDebug(EVOLUTIONPLUGIN_LOG) << " signature tag :" << tag; 0220 } 0221 } 0222 0223 void EvolutionSettings::readAccount(const QDomElement &account) 0224 { 0225 for (QDomElement accountConfig = account.firstChildElement(); !accountConfig.isNull(); accountConfig = accountConfig.nextSiblingElement()) { 0226 if (accountConfig.tagName() == QLatin1StringView("li")) { 0227 QDomElement stringValue = accountConfig.firstChildElement(); 0228 extractAccountInfo(stringValue.text()); 0229 } 0230 } 0231 } 0232 0233 void EvolutionSettings::extractAccountInfo(const QString &info) 0234 { 0235 qCDebug(EVOLUTIONPLUGIN_LOG) << " info " << info; 0236 // Read QDomElement 0237 QDomDocument account; 0238 if (!EvolutionUtil::loadInDomDocument(info, account)) { 0239 return; 0240 } 0241 0242 QDomElement domElement = account.documentElement(); 0243 0244 if (domElement.isNull()) { 0245 qCDebug(EVOLUTIONPLUGIN_LOG) << "Account not found"; 0246 return; 0247 } 0248 0249 QString name; 0250 if (domElement.hasAttribute(QStringLiteral("name"))) { 0251 name = domElement.attribute(QStringLiteral("name")); 0252 } 0253 0254 KIdentityManagementCore::Identity *newIdentity = createIdentity(name); 0255 0256 const bool enableManualCheck = (domElement.attribute(QStringLiteral("enabled")) == QLatin1StringView("true")); 0257 0258 for (QDomElement e = domElement.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) { 0259 const QString tag = e.tagName(); 0260 if (tag == QLatin1StringView("identity")) { 0261 for (QDomElement identity = e.firstChildElement(); !identity.isNull(); identity = identity.nextSiblingElement()) { 0262 const QString identityTag = identity.tagName(); 0263 if (identityTag == QLatin1StringView("name")) { 0264 const QString fullName(identity.text()); 0265 newIdentity->setIdentityName(fullName); 0266 newIdentity->setFullName(fullName); 0267 } else if (identityTag == QLatin1StringView("addr-spec")) { 0268 newIdentity->setPrimaryEmailAddress(identity.text()); 0269 } else if (identityTag == QLatin1StringView("organization")) { 0270 newIdentity->setOrganization(identity.text()); 0271 } else if (identityTag == QLatin1StringView("signature")) { 0272 if (identity.hasAttribute(QStringLiteral("uid"))) { 0273 newIdentity->setSignature(mMapSignature.value(identity.attribute(QStringLiteral("uid")))); 0274 } 0275 } else if (identityTag == QLatin1StringView("reply-to")) { 0276 newIdentity->setReplyToAddr(identity.text()); 0277 } else { 0278 qCDebug(EVOLUTIONPLUGIN_LOG) << " tag identity not found :" << identityTag; 0279 } 0280 } 0281 } else if (tag == QLatin1StringView("source")) { 0282 if (e.hasAttribute(QStringLiteral("save-passwd")) && e.attribute(QStringLiteral("save-passwd")) == QLatin1StringView("true")) { 0283 // TODO 0284 } 0285 int interval = -1; 0286 bool intervalCheck = false; 0287 if (e.hasAttribute(QStringLiteral("auto-check"))) { 0288 intervalCheck = (e.attribute(QStringLiteral("auto-check")) == QLatin1StringView("true")); 0289 } 0290 if (e.hasAttribute(QStringLiteral("auto-check-timeout"))) { 0291 interval = e.attribute(QStringLiteral("auto-check-timeout")).toInt(); 0292 } 0293 for (QDomElement server = e.firstChildElement(); !server.isNull(); server = server.nextSiblingElement()) { 0294 const QString serverTag = server.tagName(); 0295 if (serverTag == QLatin1StringView("url")) { 0296 qCDebug(EVOLUTIONPLUGIN_LOG) << " server.text() :" << server.text(); 0297 QUrl serverUrl(server.text()); 0298 const QString scheme = serverUrl.scheme(); 0299 QMap<QString, QVariant> settings; 0300 const int port = serverUrl.port(); 0301 0302 const QString path = serverUrl.path(); 0303 qCDebug(EVOLUTIONPLUGIN_LOG) << " path !" << path; 0304 const QString userName = serverUrl.userInfo(); 0305 0306 const QStringList listArgument = path.split(QLatin1Char(';')); 0307 0308 // imapx://name@pop3.xx.org:993/;security-method=ssl-on-alternate-port;namespace;shell-command=ssh%20-C%20-l%20%25u%20%25h%20exec%20/usr/sbin/imapd%20;use-shell-command=true 0309 if (scheme == QLatin1StringView("imap") || scheme == QLatin1StringView("imapx")) { 0310 if (port > 0) { 0311 settings.insert(QStringLiteral("ImapPort"), port); 0312 } 0313 // Perhaps imapx is specific don't know 0314 if (intervalCheck) { 0315 settings.insert(QStringLiteral("IntervalCheckEnabled"), true); 0316 } 0317 if (interval > -1) { 0318 settings.insert(QStringLiteral("IntervalCheckTime"), interval); 0319 } 0320 0321 bool found = false; 0322 const QString securityMethod = getSecurityMethod(listArgument, found); 0323 if (found) { 0324 if (securityMethod == QLatin1StringView("none")) { 0325 settings.insert(QStringLiteral("Safety"), QStringLiteral("None")); 0326 // Nothing 0327 } else if (securityMethod == QLatin1StringView("ssl-on-alternate-port")) { 0328 settings.insert(QStringLiteral("Safety"), QStringLiteral("SSL")); 0329 } else { 0330 qCDebug(EVOLUTIONPLUGIN_LOG) << " security method unknown : " << path; 0331 } 0332 } else { 0333 settings.insert(QStringLiteral("Safety"), QStringLiteral("STARTTLS")); 0334 } 0335 0336 addAuth(settings, QStringLiteral("Authentication"), userName); 0337 const QString agentIdentifyName = 0338 LibImportWizard::AbstractBase::createResource(QStringLiteral("akonadi_imap_resource"), name, settings); 0339 // By default 0340 addCheckMailOnStartup(agentIdentifyName, enableManualCheck); 0341 addToManualCheck(agentIdentifyName, enableManualCheck); 0342 } else if (scheme == QLatin1StringView("pop")) { 0343 if (port > 0) { 0344 settings.insert(QStringLiteral("Port"), port); 0345 } 0346 bool found = false; 0347 const QString securityMethod = getSecurityMethod(listArgument, found); 0348 if (found) { 0349 if (securityMethod == QLatin1StringView("none")) { 0350 // Nothing 0351 } else if (securityMethod == QLatin1StringView("ssl-on-alternate-port")) { 0352 settings.insert(QStringLiteral("UseSSL"), true); 0353 } else { 0354 qCDebug(EVOLUTIONPLUGIN_LOG) << " security method unknown : " << path; 0355 } 0356 } else { 0357 settings.insert(QStringLiteral("UseTLS"), true); 0358 } 0359 0360 if (intervalCheck) { 0361 settings.insert(QStringLiteral("IntervalCheckEnabled"), true); 0362 } 0363 if (interval > -1) { 0364 settings.insert(QStringLiteral("IntervalCheckInterval"), interval); 0365 } 0366 if (e.hasAttribute(QStringLiteral("keep-on-server")) && e.attribute(QStringLiteral("keep-on-server")) == QLatin1StringView("true")) { 0367 settings.insert(QStringLiteral("LeaveOnServer"), true); 0368 } 0369 addAuth(settings, QStringLiteral("AuthenticationMethod"), userName); 0370 const QString agentIdentifyName = 0371 LibImportWizard::AbstractBase::createResource(QStringLiteral("akonadi_pop3_resource"), name, settings); 0372 // By default 0373 addCheckMailOnStartup(agentIdentifyName, enableManualCheck); 0374 addToManualCheck(agentIdentifyName, enableManualCheck); 0375 } else if (scheme == QLatin1StringView("spool") || scheme == QLatin1StringView("mbox")) { 0376 // mbox file 0377 settings.insert(QStringLiteral("Path"), path); 0378 settings.insert(QStringLiteral("DisplayName"), name); 0379 LibImportWizard::AbstractBase::createResource(QStringLiteral("akonadi_mbox_resource"), name, settings); 0380 } else if (scheme == QLatin1StringView("maildir") || scheme == QLatin1StringView("spooldir")) { 0381 settings.insert(QStringLiteral("Path"), path); 0382 LibImportWizard::AbstractBase::createResource(QStringLiteral("akonadi_maildir_resource"), name, settings); 0383 } else if (scheme == QLatin1StringView("nntp")) { 0384 // FIXME in the future 0385 qCDebug(EVOLUTIONPLUGIN_LOG) << " For the moment we can't import nntp resource"; 0386 } else { 0387 qCDebug(EVOLUTIONPLUGIN_LOG) << " unknown scheme " << scheme; 0388 } 0389 } else { 0390 qCDebug(EVOLUTIONPLUGIN_LOG) << " server tag unknown :" << serverTag; 0391 } 0392 } 0393 } else if (tag == QLatin1StringView("transport")) { 0394 if (e.hasAttribute(QStringLiteral("save-passwd")) && e.attribute(QStringLiteral("save-passwd")) == QLatin1StringView("true")) { 0395 // TODO save to kwallet ? 0396 } 0397 0398 MailTransport::Transport *transport = createTransport(); 0399 transport->setIdentifier(QStringLiteral("SMTP")); 0400 for (QDomElement smtp = e.firstChildElement(); !smtp.isNull(); smtp = smtp.nextSiblingElement()) { 0401 const QString smtpTag = smtp.tagName(); 0402 if (smtpTag == QLatin1StringView("url")) { 0403 qCDebug(EVOLUTIONPLUGIN_LOG) << " smtp.text() :" << smtp.text(); 0404 QUrl smtpUrl(smtp.text()); 0405 const QString scheme = smtpUrl.scheme(); 0406 if (scheme != QLatin1StringView("sendmail")) { 0407 transport->setHost(smtpUrl.host()); 0408 transport->setName(smtpUrl.host()); 0409 // TODO setUserName : 0410 // transport->setRequiresAuthentication(true); 0411 // transport->setUserName(....); 0412 const int port = smtpUrl.port(); 0413 if (port > 0) { 0414 transport->setPort(port); 0415 } 0416 0417 const QString userName = smtpUrl.userInfo(); 0418 bool found = false; 0419 const QString authMethod = getAuthMethod(userName, found); 0420 if (found) { 0421 if (authMethod == QLatin1StringView("PLAIN")) { 0422 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::PLAIN); 0423 } else if (authMethod == QLatin1StringView("NTLM")) { 0424 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::NTLM); 0425 } else if (authMethod == QLatin1StringView("DIGEST-MD5")) { 0426 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::DIGEST_MD5); 0427 } else if (authMethod == QLatin1StringView("CRAM-MD5")) { 0428 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::CRAM_MD5); 0429 } else if (authMethod == QLatin1StringView("LOGIN")) { 0430 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::LOGIN); 0431 } else if (authMethod == QLatin1StringView("GSSAPI")) { 0432 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::GSSAPI); 0433 } else if (authMethod == QLatin1StringView("POPB4SMTP")) { 0434 transport->setAuthenticationType(MailTransport::Transport::EnumAuthenticationType::APOP); //???? 0435 } else { 0436 qCDebug(EVOLUTIONPLUGIN_LOG) << " smtp auth method unknown " << authMethod; 0437 } 0438 } 0439 0440 const QString path = smtpUrl.path(); 0441 found = false; 0442 const QStringList listArgument = path.split(QLatin1Char(';')); 0443 const QString securityMethod = getSecurityMethod(listArgument, found); 0444 if (found) { 0445 if (securityMethod == QLatin1StringView("none")) { 0446 transport->setEncryption(MailTransport::Transport::EnumEncryption::None); 0447 } else if (securityMethod == QLatin1StringView("ssl-on-alternate-port")) { 0448 transport->setEncryption(MailTransport::Transport::EnumEncryption::SSL); 0449 } else { 0450 qCDebug(EVOLUTIONPLUGIN_LOG) << " security method unknown : " << path; 0451 } 0452 } else { 0453 transport->setEncryption(MailTransport::Transport::EnumEncryption::TLS); 0454 } 0455 } 0456 } else { 0457 qCDebug(EVOLUTIONPLUGIN_LOG) << " smtp tag unknown :" << smtpTag; 0458 } 0459 } 0460 storeTransport(transport, true); 0461 } else if (tag == QLatin1StringView("drafts-folder")) { 0462 const QString selectedFolder = MailCommon::Util::convertFolderPathToCollectionStr(e.text().remove(QStringLiteral("folder://"))); 0463 newIdentity->setDrafts(selectedFolder); 0464 } else if (tag == QLatin1StringView("sent-folder")) { 0465 const QString selectedFolder = MailCommon::Util::convertFolderPathToCollectionStr(e.text().remove(QStringLiteral("folder://"))); 0466 newIdentity->setFcc(selectedFolder); 0467 } else if (tag == QLatin1StringView("auto-cc")) { 0468 if (e.hasAttribute(QStringLiteral("always")) && (e.attribute(QStringLiteral("always")) == QLatin1StringView("true"))) { 0469 QDomElement recipient = e.firstChildElement(); 0470 const QString text = recipient.text(); 0471 newIdentity->setCc(text); 0472 } 0473 } else if (tag == QLatin1StringView("reply-to")) { 0474 newIdentity->setReplyToAddr(e.text()); 0475 } else if (tag == QLatin1StringView("auto-bcc")) { 0476 if (e.hasAttribute(QStringLiteral("always")) && (e.attribute(QStringLiteral("always")) == QLatin1StringView("true"))) { 0477 QDomElement recipient = e.firstChildElement(); 0478 const QString text = recipient.text(); 0479 newIdentity->setBcc(text); 0480 } 0481 } else if (tag == QLatin1StringView("receipt-policy")) { 0482 if (e.hasAttribute(QStringLiteral("policy"))) { 0483 const QString policy = e.attribute(QStringLiteral("policy")); 0484 // TODO 0485 } 0486 } else if (tag == QLatin1StringView("pgp")) { 0487 if (e.hasAttribute(QStringLiteral("encrypt-to-self")) && (e.attribute(QStringLiteral("encrypt-to-self")) == QLatin1StringView("true"))) { 0488 // TODO 0489 } 0490 if (e.hasAttribute(QStringLiteral("always-trust")) && (e.attribute(QStringLiteral("always-trust")) == QLatin1StringView("true"))) { 0491 // TODO 0492 } 0493 if (e.hasAttribute(QStringLiteral("always-sign")) && (e.attribute(QStringLiteral("always-sign")) == QLatin1StringView("true"))) { 0494 // TODO 0495 } 0496 if (e.hasAttribute(QStringLiteral("no-imip-sign")) && (e.attribute(QStringLiteral("no-imip-sign")) == QLatin1StringView("true"))) { 0497 // TODO 0498 } 0499 } else if (tag == QLatin1StringView("smime")) { 0500 if (e.hasAttribute(QStringLiteral("sign-default")) && (e.attribute(QStringLiteral("sign-default")) == QLatin1StringView("true"))) { 0501 // TODO 0502 } 0503 if (e.hasAttribute(QStringLiteral("encrypt-default")) && (e.attribute(QStringLiteral("encrypt-default")) == QLatin1StringView("true"))) { 0504 // TODO 0505 } 0506 if (e.hasAttribute(QStringLiteral("encrypt-to-self")) && (e.attribute(QStringLiteral("encrypt-to-self")) == QLatin1StringView("true"))) { 0507 // TODO 0508 } 0509 // TODO 0510 } else { 0511 qCDebug(EVOLUTIONPLUGIN_LOG) << " tag not know :" << tag; 0512 } 0513 } 0514 storeIdentity(newIdentity); 0515 } 0516 0517 QString EvolutionSettings::getSecurityMethod(const QStringList &listArgument, bool &found) 0518 { 0519 found = false; 0520 if (listArgument.isEmpty()) { 0521 return {}; 0522 } 0523 for (const QString &str : listArgument) { 0524 if (str.contains(QLatin1StringView("security-method="))) { 0525 const int index = str.indexOf(QLatin1StringView("security-method=")); 0526 if (index != -1) { 0527 const QString securityMethod = str.right(str.length() - index - 16 /*security-method=*/); 0528 found = true; 0529 return securityMethod; 0530 } 0531 } 0532 } 0533 return {}; 0534 } 0535 0536 QString EvolutionSettings::getAuthMethod(const QString &path, bool &found) 0537 { 0538 const int index = path.indexOf(QLatin1StringView("auth=")); 0539 if (index != -1) { 0540 const QString securityMethod = path.right(path.length() - index - 5 /*auth=*/); 0541 found = true; 0542 return securityMethod; 0543 } 0544 found = false; 0545 return {}; 0546 } 0547 0548 void EvolutionSettings::addAuth(QMap<QString, QVariant> &settings, const QString &argument, const QString &userName) 0549 { 0550 bool found = false; 0551 const QString authMethod = getAuthMethod(userName, found); 0552 if (found) { 0553 if (authMethod == QLatin1StringView("PLAIN")) { 0554 settings.insert(argument, MailTransport::Transport::EnumAuthenticationType::PLAIN); 0555 } else if (authMethod == QLatin1StringView("NTLM")) { 0556 settings.insert(argument, MailTransport::Transport::EnumAuthenticationType::NTLM); 0557 } else if (authMethod == QLatin1StringView("DIGEST-MD5")) { 0558 settings.insert(argument, MailTransport::Transport::EnumAuthenticationType::DIGEST_MD5); 0559 } else if (authMethod == QLatin1StringView("CRAM-MD5")) { 0560 settings.insert(argument, MailTransport::Transport::EnumAuthenticationType::CRAM_MD5); 0561 } else if (authMethod == QLatin1StringView("LOGIN")) { 0562 settings.insert(argument, MailTransport::Transport::EnumAuthenticationType::LOGIN); 0563 } else if (authMethod == QLatin1StringView("POPB4SMTP")) { 0564 settings.insert(argument, MailTransport::Transport::EnumAuthenticationType::APOP); //???? 0565 } else { 0566 qCDebug(EVOLUTIONPLUGIN_LOG) << " smtp auth method unknown " << authMethod; 0567 } 0568 } 0569 }