Commit 1d97d083 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

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.
parent 1eae329d
......@@ -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;
}
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment