[Kde-pim] Re: How Resources and Collections play together

Thomas McGuire thomas.mcguire at gmx.net
Fri Jan 14 13:37:34 GMT 2011


Hi,

let me try to answer some questions I know about, others can fill in the 
blanks.

On Friday 14 January 2011 13:04:07 Christian Mollekopf wrote:
> I'm a bit confused how akonadi resources and collections play together
> exactly.
> 
> As far as I understand it, a collection is the akonadi internal container.
> While the collection doesn't need a resource to exist, a resource is needed
> to make the link to the storage backend (filesystem, google, etc.).
> 
> So if i want a new calendar I create a new calendar resource (not a
> collection), which will in turn generate a new collection, associated with
> the resource.

Yep.

> So I assume normally there is 1 resource with 1 associated collection, but
> there can be special resources which have several collections.

Yes, correct. Quite a lot of resources have multiple collections.

> What I need to know:
> 
> Is the resource responsible for creating/deleting the collections?

Yes, the collections need to be created in ResourceBase::retrieveCollections()

> So as an application developer, do I always work with resources not
> collections (speaking of creating/deleting toplevel
> collections(respectively storage locations))?

Not sure what you mean here. The API for applications can deal with 
collections and resources. Applications in general deal with collections more 
than with resources.

> If I want to make a dialog where the user can choose, where to store his
> calendar files, is it ok to display a list of collections with the mimetype
> which i need? Or should I somehow list the resources?

Listing the collections should be enough. There is Akonadi::CollectionDialog 
and Akonadi::CollectionComboBox for this already, btw.

> In the ChangeRecorder for the EntityTreemodel, should I rather watch the
> collections or the resources? Whats the difference?

No idea.

> Can Collections contain items without a resource associated?

No. Each collection belongs to a resource, and as soon as you put an item in 
it the item will belong to the resource as well. When that happens, 
ResourceBase::itemAdded() is called, and the resource is responsible for 
storing the item in the backend storage (filesystem, server etc). Akonadi 
might later ask the resource for the item again, in 
ResourceBase::retrieveItem(), in which case the resource needs to read the 
item from the storage backend and pass it on the Akonadi.

> If I want to have a trash collections for items of various mimetypes, can I
> create a collection directly from my app, without a resource? I just want
> to keep the items there for a couple of days and then delete them.

You can create a collection directly from your app, but a collection always 
belongs to a resource. For example the trash collection in KMail is owned by 
the maildir resource, and some IMAP resources also have trash collections.

> Would it make sense to create a trash resource, which accepts all kinds of
> mimetypes, and deletes the items after a configured time, or is that not
> the purpose of resources?

I would somehow prefer having a trash collection in each resource where it is 
needed (maildir, IMAP etc). No idea though how that would work with ical 
resources, which only have a single collection right now. Maybe a trash 
resource here would make sense.

In general, this should be handled by the Akonadi::SpecialCollections 
mechanism. The apps ask this class for a specific collection, e.g. when KMail 
needs a trash it asks 
Akonadi::SpecialMailCollections::collection(Akonadi::SpecialMailCollections::Trash).

Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110114/2a2397a5/attachment.sig>
-------------- next part --------------
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/


More information about the kde-pim mailing list