[Kde-pim] Query KDE Addressbook

Klaas Freitag freitag at kde.org
Thu Jul 14 21:55:45 BST 2011


Hi,

I use the following code snippet to query a contact from the addressbook
identified by UID:

start search:

Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob( this );
// job->setLimit( 100 );
job->setQuery( Akonadi::ContactSearchJob::ContactUid , uid );

connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchResult( KJob* ) ) 
);

job->start();


============
search Result:

void AddressProvider::searchResult( KJob* job )
{
Akonadi::ContactSearchJob *searchJob = 
qobject_cast<Akonadi::ContactSearchJob*>( job );

  if( searchJob->error() ) {
    kDebug() << "Address search job failed: " << job->errorString();
    return;
  }

  const KABC::Addressee::List contacts = searchJob->contacts();
  kDebug() << "Found list of " << contacts.size() << " addresses as search 
result";

===========

The problem is that in searchResult, no error happens, but the 
KABC::Addressee::List contacts is empty, ie. has a size of zero.
The address is in the address book, with the searched UID, as I can
verify in akonadiconsole!

How can that happen?

Thanks,

klaas
_______________________________________________
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