#include <SyncManager.h>
Public Member Functions | |
SyncManager (AbstractSyncConfig &config, SyncReport &report) | |
Initialize a new sync manager. | |
int | prepareSync (SyncSource **sources) |
Prepares the sync, performing authentication and device capability exchange. | |
int | sync () |
Starts the synchronization phase. | |
int | endSync () |
Performs the commit phase of the synchronization. | |
DevInf * | createDeviceInfo () |
Gathers the various bits and pieces known about the client and its sources and builds a SyncML devinfo 1.2 instance. | |
bool | askServerDevInf () |
Checks whether we need to ask the Server capabilities or not. | |
void | clearServerDevInf () |
Utility method, clears all the configuration params of Server caps. | |
void | setTransportAgent (TransportAgent *t) |
Sets a defined TransportAgent to be used during sync. | |
const StringBuffer | lookupMappings (Enumeration &mappings, const StringBuffer &guid) |
Scans the mappings (enumeration of pairs LUID,GUID) and searches for the correspondent LUID (key) associated to the passed GUID (value). | |
Private Member Functions | |
void | encodeItemKey (SyncItem *syncItem) |
void | decodeItemKey (SyncItem *syncItem) |
void | initialize () |
bool | readSyncSourceDefinition (SyncSource &source) |
bool | commitChanges (SyncSource &source) |
int | assignSources (SyncSource **sources) |
Status * | processSyncItem (Item *item, const CommandInfo &cmdInfo, SyncMLBuilder &syncMLBuilder) |
bool | checkForServerChanges (SyncML *syncml, ArrayList &statusList) |
const char * | getUserAgent (AbstractSyncConfig &config) |
Ensure that the user agent string is valid. | |
bool | isToExit () |
void | setSourceStateAndError (unsigned int index, SourceState state, unsigned int code, const char *msg) |
long | getToleranceDataSize (long size) |
bool | testIfDataSizeMismatch (long allocatedSize, long receivedSize) |
SyncItem * | getItem (SyncSource &source, SyncItem *(SyncSource::*getItem)()) |
A wrapper around the sync source's first/next iterator functions. | |
void | addMapCommand (int sourceIndex) |
Add the map command according to the current value of the member 'mappings', and clean up the member afterwards. | |
Private Attributes | |
DevInf * | devInf |
AbstractSyncConfig & | config |
SyncReport & | syncReport |
CredentialHandler | credentialHandler |
SyncMLBuilder | syncMLBuilder |
SyncMLProcessor | syncMLProcessor |
TransportAgent * | transportAgent |
The transportAgent used during sync. | |
SyncManagerState | currentState |
SyncSource ** | sources |
ArrayList | commands |
MappingsManager ** | mmanager |
int | sourcesNumber |
int | count |
char ** | sortedSourcesFromServer |
StringBuffer | syncURL |
StringBuffer | deviceId |
int | responseTimeout |
int | maxMsgSize |
int | maxObjSize |
bool | loSupport |
unsigned int | readBufferSize |
char | credentialInfo [1024] |
SyncManager::IncomingSyncItem * | incomingItem |
Static Private Attributes | |
static const char | encodedKeyPrefix [] |
It is configured via the DMTClientConfig with which it is constructed by the SyncClient::setDMConfig() and the (optional) DevInf provided to it by the client.
SyncManager::SyncManager | ( | AbstractSyncConfig & | config, | |
SyncReport & | report | |||
) |
Initialize a new sync manager.
Parameters provided to it have to remain valid while this sync manager exists.
config | required configuration | |
report | sync report reference to store sync results |
bool SyncManager::askServerDevInf | ( | ) |
Checks whether we need to ask the Server capabilities or not.
If we don't have enough Server information in the config, we need to ask the Server caps. A Client can force to ask Server caps again by .
void SyncManager::clearServerDevInf | ( | ) |
Utility method, clears all the configuration params of Server caps.
It is used to cleanup the Server caps information for example if the Server address changes.
DevInf* SyncManager::createDeviceInfo | ( | ) |
Gathers the various bits and pieces known about the client and its sources and builds a SyncML devinfo 1.2 instance.
For simplicity reasons this function is called for the currently active sync sources, changing them between runs thus causes a (valid!) retransmission of the device info.
SyncItem* SyncManager::getItem | ( | SyncSource & | source, | |
SyncItem *(SyncSource::*)() | getItem | |||
) | [private] |
A wrapper around the sync source's first/next iterator functions.
By default the data is encoded according to the "encoding" AbstractSyncSourceConfig property, unless the SyncSource already set an encoding.
In case of an error the error is logged and the item is set to NULL, just as if the source itself had returned NULL.
const char* SyncManager::getUserAgent | ( | AbstractSyncConfig & | config | ) | [private] |
Ensure that the user agent string is valid.
If property 'user agent' is empty, it is replaced by 'mod' and 'SwV' properties from AbstractDeviceConfig. If also 'mod' property is empty, return a default user agent.
config,: | reference to the current AbstractSyncConfig |
const StringBuffer SyncManager::lookupMappings | ( | Enumeration & | mappings, | |
const StringBuffer & | guid | |||
) |
Scans the mappings (enumeration of pairs LUID,GUID) and searches for the correspondent LUID (key) associated to the passed GUID (value).
It's used in case the SourceParent sent by the Server on a ADD command is a GUID value, it can happen if the Client didn't reply yet with the corresponding mapping.
mappings | the mappings Enumeration of KeyValuePair (LUID,GUID) to search into | |
guid | the GUID value to search |
Referenced by MappingsTest::testLookUpMappings().
void SyncManager::setTransportAgent | ( | TransportAgent * | t | ) |
Sets a defined TransportAgent to be used during sync.
Note: the passed pointer will be owned and deleted by SyncManager, so it MUST NOT be deleted by the caller.
int SyncManager::sync | ( | ) |
Starts the synchronization phase.
TransportAgent* SyncManager::transportAgent [private] |
The transportAgent used during sync.
It will ALWAYS be deleted in the destructor.