File indexing completed on 2024-11-24 04:44:05
0001 /* 0002 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> 0003 SPDX-FileContributor: Kevin Ottens <kevin@kdab.com> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "messagehelper.h" 0011 #include "resourcestateinterface.h" 0012 0013 class ImapResourceBase; 0014 0015 struct TaskArguments { 0016 TaskArguments() = default; 0017 0018 TaskArguments(const Akonadi::Item &_item) 0019 : items(Akonadi::Item::List() << _item) 0020 { 0021 } 0022 0023 TaskArguments(const Akonadi::Item &_item, const Akonadi::Collection &_collection) 0024 : collection(_collection) 0025 , items(Akonadi::Item::List() << _item) 0026 { 0027 } 0028 0029 TaskArguments(const Akonadi::Item &_item, const QSet<QByteArray> &_parts) 0030 : items(Akonadi::Item::List() << _item) 0031 , parts(_parts) 0032 { 0033 } 0034 0035 TaskArguments(const Akonadi::Item::List &_items) 0036 : items(_items) 0037 { 0038 } 0039 0040 TaskArguments(const Akonadi::Item::List &_items, const QSet<QByteArray> &_addedFlags, const QSet<QByteArray> &_removedFlags) 0041 : items(_items) 0042 , addedFlags(_addedFlags) 0043 , removedFlags(_removedFlags) 0044 { 0045 } 0046 0047 TaskArguments(const Akonadi::Item::List &_items, const Akonadi::Collection &_sourceCollection, const Akonadi::Collection &_targetCollection) 0048 : items(_items) 0049 , sourceCollection(_sourceCollection) 0050 , targetCollection(_targetCollection) 0051 { 0052 } 0053 0054 TaskArguments(const Akonadi::Item::List &_items, const QSet<Akonadi::Tag> &_addedTags, const QSet<Akonadi::Tag> &_removedTags) 0055 : items(_items) 0056 , addedTags(_addedTags) 0057 , removedTags(_removedTags) 0058 { 0059 } 0060 0061 TaskArguments(const Akonadi::Item::List &_items, const Akonadi::Relation::List &_addedRelations, const Akonadi::Relation::List &_removedRelations) 0062 : items(_items) 0063 , addedRelations(_addedRelations) 0064 , removedRelations(_removedRelations) 0065 { 0066 } 0067 0068 TaskArguments(const Akonadi::Collection &_collection) 0069 : collection(_collection) 0070 { 0071 } 0072 0073 TaskArguments(const Akonadi::Collection &_collection, const Akonadi::Collection &_parentCollection) 0074 : collection(_collection) 0075 , parentCollection(_parentCollection) 0076 { 0077 } 0078 0079 TaskArguments(const Akonadi::Collection &_collection, const Akonadi::Collection &_sourceCollection, const Akonadi::Collection &_targetCollection) 0080 : collection(_collection) 0081 , sourceCollection(_sourceCollection) 0082 , targetCollection(_targetCollection) 0083 { 0084 } 0085 0086 TaskArguments(const Akonadi::Collection &_collection, const QSet<QByteArray> &_parts) 0087 : collection(_collection) 0088 , parts(_parts) 0089 { 0090 } 0091 0092 TaskArguments(const Akonadi::Tag &_tag) 0093 : tag(_tag) 0094 { 0095 } 0096 0097 Akonadi::Collection collection; 0098 Akonadi::Item::List items; 0099 Akonadi::Collection parentCollection; // only used as parent of a collection 0100 Akonadi::Collection sourceCollection; 0101 Akonadi::Collection targetCollection; 0102 Akonadi::Tag tag; 0103 QSet<QByteArray> parts; 0104 QSet<QByteArray> addedFlags; 0105 QSet<QByteArray> removedFlags; 0106 QSet<Akonadi::Tag> addedTags; 0107 QSet<Akonadi::Tag> removedTags; 0108 Akonadi::Relation::List addedRelations; 0109 Akonadi::Relation::List removedRelations; 0110 }; 0111 0112 class ResourceState : public ResourceStateInterface 0113 { 0114 public: 0115 explicit ResourceState(ImapResourceBase *resource, const TaskArguments &arguments); 0116 0117 public: 0118 ~ResourceState() override; 0119 0120 QString userName() const override; 0121 QString resourceName() const override; 0122 QString resourceIdentifier() const override; 0123 QStringList serverCapabilities() const override; 0124 QList<KIMAP::MailBoxDescriptor> serverNamespaces() const override; 0125 QList<KIMAP::MailBoxDescriptor> personalNamespaces() const override; 0126 QList<KIMAP::MailBoxDescriptor> userNamespaces() const override; 0127 QList<KIMAP::MailBoxDescriptor> sharedNamespaces() const override; 0128 0129 bool isAutomaticExpungeEnabled() const override; 0130 bool isSubscriptionEnabled() const override; 0131 bool isDisconnectedModeEnabled() const override; 0132 int intervalCheckTime() const override; 0133 0134 Akonadi::Collection collection() const override; 0135 Akonadi::Item item() const override; 0136 Akonadi::Item::List items() const override; 0137 0138 Akonadi::Collection parentCollection() const override; 0139 0140 Akonadi::Collection sourceCollection() const override; 0141 Akonadi::Collection targetCollection() const override; 0142 0143 QSet<QByteArray> parts() const override; 0144 QSet<QByteArray> addedFlags() const override; 0145 QSet<QByteArray> removedFlags() const override; 0146 0147 Akonadi::Tag tag() const override; 0148 QSet<Akonadi::Tag> addedTags() const override; 0149 QSet<Akonadi::Tag> removedTags() const override; 0150 0151 Akonadi::Relation::List addedRelations() const override; 0152 Akonadi::Relation::List removedRelations() const override; 0153 0154 QString rootRemoteId() const override; 0155 0156 void setIdleCollection(const Akonadi::Collection &collection) override; 0157 void applyCollectionChanges(const Akonadi::Collection &collection) override; 0158 0159 void collectionAttributesRetrieved(const Akonadi::Collection &collection) override; 0160 0161 void itemRetrieved(const Akonadi::Item &item) override; 0162 0163 void itemsRetrieved(const Akonadi::Item::List &items) override; 0164 void itemsRetrievedIncremental(const Akonadi::Item::List &changed, const Akonadi::Item::List &removed) override; 0165 void itemsRetrievalDone() override; 0166 0167 void setTotalItems(int) override; 0168 0169 void itemChangeCommitted(const Akonadi::Item &item) override; 0170 void itemsChangesCommitted(const Akonadi::Item::List &items) override; 0171 0172 void collectionsRetrieved(const Akonadi::Collection::List &collections) override; 0173 0174 void tagsRetrieved(const Akonadi::Tag::List &tags, const QHash<QString, Akonadi::Item::List> &) override; 0175 void relationsRetrieved(const Akonadi::Relation::List &tags) override; 0176 0177 void collectionChangeCommitted(const Akonadi::Collection &collection) override; 0178 0179 void tagChangeCommitted(const Akonadi::Tag &tag) override; 0180 0181 void changeProcessed() override; 0182 0183 void searchFinished(const QList<qint64> &result, bool isRid = true) override; 0184 0185 void cancelTask(const QString &errorString) override; 0186 void deferTask() override; 0187 void restartItemRetrieval(Akonadi::Collection::Id col) override; 0188 void taskDone() override; 0189 0190 void emitError(const QString &message) override; 0191 void emitWarning(const QString &message) override; 0192 0193 void emitPercent(int percent) override; 0194 0195 virtual void synchronizeCollection(Akonadi::Collection::Id); 0196 void synchronizeCollectionTree() override; 0197 void scheduleConnectionAttempt() override; 0198 0199 QChar separatorCharacter() const override; 0200 void setSeparatorCharacter(QChar separator) override; 0201 0202 void showInformationDialog(const QString &message, const QString &title, const QString &dontShowAgainName) override; 0203 0204 int batchSize() const override; 0205 0206 MessageHelper::Ptr messageHelper() const override; 0207 0208 void setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode) override; 0209 0210 private: 0211 ImapResourceBase *const m_resource; 0212 const TaskArguments m_arguments; 0213 };