Sync module documentation

by Petter Nilsen (pettern@opera.com). Revision 0.1.

The API documentation is extracted automatically by Doxygen.

Background

The sync module contains the basic functionality for doing synchronizaton of various types of data between different types of Opera clients running on a wide range of platforms. It also contains a framework for easily being able to sync against other servers such as de.lio.us. Because of different requirements on different devices, this module is modulized as much as possible to easily be able to handle any type of data, format and protocol.

All classes that will occur in several unique instances (such as OpSyncDataItem) have a Reset() method to reset all data to the initial state. This makes it possible to have a pool of used and unused objects, which will greatly reduce the memory fragmentation and overhead on memory allocation, something that is particulary important on smaller devices.

Components

OpSyncCoordinator

This class contains higher level methods for interfacing the platform/device with the sync module. This is the only class that will created by the UI and will act as a coordinator. This class will also create the factory, parser and transport class and the UI will register its listeners with this class.

OpSyncComponentFactory

Contains he factory for creating the various components required for doing sync on a particular device. The factory should be fine grained enough to handle creation of specifics for each data type to sync. This base class will contain factories for the common lowest dominator on protocols and formats, and should be overriden where needed on devices that require specialized functionality.

OpSyncTransportProtocol

This is an abstract interface containing basic methods for setting up a connection to a server, and doing transactions on this connection. All transport protocols must inherit from this interface and implement functionality for a specific transport protocol (such as http). Authentication must also be handled in this class when needed.

OpSyncDataItem

Base class containing methods and collections to contain data of any type, regardless of the external format used for the data. Will usually not be overridden.

OpSyncParser

The abstract interface to parse data from/to the transport protocol. Must be inherited for XML or other formats. This class will create OpSyncDataItem instances.

Module flow

The data flow examples below assume http is the transport protocol and XML is the format used.

Initialization

The UI will create an instance of a OpSyncCoordinator class. The UI will then register its listener with this class.

Synchronizing data

OpSyncCoordinator will be called to initiate a synchronization. It will provide methods for adding data to be synchronized.

OpSyncCoordinator will create a OpSyncParser, which again will create one OpSyncDataItem per item to be synchronized. The OpSyncDataItemParser will then serialize the data contained in each item into a stream of data, and invoke the OpSyncTransportProtocol class to send this data.

When receiving data to update on the client from the server, OpSyncParser will parse the XML until it hits a new data record, in which case it will create (or use an already created) OpSyncDataItem for each item. When parsing is done, OpSyncCoordinator will receive the collection of items and the listener on the platform side will be called with the items.

Notifications to the UI

The UI will register a listener with the OpSyncCoordinator and will receive status notifications on the synchronizations though this listener.