This week a big step has been implemented and tested fully, the ability for the user to create and edit events in the offline mode. Such a step is significant since it leaves me with only to implement the sync algorithm. Wolfgang made several changes to the idl files and interfaces. The changes include:-
- calICalendar now has flags for OFFLINE_DELETED_ITEMS and created and modified items as well which allow us to changes the behavior of getItems() accordingly.
- There is a new interface calIOfflineStorage which defines the methods used to handle offline operations, currently only 3 methods are defined, offlineDelete, offlineAdd and offlineModify and calStorageCalendar.js which implements the backend for calIStorage interface, the basic SQLite handler for cached calendar, implements these methods.
- The above methods changes the offline_journal flag, which is an additional field added to the SQL table cal_events and cal_todos. As such there was a need to write an upgrade function. This made me add code inside the calStorageUpgrade.jsm module, raising the database schema version to 20 from its current level of 19.
- Since offline_journal is not a part of the standard calIEvent interface, there would always be hacks and workarounds all over the place since which writing and reading events, the functions inside calEvent.js and calTodos.js would destroy the sql columns of the record. For example, the modifyItem function inside calStorageCalendar.js first destroys the item in the database, then adds the new modified item. This a hack, wolfing told me and hence I must make sure that it does not screw up the offline_journal flag, hence before it actually goes ahead and deletes the item record, I get the flag and restore it when the modification has completed.
Coding wise, it all looks good and the wiki has been a life saver. Seriously without it there would be no progress at all. The next step is to get the sync in place. Steps for doing this have been outlined at http://wiki.mozilla.org/Lightning_Offline_Sync