diff --git a/autotests/private/protocoltest.cpp b/autotests/private/protocoltest.cpp --- a/autotests/private/protocoltest.cpp +++ b/autotests/private/protocoltest.cpp @@ -39,7 +39,7 @@ // If it wasn't you who broke it, please go find that person who was too // lazy to extend the test case and beat them with a stick. -- Dan - QCOMPARE(Akonadi::Protocol::version(), 52); + QCOMPARE(Akonadi::Protocol::version(), 53); } void ProtocolTest::testFactory_data() diff --git a/autotests/server/relationhandlertest.cpp b/autotests/server/relationhandlertest.cpp --- a/autotests/server/relationhandlertest.cpp +++ b/autotests/server/relationhandlertest.cpp @@ -325,33 +325,33 @@ TestScenario::List scenarios; scenarios << FakeAkonadiServer::loginScenario() << TestScenario::create(5, TestScenario::ClientCmd, Protocol::FetchRelationsCommand(-1, { "type" })) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), { "type" }, "foobar1")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item4.id(), { "type" }, "foobar3")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item3.id(), { "type" }, "foobar4")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), { "type" }, "foobar1")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item3.mimeType().name().toUtf8(), item4.id(), item4.mimeType().name().toUtf8(), { "type" }, "foobar3")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item4.mimeType().name().toUtf8(), item3.id(), item3.mimeType().name().toUtf8(), { "type" }, "foobar4")) << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse()); QTest::newRow("filter by type") << scenarios; } { TestScenario::List scenarios; scenarios << FakeAkonadiServer::loginScenario() << TestScenario::create(5, TestScenario::ClientCmd, Protocol::FetchRelationsCommand()) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), { "type" }, "foobar1")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), { "type2" }, "foobar2")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item4.id(), { "type" }, "foobar3")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item3.id(), { "type" }, "foobar4")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), { "type" }, "foobar1")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), { "type2" }, "foobar2")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item3.mimeType().name().toUtf8(), item4.id(), item4.mimeType().name().toUtf8(), { "type" }, "foobar3")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item4.mimeType().name().toUtf8(), item3.id(), item3.mimeType().name().toUtf8(), { "type" }, "foobar4")) << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse()); QTest::newRow("no filter") << scenarios; } { TestScenario::List scenarios; scenarios << FakeAkonadiServer::loginScenario() << TestScenario::create(5, TestScenario::ClientCmd, Protocol::FetchRelationsCommand(-1, {}, QLatin1String("testresource"))) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), { "type" }, "foobar1")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), { "type2" }, "foobar2")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item4.id(), { "type" }, "foobar3")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item3.id(), { "type" }, "foobar4")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), { "type" }, "foobar1")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), { "type2" }, "foobar2")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item3.mimeType().name().toUtf8(), item4.id(), item4.mimeType().name().toUtf8(), { "type" }, "foobar3")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item4.mimeType().name().toUtf8(), item3.id(), item3.mimeType().name().toUtf8(), { "type" }, "foobar4")) << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse()); QTest::newRow("filter by resource with matching resource") << scenarios; @@ -373,26 +373,26 @@ TestScenario::List scenarios; scenarios << FakeAkonadiServer::loginScenario() << TestScenario::create(5, TestScenario::ClientCmd, Protocol::FetchRelationsCommand(item1.id(), -1, { "type" })) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), "type", "foobar1")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), "type", "foobar1")) << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse()); QTest::newRow("filter by left and type") << scenarios; } { TestScenario::List scenarios; scenarios << FakeAkonadiServer::loginScenario() << TestScenario::create(5, TestScenario::ClientCmd, Protocol::FetchRelationsCommand(-1, item2.id(), { "type" })) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item2.id(), "type", "foobar1")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item1.id(), item1.mimeType().name().toUtf8(), item2.id(), item2.mimeType().name().toUtf8(), "type", "foobar1")) << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse()); QTest::newRow("filter by right and type") << scenarios; } { TestScenario::List scenarios; scenarios << FakeAkonadiServer::loginScenario() << TestScenario::create(5, TestScenario::ClientCmd, Protocol::FetchRelationsCommand(item3.id(), { "type" })) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item4.id(), "type", "foobar3")) - << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item3.id(), "type", "foobar4")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item3.id(), item3.mimeType().name().toUtf8(), item4.id(), item4.mimeType().name().toUtf8(), "type", "foobar3")) + << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse(item4.id(), item4.mimeType().name().toUtf8(), item3.id(), item3.mimeType().name().toUtf8(), "type", "foobar4")) << TestScenario::create(5, TestScenario::ServerCmd, Protocol::FetchRelationsResponse()); QTest::newRow("fetch by side with typefilter") << scenarios; diff --git a/src/private/protocol.cpp b/src/private/protocol.cpp --- a/src/private/protocol.cpp +++ b/src/private/protocol.cpp @@ -49,7 +49,7 @@ namespace Protocol { int version() { - return 52; + return 53; } } @@ -2703,55 +2703,68 @@ class FetchRelationsResponsePrivate : public ResponsePrivate { public: - FetchRelationsResponsePrivate(qint64 left = -1, qint64 right = -1, + FetchRelationsResponsePrivate(qint64 left = -1, const QByteArray &leftMimeType = QByteArray(), + qint64 right = -1, const QByteArray &rightMimeType = QByteArray(), const QByteArray &type = QByteArray(), const QByteArray &remoteId = QByteArray()) : ResponsePrivate(Command::FetchRelations) , left(left) + , leftMimeType(leftMimeType) , right(right) + , rightMimeType(rightMimeType) , type(type) , remoteId(remoteId) {} FetchRelationsResponsePrivate(const FetchRelationsResponsePrivate &other) : ResponsePrivate(other) , left(other.left) + , leftMimeType(other.leftMimeType) , right(other.right) + , rightMimeType(other.rightMimeType) , type(other.type) , remoteId(other.remoteId) {} bool compare(const CommandPrivate* other) const Q_DECL_OVERRIDE { return ResponsePrivate::compare(other) && COMPARE(left) + && COMPARE(leftMimeType) && COMPARE(right) + && COMPARE(rightMimeType) && COMPARE(type) && COMPARE(remoteId); } DataStream &serialize(DataStream &stream) const Q_DECL_OVERRIDE { return ResponsePrivate::serialize(stream) << left + << leftMimeType << right + << rightMimeType << type << remoteId; } DataStream &deserialize(DataStream &stream) Q_DECL_OVERRIDE { return ResponsePrivate::deserialize(stream) >> left + >> leftMimeType >> right + >> rightMimeType >> type >> remoteId; } void debugString(DebugBlock &blck) const Q_DECL_OVERRIDE { ResponsePrivate::debugString(blck); blck.write("Left", left); + blck.write("LeftMimeType", leftMimeType); blck.write("Right", right); + blck.write("RightMimeType", rightMimeType); blck.write("Type", type); blck.write("Remote ID", remoteId); } @@ -2762,7 +2775,9 @@ } qint64 left; + QByteArray leftMimeType; qint64 right; + QByteArray rightMimeType; QByteArray type; QByteArray remoteId; }; @@ -2777,10 +2792,11 @@ { } -FetchRelationsResponse::FetchRelationsResponse(qint64 left, qint64 right, +FetchRelationsResponse::FetchRelationsResponse(qint64 left, const QByteArray &leftMimeType, + qint64 right, const QByteArray &rightMimeType, const QByteArray &type, const QByteArray &remoteId) - : Response(new FetchRelationsResponsePrivate(left, right, type, remoteId)) + : Response(new FetchRelationsResponsePrivate(left, leftMimeType, right, rightMimeType, type, remoteId)) { } @@ -2794,10 +2810,18 @@ { return d_func()->left; } +QByteArray FetchRelationsResponse::leftMimeType() const +{ + return d_func()->leftMimeType; +} qint64 FetchRelationsResponse::right() const { return d_func()->right; } +QByteArray FetchRelationsResponse::rightMimeType() const +{ + return d_func()->rightMimeType; +} QByteArray FetchRelationsResponse::type() const { return d_func()->type; diff --git a/src/private/protocol_p.h b/src/private/protocol_p.h --- a/src/private/protocol_p.h +++ b/src/private/protocol_p.h @@ -774,12 +774,14 @@ { public: explicit FetchRelationsResponse(); - explicit FetchRelationsResponse(qint64 left, qint64 right, const QByteArray &type, + explicit FetchRelationsResponse(qint64 left, const QByteArray &leftMimeType, qint64 right, const QByteArray &rightMimeType, const QByteArray &type, const QByteArray &remoteId = QByteArray()); FetchRelationsResponse(const Command &command); qint64 left() const; + QByteArray leftMimeType() const; qint64 right() const; + QByteArray rightMimeType() const; QByteArray type() const; void setRemoteId(const QByteArray &remoteId); diff --git a/src/server/handler/relationfetch.cpp b/src/server/handler/relationfetch.cpp --- a/src/server/handler/relationfetch.cpp +++ b/src/server/handler/relationfetch.cpp @@ -77,7 +77,8 @@ } const Relation::List existingRelations = relationQuery.result(); Q_FOREACH (const Relation &relation, existingRelations) { - sendResponse(Protocol::FetchRelationsResponse(relation.leftId(), relation.rightId(), + sendResponse(Protocol::FetchRelationsResponse(relation.leftId(), relation.left().mimeType().name().toUtf8(), + relation.rightId(), relation.right().mimeType().name().toUtf8(), relation.relationType().name().toUtf8(), relation.remoteId().toUtf8())); } diff --git a/src/server/handlerhelper.cpp b/src/server/handlerhelper.cpp --- a/src/server/handlerhelper.cpp +++ b/src/server/handlerhelper.cpp @@ -239,7 +239,9 @@ Protocol::FetchRelationsResponse HandlerHelper::fetchRelationsResponse(const Relation &relation) { return Protocol::FetchRelationsResponse(relation.leftId(), + relation.left().mimeType().name().toUtf8(), relation.rightId(), + relation.right().mimeType().name().toUtf8(), relation.relationType().name().toUtf8()); }