Commit b7e903db authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix clazy warning

parent ded64648
Pipeline #22909 passed with stage
in 54 minutes and 25 seconds
......@@ -23,7 +23,7 @@ set(QT_REQUIRED_VERSION "5.13.0")
set(AKONADI_VERSION "5.14.40")
set(GRANTLEETHEME_LIB_VERSION "5.14.40")
set(GRAVATAR_LIB_VERSION "5.14.41")
set(IDENTITYMANAGEMENT_LIB_VERSION "5.14.40")
set(IDENTITYMANAGEMENT_LIB_VERSION "5.14.41")
set(KDEPIM_APPS_LIB_VERSION "5.14.40")
set(KLDAP_LIB_VERSION "5.14.40")
set(KMAILTRANSPORT_LIB_VERSION "5.14.40")
......
......@@ -143,7 +143,7 @@ void ComposerTest::testBug271192()
composer->infoPart()->setTo(QStringList() << (displayName + QLatin1String(" <") + mailbox + QLatin1String(">")));
QVERIFY(composer->exec());
QCOMPARE(composer->resultMessages().size(), 1);
const KMime::Message::Ptr message = composer->resultMessages().first();
const KMime::Message::Ptr message = composer->resultMessages().constFirst();
QCOMPARE(message->to()->displayNames().size(), 1);
QCOMPARE(message->to()->displayNames().first().toUtf8(), displayName.toUtf8());
delete composer;
......
......@@ -87,25 +87,25 @@ 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(), QString::fromLatin1("smime.p7s"));
QCOMPARE(signedPart->contentType()->name(), QStringLiteral("smime.p7s"));
QCOMPARE(signedPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(signedPart->contentDisposition()->filename(), QString::fromLatin1("smime.p7s"));
QCOMPARE(signedPart->contentDisposition()->filename(), QStringLiteral("smime.p7s"));
Q_UNUSED(signedPart);
QCOMPARE(MessageCore::NodeHelper::firstChild(resultMessage)->contentTransferEncoding()->encoding(), encoding);
QCOMPARE(resultMessage->contentType()->mimeType(), QByteArray("multipart/signed"));
QCOMPARE(resultMessage->contentType()->parameter(QString::fromLatin1("protocol")), QString::fromLatin1("application/pkcs7-signature"));
QCOMPARE(resultMessage->contentType()->parameter(QString::fromLatin1("micalg")), QString::fromLatin1("sha1"));
QCOMPARE(resultMessage->contentType()->parameter(QStringLiteral("protocol")), QStringLiteral("application/pkcs7-signature"));
QCOMPARE(resultMessage->contentType()->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(), QString::fromLatin1("smime.p7m"));
QCOMPARE(signedPart->contentType()->parameter(QString::fromLatin1("smime-type")), QString::fromLatin1("signed-data"));
QCOMPARE(signedPart->contentType()->name(), QStringLiteral("smime.p7m"));
QCOMPARE(signedPart->contentType()->parameter(QStringLiteral("smime-type")), QStringLiteral("signed-data"));
QCOMPARE(signedPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(signedPart->contentDisposition()->filename(), QString::fromLatin1("smime.p7m"));
QCOMPARE(signedPart->contentDisposition()->filename(), QStringLiteral("smime.p7m"));
Q_UNUSED(signedPart);
}
// process the result..
......@@ -158,10 +158,10 @@ void ComposerTestUtil::verifyEncryption(KMime::Content *content, const QByteArra
Q_ASSERT(encPart);
QCOMPARE(encPart->contentType()->mimeType(), QByteArray("application/pkcs7-mime"));
QCOMPARE(encPart->contentType()->name(), QString::fromLatin1("smime.p7m"));
QCOMPARE(encPart->contentType()->parameter(QString::fromLatin1("smime-type")), QString::fromLatin1("enveloped-data"));
QCOMPARE(encPart->contentType()->name(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentType()->parameter(QStringLiteral("smime-type")), QStringLiteral("enveloped-data"));
QCOMPARE(encPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(encPart->contentDisposition()->filename(), QString::fromLatin1("smime.p7m"));
QCOMPARE(encPart->contentDisposition()->filename(), QStringLiteral("smime.p7m"));
Q_UNUSED(encPart);
otp.parseObjectTree(resultMessage.data());
......@@ -211,10 +211,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(), QString::fromLatin1("smime.p7m"));
QCOMPARE(encPart->contentType()->parameter(QString::fromLatin1("smime-type")), QString::fromLatin1("enveloped-data"));
QCOMPARE(encPart->contentType()->name(), QStringLiteral("smime.p7m"));
QCOMPARE(encPart->contentType()->parameter(QStringLiteral("smime-type")), QStringLiteral("enveloped-data"));
QCOMPARE(encPart->contentDisposition()->disposition(), KMime::Headers::CDattachment);
QCOMPARE(encPart->contentDisposition()->filename(), QString::fromLatin1("smime.p7m"));
QCOMPARE(encPart->contentDisposition()->filename(), QStringLiteral("smime.p7m"));
Q_UNUSED(encPart);
otp.parseObjectTree(resultMessage.data());
......
......@@ -709,7 +709,7 @@ void AttachmentControllerBase::slotOpenWithAction(QAction *act)
void AttachmentControllerBase::openWith(const KService::Ptr &offer)
{
QTemporaryFile *tempFile = dumpAttachmentToTempFile(d->selectedParts.first());
QTemporaryFile *tempFile = dumpAttachmentToTempFile(d->selectedParts.constFirst());
if (!tempFile) {
KMessageBox::sorry(d->wParent,
i18n("KMail was unable to write the attachment to a temporary file."),
......
......@@ -378,7 +378,7 @@ void RichTextComposerNg::insertSignature(const KIdentityManagement::Signature &s
// We added the text of the signature above, now it is time to add the images as well.
if (signature.isInlinedHtml()) {
const QList<KIdentityManagement::Signature::EmbeddedImagePtr> embeddedImages = signature.embeddedImages();
const QVector<KIdentityManagement::Signature::EmbeddedImagePtr> embeddedImages = signature.embeddedImages();
for (const KIdentityManagement::Signature::EmbeddedImagePtr &image : embeddedImages) {
composerControler()->composerImages()->loadImage(image->image, image->name, image->name);
}
......
......@@ -79,7 +79,7 @@ MessageComposer::ComposerAttachmentInterface ComposerViewInterface::attachments(
for (const MessageCore::AttachmentPart::Ptr &attachment : mComposerView->attachmentModel()->attachments()) {
fileNames.append(attachment->fileName());
names.append(attachment->name());
nameAndSize.append(QStringLiteral("%1 (%2)").arg(attachment->name()).arg(KFormat().formatByteSize(attachment->size())));
nameAndSize.append(QStringLiteral("%1 (%2)").arg(attachment->name(), KFormat().formatByteSize(attachment->size())));
}
attachmentInterface.setNames(names);
attachmentInterface.setNamesAndSize(nameAndSize);
......
......@@ -29,7 +29,7 @@ using namespace MessageComposer;
void ContentJobBasePrivate::init(QObject *parent)
{
Q_Q(ContentJobBase);
ContentJobBase *parentJob = dynamic_cast<ContentJobBase *>(parent);
ContentJobBase *parentJob = qobject_cast<ContentJobBase *>(parent);
if (parentJob) {
if (!parentJob->appendSubjob(q)) {
qCWarning(MESSAGECOMPOSER_LOG) << "Impossible to add subjob.";
......
......@@ -196,7 +196,7 @@ void EncryptJob::doStart()
void EncryptJob::slotResult(KJob *job)
{
Q_D(EncryptJob);
//Q_D(EncryptJob);
if (error()) {
ContentJobBase::slotResult(job);
return;
......
......@@ -194,7 +194,7 @@ void SignEncryptJob::doStart()
void SignEncryptJob::slotResult(KJob *job)
{
Q_D(SignEncryptJob);
//Q_D(SignEncryptJob);
if (error()) {
ContentJobBase::slotResult(job);
return;
......@@ -220,7 +220,7 @@ void SignEncryptJob::process()
// and we want to use that
if (!d->content || !d->content->hasContent()) {
Q_ASSERT(d->subjobContents.size() == 1);
d->content = d->subjobContents.first();
d->content = d->subjobContents.constFirst();
}
const QGpgME::Protocol *proto = nullptr;
......
......@@ -44,7 +44,7 @@ class MESSAGECOMPOSER_EXPORT Recipient : public KPIM::MultiplyingLineData
{
public:
typedef QSharedPointer<Recipient> Ptr;
typedef QList<Recipient::Ptr> List;
typedef QVector<Recipient::Ptr> List;
enum Type {
To, Cc, Bcc, ReplyTo, Undefined
......
......@@ -248,7 +248,7 @@ void RecipientsEditor::slotLineAdded(MultiplyingLine *line)
if (count > 0) {
if (count == 1) {
RecipientLineNG *last_rec = qobject_cast< RecipientLineNG * >(lines().first());
RecipientLineNG *last_rec = qobject_cast< RecipientLineNG * >(lines().constFirst());
if (last_rec && (last_rec->recipientType() == Recipient::Bcc || last_rec->recipientType() == Recipient::ReplyTo)) {
rec->setRecipientType(Recipient::To);
} else {
......
......@@ -3769,7 +3769,7 @@ ModelPrivate::ViewItemJobResult ModelPrivate::viewItemJobStepInternal()
while (!mViewItemJobs.isEmpty()) {
// Have a job to do.
ViewItemJob *job = mViewItemJobs.first();
ViewItemJob *job = mViewItemJobs.constFirst();
#ifdef KDEPIM_FOLDEROPEN_PROFILE
......
......@@ -2398,13 +2398,13 @@ bool View::event(QEvent *e)
}
if (textIsLeftToRight) {
tip += htmlCodeForStandardRow.arg(i18n("Status")).arg(status);
tip += htmlCodeForStandardRow.arg(i18n("Size")).arg(mi->formattedSize());
tip += htmlCodeForStandardRow.arg(i18n("Folder")).arg(mi->folder());
tip += htmlCodeForStandardRow.arg(i18n("Status"), status);
tip += htmlCodeForStandardRow.arg(i18n("Size"), mi->formattedSize());
tip += htmlCodeForStandardRow.arg(i18n("Folder"), mi->folder());
} else {
tip += htmlCodeForStandardRow.arg(status).arg(i18n("Status"));
tip += htmlCodeForStandardRow.arg(mi->formattedSize()).arg(i18n("Size"));
tip += htmlCodeForStandardRow.arg(mi->folder()).arg(i18n("Folder"));
tip += htmlCodeForStandardRow.arg(status, i18n("Status"));
tip += htmlCodeForStandardRow.arg(mi->formattedSize(), i18n("Size"));
tip += htmlCodeForStandardRow.arg(mi->folder(), i18n("Folder"));
}
if (mi->hasAnnotation()) {
......
......@@ -85,7 +85,7 @@ DKIMAuthenticationStatusInfo::AuthStatusInfo DKIMAuthenticationStatusInfo::parse
// 2) extract methodspec
const QString methodVersionp = DKIMAuthenticationStatusInfoUtil::cfws_op() + QLatin1Char('/') + DKIMAuthenticationStatusInfoUtil::cfws_op() + QLatin1String("([0-9]+)");
const QString method_p = QLatin1Char('(') + DKIMAuthenticationStatusInfoUtil::keyword_p() + QLatin1String(")(?:") + methodVersionp + QLatin1String(")?");
QString Keyword_result_p = QLatin1String("none|pass|fail|softfail|policy|neutral|temperror|permerror");
QString Keyword_result_p = QStringLiteral("none|pass|fail|softfail|policy|neutral|temperror|permerror");
// older SPF specs (e.g. RFC 4408) use mixed case
Keyword_result_p += QLatin1String("|None|Pass|Fail|SoftFail|Neutral|TempError|PermError");
const QString result_p = QLatin1Char('=') + DKIMAuthenticationStatusInfoUtil::cfws_op() + QLatin1Char('(') + Keyword_result_p + QLatin1Char(')');
......
......@@ -145,7 +145,7 @@ QString MessageViewer::DKIMAuthenticationStatusInfoUtil::qtext_p()
QString MessageViewer::DKIMAuthenticationStatusInfoUtil::qcontent_p()
{
// qcontent as specified in Section 3.2.4 of RFC 5322
return QStringLiteral("(?:%1|%2)").arg(qtext_p()).arg(quotedPair_p());
return QStringLiteral("(?:%1|%2)").arg(qtext_p(), quotedPair_p());
}
QString MessageViewer::DKIMAuthenticationStatusInfoUtil::quotedString_p()
......
......@@ -80,7 +80,8 @@ void DKIMCheckPolicyJob::compareWithDefaultRules()
if (rule.enabled()) {
if (rule.from() == mEmailAddress || rule.from() == QLatin1Char('*')) {
//Check SDID
for (const QString &ssid : rule.signedDomainIdentifier()) {
const QStringList signedDomainIdentifier = rule.signedDomainIdentifier();
for (const QString &ssid : signedDomainIdentifier) {
if (mCheckResult.sdid == ssid) {
switch (rule.ruleType()) {
case DKIMRule::RuleType::Unknown:
......
......@@ -519,9 +519,15 @@ void DKIMCheckSignatureJob::verifyRSASignature()
sigAlg = QCA::EMSA3_SHA256;
break;
case DKIMInfo::HashingAlgorithmType::Any:
case DKIMInfo::HashingAlgorithmType::Unknown:
//Error !
break;
case DKIMInfo::HashingAlgorithmType::Unknown: {
// then signature is invalid
mError = MessageViewer::DKIMCheckSignatureJob::DKIMError::ImpossibleToVerifySignature;
mStatus = MessageViewer::DKIMCheckSignatureJob::DKIMStatus::Invalid;
Q_EMIT result(createCheckResult());
deleteLater();
qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "DKIMInfo::HashingAlgorithmType undefined ! ";
return;
}
}
if (!rsaPublicKey.verifyMessage(sec, ba, sigAlg, QCA::DERSequence)) {
computeHeaderCanonization(false);
......
......@@ -45,7 +45,7 @@ bool DKIMInfo::parseDKIM(const QString &header)
for (int i = 0; i < items.count(); ++i) {
const QString elem = items.at(i).trimmed();
if (elem.startsWith(QLatin1String("v="))) {
mVersion = elem.right(elem.length() - 2).toInt();
mVersion = elem.rightRef(elem.length() - 2).toInt();
if (mVersion != 1) {
qCWarning(MESSAGEVIEWER_DKIMCHECKER_LOG) << "Version is not correct " << mVersion;
}
......@@ -61,7 +61,7 @@ bool DKIMInfo::parseDKIM(const QString &header)
} else if (elem.startsWith(QLatin1String("bh="))) {
mBodyHash = elem.right(elem.length() - 3).remove(QLatin1Char(' '));
} else if (elem.startsWith(QLatin1String("l="))) {
mBodyLengthCount = elem.right(elem.length() - 2).toInt();
mBodyLengthCount = elem.rightRef(elem.length() - 2).toInt();
} else if (elem.startsWith(QLatin1String("i="))) {
mAgentOrUserIdentifier = elem.right(elem.length() - 2);
} else if (elem.startsWith(QLatin1String("q="))) {
......
......@@ -96,7 +96,7 @@ bool DMARCInfo::parseDMARC(const QString &key)
// else
// selected = false
//TODO verify if it's a percentage
mPercentage = elem.right(elem.length() - 4).toInt();
mPercentage = elem.rightRef(elem.length() - 4).toInt();
} else if (elem.startsWith(QLatin1String("sp="))) {
//sp: Requested Mail Receiver policy for all subdomains (plain-text;
// OPTIONAL). Indicates the policy to be enacted by the Receiver at
......
......@@ -181,6 +181,7 @@ QVector<MessagePartRendererBase *> MessagePartRendererFactory::renderersForPart(
});
QVector<MessagePartRendererBase *> r;
r.reserve(candidates.size());
for (const auto &candidate : candidates) {
r.push_back(candidate.renderer.data());
}
......
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