File indexing completed on 2024-11-10 04:49:58

0001 #include "dummykernel.h"
0002 
0003 #include <Akonadi/ChangeRecorder>
0004 #include <Akonadi/EntityMimeTypeFilterModel>
0005 #include <Akonadi/EntityTreeModel>
0006 #include <Akonadi/Session>
0007 #include <KIdentityManagementCore/IdentityManager>
0008 #include <KSharedConfig>
0009 #include <MailCommon/FolderCollectionMonitor>
0010 #include <MessageComposer/AkonadiSender>
0011 
0012 DummyKernel::DummyKernel(QObject *parent)
0013     : QObject(parent)
0014 {
0015     mMessageSender = new MessageComposer::AkonadiSender(this);
0016     mIdentityManager = new KIdentityManagementCore::IdentityManager(true, this);
0017     auto session = new Akonadi::Session("MailFilter Kernel ETM", this);
0018 
0019     mFolderCollectionMonitor = new MailCommon::FolderCollectionMonitor(session, this);
0020 
0021     mEntityTreeModel = new Akonadi::EntityTreeModel(folderCollectionMonitor(), this);
0022     mEntityTreeModel->setListFilter(Akonadi::CollectionFetchScope::Enabled);
0023     mEntityTreeModel->setItemPopulationStrategy(Akonadi::EntityTreeModel::LazyPopulation);
0024 
0025     mCollectionModel = new Akonadi::EntityMimeTypeFilterModel(this);
0026     mCollectionModel->setSourceModel(mEntityTreeModel);
0027     mCollectionModel->addMimeTypeInclusionFilter(Akonadi::Collection::mimeType());
0028     mCollectionModel->setHeaderGroup(Akonadi::EntityTreeModel::CollectionTreeHeaders);
0029     mCollectionModel->setDynamicSortFilter(true);
0030     mCollectionModel->setSortCaseSensitivity(Qt::CaseInsensitive);
0031 }
0032 
0033 KIdentityManagementCore::IdentityManager *DummyKernel::identityManager()
0034 {
0035     return mIdentityManager;
0036 }
0037 
0038 MessageComposer::MessageSender *DummyKernel::msgSender()
0039 {
0040     return mMessageSender;
0041 }
0042 
0043 Akonadi::EntityMimeTypeFilterModel *DummyKernel::collectionModel() const
0044 {
0045     return mCollectionModel;
0046 }
0047 
0048 KSharedConfig::Ptr DummyKernel::config()
0049 {
0050     return KSharedConfig::openConfig();
0051 }
0052 
0053 void DummyKernel::syncConfig()
0054 {
0055     Q_ASSERT(false);
0056 }
0057 
0058 MailCommon::JobScheduler *DummyKernel::jobScheduler() const
0059 {
0060     Q_ASSERT(false);
0061     return nullptr;
0062 }
0063 
0064 Akonadi::ChangeRecorder *DummyKernel::folderCollectionMonitor() const
0065 {
0066     return mFolderCollectionMonitor->monitor();
0067 }
0068 
0069 void DummyKernel::updateSystemTray()
0070 {
0071     Q_ASSERT(false);
0072 }
0073 
0074 bool DummyKernel::showPopupAfterDnD()
0075 {
0076     return false;
0077 }
0078 
0079 void DummyKernel::expunge(Akonadi::Collection::Id col, bool sync)
0080 {
0081     Q_UNUSED(col)
0082     Q_UNUSED(sync)
0083 }
0084 
0085 qreal DummyKernel::closeToQuotaThreshold()
0086 {
0087     return 80;
0088 }
0089 
0090 QStringList DummyKernel::customTemplates()
0091 {
0092     Q_ASSERT(false);
0093     return {};
0094 }
0095 
0096 bool DummyKernel::excludeImportantMailFromExpiry()
0097 {
0098     Q_ASSERT(false);
0099     return true;
0100 }
0101 
0102 Akonadi::Collection::Id DummyKernel::lastSelectedFolder()
0103 {
0104     Q_ASSERT(false);
0105     return Akonadi::Collection::Id();
0106 }
0107 
0108 void DummyKernel::setLastSelectedFolder(Akonadi::Collection::Id col)
0109 {
0110     Q_UNUSED(col)
0111 }