ukui-notification/notification-server/server-private.h

96 lines
2.9 KiB
C
Raw Normal View History

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 {
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);
void InvokeAction(uint id, const QString &action_key);
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);
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:
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