File indexing completed on 2024-11-24 04:42:06
0001 /* 0002 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #ifndef KCALENDARCORE_ANDROIDCALENDAR_H 0007 #define KCALENDARCORE_ANDROIDCALENDAR_H 0008 0009 #include <KCalendarCore/Calendar> 0010 0011 #include "android/calendar.h" 0012 #include "incidencekey_p.h" 0013 0014 #include "jni.h" 0015 0016 #include <unordered_map> 0017 0018 /** Access to an Android system calendar. */ 0019 class AndroidCalendar : public KCalendarCore::Calendar 0020 { 0021 public: 0022 explicit AndroidCalendar(const QTimeZone &tz, const QString &owner, jlong id); 0023 ~AndroidCalendar(); 0024 0025 // KCalendarCore::Calendar interface 0026 bool deleteIncidenceInstances(const KCalendarCore::Incidence::Ptr &incidence) override; 0027 0028 bool addEvent(const KCalendarCore::Event::Ptr &event) override; 0029 bool deleteEvent(const KCalendarCore::Event::Ptr &event) override; 0030 bool deleteEventInstances(const KCalendarCore::Event::Ptr &event) override; 0031 KCalendarCore::Event::List rawEvents(KCalendarCore::EventSortField sortField = KCalendarCore::EventSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0032 KCalendarCore::Event::List rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override; 0033 KCalendarCore::Event::List rawEventsForDate(const QDate &date, const QTimeZone &timeZone = {}, KCalendarCore::EventSortField sortField = KCalendarCore::EventSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0034 KCalendarCore::Event::Ptr event(const QString &uid, const QDateTime &recurrenceId = {}) const override; 0035 KCalendarCore::Event::List eventInstances(const KCalendarCore::Incidence::Ptr &event, KCalendarCore::EventSortField sortField = KCalendarCore::EventSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0036 0037 bool addTodo(const KCalendarCore::Todo::Ptr &todo) override; 0038 bool deleteTodo(const KCalendarCore::Todo::Ptr &todo) override; 0039 bool deleteTodoInstances(const KCalendarCore::Todo::Ptr &todo) override; 0040 KCalendarCore::Todo::List rawTodos(KCalendarCore::TodoSortField sortField = KCalendarCore::TodoSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0041 KCalendarCore::Todo::List rawTodosForDate(const QDate &date) const override; 0042 KCalendarCore::Todo::List rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const override; 0043 KCalendarCore::Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId = {}) const override; 0044 KCalendarCore::Todo::List todoInstances(const KCalendarCore::Incidence::Ptr &todo, KCalendarCore::TodoSortField sortField = KCalendarCore::TodoSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0045 0046 bool addJournal(const KCalendarCore::Journal::Ptr &journal) override; 0047 bool deleteJournal(const KCalendarCore::Journal::Ptr &journal) override; 0048 bool deleteJournalInstances(const KCalendarCore::Journal::Ptr &journal) override; 0049 KCalendarCore::Journal::List rawJournals(KCalendarCore::JournalSortField sortField = KCalendarCore::JournalSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0050 KCalendarCore::Journal::List rawJournalsForDate(const QDate &date) const override; 0051 KCalendarCore::Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId = {}) const override; 0052 KCalendarCore::Journal::List journalInstances(const KCalendarCore::Incidence::Ptr &journal, KCalendarCore::JournalSortField sortField = KCalendarCore::JournalSortUnsorted, KCalendarCore::SortDirection sortDirection = KCalendarCore::SortDirectionAscending) const override; 0053 0054 KCalendarCore::Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const override; 0055 0056 // KCalendarCore::IncidenceObserver interface 0057 void incidenceUpdate(const QString &uid, const QDateTime &recurrenceId) override; 0058 void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override; 0059 0060 private: 0061 void registerEvents(const KCalendarCore::Event::List &events) const; 0062 void registerEvent(const KCalendarCore::Event::Ptr &event) const; 0063 0064 JniCalendar m_calendar; 0065 const QString m_owner; 0066 mutable std::unordered_map<IncidenceKey, KCalendarCore::Event::Ptr> m_incidences; 0067 }; 0068 0069 #endif // KCALENDARCORE_ANDROIDCALENDAR_H