MailCommon::Kernel Class

class MailCommon::Kernel
Header: #include <MailCommon/Kernel>
CMake: find_package(KPim6MailCommon REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::MailCommon)
Inherits: QObject

Public Functions

virtual ~Kernel() override
PimCommonActivities::ActivitiesBaseManager *activitiesBaseManager() const
Akonadi::Collection collectionFromId(Akonadi::Collection::Id id) const
Akonadi::Collection draftsCollectionFolder()
void emergencyExit(const QString &reason)
MailCommon::IFilter *filterIf() const
bool folderIsDraftOrOutbox(const Akonadi::Collection &collection)
bool folderIsDrafts(const Akonadi::Collection &collection)
bool folderIsSentMailFolder(const Akonadi::Collection &collection)
bool folderIsSpams(const Akonadi::Collection &collection)
bool folderIsTemplates(const Akonadi::Collection &collection)
bool folderIsTrash(const Akonadi::Collection &collection)
PimCommon::ImapResourceCapabilitiesManager *imapResourceManager() const
Akonadi::Collection inboxCollectionFolder()
void initFolders()
bool isMainFolderCollection(const Akonadi::Collection &col)
bool isSystemFolderCollection(const Akonadi::Collection &col)
MailCommon::IKernel *kernelIf() const
bool kernelIsRegistered() const
Akonadi::Collection outboxCollectionFolder()
void registerActivitiesBaseManager(PimCommonActivities::ActivitiesBaseManager *manager)
void registerFilterIf(MailCommon::IFilter *filterIf)
void registerKernelIf(MailCommon::IKernel *kernelIf)
void registerSettingsIf(MailCommon::ISettings *settingsIf)
Akonadi::Collection sentCollectionFolder()
MailCommon::ISettings *settingsIf() const
Akonadi::Collection spamsCollectionFolder()
Akonadi::Collection templatesCollectionFolder()
Akonadi::Collection trashCollectionFolder()
Akonadi::Collection trashCollectionFromResource(const Akonadi::Collection &col)

Signals

Static Public Members

bool folderIsInbox(const Akonadi::Collection &collection)
QMap<QString, Akonadi::Collection::Id> pop3ResourceTargetCollection()
MailCommon::Kernel *self()

Private Slots

void createDefaultCollectionDone(KJob *job)
void slotDefaultCollectionsChanged()

Detailed Description

Deals with common mail application related operations. The required interfaces MUST be registered before using it! Be careful when using in multi-threaded applications, as Kernel is a QObject singleton, created in the main thread, thus event handling for Kernel::self() will happen in the main thread.

Member Function Documentation

[override virtual noexcept] Kernel::~Kernel()

Destroys the kernel.

PimCommonActivities::ActivitiesBaseManager *Kernel::activitiesBaseManager() const

Returns the activities base manager.

Returns A pointer to the activities base manager

Akonadi::Collection Kernel::collectionFromId(Akonadi::Collection::Id id) const

Returns the collection associated with the given id, or an invalid collection if not found. The EntityTreeModel of the kernel is searched for the collection. Since the ETM is loaded async, this method will not find the collection right after startup, when the ETM is not yet fully loaded.

id The collection ID to look up Returns The collection with the given ID, or an invalid collection

[private slot] void Kernel::createDefaultCollectionDone(KJob *job)

Akonadi::Collection Kernel::draftsCollectionFolder()

Returns the drafts collection folder.

Returns The drafts collection

void Kernel::emergencyExit(const QString &reason)

Performs emergency exit when an error occurs.

reason The reason for the emergency exit

MailCommon::IFilter *Kernel::filterIf() const

Returns the registered filter interface.

Returns A pointer to the filter interface

bool Kernel::folderIsDraftOrOutbox(const Akonadi::Collection &collection)

Returns true if the folder is either the outbox or one of the drafts-folders.

collection The collection to check Returns True if the collection is a draft or outbox folder, false otherwise

bool Kernel::folderIsDrafts(const Akonadi::Collection &collection)

Checks if the given collection is a drafts folder.

collection The collection to check Returns True if the collection is a drafts folder, false otherwise

[static] bool Kernel::folderIsInbox(const Akonadi::Collection &collection)

Checks if the given collection is an inbox folder.

collection The collection to check Returns True if the collection is an inbox, false otherwise

bool Kernel::folderIsSentMailFolder(const Akonadi::Collection &collection)

Returns true if the folder is one of the sent-mail folders.

collection The collection to check Returns True if the collection is a sent mail folder, false otherwise

bool Kernel::folderIsSpams(const Akonadi::Collection &collection)

Checks if the given collection is a spam/junk folder.

collection The collection to check Returns True if the collection is a spam folder, false otherwise

bool Kernel::folderIsTemplates(const Akonadi::Collection &collection)

Checks if the given collection is a templates folder.

collection The collection to check Returns True if the collection is a templates folder, false otherwise

bool Kernel::folderIsTrash(const Akonadi::Collection &collection)

Returns true if the folder is a trash folder.

When calling this too early (before the SpecialMailCollectionsDiscoveryJob from initFolders finishes), it will say false erroneously. However you can connect to SpecialMailCollections::collectionsChanged to react on dynamic changes and call this again.

collection The collection to check Returns True if the collection is a trash folder, false otherwise

PimCommon::ImapResourceCapabilitiesManager *Kernel::imapResourceManager() const

Returns the IMAP resource capabilities manager.

Returns A pointer to the IMAP resource capabilities manager

Akonadi::Collection Kernel::inboxCollectionFolder()

Returns the inbox collection folder.

Returns The inbox collection

void Kernel::initFolders()

Initializes the kernel and system mail folders.

bool Kernel::isMainFolderCollection(const Akonadi::Collection &col)

Returns true if this folder is the inbox on the local disk

col The collection to check Returns True if the collection is the main inbox, false otherwise

bool Kernel::isSystemFolderCollection(const Akonadi::Collection &col)

Checks if the given collection is a system folder collection.

col The collection to check Returns True if the collection is a system folder, false otherwise

MailCommon::IKernel *Kernel::kernelIf() const

Returns the registered kernel interface.

Returns A pointer to the kernel interface

bool Kernel::kernelIsRegistered() const

Returns whether a kernel interface is registered.

Returns True if registered, false otherwise

Akonadi::Collection Kernel::outboxCollectionFolder()

Returns the outbox collection folder.

Returns The outbox collection

[static] QMap<QString, Akonadi::Collection::Id> Kernel::pop3ResourceTargetCollection()

Returns the mapping of POP3 resources to their target collections.

Returns A map from resource names to collection IDs

void Kernel::registerActivitiesBaseManager(PimCommonActivities::ActivitiesBaseManager *manager)

Registers the activities base manager.

manager The activities base manager to register

void Kernel::registerFilterIf(MailCommon::IFilter *filterIf)

Registers the interface dealing with mail settings. This function MUST be called with a valid interface pointer, before any Kernel::self() method is used. The pointer ownership will not be transferred to Kernel.

filterIf The filter interface to register

void Kernel::registerKernelIf(MailCommon::IKernel *kernelIf)

Registers the interface dealing with main mail functionality. This function MUST be called with a valid interface pointer, before any Kernel::self() method is used. The pointer ownership will not be transferred to Kernel.

kernelIf The kernel interface to register

void Kernel::registerSettingsIf(MailCommon::ISettings *settingsIf)

Registers the interface dealing with mail settings. This function MUST be called with a valid interface pointer, before any Kernel::self() method is used. The pointer ownership will not be transferred to Kernel.

settingsIf The settings interface to register

[signal] void Kernel::requestConfigSync()

Emitted when a configuration synchronization is requested.

[signal] void Kernel::requestSystemTrayUpdate()

Emitted when a system tray update is requested.

[static] MailCommon::Kernel *Kernel::self()

Returns the kernel singleton.

Returns A pointer to the Kernel instance

Akonadi::Collection Kernel::sentCollectionFolder()

Returns the sent mail collection folder.

Returns The sent mail collection

MailCommon::ISettings *Kernel::settingsIf() const

Returns the registered settings interface.

Returns A pointer to the settings interface

[private slot] void Kernel::slotDefaultCollectionsChanged()

Akonadi::Collection Kernel::spamsCollectionFolder()

Returns the spam collection folder.

Returns The spam collection

Akonadi::Collection Kernel::templatesCollectionFolder()

Returns the templates collection folder.

Returns The templates collection

Akonadi::Collection Kernel::trashCollectionFolder()

Returns the trash collection folder.

Returns The trash collection

Akonadi::Collection Kernel::trashCollectionFromResource(const Akonadi::Collection &col)

Returns the trash folder for the resource which col belongs to.

When calling this too early (before the SpecialMailCollectionsDiscoveryJob from initFolders finishes), it will return an invalid collection erroneously. However you can connect to SpecialMailCollections::collectionsChanged to react on dynamic changes and call this again.

col The collection whose resource's trash folder should be returned Returns The trash collection for the resource