[pim/akonadi-calendar] /: Separate invitation parsing and handling

Allen Winter <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 4f276bc6cb2700e37e98b69042c05a7cb2c8be86 by Allen Winter, on behalf of Volker Krause.
Committed on 07/08/2026 at 10:53.
Pushed by vkrause into branch 'master'.

Separate invitation parsing and handling

The calling code of this already has the ScheduleMessage parsed, there's
no need to pass it as a QString and redo the parsing here.

M  +1    -1    CMakeLists.txt
M  +5    -1    autotests/itiphandlertest.cpp
M  +28   -0    src/itiphandler.cpp
M  +12   -0    src/itiphandler.h
M  +5    -1    src/itiphandler_p.cpp
M  +1    -0    src/itiphandler_p.h

https://invent.kde.org/pim/akonadi-calendar/-/commit/4f276bc6cb2700e37e98b69042c05a7cb2c8be86

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 433941f3..069ac648 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@
 
 cmake_minimum_required(VERSION 3.29)
 
-set(PIM_VERSION "6.8.40")
+set(PIM_VERSION "6.8.41")
 project(Akonadi-Calendar VERSION ${PIM_VERSION})
 
 # ECM setup
diff --git a/autotests/itiphandlertest.cpp b/autotests/itiphandlertest.cpp
index 0774f549..d25e6980 100644
--- a/autotests/itiphandlertest.cpp
+++ b/autotests/itiphandlertest.cpp
@@ -607,7 +607,11 @@ void ITIPHandlerTest::processItip(const QString &icaldata,
 {
     items.clear();
     m_pendingItipMessageSignal = 1;
-    m_itipHandler->processiTIPMessage(receiver, icaldata, action);
+
+    MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::systemTimeZone()));
+    ICalFormat format;
+    const auto message = format.parseScheduleMessage(calendar, icaldata);
+    m_itipHandler->processiTIPMessage(receiver, message, action);
     waitForIt();
 
     // 0 e-mails are sent because the status update e-mail is sent by
diff --git a/src/itiphandler.cpp b/src/itiphandler.cpp
index 69d006d7..9a72ec82 100644
--- a/src/itiphandler.cpp
+++ b/src/itiphandler.cpp
@@ -131,7 +131,35 @@ void ITIPHandler::processiTIPMessage(const QString &receiver, const QString &iCa
 
         return;
     }
+}
+
+void ITIPHandler::processiTIPMessage(const QString &receiver, const KCalendarCore::ScheduleMessage::Ptr &message, const QString &action)
+{
+    qCDebug(AKONADICALENDAR_LOG) << "processiTIPMessage called with receiver=" << receiver << "; action=" << action;
+
+    if (d->m_currentOperation != OperationNone) {
+        d->m_currentOperation = OperationNone;
+        qCritical() << "There can't be an operation in progress!" << d->m_currentOperation;
+        return;
+    }
+
+    d->m_currentOperation = OperationProcessiTIPMessage;
+
+    if (!d->isLoaded()) {
+        d->m_queuedInvitation.receiver = receiver;
+        d->m_queuedInvitation.message = message;
+        d->m_queuedInvitation.action = action;
+        return;
+    }
+
+    if (d->m_calendarLoadError) {
+        d->m_currentOperation = OperationNone;
+        qCritical() << "Error loading calendar";
+        emitiTipMessageProcessed(this, ResultError, i18n("Error loading calendar."));
+        return;
+    }
 
+    Q_ASSERT(message);
     d->m_method = static_cast<KCalendarCore::iTIPMethod>(message->method());
 
     KCalendarCore::ScheduleMessage::Status const status = message->status();
diff --git a/src/itiphandler.h b/src/itiphandler.h
index 241827b3..bf844882 100644
--- a/src/itiphandler.h
+++ b/src/itiphandler.h
@@ -310,7 +310,19 @@ public:
      *
      * \sa iTipMessageProcessed()
      */
+    [[deprecated("use the ScheduleMessage overload instead")]]
     void processiTIPMessage(const QString &receiver, const QString &iCal, const QString &action);
+    /*!
+     * Processes a received iTip message.
+     *
+     * \a receiver
+     * \a message The parsed schedule message ("invitation")
+     * \a action
+     *
+     * \sa iTipMessageProcessed()
+     * \since 26.12
+     */
+    void processiTIPMessage(const QString &receiver, const KCalendarCore::ScheduleMessage::Ptr &message, const QString &action);
 
     /*!
      * Sends an iTip message.
diff --git a/src/itiphandler_p.cpp b/src/itiphandler_p.cpp
index 72bbc9da..b7091542 100644
--- a/src/itiphandler_p.cpp
+++ b/src/itiphandler_p.cpp
@@ -79,7 +79,11 @@ void ITIPHandlerPrivate::onLoadFinished(bool success, const QString &errorMessag
             // Harmless hack, processiTIPMessage() asserts that there's not current operation running
             // to prevent users from calling it twice.
             m_currentOperation = OperationNone;
-            q->processiTIPMessage(m_queuedInvitation.receiver, m_queuedInvitation.iCal, m_queuedInvitation.action);
+            if (m_queuedInvitation.message) {
+                q->processiTIPMessage(m_queuedInvitation.receiver, m_queuedInvitation.message, m_queuedInvitation.action);
+            } else {
+                q->processiTIPMessage(m_queuedInvitation.receiver, m_queuedInvitation.iCal, m_queuedInvitation.action);
+            }
         } else {
             Q_EMIT q->iTipMessageProcessed(ITIPHandler::ResultError, i18n("Error loading calendar: %1", errorMessage));
         }
diff --git a/src/itiphandler_p.h b/src/itiphandler_p.h
index 7bf6304b..95ae5f36 100644
--- a/src/itiphandler_p.h
+++ b/src/itiphandler_p.h
@@ -22,6 +22,7 @@ namespace Akonadi
 struct Invitation {
     QString receiver;
     QString iCal;
+    KCalendarCore::ScheduleMessage::Ptr message;
     QString action;
     KCalendarCore::iTIPMethod method;
     KCalendarCore::Incidence::Ptr incidence;
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.