Lightning Offline Sync: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
This page is for tracking the Lightning Offline Sync Feature ([https://bugzilla.mozilla.org/show_bug.cgi?id=380060 bug 380060]) to be completed as part of the [http://www.code.google.com/soc Google Summer of Code 2011] programme. | This page is for tracking the Lightning Offline Sync Feature ([https://bugzilla.mozilla.org/show_bug.cgi?id=380060 bug 380060]) to be completed as part of the [http://www.code.google.com/soc Google Summer of Code 2011] programme. | ||
== The Idea == | == The Idea == | ||
Essentially the idea is to have the cached calendar function as a full-blown offline counterpart as well without having the need to implement any additional providers or managers. The information about offline user actions is retained in the cache and replayed when going online. | |||
The state transition table below gives the states which the offline item will transition to so as to preserve minimum number of calls to the network providers. | |||
<br> | |||
== TODOs == | == TODOs == | ||
| Line 38: | Line 40: | ||
| | | | ||
| | | done | ||
| | | | ||
Added versioning code in calStorageUpgradeHelper.jsm file. cal_events and cal_todos have an extra "offline_journal" column. and DB SCHEMA Version is 20. | Added versioning code in calStorageUpgradeHelper.jsm file. cal_events and cal_todos have an extra "offline_journal" column. and DB SCHEMA Version is 20. | ||
| Line 84: | Line 86: | ||
| | | | ||
| | | done | ||
| | | | ||
|- | |- | ||
| Line 91: | Line 93: | ||
| | | | ||
| mohit | | mohit | ||
| | | | ||
| done | | done | ||
| | | | ||
To be discussed | To be discussed | ||
| Line 104: | Line 106: | ||
| mohit | | mohit | ||
| | | | ||
| done | | done | ||
| | | | ||
|- | |- | ||
| Line 115: | Line 117: | ||
| | | | ||
| done | | done | ||
| *Note* cachedCalendar::modifyItem deletes the old item before putting in the new item with the changes hence the offline_flag is lost. Solution: make offline_journal flag part of the interface.. | | *Note* cachedCalendar::modifyItem deletes the old item before putting in the new item with the changes hence the offline_flag is lost. Solution: make offline_journal flag part of the interface.. | ||
|- | |- | ||
| Line 124: | Line 126: | ||
| wolfgang/mohit | | wolfgang/mohit | ||
| | | | ||
| | | done | ||
| Testing steps should be discussed | | Testing steps should be discussed | ||
|- | |- | ||
| Line 132: | Line 134: | ||
| | | | ||
| | | | ||
mohit | |||
| | | | ||
| | | done | ||
| | | | ||
|- | |- | ||
| Line 142: | Line 144: | ||
| | | | ||
| wolfgang | |||
| | | | ||
| | | done | ||
| | | | ||
switch code = offline to online mode and back | switch code = offline to online mode and back | ||
| Line 176: | Line 178: | ||
---- | ---- | ||
<br> | <br> | ||
== Workflows == | == Workflows == | ||
| Line 288: | Line 290: | ||
|} | |} | ||
== Additional issues == | == Additional issues == | ||
# CalDAV provider does not handle offline mode at all due to the fact that it performs the same DAV checks every time it's instantiated | #CalDAV provider does not handle offline mode at all due to the fact that it performs the same DAV checks every time it's instantiated | ||
## Calendar properties (organizerCN, organizerCN, imip.identity + CalDAV capabilities + items metadata) should be stored in the cache for offline use + most of those attributes should never be queried anymore | ##Calendar properties (organizerCN, organizerCN, imip.identity + CalDAV capabilities + items metadata) should be stored in the cache for offline use + most of those attributes should never be queried anymore | ||
## certain checks should be only performed in a separate method that should be executed when the calendar is created from the calendar creation dialog | ##certain checks should be only performed in a separate method that should be executed when the calendar is created from the calendar creation dialog | ||
## the calDavCalendar does not know its storage counterpart when calICalendar operations are first invoked, this should preferably be done right after instantiation, especially since "cache mode" will become the sole available mode, sooner or later | ##the calDavCalendar does not know its storage counterpart when calICalendar operations are first invoked, this should preferably be done right after instantiation, especially since "cache mode" will become the sole available mode, sooner or later | ||
# we should probably merge calIOfflineStorage with calISyncWriteCalendar into a single interface as those are actually part of the same functionality (and choose the former name since it's more significant) | #we should probably merge calIOfflineStorage with calISyncWriteCalendar into a single interface as those are actually part of the same functionality (and choose the former name since it's more significant) | ||
# any calendars that are not available due to network errors should automatically be put in offline mode and enable further operations | #any calendars that are not available due to network errors should automatically be put in offline mode and enable further operations | ||
# more or less off-topic: the caldav conflict dialog does not show the differences between events | #more or less off-topic: the caldav conflict dialog does not show the differences between events | ||
Revision as of 14:28, 20 June 2011
This page is for tracking the Lightning Offline Sync Feature (bug 380060) to be completed as part of the Google Summer of Code 2011 programme.
The Idea
Essentially the idea is to have the cached calendar function as a full-blown offline counterpart as well without having the need to implement any additional providers or managers. The information about offline user actions is retained in the cache and replayed when going online.
The state transition table below gives the states which the offline item will transition to so as to preserve minimum number of calls to the network providers.
TODOs
|
Item Name |
Priority |
Owner |
Deadline |
Progress |
Comments |
|---|---|---|---|---|---|
|
Adapt schema initialization and versioning code (calCalendarManager) |
mohit |
done |
Added versioning code in calStorageUpgradeHelper.jsm file. cal_events and cal_todos have an extra "offline_journal" column. and DB SCHEMA Version is 20. | ||
|
Add search flags "ITEM_FILTER_OFFLINE_DELETED", "ITEM_FILTER_OFFLINE_CREATED" and "ITEM_FILTER_OFFLINE_UPDATED" |
wolfgang |
done | |||
|
|
wolfgang |
cancelled | Not needed since ALL_ITEMS = 0xffff and our flags are = [29..31] | ||
|
Adapt getItems in calStorageCalendar with the above |
mohit |
done | |||
|
Adapt mSelectNonRecurringEventsByRange and this.mSelectNonRecurringTodosByRange queries |
mohit |
done | |||
|
Write offline addItem method (calStorageCalendar::addOfflineItem) |
mohit | done |
To be discussed | ||
|
Write offline delete method (calStorageCalendar::deleteOfflineItem) |
mohit | done | |||
|
Write offline modify method (calStorageCalendar::modifyOfflineItem) |
mohit |
done | *Note* cachedCalendar::modifyItem deletes the old item before putting in the new item with the changes hence the offline_flag is lost. Solution: make offline_journal flag part of the interface.. | ||
|
Test the above |
wolfgang/mohit | done | Testing steps should be discussed | ||
|
Write replay method |
mohit |
done | |||
|
Write "switch code" in calCachedCalendar |
wolfgang | done |
switch code = offline to online mode and back | ||
|
test the above |
wolfgang/mohit |
Testing steps shud be discussed | |||
|
Adapt code from Lightning 1.0b2 to HEAD |
mohit |
Workflows
Offline operations
- addItem:
- (entry) calCachedCalendar::addItem
- calStorageCalendar::addOfflineItem
- setup calOperationListener
- execute calStorageCalendar::addItem with above listener
- listener: update flag with 'c' value (see table below)
- listener: invoke original listener with result code
- modifyItem
- (entry) calCachedCalendar::modifyItem
- calStorageCalendar::modifyOfflineItem
- setup calOperationListener
- execute calStorageCalendar::modifyItem with above listener
- listener: update flag with 'm' value (see table below)
- listener: invoke original listener with result code
- deleteItem
- (entry) calCachedCalendar::deleteItem
- calStorageCalendar::deleteOfflineItem
- update flag with 'd' value (see table below)
- invoke original listener with result code
Note: we cannot delete the record yet as we will need to pass the complete calItem back to the online/uncached calendar during reconcilliation
- getItem/getItems
- code forwarded immediately to the calStorageCalendar
Note: getItems excludes results with offline column set to 'd', unless the ITEM_FILTER_OFFLINE_DELETED flag is passed via the item filter
Transition between online and offline modes
Nothing seems to be required at this stage.
Transition between offline and online modes
New code must be added to calCachedCalendar::onOfflineStatusChanged:
- manage deletions
- setup calOperationListener "listener1"
- invoke calStorageCalendar::getItems with ITEM_FILTER_OFFLINE_DELETE in item_filter and the above listener
- listener1 execution:
- onGetResult:
- setup empty calOperationListener "listener2"
- invoke calCachedCalendar::deleteItem (this) with each resulting events and listener2
- onOperationComplete:
- perform next step ("manage additions")
- onGetResult:
- manage additions
- setup calOperationListener "listener1"
- invoke calStorageCalendar::getItems with ITEM_FILTER_OFFLINE_CREATED in item_filter and the above listener
- listener1 execution:
- onGetResult:
- setup empty calOperationListener "listener2"
- invoke calCachedCalendar::addItem (this) with each resulting events and listener2
- onOperationComplete:
- perform next step ("manage modifications")
- onGetResult:
- manage additions
- setup calOperationListener "listener1"
- invoke calStorageCalendar::getItems with ITEM_FILTER_OFFLINE_MODIFIED in item_filter and the above listener
- listener1 execution:
- onGetResult:
- setup empty calOperationListener "listener2"
- invoke calCachedCalendar::modifyItem (this) with each resulting events and listener2
- onOperationComplete:
- perform calCachedCalendar::refresh (this)
- onGetResult:
Note: reconciliation must occur before calIChangeLog method because "uncached calendars" (at least calDavCalendar) contain code that manages conflicts during data upload. Otherwise, the local changes would immediately be overwritten by server-side changes.
Efficient model for state updates during offline operations
| From/To | Created | Modified | Deleted |
|---|---|---|---|
| (without state) | Mark as "created" | Mark as "modified" | Mark as "deleted" |
| Created | (none) | Keep as "created" | Delete record |
| Modified | (none) | Keep as "modified" | Mark as deleted |
| Deleted | (none) | (none) | (none) |
Additional issues
- CalDAV provider does not handle offline mode at all due to the fact that it performs the same DAV checks every time it's instantiated
- Calendar properties (organizerCN, organizerCN, imip.identity + CalDAV capabilities + items metadata) should be stored in the cache for offline use + most of those attributes should never be queried anymore
- certain checks should be only performed in a separate method that should be executed when the calendar is created from the calendar creation dialog
- the calDavCalendar does not know its storage counterpart when calICalendar operations are first invoked, this should preferably be done right after instantiation, especially since "cache mode" will become the sole available mode, sooner or later
- we should probably merge calIOfflineStorage with calISyncWriteCalendar into a single interface as those are actually part of the same functionality (and choose the former name since it's more significant)
- any calendars that are not available due to network errors should automatically be put in offline mode and enable further operations
- more or less off-topic: the caldav conflict dialog does not show the differences between events