#include <FileSyncSource.h>
Inheritance diagram for FileSyncSource:
Public Member Functions | |
FileSyncSource (const WCHAR *name, AbstractSyncSourceConfig *sc) | |
void | assign (FileSyncSource &s) |
void | setDir (const char *p) |
set/get the directory where to sync the files | |
const StringBuffer & | getDir () |
Enumeration * | getAllItemList () |
Get the list of all the keys stored in a StringBuffer. | |
int | removeAllItems () |
Removes all the item of the sync source. | |
int | insertItem (SyncItem &item) |
Called by the sync engine to add an item that the server has sent. | |
int | modifyItem (SyncItem &item) |
Called by the sync engine to update an item that the source already should have. | |
int | removeItem (SyncItem &item) |
Called by the sync engine to update an item that the source already should have. | |
void * | getItemContent (StringBuffer &key, size_t *size) |
Get the content of an item given the key. |
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.
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.
Implements CacheSyncSource.
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.
Implements SyncSource.
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.
item | the item as sent by the server |
Implements CacheSyncSource.
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.
item | the item as sent by the server |
Implements CacheSyncSource.
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.
item | the item as sent by the server |
Implements CacheSyncSource.
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)
key | the local key of the item | |
size | OUT: the size of the content |
Implements CacheSyncSource.