[frameworks/kcalendarcore] /: Change parseScheduleMessage to take a QByteArray as input
Volker Krause <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 5c879d10f619c206f7f9affe04bee774cc035c6b by Volker Krause.
Committed on 07/08/2026 at 14:54.
Pushed by winterz into branch 'master'.
Change parseScheduleMessage to take a QByteArray as input
That's what it uses internally, and that's also what the users of it have
(coming from email), so we avoid a pointless back-and-forth conversion to
QString here.
createScheduleMessage() would benefit from the same change, but that's not
changeable without picking a different method name before KF7, so just add
a TODO for that for now.
M +1 -1 autotests/testicalformat.cpp
M +1 -1 src/CMakeLists.txt
M +8 -1 src/icalformat.cpp
M +20 -1 src/icalformat.h
https://invent.kde.org/frameworks/kcalendarcore/-/commit/5c879d10f619c206f7f9affe04bee774cc035c6b
diff --git a/autotests/testicalformat.cpp b/autotests/testicalformat.cpp
index 56eba9fd3..508585b6c 100644
--- a/autotests/testicalformat.cpp
+++ b/autotests/testicalformat.cpp
@@ -506,7 +506,7 @@ void ICalFormatTest::testAllDaySchedulingMessage()
const auto itipString = format.createScheduleMessage(event, KCalendarCore::iTIPRequest);
QVERIFY(!itipString.isEmpty());
- auto scheduleMsg = format.parseScheduleMessage(calendar, itipString);
+ auto scheduleMsg = format.parseScheduleMessage(calendar, itipString.toUtf8());
QVERIFY(scheduleMsg->error().isEmpty());
auto parsedEvent = scheduleMsg->event().staticCast<KCalendarCore::Event>();
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b50dafae9..5917a2c44 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -130,7 +130,7 @@ ecm_generate_export_header(KF6CalendarCore
VERSION ${KF_VERSION}
USE_VERSION_HEADER
DEPRECATED_BASE_VERSION 0
- DEPRECATION_VERSIONS
+ DEPRECATION_VERSIONS 6.30
EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT}
)
diff --git a/src/icalformat.cpp b/src/icalformat.cpp
index b6930d1a7..492fa8242 100644
--- a/src/icalformat.cpp
+++ b/src/icalformat.cpp
@@ -499,7 +499,14 @@ FreeBusy::Ptr ICalFormat::parseFreeBusy(const QString &str)
return freeBusy;
}
+#if KCALENDARCORE_BUILD_DEPRECATED_SINCE(6, 30)
ScheduleMessage::Ptr ICalFormat::parseScheduleMessage(const Calendar::Ptr &cal, const QString &messageText)
+{
+ return parseScheduleMessage(cal, messageText.toUtf8());
+}
+#endif
+
+ScheduleMessage::Ptr ICalFormat::parseScheduleMessage(const Calendar::Ptr &cal, const QByteArray &messageText)
{
Q_D(ICalFormat);
setTimeZone(cal->timeZone());
@@ -510,7 +517,7 @@ ScheduleMessage::Ptr ICalFormat::parseScheduleMessage(const Calendar::Ptr &cal,
return ScheduleMessage::Ptr();
}
- icalcomponent *message = icalparser_parse_string(messageText.toUtf8().constData());
+ icalcomponent *message = icalparser_parse_string(messageText.constData());
if (!message) {
setException(new Exception(Exception::ParseErrorUnableToParse));
diff --git a/src/icalformat.h b/src/icalformat.h
index 285b93195..db13a8087 100644
--- a/src/icalformat.h
+++ b/src/icalformat.h
@@ -181,8 +181,9 @@ public:
Returns a QString containing the message if successful; 0 otherwise.
*/
- Q_REQUIRED_RESULT QString createScheduleMessage(const IncidenceBase::Ptr &incidence, iTIPMethod method);
+ Q_REQUIRED_RESULT QString createScheduleMessage(const IncidenceBase::Ptr &incidence, iTIPMethod method); // TODO KF7 return a QByteArray instead
+#if KCALENDARCORE_ENABLE_DEPRECATED_SINCE(6, 30)
/*!
Parses a Calendar scheduling message string into ScheduleMessage object.
@@ -194,7 +195,25 @@ public:
Returns a pointer to a ScheduleMessage object if successful; 0 otherwise.
The calling routine may later free the return memory.
*/
+ KCALENDARCORE_DEPRECATED_VERSION(6, 30, "use the QByteArray overload instead")
ScheduleMessage::Ptr parseScheduleMessage(const Calendar::Ptr &calendar, const QString &string);
+#endif
+
+ /*!
+ Parses a Calendar scheduling message string into ScheduleMessage object.
+
+ \a calendar is a pointer to a Calendar object associated with the
+ scheduling message. This calendar will also be searched for pre-existing
+ instances of the incidence referred to in the scheduling message.
+
+ \a messageText is containing the data to be parsed.
+
+ Returns a pointer to a ScheduleMessage object if successful; 0 otherwise.
+ The calling routine may later free the return memory.
+
+ \since 6.30 (took a QString as argument previously)
+ */
+ [[nodiscard]] ScheduleMessage::Ptr parseScheduleMessage(const Calendar::Ptr &calendar, const QByteArray &messageText);
/*!
Converts a QString into a FreeBusy object.