Akonadi: Lookup Contact by UID Help please
Sandro Knauß
sknauss at kde.org
Sat Apr 8 14:48:14 BST 2017
Hi Klaas,
> in my application Kraft [ http://volle-kraft-voraus.de/ ] which I just
> ported to KF5 I have a problem fetching contacts from Akonadi. Kraft
> stores UIDs as reference to the contacts in Akonadi and I need code that
> gets the contact out of Akonadi for a given UID.
Whoo great!
> In KDE4 times there was a class ContactSearchJob, but it seems that this
> is not working any more with UIDs because Baloo does not index the UIDs,
> at least that was mentioned somewhen on this list.
well this is not true anymore. You can search again for the UID with the
ContactSearchJob. The UID itsself is indexed.
So a normal ContactSearchJob should be fine to fire. There is ConactUid
parameter to match. An example how to use ContactSearchJob you'll find in
kdepim-addons/plugins/bodypartformatter/vcard/updatecontactjob.cpp
Keep in mind to set a good FetchScope, to only things you are interesting in,
this makes things much faster.
To make Kraft future save, I would you to suggest to port away from any use of
Akonadi::Item and instead use ContactSearchJob::contacts instead. Also
KContacts::Addressee should not leak deep into Kraft, so translate it at one
defined place into a internal representation of a Contact.
Because it helpes in some cases. here are some commands to perform a search on
the akonadi-search database by itself.
(UID is a actual UID of a contact):
# quest ~/.local/share/akonadi/search_db/contacts '"UID"'
Parsed Query: Query(UID at 1)
MSet:
899985: [5.80023]
# xapian-delve ~/.local/share/akonadi/search_db/contacts -r 899985
Term List for record #899985: C1402 NAknauß NAsandro de i9haczcdcz knauß mail
mail at sandroknauss.de sandro sandroknauss
-> as you see "i9haczcdcz" is the UID in my case for the contact
-> 899985 is the AkonadiID
Best regards,
sandro
More information about the kde-pim
mailing list