FileSyncSource Class Reference
[Sync Client]

Synchronizes the content of files in a certain directory and the file attributes using a certain XML format. More...

#include <FileSyncSource.h>

Inheritance diagram for FileSyncSource:

Inheritance graph
[legend]
Collaboration diagram for FileSyncSource:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileSyncSource (const WCHAR *name, SyncSourceConfig *sc)
void setDir (const char *p)
 The directory synchronized by this source.
const char * getDir ()
void setFileNode (ManagementNode *mn)
 Tracking changes requires persistent storage: for each item sent to the server a property is set to the item's modification time.
ManagementNode * getFileNode ()
SyncItem * getFirstItem ()
 Return the first SyncItem of all.
SyncItem * getNextItem ()
 Return the next SyncItem of all.
SyncItem * getFirstNewItem ()
 Return the first SyncItem of new one.
SyncItem * getNextNewItem ()
 Return the next SyncItem of new one.
SyncItem * getFirstUpdatedItem ()
 Return the first SyncItem of updated one.
SyncItem * getNextUpdatedItem ()
 Return the next SyncItem of updated one.
SyncItem * getFirstDeletedItem ()
 Return the first SyncItem of updated one.
SyncItem * getNextDeletedItem ()
 Return the next SyncItem of updated one.
SyncItem * getFirstItemKey ()
 Return the key of the first SyncItem of all.
SyncItem * getNextItemKey ()
 Return the key of the next SyncItem of all.
int addItem (SyncItem &item)
 Called by the sync engine to add an item that the server has sent.
int updateItem (SyncItem &item)
 Called by the sync engine to update an item that the source already should have.
int deleteItem (SyncItem &item)
 Called by the sync engine to update an item that the source already should have.
void setItemStatus (const WCHAR *key, int status)
 called by the sync engine with the status returned by the server for a certain item that the client sent to the server
int beginSync ()
 Called by the engine from inside SyncClient::sync() at the begin of the sync.
int endSync ()
 Called by the engine from inside SyncClient::sync() at the end of the sync.
void assign (FileSyncSource &s)
ArrayElement * clone ()
 ArrayElement implementation.

Protected Member Functions

 FileSyncSource (SyncSource &s)
virtual bool setItemData (SyncItem *syncItem)
int addedItem (SyncItem &item, const WCHAR *key)
 must be called for each successfully added item

Protected Attributes

char * dir

Classes

struct  ItemIteratorContainer

Detailed Description

Synchronizes the content of files in a certain directory and the file attributes using a certain XML format.

Todo:
document what that XML format is
Todo:
updateItem() is not implemented


Member Function Documentation

int FileSyncSource::addedItem ( SyncItem &  item,
const WCHAR *  key 
) [protected]

must be called for each successfully added item

Parameters:
item the added item
key the key of that item
Returns:
SyncML status code, STC_ITEM_ADDED on success

void FileSyncSource::setDir ( const char *  p  ) 

The directory synchronized by this source.

Parameters:
p an absolute or relative path to the directory

void FileSyncSource::setFileNode ( ManagementNode *  mn  )  [inline]

Tracking changes requires persistent storage: for each item sent to the server a property is set to the item's modification time.

The caller is responsible for storing these properties after a successful sync and continues to own the node instance itself.

During the next beginSync() the information will be used to identify added, updated and deleted items.

SyncItem* FileSyncSource::getFirstItem (  )  [inline, virtual]

Return the first SyncItem of all.

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

Implements SyncSource.

SyncItem* FileSyncSource::getNextItem (  )  [inline, virtual]

Return the next SyncItem of all.

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

Implements SyncSource.

SyncItem* FileSyncSource::getFirstNewItem (  )  [inline, virtual]

Return the first SyncItem of new one.

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

Implements SyncSource.

SyncItem* FileSyncSource::getNextNewItem (  )  [inline, virtual]

Return the next SyncItem of new one.

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

Implements SyncSource.

SyncItem* FileSyncSource::getFirstUpdatedItem (  )  [inline, virtual]

Return the first SyncItem of updated one.

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

Implements SyncSource.

SyncItem* FileSyncSource::getNextUpdatedItem (  )  [inline, virtual]

Return the next SyncItem of updated one.

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

Implements SyncSource.

SyncItem* FileSyncSource::getFirstDeletedItem (  )  [inline, virtual]

Return the first SyncItem of updated one.

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

Implements SyncSource.

SyncItem* FileSyncSource::getNextDeletedItem (  )  [inline, virtual]

Return the next SyncItem of updated one.

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

Implements SyncSource.

SyncItem* FileSyncSource::getFirstItemKey (  )  [inline, 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.

Implements SyncSource.

SyncItem* FileSyncSource::getNextItemKey (  )  [inline, 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.

Implements SyncSource.

int FileSyncSource::addItem ( SyncItem &  item  )  [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

Implements SyncSource.

Reimplemented in RawFileSyncSource.

int FileSyncSource::updateItem ( SyncItem &  item  )  [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

Implements SyncSource.

Reimplemented in RawFileSyncSource.

int FileSyncSource::deleteItem ( SyncItem &  item  )  [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

Implements SyncSource.

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

Implements SyncSource.

int FileSyncSource::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 from SyncSource.

int FileSyncSource::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 from SyncSource.


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