Changes

Jump to: navigation, search

CloudServices/Sync/FxSync/Developer/ClientAPI

521 bytes added, 23:03, 21 February 2011
Writing a Record object
* <tt>services/sync/modules/engines/history.js</tt> -- the <tt>HistoryRec</tt>,<tt>HistoryEngine</tt>, <tt>HistoryStore</tt>, and <tt>HistoryTracker</tt>.
== Writing Setting up a Record object JS Module ==
A The code for your custom sync engine should live in a <a href="https://developer.mozilla.org/en/Using_JavaScript_code_modules">JS module</a>. First off we're going to import the files mentioned above at the top the file. We're also going to import <tt>util.js</tt> as it contains many useful helpers. <pre> const Cu = Components.utils; Cu.import("resource://services-sync/engines.js"); Cu.import("resource://services-sync/record.js"); Cu.import("resource://services-sync/util.js");</pre> == The Record object == The record object is a wrapper around a single instance of whatever data it is that you are syncing -- a single bookmark, history URL, password or form data entry. For some sync engines, it makes sense to bundle all data into one record. The tabs and preferences engines work that way.
There's an object called <tt>CryptoWrapper</tt> defined in <tt>services/sync/modules/record.js</tt>, which handles all the encryption and decryption of your record for you. All you have to do is write an object that extends <tt>CryptoWrapper</tt> and maintains a property called <tt>cleartext</tt>. <tt>cleartext</tt> must be a JSON-able object. Put into it all values that you want to have encrypted, stored on the server, decrypted, and synced up.
Canmove, confirm
725
edits

Navigation menu