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.
virtual void * getItemContent (StringBuffer &key, size_t *size)
 Get the content of an item given the key.

Protected Member Functions

virtual bool filterOutgoingItem (const StringBuffer &fullName, struct stat &st)
 Used to filter outgoing items.
bool checkFileExtension (const StringBuffer &fileName, const StringBuffer &extension)
 Utility method, returns true if the fileName extension is equal to one passed.

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

bool FileSyncSource::checkFileExtension ( const StringBuffer &  fileName,
const StringBuffer &  extension 
) [protected]

Utility method, returns true if the fileName extension is equal to one passed.

Parameters:
fileName the file name
extension the extension to check
Returns:
true if the extension matches

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.

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.

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

Get the content of an item given the key.

It is used to populate the SyncItem before the engine uses it in the usual flow of the sync. It is used also by the itemHandler if needed (i.e. in the cache implementation)

Parameters:
key the local key of the item
size OUT: the size of the content

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

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 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 Jun 30 12:52:37 2009 for Funambol Outlook Plug-in Library by  doxygen 1.5.7.1