Commit 914e294c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Don't try to add more recipents if we can't (reduce number of dialogbox)

parent eead28d3
Pipeline #88599 passed with stage
in 44 minutes and 18 seconds
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(PIM_VERSION "5.18.44")
set(PIM_VERSION "5.18.45")
project(Messagelib VERSION ${PIM_VERSION})
......
......@@ -112,47 +112,69 @@ void ComposerViewBase::setMessage(const KMime::Message::Ptr &msg, bool allowDecr
m_msg = msg;
if (m_recipientsEditor) {
m_recipientsEditor->clear();
m_recipientsEditor->setRecipientString(m_msg->to()->mailboxes(), MessageComposer::Recipient::To);
m_recipientsEditor->setRecipientString(m_msg->cc()->mailboxes(), MessageComposer::Recipient::Cc);
m_recipientsEditor->setRecipientString(m_msg->bcc()->mailboxes(), MessageComposer::Recipient::Bcc);
m_recipientsEditor->setRecipientString(m_msg->replyTo()->mailboxes(), MessageComposer::Recipient::ReplyTo);
bool resultTooManyRecipients = m_recipientsEditor->setRecipientString(m_msg->to()->mailboxes(), MessageComposer::Recipient::To);
if (!resultTooManyRecipients) {
resultTooManyRecipients = m_recipientsEditor->setRecipientString(m_msg->cc()->mailboxes(), MessageComposer::Recipient::Cc);
}
if (!resultTooManyRecipients) {
resultTooManyRecipients = m_recipientsEditor->setRecipientString(m_msg->bcc()->mailboxes(), MessageComposer::Recipient::Bcc);
}
if (!resultTooManyRecipients) {
resultTooManyRecipients = m_recipientsEditor->setRecipientString(m_msg->replyTo()->mailboxes(), MessageComposer::Recipient::ReplyTo);
}
m_recipientsEditor->setFocusBottom();
// If we are loading from a draft, load unexpanded aliases as well
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-To")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::To)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
if (!resultTooManyRecipients) {
// If we are loading from a draft, load unexpanded aliases as well
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-To")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::To)) {
resultTooManyRecipients = true;
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
break;
}
}
}
}
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-CC")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::Cc)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
if (!resultTooManyRecipients) {
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-CC")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::Cc)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
resultTooManyRecipients = true;
break;
}
}
}
}
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-BCC")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::Bcc)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
if (!resultTooManyRecipients) {
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-BCC")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::Bcc)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
resultTooManyRecipients = true;
break;
}
}
}
}
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-Reply-To")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::ReplyTo)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
if (!resultTooManyRecipients) {
if (auto hrd = m_msg->headerByType("X-KMail-UnExpanded-Reply-To")) {
const QStringList spl = hrd->asUnicodeString().split(QLatin1Char(','));
for (const QString &addr : spl) {
if (!m_recipientsEditor->addRecipient(addr, MessageComposer::Recipient::ReplyTo)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add recipient.";
resultTooManyRecipients = true;
break;
}
}
}
}
Q_EMIT tooManyRecipient(resultTooManyRecipients);
}
// First, we copy the message and then parse it to the object tree parser.
// The otp gets the message text out of it, in textualContent(), and also decrypts
// the message if necessary.
......
......@@ -258,6 +258,7 @@ Q_SIGNALS:
*/
void disableHtml(MessageComposer::ComposerViewBase::Confirmation);
void enableHtml();
void tooManyRecipient(bool);
private Q_SLOTS:
void slotEmailAddressResolved(KJob *);
......
......@@ -107,7 +107,7 @@ void RecipientsEditor::addRecipient(RecipientLineNG *line, const QString &recipi
addRecipient(recipient, line->recipientType());
}
void RecipientsEditor::setRecipientString(const QVector<KMime::Types::Mailbox> &mailboxes, Recipient::Type type)
bool RecipientsEditor::setRecipientString(const QVector<KMime::Types::Mailbox> &mailboxes, Recipient::Type type)
{
int count = 1;
......@@ -119,15 +119,16 @@ void RecipientsEditor::setRecipientString(const QVector<KMime::Types::Mailbox> &
"Truncating recipients list to %2 of %1 entries.",
mailboxes.count(),
MessageComposer::MessageComposerSettings::self()->maximumRecipients()));
break;
return true;
}
if (!addRecipient(mailbox.prettyAddress(KMime::Types::Mailbox::QuoteWhenNecessary), type)) {
KMessageBox::sorry(
this,
i18nc("@info:status", "Truncating recipients list to %1.", MessageComposer::MessageComposerSettings::self()->maximumRecipients()));
break;
return true;
}
}
return false;
}
Recipient::List RecipientsEditor::recipients() const
......
......@@ -55,7 +55,7 @@ public:
Q_REQUIRED_RESULT MessageComposer::RecipientsPicker *picker() const;
void setRecipientString(const QVector<KMime::Types::Mailbox> &mailboxes, Recipient::Type);
bool setRecipientString(const QVector<KMime::Types::Mailbox> &mailboxes, Recipient::Type);
Q_REQUIRED_RESULT QString recipientString(Recipient::Type) const;
Q_REQUIRED_RESULT QStringList recipientStringList(Recipient::Type) const;
......
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