canmove, Confirmed users
725
edits
No edit summary |
|||
Line 6: | Line 6: | ||
== Overview == | == Overview == | ||
This page describes how to the client-side | This page describes how to the client-side Sync API for sync engines (and their helper classes). The focus is on using this API to create a new sync engine to synchronize a new data type. The data type can be anything that extension JS code has access to through any Mozilla API; this means this page must of necessity be pretty vague about reading and writing the underlying data. You'll have to fill in those blanks yourself. Try browsing the [link] xpcom documentation to find out how to get at the many types of useful data that Mozilla stores. | ||
To sync a new data type, you'll need to write an engine class* that extends the base SyncEngine class; you'll also need to extend three helper classes. Here are the classes you need to extend, and the files in which they're defined: | To sync a new data type, you'll need to write an engine class* that extends the base SyncEngine class; you'll also need to extend three helper classes. Here are the classes you need to extend, and the files in which they're defined: | ||
# <tt>SyncEngine</tt>, in <tt> | # <tt>SyncEngine</tt>, in <tt>services/sync/modules/engines.js</tt> | ||
# <tt>CryptoWrapper</tt>, in <tt> | # <tt>CryptoWrapper</tt>, in <tt>services/sync/modules/base_records/crypto.js</tt> | ||
# <tt>Store</tt>, in <tt> | # <tt>Store</tt>, in <tt>services/sync/modules/stores.js</tt> | ||
# <tt>Tracker</tt>, in <tt> | # <tt>Tracker</tt>, in <tt>services/sync/modules/trackers.js</tt> | ||
It will be very helpful to look at the existing sync engines -- such as the one for bookmarks and the one for history -- and their helper classes, for guidance. You can find these files at: | It will be very helpful to look at the existing sync engines -- such as the one for bookmarks and the one for history -- and their helper classes, for guidance. You can find these files at: | ||
* <tt> | * <tt>services/sync/modules/engines/bookmarks.js</tt> -- the <tt>BookmarkEngine</tt>, <tt>BookmarkStore</tt>, and <tt>BookmarkTracker</tt>. | ||
* <tt> | * <tt>services/sync/modules/type_records/bookmark.js</tt> -- the Record classes for the various subtypes of bookmarks | ||
* <tt> | * <tt>services/sync/modules/engines/history.js</tt> -- the <tt>HistoryEngine</tt>, <tt>HistoryStore</tt>, and <tt>HistoryTracker</tt>. | ||
* <tt> | * <tt>services/sync/modules/type_records/history.js</tt> -- the <tt>HistoryRec</tt> record class. | ||
After implementing your classes, you'll have to register them with Weave; you should also add a check-box to the Weave preferences screen to let the user turn your engine on and off. How to do these thing is explained at the end of the page. | After implementing your classes, you'll have to register them with Weave; you should also add a check-box to the Weave preferences screen to let the user turn your engine on and off. How to do these thing is explained at the end of the page. |