Spectral/src/notifications/manager.h

56 lines
1.5 KiB
C
Raw Normal View History

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