[pim/kdepim-addons] /: Move TNEF invitation rendering code here

Carl Schwan <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b4d77bd9c6bba2f2559e7446dcedaaa9f62d153c by Carl Schwan, on behalf of Volker Krause.
Committed on 03/08/2026 at 09:16.
Pushed by carlschwan into branch 'master'.

Move TNEF invitation rendering code here

Doesn't belong into the format library, and avoids parsing the TNEF
message twice.

M  +1    -1    CMakeLists.txt
M  +7    -16   plugins/messageviewer/bodypartformatter/ms-tnef/application_ms-tnef.cpp

https://invent.kde.org/pim/kdepim-addons/-/commit/b4d77bd9c6bba2f2559e7446dcedaaa9f62d153c

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 802dd63d3..78b039ba1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -192,7 +192,7 @@ set(KADDRESSBOOK_IMPORTEXPORT_LIB_VERSION "6.7.40")
 set(LIBKLEO_LIB_VERSION "6.7.42")
 set(AKONADI_LIB_VERSION "6.7.40")
 set(INCIDENCEEDITOR_LIB_VERSION "6.7.43")
-set(KTNEF_LIB_VERSION "6.7.40")
+set(KTNEF_LIB_VERSION "6.7.41")
 set(MESSAGELIB_LIB_VERSION "6.7.40")
 set(AKONADICALENDAR_LIB_VERSION "6.7.42")
 set(CALENDAR_UTILS_VERSION "6.7.40")
diff --git a/plugins/messageviewer/bodypartformatter/ms-tnef/application_ms-tnef.cpp b/plugins/messageviewer/bodypartformatter/ms-tnef/application_ms-tnef.cpp
index 58ed870eb..50739dc9a 100644
--- a/plugins/messageviewer/bodypartformatter/ms-tnef/application_ms-tnef.cpp
+++ b/plugins/messageviewer/bodypartformatter/ms-tnef/application_ms-tnef.cpp
@@ -63,24 +63,15 @@ public:
 
         // Look for an invitation
         QString inviteStr;
-        QFile f(fileName);
-        QByteArray buf;
-        if (!f.open(QIODevice::ReadOnly)) {
-            qCWarning(MS_TNEF_LOG) << "Failed to read attachment part: " << f.errorString();
-        } else {
-            buf = f.readAll();
-            f.close();
-        }
-        if (!buf.isEmpty()) {
+        if (const auto ical = KTnef::messageToIcal(parser.message()); !ical.isEmpty()) {
             const KCalendarCore::MemoryCalendar::Ptr cl(new KCalendarCore::MemoryCalendar(QTimeZone::systemTimeZone()));
             KCalUtils::InvitationFormatterHelper helper;
-            const QString invite = KTnef::formatTNEFInvitation(buf, cl, &helper);
-            KCalendarCore::ICalFormat format;
-            const KCalendarCore::Incidence::Ptr inc = format.fromString(invite);
-            const KCalendarCore::Event::Ptr event = inc.dynamicCast<KCalendarCore::Event>();
-            if (event && event->hasEndDate()) {
-                // no enddate => not a valid invitation
-                inviteStr = KCalUtils::IncidenceFormatter::extensiveDisplayStr(QString(), inc);
+            inviteStr = KCalUtils::IncidenceFormatter::formatICalInvitation(ical, cl, &helper);
+            if (inviteStr.isEmpty()) {
+                KCalendarCore::ICalFormat format;
+                if (const auto inc = format.fromString(ical); inc) {
+                    inviteStr = KCalUtils::IncidenceFormatter::extensiveDisplayStr(QString(), inc);
+                }
             }
         }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.