SyncSource Class Reference
[Sync Client]

This is the main API that a SyncML client developer needs to implement to let the sync engine access the client's data. More...

#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, SyncSourceConfig *sc) EXTRA_SECTION_01
 Constructor: create a SyncSource with the specified name.
const WCHAR * getName () EXTRA_SECTION_01
 Get the source name.
const SyncSourceConfiggetConfig () const EXTRA_SECTION_01
 read-only access to configuration
SyncSourceConfiggetConfig () EXTRA_SECTION_01
 read-write access to configuration
SyncSourceReportgetReport () EXTRA_SECTION_01
 Return pointer to report object.
void setReport (SyncSourceReport *sr) EXTRA_SECTION_01
 Set the report pointer with the given one (no copy, only assign the pointer to the external one).
SyncMode getPreferredSyncMode () EXTRA_SECTION_01
 Get & Set the preferred synchronization mode for the SyncSource.
void setPreferredSyncMode (SyncMode syncMode) EXTRA_SECTION_01
SyncMode getSyncMode () EXTRA_SECTION_01
 Get & Sets the server imposed synchronization mode for the SyncSource.
void setSyncMode (SyncMode syncMode) EXTRA_SECTION_01
unsigned long getLastSync () EXTRA_SECTION_01
 Get & Set the timestamp in milliseconds of the last synchronization.
void setLastSync (unsigned long timestamp) EXTRA_SECTION_01
unsigned long getNextSync () EXTRA_SECTION_01
 Gets & Sets the timestamp in milliseconds of the next synchronization.
void setNextSync (unsigned long timestamp) EXTRA_SECTION_01
void setLastAnchor (const char *last) EXTRA_SECTION_01
 Gets & Sets the last anchor associated to the source.
const char * getLastAnchor () EXTRA_SECTION_01
const char * getNextAnchor () EXTRA_SECTION_01
 Gets & Sets the next anchor associated to the source.
void setNextAnchor (const char *next) EXTRA_SECTION_01
SourceFilter * getFilter ()
 Gets filter.
void setFilter (SourceFilter *f)
 Sets filter.
virtual int beginSync () EXTRA_SECTION_01
 Called by the engine from inside SyncClient::sync() at the begin of the sync.
virtual int endSync () EXTRA_SECTION_01
 Called by the engine from inside SyncClient::sync() at the end of the sync.
virtual void setItemStatus (const WCHAR *key, int status)=0EXTRA_SECTION_01
 called by the sync engine with the status returned by the server for a certain item that the client sent to the server
virtual SyncItem * getFirstItemKey ()=0EXTRA_SECTION_01
 Return the key of the first SyncItem of all.
virtual SyncItem * getNextItemKey ()=0EXTRA_SECTION_01
 Return the key of the next SyncItem of all.
virtual SyncItem * getFirstItem ()=0EXTRA_SECTION_01
 Return the first SyncItem of all.
virtual SyncItem * getNextItem ()=0EXTRA_SECTION_01
 Return the next SyncItem of all.
virtual SyncItem * getFirstNewItem ()=0EXTRA_SECTION_01
 Return the first SyncItem of new one.
virtual SyncItem * getNextNewItem ()=0EXTRA_SECTION_01
 Return the next SyncItem of new one.
virtual SyncItem * getFirstUpdatedItem ()=0EXTRA_SECTION_01
 Return the first SyncItem of updated one.
virtual SyncItem * getNextUpdatedItem ()=0EXTRA_SECTION_01
 Return the next SyncItem of updated one.
virtual SyncItem * getFirstDeletedItem ()=0EXTRA_SECTION_01
 Return the first SyncItem of updated one.
virtual SyncItem * getNextDeletedItem ()=0EXTRA_SECTION_01
 Return the next SyncItem of updated one.
virtual int addItem (SyncItem &item)=0EXTRA_SECTION_01
 Called by the sync engine to add an item that the server has sent.
virtual int updateItem (SyncItem &item)=0EXTRA_SECTION_01
 Called by the sync engine to update an item that the source already should have.
virtual int deleteItem (SyncItem &item)=0EXTRA_SECTION_01
 Called by the sync engine to update an item that the source already should have.
virtual ArrayElement * clone () EXTRA_SECTION_01=0
 ArrayElement implementation.

Protected Member Functions

void assign (SyncSource &s)
 copies all elements, to be used by derived class' clone() implementation

Protected Attributes

SyncSourceConfigconfig
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.


Constructor & Destructor Documentation

SyncSource::SyncSource ( const WCHAR *  name,
SyncSourceConfig 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.


Member Function Documentation

const WCHAR* SyncSource::getName (  ) 

Get the source name.

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

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

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.

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.

unsigned long SyncSource::getLastSync (  ) 

Get & Set the timestamp in milliseconds of the last synchronization.

The reference time of the timestamp is platform specific.

unsigned long SyncSource::getNextSync (  ) 

Gets & Sets the timestamp in milliseconds of the next synchronization.

The reference time of the timestamp is platform specific.

void SyncSource::setFilter ( SourceFilter *  f  ) 

Sets filter.

Parameters:
f the new filter

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 FileSyncSource.

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 FileSyncSource.

virtual void SyncSource::setItemStatus ( const WCHAR *  key,
int  status 
) [pure 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

Implemented in FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource.

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 FileSyncSource, and RawFileSyncSource.

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 FileSyncSource, and RawFileSyncSource.

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 FileSyncSource.


The documentation for this class was generated from the following file:
Generated on Fri Apr 27 12:29:24 2007 for Funambol C++ Client Library by  doxygen 1.5.2