FileSyncSource Class Reference
[Client]

This class extends the CacheSyncSource abstract class, implementing a plain file datastore. More...

#include <FileSyncSource.h>

Inheritance diagram for FileSyncSource:
[legend]

List of all members.

Public Member Functions

 FileSyncSource (const WCHAR *name, AbstractSyncSourceConfig *sc, const StringBuffer &aDir=DEFAULT_SYNC_DIR, KeyValueStore *cache=NULL)
void assign (FileSyncSource &s)
void setDir (const char *p)
 set/get the directory where to sync the files
const StringBuffer & getDir ()
void setRecursive (const bool value)
 set/get the recursive flag (if true, will recurse subfolders)
const bool getRecursive ()
virtual EnumerationgetAllItemList ()
 Get the list of all the keys stored in a StringBuffer.
virtual int removeAllItems ()
 Removes all the item of the sync source.
virtual int insertItem (SyncItem &item)
 Called by the sync engine to add an item that the server has sent.
virtual int modifyItem (SyncItem &item)
 Called by the sync engine to update an item that the source already should have.
virtual int removeItem (SyncItem &item)
 Called by the sync engine to update an item that the source already should have.
SyncItem * fillSyncItem (StringBuffer *key, const bool fillData=true)
 Overrides CacheSyncSource::fillSyncItem() in order to create new FileSyncItem instead of a SyncItem.
virtual void * getItemContent (StringBuffer &key, size_t *size)
 Returns the whole file content and size, for the file with name 'key'.

Protected Member Functions

virtual bool filterOutgoingItem (const StringBuffer &fullName, struct stat &st)
 Used to filter outgoing items.

Protected Attributes

StringBuffer dir

Private Member Functions

 FileSyncSource (const FileSyncSource &s)
FileSyncSourceoperator= (const FileSyncSource &s)
bool scanFolder (const StringBuffer &fullPath, ArrayList &filesFound, bool applyFiltering=true)
 Reads the directory 'fullPath' and get all file names.

Private Attributes

bool recursive
 If true, will recurse into subfolders of 'dir'. Default is false.


Detailed Description

This class extends the CacheSyncSource abstract class, implementing a plain file datastore.

All the files in a folder are synchronized with the server. Depending on the MIME type defined for the source (see SyncSourceConfig::getType()), this class can work in two ways:

for incoming items, the format of the file is detected by the content.


Member Function Documentation

SyncItem* FileSyncSource::fillSyncItem ( StringBuffer *  key,
const bool  fillData = true 
)

Overrides CacheSyncSource::fillSyncItem() in order to create new FileSyncItem instead of a SyncItem.

NOTE: it doesn't really fill the item's data: it just creates the FileSyncItem specifying the file's path, then the file content will be read chunk by chunk from the input stream when needed.

Parameters:
key the item's key = the file name
fillData [OPTIONAL] ignored param
Returns:
a new allocated FileSyncItem

Reimplemented in MediaSyncSource.

virtual bool FileSyncSource::filterOutgoingItem ( const StringBuffer &  fullName,
struct stat &  st 
) [protected, virtual]

Used to filter outgoing items.

Current implementation doesn't filter any item: override this method for specific filtering. NOTE: this is only STATIC filtering. Meaning that these filters CANNOT be changed/disabled anytime by the Client, otherwise a change in the filter may result in the Client to send deleted items for files fitered out. See dynamicFilterItem() for dynamic filtering.

Parameters:
fullName the full path + name of the file to check
st reference to struct stat for current file
Returns:
true if the item has to be filtered out (skipped) false if the item is ok

Reimplemented in MediaSyncSource.

virtual Enumeration* FileSyncSource::getAllItemList (  )  [virtual]

Get the list of all the keys stored in a StringBuffer.

It reads all the files name in the directory. The directory is set in the sync source.

Reimplemented in PicturesSyncSource.

virtual void* FileSyncSource::getItemContent ( StringBuffer &  key,
size_t *  size 
) [virtual]

Returns the whole file content and size, for the file with name 'key'.

Note: this method is no more called by the sync engine, since we now use input streams to retrieve the file's data chunk by chunk.

virtual int FileSyncSource::insertItem ( 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

Reimplemented in PicturesSyncSource, and MediaSyncSource.

virtual int FileSyncSource::modifyItem ( 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

Reimplemented in PicturesSyncSource, and MediaSyncSource.

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

Reimplemented in PicturesSyncSource.

virtual int FileSyncSource::removeItem ( 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

Reimplemented in PicturesSyncSource, and MediaSyncSource.

bool FileSyncSource::scanFolder ( const StringBuffer &  fullPath,
ArrayList &  filesFound,
bool  applyFiltering = true 
) [private]

Reads the directory 'fullPath' and get all file names.

If recursive is true, reads recursively all subfolders too. Populates the filesFound Arraylist with the names of files. Will call filterOutgoingItem() for each item found if applyFiltering is true.

Parameters:
fullPath the absolute path of desired folder to scan if empty, will scan the 'dir' folder
filesFound [OUT] the arraylist of file names
applyFiltering if true will call filterOutgoingItem() for each item found. Default = true.
Returns:
true if no error


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

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