File indexing completed on 2024-04-21 05:50:56
0001 /* 0002 * SPDX-FileCopyrightText: 2020 Dimitris Kardarakos <dimkard@posteo.net> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #ifndef CALALARMCLIENT_H 0008 #define CALALARMCLIENT_H 0009 0010 #include <QDateTime> 0011 #include <QObject> 0012 0013 class NotificationHandler; 0014 class WakeupBackend; 0015 class WakeupManager; 0016 0017 /** 0018 * @brief Client that orchestrates the parsing of calendars and the display of notifications for event alarms. It exposes a D-Bus Interface containing a set of callable methods. 0019 * 0020 */ 0021 class CalAlarmClient : public QObject 0022 { 0023 Q_OBJECT 0024 Q_CLASSINFO("D-Bus Interface", "org.kde.kongressac") 0025 0026 public: 0027 explicit CalAlarmClient(QObject *parent = nullptr); 0028 0029 /** 0030 * @brief The Status of the checker that depends on the existence of a scheduling backend 0031 * 0032 */ 0033 enum CheckerStatus { 0034 Inactive = 0, 0035 Active = 1 0036 }; 0037 0038 /** 0039 * @return The method that should be triggered by the wakeup backend 0040 */ 0041 void wakeupCallback(); 0042 0043 // DBUS interface 0044 /** 0045 * @brief Quits the application 0046 * 0047 */ 0048 Q_SCRIPTABLE void quit(); 0049 0050 /** 0051 * @brief Checks the calendars for event alarms 0052 * 0053 */ 0054 Q_SCRIPTABLE void forceAlarmCheck(); 0055 0056 /** 0057 * @return Schedule alarm check 0058 */ 0059 Q_SCRIPTABLE void scheduleAlarmCheck(); 0060 0061 /** 0062 * @return Check if kongressac can handle alarms 0063 */ 0064 Q_SCRIPTABLE int active() const; 0065 0066 private: 0067 QString alarmText(const QString &uid) const; 0068 void checkAlarms(); 0069 void saveLastCheckTime(); 0070 QStringList calendarFileList() const; 0071 0072 QDateTime m_last_checked; 0073 NotificationHandler *m_notification_handler; 0074 WakeupManager *m_wakeup_manager; 0075 }; 0076 #endif