Saturday 6 February 2010

Akondai / KAddressBook / Google Error

Background

Following the installation of Akondai, I can sync with google and fetch / update calendar entries, and fetch contacts, but when I try to add the new contact "Google Test" with a phone number of "1234" on my PC using KAddressbook, I get an error - "Failed adding new contact".

Information Gathering

I run the Akondai Console, and enable debugging, and I see:

NotificationManager::notify ( Item (678, ) in collection 7 added )

AgentBase(akonadi_googledata_resource_1): Failed adding new contact.

And

0x9b81c50 * OK Akonadi Almost IMAP Server [PROTOCOL 15]

0x9b81c50 0 LOGIN "kontact-476707713"

0x9b81c50 0 OK User logged in

0x9b81c50 1 BEGIN

0x9b81c50 1 OK Begin completed

0x9b81c50 2 APPEND 7 0 (\MimeType[text/directory]) {141}

0x9cf8698 + Ready for literal data (expecting 141 bytes)

0x9b81c50 2 [UIDNEXT 678 DATETIME "06-Feb-2010 16:46:56 +0000"]

0x9b81c50 2 OK Append completed

0x9b81c50 3 COMMIT

0x9b81c50 3 OK Commit completed

0x9bba558 3931 X-AKLSUB 7 0 ()

0x9bba558 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9bba558 3931 OK List completed

0x9bba558 3932 UID FETCH 678 FULLPAYLOAD EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9bba558 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9bba558 3932 OK UID FETCH completed

0x9bba558 3933 X-AKLSUB 7 0 ()

0x9bba558 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9bba558 3933 OK List completed

0x9bba558 3934 UID FETCH 678 FULLPAYLOAD EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9bba558 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9bba558 3934 OK UID FETCH completed

0x9bba558 3935 X-AKLSUB 7 0 ()

0x9b0b3c0 635 X-AKLSUB 7 0 ()

0x9bba558 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9bba558 3935 OK List completed

0x9b95838 1335 X-AKLSUB 7 0 ()

0x9b95838 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9b95838 1335 OK List completed

0x9bba558 3936 UID FETCH 678 FULLPAYLOAD EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9b95838 1336 UID FETCH 678 FULLPAYLOAD EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9b0b3c0 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9b95838 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9bba558 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9b0b3c0 635 OK List completed

0x9b0b3c0 636 UID FETCH 678 FULLPAYLOAD CACHEONLY EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9bba558 3936 OK UID FETCH completed

0x9b95838 1336 OK UID FETCH completed

0x9b0b3c0 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9b0b3c0 636 OK UID FETCH completed

0x9c79110 2712 X-AKLSUB 7 0 ()

0x9c79110 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9c79110 2712 OK List completed

0x9c79110 2713 UID FETCH 678 FULLPAYLOAD EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9c79110 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9c79110 2713 OK UID FETCH completed

0x9c79110 2714 X-AKLSUB 7 0 ()

0x9c79110 * 7 0 (NAME "akonadi_googledata_resource_1" MIMETYPE (text/directory) REMOTEID "google-contacts" RESOURCE "akonadi_googledata_resource_1" CACHEPOLICY (INHERIT true INTERVAL -1 CACHETIMEOUT -1 SYNCONDEMAND false LOCALPARTS (ALL)) )

0x9c79110 2714 OK List completed

0x9c79110 2715 UID FETCH 678 FULLPAYLOAD EXTERNALPAYLOAD (UID REMOTEID COLLECTIONID FLAGS SIZE DATETIME)

0x9c79110 * 678 FETCH (UID 678 REV 0 REMOTEID "" MIMETYPE "text/directory" COLLECTIONID "7" SIZE 141 DATETIME "06-Feb-2010 16:46:56 +0000" FLAGS () PLD:RFC822 {141} BEGIN:VCARD CLASS:PUBLIC FN:Google Test N:Test;Google;;; NAME:Google Test TEL;TYPE=HOME:1234 UID:7sKGnrCVCK VERSION:3.0 END:VCARD )

0x9c79110 2715 OK UID FETCH completed

0x9b0b3c0 637 UID STORE 678 NOREV (REMOTEID.SILENT "" DIRTY.SILENT false PLD:RFC822.SILENT {141}

0x9b95d78 + Ready for literal data (expecting 141 bytes)

0x9b0b3c0 637 OK DATETIME "06-Feb-2010 16:46:56 +0000" STORE completed

0x9c0c9e0 336 STATUS 7 (MESSAGES UNSEEN SIZE)

0x9c0c9e0 * STATUS "akonadi_googledata_resource_1" (MESSAGES 60 UNSEEN 60 SIZE 111201)

0x9c0c9e0 336 OK STATUS completed

When I ise the Akondai console to look in the database, I can see the new entry I have added:
BEGIN:VCARD

CLASS:PUBLIC

FN:Google Test

N:Test;Google;;;

NAME:Google Test

TEL;TYPE=HOME:1234

UID:7sKGnrCVCK

VERSION:3.0

END:VCARD

Diagnosis


As the entry successfully gets placed into the Akondai sql database, it is assumed that the problem is caused by the communication between Akondai and google.

I know that the authentication link is OK, as the rest of the contact information came from google in the first place. Plus, I can modify an entry on google, and see the results within Kontact.

Research

It appears that there is a problem with the library that communicates with google. The libraries ARE called akonadi-googledata libgcal.

There is currently a known feature whereby contacts that have 1 or more phone number, or 1 or more email address do not synchronise correctly.

At present, I am assuming that this is the same cause as above.

The 'broken' version of libgcal is 0.98 and akonadi-googledata is 1.0.1, and the latest information can be found here: http://code.google.com/p/libgcal/issues/detail?id=50







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)