summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-26 06:19:30 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-26 06:19:30 (GMT)
commit033c2920a26c7b729604c140ab32983ce26d454c (patch)
treef41a36b04bf1b4ea69f6186659e46256f4d1f27f
parent09c2b0e61c580b7023fea546e72f38b8d9bd1f49 (diff)
Cache header pointer
-rw-r--r--messagecomposer/src/helper/messagehelper.cpp20
-rw-r--r--messagecomposer/src/sender/akonadisender.cpp4
-rw-r--r--messageviewer/src/header/grantleeheaderformatter.cpp4
-rw-r--r--messageviewer/src/header/headerstyle_util.cpp18
-rw-r--r--mimetreeparser/src/bodyformatter/mailman.cpp3
5 files changed, 25 insertions, 24 deletions
diff --git a/messagecomposer/src/helper/messagehelper.cpp b/messagecomposer/src/helper/messagehelper.cpp
index 696046e..1f81073 100644
--- a/messagecomposer/src/helper/messagehelper.cpp
+++ b/messagecomposer/src/helper/messagehelper.cpp
@@ -167,17 +167,15 @@ void applyIdentity(const KMime::Message::Ptr &message, const KIdentityManagement
KMime::Types::AddrSpecList extractAddrSpecs(const KMime::Message::Ptr &msg, const QByteArray &header)
{
KMime::Types::AddrSpecList result;
- if (!msg->headerByType(header.constData())) {
- return result;
- }
-
- KMime::Types::AddressList al =
- MessageCore::StringUtil::splitAddressField(msg->headerByType(header.constData())->asUnicodeString().toUtf8());
- KMime::Types::AddressList::const_iterator alend(al.constEnd());
- for (KMime::Types::AddressList::const_iterator ait = al.constBegin(); ait != alend; ++ait) {
- KMime::Types::MailboxList::const_iterator mitEnd((*ait).mailboxList.constEnd());
- for (KMime::Types::MailboxList::const_iterator mit = (*ait).mailboxList.constBegin(); mit != mitEnd; ++mit) {
- result.push_back((*mit).addrSpec());
+ if (auto hrd = msg->headerByType(header.constData())) {
+ KMime::Types::AddressList al =
+ MessageCore::StringUtil::splitAddressField(hrd->asUnicodeString().toUtf8());
+ KMime::Types::AddressList::const_iterator alend(al.constEnd());
+ for (KMime::Types::AddressList::const_iterator ait = al.constBegin(); ait != alend; ++ait) {
+ KMime::Types::MailboxList::const_iterator mitEnd((*ait).mailboxList.constEnd());
+ for (KMime::Types::MailboxList::const_iterator mit = (*ait).mailboxList.constBegin(); mit != mitEnd; ++mit) {
+ result.push_back((*mit).addrSpec());
+ }
}
}
return result;
diff --git a/messagecomposer/src/sender/akonadisender.cpp b/messagecomposer/src/sender/akonadisender.cpp
index 38d1ab3..fd87c8b 100644
--- a/messagecomposer/src/sender/akonadisender.cpp
+++ b/messagecomposer/src/sender/akonadisender.cpp
@@ -151,7 +151,9 @@ void AkonadiSender::sendOrQueueMessage(const KMime::Message::Ptr &message, Messa
if (d->mCustomTransportId != -1) {
transportId = d->mCustomTransportId;
} else {
- transportId = message->headerByType("X-KMail-Transport") ? message->headerByType("X-KMail-Transport")->asUnicodeString().toInt() : -1;
+ if (auto hrd = message->headerByType("X-KMail-Transport")) {
+ transportId = hrd->asUnicodeString().toInt();
+ }
}
const Transport *transport = TransportManager::self()->transportById(transportId);
if (!transport) {
diff --git a/messageviewer/src/header/grantleeheaderformatter.cpp b/messageviewer/src/header/grantleeheaderformatter.cpp
index 8e9a35d..3ab9e13 100644
--- a/messageviewer/src/header/grantleeheaderformatter.cpp
+++ b/messageviewer/src/header/grantleeheaderformatter.cpp
@@ -250,10 +250,10 @@ QString GrantleeHeaderFormatter::format(const QString &absolutePath, const Grant
Q_FOREACH (QString header, displayExtraHeaders) {
const QByteArray baHeader = header.toLocal8Bit();
- if (message->headerByType(baHeader.constData())) {
+ if (auto hrd = message->headerByType(baHeader.constData())) {
//Grantlee doesn't support '-' in variable name => remove it.
header = header.remove(QLatin1Char('-'));
- headerObject.insert(header, message->headerByType(baHeader.constData())->asUnicodeString());
+ headerObject.insert(header, hrd->asUnicodeString());
}
}
diff --git a/messageviewer/src/header/headerstyle_util.cpp b/messageviewer/src/header/headerstyle_util.cpp
index 454d8a5..2dade57 100644
--- a/messageviewer/src/header/headerstyle_util.cpp
+++ b/messageviewer/src/header/headerstyle_util.cpp
@@ -379,14 +379,16 @@ HeaderStyleUtil::xfaceSettings HeaderStyleUtil::xface(const MessageViewer::Heade
}
}
- if (settings.photoURL.isEmpty() && message->headerByType("X-Face") && useOtherPhotoSources) {
- // no photo, look for a X-Face header
- const QString xfhead = message->headerByType("X-Face")->asUnicodeString();
- if (!xfhead.isEmpty()) {
- MessageViewer::KXFace xf;
- settings.photoURL = MessageViewer::HeaderStyleUtil::imgToDataUrl(xf.toImage(xfhead));
- settings.photoWidth = 48;
- settings.photoHeight = 48;
+ if (settings.photoURL.isEmpty() && useOtherPhotoSources) {
+ if (auto hrd = message->headerByType("X-Face")) {
+ // no photo, look for a X-Face header
+ const QString xfhead = hrd->asUnicodeString();
+ if (!xfhead.isEmpty()) {
+ MessageViewer::KXFace xf;
+ settings.photoURL = MessageViewer::HeaderStyleUtil::imgToDataUrl(xf.toImage(xfhead));
+ settings.photoWidth = 48;
+ settings.photoHeight = 48;
+ }
}
}
diff --git a/mimetreeparser/src/bodyformatter/mailman.cpp b/mimetreeparser/src/bodyformatter/mailman.cpp
index d02b2e7..24a4ce6 100644
--- a/mimetreeparser/src/bodyformatter/mailman.cpp
+++ b/mimetreeparser/src/bodyformatter/mailman.cpp
@@ -59,8 +59,7 @@ bool MailmanBodyPartFormatter::isMailmanMessage(KMime::Content *curNode) const
if (curNode->hasHeader("X-Mailman-Version")) {
return true;
}
- if (curNode->hasHeader("X-Mailer")) {
- KMime::Headers::Base *header = curNode->headerByType("X-Mailer");
+ if (KMime::Headers::Base *header = curNode->headerByType("X-Mailer")) {
if (header->asUnicodeString().contains(QStringLiteral("MAILMAN"), Qt::CaseInsensitive)) {
return true;
}