folderarchivemanager.h 1.52 KB
Newer Older
1
/*
2
   SPDX-FileCopyrightText: 2013-2020 Laurent Montel <montel@kde.org>
3

4
   SPDX-License-Identifier: GPL-2.0-or-later
5
6
7
8
9
10
*/
#ifndef FOLDERARCHIVEMANAGER_H
#define FOLDERARCHIVEMANAGER_H

#include <QObject>
#include <QQueue>
Laurent Montel's avatar
Laurent Montel committed
11
#include <AkonadiCore/Item>
Laurent Montel's avatar
Laurent Montel committed
12
namespace Akonadi {
13
14
15
16
17
18
19
20
21
22
23
24
class AgentInstance;
class Collection;
}

class FolderArchiveAccountInfo;
class FolderArchiveAgentJob;
class FolderArchiveCache;
class KJob;
class FolderArchiveManager : public QObject
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
25
    explicit FolderArchiveManager(QObject *parent = nullptr);
26
27
28
    ~FolderArchiveManager();

    void load();
Laurent Montel's avatar
Laurent Montel committed
29
    void setArchiveItems(const Akonadi::Item::List &items, const QString &instanceName);
30
31
32
33
34
35
    void setArchiveItem(qlonglong itemId);

    void moveFailed(const QString &msg);
    void moveDone();

    FolderArchiveCache *folderArchiveCache() const;
36
    void reloadConfig();
37

38
public Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
39
    void slotCollectionRemoved(const Akonadi::Collection &collection);
40
    void slotInstanceRemoved(const Akonadi::AgentInstance &instance);
41

Laurent Montel's avatar
Laurent Montel committed
42
private:
Laurent Montel's avatar
Laurent Montel committed
43
    Q_DISABLE_COPY(FolderArchiveManager)
Laurent Montel's avatar
Laurent Montel committed
44
    void slotFetchParentCollection(KJob *job);
45
46
47
48
49
    void slotFetchCollection(KJob *job);

    FolderArchiveAccountInfo *infoFromInstanceName(const QString &instanceName) const;
    void nextJob();
    void removeInfo(const QString &instanceName);
Laurent Montel's avatar
Laurent Montel committed
50
    QQueue<FolderArchiveAgentJob *> mJobQueue;
Laurent Montel's avatar
Laurent Montel committed
51
    FolderArchiveAgentJob *mCurrentJob = nullptr;
Laurent Montel's avatar
Laurent Montel committed
52
    QList<FolderArchiveAccountInfo *> mListAccountInfo;
Laurent Montel's avatar
Laurent Montel committed
53
    FolderArchiveCache *const mFolderArchiveCache;
54
55
56
};

#endif // FOLDERARCHIVEMANAGER_H