Commit 5d7677bc authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Minor optimization

parent f2bd4b7a
Pipeline #38711 canceled with stage
......@@ -43,19 +43,19 @@ void ComposerTest::testAttachments()
// multipart/mixed
{
QVERIFY(message->contentType(false));
QCOMPARE(message->contentType()->mimeType(), QByteArray("multipart/mixed"));
QCOMPARE(message->contentType(false)->mimeType(), QByteArray("multipart/mixed"));
QCOMPARE(message->contents().count(), 2);
// text/plain
{
Content *plain = message->contents().at(0);
QVERIFY(plain->contentType(false));
QCOMPARE(plain->contentType()->mimeType(), QByteArray("text/plain"));
QCOMPARE(plain->contentType(false)->mimeType(), QByteArray("text/plain"));
}
// x-some/x-type (attachment)
{
Content *plain = message->contents().at(1);
QVERIFY(plain->contentType(false));
QCOMPARE(plain->contentType()->mimeType(), QByteArray("x-some/x-type"));
QCOMPARE(plain->contentType(false)->mimeType(), QByteArray("x-some/x-type"));
}
}
}
......
......@@ -73,7 +73,7 @@ void ComposerTestUtil::verifySignature(KMime::Content *content, const QByteArray
Q_ASSERT(signedPart);
QCOMPARE(signedPart->contentTransferEncoding()->encoding(), KMime::Headers::CEbase64);
QCOMPARE(signedPart->contentType()->mimeType(), QByteArray("application/pkcs7-signature"));
QCOMPARE(signedPart->contentType()->name(), QStringLiteral("smime.p7s"));
QCOMPARE(signedPart->contentType(false)->name(), QStringLiteral("smime.p7s"));
QCOMPARE(signedPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(signedPart->contentDisposition()->filename(), QStringLiteral("smime.p7s"));
Q_UNUSED(signedPart);
......@@ -81,17 +81,17 @@ void ComposerTestUtil::verifySignature(KMime::Content *content, const QByteArray
QCOMPARE(MessageCore::NodeHelper::firstChild(resultMessage)->contentTransferEncoding()->encoding(), encoding);
QCOMPARE(resultMessage->contentType()->mimeType(), QByteArray("multipart/signed"));
QCOMPARE(resultMessage->contentType()->parameter(QStringLiteral("protocol")), QStringLiteral("application/pkcs7-signature"));
QCOMPARE(resultMessage->contentType()->parameter(QStringLiteral("micalg")), QStringLiteral("sha1"));
QCOMPARE(resultMessage->contentType(false)->parameter(QStringLiteral("protocol")), QStringLiteral("application/pkcs7-signature"));
QCOMPARE(resultMessage->contentType(false)->parameter(QStringLiteral("micalg")), QStringLiteral("sha1"));
} else if (f & Kleo::SMIMEOpaqueFormat) {
KMime::Content *signedPart = Util::findTypeInMessage(resultMessage, "application", "pkcs7-mime");
Q_ASSERT(signedPart);
QCOMPARE(signedPart->contentTransferEncoding()->encoding(), KMime::Headers::CEbase64);
QCOMPARE(signedPart->contentType()->mimeType(), QByteArray("application/pkcs7-mime"));
QCOMPARE(signedPart->contentType()->name(), QStringLiteral("smime.p7m"));
QCOMPARE(signedPart->contentType()->parameter(QStringLiteral("smime-type")), QStringLiteral("signed-data"));
QCOMPARE(signedPart->contentType(false)->name(), QStringLiteral("smime.p7m"));
QCOMPARE(signedPart->contentType(false)->parameter(QStringLiteral("smime-type")), QStringLiteral("signed-data"));
QCOMPARE(signedPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(signedPart->contentDisposition()->filename(), QStringLiteral("smime.p7m"));
QCOMPARE(signedPart->contentDisposition(false)->filename(), QStringLiteral("smime.p7m"));
Q_UNUSED(signedPart);
}
// process the result..
......@@ -144,10 +144,10 @@ void ComposerTestUtil::verifyEncryption(KMime::Content *content, const QByteArra
Q_ASSERT(encPart);
QCOMPARE(encPart->contentType()->mimeType(), QByteArray("application/pkcs7-mime"));
QCOMPARE(encPart->contentType()->name(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentType()->parameter(QStringLiteral("smime-type")), QStringLiteral("enveloped-data"));
QCOMPARE(encPart->contentType(false)->name(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentType(false)->parameter(QStringLiteral("smime-type")), QStringLiteral("enveloped-data"));
QCOMPARE(encPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(encPart->contentDisposition()->filename(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentDisposition(false)->filename(), QStringLiteral("smime.p7m"));
Q_UNUSED(encPart);
otp.parseObjectTree(resultMessage.data());
......@@ -197,10 +197,10 @@ void ComposerTestUtil::verifySignatureAndEncryption(KMime::Content *content, con
KMime::Content *encPart = Util::findTypeInMessage(resultMessage.data(), "application", "pkcs7-mime");
Q_ASSERT(encPart);
QCOMPARE(encPart->contentType()->mimeType(), QByteArray("application/pkcs7-mime"));
QCOMPARE(encPart->contentType()->name(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentType()->parameter(QStringLiteral("smime-type")), QStringLiteral("enveloped-data"));
QCOMPARE(encPart->contentType(false)->name(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentType(false)->parameter(QStringLiteral("smime-type")), QStringLiteral("enveloped-data"));
QCOMPARE(encPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(encPart->contentDisposition()->filename(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentDisposition(false)->filename(), QStringLiteral("smime.p7m"));
Q_UNUSED(encPart);
otp.parseObjectTree(resultMessage.data());
......
......@@ -165,9 +165,9 @@ void EncryptJobTest::testHeaders()
result->assemble();
QVERIFY(result->contentType(false));
QCOMPARE(result->contentType()->mimeType(), mimeType);
QCOMPARE(result->contentType()->charset(), charset);
QCOMPARE(result->contentType()->parameter(QStringLiteral("protocol")), QStringLiteral("application/pgp-encrypted"));
QCOMPARE(result->contentType(false)->mimeType(), mimeType);
QCOMPARE(result->contentType(false)->charset(), charset);
QCOMPARE(result->contentType(false)->parameter(QStringLiteral("protocol")), QStringLiteral("application/pgp-encrypted"));
QCOMPARE(result->contentTransferEncoding()->encoding(), KMime::Headers::CE7Bit);
delete result;
......
......@@ -410,13 +410,14 @@ KMime::Content *MessageFactoryNG::createForwardAttachmentMessage(const KMime::Me
fwdMsg->assemble();
// set the part
KMime::Content *msgPart = new KMime::Content(fwdMsg.data());
msgPart->contentType()->setMimeType("message/rfc822");
auto ct = msgPart->contentType();
ct->setMimeType("message/rfc822");
auto cd = msgPart->contentDisposition(); //create
cd->setParameter(QStringLiteral("filename"), i18n("forwarded message"));
cd->setDisposition(KMime::Headers::CDinline);
const QString subject = fwdMsg->subject()->asUnicodeString();
msgPart->contentType()->setParameter(QStringLiteral("name"), subject);
ct->setParameter(QStringLiteral("name"), subject);
cd->fromUnicodeString(fwdMsg->from()->asUnicodeString() + QLatin1String(": ") + subject, "utf-8");
msgPart->setBody(fwdMsg->encodedContent());
msgPart->assemble();
......@@ -730,7 +731,7 @@ QPair< KMime::Message::Ptr, KMime::Content * > MessageFactoryNG::createForwardDi
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"));
part->contentDisposition(false)->setParameter(QStringLiteral("name"), i18n("forwarded message"));
part->fromUnicodeString(QString::fromLatin1(fMsg->encodedContent()));
part->assemble();
MessageComposer::Util::addLinkInformation(msg, item.id(), Akonadi::MessageStatus::statusForwarded());
......
......@@ -94,7 +94,7 @@ void AttachmentJob::doStart()
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 (ct->isText()) {
// If it is a text file, detect its charset.
//sjob->contentType()->setCharset( d->detectCharset( d->part->data() ) );
......@@ -106,7 +106,7 @@ void AttachmentJob::doStart()
qCWarning(MESSAGECOMPOSER_LOG) << "No charset specified. Using UTF-8.";
textCharset = "utf-8";
}
sjob->contentType()->setCharset(textCharset);
ct->setCharset(textCharset);
}
sjob->contentDescription()->fromUnicodeString(d->part->description(), charset);
......
......@@ -87,7 +87,7 @@ void ProtectedHeadersJob::doStart()
KMime::Content *mixedPart = new KMime::Content();
const QByteArray boundary = KMime::multiPartBoundary();
mixedPart->contentType()->setMimeType("multipart/mixed");
mixedPart->contentType()->setBoundary(boundary);
mixedPart->contentType(false)->setBoundary(boundary);
mixedPart->addContent(cjob->content());
// if setContent hasn't been called, we assume that a subjob was added
......
......@@ -325,7 +325,7 @@ KMime::Content *MessageComposer::Util::findTypeInMessage(KMime::Content *data, c
return data;
}
if ((mimeType == data->contentType()->mediaType())
&& (subType == data->contentType()->subType())) {
&& (subType == data->contentType(false)->subType())) {
return data;
}
}
......
......@@ -67,7 +67,7 @@ void MessageCore::ImageCollector::collectImagesFrom(KMime::Content *node)
}
if (parent && parent->contentType()->isMultipart()
&& parent->contentType()->subType() == "related") {
&& parent->contentType(false)->subType() == "related") {
qCWarning(MESSAGECORE_LOG) << "Adding image" << node->contentID();
d->mImages.push_back(node);
node = MessageCore::NodeHelper::next(node); // skip embedded images
......
......@@ -30,7 +30,7 @@ KMime::Content *MimeTreeParser::findTypeInDirectChilds(KMime::Content *content,
foreach (const auto child, content->contents()) {
if ((!child->contentType()->isEmpty())
&& (mimeType == child->contentType()->mimeType())) {
&& (mimeType == child->contentType(false)->mimeType())) {
return child;
}
}
......
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