akonadi
#include <itemserializerplugin.h>
Public Member Functions | |
virtual | ~ItemSerializerPlugin () |
virtual bool | deserialize (Item &item, const QByteArray &label, QIODevice &data, int version)=0 |
virtual QSet< QByteArray > | parts (const Item &item) const |
virtual void | serialize (const Item &item, const QByteArray &label, QIODevice &data, int &version)=0 |
Static Public Member Functions | |
static void | overridePluginLookup (QObject *plugin) |
Detailed Description
The base class for item type serializer plugins.
Serializer plugins convert between the payload of Akonadi::Item objects and a textual or binary representation of the actual content data. This allows to easily add support for new types to Akonadi.
The following example shows how to implement a serializer plugin for a new data type PimNote.
The PimNote data structure:
The serializer plugin code:
The desktop file:
Definition at line 119 of file itemserializerplugin.h.
Constructor & Destructor Documentation
|
virtual |
Destroys the item serializer plugin.
Definition at line 29 of file itemserializerplugin.cpp.
Member Function Documentation
|
pure virtual |
Converts serialized item data provided in data
into payload for item
.
- Parameters
-
item The item to which the payload should be added. It is guaranteed to have a mime type matching one of the supported mime types of this plugin. However it might contain a unsuited payload added manually by the application developer. Verifying the payload type in case a payload is already available is recommended therefore. label The part identifier of the part to deserialize. label
might be an unsupported item part, returnfalse
if this is the case.data A QIODevice providing access to the serialized data. The QIODevice is opened in read-only mode and positioned at the beginning. The QIODevice is guaranteed to be valid. version The version of the data format as set by the user in serialize() or 0
(default).
- Returns
false
if the specified part is not supported by this plugin,true
if the part could be de-serialized successfully.
Implemented in Akonadi::StdStringItemSerializerPlugin, and Akonadi::DefaultItemSerializerPlugin.
|
static |
Override the plugin-lookup with plugin
.
After calling this each lookup will always return plugin
. This is useful to inject a special plugin for testing purposes. To reset the plugin, set to 0.
- Since
- 4.12
Definition at line 43 of file itemserializerplugin.cpp.
|
virtual |
Returns a list of available parts for the given item payload.
The default implementation returns Item::FullPayload if a payload is set.
- Parameters
-
item The item.
Definition at line 33 of file itemserializerplugin.cpp.
|
pure virtual |
Convert the payload object provided in item
into its serialzed form into data
.
- Parameters
-
item The item which contains the payload. It is guaranteed to have a mimetype matching one of the supported mimetypes of this plugin as well as the existence of a payload object. However it might contain an unsupported payload added manually by the application developer. Verifying the payload type is recommended therefore. label The part identifier of the part to serialize. label
will be one of the item parts returned by parts().data The QIODevice where the serialized data should be written to. The QIODevice is opened in write-only mode and positioned at the beginning. The QIODevice is guaranteed to be valid. version The version of the data format. Can be set by the user to handle different versions.
Implemented in Akonadi::StdStringItemSerializerPlugin, and Akonadi::DefaultItemSerializerPlugin.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.