t_fischer: (frustrated)
Thomas Fischer ([personal profile] t_fischer) wrote in [community profile] linux4all2013-11-16 09:57 pm

Storing calendar events in IMAP, providing CalDAV interface

Recently, I faced the need for a synchronized calendar, i. e. a calendar synchronized between multiple devices (PC, smartphone, tablet) and maybe different persons (sharing a single calendar). Some of the big freemail providers like Google or Live/Outlook.com (Microsoft) offer online or web-based calendars. But those systems have limitations or issues such as residing in the U.S.A. (no protection for non-US citizen) or are tied to a certain application or non-standard protocol. So, there is need for a more generic solution.

On the other side, it is much easier to get an email account: Internet providers often offer those to their customers, there are both free and paid offers in different jurisdictions to choose from. A common protocol used for mail services is IMAP which stores and organizes your mail on the server and allows to synchronize across different clients. Essentially, IMAP offers the exact features you want to have for a calendar (or an address book, too), apart from the ‘mail business’

Already in 2005, KDE's Kontact allowed users to store and synchronize their calendars, address books, todo lists, etc in their IMAP accounts. Simplified, calendar events or address book entries are stored as attachments in hidden mails. Unfortunately, this feature is only used used in Kontact (to my knowledge) and thus not accessible in other clients including smartphones and tables. Now, the questions is, can this approach be generalized?

The idea I came up with, and so far I haven't found any prior art (please correct me if I am wrong), is to have a ‘translation service’ from CalDAV (for calendar events) or CardDAV (for address book entries) to IMAP. The service would appear and act as a CalDAV/CardDAV server towards the user, but instead of storing calendar events or addresses in a classical database, it would connect to an IMAP server and read or store the data in hidden mails' attachments.
Features of my proposal would be:

  • Statelessness
    In the best case, you do not have to configure the translation service, neither does it have to store any data. The IMAP server to use is configured through the authentication credentials you pass to the translation service. For example, if your IMAP server is called mail.example.com and your username is johndoe, you login into the translation service as user johndoe@mail.example.com (or maybe johndoe_mail.example.com); the password is forwarded without changes. The location and structure of the calendar data on the IMAP server is of no concern to the user, as it is managed by the translation service and hidden to the user.
  • Independent from client and IMAP server
    The translation server could run both on your local machine or on any server on the Internet. You can use any client that speaks CalDAV or CardDAV and store your data on any IMAP server you have an account for.
  • Security
    To encrypt transferred credentials and data, SSL or TLS should be used both between client and translation service and translation service and IMAP server. The translation service does not need to store credentials (the IMAP server will check them eventually). The translation service will know your IMAP password in plain text in main memory, so you have to trust the machine running the translation service. The design allows to run the translation service on your local machine as well.

Do you know if such a system already exists? I feel tempted to implement such a system, also I fear I lack the time or skills to do so properly. Any volunteers? ;-)