Commit b2c97f35 authored by Laurent Montel's avatar Laurent Montel 😁

const'ify, clean up code

parent fd9480a0
Pipeline #36581 canceled with stage
......@@ -31,9 +31,8 @@ Picoftheday::~Picoftheday()
void Picoftheday::configure(QWidget *parent)
{
QPointer<ConfigDialog> dlg = new ConfigDialog(parent);
dlg->exec();
delete dlg;
ConfigDialog dlg(parent);
dlg.exec();
}
QString Picoftheday::info() const
......
......@@ -156,8 +156,8 @@ public:
}
private:
MimeTreeParser::MessagePartPtr mBodyPart;
KCalendarCore::MemoryCalendar::Ptr mCalendar;
const MimeTreeParser::MessagePartPtr mBodyPart;
const KCalendarCore::MemoryCalendar::Ptr mCalendar;
};
class Formatter : public MessageViewer::MessagePartRendererBase
......
......@@ -43,30 +43,32 @@ bool partHasMimeType(KMime::Content *part, const char *mt)
MessagePart::Ptr ApplicationGnuPGWKSFormatter::process(BodyPart &part) const
{
const auto ct = part.content()->contentType(false);
if (ct && ct->isMimeType("multipart/mixed")) {
const auto subParts = part.content()->contents();
if (subParts.size() == 2
&& partHasMimeType(subParts[0], "text/plain")
&& partHasMimeType(subParts[1], "application/vnd.gnupg.wks")) {
return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), subParts.at(1), false));
} else {
return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), subParts.at(0), false));
if (ct) {
if (ct->isMimeType("multipart/mixed")) {
const auto subParts = part.content()->contents();
if (subParts.size() == 2
&& partHasMimeType(subParts[0], "text/plain")
&& partHasMimeType(subParts[1], "application/vnd.gnupg.wks")) {
return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), subParts.at(1), false));
} else {
return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), subParts.at(0), false));
}
}
}
if (ct && ct->isMimeType("application/vnd.gnupg.wks")) {
const auto content = part.content()->decodedContent();
if (content.startsWith("-----BEGIN PGP MESSAGE")) {
auto decrypt = QGpgME::openpgp()->decryptJob();
QByteArray plainText;
auto result = decrypt->exec(part.content()->decodedContent(), plainText);
if (result.error()) {
qCWarning(GNUPGWKS_LOG) << "Decryption failed!" << result.error().asString();
return {};
if (ct->isMimeType("application/vnd.gnupg.wks")) {
const auto content = part.content()->decodedContent();
if (content.startsWith("-----BEGIN PGP MESSAGE")) {
auto decrypt = QGpgME::openpgp()->decryptJob();
QByteArray plainText;
auto result = decrypt->exec(part.content()->decodedContent(), plainText);
if (result.error()) {
qCWarning(GNUPGWKS_LOG) << "Decryption failed!" << result.error().asString();
return {};
}
part.content()->setBody(plainText);
}
part.content()->setBody(plainText);
return MessagePart::Ptr(new GnuPGWKSMessagePart(&part));
}
return MessagePart::Ptr(new GnuPGWKSMessagePart(&part));
}
return {};
......
......@@ -48,7 +48,7 @@ QVector<ItineraryKDEConnectHandler::Device> ItineraryKDEConnectHandler::devices(
void ItineraryKDEConnectHandler::sendToDevice(const QString &fileName, const QString &deviceId)
{
QDBusInterface remoteApp(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/MainApplication"), QStringLiteral("org.qtproject.Qt.QCoreApplication"));
const QDBusInterface remoteApp(QStringLiteral("org.kde.kdeconnect"), QStringLiteral("/MainApplication"), QStringLiteral("org.qtproject.Qt.QCoreApplication"));
QVersionNumber kdeconnectVersion = QVersionNumber::fromString(remoteApp.property("applicationVersion").toString());
QString method;
......
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