Commit 0f3870cd authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Use QByteArrayLiteral here

parent b418e9a6
......@@ -172,13 +172,13 @@ void SignJobTest::testMixedContent()
QVERIFY(sJob);
KMime::Content *content = new KMime::Content;
content->contentType()->setMimeType(QByteArray("multipart/mixed"));
content->contentType()->setMimeType(QByteArrayLiteral("multipart/mixed"));
content->contentType()->setBoundary(KMime::multiPartBoundary());
KMime::Content *subcontent = new KMime::Content;
subcontent->contentType()->setMimeType(QByteArray("text/plain"));
subcontent->contentType()->setMimeType(QByteArrayLiteral("text/plain"));
subcontent->setBody(data.toUtf8());
KMime::Content *attachment = new KMime::Content;
attachment->contentType()->setMimeType(QByteArray("text/plain"));
attachment->contentType()->setMimeType(QByteArrayLiteral("text/plain"));
QByteArray attachmentData("an attachment");
attachment->setBody(attachmentData);
......@@ -200,7 +200,7 @@ void SignJobTest::testMixedContent()
QCOMPARE(result->contents().count(), 2);
QCOMPARE(firstChild->contents().count(), 2);
QCOMPARE(firstChild->body(), QByteArray());
QCOMPARE(firstChild->contentType()->mimeType(), QByteArray("multipart/mixed"));
QCOMPARE(firstChild->contentType()->mimeType(), QByteArrayLiteral("multipart/mixed"));
QCOMPARE(firstChild->contents()[0]->body(), data.toUtf8());
QCOMPARE(firstChild->contents()[1]->body(), attachmentData);
......
......@@ -36,7 +36,7 @@ void UtilTest::testSelectCharset()
charsets << "iso-8859-1";
charsets << "iso-8859-2"; // This one works.
QByteArray choice = Util::selectCharset(charsets, text);
QCOMPARE(choice, QByteArray("iso-8859-2"));
QCOMPARE(choice, QByteArrayLiteral("iso-8859-2"));
}
// Pick as simple a charset as possible.
......@@ -47,7 +47,7 @@ void UtilTest::testSelectCharset()
charsets << "iso-8859-1";
charsets << "utf-8";
QByteArray choice = Util::selectCharset(charsets, text);
QCOMPARE(choice, QByteArray("us-ascii"));
QCOMPARE(choice, QByteArrayLiteral("us-ascii"));
}
// Return empty charset if none works.
......
......@@ -1663,7 +1663,7 @@ void MessageComposer::ComposerViewBase::collectImages(KMime::Content *root)
qCDebug(MESSAGECOMPOSER_LOG) << "found image in multipart/related : " << node->contentType()->name();
QImage img;
img.loadFromData(node->decodedContent());
m_editor->composerControler()->composerImages()->loadImage(img, QString::fromLatin1(QByteArray(QByteArray("cid:") + node->contentID()->identifier())),
m_editor->composerControler()->composerImages()->loadImage(img, QString::fromLatin1(QByteArray(QByteArrayLiteral("cid:") + node->contentID()->identifier())),
node->contentType()->name());
}
node = MessageCore::NodeHelper::nextSibling(node);
......
......@@ -64,7 +64,7 @@ QByteArray AttachmentJobPrivate::detectCharset(const QByteArray &data)
return detectedEncoding;
} else {
qCWarning(MESSAGECOMPOSER_LOG) << "Could not autodetect charset; using UTF-8.";
return QByteArray("utf-8");
return QByteArrayLiteral("utf-8");
}
}
#endif
......
......@@ -141,19 +141,19 @@ void MessageComposer::Util::makeToplevelContentType(KMime::Content *content, Kle
case Kleo::InlineOpenPGPFormat:
case Kleo::OpenPGPMIMEFormat:
if (sign) {
content->contentType()->setMimeType(QByteArray("multipart/signed"));
content->contentType()->setMimeType(QByteArrayLiteral("multipart/signed"));
content->contentType()->setParameter(QStringLiteral("protocol"), QString::fromAscii("application/pgp-signature"));
content->contentType()->setParameter(QStringLiteral("micalg"), QString::fromAscii(QByteArray(QByteArray("pgp-") + hashAlgo)).toLower());
content->contentType()->setParameter(QStringLiteral("micalg"), QString::fromAscii(QByteArray(QByteArrayLiteral("pgp-") + hashAlgo)).toLower());
} else {
content->contentType()->setMimeType(QByteArray("multipart/encrypted"));
content->contentType()->setMimeType(QByteArrayLiteral("multipart/encrypted"));
content->contentType()->setParameter(QStringLiteral("protocol"), QString::fromAscii("application/pgp-encrypted"));
}
return;
case Kleo::SMIMEFormat:
if (sign) {
qCDebug(MESSAGECOMPOSER_LOG) << "setting headers for SMIME";
content->contentType()->setMimeType(QByteArray("multipart/signed"));
content->contentType()->setMimeType(QByteArrayLiteral("multipart/signed"));
content->contentType()->setParameter(QStringLiteral("protocol"), QString::fromAscii("application/pkcs7-signature"));
content->contentType()->setParameter(QStringLiteral("micalg"), QString::fromAscii(hashAlgo).toLower());
return;
......@@ -164,7 +164,7 @@ void MessageComposer::Util::makeToplevelContentType(KMime::Content *content, Kle
case Kleo::SMIMEOpaqueFormat:
qCDebug(MESSAGECOMPOSER_LOG) << "setting headers for SMIME/opaque";
content->contentType()->setMimeType(QByteArray("application/pkcs7-mime"));
content->contentType()->setMimeType(QByteArrayLiteral("application/pkcs7-mime"));
if (sign) {
content->contentType()->setParameter(QStringLiteral("smime-type"), QString::fromAscii("signed-data"));
......@@ -180,16 +180,16 @@ void MessageComposer::Util::setNestedContentType(KMime::Content *content, Kleo::
switch (format) {
case Kleo::OpenPGPMIMEFormat:
if (sign) {
content->contentType()->setMimeType(QByteArray("application/pgp-signature"));
content->contentType()->setMimeType(QByteArrayLiteral("application/pgp-signature"));
content->contentType()->setParameter(QStringLiteral("name"), QString::fromAscii("signature.asc"));
content->contentDescription()->from7BitString("This is a digitally signed message part.");
} else {
content->contentType()->setMimeType(QByteArray("application/octet-stream"));
content->contentType()->setMimeType(QByteArrayLiteral("application/octet-stream"));
}
return;
case Kleo::SMIMEFormat:
if (sign) {
content->contentType()->setMimeType(QByteArray("application/pkcs7-signature"));
content->contentType()->setMimeType(QByteArrayLiteral("application/pkcs7-signature"));
content->contentType()->setParameter(QStringLiteral("name"), QString::fromAscii("smime.p7s"));
return;
}
......
......@@ -64,7 +64,7 @@ void AttachmentCompressJobTest::testCompress()
QCOMPARE(zipPart->name(), QString(name + QString::fromLatin1(".zip")));
QCOMPARE(zipPart->fileName(), QString(fileName + QString::fromLatin1(".zip")));
QCOMPARE(zipPart->description(), description);
QCOMPARE(zipPart->mimeType(), QByteArray("application/zip"));
QCOMPARE(zipPart->mimeType(), QByteArrayLiteral("application/zip"));
// Uncompress the data and verify it.
// (Stuff below is stolen from KMail code.)
......
......@@ -90,7 +90,7 @@ void MessageDisplayFormatAttributeTest::shouldCloneAttribute()
void MessageDisplayFormatAttributeTest::shouldDefineType()
{
MessageViewer::MessageDisplayFormatAttribute attr;
QCOMPARE(attr.type(), QByteArray("MessageDisplayFormatAttribute"));
QCOMPARE(attr.type(), QByteArrayLiteral("MessageDisplayFormatAttribute"));
}
QTEST_MAIN(MessageDisplayFormatAttributeTest)
......@@ -991,7 +991,7 @@ public:
cryptoProto->name(),
QString::fromLatin1(metaData.keyId));
keyWithWithoutURL = QStringLiteral("%1%2</a>").arg(startKeyHREF, QString::fromLatin1(QByteArray(QByteArray("0x") + metaData.keyId)));
keyWithWithoutURL = QStringLiteral("%1%2</a>").arg(startKeyHREF, QString::fromLatin1(QByteArray(QByteArrayLiteral("0x") + metaData.keyId)));
} else {
keyWithWithoutURL = QStringLiteral("0x") + QString::fromUtf8(metaData.keyId);
}
......
......@@ -438,7 +438,7 @@ bool ViewerPrivate::deleteAttachment(KMime::Content *node, bool showWarning)
deletePart->contentType()->setCharset("utf-8");
deletePart->contentTransferEncoding()->setEncoding(KMime::Headers::CE7Bit);
QByteArray bodyMessage = QByteArray("\nYou deleted an attachment from this message. The original MIME headers for the attachment were:");
QByteArray bodyMessage = QByteArrayLiteral("\nYou deleted an attachment from this message. The original MIME headers for the attachment were:");
bodyMessage += ("\nContent-Type: ") + mimetype;
bodyMessage += ("\nname=\"") + name.toUtf8() + "\"";
bodyMessage += ("\nfilename=\"") + filename.toUtf8() + "\"";
......
......@@ -395,7 +395,7 @@ IconType AttachmentMessagePart::asIcon() const
mediaType = mNode->contentType()->mediaType();
subType = mNode->contentType()->subType();
}
const bool isTextPart = (mediaType == QByteArray("text"));
const bool isTextPart = (mediaType == QByteArrayLiteral("text"));
bool defaultAsIcon = true;
if (!neverDisplayInline()) {
......@@ -452,7 +452,7 @@ bool AttachmentMessagePart::isHidden() const
mediaType = mNode->contentType()->mediaType();
subType = mNode->contentType()->subType();
}
const bool isTextPart = (mediaType == QByteArray("text"));
const bool isTextPart = (mediaType == QByteArrayLiteral("text"));
bool defaultAsIcon = true;
if (!neverDisplayInline()) {
......
......@@ -344,7 +344,7 @@ Interface::MessagePart::Ptr ObjectTreeParser::defaultHandling(KMime::Content *no
Interface::MessagePart::Ptr mp;
ProcessResult processResult(mNodeHelper);
if (node->contentType()->mimeType() == QByteArray("application/octet-stream") &&
if (node->contentType()->mimeType() == QByteArrayLiteral("application/octet-stream") &&
(node->contentType()->name().endsWith(QLatin1String("p7m")) ||
node->contentType()->name().endsWith(QLatin1String("p7s")) ||
node->contentType()->name().endsWith(QLatin1String("p7c"))
......
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