summary refs log tree commit diff
path: root/src/notifications
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-17 16:37:25 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-07-17 16:37:25 +0300
commit0e814da91c8e041897a4c3f7e6e9234bbc7c6f7a (patch)
tree21f655d30630fe77ba48d07e4b357e2b6c6a5730 /src/notifications
parentMerge pull request #372 from bebehei/notification (diff)
downloadnheko-0e814da91c8e041897a4c3f7e6e9234bbc7c6f7a.tar.xz
Move all files under src/
Diffstat (limited to 'src/notifications')
-rw-r--r--src/notifications/Manager.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h
new file mode 100644

index 00000000..4ac60097 --- /dev/null +++ b/src/notifications/Manager.h
@@ -0,0 +1,55 @@ +#pragma once + +#include <QImage> +#include <QObject> +#include <QString> + +#if defined(Q_OS_LINUX) +#include <QtDBus/QDBusArgument> +#include <QtDBus/QDBusInterface> +#endif + +struct roomEventId +{ + QString roomId; + QString eventId; +}; + +class NotificationsManager : public QObject +{ + Q_OBJECT +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); + +#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); +}; + +#if defined(Q_OS_LINUX) +QDBusArgument & +operator<<(QDBusArgument &arg, const QImage &image); +const QDBusArgument & +operator>>(const QDBusArgument &arg, QImage &); +#endif