File indexing completed on 2024-12-22 05:00:53
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(QByteArrayLiteral("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 qreal DummyKernel::closeToQuotaThreshold() 0080 { 0081 return 80; 0082 } 0083 0084 QStringList DummyKernel::customTemplates() 0085 { 0086 Q_ASSERT(false); 0087 return {}; 0088 } 0089 0090 bool DummyKernel::excludeImportantMailFromExpiry() 0091 { 0092 Q_ASSERT(false); 0093 return true; 0094 } 0095 0096 Akonadi::Collection::Id DummyKernel::lastSelectedFolder() 0097 { 0098 Q_ASSERT(false); 0099 return Akonadi::Collection::Id(); 0100 } 0101 0102 void DummyKernel::setLastSelectedFolder(Akonadi::Collection::Id col) 0103 { 0104 Q_UNUSED(col) 0105 } 0106 0107 void DummyKernel::expunge(Akonadi::Collection::Id id, bool sync) 0108 { 0109 Akonadi::Collection col(id); 0110 if (col.isValid()) { 0111 mFolderCollectionMonitor->expunge(Akonadi::Collection(col), sync); 0112 } 0113 } 0114 0115 #include "moc_dummykernel.cpp"