Some days ago a friend of mine upgraded his iPhone to firmware 2.0, and boasted modestly on how he could sync his MS Exchange Calendar over air. Note that working calendar sync, and even by air is, of course, the holy grail of all mobile equipment, even for sales people.
Some months ago, I used the quite crude tool called ical2sqlite and some simple perl scripting, and built a proof-of-concept one-way sync from an ical source (OpenXchange) to the iPhone calendar via a Linux box. Now, recently I tested Saurik’s awsome porting work of a more or less complete Debian based GNU/Darwin userland, with dpkg, apt-get and a complete GCC based tool chain. Then the thought awoke: The hack should be doable again, and this time with nothing but the iPhone. No cross compilers. No helping computers. Just a simple over air sync.
And some hours later, it was done. The hard bits:
- The standard C++ libraries lacked a symlink. This gave confusing linker errors.
- GNU autotools do not support the iPhone “unix” environment yet. Thus, it was a bit difficult to get the standard configure script to understand the underlying platform, and it took a bit of guessing and trying to force through a working string.
- Find and fix a WIN32 related bug in the ical source. (The bug is fixed in version 0.31, but I could not get that to build)
I have only tested the following on a “standard” jail-breaked iPhone, running sshd on firmware 1.1.4. You need to know the root password. Google it up and change it if you have not done so already. Note that some of the steps may take quite some time.
Also note that this is not for the faint hearted first time iPhone users. This receipe will probably brick your phone, make random calls to your friends and call them unmentionable names, spring to pieces, and hurt your uncle Bob with the shards. If something breaks, you may keep all the parts. Don’t blame me. You have been warned. On the other hand, if you know some UNIX, this is just simple downloading, patching, compiling and scriping, and no rocket science.
Remember that this is a one-way sync. All info in your iPhone calendar will be erased, and replaced with the contents of the ical source.
Start with making sure the phone does not autolock, to prevent it going into “sleep” mode, so you don’t break your network connection while it’s at its most exciting (yaaawn).
From the Apptapp installer, install Perl. Then install Cydia. This may take som time, so make yourself som coffee while you wait. Follow the on-screen instrucions.
Quit the AppTapp installer, and start Cydia. Install Tapp, wget, SQLite v3, iPhone-headers, patch, libgcc, ssh, gcc, bison, flex and make. Did I forget something? Probably. This will take a while, so drink some of the coffee while waiting.
You should now have a somewhat semi-complete GNU-like build environment on a kind-of computer that is almost, but not completely different from a GNU-based UNIX-like system.
If you haven’t done this already, change the root password. The info is all over the net.
Now log into the phone using ssh. (If you are of the kind of people that likes to hurt themselves, it might also be doable via a local console shell.)
$ ssh root@iphone
Add a missing symlink for libstdc++
# cd /usr/lib
# ln -s libstdc++.6.0.4.dylib libstdc++.dylib
Change user to mobile
# su - mobile
Now we are ready for some serious work. First, we need to get a working version of FreeAssociation, that is, libical. Note that the newer version 0.31 won’t compile because of some bison/yacc issue. If you find a solution to this, add a comment or send me a mail.
$ wget http://garr.dl.sourceforge.net/freeassociation/libical-0.30.tar.gz
Unpack the source
$ tar xvzf libical-0.30.tar.gz
Get a small patch that moves an error related to WIN32 away from our context
$ wget http://init.linpro.no/ingvar/iphone/icaltimezone.nowin32.patch
$ patch -P0 < icaltimezone.nowin32.patch
The source needs perl to build, so add it to your path first.
$ export PATH=$PATH:/opt/iphone/bin # perl is there
Then configure and build the source.
$ cd libical-0.30
$ ./configure -build=arm-apple-darwin9.0.0d1
Have another cup while waiting. Fun, isn't it? Then Build the binaries.
Have yet another cup. Take a walk. Visit a friend you haven't seen for a while. Then return to your compilation. If you're lucky, it's finished.
Exit to root. Then install the binaries. They will go to /usr/local.
# cd ~mobile/libical-0.30
# make install
libical is unable to use the iPhone's own timezone database, so install it's own
# cd zoneinfo
# make install
So, we have a complete libical. The next step is to get that hideous thingie called ical2sqlite. Become the mobile user again, download and unpack the source.
# su - mobile
$ export PATH=$PATH:/opt/iphone/bin
$ wget ftp://ftp.uninett.no/linux/ubuntu/pool/universe/i/ical2sqlite/ical2sqlite_0.1.orig.tar.gz
$ tar xvzf ical2sqlite_0.1.orig.tar.gz
Now, configure and build the source. Have your coffee pot ready.
$ cd ical2sqlite
$ ./configure -build=arm-apple-darwin9.0.0d1 && make
Exit to root and install the binary
# cd ~mobile/ical2sqlite
# make install
The binary bits are now ready. Time for some scripting action.
# su - mobile
$ wget http://init.linpro.no/ingvar/iphone/update_calendar
$ chmod +x update_calendar
$ vi update_calendar
You know how to use the vi editor, right? You should at least change username, password, timezone and zuluoffset according to your calendar settings. Correct timezone and zuluoffset=0 worked well with my settings. For more info about the script, see my previous posting.
Then, you are ready to try the magic. From Cydia, install MobileTerminal. Start the terminal. Run the script
You're done, and might want to check the calendar.
To access this without starting a shell, I used the tool "Tapp". Now, what I want is a tool that makes this available as a Springboard icon, but without building a complete package. I think Erica Sadun's tool "Launch" can do this, but it is not available for firmware 1.1.4.
Next stop: Make a real two-way sync? That would take som serious programming. I'm not serious.