Android: ActiveSync (Exchange) for past calendar entries

Using my horde setup, my tablet only displayed calendar entries from the last four weeks. This behaviour is annoying, especially as it means ignoring the settings on the device. Apparently, Android only accepts the events if they have been modified recently. But there is another pitfall: even if you reset the ActiveSync state of your device using horde, you will still get only recently updated entries. Unfortunately, horde itself does not offer a method to "modify" all past calendar entries. So here is the equivalent of the linux command touch. Use it wisely (and in an automated fashion).

INSERT INTO horde_histories(
  object_uid, 
  history_action, 
  history_ts, 
  history_who) 
SELECT 
  'kronolith:' || e.calendar_id || ':' || e.event_uid,
  'add', 
  extract(epoch FROM now()), 
  'ADD YOUR ENTRY HERE' 
FROM kronolith_events e 
WHERE 
  e.event_start > '2013-01-01' AND 
  e.calendar_id = 'ADD YOUR ENTRY HERE'

Internally, horde uses a timestamp in the table horde_activesync_state in order to define a position in the timeline stored in the table horde_histories. By adding a new timeline entry for all past events, they look like modified to horde and, hence, to Android. Side note: although the event_modified column of the kronolith_events table contains a carefully updated timestamp, this timestamp is ignored for each and every output. For all requests, the value will be set to $_SERVER['REQUEST_TIME'].

Of course, you have to adjust a few values of the query above. The first placeholder should be your e-mail-address (or whatever you find in the old entries of the corresponding table). The second placeholder is the internal calendar id. The easiest way to obtain it is to look it up either in the calendar ICS export settings or in the existing entries of kronolith_events.

You may also like...

Leave a Reply

Your email address will not be published.