From 02d36a5f58e9a23163426b8a5aacbe1564b16422 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 24 May 2016 23:43:57 +0200 Subject: Pass in the inspection type --- common/inspection.h | 15 ++++++++++++++- common/resourceaccess.cpp | 4 ++-- common/resourceaccess.h | 4 ++-- common/resourcecontrol.cpp | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/inspection.h b/common/inspection.h index 7abcd1c..e0321bf 100644 --- a/common/inspection.h +++ b/common/inspection.h @@ -35,6 +35,7 @@ struct Inspection inspection.entityIdentifier = entity.identifier(); inspection.property = property; inspection.expectedValue = expectedValue; + inspection.type = PropertyInspectionType; return inspection; } @@ -44,18 +45,30 @@ struct Inspection inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); inspection.entityIdentifier = entity.identifier(); inspection.expectedValue = exists; + inspection.type = ExistenceInspectionType; + return inspection; + } + + static Inspection CacheIntegrityInspection(const Sink::ApplicationDomain::Entity &entity) + { + Inspection inspection; + inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); + inspection.entityIdentifier = entity.identifier(); + inspection.type = CacheIntegrityInspectionType; return inspection; } enum Type { PropertyInspectionType, - ExistenceInspectionType + ExistenceInspectionType, + CacheIntegrityInspectionType }; QByteArray resourceIdentifier; QByteArray entityIdentifier; QByteArray property; QVariant expectedValue; + int type; }; } } diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index 6dcc898..3696a93 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp @@ -353,7 +353,7 @@ KAsync::Job ResourceAccess::sendRevisionReplayedCommand(qint64 revision) } KAsync::Job -ResourceAccess::sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) +ResourceAccess::sendInspectionCommand(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) { flatbuffers::FlatBufferBuilder fbb; auto id = fbb.CreateString(inspectionId.toStdString()); @@ -366,7 +366,7 @@ ResourceAccess::sendInspectionCommand(const QByteArray &inspectionId, const QByt s << expectedValue; auto expected = fbb.CreateString(array.toStdString()); - auto location = Sink::Commands::CreateInspection(fbb, id, 0, entity, domain, prop, expected); + auto location = Sink::Commands::CreateInspection(fbb, id, inspectionType, entity, domain, prop, expected); Sink::Commands::FinishInspectionBuffer(fbb, location); open(); return sendCommand(Sink::Commands::InspectionCommand, fbb); diff --git a/common/resourceaccess.h b/common/resourceaccess.h index b9eaacd..82aa4d3 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h @@ -67,7 +67,7 @@ public: return KAsync::null(); }; virtual KAsync::Job - sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) + sendInspectionCommand(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) { return KAsync::null(); }; @@ -103,7 +103,7 @@ public: KAsync::Job sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) Q_DECL_OVERRIDE; KAsync::Job sendRevisionReplayedCommand(qint64 revision) Q_DECL_OVERRIDE; KAsync::Job - sendInspectionCommand(const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) Q_DECL_OVERRIDE; + sendInspectionCommand(int inspectionType,const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expecedValue) Q_DECL_OVERRIDE; /** * Tries to connect to server, and returns a connected socket on success. */ diff --git a/common/resourcecontrol.cpp b/common/resourcecontrol.cpp index ac6ddba..2be9b32 100644 --- a/common/resourcecontrol.cpp +++ b/common/resourcecontrol.cpp @@ -99,7 +99,7 @@ KAsync::Job ResourceControl::inspect(const Inspection &inspectionCommand) resourceAccess->open(); auto notifier = QSharedPointer::create(resourceAccess); auto id = QUuid::createUuid().toByteArray(); - return resourceAccess->sendInspectionCommand(id, ApplicationDomain::getTypeName(), inspectionCommand.entityIdentifier, inspectionCommand.property, inspectionCommand.expectedValue) + return resourceAccess->sendInspectionCommand(inspectionCommand.type, id, ApplicationDomain::getTypeName(), inspectionCommand.entityIdentifier, inspectionCommand.property, inspectionCommand.expectedValue) .template then([resourceAccess, notifier, id, time](KAsync::Future &future) { notifier->registerHandler([&future, id, time](const Notification ¬ification) { if (notification.id == id) { -- cgit v1.2.3