Friday, 5 February 2010

Kontact /KMail Sync with Akonadi

Introduction

Akonadi is a program that sits between applications and enables them to share calendar and contact information in an application indepdendent way.

I have used it to sync Kontact (KMail etc...) with Google Mail contacts / calendar and in turn, synced that with my Nexus One Android phone.

This note describes how to get Kontact to sync with Google, however, for me, there is still a significant bug: When I change contact details within Kontact, Akonadi crashes, and the contact information is removed from Google (although it stays in Kontact).

There is currently a known bug in libgcal / akonadi-userdata (versions 0.93 & 1.0.1), which are used to synchronise with Google. The bug means that any contact with more than one email address or telephone number, won't synchronise correctly. More information can be found here.

Install Akonadi


By default, Mandrive 2010 comes pre-installed with Akonadi, but if your system hasn't got it, here is what I am using:
  • akonadi-1.2.1-5mdv2010.0.i586
  • mysql-core-5.1.42-0.1mdv2010.0.i586
  • mysql-common-5.1.42-0.1mdv2010.0.i586
Now interestingly, akonadi requires an sql server (mysqld), however, it doesn't appear to be used for the calendar sync, nor for the contacts retrieval. If you want to update contacts on your PC, however, this is where the mysqld comes into play.

Run AkonadiTray

Launch AkonadiTray from the start menu
Select Start

Get mysqld to Work Correctly

In a terminal or console, type the following
akonadictl stop
mysql_install_db --datadir=$HOME/.local/share/akonadi/db_data
akonadictl start
Add Your Google Account

On the Akonadi Resource Configuration tab, select Add, and add the Google Calendar Resource.

When prompted, enter your google username (ignoring the @gmail.com or @googlemail.com), and your google password - select OK.

The system immediately connects, and if your username or password is wrong, you will be told so here.

Repeat the activity for the Google Contacts Resource, and that's it, Akonadi is configured.

Configuring Kontact

Open Kontact, and go to the Calendar application. Near the bottom of the screen, is the area where you can select which calendar to use. Click on the green '+' to add a new one.

Now, select the Akonadi entry, which will probably be at the top of the list.

Give the entry a meaningful name (e.g. Google Calendar), and create it.

Make sure the calendar is enabled - you can also set it to be the default one if you wish.

That's it - everything synced.

The procedure for adding Contacts is identical (but the process is performed on the Contacts page, of course).


Auto Running

To automatically launch the akonadi server when you start Kontact, it is essential that you make sure that Akonadi is the default for Contacts and Calendar.

Starting Again


If you have been messing around, and wish to start over, this is what you need to do:

Shut down Akonadi (shut down the tray application, and kill all the akonadi processes).
Shutdown Kontact and its applications (KMail, KOrganizer etc...)
Shutdown the Kontact systray application (e.g. KOrganizer Reminder)
Remove the akonadi files in the hidden directories:
  • .kde4/share/config/akonadi*
  • .local/share/akonadi/*
  • .config/akonadi/*
Restart the Akonadi server (re-launch the tray application)

Typical SQL Errors

These errors may be seen in the SQL log, and are addressed by the blog above:
100206 10:25:29 InnoDB: Started; log sequence number 0 1055498
100206 10:25:29 [Warning] Can't open and lock time zone table: Table 'mysql.time_zone_leap_second' doesn't exist trying to live without them
100206 10:25:29 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
100206 10:25:29 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.42-log' socket: '/home/user/.local/share/akonadi/db_misc/mysql.socket' port: 0 Mandriva Linux - MySQL Standard Edition (GPL)

3 comments:

  1. This is excellent.

    However I note that when you set up the goople calendar option in Akonadi, it automatically appends your username with @gmail.
    My google calendar username is not a gmail account. How cann I get round this.

    Many thanks,

    John

    ReplyDelete
  2. My google account is at googlmail.com, but it seemed to work. Don't you register a gmail/goolemail account, and then set it up so you can use a different address. The original gmail/googlemail address is still valid if you can remember what it is?

    ReplyDelete
  3. My google calender changes are synced to kontact but my kontact calender changes are not added to the google calendar. It's one way. Any idea what is wrong?

    ReplyDelete