diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,7 @@ set(MAILIMPORTER_LIB_VERSION "5.11.40") set(KPIMPKPASS_LIB_VERSION "5.11.40") set(KPIMITINERARY_LIB_VERSION "5.11.40") -set(KCALENDARCORE_LIB_VERSION "5.11.44") +set(KCALENDARCORE_LIB_VERSION "5.11.45") find_package(KF5CalendarCore ${KCALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDAR_UTILS_VERSION} CONFIG REQUIRED) find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED) diff --git a/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp b/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp --- a/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp +++ b/plugins/messageviewer/bodypartformatter/calendar/text_calendar.cpp @@ -362,33 +362,31 @@ return role; } - static Attachment::Ptr findAttachment(const QString &name, const QString &iCal) + static Attachment findAttachment(const QString &name, const QString &iCal) { Incidence::Ptr incidence = stringToIncidence(iCal); // get the attachment by name from the incidence Attachment::List attachments = incidence->attachments(); - Attachment::Ptr attachment; - if (!attachments.isEmpty()) { - const Attachment::List::ConstIterator end = attachments.constEnd(); - for (Attachment::List::ConstIterator it = attachments.constBegin(); it != end; ++it) { - if ((*it)->label() == name) { - attachment = *it; - break; - } + Attachment attachment; + const Attachment::List::ConstIterator end = attachments.constEnd(); + for (Attachment::List::ConstIterator it = attachments.constBegin(); it != end; ++it) { + if ((*it).label() == name) { + attachment = *it; + break; } } - if (!attachment) { + if (attachment.isEmpty()) { KMessageBox::error( nullptr, i18n("No attachment named \"%1\" found in the invitation.", name)); - return Attachment::Ptr(); + return Attachment(); } - if (attachment->isUri()) { + if (attachment.isUri()) { bool fileExists = false; - QUrl attachmentUrl(attachment->uri()); + QUrl attachmentUrl(attachment.uri()); if (attachmentUrl.isLocalFile()) { fileExists = QFile::exists(attachmentUrl.toLocalFile()); } else { @@ -403,7 +401,7 @@ "organizer to resend the invitation with this attachment " "stored inline instead of a link.", attachmentUrl.toDisplayString())); - return Attachment::Ptr(); + return Attachment(); } } return attachment; @@ -1025,18 +1023,18 @@ bool openAttachment(const QString &name, const QString &iCal) const { - Attachment::Ptr attachment(findAttachment(name, iCal)); - if (!attachment) { + Attachment attachment(findAttachment(name, iCal)); + if (attachment.isEmpty()) { return false; } - if (attachment->isUri()) { - QDesktopServices::openUrl(QUrl(attachment->uri())); + if (attachment.isUri()) { + QDesktopServices::openUrl(QUrl(attachment.uri())); } else { // put the attachment in a temporary file and launch it QTemporaryFile *file = nullptr; QMimeDatabase db; - QStringList patterns = db.mimeTypeForName(attachment->mimeType()).globPatterns(); + QStringList patterns = db.mimeTypeForName(attachment.mimeType()).globPatterns(); if (!patterns.empty()) { QString pattern = patterns.at(0); file = new QTemporaryFile(QDir::tempPath() + QStringLiteral("/messageviewer_XXXXXX") + pattern.remove(QLatin1Char('*'))); @@ -1046,22 +1044,22 @@ file->setAutoRemove(false); file->open(); file->setPermissions(QFile::ReadUser); - file->write(QByteArray::fromBase64(attachment->data())); + file->write(QByteArray::fromBase64(attachment.data())); file->close(); KRun::RunFlags flags; flags |= KRun::DeleteTemporaryFiles; - bool stat = KRun::runUrl(QUrl::fromLocalFile(file->fileName()), attachment->mimeType(), nullptr, flags); + bool stat = KRun::runUrl(QUrl::fromLocalFile(file->fileName()), attachment.mimeType(), nullptr, flags); delete file; return stat; } return true; } bool saveAsAttachment(const QString &name, const QString &iCal) const { - Attachment::Ptr a(findAttachment(name, iCal)); - if (!a) { + Attachment a(findAttachment(name, iCal)); + if (a.isEmpty()) { return false; } @@ -1073,17 +1071,17 @@ } bool stat = false; - if (a->isUri()) { + if (a.isUri()) { // save the attachment url - auto job = KIO::file_copy(QUrl(a->uri()), QUrl::fromLocalFile(saveAsFile)); + auto job = KIO::file_copy(QUrl(a.uri()), QUrl::fromLocalFile(saveAsFile)); stat = job->exec(); } else { // put the attachment in a temporary file and save it QTemporaryFile *file{ nullptr }; QMimeDatabase db; - QStringList patterns = db.mimeTypeForName(a->mimeType()).globPatterns(); + QStringList patterns = db.mimeTypeForName(a.mimeType()).globPatterns(); if (!patterns.empty()) { QString pattern = patterns.at(0); file = new QTemporaryFile(QDir::tempPath() + QStringLiteral("/messageviewer_XXXXXX") + pattern.remove(QLatin1Char('*'))); @@ -1093,7 +1091,7 @@ file->setAutoRemove(false); file->open(); file->setPermissions(QFile::ReadUser); - file->write(QByteArray::fromBase64(a->data())); + file->write(QByteArray::fromBase64(a.data())); file->close(); const QString filename = file->fileName(); delete file; diff --git a/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp b/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp --- a/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp +++ b/plugins/messageviewer/bodypartformatter/semantic/semanticurlhandler.cpp @@ -329,8 +329,8 @@ event->deleteAttachments(QStringLiteral("application/vnd.apple.pkpass")); using namespace KCalCore; - Attachment::Ptr att(new Attachment(data.toBase64(), QStringLiteral("application/vnd.apple.pkpass"))); - att->setLabel(i18n("Boarding Pass")); // TODO add passenger name after string freeze is lifted + Attachment att(data.toBase64(), QStringLiteral("application/vnd.apple.pkpass")); + att.setLabel(i18n("Boarding Pass")); // TODO add passenger name after string freeze is lifted event->addAttachment(att); } } diff --git a/plugins/messageviewerplugins/createeventplugin/eventedit.cpp b/plugins/messageviewerplugins/createeventplugin/eventedit.cpp --- a/plugins/messageviewerplugins/createeventplugin/eventedit.cpp +++ b/plugins/messageviewerplugins/createeventplugin/eventedit.cpp @@ -338,10 +338,10 @@ KCalCore::Event::Ptr EventEdit::createEventItem() { - KCalCore::Attachment::Ptr attachment(new KCalCore::Attachment(mMessage->encodedContent().toBase64(), KMime::Message::mimeType())); + KCalCore::Attachment attachment(mMessage->encodedContent().toBase64(), KMime::Message::mimeType()); const KMime::Headers::Subject *const subject = mMessage->subject(false); if (subject) { - attachment->setLabel(subject->asUnicodeString()); + attachment.setLabel(subject->asUnicodeString()); } KCalCore::Event::Ptr event(new KCalCore::Event); event->setSummary(mEventEdit->text()); diff --git a/plugins/messageviewerplugins/createtodoplugin/todoedit.cpp b/plugins/messageviewerplugins/createtodoplugin/todoedit.cpp --- a/plugins/messageviewerplugins/createtodoplugin/todoedit.cpp +++ b/plugins/messageviewerplugins/createtodoplugin/todoedit.cpp @@ -261,10 +261,10 @@ { KCalCore::Todo::Ptr todo(new KCalCore::Todo); todo->setSummary(mNoteEdit->text()); - KCalCore::Attachment::Ptr attachment(new KCalCore::Attachment(mMessage->encodedContent().toBase64(), KMime::Message::mimeType())); + KCalCore::Attachment attachment(mMessage->encodedContent().toBase64(), KMime::Message::mimeType()); const KMime::Headers::Subject *const subject = mMessage->subject(false); if (subject) { - attachment->setLabel(subject->asUnicodeString()); + attachment.setLabel(subject->asUnicodeString()); } todo->addAttachment(attachment);