Akonadi: Lookup Contact by UID Help please
kraft at freisturz.de
kraft at freisturz.de
Sat Apr 8 10:30:02 BST 2017
Hi,
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.
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.
So I tried using the ItemFetchJob with this snippet:
===
void AddressProviderPrivate::lookupAddressee( const QString& uid )
{
Akonadi::Item item;
KContacts::Addressee adr;
adr.setUid(uid);
item.setPayload(adr);
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item);
connect(job, SIGNAL(result(KJob*)), SLOT(jobFinished(KJob*)));
job->fetchScope().fetchFullPayload();
job->start();
}
void AddressProviderPrivate::jobFinished(KJob *job)
{
if (job->error()) {
qDebug() << "Error occurred" << job->errorString();
return;
}
Akonadi::ItemFetchJob *fetchJob =
qobject_cast<Akonadi::ItemFetchJob*>(job);
...
}
===
Unfortunately that does not work, but throws this error:
Error occurred "Akonadi::Exception: No remote identifier specified"
Can anybody hint me how that can be fixed? Is there a better approach to
fetch Contacts by UID nowadays? Is there any code that does similar things?
Thanks for any help!
Klaas
More information about the kde-pim
mailing list