Calendar Code Details

This page is dedicated to me finding information about the files inside the calendar code base. The information provided can be probably in the future be used in some sort of a wiki to contribute to the Mozilla Developer Network and hence be useful and be used as a quick start guide for future developers.

As always, the best information source is the code itself, but I will try to put down as much as I can understand about the code myself.

The function of this file to provide a backend for calendars whose providers need a cached calendar. The cached functionality allows one to view remote calendars offline. This feature is still experimental. More details are here

The code contains prototype definitions for calCachedCalendar and calCachedCalendarObserverHelper which is Javascript's way of defining classes and objects.

Some Major stuff that calCachedCalendar.js does is as follows:
  • Does full sync in the case of ICS provider, basically when the application goes online, the entire cache of items is thrown away, the ics file is downloaded, parsed and cached calendar is reset, in other sense, cache calendar basically is of no use, other than just for viewing the events offline.
  • In the case of CALDAV provider the cachedCalendar is much more effective. It stores the full downloaded file first when it is setup. But whenever there are changes on the server, and the application comes online, the cachedCalendar only stores the changed items, in other sense, there is a downstream sync of items that changed. This is performed by the replayChangesOn method in the caldav calendar. This is more like the functionality that should be duplicated in the offline sync scenario.
  • the calendar also handles the delete Items operations from the remote calendars. Before the remote items are deleted/modified, they are routed through the cached calendar. The cached calendar, makes a listener and attaches it to the OnOperationComplete of the remote calendar event (delete,modify or add). Hence when the operation completes successfully on the remote calendar, the cache is also changed. How simple and amazing!!
  • It has a few members, the unCachedCalendar refers to the remote calendar, and calling unCachedCalendar.deleteItem(item,listener) would trigger the deleteItem call of the remote calendar which may be an ICS or CalDAV calendar. The mCachedCalendar actually refers to the cached Calendar that is stored on the computer in an sqlite database called, cache.sqlite. Calling mCachedCalendar.deleteItem(item,listener) would actually trigger the sqlite database being modified.