[Kde-pim] Changing UID of a newly created Akonadi::Item

Kevin Krammer kevin.krammer at gmx.at
Wed Nov 23 12:25:15 GMT 2011


Hi Dan,

CC'ing kde-pim

On Tuesday, 2011-11-22, Dan Vratil wrote:
> Hi guys,
> 
> I'd like to ask you for help, because I am probably doing something wrong
> in my Akonadi resource, but I can't find out what it is :).
> 
> During development of the akonadi-google resource, I run into a problem
> with UIDs of newly created items. When I create a new event (but applies
> for contacts as well) in KOrganizer, itemAdded() in the resource is
> invoked and Akonadi::Item with the event is passed to the slot. The event
> has a generic UID assigned by Akonadi. The resource then serializes the
> Akonadi::Item payload to JSON, sends request to Google API and waits for
> reply. When the reply comes, it contains data of the newly created event +
> some more information Google added - including ID of the event in Google's
> calendar.
> 
> When the reply is received, the resource does this:
> 
> Item item = reply->request()->property("Item").value<Item>(); // This is
> the Akonadi::Item I received in itemAdded()
> Object::Event *event = static_cast<Object::Event*>(data.first()); // Parsed
> data received from Google
> item.setRemoteId(event->uid()); // set remoteID to match ID of the
> incidence in Google's calendar
> item.setRemoteRevision(event->etag());
> item.setPayload(EventPtr(event)); // set the received data as a new payload
> changeCommitted(item); // commit the change
> 
> Despite the fact, that I assigned a new payload which contains
> UID='some-id- google-gave-me' and committed it, the item still has the
> generic UID assigned by Akonadi. And this is the problem, because when I
> want to update the event the serializer takes the payload but uses the
> incorrect UID (the Akonadi's one) and Google then complains about unknown
> event.

So the problem is that the payload is not changed?
Try running Akonadiconsole when doing that and enable the debugger (tab 
Debugger). It shows the actual data transfer between Akonadiserver and its 
clients, so you could check if the new payload is sent correctly.

> So my question is, what am I doing wrong and how can I overwrite the
> Akonadi's generic UID?
> 
> I'm sometimes getting similar warnings in .xsession-errors:
> 
> plasma-desktop(5193)/plasma: Ignoring item. item.id() = 1879 ; cached id =
> 0 ; item uid = "MDg5MjIwMDc5Mzg2MDE1MDg3NzY6MDoxODUyMjExNjE0" ; calendar =
> "" ; existed in cache = false ; storageCollection.id() = 24 ;
> parentCollection.id() = 24 ; hasParent = false ; knowParent = false
>  plasma-desktop(5193)/plasma: Possible cause is that the resource isn't
> explicitly setting an uid ( and a random one is generated )
> 
> This makes me assume  that I am supposed to replace the generic ID by my
> own, yet I don't know how :)

Even a generic ID in the payload should be fine for whatever is looking at the 
payload.
Usually the application creating an event is setting the UID.
Most resources don't need to change the payload at all (they just save and 
load the data as it is).

I think this is unrelated to your other problem. For this one check if the 
payload has an UID. If not whatever program created it should have set one.

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/20111123/34a2a1e1/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