2023-04-17 11:15:11 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program 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
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: iaom <zhangpengfei@kylinos.cn>
|
|
|
|
*/
|
2023-01-31 17:39:14 +08:00
|
|
|
|
|
|
|
#ifndef UKUI_NOTIFICATION_SERVER_PRIVATE_H
|
|
|
|
#define UKUI_NOTIFICATION_SERVER_PRIVATE_H
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDBusContext>
|
2023-05-30 11:25:05 +08:00
|
|
|
#include <QMap>
|
2023-01-31 17:39:14 +08:00
|
|
|
class QDBusServiceWatcher;
|
|
|
|
namespace NotificationServer {
|
2023-02-17 16:54:45 +08:00
|
|
|
class Notification {
|
|
|
|
friend class ServerPrivate;
|
|
|
|
QString m_appName;
|
|
|
|
uint m_id = 0;
|
|
|
|
QString m_appIcon;
|
|
|
|
QString m_summary;
|
|
|
|
QString m_body;
|
|
|
|
QStringList m_actions;
|
|
|
|
QVariantMap m_hints;
|
|
|
|
int m_timeout;
|
|
|
|
};
|
2023-01-31 17:39:14 +08:00
|
|
|
class ServerPrivate : public QObject, protected QDBusContext
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-02-03 18:01:06 +08:00
|
|
|
//dbus interface
|
2023-01-31 17:39:14 +08:00
|
|
|
public:
|
|
|
|
QStringList GetCapabilities() const;
|
|
|
|
uint Notify(const QString &app_name,
|
|
|
|
uint replaces_id,
|
|
|
|
const QString &app_icon,
|
|
|
|
const QString &summary,
|
|
|
|
const QString &body,
|
|
|
|
const QStringList &actions,
|
|
|
|
const QVariantMap &hints,
|
|
|
|
int timeout);
|
|
|
|
void CloseNotification(uint id);
|
2023-02-06 17:03:12 +08:00
|
|
|
QString GetServerInformation(QString &vendor, QString &version, QString &spec_version) const;
|
2023-01-31 17:39:14 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 注册成为通知中心客户端
|
|
|
|
*/
|
|
|
|
void RegisterClient();
|
|
|
|
/**
|
|
|
|
* 注销
|
|
|
|
*/
|
|
|
|
void UnRegisterClient();
|
2023-02-03 18:01:06 +08:00
|
|
|
/**
|
|
|
|
* 通知中心关闭通知
|
|
|
|
* @param id 通知id
|
|
|
|
* @param reason 关闭原因
|
|
|
|
*/
|
|
|
|
void CloseNotification(uint id, uint);
|
2023-02-17 16:54:45 +08:00
|
|
|
void InvokeAction(uint id, const QString &action_key);
|
2023-03-20 18:08:44 +08:00
|
|
|
void UpdateUnreadMessagesNumber(const QString &desktopEntry, uint number);
|
2023-01-31 17:39:14 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void NotificationClosed(uint id, uint reason);
|
|
|
|
void ActionInvoked(uint id, const QString &actionKey);
|
|
|
|
void ActivationToken(uint id, const QString &ActivationToken);
|
2023-03-20 18:08:44 +08:00
|
|
|
void UnreadMessageNumberUpdated(const QString &desktopEntry, uint number);
|
2023-02-03 18:01:06 +08:00
|
|
|
public:
|
|
|
|
explicit ServerPrivate(QObject *parent = nullptr);
|
|
|
|
~ServerPrivate() override;
|
|
|
|
bool init();
|
|
|
|
|
|
|
|
static QString notificationServiceName();
|
|
|
|
static QString notificationServicePath();
|
|
|
|
static QString notificationServiceInterface();
|
2023-01-31 17:39:14 +08:00
|
|
|
private:
|
2023-02-17 16:54:45 +08:00
|
|
|
void sendCache();
|
2023-01-31 17:39:14 +08:00
|
|
|
QDBusServiceWatcher *m_notificationWatchers = nullptr;
|
2023-02-03 18:01:06 +08:00
|
|
|
uint m_increasedNotificationId = 1;
|
2023-05-30 11:25:05 +08:00
|
|
|
QMap<uint, Notification> m_notificationsCache;
|
2023-01-31 17:39:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // NotificationServer
|
|
|
|
|
|
|
|
#endif //UKUI_NOTIFICATION_SERVER_PRIVATE_H
|