diff --git a/plugins/notifications/kdeconnect_notifications.json b/plugins/notifications/kdeconnect_notifications.json index 8f746c6c..048eabd8 100644 --- a/plugins/notifications/kdeconnect_notifications.json +++ b/plugins/notifications/kdeconnect_notifications.json @@ -1,130 +1,131 @@ { "KPlugin": { "Authors": [ { "Email": "albertvaka@gmail.com", "Name": "Albert Vaca", "Name[ar]": "Albert Vaca", "Name[ca@valencia]": "Albert Vaca", "Name[ca]": "Albert Vaca", "Name[cs]": "Albert Vaca", "Name[da]": "Albert Vaca", "Name[de]": "Albert Vaca", "Name[el]": "Albert Vaca", "Name[en_GB]": "Albert Vaca", "Name[es]": "Albert Vaca", "Name[et]": "Albert Vaca", "Name[eu]": "Albert Vaca", "Name[fi]": "Albert Vaca", "Name[fr]": "Albert Vaca", "Name[gl]": "Albert Vaca", "Name[id]": "Albert Vaca", "Name[it]": "Albert Vaca", "Name[ko]": "Albert Vaca", "Name[nl]": "Albert Vaca", "Name[nn]": "Albert Vaca", "Name[pl]": "Albert Vaca", "Name[pt]": "Albert Vaca", "Name[pt_BR]": "Albert Vaca", "Name[ru]": "Albert Vaca", "Name[sk]": "Albert Vaca", "Name[sr@ijekavian]": "Алберт Вака Синтора", "Name[sr@ijekavianlatin]": "Albert Vaka Sintora", "Name[sr@latin]": "Albert Vaka Sintora", "Name[sr]": "Алберт Вака Синтора", "Name[sv]": "Albert Vaca", "Name[tr]": "Albert Vaca", "Name[uk]": "Albert Vaca", "Name[x-test]": "xxAlbert Vacaxx", "Name[zh_CN]": "Albert Vaca", "Name[zh_TW]": "Albert Vaca" } ], "Description": "Show device's notifications on this computer and keep them in sync", "Description[ar]": "أظهر إخطارات الجهاز على هذا الحاسوب وأبقها متزامنة", "Description[ca@valencia]": "Mostra les notificacions del dispositiu a l'ordinador i les manté sincronitzades", "Description[ca]": "Mostra les notificacions del dispositiu a l'ordinador i les manté sincronitzades", "Description[cs]": "Zobrazit upozornění telefonu v počítači a udržovat je synchronizovaná", "Description[da]": "Vis enhedens bekendtgørelser på denne computer og hold dem synkroniseret", "Description[de]": "Benachrichtigungen des Geräts auf diesem Rechner anzeigen und abgleichen", "Description[el]": "Εμφάνιση ειδοποιήσεων συσκευής στον υπολογιστή αυτόν και συγχρονισμός τους", "Description[en_GB]": "Show device's notifications on this computer and keep them in sync", "Description[es]": "Mostrar notificaciones del dispositivo en este equipo y mantenerlas en sincronía", "Description[et]": "Seadme märguannete näitamine arvutis ja nende sünkroonis hoidmine", "Description[eu]": "Erakutsi gailuaren jakinarazpenak ordenagailu honetan eta mantendu sinkronizatuta", "Description[fi]": "Näytä laitteen ilmoitukset tällä tietokoneella ja pidä ne ajan tasalla", "Description[fr]": "Affichez les notifications du téléphone sur l'ordinateur et synchronisez-les", "Description[gl]": "Mostrar as notificacións do dispositivo neste computador e mantelas sincronizadas.", "Description[id]": "Tampilkan notifikasi perangkat pada komputer ini dan menjaganya tetap tersinkron", "Description[it]": "Mostra le notifiche del telefono sul tuo computer e tienile sincronizzate", "Description[ko]": "휴대폰 알림을 컴퓨터에 표시하고 동기화하기", "Description[nl]": "Apparaatmeldingen op deze computer tonen en ze gesynchroniseerd houden", "Description[nn]": "Vis telefonvarslingar på datamaskina og hald dei synkronisert", "Description[pl]": "Pokaż powiadomienia urządzenia na swoim komputerze i synchronizuj je", "Description[pt]": "Mostrar as notificações do dispositivo neste computador e mantê-las sincronizadas", "Description[pt_BR]": "Mostra as notificações do aparelho neste computador e as mantém sincronizadas", "Description[ru]": "Показ уведомлений с устройства на компьютере и их синхронизация", "Description[sk]": "Zobraziť oznámenia telefónu na vašom počítači a udržať ich synchronizované", "Description[sr@ijekavian]": "Приказује обавештења са уређаја на рачунару и одржава их ажурним", "Description[sr@ijekavianlatin]": "Prikazuje obaveštenja sa uređaja na računaru i održava ih ažurnim", "Description[sr@latin]": "Prikazuje obaveštenja sa uređaja na računaru i održava ih ažurnim", "Description[sr]": "Приказује обавештења са уређаја на рачунару и одржава их ажурним", "Description[sv]": "Visa enhetens underrättelser på datorn och håll dem synkroniserade", "Description[tr]": "Aygıtın bildirimlerini bilgisayarda göster ve eşzamanlı tut", "Description[uk]": "Показ сповіщень з пристрою на цьому комп’ютері та підтримання синхронізації даних сповіщень", "Description[x-test]": "xxShow device's notifications on this computer and keep them in syncxx", "Description[zh_CN]": "在电脑显示手机通知并保持同步", "Description[zh_TW]": "在電腦上顯示裝置通知並且保持同步", "EnabledByDefault": true, "Icon": "preferences-desktop-notification", "Id": "kdeconnect_notifications", "License": "GPL", "Name": "Receive notifications", "Name[ar]": "استقبل الإخطارات", "Name[ca@valencia]": "Recepció de les notificacions", "Name[ca]": "Recepció de les notificacions", "Name[cs]": "Přijímat oznámení", "Name[da]": "Modtag bekendtgørelser", "Name[de]": "Benachrichtigungen empfangen", "Name[el]": "Λήψη ειδοποιήσεων", "Name[en_GB]": "Receive notifications", "Name[es]": "Recibir notificaciones", "Name[et]": "Märguannete vastuvõtmine", "Name[eu]": "Jaso jakinarazpenak", "Name[fi]": "Vastaanota ilmoituksia", "Name[fr]": "Recevoir les notifications", "Name[gl]": "Recibir notificacións", "Name[id]": "Receive notifications", "Name[it]": "Ricevi notifiche", "Name[ko]": "알림 받기", "Name[nl]": "Meldingen ontvangen", "Name[nn]": "Få varslingar", "Name[pl]": "Otrzymywanie powiadomień", "Name[pt]": "Receber as notificações", "Name[pt_BR]": "Receber notificações", "Name[ru]": "Получение уведомлений", "Name[sk]": "Prijať upozornenia", "Name[sr@ijekavian]": "Пријем обавештења", "Name[sr@ijekavianlatin]": "Prijem obaveštenja", "Name[sr@latin]": "Prijem obaveštenja", "Name[sr]": "Пријем обавештења", "Name[sv]": "Ta emot underrättelser", "Name[tr]": "Bildirimleri al", "Name[uk]": "Отримати сповіщення", "Name[x-test]": "xxReceive notificationsxx", "Name[zh_CN]": "接收通知", "Name[zh_TW]": "收到通知", "ServiceTypes": [ "KdeConnect/Plugin" ], "Version": "0.1", "Website": "http://albertvaka.wordpress.com" }, "X-KdeConnect-OutgoingPacketType": [ "kdeconnect.notification.request", - "kdeconnect.notification.reply" + "kdeconnect.notification.reply", + "kdeconnect.notification.action" ], "X-KdeConnect-SupportedPacketType": [ "kdeconnect.notification" ] } diff --git a/plugins/notifications/notification.cpp b/plugins/notifications/notification.cpp index 4f498c9c..797d737b 100644 --- a/plugins/notifications/notification.cpp +++ b/plugins/notifications/notification.cpp @@ -1,182 +1,202 @@ /** * Copyright 2013 Albert Vaca * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "notification.h" #include "notification_debug.h" #include +#include #include #include #include #include #include #include +#include + #include QMap Notification::s_downloadsInProgress; Notification::Notification(const NetworkPacket& np, QObject* parent) : QObject(parent) { //Make a own directory for each user so noone can see each others icons QString username; #ifdef Q_OS_WIN username = qgetenv("USERNAME"); #else username = qgetenv("USER"); #endif m_imagesDir = QDir::temp().absoluteFilePath(QStringLiteral("kdeconnect_") + username); m_imagesDir.mkpath(m_imagesDir.absolutePath()); QFile(m_imagesDir.absolutePath()).setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner); m_ready = false; parseNetworkPacket(np); createKNotification(np); } Notification::~Notification() { } void Notification::dismiss() { if (m_dismissable) { Q_EMIT dismissRequested(m_internalId); } } void Notification::show() { m_ready = true; Q_EMIT ready(); if (!m_silent) { m_notification->sendEvent(); } } void Notification::update(const NetworkPacket& np) { parseNetworkPacket(np); createKNotification(np); } KNotification* Notification::createKNotification(const NetworkPacket& np) { if (!m_notification) { m_notification = new KNotification(QStringLiteral("notification"), KNotification::CloseOnTimeout, this); m_notification->setComponentName(QStringLiteral("kdeconnect")); } QString escapedTitle = m_title.toHtmlEscaped(); QString escapedText = m_text.toHtmlEscaped(); QString escapedTicker = m_ticker.toHtmlEscaped(); m_notification->setTitle(m_appName.toHtmlEscaped()); if (m_title.isEmpty() && m_text.isEmpty()) { m_notification->setText(escapedTicker); } else if (m_appName==m_title) { m_notification->setText(escapedText); } else if (m_title.isEmpty()){ m_notification->setText(escapedText); } else if (m_text.isEmpty()){ m_notification->setText(escapedTitle); } else { m_notification->setText(escapedTitle+": "+escapedText); } + connect(m_notification, QOverload::of(&KNotification::activated), this, [this] (unsigned int actionIndex) { + // Do nothing for our own reply action + if(!m_requestReplyId.isEmpty() && actionIndex == 1) { + return; + } + // Notification action idices start at 1 + Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]); + }); + m_hasIcon = m_hasIcon && !m_payloadHash.isEmpty(); if (!m_hasIcon) { applyNoIcon(); show(); } else { m_iconPath = m_imagesDir.absoluteFilePath(m_payloadHash); loadIcon(np); } if (!m_requestReplyId.isEmpty()) { - m_notification->setActions(QStringList(i18n("Reply"))); + m_actions.prepend(i18n("Reply")); connect(m_notification, &KNotification::action1Activated, this, &Notification::reply); } + m_notification->setActions(m_actions); return m_notification; } void Notification::loadIcon(const NetworkPacket& np) { m_ready = false; if (QFileInfo::exists(m_iconPath)) { applyIcon(); show(); } else { FileTransferJob* fileTransferJob = s_downloadsInProgress.value(m_iconPath); if (!fileTransferJob) { fileTransferJob = np.createPayloadTransferJob(QUrl::fromLocalFile(m_iconPath)); fileTransferJob->start(); s_downloadsInProgress[m_iconPath] = fileTransferJob; } connect(fileTransferJob, &FileTransferJob::result, this, [this, fileTransferJob]{ s_downloadsInProgress.remove(m_iconPath); if (fileTransferJob->error()) { qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Error in FileTransferJob: " << fileTransferJob->errorString(); applyNoIcon(); } else { applyIcon(); } show(); }); } } void Notification::applyIcon() { QPixmap icon(m_iconPath, "PNG"); m_notification->setPixmap(icon); } void Notification::applyNoIcon() { //HACK The only way to display no icon at all is trying to load a non-existent icon m_notification->setIconName(QStringLiteral("not_a_real_icon")); } void Notification::reply() { Q_EMIT replyRequested(); } void Notification::parseNetworkPacket(const NetworkPacket& np) { m_internalId = np.get(QStringLiteral("id")); m_appName = np.get(QStringLiteral("appName")); m_ticker = np.get(QStringLiteral("ticker")); m_title = np.get(QStringLiteral("title")); m_text = np.get(QStringLiteral("text")); m_dismissable = np.get(QStringLiteral("isClearable")); m_hasIcon = np.hasPayload(); m_silent = np.get(QStringLiteral("silent")); m_payloadHash = np.get(QStringLiteral("payloadHash")); m_requestReplyId = np.get(QStringLiteral("requestReplyId"), QString()); + + m_actions.clear(); + + for (QJsonValue value : np.get(QStringLiteral("actions"))) { + m_actions.append(value.toString()); + } + } diff --git a/plugins/notifications/notification.h b/plugins/notifications/notification.h index 44b212dd..e243db34 100644 --- a/plugins/notifications/notification.h +++ b/plugins/notifications/notification.h @@ -1,100 +1,102 @@ /** * Copyright 2013 Albert Vaca * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef NOTIFICATION_H #define NOTIFICATION_H #include #include #include #include #include #include class Notification : public QObject { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications.notification") Q_PROPERTY(QString internalId READ internalId) Q_PROPERTY(QString appName READ appName) Q_PROPERTY(QString ticker READ ticker) Q_PROPERTY(QString title READ title) Q_PROPERTY(QString text READ text) Q_PROPERTY(QString iconPath READ iconPath) Q_PROPERTY(bool dismissable READ dismissable) Q_PROPERTY(bool hasIcon READ hasIcon) Q_PROPERTY(bool silent READ silent) Q_PROPERTY(QString replyId READ replyId) public: Notification(const NetworkPacket& np, QObject* parent); ~Notification() override; QString internalId() const { return m_internalId; } QString appName() const { return m_appName; } QString ticker() const { return m_ticker; } QString title() const { return m_title; } QString text() const { return m_text; } QString iconPath() const { return m_iconPath; } bool dismissable() const { return m_dismissable; } QString replyId() const { return m_requestReplyId; } bool hasIcon() const { return m_hasIcon; } void show(); bool silent() const { return m_silent; } void update(const NetworkPacket& np); bool isReady() const { return m_ready; } KNotification* createKNotification(const NetworkPacket& np); public Q_SLOTS: Q_SCRIPTABLE void dismiss(); Q_SCRIPTABLE void reply(); Q_SIGNALS: void dismissRequested(const QString& m_internalId); void replyRequested(); Q_SCRIPTABLE void ready(); + void actionTriggered(const QString& key, const QString& action); private: QString m_internalId; QString m_appName; QString m_ticker; QString m_title; QString m_text; QString m_iconPath; QString m_requestReplyId; bool m_dismissable; bool m_hasIcon; QPointer m_notification; QDir m_imagesDir; bool m_silent; QString m_payloadHash; bool m_ready; + QStringList m_actions; void parseNetworkPacket(const NetworkPacket& np); void loadIcon(const NetworkPacket& np); void applyIcon(); void applyNoIcon(); static QMap s_downloadsInProgress; }; #endif diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp index 41714979..843b7881 100644 --- a/plugins/notifications/notificationsdbusinterface.cpp +++ b/plugins/notifications/notificationsdbusinterface.cpp @@ -1,183 +1,193 @@ /** * Copyright 2013 Albert Vaca * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "notificationsdbusinterface.h" #include "notification_debug.h" #include "notification.h" #include #include #include #include "notificationsplugin.h" #include "sendreplydialog.h" //In older Qt released, qAsConst isnt available #include "qtcompat_p.h" NotificationsDbusInterface::NotificationsDbusInterface(KdeConnectPlugin* plugin) : QDBusAbstractAdaptor(const_cast(plugin->device())) , m_device(plugin->device()) , m_plugin(plugin) , m_lastId(0) { } NotificationsDbusInterface::~NotificationsDbusInterface() { qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Destroying NotificationsDbusInterface"; } void NotificationsDbusInterface::clearNotifications() { qDeleteAll(m_notifications); m_notifications.clear(); Q_EMIT allNotificationsRemoved(); } QStringList NotificationsDbusInterface::activeNotifications() { return m_notifications.keys(); } void NotificationsDbusInterface::notificationReady() { Notification* noti = static_cast(sender()); disconnect(noti, &Notification::ready, this, &NotificationsDbusInterface::notificationReady); addNotification(noti); } void NotificationsDbusInterface::processPacket(const NetworkPacket& np) { if (np.get(QStringLiteral("isCancel"))) { QString id = np.get(QStringLiteral("id")); // cut off kdeconnect-android's prefix if there: if (id.startsWith(QLatin1String("org.kde.kdeconnect_tp::"))) id = id.mid(id.indexOf(QLatin1String("::")) + 2); removeNotification(id); return; } QString id = np.get(QStringLiteral("id")); Notification* noti = nullptr; if (!m_internalIdToPublicId.contains(id)) { noti = new Notification(np, this); if (noti->isReady()) { addNotification(noti); } else { connect(noti, &Notification::ready, this, &NotificationsDbusInterface::notificationReady); } } else { QString pubId = m_internalIdToPublicId.value(id); noti = m_notifications.value(pubId); } noti->update(np); } void NotificationsDbusInterface::addNotification(Notification* noti) { const QString& internalId = noti->internalId(); if (m_internalIdToPublicId.contains(internalId)) { removeNotification(internalId); } //qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "addNotification" << internalId; connect(noti, &Notification::dismissRequested, this, &NotificationsDbusInterface::dismissRequested); connect(noti, &Notification::replyRequested, this, [this,noti]{ replyRequested(noti); }); + connect(noti, &Notification::actionTriggered, this, &NotificationsDbusInterface::sendAction); + const QString& publicId = newId(); m_notifications[publicId] = noti; m_internalIdToPublicId[internalId] = publicId; QDBusConnection::sessionBus().registerObject(m_device->dbusPath()+"/notifications/"+publicId, noti, QDBusConnection::ExportScriptableContents); Q_EMIT notificationPosted(publicId); } void NotificationsDbusInterface::removeNotification(const QString& internalId) { //qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "removeNotification" << internalId; if (!m_internalIdToPublicId.contains(internalId)) { qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Not found noti by internal Id: " << internalId; return; } QString publicId = m_internalIdToPublicId.take(internalId); Notification* noti = m_notifications.take(publicId); if (!noti) { qCDebug(KDECONNECT_PLUGIN_NOTIFICATION) << "Not found noti by public Id: " << publicId; return; } //Deleting the notification will unregister it automatically //QDBusConnection::sessionBus().unregisterObject(mDevice->dbusPath()+"/notifications/"+publicId); noti->deleteLater(); Q_EMIT notificationRemoved(publicId); } void NotificationsDbusInterface::dismissRequested(const QString& internalId) { NetworkPacket np(PACKET_TYPE_NOTIFICATION_REQUEST); np.set(QStringLiteral("cancel"), internalId); m_plugin->sendPacket(np); //Workaround: we erase notifications without waiting a response from the //phone because we won't receive a response if we are out of sync and this //notification no longer exists. Ideally, each time we reach the phone //after some time disconnected we should re-sync all the notifications. removeNotification(internalId); } void NotificationsDbusInterface::replyRequested(Notification* noti) { QString replyId = noti->replyId(); QString appName = noti->appName(); QString originalMessage = noti->ticker(); SendReplyDialog* dialog = new SendReplyDialog(originalMessage, replyId, appName); connect(dialog, &SendReplyDialog::sendReply, this, &NotificationsDbusInterface::sendReply); dialog->show(); dialog->raise(); } void NotificationsDbusInterface::sendReply(const QString& replyId, const QString& message) { NetworkPacket np(PACKET_TYPE_NOTIFICATION_REPLY); np.set(QStringLiteral("requestReplyId"), replyId); np.set(QStringLiteral("message"), message); m_plugin->sendPacket(np); } +void NotificationsDbusInterface::sendAction(const QString& key, const QString& action) +{ + NetworkPacket np(PACKET_TYPE_NOTIFICATION_ACTION); + np.set("key", key); + np.set("action", action); + m_plugin->sendPacket(np); +} + QString NotificationsDbusInterface::newId() { return QString::number(++m_lastId); } diff --git a/plugins/notifications/notificationsdbusinterface.h b/plugins/notifications/notificationsdbusinterface.h index 16943285..68261722 100644 --- a/plugins/notifications/notificationsdbusinterface.h +++ b/plugins/notifications/notificationsdbusinterface.h @@ -1,75 +1,76 @@ /** * Copyright 2013 Albert Vaca * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef NOTIFICATIONSDBUSINTERFACE_H #define NOTIFICATIONSDBUSINTERFACE_H #include #include #include #include #include #include #include "notification.h" class KdeConnectPlugin; class Device; class NotificationsDbusInterface : public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications") public: explicit NotificationsDbusInterface(KdeConnectPlugin* plugin); ~NotificationsDbusInterface() override; void processPacket(const NetworkPacket& np); 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 /*methods*/: void removeNotification(const QString& internalId); QString newId(); //Generates successive identifiers to use as public ids void notificationReady(); private /*attributes*/: const Device* m_device; KdeConnectPlugin* m_plugin; QHash> m_notifications; QHash m_internalIdToPublicId; int m_lastId; }; #endif diff --git a/plugins/notifications/notificationsplugin.h b/plugins/notifications/notificationsplugin.h index e5890e60..cfb34f21 100644 --- a/plugins/notifications/notificationsplugin.h +++ b/plugins/notifications/notificationsplugin.h @@ -1,55 +1,57 @@ /** * Copyright 2013 Albert Vaca * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef NOTIFICATIONSPLUGIN_H #define NOTIFICATIONSPLUGIN_H #include #define PACKET_TYPE_NOTIFICATION_REQUEST QStringLiteral("kdeconnect.notification.request") #define PACKET_TYPE_NOTIFICATION_REPLY QStringLiteral("kdeconnect.notification.reply") +#define PACKET_TYPE_NOTIFICATION_ACTION QStringLiteral("kdeconnect.notification.action") + /* * This class is just a proxy for NotificationsDbusInterface * because it can not inherit from QDBusAbstractAdaptor and * KdeConnectPlugin at the same time (both are QObject) */ class NotificationsDbusInterface; class NotificationsListener; class NotificationsPlugin : public KdeConnectPlugin { Q_OBJECT public: explicit NotificationsPlugin(QObject* parent, const QVariantList& args); ~NotificationsPlugin() override; bool receivePacket(const NetworkPacket& np) override; void connected() override; protected: NotificationsDbusInterface* notificationsDbusInterface; NotificationsListener* notificationsListener; }; #endif