From 8e094ba1c963caacdafd9c728f9c4c5ba7a46492 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Wed, 28 Jan 2009 15:06:58 -0400 Subject: [PATCH] Reporting each google contact XML to akonadi (I guess it will need a format plugin to handle it?). --- googledataresource.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/googledataresource.cpp b/googledataresource.cpp index 817ac7b..d344f64 100644 --- a/googledataresource.cpp +++ b/googledataresource.cpp @@ -46,6 +46,9 @@ void googledataResource::retrieveItems( const Akonadi::Collection &collection ) Item::List items; int result; + /* Downloading the contacts can be slow and it is blocking. Will + * it mess up with akonadi? + */ if ((result = gcal_get_contacts(gcal, &all_contacts))) exit(1); @@ -62,14 +65,29 @@ void googledataResource::retrieveItems( const Akonadi::Collection &collection ) bool googledataResource::retrieveItem( const Akonadi::Item &item, const QSet &parts ) { - Q_UNUSED( item ); Q_UNUSED( parts ); + const QString entry_id = item.remoteId(); + QString xml_entry; + /* I assume that here I can report the atom::entry data? + */ + Item newItem(item); + gcal_contact_t contact; - // TODO: this method is called when Akonadi wants more data for a given item. - // You can only provide the parts that have been requested but you are allowed - // to provide all in one go + /* + * And another question, are the requests in the same sequence that + * I informed in 'retrieveItems'? For while, I try to locate the entry... + */ + for (size_t i = 0; i < all_contacts.length; ++i) { + contact = gcal_contact_element(&all_contacts, i); + if (entry_id == gcal_contact_get_id(contact)) { + xml_entry = gcal_contact_get_xml(contact); + newItem.setPayload(xml_entry); + return true; + } + + } - return true; + return false; } void googledataResource::aboutToQuit() -- 2.11.4.GIT