aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-08-23 22:39:27 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-08-23 22:50:32 (GMT)
commitf82aa88b10f68e91289333c7043892df1a41f22e (patch)
treef5afcafb411bfa95a94b4a1eb7a40a7ea77227e6
parentc2c0a34d4145eb8a0187348e4f51784ab8d12f66 (diff)
Expose SubscriptionChangeNotification to Monitor (Protocol change)
We can now monitor changes in all Monitors subscriptions through Monitor
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/monitor.h49
-rw-r--r--src/core/monitor_p.cpp59
-rw-r--r--src/core/monitor_p.h3
-rw-r--r--src/core/notificationsubscriber.cpp180
-rw-r--r--src/core/notificationsubscriber.h80
-rw-r--r--src/core/subscriptionmonitor.cpp247
-rw-r--r--src/core/subscriptionmonitor.h123
-rw-r--r--src/private/protocol.cpp349
-rw-r--r--src/private/protocol_p.h70
-rw-r--r--src/server/notificationsubscriber.cpp19
-rw-r--r--src/server/notificationsubscriber.h3
13 files changed, 484 insertions, 704 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3cf91bc..df5af7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,7 @@ include(ECMQtDeclareLoggingCategory)
include(AkonadiMacros)
-set(PIM_VERSION "5.3.42")
+set(PIM_VERSION "5.3.43")
set(QT_REQUIRED_VERSION "5.5.0")
set(AKONADI_VERSION ${PIM_VERSION})
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 2dca11d..203bfb3 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -47,6 +47,7 @@ set(akonadicore_base_SRCS
monitor_p.cpp
newmailnotifierattribute.cpp
notificationsource_p.cpp
+ notificationsubscriber.cpp
partfetcher.cpp
pastehelper.cpp
persistentsearchattribute.cpp
@@ -61,7 +62,6 @@ set(akonadicore_base_SRCS
sessionthread.cpp
specialcollectionattribute.cpp
specialcollections.cpp
- subscriptionmonitor.cpp
tag.cpp
tagattribute.cpp
tagfetchscope.cpp
@@ -104,6 +104,7 @@ ecm_generate_headers(AkonadiCore_base_HEADERS
KDSignalBlocker
MimeTypeChecker
NewMailNotifierAttribute
+ NotificationSubscriber
Monitor
PartFetcher
PersistentSearchAttribute
@@ -115,7 +116,6 @@ ecm_generate_headers(AkonadiCore_base_HEADERS
SpecialCollections
SpecialCollectionAttribute
Supertrait
- SubscriptionMonitor
Tag
TagAttribute
TagFetchScope
diff --git a/src/core/monitor.h b/src/core/monitor.h
index 19b9143..4903995 100644
--- a/src/core/monitor.h
+++ b/src/core/monitor.h
@@ -38,6 +38,7 @@ class ItemFetchScope;
class MonitorPrivate;
class Session;
class TagFetchScope;
+class NotificationSubscriber;
namespace Protocol
{
@@ -91,7 +92,14 @@ public:
Collections = 1,
Items,
Tags,
- Relations
+ Relations,
+ /**
+ * Listen to subscription changes of other Monitors connected to Akonadi.
+ * This is only for debugging purposes and should not be used in real
+ * applications.
+ * @since 5.4
+ */
+ Subscribers
};
/**
@@ -674,6 +682,45 @@ Q_SIGNALS:
void relationRemoved(const Akonadi::Relation &relation);
/**
+ * This signal is emitted when Subscribers are monitored and a new subscriber
+ * subscribers to the server.
+ *
+ * @param subscriber The new subscriber
+ * @since 5.4
+ *
+ * @note Monitoring for subscribers and listening to this signal only makes
+ * sense if you want to globally debug Monitors. There is no reason to use
+ * this in regular applications.
+ */
+ void notificationSubscriberAdded(const Akonadi::NotificationSubscriber &subscriber);
+
+ /**
+ * This signal is emitted when Subscribers are monitored and an existing
+ * subscriber changes its subscription.
+ *
+ * @param subscriber The changed subscriber
+ * @since 5.4
+ *
+ * @note Monitoring for subscribers and listening to this signal only makes
+ * sense if you want to globally debug Monitors. There is no reason to use
+ * this in regular applications.
+ */
+ void notificationSubscriberChanged(const Akonadi::NotificationSubscriber &subscriber);
+
+ /**
+ * This signal is emitted when Subscribers are monitored and an existing
+ * subscriber unsubscribes from the server.
+ *
+ * @param subscriber The removed subscriber
+ * @since 5.4
+ *
+ * @note Monitoring for subscribers and listening to this signal only makes
+ * sense if you want to globally debug Monitors. There is no reason to use
+ * this in regular applications.
+ */
+ void notificationSubscriberRemoved(const Akonadi::NotificationSubscriber &subscriber);
+
+ /**
* This signal is emitted if the Monitor starts or stops monitoring @p collection explicitly.
* @param collection The collection
* @param monitored Whether the collection is now being monitored or not.
diff --git a/src/core/monitor_p.cpp b/src/core/monitor_p.cpp
index 7167d41..9ed72d7 100644
--- a/src/core/monitor_p.cpp
+++ b/src/core/monitor_p.cpp
@@ -30,6 +30,7 @@
#include "changemediator_p.h"
#include "vectorhelper.h"
#include "akonadicore_debug.h"
+#include "notificationsubscriber.h"
using namespace Akonadi;
class operation;
@@ -340,6 +341,10 @@ bool MonitorPrivate::ensureDataAvailable(const Protocol::ChangeNotification &msg
return true;
}
+ if (msg.type() == Protocol::Command::SubscriptionChangeNotification) {
+ return true;
+ }
+
if (msg.type() == Protocol::Command::CollectionChangeNotification
&& static_cast<const Protocol::CollectionChangeNotification&>(msg).operation() == Protocol::CollectionChangeNotification::Remove) {
//For collection removals the collection is gone anyways, so we can't fetch it. Rid will be set later on instead.
@@ -466,6 +471,25 @@ bool MonitorPrivate::emitNotification(const Protocol::ChangeNotification &msg)
if (!items.isEmpty() || itemNtf.operation() == Protocol::ItemChangeNotification::Remove || !fetchItems()) {
someoneWasListening = emitItemsNotification(msg, items, parent, destParent);
}
+ } else if (msg.type() == Protocol::Command::SubscriptionChangeNotification) {
+ const auto &subNtf = static_cast<const Protocol::SubscriptionChangeNotification&>(msg);
+ NotificationSubscriber subscriber;
+ subscriber.setSubscriber(subNtf.subscriber());
+ subscriber.setSessionId(subNtf.sessionId());
+ subscriber.setMonitoredCollections(subNtf.collections());
+ subscriber.setMonitoredItems(subNtf.items());
+ subscriber.setMonitoredTags(subNtf.tags());
+ QSet<Monitor::Type> monitorTypes;
+ Q_FOREACH (auto type, subNtf.types()) {
+ monitorTypes.insert(static_cast<Monitor::Type>(type));
+ }
+ subscriber.setMonitoredTypes(monitorTypes);
+ subscriber.setMonitoredMimeTypes(subNtf.mimeTypes());
+ subscriber.setMonitoredResources(subNtf.resources());
+ subscriber.setIgnoredSessions(subNtf.ignoredSessions());
+ subscriber.setIsAllMonitored(subNtf.isAllMonitored());
+ subscriber.setIsExclusive(subNtf.isExclusive());
+ someoneWasListening = emitSubscriptionChangeNotification(subNtf, subscriber);
}
return someoneWasListening;
@@ -673,6 +697,7 @@ void MonitorPrivate::commandReceived(qint64 tag, const Protocol::Command &comman
case Protocol::Command::CollectionChangeNotification:
case Protocol::Command::TagChangeNotification:
case Protocol::Command::RelationChangeNotification:
+ case Protocol::Command::SubscriptionChangeNotification:
slotNotify(command);
break;
default:
@@ -1141,6 +1166,40 @@ bool MonitorPrivate::emitRelationNotification(const Protocol::RelationChangeNoti
return false;
}
+bool MonitorPrivate::emitSubscriptionChangeNotification(const Protocol::SubscriptionChangeNotification &msg,
+ const Akonadi::NotificationSubscriber &subscriber)
+{
+ if (!subscriber.isValid()) {
+ return false;
+ }
+
+ switch (msg.operation()) {
+ case Protocol::SubscriptionChangeNotification::Add:
+ if (q_ptr->receivers(SIGNAL(notificationSubscriberAdded(Akonadi::NotificationSubscriber))) == 0) {
+ return false;
+ }
+ Q_EMIT q_ptr->notificationSubscriberAdded(subscriber);
+ return true;
+ case Protocol::SubscriptionChangeNotification::Modify:
+ if (q_ptr->receivers(SIGNAL(notificationSubscriberChanged(Akonadi::NotificationSubscriber))) == 0) {
+ return false;
+ }
+ Q_EMIT q_ptr->notificationSubscriberChanged(subscriber);
+ return true;
+ case Protocol::SubscriptionChangeNotification::Remove:
+ if (q_ptr->receivers(SIGNAL(notificationSubscriberRemoved(Akonadi::NotificationSubscriber))) == 0) {
+ return false;
+ }
+ Q_EMIT q_ptr->notificationSubscriberRemoved(subscriber);
+ return true;
+ default:
+ break;
+ }
+
+ return false;
+}
+
+
void MonitorPrivate::invalidateCaches(const Protocol::ChangeNotification &msg)
{
// remove invalidates
diff --git a/src/core/monitor_p.h b/src/core/monitor_p.h
index ef91796..73f7127 100644
--- a/src/core/monitor_p.h
+++ b/src/core/monitor_p.h
@@ -161,6 +161,9 @@ public:
bool emitRelationNotification(const Protocol::RelationChangeNotification &msg, const Relation &relation);
+ bool emitSubscriptionChangeNotification(const Protocol::SubscriptionChangeNotification &msg,
+ const NotificationSubscriber &subscriber);
+
void serverStateChanged(Akonadi::ServerManager::State state);
/**
diff --git a/src/core/notificationsubscriber.cpp b/src/core/notificationsubscriber.cpp
new file mode 100644
index 0000000..8c84279
--- /dev/null
+++ b/src/core/notificationsubscriber.cpp
@@ -0,0 +1,180 @@
+#include "notificationsubscriber.h"
+
+namespace Akonadi
+{
+class NotificationSubscriber::Private : public QSharedData
+{
+public:
+ explicit Private()
+ : QSharedData()
+ , isAllMonitored(false)
+ , isExclusive(false)
+ {}
+
+ Private(const Private &other)
+ : QSharedData(other)
+ , subscriber(other.subscriber)
+ , sessionId(other.sessionId)
+ , collections(other.collections)
+ , items(other.items)
+ , tags(other.tags)
+ , types(other.types)
+ , mimeTypes(other.mimeTypes)
+ , resources(other.resources)
+ , ignoredSessions(other.ignoredSessions)
+ , isAllMonitored(other.isAllMonitored)
+ , isExclusive(other.isExclusive)
+ {}
+
+ QByteArray subscriber;
+ QByteArray sessionId;
+ QSet<qint64> collections;
+ QSet<qint64> items;
+ QSet<qint64> tags;
+ QSet<Monitor::Type> types;
+ QSet<QString> mimeTypes;
+ QSet<QByteArray> resources;
+ QSet<QByteArray> ignoredSessions;
+ bool isAllMonitored;
+ bool isExclusive;
+};
+
+}
+
+using namespace Akonadi;
+
+NotificationSubscriber::NotificationSubscriber()
+ : d(new Private)
+{
+}
+
+NotificationSubscriber::NotificationSubscriber(const NotificationSubscriber &other)
+ : d(other.d)
+{
+}
+
+NotificationSubscriber::~NotificationSubscriber()
+{
+}
+
+NotificationSubscriber &NotificationSubscriber::operator=(const NotificationSubscriber &other)
+{
+ d = other.d;
+ return *this;
+}
+
+bool NotificationSubscriber::isValid() const
+{
+ return !d->subscriber.isEmpty();
+}
+
+
+QByteArray NotificationSubscriber::subscriber() const
+{
+ return d->subscriber;
+}
+
+void NotificationSubscriber::setSubscriber(const QByteArray &subscriber)
+{
+ d->subscriber = subscriber;
+}
+
+QByteArray NotificationSubscriber::sessionId() const
+{
+ return d->sessionId;
+}
+
+void NotificationSubscriber::setSessionId(const QByteArray &sessionId)
+{
+ d->sessionId = sessionId;
+}
+
+QSet<qint64> NotificationSubscriber::monitoredCollections() const
+{
+ return d->collections;
+}
+
+void NotificationSubscriber::setMonitoredCollections(const QSet<qint64> &collections)
+{
+ d->collections = collections;
+}
+
+QSet<qint64> NotificationSubscriber::monitoredItems() const
+{
+ return d->items;
+}
+
+void NotificationSubscriber::setMonitoredItems(const QSet<qint64> &items)
+{
+ d->items = items;
+}
+
+QSet<qint64> NotificationSubscriber::monitoredTags() const
+{
+ return d->tags;
+}
+
+void NotificationSubscriber::setMonitoredTags(const QSet<qint64> &tags)
+{
+ d->tags = tags;
+}
+
+QSet<Monitor::Type> NotificationSubscriber::monitoredTypes() const
+{
+ return d->types;
+}
+
+void NotificationSubscriber::setMonitoredTypes(const QSet<Monitor::Type> &types)
+{
+ d->types = types;
+}
+
+QSet<QString> NotificationSubscriber::monitoredMimeTypes() const
+{
+ return d->mimeTypes;
+}
+
+void NotificationSubscriber::setMonitoredMimeTypes(const QSet<QString> &mimeTypes)
+{
+ d->mimeTypes = mimeTypes;
+}
+
+QSet<QByteArray> NotificationSubscriber::monitoredResources() const
+{
+ return d->resources;
+}
+
+void NotificationSubscriber::setMonitoredResources(const QSet<QByteArray> &resources)
+{
+ d->resources = resources;
+}
+
+QSet<QByteArray> NotificationSubscriber::ignoredSessions() const
+{
+ return d->ignoredSessions;
+}
+
+void NotificationSubscriber::setIgnoredSessions(const QSet<QByteArray> &ignoredSessions)
+{
+ d->ignoredSessions = ignoredSessions;
+}
+
+bool NotificationSubscriber::isAllMonitored() const
+{
+ return d->isAllMonitored;
+}
+
+void NotificationSubscriber::setIsAllMonitored(bool isAllMonitored)
+{
+ d->isAllMonitored = isAllMonitored;
+}
+
+bool NotificationSubscriber::isExclusive() const
+{
+ return d->isExclusive;
+}
+
+void NotificationSubscriber::setIsExclusive(bool isExclusive)
+{
+ d->isExclusive = isExclusive;
+}
diff --git a/src/core/notificationsubscriber.h b/src/core/notificationsubscriber.h
new file mode 100644
index 0000000..6006354
--- /dev/null
+++ b/src/core/notificationsubscriber.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (c) 2016 Daniel Vrátil <dvratil@kde.org>
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ This library 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 Library General Public
+ License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+*/
+
+#ifndef AKONADI_NOTIFICATIONSUBSCRIBER_H
+#define AKONADI_NOTIFICATIONSUBSCRIBER_H
+
+#include <akonadicore_export.h>
+
+#include "monitor.h"
+#include <QSet>
+
+namespace Akonadi {
+
+class AKONADICORE_EXPORT NotificationSubscriber
+{
+public:
+ explicit NotificationSubscriber();
+ NotificationSubscriber(const NotificationSubscriber &other);
+ ~NotificationSubscriber();
+
+ NotificationSubscriber &operator=(const NotificationSubscriber &other);
+
+ bool isValid() const;
+
+ QByteArray subscriber() const;
+ void setSubscriber(const QByteArray &subscriber);
+
+ QByteArray sessionId() const;
+ void setSessionId(const QByteArray &sessionId);
+
+ QSet<qint64> monitoredCollections() const;
+ void setMonitoredCollections(const QSet<qint64> &collections);
+
+ QSet<qint64> monitoredItems() const;
+ void setMonitoredItems(const QSet<qint64> &items);
+
+ QSet<qint64> monitoredTags() const;
+ void setMonitoredTags(const QSet<qint64> &tags);
+
+ QSet<Monitor::Type> monitoredTypes() const;
+ void setMonitoredTypes(const QSet<Monitor::Type> &type);
+
+ QSet<QString> monitoredMimeTypes() const;
+ void setMonitoredMimeTypes(const QSet<QString> &mimeTypes);
+
+ QSet<QByteArray> monitoredResources() const;
+ void setMonitoredResources(const QSet<QByteArray> &resources);
+
+ QSet<QByteArray> ignoredSessions() const;
+ void setIgnoredSessions(const QSet<QByteArray> &ignoredSessions);
+
+ bool isAllMonitored() const;
+ void setIsAllMonitored(bool isAllMonitored);
+
+ bool isExclusive() const;
+ void setIsExclusive(bool isExclusive);
+
+private:
+ class Private;
+ QSharedDataPointer<Private> d;
+};
+
+}
+#endif
diff --git a/src/core/subscriptionmonitor.cpp b/src/core/subscriptionmonitor.cpp
deleted file mode 100644
index 5b0bb84..0000000
--- a/src/core/subscriptionmonitor.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- Copyright (c) 2016 Daniel Vrátil <dvratil@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-*/
-
-#include "subscriptionmonitor.h"
-#include "monitor_p.h"
-
-using namespace Akonadi;
-
-namespace Akonadi
-{
-
-class SubscriberPrivate : public QSharedData
-{
-public:
- SubscriberPrivate()
- : QSharedData()
- , allMonitored(false)
- , isExclusive(false)
- {}
-
- SubscriberPrivate(const SubscriberPrivate &other)
- : QSharedData(other)
- , name(other.name)
- , sessionId(other.sessionId)
- , collections(other.collections)
- , items(other.items)
- , tags(other.tags)
- , types(other.types)
- , mimeTypes(other.mimeTypes)
- , resources(other.resources)
- , ignoredSessions(other.ignoredSessions)
- , allMonitored(other.allMonitored)
- , isExclusive(other.isExclusive)
- {}
-
- QByteArray name;
- QByteArray sessionId;
- QSet<Collection::Id> collections;
- QSet<Item::Id> items;
- QSet<Tag::Id> tags;
- QSet<Subscriber::Type> types;
- QSet<QString> mimeTypes;
- QSet<QByteArray> resources;
- QSet<QByteArray> ignoredSessions;
- bool allMonitored;
- bool isExclusive;
-};
-
-class SubscriptionMonitorPrivate : public MonitorPrivate
-{
-public:
- SubscriptionMonitorPrivate(SubscriptionMonitor *qq)
- : MonitorPrivate(Q_NULLPTR, qq)
- {
- pendingModification.startMonitoringType(Protocol::ModifySubscriptionCommand::SubscriptionChanges);
- }
-
- void slotNotify(const Protocol::ChangeNotification &msg) Q_DECL_OVERRIDE
- {
- if (msg.type() == Protocol::Command::SubscriptionChangeNotification) {
- emitSubscriptionNotification(msg);
- } else {
- MonitorPrivate::slotNotify(msg);
- }
- }
-
- void emitSubscriptionNotification(const Protocol::SubscriptionChangeNotification &msg)
- {
- Q_Q(SubscriptionMonitor);
-
- Subscriber subscriber;
- subscriber.d->name = msg.subscriber();
- if (!msg.isRemove()) {
- // NOTE: I have slightly over-designed the change notifications to
- // have the "added" and "removed" API without realizing we don't really
- // need that in the client API. The server does not use the "removed"
- // API either but if we need that in the future, we can easily change
- // it to use it (i.e. to send incremental changes rather than current
- // full state of subscription) and adjust the signal APIs in this class
- subscriber.d->sessionId = msg.sessionId();
- subscriber.d->collections = msg.addedCollections();
- subscriber.d->items = msg.addedItems();
- subscriber.d->tags = msg.addedTags();
- Q_FOREACH (Protocol::ModifySubscriptionCommand::ChangeType type, msg.addedTypes()) {
- subscriber.d->types.insert(static_cast<Subscriber::Type>(type));
- }
- subscriber.d->mimeTypes = msg.addedMimeTypes();
- subscriber.d->resources = msg.addedResources();
- subscriber.d->ignoredSessions = msg.addedIgnoredSessions();
- subscriber.d->allMonitored = msg.isAllMonitored();
- subscriber.d->isExclusive = msg.isExclusive();
- }
-
- switch (msg.operation()) {
- case Protocol::SubscriptionChangeNotification::Add:
- Q_EMIT q->subscriptionAdded(subscriber);
- break;
- case Protocol::SubscriptionChangeNotification::Modify:
- Q_EMIT q->subscriptionChanged(subscriber);
- break;
- case Protocol::SubscriptionChangeNotification::Remove:
- Q_EMIT q->subscriptionRemoved(subscriber.name());
- break;
- default:
- Q_ASSERT_X(false, __FUNCTION__, "Unknown operation type");
- break;
- }
- }
-
-private:
- Q_DECLARE_PUBLIC(SubscriptionMonitor)
-};
-
-}
-
-Subscriber::Subscriber()
- : d(new SubscriberPrivate)
-{
-}
-
-Subscriber::Subscriber(const Subscriber &other)
- : d(other.d)
-{
-}
-
-Subscriber::~Subscriber()
-{
-}
-
-Subscriber &Subscriber::operator=(const Subscriber &other)
-{
- if (*this == other) {
- return *this;
- }
- d = other.d;
- return *this;
-}
-
-bool Subscriber::operator==(const Subscriber &other) const
-{
- return d->name == other.d->name
- && d->sessionId == other.d->sessionId
- && d->collections == other.d->collections
- && d->items == other.d->items
- && d->tags == other.d->tags
- && d->types == other.d->types
- && d->mimeTypes == other.d->mimeTypes
- && d->resources == other.d->resources
- && d->ignoredSessions == other.d->ignoredSessions
- && d->allMonitored == other.d->allMonitored
- && d->isExclusive == other.d->isExclusive;
-}
-
-QByteArray Subscriber::name() const
-{
- return d->name;
-}
-
-QByteArray Subscriber::sessionId() const
-{
- return d->sessionId;
-}
-
-QSet<Collection::Id> Subscriber::monitoredCollections() const
-{
- return d->collections;
-}
-
-QSet<Item::Id> Subscriber::monitoredItems() const
-{
- return d->items;
-}
-
-QSet<Tag::Id> Subscriber::monitoredTags() const
-{
- return d->tags;
-}
-
-QSet<Subscriber::Type> Subscriber::monitoredTypes() const
-{
- return d->types;
-}
-
-QSet<QString> Subscriber::monitoredMimeTypes() const
-{
- return d->mimeTypes;
-}
-
-QSet<QByteArray> Subscriber::monitoredResources() const
-{
- return d->resources;
-}
-
-QSet<QByteArray> Subscriber::ignoredSessions() const
-{
- return d->ignoredSessions;
-}
-
-bool Subscriber::monitorsAll() const
-{
- return d->allMonitored;
-}
-
-bool Subscriber::isExclusive() const
-{
- return d->isExclusive;
-}
-
-
-
-
-SubscriptionMonitor::SubscriptionMonitor(QObject *parent)
- : Monitor(new SubscriptionMonitorPrivate(this), parent)
-{
-}
-
-SubscriptionMonitor::~SubscriptionMonitor()
-{
-}
-
-void SubscriptionMonitor::setSession(Akonadi::Session *session)
-{
- Monitor::setSession(session);
-}
-
-Session *SubscriptionMonitor::session() const
-{
- return Monitor::session();
-}
-
-
diff --git a/src/core/subscriptionmonitor.h b/src/core/subscriptionmonitor.h
deleted file mode 100644
index 525977f..0000000
--- a/src/core/subscriptionmonitor.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- Copyright (c) 2016 Daniel Vrátil <dvratil@kde.org>
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This library 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 Library General Public
- License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-*/
-
-#ifndef AKONADI_SUBSCRIPTIONMONITOR
-#define AKONADI_SUBSCRIPTIONMONITOR
-
-#include "monitor.h"
-#include "akonadicore_export.h"
-
-
-namespace Akonadi
-{
-
-class SubscriptionMonitorPrivate;
-class SubscriberPrivate;
-class AKONADICORE_EXPORT Subscriber
-{
-public:
- enum Type {
- InvalidType,
- Collection,
- Item,
- Tag,
- Relation,
- Subscription
- };
-
- explicit Subscriber();
- Subscriber(const Subscriber &other);
- ~Subscriber();
-
- Subscriber &operator=(const Subscriber &other);
- bool operator==(const Subscriber &other) const;
-
- QByteArray name() const;
- QByteArray sessionId() const;
-
- QSet<Collection::Id> monitoredCollections() const;
- QSet<Item::Id> monitoredItems() const;
- QSet<Tag::Id> monitoredTags() const;
- QSet<Type> monitoredTypes() const;
- QSet<QString> monitoredMimeTypes() const;
- QSet<QByteArray> monitoredResources() const;
- QSet<QByteArray> ignoredSessions() const;
- bool monitorsAll() const;
- bool isExclusive() const;
-
-private:
- QSharedDataPointer<SubscriberPrivate> d;
-
- friend class SubscriptionMonitorPrivate;
-};
-
-class SubscriptionMonitorPrivate;
-/**
- * @short Monitors change notification subscription changes
- *
- * The SubscriptionMonitor is a specialized Monitor which monitors only for
- * changes in notification subscriptions.
- *
- * This class is only useful for developer tools like Akonadi Console which
- * want to show and introspect the notification system and should not ever be
- * user in normal applications.
- *
- * @since 16.04
- */
-class AKONADICORE_EXPORT SubscriptionMonitor : protected Monitor
-{
- Q_OBJECT
-
-public:
- explicit SubscriptionMonitor(QObject *parent = Q_NULLPTR);
-
- ~SubscriptionMonitor();
-
- void setSession(Session *session);
-
- Session *session() const;
-
-Q_SIGNALS:
- /**
- * This signal is emitted when a new Monitor subscribes to notifications.
- * Once this monitor is set up and registered to Akonadi it will also be
- * emitted once for each existing subscriber so that applications can
- * initially populate their list of subscribers.
- */
- void subscriptionAdded(const Subscriber &subscription);
-
- /**
- * This signal is emitted when an existing subscriber changes its subscription
- * settings.
- */
- void subscriptionChanged(const Subscriber &subscription);
-
- /**
- * This signal is emitted when an existing subscriber unsubscribes from the
- * server, i.e. when a Monitor is destroyed.
- */
- void subscriptionRemoved(const QByteArray &subscriber);
-
-private:
- friend class SubscriptionMonitorPrivate;
-};
-
-}
-
-#endif
diff --git a/src/private/protocol.cpp b/src/private/protocol.cpp
index 0ef7f2e..7b18586 100644
--- a/src/private/protocol.cpp
+++ b/src/private/protocol.cpp
@@ -49,7 +49,7 @@ namespace Akonadi {
namespace Protocol {
int version() {
- return 53;
+ return 54;
}
}
@@ -569,6 +569,7 @@ public:
registerType<Command::CollectionChangeNotification, CollectionChangeNotification, Response /* invalid */>();
registerType<Command::TagChangeNotification, TagChangeNotification, Response /* invalid */>();
registerType<Command::RelationChangeNotification, RelationChangeNotification, Response /* invalid */>();
+ registerType<Command::SubscriptionChangeNotification, SubscriptionChangeNotification, Response /* invalid */>();
registerType<Command::CreateSubscription, CreateSubscriptionCommand, CreateSubscriptionResponse>();
registerType<Command::ModifySubscription, ModifySubscriptionCommand, ModifySubscriptionResponse>();
}
@@ -9863,7 +9864,6 @@ class SubscriptionChangeNotificationPrivate : public ChangeNotificationPrivate
public:
SubscriptionChangeNotificationPrivate()
: ChangeNotificationPrivate(Command::SubscriptionChangeNotification)
- , modifiedParts(SubscriptionChangeNotification::None)
, operation(SubscriptionChangeNotification::InvalidOp)
, isAllMonitored(false)
, isExclusive(false)
@@ -9872,21 +9872,13 @@ public:
SubscriptionChangeNotificationPrivate(const SubscriptionChangeNotificationPrivate &other)
: ChangeNotificationPrivate(other)
, subscriber(other.subscriber)
- , addedCollections(other.addedCollections)
- , removedCollections(other.removedCollections)
- , addedItems(other.addedItems)
- , removedItems(other.removedItems)
- , addedTags(other.addedTags)
- , removedTags(other.removedTags)
- , addedTypes(other.addedTypes)
- , removedTypes(other.removedTypes)
- , addedMimeTypes(other.addedMimeTypes)
- , removedMimeTypes(other.removedMimeTypes)
- , addedResources(other.addedResources)
- , removedResources(other.removedResources)
- , addedIgnoredSessions(other.addedIgnoredSessions)
- , removedIgnoredSessions(other.removedIgnoredSessions)
- , modifiedParts(other.modifiedParts)
+ , collections(other.collections)
+ , items(other.items)
+ , tags(other.tags)
+ , types(other.types)
+ , mimeTypes(other.mimeTypes)
+ , resources(other.resources)
+ , ignoredSessions(other.ignoredSessions)
, operation(other.operation)
, isAllMonitored(other.isAllMonitored)
, isExclusive(other.isExclusive)
@@ -9895,23 +9887,15 @@ public:
bool compare(const CommandPrivate *other) const Q_DECL_OVERRIDE
{
return ChangeNotificationPrivate::compare(other)
- && COMPARE(modifiedParts)
&& COMPARE(operation)
&& COMPARE(subscriber)
- && COMPARE(addedCollections)
- && COMPARE(removedCollections)
- && COMPARE(addedItems)
- && COMPARE(removedItems)
- && COMPARE(addedTags)
- && COMPARE(removedTags)
- && COMPARE(addedTypes)
- && COMPARE(removedTypes)
- && COMPARE(addedMimeTypes)
- && COMPARE(removedMimeTypes)
- && COMPARE(addedResources)
- && COMPARE(removedResources)
- && COMPARE(addedIgnoredSessions)
- && COMPARE(removedIgnoredSessions)
+ && COMPARE(collections)
+ && COMPARE(items)
+ && COMPARE(tags)
+ && COMPARE(types)
+ && COMPARE(mimeTypes)
+ && COMPARE(resources)
+ && COMPARE(ignoredSessions)
&& COMPARE(isAllMonitored)
&& COMPARE(isExclusive);
}
@@ -9921,41 +9905,15 @@ public:
ChangeNotificationPrivate::debugString(blck);
blck.write("Subscriber", subscriber);
blck.write("Operation", operation);
- blck.write("Modified parts", modifiedParts);
- if (modifiedParts & SubscriptionChangeNotification::Collections) {
- blck.write("Added cols", addedCollections);
- blck.write("Removed cols", removedCollections);
- }
- if (modifiedParts & SubscriptionChangeNotification::Items) {
- blck.write("Added items", addedItems);
- blck.write("Removed items", removedItems);
- }
- if (modifiedParts & SubscriptionChangeNotification::Tags) {
- blck.write("Added tags", addedTags);
- blck.write("Removed tags", removedTags);
- }
- if (modifiedParts & SubscriptionChangeNotification::Types) {
- blck.write("Added types", addedTypes);
- blck.write("Removed types", removedTypes);
- }
- if (modifiedParts & SubscriptionChangeNotification::MimeTypes) {
- blck.write("Added mimetypes", addedMimeTypes);
- blck.write("Removed mimetypes", removedMimeTypes);
- }
- if (modifiedParts & SubscriptionChangeNotification::Resources) {
- blck.write("Added resources", addedResources);
- blck.write("Removed resources", removedResources);
- }
- if (modifiedParts & SubscriptionChangeNotification::IgnoredSessions) {
- blck.write("Added ignored sessions", addedIgnoredSessions);
- blck.write("Removed ignored sessions", removedIgnoredSessions);
- }
- if (modifiedParts & SubscriptionChangeNotification::Monitored) {
- blck.write("All monitored", isAllMonitored);
- }
- if (modifiedParts & SubscriptionChangeNotification::Exclusive) {
- blck.write("Is exclusive", isExclusive);
- }
+ blck.write("Collections", collections);
+ blck.write("Items", items);
+ blck.write("Tags", tags);
+ blck.write("Types", types);
+ blck.write("Mime types", mimeTypes);
+ blck.write("Resources", resources);
+ blck.write("Ignored sessions", ignoredSessions);
+ blck.write("All monitored", isAllMonitored);
+ blck.write("Is exclusive", isExclusive);
}
DataStream &serialize(DataStream &stream) const Q_DECL_OVERRIDE
@@ -9963,41 +9921,15 @@ public:
ChangeNotificationPrivate::serialize(stream)
<< subscriber
<< operation
- << modifiedParts;
- if (modifiedParts & SubscriptionChangeNotification::Collections) {
- stream << addedCollections
- << removedCollections;
- }
- if (modifiedParts & SubscriptionChangeNotification::Items) {
- stream << addedItems
- << removedItems;
- }
- if (modifiedParts & SubscriptionChangeNotification::Tags) {
- stream << addedTags
- << removedTags;
- }
- if (modifiedParts & SubscriptionChangeNotification::Types) {
- stream << addedTypes
- << removedTypes;
- }
- if (modifiedParts & SubscriptionChangeNotification::MimeTypes) {
- stream << addedMimeTypes
- << removedMimeTypes;
- }
- if (modifiedParts & SubscriptionChangeNotification::Resources) {
- stream << addedResources
- << removedResources;
- }
- if (modifiedParts & SubscriptionChangeNotification::IgnoredSessions) {
- stream << addedIgnoredSessions
- << removedIgnoredSessions;
- }
- if (modifiedParts & SubscriptionChangeNotification::Monitored) {
- stream << isAllMonitored;
- }
- if (modifiedParts & SubscriptionChangeNotification::Exclusive) {
- stream << isExclusive;
- }
+ << collections
+ << items
+ << tags
+ << types
+ << mimeTypes
+ << resources
+ << ignoredSessions
+ << isAllMonitored
+ << isExclusive;
return stream;
}
@@ -10006,41 +9938,15 @@ public:
ChangeNotificationPrivate::deserialize(stream)
>> subscriber
>> operation
- >> modifiedParts;
- if (modifiedParts & SubscriptionChangeNotification::Collections) {
- stream >> addedCollections
- >> removedCollections;
- }
- if (modifiedParts & SubscriptionChangeNotification::Items) {
- stream >> addedItems
- >> removedItems;
- }
- if (modifiedParts & SubscriptionChangeNotification::Tags) {
- stream >> addedTags
- >> removedTags;
- }
- if (modifiedParts & SubscriptionChangeNotification::Types) {
- stream >> addedTypes
- >> removedTypes;
- }
- if (modifiedParts & SubscriptionChangeNotification::MimeTypes) {
- stream >> addedMimeTypes
- >> removedMimeTypes;
- }
- if (modifiedParts & SubscriptionChangeNotification::Resources) {
- stream >> addedResources
- >> removedResources;
- }
- if (modifiedParts & SubscriptionChangeNotification::IgnoredSessions) {
- stream >> addedIgnoredSessions
- >> removedIgnoredSessions;
- }
- if (modifiedParts & SubscriptionChangeNotification::Monitored) {
- stream >> isAllMonitored;
- }
- if (modifiedParts & SubscriptionChangeNotification::Exclusive) {
- stream >> isExclusive;
- }
+ >> collections
+ >> items
+ >> tags
+ >> types
+ >> mimeTypes
+ >> resources
+ >> ignoredSessions
+ >> isAllMonitored
+ >> isExclusive;
return stream;
}
@@ -10050,21 +9956,13 @@ public:
}
QByteArray subscriber;
- QSet<ChangeNotification::Id> addedCollections;
- QSet<ChangeNotification::Id> removedCollections;
- QSet<ChangeNotification::Id> addedItems;
- QSet<ChangeNotification::Id> removedItems;
- QSet<ChangeNotification::Id> addedTags;
- QSet<ChangeNotification::Id> removedTags;
- QSet<ModifySubscriptionCommand::ChangeType> addedTypes;
- QSet<ModifySubscriptionCommand::ChangeType> removedTypes;
- QSet<QString> addedMimeTypes;
- QSet<QString> removedMimeTypes;
- QSet<QByteArray> addedResources;
- QSet<QByteArray> removedResources;
- QSet<QByteArray> addedIgnoredSessions;
- QSet<QByteArray> removedIgnoredSessions;
- SubscriptionChangeNotification::ModifiedParts modifiedParts;
+ QSet<ChangeNotification::Id> collections;
+ QSet<ChangeNotification::Id> items;
+ QSet<ChangeNotification::Id> tags;
+ QSet<ModifySubscriptionCommand::ChangeType> types;
+ QSet<QString> mimeTypes;
+ QSet<QByteArray> resources;
+ QSet<QByteArray> ignoredSessions;
SubscriptionChangeNotification::Operation operation;
bool isAllMonitored;
bool isExclusive;
@@ -10093,11 +9991,6 @@ void SubscriptionChangeNotification::setOperation(Operation operation)
d_func()->operation = operation;
}
-SubscriptionChangeNotification::ModifiedParts SubscriptionChangeNotification::modifiedParts() const
-{
- return d_func()->modifiedParts;
-}
-
QByteArray SubscriptionChangeNotification::subscriber() const
{
return d_func()->subscriber;
@@ -10108,158 +10001,74 @@ void SubscriptionChangeNotification::setSubscriber(const QByteArray &subscriber)
d_func()->subscriber = subscriber;
}
-QSet<ChangeNotification::Id> SubscriptionChangeNotification::addedCollections() const
-{
- return d_func()->addedCollections;
-}
-
-void SubscriptionChangeNotification::setAddedCollections(const QSet<Id> &addedCols)
+QSet<ChangeNotification::Id> SubscriptionChangeNotification::collections() const
{
- d_func()->addedCollections = addedCols;
- d_func()->modifiedParts |= Collections;
-}
-
-QSet<ChangeNotification::Id> SubscriptionChangeNotification::removedCollections() const
-{
- return d_func()->removedCollections;
-}
-
-void SubscriptionChangeNotification::setRemovedCollections(const QSet<Id> &removedCols)
-{
- d_func()->removedCollections = removedCols;
- d_func()->modifiedParts|= Collections;
-}
-
-QSet<ChangeNotification::Id> SubscriptionChangeNotification::addedItems() const
-{
- return d_func()->addedItems;
-}
-
-void SubscriptionChangeNotification::setAddedItems(const QSet<Id> &addedItems)
-{
- d_func()->addedItems = addedItems;
- d_func()->modifiedParts |= Items;
-}
-
-QSet<ChangeNotification::Id> SubscriptionChangeNotification::removedItems() const
-{
- return d_func()->removedItems;
-}
-
-void SubscriptionChangeNotification::setRemovedItems(const QSet<Id> &removedItems)
-{
- d_func()->removedItems = removedItems;
- d_func()->modifiedParts |= Items;
-}
-
-QSet<ChangeNotification::Id> SubscriptionChangeNotification::addedTags() const
-{
- return d_func()->addedTags;
-}
-
-void SubscriptionChangeNotification::setAddedTags(const QSet<Id> &addedTags)
-{
- d_func()->addedTags = addedTags;
- d_func()->modifiedParts |= Tags;
-}
-
-QSet<ChangeNotification::Id> SubscriptionChangeNotification::removedTags() const
-{
- return d_func()->removedTags;
-}
-
-void SubscriptionChangeNotification::setRemovedTags(const QSet<Id> &removedTags)
-{
- d_func()->removedTags = removedTags;
- d_func()->modifiedParts |= Tags;
-}
-
-QSet<ModifySubscriptionCommand::ChangeType> SubscriptionChangeNotification::addedTypes() const
-{
- return d_func()->addedTypes;
-}
-
-void SubscriptionChangeNotification::setAddedTypes(const QSet<ModifySubscriptionCommand::ChangeType> &addedTypes)
-{
- d_func()->addedTypes = addedTypes;
- d_func()->modifiedParts |= Types;
-}
-
-QSet<ModifySubscriptionCommand::ChangeType> SubscriptionChangeNotification::removedTypes() const
-{
- return d_func()->removedTypes;
+ return d_func()->collections;
}
-void SubscriptionChangeNotification::setRemovedTypes(const QSet<ModifySubscriptionCommand::ChangeType> &removedTypes)
+void SubscriptionChangeNotification::setCollections(const QSet<Id> &cols)
{
- d_func()->removedTypes = removedTypes;
- d_func()->modifiedParts |= Types;
+ d_func()->collections = cols;
}
-QSet<QString> SubscriptionChangeNotification::addedMimeTypes() const
+QSet<ChangeNotification::Id> SubscriptionChangeNotification::items() const
{
- return d_func()->addedMimeTypes;
+ return d_func()->items;
}
-void SubscriptionChangeNotification::setAddedMimeTypes(const QSet<QString> &addedMt)
+void SubscriptionChangeNotification::setItems(const QSet<Id> &items)
{
- d_func()->addedMimeTypes = addedMt;
- d_func()->modifiedParts |= MimeTypes;
+ d_func()->items = items;
}
-QSet<QString> SubscriptionChangeNotification::removedMimeTypes() const
+QSet<ChangeNotification::Id> SubscriptionChangeNotification::tags() const
{
- return d_func()->removedMimeTypes;
+ return d_func()->tags;
}
-void SubscriptionChangeNotification::setRemovedMimeTypes(const QSet<QString> &removedMt)
+void SubscriptionChangeNotification::setTags(const QSet<Id> &tags)
{
- d_func()->removedMimeTypes = removedMt;
- d_func()->modifiedParts |= MimeTypes;
+ d_func()->tags = tags;
}
-QSet<QByteArray> SubscriptionChangeNotification::addedResources() const
+QSet<ModifySubscriptionCommand::ChangeType> SubscriptionChangeNotification::types() const
{
- return d_func()->addedResources;
+ return d_func()->types;
}
-void SubscriptionChangeNotification::setAddedResources(const QSet<QByteArray> &addedRes)
+void SubscriptionChangeNotification::setTypes(const QSet<ModifySubscriptionCommand::ChangeType> &types)
{
- d_func()->addedResources = addedRes;
- d_func()->modifiedParts |= Resources;
+ d_func()->types = types;
}
-QSet<QByteArray> SubscriptionChangeNotification::removedResources() const
+QSet<QString> SubscriptionChangeNotification::mimeTypes() const
{
- return d_func()->removedResources;
+ return d_func()->mimeTypes;
}
-void SubscriptionChangeNotification::setRemovedResources(const QSet<QByteArray> &removedRes)
+void SubscriptionChangeNotification::setMimeTypes(const QSet<QString> &mimetypes)
{
- d_func()->removedResources = removedRes;
- d_func()->modifiedParts |= Resources;
+ d_func()->mimeTypes = mimetypes;
}
-QSet<QByteArray> SubscriptionChangeNotification::addedIgnoredSessions() const
+QSet<QByteArray> SubscriptionChangeNotification::resources() const
{
- return d_func()->addedIgnoredSessions;
+ return d_func()->resources;
}
-void SubscriptionChangeNotification::setAddedIgnoredSessions(const QSet<QByteArray> &addedSessions)
+void SubscriptionChangeNotification::setResources(const QSet<QByteArray> &resources)
{
- d_func()->addedIgnoredSessions = addedSessions;
- d_func()->modifiedParts |= IgnoredSessions;
+ d_func()->resources = resources;
}
-QSet<QByteArray> SubscriptionChangeNotification::removedIgnoredSessions() const
+QSet<QByteArray> SubscriptionChangeNotification::ignoredSessions() const
{
- return d_func()->removedIgnoredSessions;
+ return d_func()->ignoredSessions;
}
-void SubscriptionChangeNotification::setRemovedIgnoredSessions(const QSet<QByteArray> &removedSessions)
+void SubscriptionChangeNotification::setIgnoredSessions(const QSet<QByteArray> &sessions)
{
- d_func()->removedIgnoredSessions = removedSessions;
- d_func()->modifiedParts |= IgnoredSessions;
+ d_func()->ignoredSessions = sessions;
}
bool SubscriptionChangeNotification::isAllMonitored() const
@@ -10270,7 +10079,6 @@ bool SubscriptionChangeNotification::isAllMonitored() const
void SubscriptionChangeNotification::setAllMonitored(bool allMonitored)
{
d_func()->isAllMonitored = allMonitored;
- d_func()->modifiedParts |= Monitored;
}
bool SubscriptionChangeNotification::isExclusive() const
@@ -10281,7 +10089,6 @@ bool SubscriptionChangeNotification::isExclusive() const
void SubscriptionChangeNotification::setExclusive(bool isExclusive)
{
d_func()->isExclusive = isExclusive;
- d_func()->modifiedParts |= Exclusive;
}
DataStream &operator<<(DataStream &stream, const SubscriptionChangeNotification &ntf)
diff --git a/src/private/protocol_p.h b/src/private/protocol_p.h
index 9f719cf..5ff064e 100644
--- a/src/private/protocol_p.h
+++ b/src/private/protocol_p.h
@@ -2472,65 +2472,35 @@ public:
Remove
};
- enum ModifiedPart {
- None = 0,
- Collections = 1 << 0,
- Items = 1 << 1,
- Tags = 1 << 2,
- Types = 1 << 3,
- MimeTypes = 1 << 4,
- Resources = 1 << 5,
- IgnoredSessions = 1 << 6,
- Monitored = 1 << 7,
- Exclusive = 1 << 8
- };
- Q_DECLARE_FLAGS(ModifiedParts, ModifiedPart)
-
explicit SubscriptionChangeNotification();
SubscriptionChangeNotification(const Command &other);
Operation operation() const;
void setOperation(Operation operation);
- ModifiedParts modifiedParts() const;
-
QByteArray subscriber() const;
void setSubscriber(const QByteArray &subscriber);
- QSet<Id> addedCollections() const;
- void setAddedCollections(const QSet<Id> &addedCols);
- QSet<Id> removedCollections() const;
- void setRemovedCollections(const QSet<Id> &removedCols);
-
- QSet<Id> addedItems() const;
- void setAddedItems(const QSet<Id> &addedItems);
- QSet<Id> removedItems() const;
- void setRemovedItems(const QSet<Id> &removedItems);
-
- QSet<Id> addedTags() const;
- void setAddedTags(const QSet<Id> &addedTags);
- QSet<Id> removedTags() const;
- void setRemovedTags(const QSet<Id> &removedTags);
-
- QSet<ModifySubscriptionCommand::ChangeType> addedTypes() const;
- void setAddedTypes(const QSet<ModifySubscriptionCommand::ChangeType> &addedTypes);
- QSet<ModifySubscriptionCommand::ChangeType> removedTypes() const;
- void setRemovedTypes(const QSet<ModifySubscriptionCommand::ChangeType> &removedTypes);
-
- QSet<QString> addedMimeTypes() const;
- void setAddedMimeTypes(const QSet<QString> &addedMimeTypes);
- QSet<QString> removedMimeTypes() const;
- void setRemovedMimeTypes(const QSet<QString> &removedMimeTypes);
-
- QSet<QByteArray> addedResources() const;
- void setAddedResources(const QSet<QByteArray> &addedResources);
- QSet<QByteArray> removedResources() const;
- void setRemovedResources(const QSet<QByteArray> &removedResouces);
-
- QSet<QByteArray> addedIgnoredSessions() const;
- void setAddedIgnoredSessions(const QSet<QByteArray> &ignoredSessions);
- QSet<QByteArray> removedIgnoredSessions() const;
- void setRemovedIgnoredSessions(const QSet<QByteArray> &ignoredSessions);
+ QSet<Id> collections() const;
+ void setCollections(const QSet<Id> &cols);
+
+ QSet<Id> items() const;
+ void setItems(const QSet<Id> &items);
+
+ QSet<Id> tags() const;
+ void setTags(const QSet<Id> &tags);
+
+ QSet<ModifySubscriptionCommand::ChangeType> types() const;
+ void setTypes(const QSet<ModifySubscriptionCommand::ChangeType> &types);
+
+ QSet<QString> mimeTypes() const;
+ void setMimeTypes(const QSet<QString> &mimeTypes);
+
+ QSet<QByteArray> resources() const;
+ void setResources(const QSet<QByteArray> &resources);
+
+ QSet<QByteArray> ignoredSessions() const;
+ void setIgnoredSessions(const QSet<QByteArray> &ignoredSessions);
bool isAllMonitored() const;
void setAllMonitored(bool allMonitored);
diff --git a/src/server/notificationsubscriber.cpp b/src/server/notificationsubscriber.cpp
index 376d5c3..95247b6 100644
--- a/src/server/notificationsubscriber.cpp
+++ b/src/server/notificationsubscriber.cpp
@@ -235,12 +235,15 @@ void NotificationSubscriber::modifySubscription(const Protocol::ModifySubscripti
&& command.startMonitoringTypes().contains(Protocol::ModifySubscriptionCommand::SubscriptionChanges))
{
// If yes, then send them list of all existing subscribers
+ qDebug() << "========" << mSubscriber << "monitors subscriptions, will get" << mManager->mSubscribers.count() << "of them!";
Protocol::ChangeNotification::List ntfs;
+ ntfs.reserve(mManager->mSubscribers.count());
Q_FOREACH (const NotificationSubscriber *subscriber, mManager->mSubscribers) {
ntfs << subscriber->toChangeNotification();
}
// Send them back to caller
- notify(ntfs);
+ QMetaObject::invokeMethod(this, "notify", Qt::QueuedConnection,
+ Q_ARG(Akonadi::Protocol::ChangeNotification::List, ntfs));
}
// Emit subscription change notification
@@ -258,13 +261,13 @@ Protocol::ChangeNotification NotificationSubscriber::toChangeNotification() cons
ntf.setSessionId(mSession);
ntf.setSubscriber(mSubscriber);
ntf.setOperation(Protocol::SubscriptionChangeNotification::Add);
- ntf.setAddedCollections(mMonitoredCollections);
- ntf.setAddedItems(mMonitoredItems);
- ntf.setAddedTags(mMonitoredTags);
- ntf.setAddedTypes(mMonitoredTypes);
- ntf.setAddedMimeTypes(mMonitoredMimeTypes);
- ntf.setAddedResources(mMonitoredResources);
- ntf.setAddedIgnoredSessions(mIgnoredSessions);
+ ntf.setCollections(mMonitoredCollections);
+ ntf.setItems(mMonitoredItems);
+ ntf.setTags(mMonitoredTags);
+ ntf.setTypes(mMonitoredTypes);
+ ntf.setMimeTypes(mMonitoredMimeTypes);
+ ntf.setResources(mMonitoredResources);
+ ntf.setIgnoredSessions(mIgnoredSessions);
ntf.setAllMonitored(mAllMonitored);
ntf.setExclusive(mExclusive);
return ntf;
diff --git a/src/server/notificationsubscriber.h b/src/server/notificationsubscriber.h
index 2e3af8e..ed7b407 100644
--- a/src/server/notificationsubscriber.h
+++ b/src/server/notificationsubscriber.h
@@ -43,7 +43,8 @@ public:
explicit NotificationSubscriber(NotificationManager *manager, quintptr socketDescriptor);
~NotificationSubscriber();
- void notify(const Protocol::ChangeNotification::List &notifications);
+public Q_SLOTS:
+ void notify(const Akonadi::Protocol::ChangeNotification::List &notifications);
private Q_SLOTS:
void socketReadyRead();