The SyncML Reference Implementation consists of the following three layers, as shown in Figure 10-2.
Figure 10-2. Architecture overview
The SyncML core layer implements the SyncML API, which is exposed to the application. The core layer is platform-independent and includes the following three modules, shown in Figure 10-3:
SyncML Manager This module manages multiple SyncML instances, controls access to the workspace buffer, and switches between sending and receiving messages.
SyncML Command Builder This module is used to generate SyncML messages. It offers the necessary functions to construct the synchronization packages and command sequences. Appropriate XML or WBXML code is generated.
SyncML Command Dispatcher This module is used to decode SyncML messages after they are received. It offers functions to interpret SyncML messages and command sequences. XML or WBXML documents are parsed, and callback functions provided by the application are invoked in order to handle each command within the parsed message. The callback functions are responsible for passing the data to the application logic.
Figure 10-3. Reference Implementation modules
The platform-specific layer provides the basic functionality used by the core layer. Modules optimized for particular target platforms can be plugged into this layer to customize the Reference Implementation for specific environments:
SyncML Workspace The SyncML Workspace handles the memory allocated to incoming and outgoing SyncML Messages. This module is designed as a plug-in, allowing different implementations for different environments. The workspace should be optimized for the particular target platform. The Reference Implementation provides sample implementations for mobile clients, as well as for PCs or servers. A server with plenty of memory available has different possibilities than a PDA or a mobile phone. Nevertheless, the architecture allows the development of a platform independent SyncML workspace if required.
SyncML Encoder/Decoder The SyncML Encoder/Decoder is designed as a plug-in, encapsulating the parsing and encoding functionality. This approach allows for changing the type of encoding (XML and/or WBXML) and taking platform-specific optimizations into account. Again, it would be possible to develop platform-independent encoders/decoders if required and if an optimization for a particular target is not intended.
The third layer encapsulates the platform-dependent library functions, such as simple memory allocation or string handling. The two layers above use these functions in order to achieve portability.
To use the Reference Implementation and to receive the decoded data, an application has to provide implementations for callback functions. These callbacks handle incoming commands and are called by SyncML while parsing a document. One of these SyncML callback functions implemented by the application, or by the transport module, allows SyncML to trigger the sending of Messages when the workspace runs out of memory.
In order to avoid redundant implementation efforts, the transport layer is not part of the Reference Implementation itself. Instead the application can take advantage of existing transport layer functionality on the individual platforms or use the transport implementation provided by SyncML.