matrixion/src/notifications/Manager.h

56 lines
1.5 KiB
C
Raw Normal View History

2018-05-05 22:40:24 +03:00
#pragma once
#include <QImage>
#include <QObject>
2018-05-05 22:40:24 +03:00
#include <QString>
2018-08-12 09:33:36 +03:00
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
#include <QtDBus/QDBusArgument>
#include <QtDBus/QDBusInterface>
#endif
struct roomEventId
2018-05-05 22:40:24 +03:00
{
QString roomId;
QString eventId;
};
class NotificationsManager : public QObject
{
Q_OBJECT
2018-05-05 22:40:24 +03:00
public:
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);
2018-08-12 09:33:36 +03:00
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
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-08-12 09:33:36 +03:00
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
QDBusArgument &
operator<<(QDBusArgument &arg, const QImage &image);
const QDBusArgument &
operator>>(const QDBusArgument &arg, QImage &);
#endif