[Kde-pim] retrieving a resource from an akonadi:/ url
Daniel Vrátil
dvratil at kde.org
Wed Jun 29 08:30:14 BST 2016
On Wednesday, June 29, 2016 12:59:40 AM CEST Jos van den Oever wrote:
> On Wednesday 29 June 2016 00:46:02 Daniel Vrátil wrote:
> > On Tuesday, June 28, 2016 9:43:04 PM CEST Jos van den Oever wrote:
> > > I've now managed to get the complete payload. with QList<Item> I can get
> > > several items at a time. Performance is not an issue I'm worried about.
> > > The
> > > aim is to be able to link to mails from another application. I do not
> > > want
> > > to rely on akonadi identifiers. Luckily emails do not change, so I can
> > > use
> > > a checksum like sha1 as the reference.
> > >
> > > I've also tried Ingos suggestion to use removeId. For maildir, this
> > > gives
> > > the filename, but not the complete path. Perhaps
> > > setFetchRemoteIdentification(true) can help to get all collections
> > > remoteIds from which I can then build a path.
> >
> > setFetchRemoteIdenfitication() affects whether Item::remoteId() should be
> > retrieved or not, so that won't help you much. You could however enable
> > full ancestor retrieval, which will give you full chain of
> > Akonadi::Collections that the Item belongs to. You can then use the
> > Collection's remoteID to build a fully unique path.
>
> How would I get the collection from an Akonadi::Item after doing
> setAncestorRetrieval(Akonadi::ItemFetchScope::AncestorRetrieval::All) on
> Akonadi::ItemFetchJob(list, this)?
>
> The code below gives an empty string for collection.remoteId(). The
> displayName() is empty too.
>
> Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob*>(job);
> foreach (const Akonadi::Item &item, fetchJob->items()) {
> Akonadi::Item foo(item.remoteId());
> Akonadi::Collection collection(item.storageCollectionId());
Don't use item.storageCollectionId(), use item.prentCollection() right away.
Only that way you'll get the entire ancestor chain.
> while (collection.isValid()) {
> qDebug() << "parent: " << collection.id() << " " <<
> collection.remoteId();
> collection = collection.parentCollection();
> }
> }
>
> Also, only one parent is retrieved, even when the mail comes from a nested
> folder.
>
> > However using remoteID with maildir has one big problem: maildir actually
> > encodes flags (like the "seen" flag) into the file name, so when user
> > marks
> > an email as read (or changes some other flags), the file name changes and
> > thus the remoteID changes. In this case Akonadi ID is actually more
> > stable.
>
> Good point. The checksum would also remain the same. To use that for
> retrieval would require yet another index. I do not see any other way to
> make a good permanent identifier for use outside akonadi.
If your application is long-running, you can spawn an Akonadi::Monitor to be
notified about any change in the watched emails/folders, allowing you to learn
about added/removed emails and to update your identifier in case of change or
move.
On each start you can do a new ItemFetchJob with
ItemFetchScope::setFetchChangedSince() to only get a list of Items that
changed (were added, updated or moved) since the given timestamp to update
your index. Unfortunately, no way to get a list of removed Items this way....
Dan
>
> Cheers,
> Jos
>
>
>
> _______________________________________________
> 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/
--
Daniel Vrátil
www.dvratil.cz | dvratil at kde.org
IRC: dvratil on Freenode (#kde, #kontact, #akonadi, #fedora-kde)
GPG Key: 0x4D69557AECB13683
Fingerprint: 0ABD FA55 A4E6 BEA9 9A83 EA97 4D69 557A ECB1 3683
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20160629/6160adcc/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