#include <SyncSource.h>
Public Member Functions | |
SyncSource (const WCHAR *name, AbstractSyncSourceConfig *sc) | |
Constructor: create a SyncSource with the specified name. | |
const WCHAR * | getName () |
Get the source name. | |
void | setConfig (AbstractSyncSourceConfig *sc) |
use this directly after constructing the source when passing the configuration to the constructor directly is not possible | |
const AbstractSyncSourceConfig & | getConfig () const |
read-only access to configuration | |
AbstractSyncSourceConfig & | getConfig () |
read-write access to configuration | |
SyncSourceReport * | getReport () |
Return pointer to report object. | |
void | setReport (SyncSourceReport *sr) |
Set the report pointer with the given one (no copy, only assign the pointer to the external one). | |
SyncMode | getPreferredSyncMode () |
Get & Set the preferred synchronization mode for the SyncSource. | |
void | setPreferredSyncMode (SyncMode syncMode) |
SyncMode | getSyncMode () |
Get & Sets the server imposed synchronization mode for the SyncSource. | |
void | setSyncMode (SyncMode syncMode) |
unsigned long | getLastSync () |
Get & Set the timestamp in milliseconds of the last synchronization. | |
void | setLastSync (unsigned long timestamp) |
unsigned long | getNextSync () |
Gets & Sets the timestamp in milliseconds of the next synchronization. | |
void | setNextSync (unsigned long timestamp) |
void | setLastAnchor (const char *last) |
Gets & Sets the last anchor associated to the source. | |
const char * | getLastAnchor () |
const char * | getNextAnchor () |
Gets & Sets the next anchor associated to the source. | |
void | setNextAnchor (const char *next) |
SourceFilter * | getFilter () |
Gets filter. | |
void | setFilter (SourceFilter *f) |
Sets filter. | |
virtual int | beginSync () |
Called by the engine from inside SyncClient::sync() at the begin of the sync. | |
virtual int | endSync () |
Called by the engine from inside SyncClient::sync() at the end of the sync. | |
virtual void | setItemStatus (const WCHAR *, int) |
called by the sync engine with the status returned by the server for a certain item that the client sent to the server | |
virtual void | setItemStatus (const WCHAR *key, int status, const char *) |
called by the sync engine with the status returned by the server for a certain item that the client sent to the server. | |
virtual void | serverStatusPackageEnded () |
Indicates that all the server status of the current package of the client items has been processed by the engine. | |
virtual void | clientStatusPackageEnded () |
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. | |
virtual int | removeAllItems ()=0 |
Removes all the item of the sync source. | |
virtual SyncItem * | getFirstItem ()=0 |
Return the first SyncItem of all. | |
virtual SyncItem * | getNextItem ()=0 |
Return the next SyncItem of all. | |
virtual SyncItem * | getFirstNewItem ()=0 |
Return the first SyncItem of new one. | |
virtual SyncItem * | getNextNewItem ()=0 |
Return the next SyncItem of new one. | |
virtual SyncItem * | getFirstUpdatedItem ()=0 |
Return the first SyncItem of updated one. | |
virtual SyncItem * | getNextUpdatedItem ()=0 |
Return the next SyncItem of updated one. | |
virtual SyncItem * | getFirstDeletedItem ()=0 |
Return the first SyncItem of updated one. | |
virtual SyncItem * | getNextDeletedItem ()=0 |
Return the next SyncItem of updated one. | |
virtual int | addItem (SyncItem &item)=0 |
Called by the sync engine to add an item that the server has sent. | |
virtual int | updateItem (SyncItem &item)=0 |
Called by the sync engine to update an item that the source already should have. | |
virtual int | deleteItem (SyncItem &item)=0 |
Called by the sync engine to update an item that the source already should have. | |
Protected Member Functions | |
void | assign (SyncSource &s) |
copies all elements, to be used by derived class' clone() implementation | |
Protected Attributes | |
AbstractSyncSourceConfig * | config |
SyncSourceReport * | report |
Private Attributes | |
SyncMode | syncMode |
unsigned long | lastSync |
unsigned long | nextSync |
WCHAR * | name |
char | next [DIM_ANCHOR] |
char | last [DIM_ANCHOR] |
SourceFilter * | filter |
Each client may provide access to one or more sources.
SyncSource::SyncSource | ( | const WCHAR * | name, | |
AbstractSyncSourceConfig * | sc | |||
) |
Constructor: create a SyncSource with the specified name.
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 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.
item | the item as sent by the server |
Implemented in WindowsSyncSource, and TestFileSyncSource.
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.
Reimplemented in WindowsSyncSource, and TestFileSyncSource.
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
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.
item | the item as sent by the server |
Implemented in WindowsSyncSource, and TestFileSyncSource.
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
Reimplemented in WindowsSyncSource, and TestFileSyncSource.
Referenced by LocalTests::compareDatabases().
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 WindowsSyncSource, and TestFileSyncSource.
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 WindowsSyncSource, and TestFileSyncSource.
Referenced by ClientTest::dump().
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 WindowsSyncSource, and TestFileSyncSource.
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 WindowsSyncSource, and TestFileSyncSource.
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.
Referenced by WindowsSyncSource::addItem(), WindowsSyncSource::beginSync(), WindowsSyncSource::checkBirthdayAnniversary(), WindowsSyncSource::createOldItems(), WindowsSyncSource::deleteItem(), WindowsSyncSource::endSync(), WindowsSyncSource::extractFolder(), WindowsSyncSource::getFirstItem(), WindowsSyncSource::getFirstNewItem(), WindowsSyncSource::getFirstUpdatedItem(), WindowsSyncSource::getNextItem(), WindowsSyncSource::getNextNewItem(), WindowsSyncSource::getNextUpdatedItem(), WindowsSyncSource::getStartFolder(), WindowsSyncSource::manageModificationsFromLastSync(), WindowsSyncSource::manageSourceError(), WindowsSyncSource::pushAllItemsToList(), WindowsSyncSource::removeAllItems(), WindowsSyncSource::updateFilters(), and WindowsSyncSource::updateItem().
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 WindowsSyncSource, and TestFileSyncSource.
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 WindowsSyncSource, and TestFileSyncSource.
Referenced by ClientTest::dump().
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 WindowsSyncSource, and TestFileSyncSource.
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 WindowsSyncSource, and TestFileSyncSource.
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.
Referenced by WindowsSyncSource::beginSync(), WindowsSyncClient::continueAfterPrepareSync(), WindowsSyncSource::endSync(), WindowsSyncSource::getFirstItem(), WindowsSyncSource::getFirstNewItem(), and printReport().
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.
Implemented in WindowsSyncSource, and TestFileSyncSource.
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
void SyncSource::setFilter | ( | SourceFilter * | f | ) |
Sets filter.
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.
key | the local key of the item | |
status | the SyncML status returned by the server | |
command | the SyncML command associated to the item |
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
key | the local key of the item | |
status | the SyncML status returned by the server |
Reimplemented in WindowsSyncSource, and TestFileSyncSource.
Referenced by setItemStatus().
void SyncSource::setReport | ( | SyncSourceReport * | sr | ) |
Set the report pointer with the given one (no copy, only assign the pointer to the external one).
sr | the report for this sync source |
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.
item | the item as sent by the server |
Implemented in WindowsSyncSource, and TestFileSyncSource.