Commit 27873cd6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Minor optimizatiopn

parent 94bafe90
Pipeline #38395 passed with stage
in 44 minutes and 55 seconds
......@@ -342,7 +342,7 @@ void MessageFactoryNG::createForwardAsync()
//TODO Check if this is ok
msg->setHead(mOrigMsg->head());
msg->setBody(mOrigMsg->body());
const QString oldContentType = msg->contentType()->asUnicodeString();
const QString oldContentType = msg->contentType(true)->asUnicodeString();
const uint originalIdentity = identityUoid(mOrigMsg);
MessageHelper::initFromMessage(msg, mOrigMsg, mIdentityManager, originalIdentity);
......@@ -706,8 +706,9 @@ QPair< KMime::Message::Ptr, KMime::Content * > MessageFactoryNG::createForwardDi
const QString mainPartText = i18n("\nThis is a MIME digest forward. The content of the"
" message is contained in the attachment(s).\n\n\n");
digest->contentType()->setMimeType("multipart/digest");
digest->contentType()->setBoundary(KMime::multiPartBoundary());
auto ct = digest->contentType();
ct->setMimeType("multipart/digest");
ct->setBoundary(KMime::multiPartBoundary());
digest->contentDescription()->fromUnicodeString(QStringLiteral("Digest of %1 messages.").arg(items.count()), "utf8");
digest->contentDisposition()->setFilename(QStringLiteral("digest"));
digest->fromUnicodeString(mainPartText);
......@@ -727,7 +728,7 @@ QPair< KMime::Message::Ptr, KMime::Content * > MessageFactoryNG::createForwardDi
KMime::Content *part = new KMime::Content(digest);
part->contentType()->setMimeType("message/rfc822");
part->contentType()->setCharset(fMsg->contentType()->charset());
part->contentType(false)->setCharset(fMsg->contentType()->charset());
part->contentID()->setIdentifier(fMsg->contentID()->identifier());
part->contentDescription()->fromUnicodeString(fMsg->contentDescription()->asUnicodeString(), "utf8");
part->contentDisposition()->setParameter(QStringLiteral("name"), i18n("forwarded message"));
......
......@@ -91,8 +91,9 @@ void AttachmentJob::doStart()
sjob->contentTransferEncoding()->setEncoding(d->part->encoding());
}
sjob->contentType()->setMimeType(d->part->mimeType()); // setMimeType() clears all other params.
sjob->contentType()->setName(d->part->name(), charset);
auto ct = sjob->contentType();
ct->setMimeType(d->part->mimeType()); // setMimeType() clears all other params.
ct->setName(d->part->name(), charset);
if (sjob->contentType()->isText()) {
// If it is a text file, detect its charset.
//sjob->contentType()->setCharset( d->detectCharset( d->part->data() ) );
......@@ -110,12 +111,13 @@ void AttachmentJob::doStart()
sjob->contentDescription()->fromUnicodeString(d->part->description(), charset);
sjob->contentDisposition()->setFilename(d->part->fileName());
sjob->contentDisposition()->setRFC2047Charset(charset);
auto contentDisposition = sjob->contentDisposition();
contentDisposition->setFilename(d->part->fileName());
contentDisposition->setRFC2047Charset(charset);
if (d->part->isInline()) {
sjob->contentDisposition()->setDisposition(KMime::Headers::CDinline);
contentDisposition->setDisposition(KMime::Headers::CDinline);
} else {
sjob->contentDisposition()->setDisposition(KMime::Headers::CDattachment);
contentDisposition->setDisposition(KMime::Headers::CDattachment);
}
ContentJobBase::doStart();
......
......@@ -178,7 +178,6 @@ ViewerPrivate::ViewerPrivate(Viewer *aParent, QWidget *mainWindow, KActionCollec
, q(aParent)
, mSession(new Akonadi::Session("MessageViewer-"
+ QByteArray::number(reinterpret_cast<quintptr>(this)), this))
, mPreviouslyViewedItemId(-1)
{
if (!mainWindow) {
mMainWindow = aParent;
......
......@@ -667,7 +667,7 @@ public:
Akonadi::Session *mSession = nullptr;
Akonadi::Monitor mMonitor;
QSet<AbstractMessageLoadedHandler *> mMessageLoadedHandlers;
Akonadi::Item::Id mPreviouslyViewedItemId;
Akonadi::Item::Id mPreviouslyViewedItemId = -1;
MessageViewer::ScamDetectionWarningWidget *mScamDetectionWarning = nullptr;
MessageViewer::OpenSavedFileFolderWidget *mOpenSavedFileFolderWidget = nullptr;
......
......@@ -1229,9 +1229,10 @@ KMime::Content *TemplateParserJob::createMultipartRelated(const MessageCore::Ima
KMime::Content *TemplateParserJob::createPlainPartContent(const QString &plainBody) const
{
KMime::Content *textPart = new KMime::Content(d->mMsg.data());
textPart->contentType()->setMimeType("text/plain");
auto ct = textPart->contentType(true);
ct->setMimeType("text/plain");
QTextCodec *charset = selectCharset(d->mCharsets, plainBody);
textPart->contentType()->setCharset(charset->name());
ct->setCharset(charset->name());
textPart->contentTransferEncoding()->setEncoding(KMime::Headers::CE8Bit);
textPart->fromUnicodeString(plainBody);
return textPart;
......@@ -1242,15 +1243,15 @@ KMime::Content *TemplateParserJob::createMultipartAlternativeContent(const QStri
KMime::Content *multipartAlternative = new KMime::Content(d->mMsg.data());
multipartAlternative->contentType()->setMimeType("multipart/alternative");
const QByteArray boundary = KMime::multiPartBoundary();
multipartAlternative->contentType()->setBoundary(boundary);
multipartAlternative->contentType(false)->setBoundary(boundary); //Already created
KMime::Content *textPart = createPlainPartContent(plainBody);
multipartAlternative->addContent(textPart);
KMime::Content *htmlPart = new KMime::Content(d->mMsg.data());
htmlPart->contentType()->setMimeType("text/html");
htmlPart->contentType(true)->setMimeType("text/html");
QTextCodec *charset = selectCharset(d->mCharsets, htmlBody);
htmlPart->contentType()->setCharset(charset->name());
htmlPart->contentType(false)->setCharset(charset->name()); //Already created
htmlPart->contentTransferEncoding()->setEncoding(KMime::Headers::CE8Bit);
htmlPart->fromUnicodeString(htmlBody);
multipartAlternative->addContent(htmlPart);
......
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