File indexing completed on 2024-04-28 08:49:09
0001 /** 0002 * SPDX-FileCopyrightText: 2013 Albert Vaca <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <KNotification> 0010 #include <QDir> 0011 #include <QObject> 0012 #include <QPointer> 0013 #include <QString> 0014 0015 #include <core/device.h> 0016 #include <core/networkpacket.h> 0017 0018 class Notification : public QObject 0019 { 0020 Q_OBJECT 0021 Q_CLASSINFO("D-Bus Interface", "org.kde.kdeconnect.device.notifications.notification") 0022 Q_PROPERTY(QString internalId READ internalId CONSTANT) 0023 Q_PROPERTY(QString appName READ appName NOTIFY ready) 0024 Q_PROPERTY(QString ticker READ ticker NOTIFY ready) 0025 Q_PROPERTY(QString title READ title NOTIFY ready) 0026 Q_PROPERTY(QString text READ text NOTIFY ready) 0027 Q_PROPERTY(QString iconPath READ iconPath NOTIFY ready) 0028 Q_PROPERTY(bool dismissable READ dismissable NOTIFY ready) 0029 Q_PROPERTY(bool hasIcon READ hasIcon NOTIFY ready) 0030 Q_PROPERTY(bool silent READ silent NOTIFY ready) 0031 Q_PROPERTY(QString replyId READ replyId NOTIFY ready) 0032 0033 public: 0034 Notification(const NetworkPacket &np, const Device *device, QObject *parent); 0035 0036 QString internalId() const 0037 { 0038 return m_internalId; 0039 } 0040 QString appName() const 0041 { 0042 return m_appName; 0043 } 0044 QString ticker() const 0045 { 0046 return m_ticker; 0047 } 0048 QString title() const 0049 { 0050 return m_title; 0051 } 0052 QString text() const 0053 { 0054 return m_text; 0055 } 0056 QString iconPath() const 0057 { 0058 return m_iconPath; 0059 } 0060 bool dismissable() const 0061 { 0062 return m_dismissable; 0063 } 0064 QString replyId() const 0065 { 0066 return m_requestReplyId; 0067 } 0068 bool hasIcon() const 0069 { 0070 return m_hasIcon; 0071 } 0072 void show(); 0073 bool silent() const 0074 { 0075 return m_silent; 0076 } 0077 void update(const NetworkPacket &np); 0078 bool isReady() const 0079 { 0080 return m_ready; 0081 } 0082 void createKNotification(const NetworkPacket &np); 0083 0084 public Q_SLOTS: 0085 Q_SCRIPTABLE void dismiss(); 0086 Q_SCRIPTABLE void reply(); 0087 Q_SCRIPTABLE void sendReply(const QString &message); 0088 0089 Q_SIGNALS: 0090 void dismissRequested(const QString &m_internalId); 0091 void replyRequested(); 0092 Q_SCRIPTABLE void ready(); 0093 void actionTriggered(const QString &key, const QString &action); 0094 void replied(const QString &message); 0095 0096 private: 0097 QString m_internalId; 0098 QString m_appName; 0099 QString m_ticker; 0100 QString m_title; 0101 QString m_text; 0102 QString m_iconPath; 0103 QString m_requestReplyId; 0104 bool m_dismissable; 0105 bool m_hasIcon; 0106 QPointer<KNotification> m_notification; 0107 QDir m_imagesDir; 0108 bool m_silent; 0109 QString m_payloadHash; 0110 bool m_ready; 0111 QStringList m_actions; 0112 const Device *m_device; 0113 0114 void parseNetworkPacket(const NetworkPacket &np); 0115 void loadIcon(const NetworkPacket &np); 0116 void applyIcon(); 0117 0118 static QMap<QString, FileTransferJob *> s_downloadsInProgress; 0119 };