Changeset View
Changeset View
Standalone View
Standalone View
agents/unifiedmailboxagent/unifiedmailboxagent.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2018 Daniel Vrátil <dvratil@kde.org> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2 of the License, or (at your option) any later version. | ||||
8 | | ||||
9 | This program is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
12 | General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program; see the file COPYING. If not, write to | ||||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
17 | Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | #ifndef UNIFIEDMAILBOXAGENT_H | ||||
21 | #define UNIFIEDMAILBOXAGENT_H | ||||
22 | | ||||
23 | #include <AkonadiAgentBase/ResourceBase> | ||||
24 | #include <Akonadi/KMime/SpecialMailCollections> | ||||
25 | | ||||
26 | #include "unifiedmailboxmanager.h" | ||||
27 | | ||||
28 | #include <QHash> | ||||
29 | #include <QVector> | ||||
30 | | ||||
31 | /* Despite its name, this is actually a Resource, but it acts as an Agent: it | ||||
32 | * listens to notifications about Items that belong to other resources and acts | ||||
33 | * on them. | ||||
34 | * The only reason this agent has to implement ResourceBase is to be able to own | ||||
35 | * the virtual unified collections into which content of other collections is | ||||
36 | * linked. | ||||
37 | */ | ||||
38 | class UnifiedMailboxAgent : public Akonadi::ResourceBase | ||||
39 | { | ||||
40 | Q_OBJECT | ||||
41 | | ||||
42 | public: | ||||
43 | explicit UnifiedMailboxAgent(const QString &id); | ||||
44 | ~UnifiedMailboxAgent() override = default; | ||||
45 | | ||||
46 | void configure(WId windowId) override; | ||||
47 | | ||||
48 | void setEnableAgent(bool enable); | ||||
49 | bool enabledAgent() const; | ||||
50 | | ||||
51 | void retrieveCollections() override; | ||||
52 | void retrieveItems(const Akonadi::Collection &collection) override; | ||||
53 | bool retrieveItem(const Akonadi::Item &item, const QSet<QByteArray> &parts) override; | ||||
54 | private: | ||||
55 | void delayedInit(); | ||||
56 | | ||||
57 | void fixSpecialCollections(); | ||||
58 | void fixSpecialCollection(const QString &colId, Akonadi::SpecialMailCollections::Type type); | ||||
59 | | ||||
60 | UnifiedMailboxManager mBoxManager; | ||||
61 | }; | ||||
62 | | ||||
63 | #endif |