File indexing completed on 2024-11-24 04:53:14
0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net> 0002 0003 This file is part of the Trojita Qt IMAP e-mail client, 0004 http://trojita.flaska.net/ 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License as 0008 published by the Free Software Foundation; either version 2 of 0009 the License or (at your option) version 3 or any later version 0010 accepted by the membership of KDE e.V. (or its successor approved 0011 by the membership of KDE e.V.), which shall act as a proxy 0012 defined in Section 14 of version 3 of the license. 0013 0014 This program is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 GNU General Public License for more details. 0018 0019 You should have received a copy of the GNU General Public License 0020 along with this program. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef IMAP_MODEL_TASKFACTORY_H 0024 #define IMAP_MODEL_TASKFACTORY_H 0025 0026 #include <memory> 0027 #include <QMap> 0028 #include <QModelIndex> 0029 #include "CatenateData.h" 0030 #include "CopyMoveOperation.h" 0031 #include "FlagsOperation.h" 0032 #include "SubscribeUnSubscribeOperation.h" 0033 #include "UidSubmitData.h" 0034 #include "Imap/Parser/Uids.h" 0035 0036 namespace Imap 0037 { 0038 class Parser; 0039 namespace Mailbox 0040 { 0041 0042 class AppendTask; 0043 class CopyMoveMessagesTask; 0044 class CreateMailboxTask; 0045 class DeleteMailboxTask; 0046 class EnableTask; 0047 class ExpungeMailboxTask; 0048 class FetchMsgMetadataTask; 0049 class FetchMsgPartTask; 0050 class GetAnyConnectionTask; 0051 class IdTask; 0052 class ImapTask; 0053 class KeepMailboxOpenTask; 0054 class ListChildMailboxesTask; 0055 class NumberOfMessagesTask; 0056 class ObtainSynchronizedMailboxTask; 0057 class OpenConnectionTask; 0058 class UpdateFlagsTask; 0059 class UpdateFlagsOfAllMessagesTask; 0060 class ThreadTask; 0061 class NoopTask; 0062 class UnSelectTask; 0063 class SortTask; 0064 class SubscribeUnsubscribeTask; 0065 class GenUrlAuthTask; 0066 class UidSubmitTask; 0067 0068 class Model; 0069 class TreeItemMailbox; 0070 class TreeItemPart; 0071 0072 class TaskFactory 0073 { 0074 public: 0075 virtual ~TaskFactory(); 0076 0077 virtual CopyMoveMessagesTask *createCopyMoveMessagesTask(Model *model, const QModelIndexList &messages, 0078 const QString &targetMailbox, const CopyMoveOperation op); 0079 virtual CreateMailboxTask *createCreateMailboxTask(Model *model, const QString &mailbox); 0080 virtual DeleteMailboxTask *createDeleteMailboxTask(Model *model, const QString &mailbox); 0081 virtual EnableTask *createEnableTask(Model *model, ImapTask *dependingTask, const QList<QByteArray> &extensions); 0082 virtual ExpungeMailboxTask *createExpungeMailboxTask(Model *model, const QModelIndex &mailbox); 0083 virtual FetchMsgMetadataTask *createFetchMsgMetadataTask(Model *model, const QModelIndex &mailbox, const Imap::Uids &uid); 0084 virtual FetchMsgPartTask *createFetchMsgPartTask(Model *model, const QModelIndex &mailbox, const Imap::Uids &uids, const QList<QByteArray> &parts); 0085 virtual GetAnyConnectionTask *createGetAnyConnectionTask(Model *model); 0086 virtual IdTask *createIdTask(Model *model, ImapTask *dependingTask); 0087 virtual KeepMailboxOpenTask *createKeepMailboxOpenTask(Model *model, const QModelIndex &mailbox, Parser *oldParser); 0088 virtual ListChildMailboxesTask *createListChildMailboxesTask(Model *model, const QModelIndex &mailbox); 0089 virtual NumberOfMessagesTask *createNumberOfMessagesTask(Model *model, const QModelIndex &mailbox); 0090 virtual ObtainSynchronizedMailboxTask *createObtainSynchronizedMailboxTask(Model *model, const QModelIndex &mailboxIndex, 0091 ImapTask *parentTask, KeepMailboxOpenTask *keepTask); 0092 virtual OpenConnectionTask *createOpenConnectionTask(Model *model); 0093 virtual UpdateFlagsOfAllMessagesTask *createUpdateFlagsOfAllMessagesTask(Model *model, const QModelIndex &mailbox, 0094 const FlagsOperation flagOperation, const QString &flags); 0095 virtual UpdateFlagsTask *createUpdateFlagsTask(Model *model, const QModelIndexList &messages, const FlagsOperation flagOperation, 0096 const QString &flags); 0097 virtual UpdateFlagsTask *createUpdateFlagsTask(Model *model, CopyMoveMessagesTask *copyTask, 0098 const QList<QPersistentModelIndex> &messages, const FlagsOperation flagOperation, 0099 const QString &flags); 0100 virtual ThreadTask *createThreadTask(Model *model, const QModelIndex &mailbox, const QByteArray &algorithm, const QStringList &searchCriteria); 0101 virtual ThreadTask *createIncrementalThreadTask(Model *model, const QModelIndex &mailbox, const QByteArray &algorithm, const QStringList &searchCriteria); 0102 virtual NoopTask *createNoopTask(Model *model, ImapTask *parentTask); 0103 virtual UnSelectTask *createUnSelectTask(Model *model, ImapTask *parentTask); 0104 virtual SortTask *createSortTask(Model *model, const QModelIndex &mailbox, const QStringList &searchConditions, const QStringList &sortCriteria); 0105 virtual AppendTask *createAppendTask(Model *model, const QString &targetMailbox, const QByteArray &rawMessageData, 0106 const QStringList &flags, const QDateTime ×tamp); 0107 virtual AppendTask *createAppendTask(Model *model, const QString &targetMailbox, const QList<CatenatePair> &data, 0108 const QStringList &flags, const QDateTime ×tamp); 0109 virtual SubscribeUnsubscribeTask *createSubscribeUnsubscribeTask(Model *model, const QString &mailboxName, 0110 const SubscribeUnsubscribeOperation operation); 0111 virtual SubscribeUnsubscribeTask *createSubscribeUnsubscribeTask(Model *model, ImapTask *parentTask, const QString &mailboxName, 0112 const SubscribeUnsubscribeOperation operation); 0113 virtual GenUrlAuthTask *createGenUrlAuthTask(Model *model, const QString &host, const QString &user, const QString &mailbox, 0114 const uint uidValidity, const uint uid, const QString &part, const QString &access); 0115 virtual UidSubmitTask *createUidSubmitTask(Model *model, const QString &mailbox, const uint uidValidity, const uint uid, 0116 const UidSubmitOptionsList &submitOptions); 0117 }; 0118 0119 class TestingTaskFactory: public TaskFactory 0120 { 0121 public: 0122 TestingTaskFactory(); 0123 OpenConnectionTask *createOpenConnectionTask(Model *model) override; 0124 ListChildMailboxesTask *createListChildMailboxesTask(Model *model, const QModelIndex &mailbox) override; 0125 bool fakeOpenConnectionTask; 0126 bool fakeListChildMailboxes; 0127 QMap<QString,QStringList> fakeListChildMailboxesMap; 0128 private: 0129 Parser *newParser(Model *model); 0130 }; 0131 0132 typedef std::unique_ptr<TaskFactory> TaskFactoryPtr; 0133 0134 } 0135 } 0136 0137 #endif // IMAP_MODEL_TASKFACTORY_H