File indexing completed on 2024-04-21 15:02:33

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef NOTIFYBYANDROID_H
0008 #define NOTIFYBYANDROID_H
0009 
0010 #include "knotificationplugin.h"
0011 
0012 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0013 #include <QAndroidJniObject>
0014 #else
0015 #include <QJniObject>
0016 // TODO KF6 remove this porting aid
0017 using QAndroidJniObject = QJniObject;
0018 #endif
0019 #include <QPointer>
0020 
0021 /** Android notification backend. */
0022 class NotifyByAndroid : public KNotificationPlugin
0023 {
0024     Q_OBJECT
0025 public:
0026     explicit NotifyByAndroid(QObject *parent = nullptr);
0027     ~NotifyByAndroid() override;
0028 
0029     // interface of KNotificationPlugin
0030     QString optionName() override;
0031     void notify(KNotification *notification, KNotifyConfig *config) override;
0032     void update(KNotification *notification, KNotifyConfig *config) override;
0033     void close(KNotification *notification) override;
0034 
0035     // interface from Java
0036     void notificationFinished(int id);
0037     void notificationActionInvoked(int id, int action);
0038     void notificationInlineReply(int id, const QString &text);
0039 
0040 private:
0041     void notifyDeferred(KNotification *notification);
0042     QAndroidJniObject createAndroidNotification(KNotification *notification, KNotifyConfig *config) const;
0043 
0044     QAndroidJniObject m_backend;
0045     QHash<int, QPointer<KNotification>> m_notifications;
0046 };
0047 
0048 #endif // NOTIFYBYANDROID_H