[Kde-pim] akonadiserver remembers collection context between fetch and delete

David Faure faure at kde.org
Wed Jun 24 17:29:28 BST 2015


From an akonadi resource, I do on startup:

  Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(collection1);
  [...]

And much much later on, completely unrelated to that, when I want to handle 
deletion of an item in another collection (say collection2), I do :

  itemsRetrievedIncremental(Item::List(), deletedItems);

which leads to ItemSync doing an ItemDeleteJob(deletedItems).
The thing is, these items have a remote ID, but no ID.
I would have to run another job just to get the ID from the remote ID, that 
seems overkill. Especially since akonadiserver does support RID REMOVE :)

The problem: akonadiserver doesn't find the item from its RID, because it's 
still looking into collection1.

Remove::parseStream() starts with 
connection()->context()->collectionId() == collection1
and doesn't change that in parseContext, since the command contains no 
collection context. So it queries for RID in collection1, and fails.

RID REMOVE ("f305c49b-5575-4130-821d-526e80a81596") 
NO No items found 

Why does akonadiserver remember the initially listed collection as context?
I suppose because of the stateful IMAP SELECT stuff? It seems inappropriate 
here...

What can I do to work around this? I see a CollectionSelectJob in 
kdepimlibs/akonadi but it's deprecated and not installed anymore - 
understandably, since this statefulness is what's giving me trouble in the 
first place.

Should ItemDeleteJob pass along the collection of the item, rather than just 
the remote id? Or is that not supported by the imap RID REMOVE syntax?
(I see ProtocolHelper::commandContextToByteArray takes a collection, but for 
ItemDeleteJob, that seems to mean "delete this entire collection", right?)

Unless I'm missing something, I guess my only solution is to find out the 
actual id() of the items :(

PS: this is with Qt4, akonadi 1.13, I'm targetting 70 Qt4/kde4 users, can't 
use Qt5/KF5 yet for this.

-- 
David Faure, faure at kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5

_______________________________________________
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