File indexing completed on 2024-11-10 04:40:19
0001 /* 0002 SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "storage/datastore.h" 0010 0011 namespace Akonadi 0012 { 0013 namespace Server 0014 { 0015 class FakeAkonadiServer; 0016 0017 class FakeDataStoreFactory : public DataStoreFactory 0018 { 0019 public: 0020 FakeDataStoreFactory(FakeAkonadiServer *akonadi); 0021 DataStore *createStore() override; 0022 0023 private: 0024 FakeAkonadiServer *m_akonadi; 0025 }; 0026 0027 class FakeDataStore : public DataStore 0028 { 0029 Q_OBJECT 0030 friend class FakeDataStoreFactory; 0031 0032 public: 0033 ~FakeDataStore() override; 0034 0035 bool init() override; 0036 0037 QMap<QString, QVariantList> changes() const 0038 { 0039 return mChanges; 0040 } 0041 0042 bool setItemsFlags(const PimItem::List &items, 0043 const QList<Flag> *currentFlags, 0044 const QList<Flag> &flags, 0045 bool *flagsChanged = nullptr, 0046 const Collection &col = Collection(), 0047 bool silent = false) override; 0048 bool appendItemsFlags(const PimItem::List &items, 0049 const QList<Flag> &flags, 0050 bool *flagsChanged = nullptr, 0051 bool checkIfExists = true, 0052 const Collection &col = Collection(), 0053 bool silent = false) override; 0054 bool removeItemsFlags(const PimItem::List &items, 0055 const QList<Flag> &flags, 0056 bool *flagsChanged = nullptr, 0057 const Collection &col = Collection(), 0058 bool silent = false) override; 0059 0060 bool setItemsTags(const PimItem::List &items, const Tag::List &tags, bool *tagsChanged = nullptr, bool silent = false) override; 0061 bool appendItemsTags(const PimItem::List &items, 0062 const Tag::List &tags, 0063 bool *tagsChanged = nullptr, 0064 bool checkIfExists = true, 0065 const Collection &col = Collection(), 0066 bool silent = false) override; 0067 bool removeItemsTags(const PimItem::List &items, const Tag::List &tags, bool *tagsChanged = nullptr, bool silent = false) override; 0068 0069 bool removeItemParts(const PimItem &item, const QSet<QByteArray> &parts) override; 0070 0071 bool invalidateItemCache(const PimItem &item) override; 0072 0073 bool appendCollection(Collection &collection, const QStringList &mimeTypes, const QMap<QByteArray, QByteArray> &attributes) override; 0074 0075 bool cleanupCollection(Collection &collection) override; 0076 0077 bool moveCollection(Collection &collection, const Collection &newParent) override; 0078 0079 bool appendMimeTypeForCollection(qint64 collectionId, const QStringList &mimeTypes) override; 0080 0081 void activeCachePolicy(Collection &col) override; 0082 0083 bool appendPimItem(QList<Part> &parts, 0084 const QList<Flag> &flags, 0085 const MimeType &mimetype, 0086 const Collection &collection, 0087 const QDateTime &dateTime, 0088 const QString &remote_id, 0089 const QString &remoteRevision, 0090 const QString &gid, 0091 PimItem &pimItem) override; 0092 0093 bool cleanupPimItems(const PimItem::List &items, bool silent = false) override; 0094 0095 bool unhidePimItem(PimItem &pimItem) override; 0096 bool unhideAllPimItems() override; 0097 0098 bool addCollectionAttribute(const Collection &col, const QByteArray &key, const QByteArray &value, bool silent = false) override; 0099 bool removeCollectionAttribute(const Collection &col, const QByteArray &key) override; 0100 0101 bool beginTransaction(const QString &name = QString()) override; 0102 bool rollbackTransaction() override; 0103 bool commitTransaction() override; 0104 0105 void setPopulateDb(bool populate); 0106 0107 protected: 0108 FakeDataStore(FakeAkonadiServer *akonadi); 0109 0110 QMap<QString, QVariantList> mChanges; 0111 0112 private: 0113 bool mPopulateDb; 0114 }; 0115 0116 } 0117 }