File indexing completed on 2024-10-27 04:51:03

0001 /*
0002    SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #pragma once
0007 
0008 #include <Akonadi/Item>
0009 #include <QObject>
0010 #include <QQueue>
0011 namespace Akonadi
0012 {
0013 class AgentInstance;
0014 class Collection;
0015 }
0016 
0017 class FolderArchiveAccountInfo;
0018 class FolderArchiveAgentJob;
0019 class FolderArchiveCache;
0020 class KJob;
0021 class FolderArchiveManager : public QObject
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit FolderArchiveManager(QObject *parent = nullptr);
0026     ~FolderArchiveManager() override;
0027 
0028     void load();
0029     void setArchiveItems(const Akonadi::Item::List &items, const QString &instanceName);
0030     void setArchiveItem(qlonglong itemId);
0031 
0032     void moveFailed(const QString &msg);
0033     void moveDone();
0034 
0035     [[nodiscard]] FolderArchiveCache *folderArchiveCache() const;
0036     void reloadConfig();
0037 
0038 public Q_SLOTS:
0039     void slotCollectionRemoved(const Akonadi::Collection &collection);
0040     void slotInstanceRemoved(const Akonadi::AgentInstance &instance);
0041 
0042 private:
0043     void slotFetchParentCollection(KJob *job);
0044     void slotFetchCollection(KJob *job);
0045 
0046     [[nodiscard]] FolderArchiveAccountInfo *infoFromInstanceName(const QString &instanceName) const;
0047     void nextJob();
0048     void removeInfo(const QString &instanceName);
0049     QQueue<FolderArchiveAgentJob *> mJobQueue;
0050     FolderArchiveAgentJob *mCurrentJob = nullptr;
0051     QList<FolderArchiveAccountInfo *> mListAccountInfo;
0052     FolderArchiveCache *const mFolderArchiveCache;
0053 };