SyncManager Class Reference
[Client]

This is the core class which encodes the flow of messages between client and server throughout a session. More...

#include <SyncManager.h>

Collaboration diagram for SyncManager:
[legend]

List of all members.

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
AbstractSyncConfigconfig
SyncReportsyncReport
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 []


Detailed Description

This is the core class which encodes the flow of messages between client and server throughout a session.

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.


Constructor & Destructor Documentation

SyncManager::SyncManager ( AbstractSyncConfig config,
SyncReport report 
)

Initialize a new sync manager.

Parameters provided to it have to remain valid while this sync manager exists.

Parameters:
config required configuration
report sync report reference to store sync results


Member Function Documentation

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 .

Returns:
true if we need to Get defInf to the Server

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.

Returns:
device infos, to be deleted by caller, or NULL if unavailable

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.

Parameters:
config,: reference to the current AbstractSyncConfig
Returns:
: user agent property as a new char* (need to be freed by the caller)

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.

Note:
If GUID not found, the passed GUID is returned.
Parameters:
mappings the mappings Enumeration of KeyValuePair (LUID,GUID) to search into
guid the GUID value to search
Returns:
the correspondent LUID value. If GUID not found, empty string is returned.

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.

Returns:
a status code for the sync. Can be: 0 on success an interal code (see: TODO) a status code from the server


Member Data Documentation

TransportAgent* SyncManager::transportAgent [private]

The transportAgent used during sync.

It will ALWAYS be deleted in the destructor.


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

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