-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiqdbusservice.h
101 lines (80 loc) · 2.72 KB
/
iqdbusservice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* This file is part of IQ Notifier.
*
* IQ Notifier is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* IQ Notifier is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IQ Notifier. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <type_traits>
#include <vector>
#include <QObject>
#include <QString>
#include <QStringList>
#include <gsl/gsl>
#include "iqconfig.h"
#include "iqnotificationreceiver.h"
class IQDBusService : public QObject
{
Q_OBJECT
public:
static QString versionString();
static QString appString();
using QObject::QObject;
// TODO: use not_null
gsl::not_null<IQDBusService *>
connectReceiver(IQNotificationReceiver *receiver);
/*
* For configurable modifiers we should check is it enabled in config
*/
template <class T>
typename std::enable_if_t<std::is_base_of<IQConfigurable, T>::value,
gsl::not_null<IQDBusService *>>
addModifier(std::unique_ptr<T> modifier)
{
if (modifier->isEnabled())
modifers.push_back(std::move(modifier));
return this;
}
template <class T>
typename std::enable_if_t<!std::is_base_of<IQConfigurable, T>::value,
gsl::not_null<IQDBusService *>>
addModifier(std::unique_ptr<T> modifier)
{
modifers.push_back(std::move(modifier));
return this;
}
// DBus interface
QStringList GetCapabilities();
QString GetServerInformation(QString &vendor, QString &version,
QString &spec_version);
uint32_t Notify(const QString &app_name, uint32_t replaces_id,
const QString &app_icon, const QString &summary,
const QString &body, const QStringList &actions,
const QVariantMap &hints, uint32_t expire_timeout);
void CloseNotification(uint32_t id);
signals:
// DBus signals
void ActionInvoked(uint32_t notification_id, const QString &action_key);
void NotificationClosed(uint32_t notification_id, uint32_t reason);
// Internal signals
void createNotificationSignal(const IQNotification ¬ification);
void dropNotificationSignal(IQNotification::id_t id);
public slots:
void onNotificationDropped(IQNotification::id_t id,
IQNotification::ClosingReason reason);
void onActionInvoked(IQNotification::id_t id,
const QString &action_key);
private:
std::vector<IQNotificationModifier::ptr_t> modifers;
IQNotification modify(IQNotification notification);
};