-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathnotifyserverapplet.cpp
More file actions
116 lines (89 loc) · 2.77 KB
/
notifyserverapplet.cpp
File metadata and controls
116 lines (89 loc) · 2.77 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "notifyserverapplet.h"
#include "notificationmanager.h"
#include "dbusadaptor.h"
#include "pluginfactory.h"
#include <QThread>
#include <QLoggingCategory>
namespace notification {
Q_DECLARE_LOGGING_CATEGORY(notifyLog)
}
namespace notification {
NotifyServerApplet::NotifyServerApplet(QObject *parent)
: DApplet(parent)
{
}
NotifyServerApplet::~NotifyServerApplet()
{
qDebug(notifyLog) << "Exit notification server.";
if (m_manager) {
m_manager->deleteLater();
}
if (m_worker) {
m_worker->exit();
m_worker->wait();
m_worker->deleteLater();
}
}
bool NotifyServerApplet::load()
{
return DApplet::load();
}
bool NotifyServerApplet::init()
{
DApplet::init();
m_manager = new NotificationManager();
if (!m_manager->registerDbusService()) {
qWarning(notifyLog) << QString("Can't register Notifications to the D-Bus object.");
return false;
}
new DbusAdaptor(m_manager);
new DDENotificationDbusAdaptor(m_manager);
connect(m_manager, &NotificationManager::NotificationStateChanged, this, &NotifyServerApplet::notificationStateChanged);
removeExpiredNotifications();
m_worker = new QThread();
m_manager->moveToThread(m_worker);
m_worker->start();
return true;
}
void NotifyServerApplet::actionInvoked(qint64 id, uint bubbleId, const QString &actionKey)
{
QMetaObject::invokeMethod(m_manager, "actionInvoked", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(QString, actionKey));
}
void NotifyServerApplet::actionInvoked(qint64 id, const QString &actionKey)
{
QMetaObject::invokeMethod(m_manager, "actionInvoked", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(QString, actionKey));
}
void NotifyServerApplet::notificationClosed(qint64 id, uint bubbleId, uint reason)
{
QMetaObject::invokeMethod(m_manager, "notificationClosed", Qt::DirectConnection, Q_ARG(qint64, id), Q_ARG(uint, bubbleId), Q_ARG(uint, reason));
}
QVariant NotifyServerApplet::appValue(const QString &appId, int configItem)
{
return m_manager->GetAppInfo(appId, configItem);
}
void NotifyServerApplet::removeNotification(qint64 id)
{
m_manager->removeNotification(id);
}
void NotifyServerApplet::removeNotifications(const QString &appName)
{
m_manager->removeNotifications(appName);
}
void NotifyServerApplet::removeNotifications()
{
m_manager->removeNotifications();
}
void NotifyServerApplet::removeExpiredNotifications()
{
m_manager->removeExpiredNotifications();
}
void NotifyServerApplet::setBlockClosedId(qint64 id)
{
m_manager->setBlockClosedId(id);
}
D_APPLET_CLASS(NotifyServerApplet)
}
#include "notifyserverapplet.moc"