enum EDSContactsStorageItemIterator::eCursorInit EDSContactsStorageItemIterator::cursorInit(EBookClient* c)
{
  LOG_FUNC();

  GError *gerror = NULL;

  EContactField sort_fields[]      = { E_CONTACT_FULL_NAME };
  EBookCursorSortType sort_types[] = { E_BOOK_CURSOR_SORT_ASCENDING };

  e_book_client_get_cursor_sync(c, NULL, sort_fields, sort_types, 1, &cursor, NULL, &gerror);

  if (NULL != gerror)
  {
    LOG_ERROR() << "Error e_book_client_get_cursor_sync results: " << GERROR_MESSAGE(gerror)<<std::endl ;
    GERROR_FREE(gerror);
    return eCursorInitFail;
  }

  total = e_book_client_cursor_get_total(cursor);
  LOG_VERBOSE() << "Number of contacts: " << total <<std::endl;

  GERROR_FREE(gerror);

  return eCursorInitOK;
}
/*
 * Create an EBookClient cursor sorted by family name, and then by given name as
 * the secondary sort key.
 */
static EBookClientCursor *
get_cursor (EBookClient *book_client)
{
  EContactField sort_fields[] = { E_CONTACT_FAMILY_NAME, E_CONTACT_GIVEN_NAME };
  EBookCursorSortType sort_types[] = { E_BOOK_CURSOR_SORT_ASCENDING, E_BOOK_CURSOR_SORT_ASCENDING };
  EBookClientCursor *cursor = NULL;
  GError *error = NULL;

  if (!e_book_client_get_cursor_sync (book_client,
				      NULL,
				      sort_fields,
				      sort_types,
				      2,
				      &cursor,
				      NULL,
				      &error)) {
	  g_warning ("Unable to create cursor");
	  g_clear_error (&error);
  }

  return cursor;
}