增加消息缓存更新机制
This commit is contained in:
parent
a5ac8ceebf
commit
c6c8fe0998
|
@ -21,7 +21,7 @@
|
|||
#define UKUI_NOTIFICATION_SERVER_PRIVATE_H
|
||||
#include <QObject>
|
||||
#include <QDBusContext>
|
||||
#include <QVector>
|
||||
#include <QMap>
|
||||
class QDBusServiceWatcher;
|
||||
namespace NotificationServer {
|
||||
class Notification {
|
||||
|
@ -85,7 +85,7 @@ private:
|
|||
void sendCache();
|
||||
QDBusServiceWatcher *m_notificationWatchers = nullptr;
|
||||
uint m_increasedNotificationId = 1;
|
||||
QVector<Notification> m_notificationsCache;
|
||||
QMap<uint, Notification> m_notificationsCache;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ uint ServerPrivate::Notify(const QString &app_name, uint replaces_id, const QStr
|
|||
notification.m_body = body;
|
||||
notification.m_actions = actions;
|
||||
notification.m_hints = newHints;
|
||||
m_notificationsCache.append(notification);
|
||||
m_notificationsCache.insert(id, notification);
|
||||
return id;
|
||||
}
|
||||
for(const QString &service : m_notificationWatchers->watchedServices()) {
|
||||
|
@ -171,6 +171,9 @@ void ServerPrivate::UnRegisterClient()
|
|||
|
||||
void ServerPrivate::CloseNotification(uint id, uint reason)
|
||||
{
|
||||
if(m_notificationsCache.contains(id)) {
|
||||
m_notificationsCache.remove(id);
|
||||
}
|
||||
Q_EMIT NotificationClosed(id, reason);
|
||||
}
|
||||
|
||||
|
@ -182,8 +185,8 @@ void ServerPrivate::InvokeAction(uint id, const QString &action_key)
|
|||
|
||||
void ServerPrivate::sendCache()
|
||||
{
|
||||
while(!m_notificationsCache.isEmpty()) {
|
||||
auto notification = m_notificationsCache.takeFirst();
|
||||
for(const uint &id : m_notificationsCache.keys()) {
|
||||
auto notification = m_notificationsCache.take(id);
|
||||
for(const QString &service : m_notificationWatchers->watchedServices()) {
|
||||
QDBusMessage msg = QDBusMessage::createMethodCall(service,
|
||||
QStringLiteral("/NotificationClient"),
|
||||
|
|
Loading…
Reference in New Issue