The following is an archive copy from http://fourmont.org/drupal/node/2 which seems to have gone, at least temporarily.
New SyncML version 0.7.0
Sun, 01/14/2007 - 18:02 karsten
SyncML (Synchronization Markup Language) is a protocol standard defined by the Open Mobile Alliance for platform-independent information synchronization.
SyncML is mostly used as a method to synchronize contact and calendar information between some type of handheld device and a computer (personal, or network-based service), such as between a mobile phone and a Horde installation.
For some time now I've been working on a PHP PEAR package to provide a SyncML implementation. This package is part of the Horde groupware application, but is intended to be useful independent from Horde as well.
The new version 0.7.0 is a major step towards separating the SyncML part and the backend (Horde) part. There's now an example SQL backend that works with plain sql tables and does not require Horde at all.
The aim of the SyncML package is to provide a robust implementation of the SyncML protocol to allow groupware applications (especially but not limited to Horde) providing the SyncML functionality of replication their data with PDAs, phones and Outlook.
To allow integration with different groupware apps, the SyncML protocol part needs to be separated from the part communicating with the actual groupware application.
This is done by means of a Backend class that contains all the backend application (horde) dependent code.
Until now, this has been more a vague idea than concrete code but 0.7.0 does change that:
there's now an (abstract) !SyncML_Backend class in Backend.php, that defines and documents all the functions a Backend must provide. For some functionality like session handling and logging the Backend class does also provide a default implementation. Plese read the documentation at the beginning of Backend.php.
Individual backend implementation are derived from !SyncML_Backend and reside in the Backend/ directory. Currently there are two such backends:
Horde backend
This backend allows replication with the Horde groupware suite, see http://www.horde.org. Development of the SyncML package is done as part of the Horde development, so the Horde backend is the one best tested and most heavily used.
SQL backend
This is new for 0.7.0 and more or less all changes in this release were done to allow creation of this class. The SQL backend is some kind of reference implementation of a backend that uses only plain database tables. The database is directly accessed using the PEAR MDB2 package, successor to the pear DB package. The SQL backend does not require a Horde installation at all. Developers who want to create their own backend can have a look at the SQL backend and take it as a starting point for their own implementation. It provides almost all the functionality of a backend server: the only thing it lacks is conversion of different content types: for example phone1 may store an address book entry with content type text/vcard (vcard3.0, as of rfc2426) while phone2 then needs this entry presented as text/x-vcard (vcard2.1, as of http://www.imc.org\). The SQL backend can't do such a conversion. However actual backends (like Horde) normally provide it as they have to "understand" the data's content rather than just store it.
Structural Changes
The backend is one end point of the SyncML package. The other end is the place where the HTTP request gets into the System. Prior to 0.7.0 this has been a bit confusing as some of the logic was done in the Horde RPC package, from there it went to SyncML.php and in there to two other handlers. This has been greatly simplied. As of 0.7.0 there is one central function in SyncML.php:
SyncML_HandleRequest($request, $contentType, $backend = 'Horde',$backendparms = array())
This one you provide with a HTTP request and its content type: application/vnd.syncml+xml or application/vnd.syncml+wbxml as provided by the client.
pear install MDB2_Driver_mysql MDB2_Driver_mysql
- Install the SyncML package and the XML_WBXML package from http://pear.horde.org:
pear channel-discover pear.horde.org; pear install --force -c pear.horde.org SyncML XML_WBXML
- If you want to use the Funambol clients, you also need iCalendar, String and NLS:
pear install --force -c pear.horde.org iCalendar String NLS
- Create a database in your database engine (like mysql) as described in Backend/Sql.php:
require_once 'SyncML.php';
// Backend Setup:
$backend = 'Sql';
$backend_parms = array('dsn' => 'mysql://syncml:password@localhost/syncml', // adjust as required
'debug_dir' => '/tmp/sync', // debug output to this dir, must be writeable be web server
'debug_files' => true, // log all (wb)xml packets received or sent to debug_dir:
'log_level' => PEAR_LOG_DEBUG); // log everything
// Not all phpinstalls have http_raw_post_data set, ini-config needed.
// Is it also deprecated in later versions? Well, php://input works.
if( isset($GLOBALS['HTTP_RAW_POST_DATA']) )
$input = $GLOBALS['HTTP_RAW_POST_DATA'];
else
$raw_post = file_get_contents('php://input');
$response = SyncML_HandleRequest($input, $_SERVER['CONTENT_TYPE'], $backend, $backend_parms);
if (is_a($response, 'PEAR_Error')) {
header('HTTP/1.0 500 Internal Server Error');
exit;
}
/* Return the response to the client. */
header('Content-Type: ' . $_SERVER['CONTENT_TYPE']);
header('Content-length: ' . strlen($response));
header('Accept-Charset: UTF-8');
echo $response;
Where to get the SyncML package
The SyncML package is part of the Horde framework. At the moment you have to download the framework from htt://www.horde.org to obtain the SyncML and WBXML packages. It'll be included in the pear channel server as soon as possible to allow installation using the PEAR installer.
If you have any questions, send me a message to karsten at horde _dot_ org.