/** * SPDX-FileCopyrightText: 2015 Holger Kaelberer * SPDX-FileCopyrightText: 2018 Richard Liebscher * * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ #pragma once #include #include #include #include #include #include #include class KdeConnectPlugin; struct NotifyingApplication; #define PACKET_TYPE_NOTIFICATION QStringLiteral("kdeconnect.notification") class NotificationsListenerThread : public QThread { Q_OBJECT public: void run() override; void stop(); void handleNotifyCall(DBusMessage *message); Q_SIGNALS: void notificationReceived(const QString &, uint, const QString &, const QString &, const QString &, const QStringList &, const QVariantMap &, int); private: std::atomic m_connection = nullptr; }; // TODO: make a singleton, shared for all devices class NotificationsListener : public QObject { Q_OBJECT public: explicit NotificationsListener(KdeConnectPlugin *aPlugin); ~NotificationsListener() override; protected: KdeConnectPlugin *m_plugin; QHash m_applications; // virtual helper function to make testing possible (QDBusArgument can not // be injected without making a DBUS-call): virtual bool parseImageDataArgument(const QVariant &argument, int &width, int &height, int &rowStride, int &bitsPerSample, int &channels, bool &hasAlpha, QByteArray &imageData) const; QSharedPointer iconForImageData(const QVariant &argument) const; QSharedPointer iconForIconName(const QString &iconName) const; QSharedPointer iconFromQImage(const QImage &image) const; private Q_SLOTS: void loadApplications(); void onNotify(const QString &, uint, const QString &, const QString &, const QString &, const QStringList &, const QVariantMap &, int); private: QSharedPointer pngFromImage(); NotificationsListenerThread *m_thread; };