From 67e83aadde8db2bb1293cee61e8c6306a4ffcca0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 18 Jan 2016 18:36:41 +0100 Subject: Working resource inspection --- common/genericresource.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'common/genericresource.cpp') diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 90fc763..892c3db 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp @@ -301,6 +301,7 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c if (Akonadi2::Commands::VerifyInspectionBuffer(verifier)) { auto buffer = Akonadi2::Commands::GetInspection(command); int inspectionType = buffer->type(); + QByteArray inspectionId = QByteArray::fromRawData(reinterpret_cast(buffer->id()->Data()), buffer->id()->size()); QByteArray entityId = QByteArray::fromRawData(reinterpret_cast(buffer->entityId()->Data()), buffer->entityId()->size()); QByteArray domainType = QByteArray::fromRawData(reinterpret_cast(buffer->domainType()->Data()), buffer->domainType()->size()); QByteArray property = QByteArray::fromRawData(reinterpret_cast(buffer->property()->Data()), buffer->property()->size()); @@ -308,7 +309,21 @@ GenericResource::GenericResource(const QByteArray &resourceInstanceIdentifier, c QDataStream s(expectedValueString); QVariant expectedValue; s >> expectedValue; - return inspect(inspectionType, domainType, entityId, property, expectedValue); + inspect(inspectionType, inspectionId, domainType, entityId, property, expectedValue).then([=]() { + Akonadi2::ResourceNotification n; + n.type = Akonadi2::NotificationType_Inspection; + n.id = inspectionId; + n.code = Akonadi2::NotificationCode_Success; + emit notify(n); + }, [=](int code, const QString &message) { + Akonadi2::ResourceNotification n; + n.type = Akonadi2::NotificationType_Inspection; + n.message = message; + n.id = inspectionId; + n.code = Akonadi2::NotificationCode_Failure; + emit notify(n); + }).exec(); + return KAsync::null(); } return KAsync::error(-1, "Invalid inspection command."); }); @@ -334,7 +349,7 @@ GenericResource::~GenericResource() delete mSourceChangeReplay; } -KAsync::Job GenericResource::inspect(int inspectionType, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) +KAsync::Job GenericResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) { Warning() << "Inspection not implemented"; return KAsync::null(); -- cgit v1.2.3