From e7ddc02bce5b4e46b44e3cb39c06ed25dc291c0a Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 19 Jan 2016 09:52:40 +0100 Subject: Prepared maildir inspection implementation --- common/clientapi.h | 21 +----------- common/inspection.h | 50 ++++++++++++++++++++++++++++ common/resourcefacade.h | 5 +++ examples/maildirresource/maildirresource.cpp | 6 ++++ examples/maildirresource/maildirresource.h | 1 + 5 files changed, 63 insertions(+), 20 deletions(-) create mode 100644 common/inspection.h diff --git a/common/clientapi.h b/common/clientapi.h index 5ed99e0..14caa7a 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -26,6 +26,7 @@ #include #include "query.h" +#include "inspection.h" #include "applicationdomaintype.h" class QAbstractItemModel; @@ -114,26 +115,6 @@ public: }; namespace Resources { - struct Inspection { - static Inspection PropertyInspection(const Akonadi2::ApplicationDomain::Entity &entity, const QByteArray &property, const QVariant &expectedValue) - { - Inspection inspection; - inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); - inspection.entityIdentifier = entity.identifier(); - inspection.property = property; - inspection.expectedValue = expectedValue; - return inspection; - } - - enum Type { - PropertyInspectionType - }; - - QByteArray resourceIdentifier; - QByteArray entityIdentifier; - QByteArray property; - QVariant expectedValue; - }; template KAsync::Job inspect(const Inspection &inspectionCommand); } diff --git a/common/inspection.h b/common/inspection.h new file mode 100644 index 0000000..45d599a --- /dev/null +++ b/common/inspection.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2015 Christian Mollekopf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ +#pragma once + +#include +#include +#include "applicationdomaintype.h" + +namespace Akonadi2 { + namespace Resources { + +struct Inspection { + static Inspection PropertyInspection(const Akonadi2::ApplicationDomain::Entity &entity, const QByteArray &property, const QVariant &expectedValue) + { + Inspection inspection; + inspection.resourceIdentifier = entity.resourceInstanceIdentifier(); + inspection.entityIdentifier = entity.identifier(); + inspection.property = property; + inspection.expectedValue = expectedValue; + return inspection; + } + + enum Type { + PropertyInspectionType + }; + QByteArray resourceIdentifier; + QByteArray entityIdentifier; + QByteArray property; + QVariant expectedValue; +}; + + } +} diff --git a/common/resourcefacade.h b/common/resourcefacade.h index 38e0c0e..ae3037a 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h @@ -27,6 +27,7 @@ namespace Akonadi2 { class Query; + class Inspection; } class ResourceFacade : public Akonadi2::StoreFacade @@ -38,5 +39,9 @@ public: KAsync::Job modify(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; KAsync::Job remove(const Akonadi2::ApplicationDomain::AkonadiResource &resource) Q_DECL_OVERRIDE; QPair, typename Akonadi2::ResultEmitter::Ptr > load(const Akonadi2::Query &query) Q_DECL_OVERRIDE; + KAsync::Job inspect(const Akonadi2::Inspection &domainObject) Q_DECL_OVERRIDE + { + return KAsync::error(-1, "Failed to inspect."); + } }; diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 70f6ae5..3531b92 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp @@ -35,6 +35,7 @@ #include "facadefactory.h" #include "indexupdater.h" #include "libmaildir/maildir.h" +#include "inspection.h" #include #include #include @@ -292,6 +293,11 @@ void MaildirResource::removeFromDisk(const QByteArray &instanceIdentifier) Akonadi2::Storage(Akonadi2::storageLocation(), instanceIdentifier + ".synchronization", Akonadi2::Storage::ReadWrite).removeFromDisk(); } +KAsync::Job MaildirResource::inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) +{ + Trace() << "Inspecting " << inspectionType << domainType << entityId << property << expectedValue; +} + MaildirResourceFactory::MaildirResourceFactory(QObject *parent) : Akonadi2::ResourceFactory(parent) { diff --git a/examples/maildirresource/maildirresource.h b/examples/maildirresource/maildirresource.h index 21ee637..5f7795b 100644 --- a/examples/maildirresource/maildirresource.h +++ b/examples/maildirresource/maildirresource.h @@ -44,6 +44,7 @@ class MaildirResource : public Akonadi2::GenericResource public: MaildirResource(const QByteArray &instanceIdentifier, const QSharedPointer &pipeline = QSharedPointer()); KAsync::Job synchronizeWithSource(Akonadi2::Storage &mainStore, Akonadi2::Storage &synchronizationStore) Q_DECL_OVERRIDE; + KAsync::Job inspect(int inspectionType, const QByteArray &inspectionId, const QByteArray &domainType, const QByteArray &entityId, const QByteArray &property, const QVariant &expectedValue) Q_DECL_OVERRIDE; static void removeFromDisk(const QByteArray &instanceIdentifier); private: KAsync::Job replay(Akonadi2::Storage &synchronizationStore, const QByteArray &type, const QByteArray &key, const QByteArray &value) Q_DECL_OVERRIDE; -- cgit v1.2.3