Akonadi::PreprocessorBase Class

Header: #include <Akonadi/PreprocessorBase>
CMake: find_package(KPim6 REQUIRED COMPONENTS AkonadiAgentBase)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiAgentBase)
Inherits: Akonadi::AgentBase

Public Types

enum ProcessingResult { ProcessingCompleted, ProcessingDelayed, ProcessingFailed, ProcessingRefused }

Public Functions

Akonadi::ItemFetchScope &fetchScope()
void finishProcessing(Akonadi::PreprocessorBase::ProcessingResult result)
virtual Akonadi::PreprocessorBase::ProcessingResult processItem(const Akonadi::Item &item) = 0
void setFetchScope(const Akonadi::ItemFetchScope &fetchScope)

Protected Functions

PreprocessorBase(const QString &id)
virtual ~PreprocessorBase() override

Detailed Description

\shortThe base class for all Akonadi preprocessor agents.

This class should be used as a base class by all preprocessor agents since it encapsulates large parts of the protocol between preprocessor agent, agent manager and the Akonadi storage.

Preprocessor agents are special agents that are informed about newly added items before any other agents. This allows them to do filtering on the items or any other task that shall be done before the new item is visible in the Akonadi storage system.

The method all the preprocessors must implement is processItem().

Author: Szymon Stefanek <s.stefanek@gmail.com>

Member Type Documentation

enum PreprocessorBase::ProcessingResult

Describes the possible return values of the processItem() method.

Member Function Documentation

[protected] PreprocessorBase::PreprocessorBase(const QString &id)

Creates a new preprocessor base agent.

id The instance id of the preprocessor base agent.

[override virtual noexcept protected] PreprocessorBase::~PreprocessorBase()

Destroys the preprocessor base agent.

Akonadi::ItemFetchScope &PreprocessorBase::fetchScope()

Returns the item fetch scope.

Since this returns a reference it can be used to conveniently modify the current scope in-place, i.e. by calling a method on the returned reference without storing it in a local variable. See the ItemFetchScope documentation for an example.

Returns a reference to the current item fetch scope

\seesetFetchScope() for replacing the current item fetch scope

See also setFetchScope().

void PreprocessorBase::finishProcessing(Akonadi::PreprocessorBase::ProcessingResult result)

This method must be called if processing is implemented asynchronously. result the processing result You should call it when you have completed the processing or if an abortRequest() signal arrives (and in this case you will probably use ProcessingFailed as result).

Valid values for \p result are ProcessingCompleted, PocessingRefused and ProcessingFailed. Passing any other value will lead to a runtime assertion.

[pure virtual] Akonadi::PreprocessorBase::ProcessingResult PreprocessorBase::processItem(const Akonadi::Item &item)

This method must be implemented by every preprocessor subclass. item the item to process It must realize the preprocessing of the given \p item.

The Akonadi server will push in for preprocessing any newly created item: it's your responsibility to decide if you want to process the item or not.

The method should return ProcessingCompleted on success, ProcessingDelayed if processing is implemented asynchronously and ProcessingRefused or ProcessingFailed if the processing didn't complete.

If your operation is asynchronous then you should also connect to the abortRequested() signal and handle it appropriately (as the server MAY abort your async job if it decides that it's taking too long).

void PreprocessorBase::setFetchScope(const Akonadi::ItemFetchScope &fetchScope)

Sets the item fetch scope.

The ItemFetchScope controls how much of an item's data is fetched from the server, e.g. whether to fetch the full item payload or only meta data.

fetchScope The new scope for item fetch operations.

\seefetchScope()

See also fetchScope().