I've been using the iPhone for a couple of months now and one thing that kept bugging me was that iTunes does not allow you to specify a server based calendar as the calendar to sync events created on the iPhone to. It only allows to sync events created on the iPhone to local calendars in iCal. Since I'm using Zimbra as my server for mail, calendar, etc. and I want to be able to update it also when I'm not near my MacBook Pro that becomes pretty annoying. In OS X Leopards iCal you can subscribe to server based calendar and also update them, so it's a mistery to my why the iPhone events can't be synced to a CalDAV server.

Anyways, a nice challenge to solve and it's actually pretty easy using Applescript. I've set up iCal to subscribe to the CalDAV server. So from iCal (and the Zimbra web client) I'm working on the same data. Then there an iCal local calendar defined (named iPhone) and in iTunes this calendar is specified as the one where new events created on the iPhone should be stored. The server based Calendar that iCal is subscribed to is also selected in iTunes to be sync to the iPhone.

So now the only we need to accomplish is get the events created on the iPhone into the CalDAV server. The following Applescript does this for me:

tell application "iCal"
set allEvents to every event in calendar "iPhone"
repeat with theEvent in allEvents
make new event at end of events of calendar "Calendar"
with data theEvent
delete theEvent
end repeat
reload calendars
end tell

 

This script is scheduled to run eveny 15 minutes and simply copies all events found in the iPhone calendar to the server Calendar and then removes it from the iPhone. Works nicely and the only drawback left is that events are not sync-ed in realtime, I have to do a sync between the MacBook and the iPhone... but who knows, maybe that can be improved using the push capabilities that are part of iPhone 2.0.

3 comments:

  1. Gero said...

    Greetings Gero,

    This issue is exactly the same I had (except I'm using Kerio as mailserver).

    I'm having a problem though, trying to run/compile the script, it gives a syntax-error on the line 'with Data theEvent'. The word 'Data' is highlighted..

    I'm a noob on scripts, but what's wrong here?

    Thanks...

    Martijn Smulders
    Note: Comment imported. Original by Martijn Smulders ( email: martyn@iae.nl website: null ) at 2008-06-26 09:45  

  2. Gero said...

    Hi Martijn,

    I did a little reformatting on the script such that it fits with the width of the blog entry. Probably when put "with data theEvent" at the end of the previous line it will work fine.

    Gero
    Note: Comment imported. Original by Gero Vermaas ( email: gero@vermaas.net website: http://vermaas.net ) at 2008-06-26 09:55  

  3. Gero said...

    Works perfectly now!

    (jee, I'm really a noob)
    Note: Comment imported. Original by Martijn Smulders ( email: martyn@iae.nl website: null ) at 2008-06-26 10:15  

Post a Comment