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

Kevin Krammer kevin.krammer at gmx.at
Fri Jan 14 14:07:06 GMT 2011


Hi as well,

On Friday, 2011-01-14, Thomas McGuire wrote:
> Hi,
> 
> let me try to answer some questions I know about, others can fill in the
> blanks.

I'll try to do that.

> 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.

Right, unless there is a resource which allows creating of calendar 
collections, in which case you can create collections through the app and the 
resource will create them on the backend.

> > 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()

While true, I think we need to clarify this a bit more.

Each resource is responsible for creating its own top level collection.

If the backend already has other collections, retrieveCollections() will 
create them if they are not yet known to Akonadi.

If collection access rights allow creation of sub collections, any Akonadi 
client can do that, the resource will then make sure it is also created on the 
backend.

Example: KMail and maildir resource.
The default maildir resource works on $HOME/.local/share/local-mail as its 
backend.
It has created a top level collection representing that directory.
KMail can now create child collections in there, the maildir resource responds 
by creating respective subdirectories.

> > 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.

In terms of top level collection creation/deletion you always work 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.

No idea either.

> > 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

Cheers,
Kevin

-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110114/b94a8894/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