[Kde-pim] retrieving a resource from an akonadi:/ url

Jos van den Oever jos at vandenoever.info
Wed Jun 29 01:59:40 BST 2016


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());
        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.

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/


More information about the kde-pim mailing list