2018-05-05 22:40:24 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QImage>
|
2018-07-11 17:33:02 +03:00
|
|
|
#include <QObject>
|
2018-05-05 22:40:24 +03:00
|
|
|
#include <QString>
|
|
|
|
|
2018-07-11 17:33:02 +03:00
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
#include <QtDBus/QDBusArgument>
|
|
|
|
#include <QtDBus/QDBusInterface>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct roomEventId
|
2018-05-05 22:40:24 +03:00
|
|
|
{
|
2018-07-11 17:33:02 +03:00
|
|
|
QString roomId;
|
|
|
|
QString eventId;
|
|
|
|
};
|
|
|
|
|
|
|
|
class NotificationsManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-05-05 22:40:24 +03:00
|
|
|
public:
|
2018-07-11 17:33:02 +03:00
|
|
|
NotificationsManager(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
void postNotification(const QString &roomId,
|
|
|
|
const QString &eventId,
|
|
|
|
const QString &roomName,
|
|
|
|
const QString &senderName,
|
|
|
|
const QString &text,
|
|
|
|
const QImage &icon);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void notificationClicked(const QString roomId, const QString eventId);
|
|
|
|
|
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
private:
|
|
|
|
QDBusInterface dbus;
|
|
|
|
uint showNotification(const QString summary, const QString text, const QImage image);
|
|
|
|
|
|
|
|
// notification ID to (room ID, event ID)
|
|
|
|
QMap<uint, roomEventId> notificationIds;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// these slots are platform specific (D-Bus only)
|
|
|
|
// but Qt slot declarations can not be inside an ifdef!
|
|
|
|
private slots:
|
|
|
|
void actionInvoked(uint id, QString action);
|
|
|
|
void notificationClosed(uint id, uint reason);
|
2018-05-05 22:40:24 +03:00
|
|
|
};
|
2018-07-11 17:33:02 +03:00
|
|
|
|
|
|
|
#if defined(Q_OS_LINUX)
|
|
|
|
QDBusArgument &
|
|
|
|
operator<<(QDBusArgument &arg, const QImage &image);
|
|
|
|
const QDBusArgument &
|
|
|
|
operator>>(const QDBusArgument &arg, QImage &);
|
|
|
|
#endif
|