TestFileSyncSource Class Reference
[Client]

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

#include <TestFileSyncSource.h>

Inheritance diagram for TestFileSyncSource:
[legend]
Collaboration diagram for TestFileSyncSource:
[legend]

List of all members.

Public Member Functions

 TestFileSyncSource (const WCHAR *name, AbstractSyncSourceConfig *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 ()
SyncItem * getNextItemKey ()
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 removeAllItems ()
 Removes all the item of the sync source.
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 (TestFileSyncSource &s)

Protected Member Functions

 TestFileSyncSource (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

Private Member Functions

unsigned long getServerModTime (const char *keystr)
 returns time stored in fileNode for the given key, 0 if not found
SyncItem * getFirst (ItemIteratorContainer &container, bool getData=true)
SyncItem * getNext (ItemIteratorContainer &container, bool getData=true)

Private Attributes

struct
TestFileSyncSource::ItemIteratorContainer 
allItems
struct
TestFileSyncSource::ItemIteratorContainer 
newItems
struct
TestFileSyncSource::ItemIteratorContainer 
updatedItems
struct
TestFileSyncSource::ItemIteratorContainer 
deletedItems
ManagementNode * fileNode


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 TestFileSyncSource::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

int TestFileSyncSource::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.

int TestFileSyncSource::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 TestFileSyncSource::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.

int TestFileSyncSource::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.

SyncItem* TestFileSyncSource::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* TestFileSyncSource::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* TestFileSyncSource::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* TestFileSyncSource::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* TestFileSyncSource::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* TestFileSyncSource::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* TestFileSyncSource::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* TestFileSyncSource::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.

int TestFileSyncSource::removeAllItems (  )  [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.

Implements SyncSource.

void TestFileSyncSource::setDir ( const char *  p  ) 

The directory synchronized by this source.

Parameters:
p an absolute or relative path to the directory

void TestFileSyncSource::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.

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

Reimplemented from SyncSource.

int TestFileSyncSource::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.


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

Generated on Tue Apr 6 13:00:43 2010 for Funambol Outlook Plug-in Library by  doxygen 1.5.7.1