EvolutionCalendarSource Class Reference

#include <EvolutionCalendarSource.h>

Inheritance diagram for EvolutionCalendarSource:

Inheritance graph
[legend]
Collaboration diagram for EvolutionCalendarSource:

Collaboration graph
[legend]

List of all members.

Classes

class  ItemID

Public Member Functions

 EvolutionCalendarSource (ECalSourceType type, const EvolutionSyncSourceParams &params)
 EvolutionCalendarSource (const EvolutionCalendarSource &other)
virtual ~EvolutionCalendarSource ()
virtual Databases getDatabases ()
virtual void open ()
virtual void close ()
virtual void exportData (ostream &out)
virtual string fileSuffix () const
virtual const char * getMimeType () const
virtual const char * getMimeVersion () const
virtual const char * getSupportedTypes () const
virtual SyncItem * createItem (const string &luid)

Protected Types

typedef list
< boost::shared_ptr< eptr
< icalcomponent > > > 
ICalComps_t

Protected Member Functions

virtual void listAllItems (RevisionMap_t &revisions)
virtual InsertItemResult insertItem (const string &luid, const SyncItem &item)
virtual void setItemStatusThrow (const char *key, int status)
virtual void deleteItem (const string &luid)
virtual void logItem (const string &luid, const string &info, bool debug=false)
virtual void logItem (const SyncItem &item, const string &info, bool debug=false)
icalcomponent * retrieveItem (const ItemID &id)
string retrieveItemAsString (const ItemID &id)
icalcomponent_kind getCompType ()
char * authenticate (const char *prompt, const char *key)
string getLUID (ECalComponent *ecomp)
ItemID getItemID (ECalComponent *ecomp)
ItemID getItemID (icalcomponent *icomp)
string getItemModTime (ECalComponent *ecomp)
string getItemModTime (const ItemID &id)
string icalTime2Str (const struct icaltimetype &tt)
ICalComps_t removeEvents (const string &uid, bool returnOnlyChildren)

Static Protected Member Functions

static char * eCalAuthFunc (ECal *ecal, const char *prompt, const char *key, gpointer user_data)

Protected Attributes

eptr< ECal, GObject > m_calendar
ECalSourceType m_type
string m_typeName
ECal *(* m_newSystem )(void)
set< string > m_allLUIDs


Detailed Description

Implements access to Evolution calendars, either using the to-do item or events. Change tracking is done by looking at the modification time stamp. Recurring events and their detached recurrences are handled as one item for the main event and one item for each detached recurrence.

Definition at line 36 of file EvolutionCalendarSource.h.


Member Typedef Documentation

typedef list< boost::shared_ptr< eptr<icalcomponent> > > EvolutionCalendarSource::ICalComps_t [protected]

A list of ref-counted smart pointers to icalcomponents. The list members can be copied; destroying the last instance will destroy the smart pointer, which then calls icalcomponent_free().

Definition at line 185 of file EvolutionCalendarSource.h.


Constructor & Destructor Documentation

EvolutionCalendarSource::EvolutionCalendarSource ( ECalSourceType  type,
const EvolutionSyncSourceParams params 
)

Parameters:
type chooses which kind of calendar data to use: E_CAL_SOURCE_TYPE_TODO, E_CAL_SOURCE_TYPE_JOURNAL, E_CAL_SOURCE_TYPE_EVENT

Definition at line 54 of file EvolutionCalendarSource.cpp.

EvolutionCalendarSource::EvolutionCalendarSource ( const EvolutionCalendarSource other  ) 

virtual EvolutionCalendarSource::~EvolutionCalendarSource (  )  [inline, virtual]

Definition at line 48 of file EvolutionCalendarSource.h.

References close().


Member Function Documentation

char * EvolutionCalendarSource::authenticate ( const char *  prompt,
const char *  key 
) [protected]

actual implementation of ECalAuthFunc

Definition at line 117 of file EvolutionCalendarSource.cpp.

References EvolutionSyncSource::getName(), and EvolutionSyncSourceConfig::getPassword().

void EvolutionCalendarSource::close (  )  [virtual]

closes the data source so that it can be reopened

Just as open() it should not affect the state of the database unless some previous action requires it.

Implements TrackingSyncSource.

Definition at line 197 of file EvolutionCalendarSource.cpp.

References m_calendar, and EvolutionSyncSource::sleepSinceModification().

Referenced by ~EvolutionCalendarSource().

SyncItem * EvolutionCalendarSource::createItem ( const string &  uid  )  [virtual]

Extract information for the item identified by UID and store it in a new SyncItem. The caller must free that item. May throw exceptions.

Parameters:
uid identifies the item

Implements TrackingSyncSource.

Reimplemented in EvolutionMemoSource.

Definition at line 239 of file EvolutionCalendarSource.cpp.

References logItem(), and retrieveItemAsString().

void EvolutionCalendarSource::deleteItem ( const string &  uid  )  [protected, virtual]

static char* EvolutionCalendarSource::eCalAuthFunc ( ECal *  ecal,
const char *  prompt,
const char *  key,
gpointer  user_data 
) [inline, static, protected]

ECalAuthFunc which calls the authenticate() methods

Definition at line 129 of file EvolutionCalendarSource.h.

Referenced by open().

void EvolutionCalendarSource::exportData ( ostream &  out  )  [virtual]

exports all items one after the other, separated by blank line; if that format is not suitable, then the derived class must override this call

Reimplemented from TrackingSyncSource.

Definition at line 219 of file EvolutionCalendarSource.cpp.

References getItemID(), m_calendar, retrieveItemAsString(), and EvolutionSyncSource::throwError().

virtual string EvolutionCalendarSource::fileSuffix (  )  const [inline, virtual]

file suffix for database files

Implements TrackingSyncSource.

Definition at line 57 of file EvolutionCalendarSource.h.

icalcomponent_kind EvolutionCalendarSource::getCompType (  )  [inline, protected]

returns the type which the ical library uses for our components

Definition at line 122 of file EvolutionCalendarSource.h.

References m_type.

Referenced by insertItem().

EvolutionSyncSource::Databases EvolutionCalendarSource::getDatabases (  )  [virtual]

returns a list of all know sources for the kind of items supported by this sync source

Implements TrackingSyncSource.

Definition at line 87 of file EvolutionCalendarSource.cpp.

References eptr< T, base, R >::get(), m_type, and EvolutionSyncSource::throwError().

EvolutionCalendarSource::ItemID EvolutionCalendarSource::getItemID ( icalcomponent *  icomp  )  [protected]

Definition at line 714 of file EvolutionCalendarSource.cpp.

References icalTime2Str().

EvolutionCalendarSource::ItemID EvolutionCalendarSource::getItemID ( ECalComponent *  ecomp  )  [protected]

Extract item ID from calendar item. An icalcomponent must refer to the VEVENT/VTODO/VJOURNAL component.

Definition at line 705 of file EvolutionCalendarSource.cpp.

References EvolutionSyncSource::throwError().

Referenced by exportData(), EvolutionMemoSource::insertItem(), insertItem(), and listAllItems().

string EvolutionCalendarSource::getItemModTime ( const ItemID id  )  [protected]

Extract modification string of an item stored in the calendar.

Returns:
empty string if no time was available

Definition at line 737 of file EvolutionCalendarSource.cpp.

References icalTime2Str(), and retrieveItem().

string EvolutionCalendarSource::getItemModTime ( ECalComponent *  ecomp  )  [protected]

Extract modification string from calendar item.

Returns:
empty string if no time was available

Definition at line 725 of file EvolutionCalendarSource.cpp.

References icalTime2Str().

Referenced by EvolutionMemoSource::insertItem(), insertItem(), and listAllItems().

string EvolutionCalendarSource::getLUID ( ECalComponent *  ecomp  )  [protected]

Returns the LUID of a calendar item.

Referenced by retrieveItem(), and retrieveItemAsString().

virtual const char* EvolutionCalendarSource::getMimeType (  )  const [inline, virtual]

Returns the preferred mime type of the items handled by the sync source. Example: "text/x-vcard"

Implements TrackingSyncSource.

Reimplemented in EvolutionMemoSource.

Definition at line 58 of file EvolutionCalendarSource.h.

virtual const char* EvolutionCalendarSource::getMimeVersion (  )  const [inline, virtual]

Returns the version of the mime type used by client. Example: "2.1"

Implements TrackingSyncSource.

Reimplemented in EvolutionMemoSource.

Definition at line 59 of file EvolutionCalendarSource.h.

virtual const char* EvolutionCalendarSource::getSupportedTypes (  )  const [inline, virtual]

A string representing the source types (with versions) supported by the SyncSource. The string must be formatted as a sequence of "type:version" separated by commas ','. For example: "text/x-vcard:2.1,text/vcard:3.0". The version can be left empty, for example: "text/x-s4j-sifc:". Supported types will be sent as part of the DevInf.

Implements TrackingSyncSource.

Reimplemented in EvolutionMemoSource.

Definition at line 60 of file EvolutionCalendarSource.h.

string EvolutionCalendarSource::icalTime2Str ( const struct icaltimetype &  tt  )  [protected]

Convert to string in canonical representation.

Referenced by getItemID(), and getItemModTime().

EvolutionCalendarSource::InsertItemResult EvolutionCalendarSource::insertItem ( const string &  uid,
const SyncItem &  item 
) [protected, virtual]

Create or modify an item.

The sync source should be flexible: if the UID is non-empty, it shall modify the item referenced by the UID. If the UID is empty, the normal operation is to add it. But if the item already exists (e.g., a calendar event which was imported by the user manually), then the existing item should be updated also in the second case.

Passing a UID of an item which does not exist is an error. This error should be reported instead of covering it up by (re)creating the item.

Errors are signalled by throwing an exception. Returning empty strings in the result is an error which triggers an "item could not be stored" error.

Parameters:
uid identifies the item to be modified, empty for creating
item contains the new content of the item and its MIME type
Returns:
the result of inserting the item

Implements TrackingSyncSource.

Reimplemented in EvolutionMemoSource.

Definition at line 265 of file EvolutionCalendarSource.cpp.

References eptr< T, base, R >::get(), getCompType(), getItemID(), getItemModTime(), EvolutionCalendarSource::ItemID::getLUID(), logItem(), m_allLUIDs, m_calendar, EvolutionCalendarSource::ItemID::m_rid, EvolutionCalendarSource::ItemID::m_uid, removeEvents(), and EvolutionSyncSource::throwError().

void EvolutionCalendarSource::listAllItems ( RevisionMap_t revisions  )  [protected, virtual]

void EvolutionCalendarSource::logItem ( const SyncItem &  item,
const string &  info,
bool  debug = false 
) [protected, virtual]

void EvolutionCalendarSource::logItem ( const string &  uid,
const string &  info,
bool  debug = false 
) [protected, virtual]

log a one-line info about an item

Implements TrackingSyncSource.

Definition at line 572 of file EvolutionCalendarSource.cpp.

References EvolutionSyncSource::getName().

Referenced by EvolutionMemoSource::createItem(), createItem(), EvolutionMemoSource::insertItem(), and insertItem().

void EvolutionCalendarSource::open (  )  [virtual]

Actually opens the data source specified in the constructor, will throw the normal exceptions if that fails. Should not modify the state of the sync source: that can be deferred until the server is also ready and beginSync() is called.

Implements TrackingSyncSource.

Definition at line 128 of file EvolutionCalendarSource.cpp.

References eCalAuthFunc(), EvolutionSyncClient::fatalError(), EvolutionSyncSourceConfig::getDatabaseID(), m_calendar, m_newSystem, m_type, m_typeName, eptr< T, base, R >::set(), and EvolutionSyncSource::throwError().

EvolutionCalendarSource::ICalComps_t EvolutionCalendarSource::removeEvents ( const string &  uid,
bool  returnOnlyChildren 
) [protected]

Utility function which extracts all icalcomponents with the given UID, stores them in a list and then removes them from the calendar. Trying to remove a non-existant UID is logged, but not an error. It simply returns an empty list.

Relies on m_allLUIDs, but does not update it. The caller must ensure that the calendar remains in a consistent state.

Parameters:
returnOnlyChildren only return children in list, even if parent is also removed

Definition at line 495 of file EvolutionCalendarSource.cpp.

References EvolutionSyncSource::getName(), m_allLUIDs, m_calendar, retrieveItem(), and EvolutionSyncSource::throwError().

Referenced by deleteItem(), and insertItem().

icalcomponent * EvolutionCalendarSource::retrieveItem ( const ItemID id  )  [protected]

retrieve the item with the given id - may throw exception

caller has to free result

Definition at line 621 of file EvolutionCalendarSource.cpp.

References getLUID(), m_calendar, and EvolutionSyncSource::throwError().

Referenced by EvolutionMemoSource::createItem(), getItemModTime(), removeEvents(), and retrieveItemAsString().

string EvolutionCalendarSource::retrieveItemAsString ( const ItemID id  )  [protected]

retrieve the item with the given luid as VCALENDAR string - may throw exception

Definition at line 640 of file EvolutionCalendarSource.cpp.

References getLUID(), m_calendar, retrieveItem(), and EvolutionSyncSource::throwError().

Referenced by createItem(), and exportData().

void EvolutionCalendarSource::setItemStatusThrow ( const char *  key,
int  status 
) [protected, virtual]

Reimplemented from TrackingSyncSource.

Definition at line 254 of file EvolutionCalendarSource.cpp.

References EvolutionSyncSource::getName().


Member Data Documentation

set<string> EvolutionCalendarSource::m_allLUIDs [protected]

A set of all existing objects. Initialized in the last call to listAllItems() and then updated as items get added/removed. Used to decide how insertItem() has to be implemented without the troublesome querying of the EDS backend.

Definition at line 177 of file EvolutionCalendarSource.h.

Referenced by deleteItem(), insertItem(), listAllItems(), and removeEvents().

eptr<ECal, GObject> EvolutionCalendarSource::m_calendar [protected]

valid after open(): the calendar that this source references

Definition at line 77 of file EvolutionCalendarSource.h.

Referenced by close(), deleteItem(), exportData(), EvolutionMemoSource::insertItem(), insertItem(), listAllItems(), open(), removeEvents(), retrieveItem(), and retrieveItemAsString().

ECal*(* EvolutionCalendarSource::m_newSystem)(void) [protected]

e_cal_new_system_calendar, etc.

Referenced by EvolutionCalendarSource(), and open().

ECalSourceType EvolutionCalendarSource::m_type [protected]

use events or todos?

Definition at line 79 of file EvolutionCalendarSource.h.

Referenced by EvolutionCalendarSource(), getCompType(), getDatabases(), and open().

"calendar", "task list", "memo list"

Definition at line 80 of file EvolutionCalendarSource.h.

Referenced by EvolutionCalendarSource(), and open().


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

Generated on Sat Oct 18 17:17:03 2008 for SyncEvolution and Funambol by  doxygen 1.5.7.1