Changes

Jump to: navigation, search

CloudServices/Sync/FxSync/Developer/ClientAPI

599 bytes added, 22:53, 21 February 2011
Writing a Record class
After implementing your objects, you'll have to register them with the Sync service.
== Writing a Record class object ==
A Record object is a wrapper around a single instance of whatever data it is that you are syncing -- a single bookmark in the case of the bookmark engine, a single browser tab in the case of the tab enginehistory URL, password or form data entry. For some sync engines, it makes sense to bundle all data into one record. The tabs and so onpreferences engines work that way.
There's a class an object called <tt>CryptoWrapper</tt> defined in <tt>services/sync/modules/base_records/cryptorecord.js</tt>, which handles all the encryption and decryption of your record for you. All you have to do is write a class an object that extends <tt>CryptoWrapper</tt> and maintains a property called <tt>cleartext</tt>. <tt>cleartext</tt> must be a JSON-dictionary-style able object; put . Put into it all values that you want to have encrypted, stored on the server, decrypted, and synced up.
You may find it useful to write getters and setters for various properties of your Record classrecord implementation.
The skeleton of a sample Record classrecord implementation:
<pre>
function FooRecord(uricollection, id) { CryptoWrapper.call(this, uricollection, id);
}
FooRecord.prototype = {
__proto__: CryptoWrapper.prototype,
_logName: "Record.Foo", ttl: FOO_TTL, // optional
get bar() this.cleartext.bar,
set bar(value) {
this.cleartext.bar = value;
},
 
get baz() this.cleartext.baz,
set baz(value) {
this.cleartext.baz = value;
}
};
</pre>
 
To save all that typing for declaring the getters and setters, you can also use <tt>Utils.deferGetSet</tt>:
 
<pre>
function FooRecord(collection, id) {
CryptoWrapper.call(this, collection, id);
}
FooRecord.prototype = {
__proto__: CryptoWrapper.prototype,
_logName: "Record.Foo",
ttl: FOO_TTL // optional
};
Utils.deferGetSet(FooRec, "cleartext", ["bar", "baz"]);
</pre>
Canmove, confirm
725
edits

Navigation menu