How to leverage Akonadi for emails in a Plasmoid

Daniel Vrátil me at dvratil.cz
Sat Aug 13 18:24:52 BST 2022


Hi Nathan,

the DBus API doesn't offer any means to access data stored in Akonadi,
you have to use the C++ API. One option is the EntityTreeModel (ETM),
which will give you a tree of folders, and emails in them. This can
be very memory consuming, though if the user has tons of emails.

There are more optimal approaches using CollectionFetchJob to retrieve
Collections ("folders"), ItemFetchJob to retrieve Items ("emails") from
particular Collection and then using Monitor to observe and be notified
about changes (e.g. new Item) in Collections you are interested in.

The exact details of how to put all this together depend on whether you
want to monitor only specific folder or a specific account, or INBOXes
or whether you want to let the user to choose which folders to include
in your Plasmoid.

None of this is usable straight from QML, they way I would do it would
be to create a custom QAbstractItemModel, populate and update it using
the Akonadi features described above and expose that model into QML.

Hope it helps,
/Dan

On 2022-08-07 15:42, Nathan wrote:
> Hi! I didn't get any response in the channel, and the info said I
> could reach out here.
> 
> I'm learning how to make Plasmoids, and I'm. Wanting to make a widget
> for displaying emails.
> 
> How can I access a list of old emails, information about email, and
> capture new emails, in QML in a Plasmoid?
> 
> I've been examining the Akonadi dbus api with a dbus explorer, but I
> can't quite figure it out. I've searched online for documentation on
> the dbus api, and haven't really found anything.
> 
> Is there any documentation on how to directly use dbus for what I'm
> looking for? Or is there an alternative way to get emails via QML?
> 
> Thanks in advance!
> - Nathan


More information about the kde-pim mailing list