Kanojo Blog Blog-Blog

7Dec/100

Free/Open Wireless Sync your iPhone with Linux!

While using 3.x on my iPhone free (as in self-hosted and "free as in free speech") syncing was a bit of tinkering here and there but worked. With iOS 4 Apple introduced a new scheme for the Calendar (which used to be a nicely and sanely formatted sqlite file), so all the sync-tools aren't really working anymore. Iphonesync (required J/B Phones and synced to e.g. Funambol) can still read notes(?) and addresses but can't sync the calendar anymore. So i was looking for another option to sync this thingy - and found one (or two) ...

Basically there are two options - one is to use libimobiledevice, a library that achieved protocol-compatability with iPhones native interfaces (the same protocol as used by iTunes) that is just Wowzers. They also implemented a API for syncing calendar, contacts, notes and apps(?). Problem is - the API is there, but no "client" to use it. Conduit seems to have something in the planning or may have even started implementing it... but you'd have to hack or wait here.

The other option you have is checking what option that strange phone has natively, and for iOS 4.x you may discover theres calDAV and cardDAV, which are two nice (almost) standardized protocols for syncinc Calendars and Contacts... So why not just use them?

Turns out it's a bit more complicated than that. Apple has published a card/calDAV sync-server under GPL, but has made it kind of complicated to get this up and running nicely. Thanks to the thrive of the Free Software Scene there are quite some alternatives, to me to most noteworthy one is davical - a nice little service written in php to provide both cardDAV and calDAV as well as a tiny tweeny little web-interface for administration and settings. That and a variety of sync-clients on the Linux side makes just what you need! 🙂 So let's set this up!

For those of you using Debian there's the nice way to use the official davical packages on their repository. I chose another path and installed from git - i simply checked out their git-repos and moved the files in my DocumentRoot, then almost verbatimly followed theiwiki-page for Debian-Installations. One real problem was the .well-known URL scheme for cardDAV (who the f... came up with that f... up scheme for auto-discovery?). Thanks to the nice support in the davical irc channel and some brute-forcing i got it to work quite easily. Luckily i didn't need the SRV-Records proposed here (why ever?!), so all i had to do is forwarding the .well-known urls correctly:

RewriteEngine On
RewriteRule ^/.well-known(.*)$ /caldav.php/.well-known$1 [NC,L]
RewriteRule ^/principals/users(.*)$ /caldav.php$1 [NC,L]
This in the apache config did the job (adjust the path to caldav.php!), now the only thing i had to do to get cardDAV to work was creating a address-book-resource - almost to simple to be true.
Enter the corresponding information on your iPhone and you're good to go. Don't forget to set your default addressbook and calendar!
The next point coming up is linking your Linux PIM programm to cardDAV and calDAV - i chose Evolution here and that really made me shoot myself in the leg! It seems that in current versions of Evolution in the Debian repositories cardDAV support is super br00ked - the version from Debian stable didn't have any cardDAV support to begin with. So it's compile-yourself-time! Luckily the Evolution guys wrote a Makefile meant for developers to automate evolution compilation. It'll clone the GIT repositories for Evolution and most of its relevant dependencies, build them and install them to a seperated prefix (e.g. /opt/evo/). I had to tinker around a bit to get it to actually compile and not barf somewhere in between - mainly by pinning the version of the checkouts and disabling a few unneeded dependencies.  My modified Makefile (this is nothing magic, i just followed the docs on the site above) is available here for convenience. With that just follow the guide on the site above - you'll receive a Evolution nicely talking cardDAV and calDAV! On other distributions with different Evolution-Versions you might not have to compile Evolution yourself. Even more convenient!
Now just add a new calendar and addressbook in Evolution using your url to caldav.php and appropriate settings. That is:
caldav://your.hostna.me/path/to/caldav.php/USERNAME/home
as calendar-URI and
http://your.hostna.me/path/to/caldav.php/USERNAME/YOUR-CONTACTS-NAME
(whatever you chose as addressbook name before) as URL for cardDAV, also check avoid IfMatch.
That was it for me - i now can finally sync my iPhone (and probably other smartphones too?) wirelessly with using only free and open Tools with Linux! Yay!
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.