Archive for the ‘iphone’ Category

Syncing your ical calendar to the iPhone from Linux

Wednesday, March 12th, 2008

Many Linux users are advanced and experienced users. Those of them that also own an iPhone have probably jailbroken it to run custom third party applications as the first thing they do when they get home from their Apple pusher. Such users would like to control the content of the phone themselves, no matter what Apple wants them to do. For example, syncing mp3 and video to and from the iPhone is possible from Linux using Amarok and sshfs. I am such a user.

Now, I thought, could it be that hard to sync the calendar too? That would be extremely useful. It seems it was. I googled a bit for a solution, but found only iTunes, non-working syncml apps, and third party converting services. Do I want to send my https encrypted syncml url, username and password to some third party service provider in another part of the world over unencrypted http? I think not. Also, our groupware server runs OpenXchange, and its ical support is better than its syncml support, which is syncml v1 only. There exists starting points for syncing contacts via Evolution and an iPhone version of Funambol, but it doesn’t support the calendar.

Then I stumbled over ical2sqlite by Lucas Waye at his blog. His program seemed to be able to do what I wanted, so I tried to download it to give it a try. The source was not available from his blog anymore, but it has been accepted into Ubuntu Hardy, and can be downloaded from any mirror.

After some hours of trying and failing, I got it to work acceptable with ical data from OpenXchange, thus creating a proof-of-concept one-way sync.

Now, ical2sqlite is quite rough and unfinished work. It has some cool features, like it segfaults no matter what on x86_64, it crashes if it gets some special characters like ticks (‘), it crashes with a segfault if a description field is larger than about 1088 bytes, it crashes if it gets date fields in zulu time format, and it probably has a ton of other bugs. But if you can avoid those bugs, for example by piping the ical data through a perl script, you’re done.

Could one not write a less buggy program, or use perl only? There exists ical modules for perl, doesn’t it? Yes it does. Feel free to contribute :-)

Meanwhile, here’s what you need:

  • A jailbroken iPhone with OpenSSH available over Wifi. (iPod Touch will probably work too.)
  • A modern Linux distribution with the standard tool chain (gcc, make). Fedora and Ubuntu is nice. I have only got the program to work on i386.
  • ical (libical-dev) and sqlite (libsqlite3-dev) libraries and header files.
  • curl (wget or any perl module to download stuff would probably do too).
  • Perl. But you already have that.

Now, download ical2sqlite from an Ubuntu mirror and install it the normal way.

$ wget
$ tar xvzf ical2sqlite_0.1.orig.tar.gz
$ cd ical2sqlite/
$ ./configure
$ make
$ sudo make install

(If you run Ubuntu and have the know-how, you might want to build and install the package instead).

The next thing you need some script to download and massage the data to get around the menioned bugs. You can use mine: Just download it, edit it, and run it. (You can put it somewhere in your path and do chmod +x if you like).

This script is quite rough. A polished version should probably take options, use perl modules for converting time zone data, use more secure password and tempfile handling and so on. Feel free to contribute changes.

At least, change values for the variables icalurl, user, password, your phone’s ip-address, timezone and zuluoffset.

Note: This is one-way sync only. The existing iphone calendar will be overwritten, and all its contents lost. Proceed with care..

Then just run the script. Nice, eh?

By the way, I asked Lucas if he would fix the bugs mentioned above. Eventually, he probably will, but be patient.

iPhone: The Good, the Bad and the Ugly

Tuesday, March 11th, 2008

So, I got myself an iPhone.

I am, let’s say, more than average interested in small tech gadgets, but also like to be content with what I have, and use that for as long as possible. This means, I have had four cell phones the last fourteen years, and have rather tried to expand their use than jump on new and fancier things. I loved my Palm III to it’s complete and absolute death, after having unsuccessfully tried to resurrect it by replacing its broken screen myself. I have read a lot of long ebooks on the palm, and later, on a one-inch phone screen. I have read very, very many web pages via WAP over a 9600bps GSM connection, and used this as dial-up connection from laptops. A bit masochistic, perhaps. On the other hand, I have been to a lot of places lately with no umts/edge/gprs link, but it’s more than 10 years since I was in a place (wearing a cell phone), and could not get a GSM link.

All this time, I have missed the ultimate gadget: A pocket sized full fledged computer, for generic shell based network access, email, surfing the web, writing memos, chatting on irc, watching films, listening to music, doing GPS positioning, direct messaging, and whatnot. But up to this time, no such thing existed, and as putting a laptop in the pocket means a bit larger trousers than I prefer, I was content to reuse my old stuff until they just stopped working.

But this time, I was absolutely conquered. A friend bought an iPhone, and completely showed off. So smooth. So slick. So extremely sexy. Another friend’s friend was in the US, and brought one back. After a bit hacking, see below, it was ready for use in Norway.

Though not being the ultimate gadget, the iPhone comes closer than any gizmo I’ve seen so far.

The Good

  • Extremely slick hardware. So smoth and ooooh, so shiny, but absolutely without looking cheap. It even feels robust at the touch.
  • For a smartphone, a very large widescreen sized, glass-covered, high contrasted screen.
  • Extremely sexy user interface. Using touch screen controls for sliding and zooming is very elegant, and feels so natural. Why has nobody done this before? As the interface is self-explaining, there is no user manual. Apple is innovative as usual.
  • For a smart phone, quite stable, running a stripped version of OSX under the user interface.
  • Internet connection via EDGE or Wifi when available.
  • Real multi tasking, meaning you can listen to music while surfing the web while downloading email in the background
  • Preinstalled with built in full-fledged web browser, mail-client, ipod for music and movies, YouTube browser(!), calendar, contact database, text notes and other nice stuff
  • Easy to sync content (via iTunes)

The Bad

  • No possibility for manually battery replacement (and thus, no third party batteries). I guess my local Apple pusher could fix my battery when it dies for the price of you-should-rather-buy-a-new-one-and-by-the-way-would-you-not-like-to-see-our-new-models. Also, if one uses the iPhone for viewing films or a lot of web surfing, the battery capacity is a bit limited.
  • Can only synch with one single iTunes instance. Synching with iTunes elsewhere means deleting all content on the phone. And iTunes is the only (official )way to synch. Stupid (but see hacks below).
  • Cannot be used as an external modem (but see hacks below)
  • No 3G network. Now, even though the phone has a full fledged browser, the screen is quite small, and not built for massive web surfing. Thus, EDGE, maxing out at about 160kbps, should be enough for most things, and is also appropriate for email. In Norway, 3G means UMTS, which is a battery sucker. I can live with EDGE.
  • No cut-and-paste between applications. Stupid.
  • No way to edit and resend SMS messages. Stupid.
  • No native MMS support (but see below for hacks). With built-in email, who needs MMS? Well, my mother-in-law has no email account, but she has a cell phone with a color screen, and grandchildren. Nuff said.
  • No over-air synching of media content, calendar or other stuff except email (but this is probably hackable, though I have not tested it).
  • The user interface has some limitations and rough edges. For example, the SMS application has some bugs when displaying the messages as a dialogue series, but sometimes shows messages out of order (reported fixed in firmware 1.1.4). Another example is that the email client expands the whole IMAP folder tree, even though that, in my case, means several hundred folders, making a bit awkward to manouvre. The possibility to open and close folders, hiding subfolders, should be added.
  • Only the web browser and the media player can be rotated 90° to show content in wide screen. This should be added to other applications as well.
  • No preinstalled games that I have found.
  • No GPS (but see hacks below).
  • No IRC or other direct messaging client (but see hacks below)

The ugly

Generally, Apple has done a lot for keeping control over the device. Vendor lock-in, no third party software or hardware applications at all, no access to the underlying file system, no bluetooth network connection, and so on. This means they can in some ways control the behavour of their customers, which might be valuable (for Apple). Customers who want more freedom have to either buy another phone, or as Apple really, really asked for it, crack their way into the device.

  • Vendor lock-in: Only Apple-enslaved mobile partners in selected areas of the World do deliver activation of the iPhone, making it unavailable in countries with no Apple partner mobile service providers (like Norway). This is of course asking for trouble, and hacks are available, see below.
  • Closed for third party applications. A SDK is promised, but still unavailable (but see below for hacks).
  • Bluetooth is provided, but is closed for synching content, and only used for headphones and such. Stupid.
  • No support for third party storage, like flash cards, to expand the 8 or 16GB filesystem. Stupid.
  • As with OSX on the Macintosh, Apple is still the Evil Empire, using BSD and other licencing to tivoizate the iPhone by taking open source and Free Software, and using it without actively giving back (though some would say that this is a wanted feature of BSD software and expected use.)

Adding the missing parts – hacking the iPhone

So, since Apple asked for it so hard, there are a lot of hacks for the iPhone, making it much more valuable for the experienced user, and making it available for all public GSM network providers in the World.

Bypassing activation, Unlocking, and jailbreaking

This far, all firmware versions of the iPhone has been cracked open. Enough said, actually. The net is full of information. See for example . I found it easier to open my iPhone than to change SIM card.

Missing parts: Web and SOCKS proxy

By installing the TinyProxy package, and setting up an ad-hoc wifi network, you can use the iPhone as kind-of modem. This posting is done on a laptop using TinyProxy and my iPhone for network access. Note the settings in the configuration file tinyproxy.conf, giving access to specific networks.

And you can of course use OpenSSH’s built-in SOCKS proxy. Works as a charm (though without resovling host names, put them in /etc/hosts).

Missing parts: SwirlyMMS

As I told above, my mother-in-law has no email adress, but she has a cell phone with a color screen. And she has grandchildren. Thus MMS is a must, and Apple must have been really, really stupid to leave this part out. Enter SwirlyMMS to the rescue. This application is still a bit rough in the edges, but provides sending and receiving text and pictures, and probably any other binary content fitting in a MMS message. See for details.

Missing parts: Other third party applications: Other must-haves

  • BSD subsystem and OpenSSH
  • Navizone for GSM triangulating, giving GPS-like positioning
  • Colloquy and IM Chat for IRC and instant messaging
  • Mobile finder with picture and text plugins for viewing filesystem contents
  • Books ebook reader
  • TeVee TV program browser
  • RSS and MobileCast for exactly that
  • SIMPort for importing contacts from older GSM SIM cards
  • Labyrinth – the classical BRIO labyrinth game, exploiting the motion sensor. The ultimate show off demo app.
  • Games: Do a Google search for iphone games

Missing parts: Syncing media and calendar from Linux

After you have installed OpenSSH on the iPhone, you can sync it from Linux, using Amarok and the sshfs fuser plugin. The instructions are all over the net. Using Amarok, you are no longer bound to a single iTunes instance. A must have.

It’s possible to sync the calendar from Linux too, using ical2sqlite and some scripting to massage the data on the way. Works for me with ical data from OpenXchange. Stay tuned, and I’ll do another posting on that.

Missing parts: A GNU based unix subsystem for the iPhone

The BSD subsystem as delivered from the AppTapp installer by Nullriver Software is a bit rough. For example, setting the password using the passwd command makes the springboard startup program crash continously. Jay Freeman, a serious iphone hacker, has started the Telesphoreo project for running a subset of the GNU tools to replace the NullRiver BSD subsystem package, making it more stable and hacker friendly. For installing, he built Cydia, based on apt-get from Debian. See for more info.

Yes, by the way, he is involved in a project to build a JVM for the iPhone, based on GNU Classpath. Cool.

Make your own

Buy the O’Reilly book “iPhone Open Application Development”, and start hacking.