[Kde-pim] Re: How can a resource identify its Collection?

David Jarvie djarvie at kde.org
Thu Mar 24 23:33:38 GMT 2011


On Wednesday 02 March 2011 17:48:08 Kevin Krammer wrote:
> On Wednesday, 2011-03-02, David Jarvie wrote:
> > In a resource which only has a single Collection, how can the resource
> > identify its Collection so that it can call ItemCreateJob, ItemModifyJob
> > etc on the collection? The remote id of the collection is known, but not
> > the Akonadi id.
> > 
> > Following Kevin's suggestion, I tried the following code to create a new
> > item within the resource, but the the job returns with the error
> >     "Unknown error. (Unknown collection.)"
> > 
> > Collection c;
> > c.setParentCollection(Collection::root());
> > c.setRemoteId(directoryName());
> > Item item;
> > // ... set item mime type and payload
> > item.setParentCollection(c);
> > ItemCreateJob* job = new ItemCreateJob(item, c);
> > 
> > I checked with debug output that the remote ID for the collection is the
> > same as in the Akonadi database. I wonder if something else has to be done
> > to enable collections to be found by their remote IDs?
> 
> I assumed this would work, i.e. a resource being allowed to address its 
> entities by remoteId :(
> But it seems that at least the ItemCreateJob always uses the collection.id() 
> when sending the APPEND command.
> 
> Seems you have to fetch your root collection once, but maybe Volker has 
> another idea?

I've found that the following will alow the collection ID for the resource to be determined (for resources which have only one collection):

CollectionFetchJob* job = new CollectionFetchJob(Collection::root(), CollectionFetchJob::FirstLevel);
job->fetchScope().setResource(identifier());

The collectionsReceived() slot provides access to the returned collection, and its ID.

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20110324/c68d0f60/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