2015-09-10 15:36:03 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2015 Holger Kaelberer <holger.k@elberer.de>
|
2015-09-10 15:36:03 +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
|
2015-09-10 15:36:03 +01:00
|
|
|
*/
|
|
|
|
|
2023-07-21 19:22:59 +01:00
|
|
|
#pragma once
|
2018-10-26 22:29:28 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QBuffer>
|
2018-10-07 19:23:20 +01:00
|
|
|
#include <QDBusAbstractAdaptor>
|
|
|
|
#include <QDBusArgument>
|
2016-08-27 12:59:25 +01:00
|
|
|
#include <QFile>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <core/device.h>
|
2015-09-10 15:36:03 +01:00
|
|
|
|
2023-03-13 02:20:12 +00:00
|
|
|
#include <gio/gio.h>
|
|
|
|
|
2015-09-10 15:36:03 +01:00
|
|
|
class KdeConnectPlugin;
|
|
|
|
class Notification;
|
2015-12-07 02:21:35 +00:00
|
|
|
struct NotifyingApplication;
|
2015-09-10 15:36:03 +01:00
|
|
|
|
2023-03-13 02:20:12 +00:00
|
|
|
class NotificationsListener : public QObject
|
2015-09-10 15:36:03 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2022-09-10 22:23:52 +01:00
|
|
|
explicit NotificationsListener(KdeConnectPlugin *aPlugin);
|
2016-06-20 08:05:02 +01:00
|
|
|
~NotificationsListener() override;
|
2015-09-10 15:36:03 +01:00
|
|
|
|
2015-12-05 22:13:34 +00:00
|
|
|
protected:
|
2022-09-10 22:23:52 +01:00
|
|
|
KdeConnectPlugin *m_plugin;
|
2017-09-03 20:39:44 +01:00
|
|
|
QHash<QString, NotifyingApplication> m_applications;
|
2015-09-10 15:36:03 +01:00
|
|
|
|
2016-08-27 12:59:25 +01:00
|
|
|
// virtual helper function to make testing possible (QDBusArgument can not
|
|
|
|
// be injected without making a DBUS-call):
|
2023-03-13 02:20:12 +00:00
|
|
|
virtual bool parseImageDataArgument(GVariant *argument,
|
2022-09-10 22:23:52 +01:00
|
|
|
int &width,
|
|
|
|
int &height,
|
|
|
|
int &rowStride,
|
|
|
|
int &bitsPerSample,
|
|
|
|
int &channels,
|
|
|
|
bool &hasAlpha,
|
|
|
|
QByteArray &imageData) const;
|
2023-03-13 02:20:12 +00:00
|
|
|
QSharedPointer<QIODevice> iconForImageData(GVariant *argument) const;
|
|
|
|
static QSharedPointer<QIODevice> iconForIconName(const QString &iconName);
|
2016-08-27 12:59:25 +01:00
|
|
|
|
2023-03-13 02:20:12 +00:00
|
|
|
static GDBusMessage *onMessageFiltered(GDBusConnection *connection, GDBusMessage *msg, int incoming, void *parent);
|
2015-12-05 22:11:57 +00:00
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void loadApplications();
|
|
|
|
|
2016-04-27 18:45:58 +01:00
|
|
|
private:
|
|
|
|
void setTranslatedAppName();
|
2017-09-03 20:39:44 +01:00
|
|
|
QString m_translatedAppName;
|
2023-03-13 02:20:12 +00:00
|
|
|
|
|
|
|
GDBusConnection *m_gdbusConnection = nullptr;
|
|
|
|
unsigned m_gdbusFilterId = 0;
|
2015-09-10 15:36:03 +01:00
|
|
|
};
|