2013-08-13 23:09:46 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com>
|
2013-08-13 23:09:46 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2013-08-13 23:09:46 +01:00
|
|
|
*/
|
|
|
|
|
2013-08-20 12:53:36 +01:00
|
|
|
#ifndef NOTIFICATIONSPLUGIN_H
|
|
|
|
#define NOTIFICATIONSPLUGIN_H
|
2013-08-13 23:09:46 +01:00
|
|
|
|
2014-06-14 15:34:00 +01:00
|
|
|
#include <core/kdeconnectplugin.h>
|
2016-05-31 16:16:01 +01:00
|
|
|
|
2020-10-15 03:03:05 +01:00
|
|
|
#include "notification.h"
|
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
#define PACKET_TYPE_NOTIFICATION_REQUEST QStringLiteral("kdeconnect.notification.request")
|
|
|
|
#define PACKET_TYPE_NOTIFICATION_REPLY QStringLiteral("kdeconnect.notification.reply")
|
2019-02-08 22:47:41 +00:00
|
|
|
#define PACKET_TYPE_NOTIFICATION_ACTION QStringLiteral("kdeconnect.notification.action")
|
|
|
|
|
2013-08-13 23:18:32 +01:00
|
|
|
class NotificationsPlugin
|
2013-08-13 23:09:46 +01:00
|
|
|
: public KdeConnectPlugin
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-10-15 03:03:05 +01:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications")
|
2013-08-13 23:09:46 +01:00
|
|
|
|
|
|
|
public:
|
2017-09-03 20:39:44 +01:00
|
|
|
explicit NotificationsPlugin(QObject* parent, const QVariantList& args);
|
2018-03-18 11:42:15 +00:00
|
|
|
|
2018-03-04 19:48:51 +00:00
|
|
|
bool receivePacket(const NetworkPacket& np) override;
|
2016-06-20 08:05:02 +01:00
|
|
|
void connected() override;
|
2020-10-15 03:03:05 +01:00
|
|
|
QString dbusPath() const override;
|
|
|
|
|
|
|
|
void clearNotifications();
|
|
|
|
void dismissRequested(const QString& notification);
|
|
|
|
void replyRequested(Notification* noti);
|
|
|
|
void addNotification(Notification* noti);
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
Q_SCRIPTABLE QStringList activeNotifications();
|
|
|
|
Q_SCRIPTABLE void sendReply(const QString& replyId, const QString& message);
|
|
|
|
Q_SCRIPTABLE void sendAction(const QString& key, const QString& action);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
Q_SCRIPTABLE void notificationPosted(const QString& publicId);
|
|
|
|
Q_SCRIPTABLE void notificationRemoved(const QString& publicId);
|
|
|
|
Q_SCRIPTABLE void notificationUpdated(const QString& publicId);
|
|
|
|
Q_SCRIPTABLE void allNotificationsRemoved();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void removeNotification(const QString& internalId);
|
|
|
|
QString newId(); //Generates successive identifiers to use as public ids
|
|
|
|
void notificationReady();
|
|
|
|
|
|
|
|
QHash<QString, QPointer<Notification>> m_notifications;
|
|
|
|
QHash<QString, QString> m_internalIdToPublicId;
|
|
|
|
int m_lastId = 0;
|
2013-08-13 23:09:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|