File indexing completed on 2024-11-24 04:50:44
0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #pragma once 0005 0006 #include <MailCommon/MailInterfaces> 0007 0008 namespace Akonadi 0009 { 0010 class EntityTreeModel; 0011 class EntityMimeTypeFilterModel; 0012 } 0013 0014 namespace MailCommon 0015 { 0016 class FolderCollectionMonitor; 0017 } 0018 0019 /** 0020 * @short Central point of coordination in Merkuro Mail 0021 * 0022 * The MailKernel class represents the core of Merkuro Mail, where the different parts 0023 * come together and are coordinated. It is currently also the class which exports 0024 * Merkuro Mail's main D-BUS interfaces. 0025 * 0026 * The kernel is responsible for creating various 0027 * (singleton) objects such as the identity manager and the message sender. 0028 * 0029 * The kernel also creates an Akonadi Session, Monitor and EntityTreeModel. These 0030 * are shared so that other objects in Merkuro Mail have access to it. Having only one EntityTreeModel 0031 * instead of many reduces the overall communication with the Akonadi server. 0032 */ 0033 class MailKernel : public QObject, public MailCommon::IKernel, public MailCommon::ISettings, public MailCommon::IFilter 0034 { 0035 Q_OBJECT 0036 Q_CLASSINFO("D-Bus Interface", "org.kde.pim.merkuro.mail") 0037 0038 public: 0039 static MailKernel &self(); 0040 0041 // IKernel 0042 KIdentityManagementCore::IdentityManager *identityManager() override; 0043 MessageComposer::MessageSender *msgSender() override; 0044 0045 // ISettings 0046 Akonadi::EntityMimeTypeFilterModel *collectionModel() const override; 0047 KSharedConfig::Ptr config() override; 0048 void syncConfig() override; 0049 MailCommon::JobScheduler *jobScheduler() const override; 0050 Akonadi::ChangeRecorder *folderCollectionMonitor() const override; 0051 void updateSystemTray() override; 0052 0053 // IFilter 0054 void openFilterDialog(bool createDummyFilter = true) override; 0055 void createFilter(const QByteArray &field, const QString &value) override; 0056 0057 [[nodiscard]] qreal closeToQuotaThreshold() override; 0058 [[nodiscard]] bool excludeImportantMailFromExpiry() override; 0059 [[nodiscard]] QStringList customTemplates() override; 0060 [[nodiscard]] Akonadi::Collection::Id lastSelectedFolder() override; 0061 void setLastSelectedFolder(Akonadi::Collection::Id col) override; 0062 [[nodiscard]] bool showPopupAfterDnD() override; 0063 void expunge(Akonadi::Collection::Id id, bool sync) override; 0064 0065 private: 0066 explicit MailKernel(QObject *parent = nullptr); 0067 ~MailKernel() override; 0068 0069 KSharedConfigPtr mConfig; 0070 KIdentityManagementCore::IdentityManager *const mIdentityManager = nullptr; 0071 MessageComposer::MessageSender *const mMessageSender = nullptr; 0072 MailCommon::FolderCollectionMonitor *mFolderCollectionMonitor = nullptr; 0073 Akonadi::EntityTreeModel *mEntityTreeModel = nullptr; 0074 Akonadi::EntityMimeTypeFilterModel *mCollectionModel = nullptr; 0075 };