From d40e46683d1ded43fe413bc65119731719dd0eec Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Wed, 28 Jan 2009 14:54:48 -0400 Subject: [PATCH] Adding code to retrieve a user contact list. --- googledataresource.cpp | 21 ++++++++++++++++----- googledataresource.h | 4 ++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/googledataresource.cpp b/googledataresource.cpp index ce86a06..817ac7b 100644 --- a/googledataresource.cpp +++ b/googledataresource.cpp @@ -29,6 +29,7 @@ googledataResource::googledataResource( const QString &id ) googledataResource::~googledataResource() { gcal_delete(gcal); + gcal_cleanup_contacts(&all_contacts); } void googledataResource::retrieveCollections() @@ -42,11 +43,21 @@ void googledataResource::retrieveItems( const Akonadi::Collection &collection ) { Q_UNUSED( collection ); - // TODO: this method is called when Akonadi wants to know about all the - // items in the given collection. You can but don't have to provide all the - // data for each item, remote ID and MIME type are enough at this stage. - // Depending on how your resource accesses the data, there are several - // different ways to tell Akonadi when you are done. + Item::List items; + int result; + + if ((result = gcal_get_contacts(gcal, &all_contacts))) + exit(1); + + /* Each google entry has a unique ID and edit_url */ + for (size_t i = 0; i < all_contacts.length; ++i) { + + Item item(QLatin1String("what_is_the_mime_type?")); + gcal_contact_t contact = gcal_contact_element(&all_contacts, i); + item.setRemoteId(gcal_contact_get_id(contact)); + } + + itemsRetrieved(items); } bool googledataResource::retrieveItem( const Akonadi::Item &item, const QSet &parts ) diff --git a/googledataresource.h b/googledataresource.h index 4a11df3..cd904a8 100644 --- a/googledataresource.h +++ b/googledataresource.h @@ -4,6 +4,7 @@ #include extern "C" { #include +#include } class googledataResource : public Akonadi::ResourceBase, @@ -29,7 +30,10 @@ protected: virtual void itemChanged( const Akonadi::Item &item, const QSet &parts ); virtual void itemRemoved( const Akonadi::Item &item ); + /* Google data context: holds user account name/password */ gcal_t gcal; + /* Contact array */ + struct gcal_contact_array all_contacts; }; #endif -- 2.11.4.GIT