Uncategorized

Syncing Kontact with Android

I recently became the proud new owner of an Android phone, or more specifically the Samsung Galaxy S i9000. Upon purchase it was promptly rooted and had a custom rom flashed onto it. Also recently KDE 4.6 was released and after a night of compiling I was sitting at a sparkling new desktop and customising it.

But this post isn’t about KDE 4.6 and nor is it about roms and galaxys. It’s about Kontact 2, part of KDEPIM 4.6 (which is still considered unstable by upstream) and how to achieve the state of PIM-zen which everybody should achieve once in their lives. The state of PIM-zen, for those too lazy to click, is the state where your PIM data (calendar/todo/contacts/feeds/etc) is accessible through any digital medium, be it your desktop’s PIM applications, a website visited from a remote location, or your mobile phone’s bundled PIM-suite.

Syncing your Calendar and events

I’m not going to talk about syncing email, as that has been covered countless times elsewhere. So let’s start with syncing the calendar, as it is the next most prevalent in use. Google phones unsurprisingly sync well to Google accounts – and given that Google accounts have a web-based frontend too, this kills two birds with one stone in our “access everywhere” requirement of PIM-zen. So our solution is going to be Kontact 2 <–Sync–> Google’s PIM Suite <–Sync–> Android device.

Kontact 2 is completely Akonadi based. In comparison to Kontact 1, where there was a makeshift Akonadi-resource wrapper which you could add to harness Akonadi as a data source, Kontact 2 only uses Akonadi-supported sources for your data. Luckily Akonadi makes it easy to connect to data sources, and so there is a specialised Akonadi-GCal-resource which you can add.

To do this, just right click on the bottom left box in Korganizer which holds the calendar sources, click “Add Calendar”, and select “Akonadi Google Calendar Resource”.

To get the resource, you may need to install the akonadi-googledata package. After clicking OK, all that remains is that you enter in your Google username (your email), and your Google account password. It should then start syncing and working flawlessly. Your Android phone can then sync to your Google account’s calendar.

However GCal is very buggy it seems as it isn’t unlikely that you’ll be having problems such as unable to authenticate or unable to grab calendar data. After scouring the web here are a few potential solutions to problems you might have:

  • Add the resource through the Akonadi configuration, not through Korganizer’s Akonadi wizard.
  • Ensure you have suffixed @gmail.com (even if you have an @googlemail.com address) to your username.
  • Make sure you don’t use special characters (non-alphanumeric) in your password.
  • Use the latest version of libgcal (>0.9.3 should be good enough)
  • Remove any older version of libgcal.
  • If you are behind a proxy, set it properly in KDE’s system settings -> Network -> Proxy, if not, ensure it is “Connect to internet directly”. (OpenSuse’s defaults to using env variables)
  • Ensure you have ca-certificates package installed, and the certificate from https://l.google.com/ to the list of accepted certs.
  • Have at least one event in the Google Calendar or it won’t sync (bug).
  • Sign out all other account sessions as detailed here.
  • … and of course, make sure Akonadi is running. (akonadictl start)

If it doesn’t work, you may want to stop akonadiserver, then start it with akonadictl start &> log in order to get a logfile. You can then poke around to see exactly where it failed. #akonadi on freenode may be able to help.

If it still doesn’t work, don’t despair (it didn’t work for me either!), as there is an alternative sync. The alternative uses CalDAV, as opposed to directly using Google’s Data API. To use it, just select “DAV groupware resource” from the wizard from the same screenshot shown above. However when it asks for you to pick the groupware server, click Cancel. This will prompt you to enter the details manually. Now follow the instructions by Google for SunBird for setting up a CalDAV resource, and as shown below in the screenshot, then after pressing OK things should starting syncing fine.

Finally, we should note that there might be some data loss, as Google Calendar doesn’t implement all of the data fields, such as attendees to events. Another thing you might want to note is that exporting your existing KOrganizer calendar into ical/ics and then importing into Google Calendar may not work, as KOrganizer doesn’t follow the ical/ics specs properly. If you are exporting and are manually modifying the ical/ics file such that it works, ensure you define the timezone, otherwise chaos will ensue :D

Syncing your contacts

Android has, just like Calendar, a built-in autosync with your Google account’s contacts. Akonadi also has a Google Contacts resource, which you may use in similar fashion to the Google Calendar resource described above. Unfortunately it doesn’t work with me, and so I’m currently in the process of debugging it with Savago in #akonadi. YMMV, and I don’t know any good alternative to syncing this.

Syncing your todo lists

This is a pain. First off it should be plainly stated that Google’s Android does not have a stock to-do application. Google’s own laughable implementation of a to-do webapp in GMail is – well, I would use the most derogatory adjectives I could think of to describe it, but that would just mislead you into thinking that it is possible to quantify the horribleness of it (which it isn’t) – oh, where was I? Oh yes, Google’s to-do webapp doesn’t allow you to access it via ical or any sane format, is missing a ton of useful meta-tags which some people might want, and so you should probably scratch out trying to sync over Google’s to-do webapp.

The options do you have are limited to what exists on the Android marketplace to read your todo lists. The two major ones are Astrid Tasks and RememberTheMilk, both of which are very good. Let’s cover RTM first.

The biggest downside with RTM is that in order to use the Android application for it (which is very good), you have to be a RTM Pro user, which costs 25$ a year, which is actually worth it if you are really dependent on task lists. Alternatively you could use their mobile barebones webapp which looks ugly but gets the job done. Their main webinterface is probably the only webinterface I actually really enjoy using, but the downside is that you cannot interact with your tasks via KTodo – you get only readonly access via an iCal file (note that you can also use a version where your todo items are converted to events in your iCal file for use through the KOrganizer interface). So the final setup goes somewhat like this RTM Android App <– Push/scheduled syncs –> RTM Website and/or Google Calendar <– Read-only iCal file –> KTodo. It should be noted that RTM supports syncing with your Google Calendar as well, so that’s an added plus if you want to use that interface. Note that there is also a RTM Plasmoid, which just adds icing to the cake.

The alternative is Astrid Tasks. Whilst interfacewise a little more clunky it still does get things done. It can sync with a “space” on the online saas Producteev, which in turn allows you to manage it from there. It also does a two-way sync with Google’s to-do webapp, but is known to be buggy, YMMV. However from there it doesn’t seem to have a way to sync with KTodo. Luckily, in a twisted sort of way, it does allow you to sync to RTM via a now unofficial sync (due to RTM’s policies of not allowing other companies to make added profit from their system), and using RTM you can then do the same sync as above. However if you use Astrid Tasks even with syncing to RTM, you don’t need to be a RTM Pro user and hence everything is free. Your options are therefore Astrid Tasks Android App <–> Producteev/Google, or Astrid Tasks Android App <–> RTM <– Read-only iCal file –> KTodo.

There is a third alternative – GTDAgenda. This webapp closely follows the original principles of Getting Things Done by David Allen. It’s a really powerful tool and comes with both a mobile site and Android application too. The only downside is that they are rather expensive and their free version is rather stripped down. Even when stripped down it does seem a little overkill for my needs, but it might be different for you.

My personal reccomendation is to just go with RTM.

Syncing your RSS feeds

Syncing your RSS feeds are a little tricky now that Akregator’s Google Reader sync is unmaintained and broken. Also Google doesn’t have a stock feeds application (why, oh why, Google, do you leave out the basics!) – update: actually it turns out they have recently published one. This pretty much limits you to running any Android app which syncs with Google Reader (there are a few out there, I personally use Pulse) – or you could just access Google Reader’s mobile application, which is really attractive for a mobile site I must say.

In the meantime, get somebody hacking on Akregator and fix that sync plugin!

… and reach your state of PIM-zen!

I hope that this guide has been helpful to those wanting to achieve that perfect sync across all their devices. Any tips and tricks I missed out please let me know in the comments.

Life & much, much more

Presenting the Nagger

Over Christmas one of my more humourous gifts to my parents was to allow them to remotely nag each other electronically. Since my dad is often overseas, this actually has some practical use.

The idea was to create a remotely synchronised dynamic wallpaper with text that could be set by another person remotely. Person A would type in some text, a wallpaper with the text formatted would be generated, Person B’s computer would detect that there is an update, download the wallpaper and set it immediately. (I originally wanted to make a pop up message, but realised that having "Go and exercise!" pop up during a powerpoint presentation with your boss wasn’t the best thing)

The system would operate as such: I would create a html form on my webserver to allow somebody to type in text. PHP would take the text and use GD to generate a .jpg file of an image with the text overlayed on top. Batch file on Windows computer would download the .jpg file (either on startup, or via cronw) via URL2FILE. Batch file will call imagemagick installed on the Windows computer to convert .jpg to .bmp because apparently that’s what Windows likes for wallpaper formats and converting on the server would mean a ultra big file download. Finally, batch file will tweak the registry to change the wallpaper and "refresh" it such that it changes immediately.

Here’s an example :)

PHP code:

<?php
if (isset($_POST['submit']) && isset($_POST['nag']) && !empty($_POST['nag'])) {
$width = 1280;
$height = 800;
$imgname = "wallpaper_blank.jpg"; # The empty blue background template
$im = imagecreatefromjpeg ($imgname);
$text = $_POST['nag'];
$textcolor = ImageColorAllocate($im, 255, 255, 255);
$font = 20;
$font_width = ImageFontWidth($font);
$font_height = ImageFontHeight($font);
$font_width = 10;
$text_width = $font_width * strlen($text);
// Position to align in center
$position_center = ceil(($width - $text_width) / 2);
$text_height = $font_height;
// Position to align in abs middle
$position_middle = ceil(($height - $text_height) / 2);
imagettftext ($im, 15, 0, $position_center, $position_middle, $textcolor,
'/path/to/ttf/fontfile/AllOverAgainAllCaps.ttf', $text); # We're offsetting this a little to give space for desktop icons
Imagejpeg($im, '/path/to/final/image/wallpaper.jpg', 100);
chmod('/path/to/final/wallpaper.jpg', 0644); # Ensure we can download it (depending on server setup)
echo 'Nag done!';
} else {
echo '<form action="" method="post">';
echo '<textarea name="nag" rows="10" cols="50"></textarea><br />';
echo '<input type="submit" name="submit" value="Nag!">';
echo '</form>';
}

Batchfile code:

C:\path\to\URL2FILE.EXE http://mysite.com/wallpaper.jpg C:\path\to\save\wallpaper.jpg
C:\path\to\imagemagick\convert.exe C:\path\to\save\wallpaper.jpg C:\path\to\save\wallpaper.bmp
REG ADD "HKCU\Control Panel\Desktop" /V Wallpaper /T REG_SZ /F /D "C:\path\to\save\wallpaper.bmp"
REG ADD "HKCU\Control Panel\Desktop" /V WallpaperStyle /T REG_SZ /F /D 2
REG ADD "HKCU\Control Panel\Desktop" /V TileWallpaper /T REG_SZ /F /D 0
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters

I thought it was cute, parents loved it.

P.S. If anybody knows a sane wait to input code into WordPress/Blogilo and have it immediately embedded in <code> tags as well as not lose whitespace, give me a poke.

Uncategorized

The state of vendor lock-in on handheld services?

In this day and age it seems as though the word smartphone has replaced (or at least become synonymous with) the traditional phones we grew up with. These devices try to tackle the usual on-the-go services: PIM, messaging, casual browsing, multimedia and social networking. However with this is also an attempt to lock users into proprietary services, say for example, Flickr. I’ve been wondering for quite some time which mobile OS actually fares better on this, with the choices being the iPhone, Blackberry, Windows Mobile, Symbian, and WebOS (that’s Palm Pre).

This is best explained through example, so let’s take Mr Hip and Trendy who are well versed in navigating Facebook for their friends, Flickr or Picasa for their latest photo albums, Last.FM for the music, iTunes for their personal collection, YouTube for cats doing funny things and Twitter for trying to up their cool. Now let’s take away the Hip and Trendy part of all that and leave us with somebody who wants to do things their own way.

We have a neatly categorised library of music and video files on our home computer, and a few re-encoded video files on a remote server specifically made for mobile viewing. None of this iTunes schrwap. We run a shoutcast service for streaming, easily accessible through dyndns. Our latest photo albums, ebook library, and latest LaTeX-compiled (to pdf) essays are neatly stored on our home computer, all tagged as necessary for Nepomuk, and mirrored to the remote server. We have a similarly synchronised set of .ical files for calendars and appointments, and vcards for contact information, and of course mail is on our very own setup on our server. As for social networking, an own-hosted modded WordPress install is used for (micro)blogging. We don’t mind a little Facebook here and there, but would also love to be kept connected on IRC. Of course it’s a-given that our remote server(s) are all equipped with (S)FTP, SSH, and Webdav support.

I don’t know much about the current state of smartphones but perhaps for those that do – can I bend it to use what I use and still feel a decent sense of integration? With this I mean drag-and-drop transfers for files and multimedia, seamless switching between local and remote locations (with support for above protocols), directory synchronisation (rsync?), PIM synchronisation as necessary for ical/vcard/mail/rss with a custom and remote location (or at least importing), and perhaps clients available (terminal emulation, anyone?) for SSH, IRC, and streaming.

Can I actually use my services the way I want them on a smartphone in this day and age?

I know I’ve had somewhat limited success on my own aging Windows Mobile phone, with third-party apps accomplishing iCal sync, SSH (putty), IRC, mail and RSS, and luckily it isn’t tied to nonsense like iTunes when I want to transfer music over. However the rest of the long-dead OS shove these few glimmers of freedom away in a dark and dusty corner of the market. I quite honestly wonder how the rest is doing – so I ask again:

Is it possible?