aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-08-15 22:17:22 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-08-15 22:17:22 (GMT)
commit1d97d08337f805c95ae6060e4d04b34c1a8a18b7 (patch)
treee7f35a8ea9be3889013bf1868d24eee94ef4f3c8
parent1eae329d4e4815e0bf97771e25762807e7e1fdd2 (diff)
Upload session ID as part of RegisterSubscriberCommand
We need to have sessionID available on server side so that we can correctly resolve Collection referencing based on session when accepting/discarding notification.
-rw-r--r--src/core/monitor_p.cpp2
-rw-r--r--src/private/protocol.cpp32
-rw-r--r--src/private/protocol_p.h6
-rw-r--r--src/server/notificationsubscriber.cpp3
4 files changed, 33 insertions, 10 deletions
diff --git a/src/core/monitor_p.cpp b/src/core/monitor_p.cpp
index 50660df..d746a0b 100644
--- a/src/core/monitor_p.cpp
+++ b/src/core/monitor_p.cpp
@@ -643,7 +643,7 @@ void MonitorPrivate::commandReceived(qint64 tag, const Protocol::Command &comman
subname += QByteArray::number(quintptr(q));
}
qCDebug(AKONADICORE_LOG) << q_ptr << "Subscribing as \"" << subname << "\"";
- Protocol::CreateSubscriptionCommand subCmd(subname);
+ Protocol::CreateSubscriptionCommand subCmd(subname, session->sessionId());
ntfConnection->sendCommand(2, subCmd);
break;
}
diff --git a/src/private/protocol.cpp b/src/private/protocol.cpp
index cf841de..0ef7f2e 100644
--- a/src/private/protocol.cpp
+++ b/src/private/protocol.cpp
@@ -9254,40 +9254,47 @@ DataStream &operator>>(DataStream &stream, Akonadi::Protocol::RelationChangeNoti
class CreateSubscriptionCommandPrivate : public CommandPrivate
{
public:
- CreateSubscriptionCommandPrivate(const QByteArray &subscriberName = QByteArray())
+ CreateSubscriptionCommandPrivate(const QByteArray &subscriberName = QByteArray(),
+ const QByteArray &session = QByteArray())
: CommandPrivate(Command::CreateSubscription)
, subscriberName(subscriberName)
+ , session(session)
{}
bool compare(const CommandPrivate *other) const Q_DECL_OVERRIDE
{
return CommandPrivate::compare(other)
- && COMPARE(subscriberName);
+ && COMPARE(subscriberName)
+ && COMPARE(session);
}
void debugString(DebugBlock &blck) const Q_DECL_OVERRIDE
{
blck.write("Subscriber", subscriberName);
+ blck.write("Session", session);
}
DataStream &deserialize(DataStream &stream) Q_DECL_OVERRIDE
{
return CommandPrivate::deserialize(stream)
- >> subscriberName;
+ >> subscriberName
+ >> session;
}
DataStream &serialize(DataStream &stream) const Q_DECL_OVERRIDE
{
return CommandPrivate::serialize(stream)
- << subscriberName;
+ << subscriberName
+ << session;
}
CommandPrivate *clone() const Q_DECL_OVERRIDE
{
- return new CreateSubscriptionCommandPrivate(subscriberName);
+ return new CreateSubscriptionCommandPrivate(subscriberName, session);
}
QByteArray subscriberName;
+ QByteArray session;
};
AKONADI_DECLARE_PRIVATE(CreateSubscriptionCommand)
@@ -9297,8 +9304,9 @@ CreateSubscriptionCommand::CreateSubscriptionCommand()
{
}
-CreateSubscriptionCommand::CreateSubscriptionCommand(const QByteArray &subscriberName)
- : Command(new CreateSubscriptionCommandPrivate(subscriberName))
+CreateSubscriptionCommand::CreateSubscriptionCommand(const QByteArray &subscriberName,
+ const QByteArray &session)
+ : Command(new CreateSubscriptionCommandPrivate(subscriberName, session))
{
}
@@ -9318,6 +9326,16 @@ QByteArray CreateSubscriptionCommand::subscriberName() const
return d_func()->subscriberName;
}
+void CreateSubscriptionCommand::setSession(const QByteArray &session)
+{
+ d_func()->session = session;
+}
+
+QByteArray CreateSubscriptionCommand::session() const
+{
+ return d_func()->session;
+}
+
DataStream &operator<<(DataStream &stream, const CreateSubscriptionCommand &command)
{
return command.d_func()->serialize(stream);
diff --git a/src/private/protocol_p.h b/src/private/protocol_p.h
index 60faff1..9f719cf 100644
--- a/src/private/protocol_p.h
+++ b/src/private/protocol_p.h
@@ -2324,12 +2324,16 @@ class AKONADIPRIVATE_EXPORT CreateSubscriptionCommand : public Command
{
public:
explicit CreateSubscriptionCommand();
- explicit CreateSubscriptionCommand(const QByteArray &subscriberName);
+ explicit CreateSubscriptionCommand(const QByteArray &subscriberName,
+ const QByteArray &session);
CreateSubscriptionCommand(const Command &other);
void setSubscriberName(const QByteArray &name);
QByteArray subscriberName() const;
+ void setSession(const QByteArray &session);
+ QByteArray session() const;
+
private:
AKONADI_DECLARE_PRIVATE(CreateSubscriptionCommand)
diff --git a/src/server/notificationsubscriber.cpp b/src/server/notificationsubscriber.cpp
index 96cb384..376d5c3 100644
--- a/src/server/notificationsubscriber.cpp
+++ b/src/server/notificationsubscriber.cpp
@@ -146,6 +146,7 @@ void NotificationSubscriber::registerSubscriber(const Protocol::CreateSubscripti
qDebug() << "Subscriber" << this << "identified as" << command.subscriberName();
mSubscriber = command.subscriberName();
+ mSession = command.session();
if (mManager) {
Protocol::SubscriptionChangeNotification changeNtf;
@@ -412,7 +413,7 @@ bool NotificationSubscriber::acceptsCollectionNotification(const Protocol::Colle
//The session belonging to this monitor referenced or dereferenced the collection. We always want this notification.
//The referencemanager no longer holds a reference, so we have to check this way.
- if (notification.changedParts().contains("REFERENCED") && mSession == notification.sessionId()) {
+ if (notification.changedParts().contains(AKONADI_PARAM_REFERENCED) && mSession == notification.sessionId()) {
return true;
}