MediaSyncSourceSyncMLData Class Reference

------------------------------------------------------------------------------------- NOTE: this class is the OLD version of MediaSyncSource, used to sync media items only via syncML (no http upload/download), so the file's data is exchanged via SyncML. More...

#include <MediaSyncSourceSyncMLData.h>

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

List of all members.

Public Member Functions

 MediaSyncSourceSyncMLData (const WCHAR *wname, AbstractSyncSourceConfig *sc, const StringBuffer &aDir, MediaSyncSourceParams mediaParams)
virtual int beginSync ()
 Overrides FileSyncSource::beginSync().
int insertItem (SyncItem &item)
 Overrides FileSyncSource::insertItem - implemented empty.
int modifyItem (SyncItem &item)
 Overrides FileSyncSource::modifyItem - implemented empty.
int removeItem (SyncItem &item)
 Overrides FileSyncSource::removeItem - implemented empty.
StringBuffer getItemSignature (StringBuffer &key)
 Overrides CacheSyncSource::getItemSignature().
virtual void fireClientTotalNumber (int number)
 Overwrite the way to send the total number of items to the client.
void setItemStatus (const WCHAR *wkey, int status, const char *command)
 Overrides CacheSyncSource::setItemStatus().

Protected Member Functions

virtual SyncItem * fillSyncItem (StringBuffer *key, const bool fillData=true)
 Overrides CacheSyncSource::fillSyncItem().
virtual void getKeyAndSignature (SyncItem &item, KeyValuePair &kvp)
 Overrides CacheSyncSource::getKeyAndSignature().
SyncItem * getFirstItem ()
 Overrides CacheSyncSource::getFirstItem().
virtual SyncItem * getFirstNewItem ()
 Overrides CacheSyncSource::getFirstNewItem().
virtual bool filterOutgoingItem (const StringBuffer &fullName, struct stat &st)
 Used to filter outgoing items (overrides FileSyncSource::filterOutgoingItem) Filters the cache files (*.dat).
virtual bool dynamicFilterItem (const StringBuffer &fileName)
 Filters a specific item (dynamic filtering).
void dynamicFilterItems (Enumeration *itemKeys)
 Used to filter dynamically outgoing items.
virtual int saveCache ()
 Overrides CacheSyncSource::saveCache().
StringBuffer getLUIDFromPath (const StringBuffer &path)
 Utility method to retrieve the LUID of an item, given its path.
StringBuffer getPathFromLUID (const StringBuffer &luid)
 Utility method to retrieve the full path of an item, given its LUID.
void setSourceError (const int errorCode)
 Used to set errors in the MediaSyncSource.

Protected Attributes

MediaSyncSourceParams params
 Contains parameters used by this class.
StringBuffer filterDateString
 UTC string of the params::filterByDate (just for debugging).

Private Member Functions

bool checkCacheValidity ()
 Read the URL, username and client sw version from the cache.
bool verifyNextLUIDValue ()
 Utility method: scans the LUIDMap and check if there's a LUID >= than the passed one.
bool refreshLUIDMap ()
 Utility method: scans and compress the LUIDMap PropertyFile, removing all entries that have no correspondence in the cache.
const int readNextLUID ()
 Reads the nextLUID value from the KeyValueStore, under config folder.
void saveNextLUID (const int nextLUID)
 Stores the nextLUID value in the KeyValueStore, under config folder.

Private Attributes

KeyValueStoreLUIDMap
 Map of: Full items Path <-> Items LUID The LUID is an incremental number, different for every new item.
KeyValueStoreconfigParams
 Used to store KeyValuePairs containing config parameters used by this class.


Detailed Description

------------------------------------------------------------------------------------- NOTE: this class is the OLD version of MediaSyncSource, used to sync media items only via syncML (no http upload/download), so the file's data is exchanged via SyncML.

This was the implementation of MediaSyncSource class in v8.5, used for backward compatibility. See MediaSyncSource.h for the new implementation since v8.7. ------------------------------------------------------------------------------------- This class extends the FileSyncSource class, to define a special behavior for generic "media files" to be synchronized between the Server and a mobile Client.

Differences from FileSyncSource are:


Member Function Documentation

virtual int MediaSyncSourceSyncMLData::beginSync (  )  [virtual]

Overrides FileSyncSource::beginSync().

Checks if the pictures cache is still valid, before starting a sync. If not, the cache is cleared.

bool MediaSyncSourceSyncMLData::checkCacheValidity (  )  [private]

Read the URL, username and client sw version from the cache.

If wrong (different from the passed ones) or missing, the current cache is not valid (true is returned). This method is called by MediaSyncSource::beginSync().

Returns:
true if the cache file is valid, false if not.

virtual bool MediaSyncSourceSyncMLData::dynamicFilterItem ( const StringBuffer &  fileName  )  [protected, virtual]

Filters a specific item (dynamic filtering).

This is called AFTER the cache is created, so this is the place to set a custom filter that may change or be disabled over time. Can be reimplemented by derived classes to specify different filterings. Current filters: 1. files with size > filterBySize 2. if the filterByDate is set, files with modification date < filterByDate

Parameters:
fileName the full name of the file to be checked
Returns:
true if the file must be filtered out (not sent), false otherwise

void MediaSyncSourceSyncMLData::dynamicFilterItems ( Enumeration itemKeys  )  [protected]

Used to filter dynamically outgoing items.

Calls dynamicFilterItem() for all items in the passed array. This method is called from getFirstItem and getFirstNewItem, just before firing the total number of client's items.

Parameters:
itemKeys the Enumeration of items to be sent (newKeys for a fast sync, allKeys for a slow sync), to apply the filter

virtual SyncItem* MediaSyncSourceSyncMLData::fillSyncItem ( StringBuffer *  key,
const bool  fillData = true 
) [protected, virtual]

Overrides CacheSyncSource::fillSyncItem().

The SyncItem key set is the LUID of this item. It is used by the method getXXXItem to complete the SyncItem.

Reimplemented from FileSyncSource.

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

Used to filter outgoing items (overrides FileSyncSource::filterOutgoingItem) Filters the cache files (*.dat).

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

virtual void MediaSyncSourceSyncMLData::fireClientTotalNumber ( int  number  )  [virtual]

Overwrite the way to send the total number of items to the client.

This is because the MediaSyncSource has to remove some fake items in the cache file (see fillItemModifications()), it was called by CacheSyncSource. It should not be overloaded... of items that will be updated

SyncItem* MediaSyncSourceSyncMLData::getFirstItem (  )  [protected]

Overrides CacheSyncSource::getFirstItem().

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

Compared to te CacheSyncSource implementation:

  • applies the (dynamic) filtering on the allItems keys (like the date filtering).

virtual SyncItem* MediaSyncSourceSyncMLData::getFirstNewItem (  )  [protected, virtual]

Overrides CacheSyncSource::getFirstNewItem().

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

Compared to te CacheSyncSource implementation:

  • cleans up the special properties found in the MEDIA cache (url, username, swv).
  • applies the (dynamic) filtering on the newItems keys (like the date filtering).

StringBuffer MediaSyncSourceSyncMLData::getItemSignature ( StringBuffer &  key  ) 

Overrides CacheSyncSource::getItemSignature().

Gets the signature of an item given its full path. The signature is the timestamp of last modification time.

Parameters:
key the key of the item (its full path and name)
Returns:
the signature of the selected item (last modification time)

virtual void MediaSyncSourceSyncMLData::getKeyAndSignature ( SyncItem &  item,
KeyValuePair &  kvp 
) [protected, virtual]

Overrides CacheSyncSource::getKeyAndSignature().

Utility method that populates the keyValuePair with the couple key/signature starting from the SyncItem. The SyncItem key set is the LUID of this item. Used in the addItem and updateItem

Parameters:
item - IN: the SyncItem
kvp - OUT: the KeyValuePair to be populate

StringBuffer MediaSyncSourceSyncMLData::getLUIDFromPath ( const StringBuffer &  path  )  [protected]

Utility method to retrieve the LUID of an item, given its path.

This is called for outgoing items: we send a LUID as key to the Server.

StringBuffer MediaSyncSourceSyncMLData::getPathFromLUID ( const StringBuffer &  luid  )  [protected]

Utility method to retrieve the full path of an item, given its LUID.

This is called for incoming items and when receiving item's status: we need the full path to update the cache. Note: returns a NULL StringBuffer if LUID not found in the LUIDMap.

Parameters:
luid the item's LUID
Returns:
the item's full path (NULL StringBuffer if LUID not found)

const int MediaSyncSourceSyncMLData::readNextLUID (  )  [private]

Reads the nextLUID value from the KeyValueStore, under config folder.

Returns:
the nextLUID value read

bool MediaSyncSourceSyncMLData::refreshLUIDMap (  )  [private]

Utility method: scans and compress the LUIDMap PropertyFile, removing all entries that have no correspondence in the cache.

This method is called before saving the LUIDMap file at the end of sync to avoid the propertyfile growing indefinitely.

Returns:
true if the LUIDMap was resized

virtual int MediaSyncSourceSyncMLData::saveCache (  )  [protected, virtual]

Overrides CacheSyncSource::saveCache().

Saves the cache and the LUID_Map into the persistent store. Adds the special properties (url, username, swv) to the cache file. Set the files attribute to hidden (TODO).

void MediaSyncSourceSyncMLData::saveNextLUID ( const int  nextLUID  )  [private]

Stores the nextLUID value in the KeyValueStore, under config folder.

This method is called in case a new item is found locally, and so a new LUID is generated for it.

Parameters:
nextLUID the updated value of nextLUID.

void MediaSyncSourceSyncMLData::setItemStatus ( const WCHAR *  wkey,
int  status,
const char *  command 
)

Overrides CacheSyncSource::setItemStatus().

The key received from Server is the item's LUID. We need to retrieve the item's path from the LUID (full path is the key fro the cache).

void MediaSyncSourceSyncMLData::setSourceError ( const int  errorCode  )  [protected]

Used to set errors in the MediaSyncSource.

Will set the source state (error state), the source's last error code and source's last error message.

Parameters:
errorCode the error code

bool MediaSyncSourceSyncMLData::verifyNextLUIDValue (  )  [private]

Utility method: scans the LUIDMap and check if there's a LUID >= than the passed one.

If so, updates the params::nextLUID value and returns true. This method is called just once in the constructor.


Member Data Documentation

Used to store KeyValuePairs containing config parameters used by this class.

It is saved under the system config folder, with name "<sourcename>_params.ini". Actually tho only parameter used is 'nextLUID', which is an incremental number used as the item's key when sending items to the Server (to be sure the key is unique).

Map of: Full items Path <-> Items LUID The LUID is an incremental number, different for every new item.

It's used as the SyncItem's key when sending the items to the Server, to make sure we never send 2 items with the same key. The map is stored as a PropertyFile in the 'dir' folder.


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

Generated on Tue Dec 21 15:16:21 2010 for Funambol Outlook Plug-in Library by  doxygen 1.5.7.1