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

81 lines
2.2 KiB
C
Raw Normal View History

2023-01-31 17:39:14 +08:00
//
// Created by zpf on 23-1-31.
//
#ifndef UKUI_NOTIFICATION_SERVER_PRIVATE_H
#define UKUI_NOTIFICATION_SERVER_PRIVATE_H
#include <QObject>
#include <QDBusContext>
#include <QVector>
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;
QVector<Notification> m_notificationsCache;
2023-01-31 17:39:14 +08:00
};
} // NotificationServer
#endif //UKUI_NOTIFICATION_SERVER_PRIVATE_H