SyncSource Class Reference
[Client]

#include <SyncSource.h>

Inheritance diagram for SyncSource:

Inheritance graph
[legend]
Collaboration diagram for SyncSource:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 SyncSource (const WCHAR *name, AbstractSyncSourceConfig *sc)
virtual ~SyncSource ()
const WCHAR * getName ()
void setConfig (AbstractSyncSourceConfig *sc)
const AbstractSyncSourceConfiggetConfig () const
AbstractSyncSourceConfiggetConfig ()
SyncSourceReportgetReport ()
void setReport (SyncSourceReport *sr)
SyncMode getPreferredSyncMode ()
void setPreferredSyncMode (SyncMode syncMode)
SyncMode getSyncMode ()
void setSyncMode (SyncMode syncMode)
unsigned long getLastSync ()
void setLastSync (unsigned long timestamp)
unsigned long getNextSync ()
void setNextSync (unsigned long timestamp)
void setLastAnchor (const char *last)
const char * getLastAnchor ()
const char * getNextAnchor ()
void setNextAnchor (const char *next)
SourceFilter * getFilter ()
void setFilter (SourceFilter *f)
virtual int beginSync ()
virtual int endSync ()
virtual void setItemStatus (const WCHAR *, int)
virtual void setItemStatus (const WCHAR *key, int status, const char *)
virtual void serverStatusPackageEnded ()
virtual void clientStatusPackageEnded ()
virtual int removeAllItems ()=0
virtual SyncItem * getFirstItemKey ()=0
virtual SyncItem * getNextItemKey ()=0
virtual SyncItem * getFirstItem ()=0
virtual SyncItem * getNextItem ()=0
virtual SyncItem * getFirstNewItem ()=0
virtual SyncItem * getNextNewItem ()=0
virtual SyncItem * getFirstUpdatedItem ()=0
virtual SyncItem * getNextUpdatedItem ()=0
virtual SyncItem * getFirstDeletedItem ()=0
virtual SyncItem * getNextDeletedItem ()=0
virtual int addItem (SyncItem &item)=0
virtual int updateItem (SyncItem &item)=0
virtual int deleteItem (SyncItem &item)=0

Protected Member Functions

void assign (SyncSource &s)

Protected Attributes

AbstractSyncSourceConfigconfig
SyncSourceReportreport


Detailed Description

This is the main API that a SyncML client developer needs to implement to let the sync engine access the client's data. Each client may provide access to one or more sources.

Definition at line 60 of file SyncSource.h.


Constructor & Destructor Documentation

SyncSource::SyncSource ( const WCHAR *  name,
AbstractSyncSourceConfig sc 
)

Constructor: create a SyncSource with the specified name

Parameters:
name the name of the SyncSource
sc configuration for the sync source: the instance must remain valid throughout the lifetime of the sync source because it keeps a reference to it and uses it as its own. A NULL pointer is allowed for unit testing outside of the sync framework; the sync source then references a global config instance to avoid crashes, but modifying that config will not make much sense. The pointer may also be set directly after creating the SyncSource, which is useful when a derived class creates the config in its own constructor.

virtual SyncSource::~SyncSource (  )  [virtual]


Member Function Documentation

virtual int SyncSource::addItem ( SyncItem &  item  )  [pure virtual]

Called by the sync engine to add an item that the server has sent. The sync source is expected to add it to its database, then set the key to the local key assigned to the new item. Alternatively the sync source can match the new item against one of the existing items and return that key.

Parameters:
item the item as sent by the server
Returns:
SyncML status code

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

void SyncSource::assign ( SyncSource s  )  [protected]

copies all elements, to be used by derived class' clone() implementation

virtual int SyncSource::beginSync (  )  [virtual]

Called by the engine from inside SyncClient::sync() at the begin of the sync.

The SyncSource can do every initialization it needs. The server has been contacted, so in particular getSyncMode() can now be used to find out what the sync mode for this synchronization run will be. After this call the iterators for SyncItems must return valid results for the current sync mode.

The synchronization stops if this function return a non-zero value.

Returns:
- 0 on success, an error otherwise

Reimplemented in TestEvolutionSyncSource, and EvolutionSyncSource.

Referenced by LocalTests::compareDatabases().

virtual void SyncSource::clientStatusPackageEnded (  )  [virtual]

Indicates that all the client status of the current package of the server items that has been processed by the client and are going to be sent to the server. This signal can be useful to update the modification arrays

Reimplemented in CacheSyncSource.

virtual int SyncSource::deleteItem ( SyncItem &  item  )  [pure virtual]

Called by the sync engine to update an item that the source already should have. The item's key is the local key of that item, no data is provided.

Parameters:
item the item as sent by the server

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

virtual int SyncSource::endSync (  )  [virtual]

Called by the engine from inside SyncClient::sync() at the end of the sync.

The SyncSource can do any needed commit action to save the state of the items. The engine commits to the server the changes applied in the transaction only if this function return 0.

FIXME: the return code is currently ignored by the sync engine

Returns:
- 0 on success, an error otherwise

Reimplemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

Referenced by LocalTests::compareDatabases().

AbstractSyncSourceConfig& SyncSource::getConfig (  ) 

read-write access to configuration

const AbstractSyncSourceConfig& SyncSource::getConfig (  )  const

read-only access to configuration

Referenced by EvolutionSyncSource::beginSync().

SourceFilter* SyncSource::getFilter (  ) 

Gets filter

virtual SyncItem* SyncSource::getFirstDeletedItem (  )  [pure virtual]

Return the first SyncItem of updated one. It is used in case of fast sync and retrieve the new data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

virtual SyncItem* SyncSource::getFirstItem (  )  [pure virtual]

Return the first SyncItem of all. It is used in case of slow sync and retrieve the entire data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

Referenced by ClientTest::dump().

virtual SyncItem* SyncSource::getFirstItemKey (  )  [pure virtual]

Return the key of the first SyncItem of all. It is used in case of refresh sync and retrieve all the keys of the data source.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

virtual SyncItem* SyncSource::getFirstNewItem (  )  [pure virtual]

Return the first SyncItem of new one. It is used in case of fast sync and retrieve the new data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

virtual SyncItem* SyncSource::getFirstUpdatedItem (  )  [pure virtual]

Return the first SyncItem of updated one. It is used in case of fast sync and retrieve the new data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

const char* SyncSource::getLastAnchor (  ) 

unsigned long SyncSource::getLastSync (  ) 

Get & Set the timestamp in milliseconds of the last synchronization. The reference time of the timestamp is platform specific.

const WCHAR* SyncSource::getName (  ) 

Get the source name.

Returns:
- the source name (a pointer to the object buffer, will be released at object destruction)

Reimplemented in TestEvolutionSyncSource, and EvolutionSyncSource.

const char* SyncSource::getNextAnchor (  ) 

Gets & Sets the next anchor associated to the source

virtual SyncItem* SyncSource::getNextDeletedItem (  )  [pure virtual]

Return the next SyncItem of updated one. It is used in case of fast sync and retrieve the new data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

virtual SyncItem* SyncSource::getNextItem (  )  [pure virtual]

Return the next SyncItem of all. It is used in case of slow sync and retrieve the entire data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

Referenced by ClientTest::dump().

virtual SyncItem* SyncSource::getNextItemKey (  )  [pure virtual]

Return the key of the next SyncItem of all. It is used in case of refresh sync and retrieve all the keys of the data source.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

virtual SyncItem* SyncSource::getNextNewItem (  )  [pure virtual]

Return the next SyncItem of new one. It is used in case of fast sync and retrieve the new data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

unsigned long SyncSource::getNextSync (  ) 

Gets & Sets the timestamp in milliseconds of the next synchronization. The reference time of the timestamp is platform specific.

virtual SyncItem* SyncSource::getNextUpdatedItem (  )  [pure virtual]

Return the next SyncItem of updated one. It is used in case of fast sync and retrieve the new data source content.

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.

SyncMode SyncSource::getPreferredSyncMode (  ) 

Get & Set the preferred synchronization mode for the SyncSource.

Taken initially from the configuration by setConfig(), it can then be modified by the client. The code synchronization code itself reads this value, but it doesn't modify it.

SyncSourceReport* SyncSource::getReport (  ) 

Return pointer to report object.

SyncMode SyncSource::getSyncMode (  ) 

Get & Sets the server imposed synchronization mode for the SyncSource.

Agreed upon with the server during the initial exchange with the server. The SyncSource can react to it in beginSync(), in particular it must wipe its local data during a refresh from server.

Referenced by EvolutionSyncSource::beginSync().

virtual int SyncSource::removeAllItems (  )  [pure virtual]

Removes all the item of the sync source. It is called by the engine in the case of a refresh from server to clean all the client items before receiving the server ones. It is called after the beginSync() method.

Returns:
0 if the remote succeded.

Implemented in TestEvolutionSyncSource, and EvolutionSyncSource.

virtual void SyncSource::serverStatusPackageEnded (  )  [virtual]

Indicates that all the server status of the current package of the client items has been processed by the engine. This signal can be useful to update the modification arrays

Reimplemented in CacheSyncSource.

void SyncSource::setConfig ( AbstractSyncSourceConfig sc  ) 

use this directly after constructing the source when passing the configuration to the constructor directly is not possible

Referenced by EvolutionSyncSource::EvolutionSyncSource().

void SyncSource::setFilter ( SourceFilter *  f  ) 

Sets filter

Parameters:
f the new filter

virtual void SyncSource::setItemStatus ( const WCHAR *  key,
int  status,
const char *   
) [inline, virtual]

called by the sync engine with the status returned by the server for a certain item that the client sent to the server. It contains also the proper command associated to the item.

Parameters:
key the local key of the item
status the SyncML status returned by the server
command the SyncML command associated to the item

Reimplemented in CacheSyncSource.

Definition at line 277 of file SyncSource.h.

References setItemStatus().

virtual void SyncSource::setItemStatus ( const WCHAR *  ,
int   
) [inline, virtual]

called by the sync engine with the status returned by the server for a certain item that the client sent to the server

Parameters:
key the local key of the item
status the SyncML status returned by the server
Deprecated:
Since:
SyncML API v7

Definition at line 265 of file SyncSource.h.

Referenced by setItemStatus().

void SyncSource::setLastAnchor ( const char *  last  ) 

Gets & Sets the last anchor associated to the source

void SyncSource::setLastSync ( unsigned long  timestamp  ) 

void SyncSource::setNextAnchor ( const char *  next  ) 

void SyncSource::setNextSync ( unsigned long  timestamp  ) 

void SyncSource::setPreferredSyncMode ( SyncMode  syncMode  ) 

void SyncSource::setReport ( SyncSourceReport sr  ) 

Set the report pointer with the given one (no copy, only assign the pointer to the external one)

Parameters:
sr the report for this sync source

void SyncSource::setSyncMode ( SyncMode  syncMode  ) 

virtual int SyncSource::updateItem ( SyncItem &  item  )  [pure virtual]

Called by the sync engine to update an item that the source already should have. The item's key is the local key of that item.

Parameters:
item the item as sent by the server
Returns:
SyncML status code

Implemented in TestEvolutionSyncSource, EvolutionSyncSource, and CacheSyncSource.


Member Data Documentation

Definition at line 75 of file SyncSource.h.


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

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