File indexing completed on 2024-11-24 04:44:21

0001 /*
0002     SPDX-FileCopyrightText: 2009 Bertjan Broeksem <broeksema@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "settings.h"
0010 #include "singlefileresource.h"
0011 
0012 namespace KMBox
0013 {
0014 class MBox;
0015 }
0016 
0017 class MboxResource : public Akonadi::SingleFileResource<Settings>
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit MboxResource(const QString &id);
0023     ~MboxResource() override;
0024 
0025 protected Q_SLOTS:
0026     bool retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts) override;
0027     void retrieveItems(const Akonadi::Collection &col) override;
0028 
0029 protected:
0030     void aboutToQuit() override;
0031 
0032     void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override;
0033     void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) override;
0034     void itemRemoved(const Akonadi::Item &item) override;
0035 
0036     // From SingleFileResourceBase
0037     void handleHashChange() override;
0038     bool readFromFile(const QString &fileName) override;
0039     bool writeToFile(const QString &fileName) override;
0040 
0041     [[nodiscard]] Akonadi::Collection rootCollection() const override;
0042 
0043 private:
0044     void onCollectionFetch(KJob *job);
0045     void onCollectionModify(KJob *job);
0046     QHash<KJob *, Akonadi::Item> mCurrentItemDeletions;
0047     KMBox::MBox *mMBox = nullptr;
0048 };