Commit 23547ea9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move method to util.h file

parent 57cdf387
Pipeline #72980 canceled with stage
......@@ -79,17 +79,6 @@
using namespace MessageComposer;
static QStringList encodeIdn(const QStringList &emails)
{
QStringList encoded;
encoded.reserve(emails.count());
for (const QString &email : emails) {
encoded << KEmailAddress::normalizeAddressesAndEncodeIdn(email);
}
return encoded;
}
ComposerViewBase::ComposerViewBase(QObject *parent, QWidget *parentGui)
: QObject(parent)
, m_msg(KMime::Message::Ptr(new KMime::Message))
......@@ -1127,14 +1116,14 @@ void ComposerViewBase::fillQueueJobHeaders(MailTransport::MessageQueueJob *qjob,
// if this header is not empty, it contains the real recipient of the message, either the primary or one of the
// secondary recipients. so we set that to the transport job, while leaving the message itself alone.
if (KMime::Headers::Base *realTo = message->headerByType("X-KMail-EncBccRecipients")) {
qjob->addressAttribute().setTo(cleanEmailList(encodeIdn(realTo->asUnicodeString().split(QLatin1Char('%')))));
qjob->addressAttribute().setTo(MessageComposer::Util::cleanUpEmailListAndEncoding(realTo->asUnicodeString().split(QLatin1Char('%'))));
message->removeHeader("X-KMail-EncBccRecipients");
message->assemble();
qCDebug(MESSAGECOMPOSER_LOG) << "sending with-bcc encr mail to a/n recipient:" << qjob->addressAttribute().to();
} else {
qjob->addressAttribute().setTo(cleanEmailList(encodeIdn(infoPart->to())));
qjob->addressAttribute().setCc(cleanEmailList(encodeIdn(infoPart->cc())));
qjob->addressAttribute().setBcc(cleanEmailList(encodeIdn(infoPart->bcc())));
qjob->addressAttribute().setTo(MessageComposer::Util::cleanUpEmailListAndEncoding(infoPart->to()));
qjob->addressAttribute().setCc(MessageComposer::Util::cleanUpEmailListAndEncoding(infoPart->cc()));
qjob->addressAttribute().setBcc(MessageComposer::Util::cleanUpEmailListAndEncoding(infoPart->bcc()));
}
}
......@@ -1802,16 +1791,6 @@ void ComposerViewBase::setUrgent(bool urgent)
m_urgent = urgent;
}
QStringList ComposerViewBase::cleanEmailList(const QStringList &emails)
{
QStringList clean;
clean.reserve(emails.count());
for (const QString &email : emails) {
clean << KEmailAddress::extractEmailAddress(email);
}
return clean;
}
int ComposerViewBase::autoSaveInterval() const
{
return m_autoSaveInterval;
......
......@@ -21,6 +21,7 @@
#include "messagecomposer_debug.h"
#include <KCharsets>
#include <KEmailAddress>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -464,3 +465,28 @@ bool MessageComposer::Util::hasMissingAttachments(const QStringList &attachmentK
}
return true;
}
static QStringList encodeIdn(const QStringList &emails)
{
QStringList encoded;
encoded.reserve(emails.count());
for (const QString &email : emails) {
encoded << KEmailAddress::normalizeAddressesAndEncodeIdn(email);
}
return encoded;
}
QStringList MessageComposer::Util::cleanEmailList(const QStringList &emails)
{
QStringList clean;
clean.reserve(emails.count());
for (const QString &email : emails) {
clean << KEmailAddress::extractEmailAddress(email);
}
return clean;
}
QStringList MessageComposer::Util::cleanUpEmailListAndEncoding(const QStringList &emails)
{
return cleanEmailList(encodeIdn(emails));
}
......@@ -75,6 +75,9 @@ Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT bool isStandaloneMessage(const Akonadi:
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT KMime::Message::Ptr message(const Akonadi::Item &item);
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT bool hasMissingAttachments(const QStringList &attachmentKeywords, QTextDocument *doc, const QString &subj);
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QStringList cleanEmailList(const QStringList &emails);
Q_REQUIRED_RESULT MESSAGECOMPOSER_EXPORT QStringList cleanUpEmailListAndEncoding(const QStringList &emails);
}
}
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