Upgrading DAViCal to support iOS7 devices

Are we speaking the same language?

In a previous post, I went through how to build a calendar sever using DAViCal – created by fellow kiwi Andrew McMillan.

The server has run perfectly since the day I built it, and it was only recently (read: last year) that I noticed I was no longer getting my event reminders on my iPhone. I had recently upgraded to iOS7 and assumed that maybe the authentication information had probably got scambled during the upgrade, so I deleted and re-added the user information but failed to rectify the problem. It still worked fine on my first gen iPad using iOS6 so I knew it had to be related to the upgrade.

After scouring the web for a solution, I discovered I wasn’t the only person having problems… and it wasn’t just with DAViCal. There was a lot of finger pointing and wringing of hands, but at the time I couldn’t find any solution to fix it.

I keep checking the author’s website, the DAViCal website and hoped there would be a package update but alas nothing appeared. As time marched on my interest waned until one day I forgot all about it.

A fix found…

The other day I got to thinking about my iPhone (in particular iOS7) and the how the various revisions to the iOS software had failed to fix my calendar problems. Armed with renewed vigor I jumped on the web and had a look to see if there were any fixes… and to my joy, discovered this post here (well, found a forum which ultimately linked to that location).

I copied the files, updated the database, and… success! Cross-platform access to read/write calendar entries!! For anyone else looking for the similar steps, here’s what I did.

Step one: Get the update

sudo wget http://www.inf-it.com/fixes/DAViCal_GIT-latest.tgz
sudo tar -zxvf DAViCal_GIT-latest.tgz
cd DAViCal_GIT-latest/davical

If you want a fallback option, it might be worth backing up the existing files for both davical and awl. I’m using mine on an Ubuntu server so my files are located in \usr\share\davical and \usr\share\awl.

Step two: Copy the files

sudo cp -vR /davical/* /usr/share/davical/
sudo cp -vR /awl/* usr/share/awl/

Step three: Update the database

sudo cd /usr/share/davical/dba
sudo wget http://www.inf-it.com/fixes/caldav_functions-fix2.sql
psql -U postgres davical < caldav_functions-fix2.sql

Note:

When I originally created the database I must have used the ‘postgres‘ superuser. This meant that when I tried to update the database using the user ‘davical_dba‘ I got a permission error. The original command in the sql file was:

psql -U davical_dba davical < caldav_functions-fix2.sql

Step four: Restart the server

For good measure I restarted the server, but one restarted I had no problems adding calendar entries on my iPhone, and viewing others I’d created on other calendar applications (namely Thunderbird+Lightning).

Notes on the PostgreSQL superuser

If you’re like me and the ravages of time play havoc with your memory (i.e. you forgot your postgres user password) don’t panic: you can reset it using the following steps…

sudo vi /etc/postgresql/8.4/main/pg_hba.conf

change the line for the postgres user to read

local   all         postgres                          trust

then restart the server.

sudo /etc/init.d/postgresql restart

Log into PostgreSQL and at the postgres prompt (postgres=#) change the password…

psql -U postgres

postgres=# ALTER USER postgres with password 'secure-password';

where secure-password is a password of your choice.

Change the pg_hba.conf file back…

sudo vi /etc/postgresql/8.4/main/pg_hba.conf

local   all         postgres                          md5

then restart the server.

sudo /etc/init.d/postgresql restart

Log in to psql to make sure the new password is effective.

psql -U postgres