File indexing completed on 2024-04-21 07:43:27

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 #include <QJniObject>
0013 #include <QPointer>
0014 
0015 /** Android notification backend. */
0016 class NotifyByAndroid : public KNotificationPlugin
0017 {
0018     Q_OBJECT
0019 public:
0020     explicit NotifyByAndroid(QObject *parent = nullptr);
0021     ~NotifyByAndroid() override;
0022 
0023     // interface of KNotificationPlugin
0024     QString optionName() override;
0025     void notify(KNotification *notification, const KNotifyConfig &notifyConfig) override;
0026     void update(KNotification *notification, const KNotifyConfig &notifyConfig) override;
0027     void close(KNotification *notification) override;
0028 
0029     // interface from Java
0030     void notificationFinished(int id);
0031     void notificationActionInvoked(int id, const QString &action);
0032     void notificationInlineReply(int id, const QString &text);
0033 
0034 private:
0035     void notifyDeferred(KNotification *notification);
0036     QJniObject createAndroidNotification(KNotification *notification, const KNotifyConfig &notifyConfig) const;
0037 
0038     QJniObject m_backend;
0039     QHash<int, QPointer<KNotification>> m_notifications;
0040 };
0041 
0042 #endif // NOTIFYBYANDROID_H