OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CalDAVHelper Class Reference

Documentation for class CalDAVHelper. This class implements CalDAV client using libcurl. More...

#include <CalDAVHelper.hpp>

Classes

class  CalendarInfo
 Class describing calendar. More...
 
struct  EventMetadata
 Simple struct describing items in metadata. More...
 

Public Types

enum  CalendarItemTypes { EVENT = 0, TODO, JOURNAL }
 
typedef std::vector
< EventMetadata
EventsMetadata
 
typedef std::vector< CalendarInfoCalendars
 

Public Member Functions

 CalDAVHelper (const std::string &serverUrl, bool isCalendarUrl, OpenAB::HttpSession *httpSession, OpenAB::HttpAuthorizer *httpAuthorizer)
 Constructor. More...
 
virtual ~CalDAVHelper ()
 Destructor, virtual by default. More...
 
bool findPrincipalUrl ()
 Queries principal url - url used by given user to send CalDAV requests. More...
 
bool findCalendarHomeSet ()
 Queries address book set - url that can be further queried about user calendars details.. More...
 
bool findCalendars ()
 Queries calendars information. Queried information about calendars can be obtained by getCalendars, for each calendar information like display name and supported items type is queried. More...
 
bool queryCalendarInfo (const std::string &calendarURL, CalendarInfo &info)
 Queries calendar infromation. In opposite to findCalendars, this function queries detailed information about given calendar and return them directly to caller. This function won't alter results of getCalendars function. More...
 
bool queryCalendarMetadata (const std::string &calendarURL)
 Queries calendar metadata (current revision and sync token). After calling this function sync token can be obtained by using getSyncToken(). More...
 
bool queryEventsMetadata (const std::string &calendarURL)
 Queries events/tasks metadata (list of IDs and revisions). After calling this function metadata can be obtained by using getContactsMetadata() and getTotalCount(). More...
 
bool queryChangedEventsMetadata (const std::string &calendarURL, const std::string &syncToken, std::vector< OpenAB::PIMItem::ID > &removed)
 Queries only metadata of events/tasks that were modified since provided sync token was created. After calling this function metadata can be obtained by using getEventsMetadata() and getTotalCount(). More...
 
bool downloadEvents (const std::string &calendarURL, unsigned int offset, unsigned int size, std::vector< std::string > &icals)
 Downloads iCalendar objects from metadata. More...
 
bool downloadEvents (const std::string &calendarURL, std::vector< std::string > &uris, std::vector< std::string > &icals)
 Downloads iCalendar objects with given uris. More...
 
bool addEvent (const std::string &calendarURL, const std::string &ical, std::string &uri, std::string &etag)
 Creates new event/task. More...
 
bool removeEvent (const std::string &uri, const std::string &etag="")
 Removes event/task. More...
 
bool modifyEvent (const std::string &uri, const std::string &ical, std::string &etag)
 Modifies event/task. More...
 
unsigned int getTotalCount () const
 Returns total count of items in metadata downlaoded by queryEventsMetadata or queryChangedEventsMetadata. More...
 
std::string getSyncToken () const
 Returns sync token queried by queryCalendarMetadata(). More...
 
EventsMetadata getEventsMetadata () const
 Returns contacts metadata downlaoded by queryContactsMetadata or queryChangedEventsMetadata. More...
 
Calendars getCalendars () const
 Returns list of available calendars. More...
 

Detailed Description

Documentation for class CalDAVHelper. This class implements CalDAV client using libcurl.

Member Typedef Documentation

typedef std::vector<CalendarInfo> CalDAVHelper::Calendars

Member Enumeration Documentation

Enumerator
EVENT 
TODO 
JOURNAL 

Constructor & Destructor Documentation

CalDAVHelper::CalDAVHelper ( const std::string &  serverUrl,
bool  isCalendarUrl,
OpenAB::HttpSession httpSession,
OpenAB::HttpAuthorizer httpAuthorizer 
)

Constructor.

Parameters
[in]serverUrladdress of CalDAV server or direct address of calendar to be used.
[in]isCalendarUrlindicates if url provided as serverUrl is calendar url or server url.
[in]httpSessionCURL http session object to be used for HTTP requests.
[in]httpAuthorizerinitialized httpAuthorizer required by given server.
CalDAVHelper::~CalDAVHelper ( )
virtual

Destructor, virtual by default.

Member Function Documentation

bool CalDAVHelper::addEvent ( const std::string &  calendarURL,
const std::string &  ical,
std::string &  uri,
std::string &  etag 
)

Creates new event/task.

Note
Provided iCalendar object needs to have UID field set. It is up to caller of this function to ensure that new object UID is unique on the server (otherwise server will reject request).
Parameters
[in]calendarURLcalendar to be used.
[in]icaliCalendar object to be created.
[out]uriURI of newly created item.
[out]etagrevision of newly created item.
Returns
true if item was created successfully, false otherwise (e.g. provided iCalendar couldn't be parsed, it didn't contain UID or UID already exists on server).
bool CalDAVHelper::downloadEvents ( const std::string &  calendarURL,
unsigned int  offset,
unsigned int  size,
std::vector< std::string > &  icals 
)

Downloads iCalendar objects from metadata.

Parameters
[in]calendarURLcalendar to be used.
[in]offsetoffset of events/tasks in metadata.
[in]sizenumber of events/tasks to be downloaded.
[out]icalsdownloaded iCalendar objects in the same order as in metadata.
Note
before calling this either queryEventsMetadata or queryChangedEventsMetadata needs to be called to populate metadata information. This function is preferable way of downloading all contents off calendar in batches.
Returns
true if objects were downloaded successfully.
bool CalDAVHelper::downloadEvents ( const std::string &  calendarURL,
std::vector< std::string > &  uris,
std::vector< std::string > &  icals 
)

Downloads iCalendar objects with given uris.

Parameters
[in]calendarURLcalendar to be used.
[in]urislist of iCalendar uri (from EventMetadata) to be downloaded.
[out]icalsdownloaded iCalendar list in the same order as provided uris.
Returns
true if objects were downloaded successfully.
bool CalDAVHelper::findCalendarHomeSet ( )

Queries address book set - url that can be further queried about user calendars details..

Note
: If direct URL for calendar was not provided, it should be called after findPrincipalUrl and before findCalendars.
Returns
true if calendar home set was found successfully, false otherwise.
bool CalDAVHelper::findCalendars ( )

Queries calendars information. Queried information about calendars can be obtained by getCalendars, for each calendar information like display name and supported items type is queried.

Note
: If direct URL for calendar was not provided, it should be called after findAddressbookSet and before queryCalendarMetadata.
Returns
true if calendars were found successfully, false otherwise.
bool CalDAVHelper::findPrincipalUrl ( )

Queries principal url - url used by given user to send CalDAV requests.

Note
If direct URL for calendar was not provided, it needs to be called before calling other functions from this class.
Returns
true if principal URL was found successfully, false otherwise.
Calendars CalDAVHelper::getCalendars ( ) const
inline

Returns list of available calendars.

Returns
list of available calendars.
EventsMetadata CalDAVHelper::getEventsMetadata ( ) const
inline

Returns contacts metadata downlaoded by queryContactsMetadata or queryChangedEventsMetadata.

Note
that calls to queryContactsMetadata and queryChangedEventsMetadata will overwrite results.
Returns
events/tasks metadata.
std::string CalDAVHelper::getSyncToken ( ) const
inline

Returns sync token queried by queryCalendarMetadata().

Returns
sync token
unsigned int CalDAVHelper::getTotalCount ( ) const
inline

Returns total count of items in metadata downlaoded by queryEventsMetadata or queryChangedEventsMetadata.

Returns
total count of events/tasks in metadata.
bool CalDAVHelper::modifyEvent ( const std::string &  uri,
const std::string &  ical,
std::string &  etag 
)

Modifies event/task.

Note
: there is no need to provide calendar URL as it will be part of item URI
Parameters
[in]uriid of item to be updated.
[in]icaliCalendar object to be uploaded.
[out]etagnew revision of updated item.
Returns
true if item was modified successfully.
bool CalDAVHelper::queryCalendarInfo ( const std::string &  calendarURL,
CalendarInfo info 
)

Queries calendar infromation. In opposite to findCalendars, this function queries detailed information about given calendar and return them directly to caller. This function won't alter results of getCalendars function.

Parameters
[in]calendarURLurl of calendar which details should be queried
[out]infoCalendarInfo structure filled with calendar details.
Returns
true if calendar details were queried successfully, false otherwise.
bool CalDAVHelper::queryCalendarMetadata ( const std::string &  calendarURL)

Queries calendar metadata (current revision and sync token). After calling this function sync token can be obtained by using getSyncToken().

Parameters
[in]calendarURLcalendar to be queried.
Returns
true if address book metadata was queried successfully, false otherwise.
bool CalDAVHelper::queryChangedEventsMetadata ( const std::string &  calendarURL,
const std::string &  syncToken,
std::vector< OpenAB::PIMItem::ID > &  removed 
)

Queries only metadata of events/tasks that were modified since provided sync token was created. After calling this function metadata can be obtained by using getEventsMetadata() and getTotalCount().

Parameters
[in]calendarURLcalendar to be queried.
[in]syncTokenlast synchronization token
[out]removedlist of removed items from server
Returns
true if metadata was queried successfully, false otherwise.
bool CalDAVHelper::queryEventsMetadata ( const std::string &  calendarURL)

Queries events/tasks metadata (list of IDs and revisions). After calling this function metadata can be obtained by using getContactsMetadata() and getTotalCount().

Parameters
[in]calendarURLcalendar to be queried.
Returns
true if contacts metadata was queried successfully, false otherwise.
bool CalDAVHelper::removeEvent ( const std::string &  uri,
const std::string &  etag = "" 
)

Removes event/task.

Note
: there is no need to provide calendar URL as it will be part of item URI
Parameters
[in]uriid of item to be removed.
[in]etagrevision of item to be removed, if revision of given item does not match on the server, removal will fail (not all servers supports that).
Returns
true if contact was removed successfully.

The documentation for this class was generated from the following files: