Akonadi::SpecialMailCollections Class

class Akonadi::SpecialMailCollections

Interface to special mail collections such as inbox, outbox etc. More...

Header: #include <Akonadi/SpecialMailCollections>
CMake: find_package(KPim6AkonadiMime REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiMime)

Public Types

enum Type { Invalid, Root, Inbox, Outbox, SentMail, …, LastType }

Public Functions

Akonadi::Collection collection(Akonadi::SpecialMailCollections::Type type, const Akonadi::AgentInstance &instance) const
Akonadi::Collection defaultCollection(Akonadi::SpecialMailCollections::Type type) const
bool hasCollection(Akonadi::SpecialMailCollections::Type type, const Akonadi::AgentInstance &instance) const
bool hasDefaultCollection(Akonadi::SpecialMailCollections::Type type) const
bool registerCollection(Akonadi::SpecialMailCollections::Type type, const Akonadi::Collection &collection)
bool unregisterCollection(const Akonadi::Collection &collection)
void verifyI18nDefaultCollection(Akonadi::SpecialMailCollections::Type type)

Static Public Members

Akonadi::SpecialMailCollections *self()
Akonadi::SpecialMailCollections::Type specialCollectionType(const Akonadi::Collection &collection)

Private Slots

void slotCollectionModified(KJob *job)

Detailed Description

This class is the central interface to the local mail folders. These folders can either be in the default resource (stored in ~/.local/share/local-mail) or in any number of custom resources. Special collections of the following types are supported: inbox, outbox, sent-mail, trash, drafts, templates and spam.

To check whether a special mail collection is available, simply use the hasCollection() and hasDefaultCollection() methods. Available special mail collections are accessible through the collection() and defaultCollection() methods.

To create a special mail collection, use a SpecialMailCollectionsRequestJob. This will create the special mail collections you request and automatically register them with SpecialMailCollections, so that it now knows they are available.

This class monitors all special mail collections known to it, and removes it from the known list if they are deleted. Note that this class does not automatically rebuild the collections that disappeared.

The defaultCollectionsChanged() and collectionsChanged() signals are emitted when the special mail collections for a resource change (i.e. some became available or some become unavailable).

if ( SpecialMailCollections::self()->hasDefaultCollection( SpecialMailCollections::Outbox ) ) {
  const Collection col = SpecialMailCollections::self()->defaultCollection( SpecialMailCollections::Outbox );
  // ...
} else {
  // ... use SpecialMailCollectionsRequestJob to request the collection...
}

Author: Constantin Berzan <exit3219@gmail.com>

Member Type Documentation

enum SpecialMailCollections::Type

Describes the possible types of special mail collections.

Generally, there may not be two special mail collections of the same type in the same resource.

Member Function Documentation

Akonadi::Collection SpecialMailCollections::collection(Akonadi::SpecialMailCollections::Type type, const Akonadi::AgentInstance &instance) const

Returns the special mail collection of the given type in the given agent instance, or an invalid collection if such a collection is unknown.

Akonadi::Collection SpecialMailCollections::defaultCollection(Akonadi::SpecialMailCollections::Type type) const

Returns the special mail collection of given type in the default resource, or an invalid collection if such a collection is unknown.

bool SpecialMailCollections::hasCollection(Akonadi::SpecialMailCollections::Type type, const Akonadi::AgentInstance &instance) const

Returns whether the given agent instance has a special collection of the given type.

bool SpecialMailCollections::hasDefaultCollection(Akonadi::SpecialMailCollections::Type type) const

Returns whether the default resource has a special mail collection of the given type.

bool SpecialMailCollections::registerCollection(Akonadi::SpecialMailCollections::Type type, const Akonadi::Collection &collection)

Registers the given collection as a special mail collection with the given type. type the type of collection collection the collection to register The collection must be owned by a valid resource. Registering a new collection of a previously registered type forgets the old collection.

[static] Akonadi::SpecialMailCollections *SpecialMailCollections::self()

Returns the global SpecialMailCollections instance.

[private slot] void SpecialMailCollections::slotCollectionModified(KJob *job)

[static] Akonadi::SpecialMailCollections::Type SpecialMailCollections::specialCollectionType(const Akonadi::Collection &collection)

Returns the special collection type for a given collection, or empty if the collection doesn't have a special type.

bool SpecialMailCollections::unregisterCollection(const Akonadi::Collection &collection)

Unregisters the given collection as a special mail collection collection the collection to unregister The collection must be owned by a valid resource.

void SpecialMailCollections::verifyI18nDefaultCollection(Akonadi::SpecialMailCollections::Type type)

Verifies that the default i18n collection of the given type exists. type the type of collection to verify