[Kde-pim] How to use akonadi

Volker Krause vkrause at kde.org
Mon Sep 7 07:48:52 BST 2009


On Monday 07 September 2009 01:17:03 David Jarvie wrote:
> On Thursday 03 Sep 2009 19:05:03 Eduardo Robles Elvira wrote:
> > On Wed, Sep 2, 2009 at 11:04 PM, Mantia Andras<amantia at kde.org> wrote:
> > > Tobias Koenig wrote:
> > >> On Wed, Sep 02, 2009 at 04:28:12AM +0100, David Jarvie wrote:
> > >> Hej David,
> > >>
> > >>> I've looked for example code, and looked at the API documentation
> > >>> (including the Akonadi overview there), but I'm at a bit of a loss to
> > >>> know how to start. It would seem that the right thing might be to
> > >>> create an Akonadi::Collection instance, but I'm not sure, and what to
> > >>> do after that isn't clear.
> > >>
> > >> You have to use the Akonadi::(Item/Collection)XyzJobs from
> > >> kdepimlibs/akonadi to load, modify and save the items and collections.
> > >>
> > >> So the first step is to use a CollectionFetchJob with the start
> > >> collection set to Collection::root() and type set to Recursive. Then
> > >> in the finish slot of this job you can trigger an ItemFetchJob for
> > >> every returned collection. Then you can iterate over all returned
> > >> items and filter out everything that has not the wanted mime type.
> >
> > Hi!
> >
> > I'm not sure if this would be the right approach, but you could use
> > Akonadi jobs to create, delete and modify alarms as suggested, but
> > then you could also at the same time use an items' model to maintain
> > an updated list of the alarms. This way in case if there' other
> > processes modifying the alarms you will get automatically the updates,
> > and you don't need to write the logic to get the alarms yourself. You
> > could inherit from Akonadi::ItemModel and watch for updates (connect
> > to signals like dataChanged, columnsInserted, columnsRemoved).
>
> Thanks to everybody for their advice - I've managed to make fetch and
> create Collections and AgentInstances now, but I have a few more questions
> which I can't find answers to in the docs. (I tried  on IRC, but at the
> time I could log on, there was no response.)
>
> 1) After creating an agent, the new collection containing it doesn't appear
> immediately, even using a QTimer:singleShot(0) before using
> CollectionFetchJob to fetch the Collection list again. How can one know
> when the collection list has been refreshed?

There is Akonadi::Monitor which informs you about every change that is 
happening. Knowing when something is "done" is difficult though in a highly 
async environment, so monitoring for changes is the perferred approach.

> 2) Does a collection always only contain items belonging to a single
> resource? The existence of the Collection::setResource() method appears to
> indicate this.

Yes. We are working on "virtual" collections though that will contain the 
result of a search query, which could include items from various resources.

> 3) Are ResourceBase-derived instances ever accessed by clients, or are they
> only for use the server, and clients always use Agent instances?
> Collection::resource() returns a resource identifier - is this really an
> Agent identifier? Else, how can this be used to fetch the actual resource?

Resources are a special case of an agent, therefore a resource identifier and 
an agent identifier are the same. Clients typically work on AgentInstance 
objects, the ResourceBase objects are used in the separate resource process 
and are only accessible via D-Bus by clients (which is rarely needed, but can 
be useful for eg. setting a pre-defined configuration).

> 4) The KAlarm resource can handle multiple mime types, but I need to set
> one specific mime type when I create an new agent instance (so that it will
> only contain that one mime type). Is this possible, or is it necessary to
> define multiple resources each handling a single mime type?

Resources can support multiple mimetypes, the Kolab one for example supports a 
whole bunch of them. There are two places where a resource can specify 
mimetypes, its desktop files and in the content mimetypes field of 
collections created by it. The ones in the desktop file are used for 
filtering agent types, eg. in the resource creation dialogs. The collection 
content mimetypes specify what you can actually put into a collection, which 
is not necessarily the same (eg. Kolab supports contacts and events, but not 
in the same folder).

regards
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20090907/0e3dd874/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