Horde and Funambol Windows Mobile... It works!

| | Comments (7) | TrackBacks (1)
webmail-mobil-html3_html_2e45f44b.pngYes, Horde (a PHP framework supporting applications like IMP (for mail), Kronolith (for appointments), Turba (contacts / addressbook), and many more) is quite nice for an open source collaboration framework with a neat web interface - even PHP is not the show stopper here (normally it is).

So I managed to introduce Horde Services for 13,000 user accounts, do the complete LDAP backend connection and using Cyrus IMAP as mail server. The system runs on 4 nodes (2 active and 2 standby), serving approx 600-800 users concurrently (for Horde Web/IMP) and 2000 users concurrently (for IMAP4 mail).

But then there was the question for SyncML and synchronization of the turba addressbooks and the kronolith calendar dates to a mobile device... And yes, it had to work on Windows Mobile...

Solution is - of course - Funambol. They offer nice community edition clients free to use implementing SyncML on many platforms, Windows Mobile is one of them. But it is not so "standard compatible" - it was impossible to sync... Until I discovered the reason: The "configuration" tree which does not exist in Horde!

Short: To make Funambol Client for Windows Mobile work with the Horde framework, you have to do four things:

  • Define an extra application api in your Horde tree (I named it "syncconf").
  • Register it saying it provides "configuration/list", "configuration/listBy" and "configuration/import"
  • Patch horde/lib/SyncML/Backend.php to accept "configuration" as database
  • Patch horde/lib/SyncML/Backend/Sql.php to accept "configuration" as database
To be able to register an application you have to have at least an "api.php" file in a horde subdirectory named with the application name. So I had to do a mkdir $hordedir/syncconf, there I had to make two subdirectories: config and lib.

In my case I have three new directories:

.....horde/syncconf/
.....horde/syncconf/config
.....horde/syncconf/lib

I began with the API. This is the easy part, it looks like this:

<?php

$_services['import'] = array(
 'args' => array('content' => 'string', 'contentType' => 'string', 'source' => 'string'),
 'type' => 'string',
);

$_services['listBy'] = array(
 'type' => '{urn:horde}stringArray'
);

$_services['list'] = array(
 'type' => '{urn:horde}stringArray'
);

function _syncconf_import($content, $contentType = 'array', $import_source = null)
{
$result="";
  return $result;
}

function _syncconf_listBy()
{
  $ar=array();
 return $ar;
}

function _syncconf_list()
{
$ar=array();
 return $ar;
}

As you see, we don't return anything useful. These functions always return an empty result - an empty string or an empty array. But that will do the trick!

Save that file as "....horde/syncconf/lib/api.php" and you have your superb new API! (returning nothing, wha whaaaaa).

Now make a fake configuration (Horde DOES WANT a configuration! No chance if you don't have one). Create file conf.php as ....horde/syncconf/config/conf.php:

<?php
  $conf['syncconf']['looking_for_nice_woman_to_make_family'] = true;


put in whatever you want.

You may omit the last "?>" as all included Horde files do. I am just accomodating to their style.


Now it is time to register this "application" - hey we don't even have a user interface - all we have is a dumb api and a nonsense config. So we have to insert this in ....horde/config/registry.php  (the Horde application registry):

$this->applications['syncconf'] = array(
 'fileroot' => dirname(__FILE__) . '/../syncconf',
 'name' => 'Funambol Configuration',
 'status' => 'hidden',
 'provides' => array('configuration/listBy','configuration/list','configuration/import')
);


Please make sure that the status is 'hidden' otherwise Horde will have some big problem...

Last, define "configuration" as valid SyncML database name. Unfortunately, there is not a small configuration file to achieve this, no, you have to patch Backend.php and Backend/Sql.php (real paths described above).

In ....horde/lib/SyncML/Backend.php you'll find these lines:

    function isValidDatabaseURI($databaseURI)
    {
        $database = $this->_normalize($databaseURI);

        switch($database) {
        case 'tasks';
        case 'calendar';
        case 'notes';
        case 'contacts';
        case 'configuration';
            return true;



Note I just added "case 'configuration';" to the switch statement.

The same applies to ....horde/lib/SyncML/Backend/Sql.php:

    function isValidDatabaseURI($databaseURI)
    {
        $database = $this->_normalize($databaseURI);

        switch($database) {
        case 'tasks';
        case 'calendar';
        case 'notes';
        case 'contacts';
        case 'configuration';
        case 'events':
        case 'memo':
            return true;



Same trick as above: I just inserted "case 'configuration';".

Now you're ready to run.

The SyncML server URL is just

https://your_horde_server/horde/rpc.php

I used an Apache Alias statement to change this to

https://our_horde_site/sync

And it works.
webmail-mobil-html3_html_7d4ebf3d.pngThe first run (after entering server url, username and password) will fail though, the Funambol client just does not like to have zero data (as our api does not return anything). But after acknowledging this "error" with ok, it will work and synchronizes Contacts, Tasks, Calendar items and Notes!
Please make sure that neither "E-Mail" nor "Briefcase" are selecedt in the PIM settings of  the Funambol Client. These won't work.
Just use normal IMAP4 account data for Windows Mobile Messaging to get your email on your phone/mobile device.


Mission accomplished.

Yes, I hate PHP.
But Horde is quite cool.


1 TrackBacks

Listed below are links to blogs that reference this entry: Horde and Funambol Windows Mobile... It works!.

TrackBack URL for this entry: http://southbrain.com/mt/mt-tb.cgi/76

... denn es gibt ja wie bei vielem Anderen auch standardisierte Protokolle. Leider hat man in den Meisten für eine Aufgabe die große Auswahl zwischen unterschiedlichsten Standards oder jeder spricht so ein Bisschen seinen eigenen Dialekt.Ein gutes Bei Read More

7 Comments

Interesting post, thanks!

Actually, the WinMobile client is supposed to work even if the config sync source is not available on the server, so what you reported is actually a bug.
You may want to report this also on the Funambol tracker or mailing list, so that it can be scheduled for being fixed.

Andrea

As there are some issues between outlook/symbian/xxx events/contacts format, using horde as a syncml server can prevent some events/contacts to sync... anyway it could be a nice solution for a non enterprise environment (imho).

Nice post anyway!

Thanks for the great post.. previously i manage to sync Horde webmail with windows mobile using funambol-pocketpc-plugin-6.5.18.cab ... by pointing the URL in client to http://mailserver/rpc.php

It can sync the calendar, task, note and contact ..

Maybe i can try your solution soon .. thanks again ..

This workaround is needed for Funambol clients 7.x and 8.0.4, at the time being.

Funambol

Brilliant post. Thank you.

The proposed fix on horde doesn't work anymore in latest version, because the conf.php file format changed a bit.
This is what I've put in that file:


<?php
/* CONFIG START. DO NOT CHANGE ANYTHING IN OR AFTER THIS LINE. */
// $Horde: syncconf/config/conf.xml,v 1.6.2.5 2008/05/06 21:26:59 bklang Exp $
$conf['syncconf']['import_export'] = true;
$conf['syncconf']['allow'] = true;
/* CONFIG END. DO NOT CHANGE ANYTHING IN OR BEFORE THIS LINE. */

Please notice no "?>" at end.

Anyway, I still think that Funambol's actions ("refusing to sync if it's not Funambol server") doesn't fit with the opensource/standard advertisement they are doing. I hope it won't become another "open source" lockware

i already to the above and changes to conf.php then i get wrong username n password ..

i cant leave the password blank to clik "OK"

so glad to see that it really works! this was especially desirable for me cause I use both Funambol and Horde for business. with Funambol I can integrate email features and functions. surprised that it is so easy.

Leave a comment

July 2011

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

About

This blog is owned by:

Pascal Gienger
Kanzleistr. 14
78462 Konstanz
Phone +49 7531 584298-0
Fax +49 7531 584298-9

Google+: Profile
YouTube Channel: pascalgienger