[Kde-pim] Re: Handling external updates for an Akonadi resource

Kevin Krammer kevin.krammer at gmx.at
Mon Feb 28 10:04:49 GMT 2011


On Monday, 2011-02-28, David Jarvie wrote:
> On Mon, February 28, 2011 9:42 am, Kevin Krammer wrote:
> > On Monday, 2011-02-28, David Jarvie wrote:
> >> Can somebody tell me how an Akonadi resource can notify the server that
> >> unsolicited updates have occurred. In writing the KAlarm directory
> >> resource (1 file per alarm), I want the resource to update whenever
> >> externally triggered changes occur to files in the directory
> >> (creations/changes/deletions). The resource sees these via KDirWatch
> >> signals, but I can't find a way of telling the server about the changes
> >> (via synchronize(), itemsRetrievedIncremental() etc) which doesn't
> >> result
> >> in either no update occurring or a full resynchronisation. In these
> >> cases,
> >> only the single file/alarm affected should be updated in the server - it
> >> shouldn't result in a complete reload of all files.
> > 
> > I think you can use an ItemModifyJob for that, just like any application
> > would modify an item in Akonadi.
> > As a resource you don't have to get the item from Akonadi first, you can
> > address it using remoteId for item the item's parent collection.
> 
> Thanks, Kevin. I never thought of a resource being able to use jobs, but
> that sounds a plausible way of doing it.

Indeed. The resource base code acutally uses jobs internally, the wrapper is 
more or less a convenience thing for common operations, so a resource 
developer doesn't have to care about them for the basic operations.
(and some resource won't need anything more than those basic operations).

> > Do you have a collection hierachy or only one top level collection
> > containing the items?
> 
> The resource contains just one collection.

In this case it should be rather simple.
Basically create the minimum collection and the minimum item and the create 
the item modify job with that

// just like when creating the instance for retrieveCollections, e.g.
Collection collection;
collection.remoteId("whatever");
collection.setParentCollection( Collection::root() );

Item item( "your/mimetype" );
item.setParentCollection( collection );

// payload, maybe modify remoteRevision

ItemModifyJob *job = new ItemModifyJob( item );

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/20110228/0594e077/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