File indexing completed on 2024-11-24 04:42:07

0001 /*
0002     SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 #ifndef ANDROIDICALCONVERTER_H
0007 #define ANDROIDICALCONVERTER_H
0008 
0009 #include <KCalendarCore/Event>
0010 
0011 class JniAttendeeData;
0012 class JniEventData;
0013 class JniExtendedPropertyData;
0014 class JniReminderData;
0015 
0016 /** Functions to convert between the Android and KCalendarCore iCal data representations. */
0017 class AndroidIcalConverter
0018 {
0019 public:
0020     /** Convert Android event data to KCalendarCore::Event. */
0021     static KCalendarCore::Event::Ptr readEvent(const JniEventData &data);
0022 
0023     /** Convert an KCalendarCore::Event to a Android event data. */
0024     static JniEventData writeEvent(const KCalendarCore::Event::Ptr &event);
0025 
0026 private:
0027     friend class AndroidIcalConverterTest;
0028 
0029     /** Convert Android attendee data to KCalndarCore::Attendee. */
0030     static KCalendarCore::Attendee readAttendee(const JniAttendeeData &data);
0031     /** Convert KCalendarCore::Attendee to Android attendee data. */
0032     static JniAttendeeData writeAttendee(const KCalendarCore::Attendee &attendee);
0033 
0034     /** Convert Android reminder data to KCalendarCore::Alarm. */
0035     static KCalendarCore::Alarm::Ptr readAlarm(const JniReminderData &data, KCalendarCore::Incidence *parent);
0036     /** Convert KCalendarCore::Alarm to Android reminder data. */
0037     static JniReminderData writeAlarm(const KCalendarCore::Alarm::Ptr &alarm);
0038 
0039     /** Add a decoded DAVx⁵ extended property to @p incidence. */
0040     static void addExtendedProperty(KCalendarCore::Incidence *incidence, const QString &name, const QString &value);
0041     /** Write extended properties in DAVx⁵ format. */
0042     static std::vector<JniExtendedPropertyData> writeExtendedProperties(const KCalendarCore::Incidence *incidence);
0043 
0044     /** Parse RDATE/EXDATE Android encoding. */
0045     template <typename T>
0046     static QList<T> readRDates(const QString &data);
0047     /** Write RDATE/EXDATE entries in the Android format. */
0048     static QString writeRDates(const QList<QDate> &rdates);
0049     static QString writeRDates(const QList<QDateTime> &rdates);
0050 };
0051 
0052 #endif // ANDROIDICALCONVERTER_H