Talk:Lightning Offline Sync

From MozillaWiki
Jump to: navigation, search

Lightning Offline Sync

Proposed Implementation of the Offline Status Notifier

Motivation

if you are in "online mode" and for some reason your caldav server is not accessible (for example when you access Canada from Singapore…), your modifications would simply fail, unless the user would put himself in offline mode manually. What would be nice, is to have code that detects that case and triggers the switching of the calendar in particular to offline mode. And, during the "refresh" phase, would test whether the calendar has come back online and then proceeds with the reconciliation.

Implementation

50x handling workflow

Online Mode

AddItem/Adopt Item

  • calCachedCalendar::adoptItem calls up caldav::adoptItemOrUseCache with useCache set to true and passes "aListener" which inserts the item into the cache.
  • caldav::adoptItemOrUseCache sets up opListener and calls caldav::adoptItem and passes "opListener" to it
  • opListener is invoked after successful completion of event POST request
  • opListener::onOperationComplete then invokes "aListener" with a success code.
  • aListener::onOperationComplete creates the item in the cache.

50x Error Mode

  • calCachedCalendar::adoptItem calls up caldav::AdoptItemOrUseCache and passes "aListener" which inserts the item into the cache.
  • caldav::adoptItemOrUseCache sets up opListener and calls up caldav::doAdoptItem with "opListener"
  • caldav::doAdoptItem passes addListener to the POST request
  • addListener::onOperationComplete is invoked with a status of 50x
  • addListener::onOperationComplete invokes opListener::onOperationComplete with a NS_ERROR_CONNECTION_REFUSED status
  • opListener::onOperationComplete invokes adoptOfflineItem and passes it "listener"
  • adoptOfflineItem invokes listener on successful completion.
  • listener::onOperationComplete invokes "aListener::onOperationComplete" with a NS_ERROR_CONNECTION_REFUSED status msg

It makes sense not to return a success code to "aListener" since there was no successful execution of the normal online mode.

Reconcile Mode

  • reconcileAddedItems calls up addItemOrUseCache with useCache set to 'false' and passes in "addListener"
  • addItemOrUseCache calls up caldav::addItem and passes in "addListener"
  • if the server update is successful, addListener::onOperation is invoked with success
  • addListener::onOperationComplete removes the offline flag associated with the item