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-02-03 18:01:06 +08:00
|
|
|
|
|
|
|
|
|
#ifndef UKUI_NOTIFICATION_NOTIFICATION_CLIENT_PRIVATE_H
|
|
|
|
|
#define UKUI_NOTIFICATION_NOTIFICATION_CLIENT_PRIVATE_H
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QDBusInterface>
|
2023-02-17 16:54:45 +08:00
|
|
|
|
#include <QDBusServiceWatcher>
|
2023-02-03 18:01:06 +08:00
|
|
|
|
#include "notifications_interface.h"
|
2023-02-06 17:03:12 +08:00
|
|
|
|
#include "notification-client.h"
|
2023-02-03 18:01:06 +08:00
|
|
|
|
namespace UkuiNotification {
|
|
|
|
|
class NotificationClientPrivate : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2023-02-16 09:28:41 +08:00
|
|
|
|
explicit NotificationClientPrivate(NotificationClient *q);
|
2023-02-03 18:01:06 +08:00
|
|
|
|
~NotificationClientPrivate() override;
|
2023-02-17 16:54:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* 初始化客户端dbus服务并注册成为客户端
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2023-02-09 13:54:53 +08:00
|
|
|
|
bool init();
|
2023-02-17 16:54:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* 注销
|
|
|
|
|
*/
|
|
|
|
|
void unregisterClient();
|
2023-02-03 18:01:06 +08:00
|
|
|
|
static QString clientServicePath();
|
|
|
|
|
static QString clientServiceInterface();
|
|
|
|
|
|
|
|
|
|
void 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);
|
2023-03-08 16:57:51 +08:00
|
|
|
|
bool closeNotification(uint id, NotificationCloseReason::CloseReason reason);
|
2023-02-17 16:54:45 +08:00
|
|
|
|
bool invokeAction(uint id, const QString &action_key);
|
2023-02-13 17:10:55 +08:00
|
|
|
|
|
2023-02-09 13:54:53 +08:00
|
|
|
|
private Q_SLOTS:
|
2023-02-06 17:03:12 +08:00
|
|
|
|
void notificationClosed(uint id, uint reason);
|
2023-02-09 13:54:53 +08:00
|
|
|
|
void serviceChange(const QString &service, const QString &oldOwner, const QString &newOwner);
|
2023-02-17 16:54:45 +08:00
|
|
|
|
/**
|
|
|
|
|
* 用于注册客户端,或在服务发生变化(重启)后重新注册客户端
|
|
|
|
|
* @return true 成功 false 失败
|
|
|
|
|
*/
|
2023-02-09 13:54:53 +08:00
|
|
|
|
bool registerClient();
|
2023-02-13 17:10:55 +08:00
|
|
|
|
|
2023-02-09 13:54:53 +08:00
|
|
|
|
private:
|
2023-02-03 18:01:06 +08:00
|
|
|
|
OrgFreedesktopNotificationsInterface* m_notificationsInterface = nullptr;
|
|
|
|
|
QDBusInterface *m_serverInterface = nullptr;
|
2023-02-17 16:54:45 +08:00
|
|
|
|
QDBusServiceWatcher *m_watcher = nullptr;
|
|
|
|
|
bool m_registered = false;
|
2023-02-06 17:03:12 +08:00
|
|
|
|
NotificationClient *q;
|
2023-02-03 18:01:06 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
#endif //UKUI_NOTIFICATION_NOTIFICATION_CLIENT_PRIVATE_H
|