From 25fadd03cb0472607777ef468ba506ac63097840 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Tue, 3 Feb 2009 13:39:24 -0400 Subject: [PATCH] Hacking a way to get contacts data into akonadi: I'm reporting the payload in the retrieveItems. --- googledataresource.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/googledataresource.cpp b/googledataresource.cpp index 75289c2..cf73d48 100644 --- a/googledataresource.cpp +++ b/googledataresource.cpp @@ -17,6 +17,14 @@ extern "C" { #include } + +/** FIXME: for some reason the 'retrieveItem' functions is not being called. + * this makes the entries to lack its contents (name, email, etc). + * I should investigate why and fix, for while this is a workaround: + * I report the payload in the 'retrieveItems' function. + */ +#define ITEM_BUG_WTF + using namespace Akonadi; GoogleDataResource::GoogleDataResource( const QString &id ) @@ -94,11 +102,36 @@ void GoogleDataResource::retrieveItems( const Akonadi::Collection &collection ) /* Each google entry has a unique ID and edit_url */ for (size_t i = 0; i < all_contacts.length; ++i) { - Item item(QLatin1String("text/directory")); gcal_contact_t contact = gcal_contact_element(&all_contacts, i); + +#ifdef ITEM_BUG_WTF + KABC::Addressee addressee; + KABC::PhoneNumber number; + KABC::Key key; + QString temp; + + /* name */ + temp = gcal_contact_get_title(contact); + addressee.setNameFromString(temp); + /* email */ + temp = gcal_contact_get_email(contact); + addressee.insertEmail(temp, true); + /* edit url: required to do edit/delete */ + temp = gcal_contact_get_url(contact); + addressee.setUid(temp); + /* ETag: required by Google Data protocol 2.0 */ + temp = gcal_contact_get_etag(contact); + key.setId(temp); + addressee.insertKey(key); + /* TODO: telefone, address, etc */ + + item.setPayload(addressee); +#endif + item.setRemoteId(gcal_contact_get_id(contact)); + items << item; } -- 2.11.4.GIT