aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-03-23 00:48:43 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-08-15 20:01:12 (GMT)
commit65d246031bc4bc47e74ff6d176552feaa5917b55 (patch)
treeec2a0e3eef81adc7fe8c3285c356bf608b56c57b
parent4a3d8d206c2a6b0032fba8793569b6e721fc757a (diff)
Reject notifications in uninitialized NotificationSubscriber
Wait until client identify itself before sending it notifications.
-rw-r--r--autotests/server/notificationmanagertest.cpp1
-rw-r--r--src/server/notificationsubscriber.cpp8
2 files changed, 8 insertions, 1 deletions
diff --git a/autotests/server/notificationmanagertest.cpp b/autotests/server/notificationmanagertest.cpp
index f694147..dc5a5c9 100644
--- a/autotests/server/notificationmanagertest.cpp
+++ b/autotests/server/notificationmanagertest.cpp
@@ -39,6 +39,7 @@ public:
TestableNotificationSubscriber()
: NotificationSubscriber()
{
+ mSubscriber = "TestSubscriber";
}
void setAllMonitored(bool allMonitored)
diff --git a/src/server/notificationsubscriber.cpp b/src/server/notificationsubscriber.cpp
index c21a4f7..5317280 100644
--- a/src/server/notificationsubscriber.cpp
+++ b/src/server/notificationsubscriber.cpp
@@ -140,7 +140,7 @@ void NotificationSubscriber::disconnectSubscriber()
void NotificationSubscriber::registerSubscriber(const Protocol::CreateSubscriptionCommand &command)
{
- qDebug() << "Subscriber identified:" << command.subscriberName();
+ qDebug() << "Subscriber" << this << "identified as" << command.subscriberName();
mSubscriber = command.subscriberName();
if (mManager) {
@@ -307,6 +307,7 @@ bool NotificationSubscriber::isMoveDestinationResourceMonitored(const Protocol::
return mMonitoredResources.contains(msg.destinationResource());
}
+
bool NotificationSubscriber::acceptsItemNotification(const Protocol::ItemChangeNotification &notification) const
{
if (notification.items().count() == 0) {
@@ -514,6 +515,11 @@ bool NotificationSubscriber::acceptsSubscriptionNotification(const Protocol::Sub
bool NotificationSubscriber::acceptsNotification(const Protocol::ChangeNotification &notification) const
{
+ // Uninitialized subscriber gets nothing
+ if (mSubscriber.isEmpty()) {
+ return false;
+ }
+
// session is ignored
if (mIgnoredSessions.contains(notification.sessionId())) {
return false;