зеркало из https://github.com/mozilla/pjs.git
engines now get the pbe identity directly from the identity manager; engines now know their 'enabled' status (pref); main service syncs *all* registered (enabled) engines
This commit is contained in:
Родитель
1fa3e135bc
Коммит
9a24767ab7
|
@ -102,6 +102,10 @@ Engine.prototype = {
|
||||||
get snapshotFile() { return this.serverPrefix + "snapshot.json"; },
|
get snapshotFile() { return this.serverPrefix + "snapshot.json"; },
|
||||||
get deltasFile() { return this.serverPrefix + "deltas.json"; },
|
get deltasFile() { return this.serverPrefix + "deltas.json"; },
|
||||||
|
|
||||||
|
get enabled() {
|
||||||
|
return Utils.prefs.getBoolPref("engine." + this.name);
|
||||||
|
},
|
||||||
|
|
||||||
__os: null,
|
__os: null,
|
||||||
get _os() {
|
get _os() {
|
||||||
if (!this.__os)
|
if (!this.__os)
|
||||||
|
@ -143,10 +147,18 @@ Engine.prototype = {
|
||||||
this.__snapshot = value;
|
this.__snapshot = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
_init: function Engine__init(davCollection, pbeId) {
|
get _pbeId() {
|
||||||
this._pbeId = pbeId;
|
let id = ID.get('Engine:PBE:' + this.name);
|
||||||
this._engineId = new Identity(pbeId.realm + " - " + this.logName,
|
if (!id)
|
||||||
pbeId.username);
|
id = ID.get('Engine:PBE:default');
|
||||||
|
if (!id)
|
||||||
|
throw "No identity found for engine PBE!";
|
||||||
|
return id;
|
||||||
|
},
|
||||||
|
|
||||||
|
_init: function Engine__init() {
|
||||||
|
this._engineId = new Identity(this._pbeId.realm + " - " + this.logName,
|
||||||
|
this._pbeId.username);
|
||||||
this._log = Log4Moz.Service.getLogger("Service." + this.logName);
|
this._log = Log4Moz.Service.getLogger("Service." + this.logName);
|
||||||
this._log.level =
|
this._log.level =
|
||||||
Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.engine")];
|
Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.engine")];
|
||||||
|
@ -818,8 +830,8 @@ Engine.prototype = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function BookmarksEngine(davCollection, pbeId) {
|
function BookmarksEngine(pbeId) {
|
||||||
this._init(davCollection, pbeId);
|
this._init(pbeId);
|
||||||
}
|
}
|
||||||
BookmarksEngine.prototype = {
|
BookmarksEngine.prototype = {
|
||||||
get name() { return "bookmarks"; },
|
get name() { return "bookmarks"; },
|
||||||
|
@ -929,8 +941,8 @@ BookmarksEngine.prototype = {
|
||||||
};
|
};
|
||||||
BookmarksEngine.prototype.__proto__ = new Engine();
|
BookmarksEngine.prototype.__proto__ = new Engine();
|
||||||
|
|
||||||
function HistoryEngine(davCollection, pbeId) {
|
function HistoryEngine(pbeId) {
|
||||||
this._init(davCollection, pbeId);
|
this._init(pbeId);
|
||||||
}
|
}
|
||||||
HistoryEngine.prototype = {
|
HistoryEngine.prototype = {
|
||||||
get name() { return "history"; },
|
get name() { return "history"; },
|
||||||
|
@ -953,8 +965,8 @@ HistoryEngine.prototype = {
|
||||||
};
|
};
|
||||||
HistoryEngine.prototype.__proto__ = new Engine();
|
HistoryEngine.prototype.__proto__ = new Engine();
|
||||||
|
|
||||||
function CookieEngine(davCollection, pbeId) {
|
function CookieEngine(pbeId) {
|
||||||
this._init(davCollection, pbeId);
|
this._init(pbeId);
|
||||||
}
|
}
|
||||||
CookieEngine.prototype = {
|
CookieEngine.prototype = {
|
||||||
get name() { return "cookies"; },
|
get name() { return "cookies"; },
|
||||||
|
|
|
@ -77,17 +77,21 @@ function WeaveSvc() {
|
||||||
this._initLogs();
|
this._initLogs();
|
||||||
this._log.info("Weave Sync Service Initializing");
|
this._log.info("Weave Sync Service Initializing");
|
||||||
|
|
||||||
|
// Create Weave identities (for logging in, and for encryption)
|
||||||
ID.set('WeaveID', new Identity('Mozilla Services Password', this.username));
|
ID.set('WeaveID', new Identity('Mozilla Services Password', this.username));
|
||||||
ID.setAlias('WeaveID', 'DAV:default');
|
|
||||||
|
|
||||||
ID.set('WeaveCryptoID',
|
ID.set('WeaveCryptoID',
|
||||||
new Identity('Mozilla Services Encryption Passphrase', this.username));
|
new Identity('Mozilla Services Encryption Passphrase', this.username));
|
||||||
//ID.setAlias('WeaveCryptoID', '...');
|
|
||||||
|
|
||||||
Engines.register(new BookmarksEngine(DAV, ID.get('WeaveCryptoID')));
|
// Set up aliases for other modules to use our IDs
|
||||||
Engines.register(new HistoryEngine(DAV, ID.get('WeaveCryptoID')));
|
ID.setAlias('WeaveID', 'DAV:default');
|
||||||
Engines.register(new CookieEngine(DAV, ID.get('WeaveCryptoID')));
|
ID.setAlias('WeaveCryptoID', 'Engine:PBE:default');
|
||||||
|
|
||||||
|
// Register built-in engines
|
||||||
|
Engines.register(new BookmarksEngine());
|
||||||
|
Engines.register(new HistoryEngine());
|
||||||
|
Engines.register(new CookieEngine());
|
||||||
|
|
||||||
|
// Other misc startup
|
||||||
Utils.prefs.addObserver("", this, false);
|
Utils.prefs.addObserver("", this, false);
|
||||||
|
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
|
@ -484,22 +488,18 @@ WeaveSvc.prototype = {
|
||||||
this._keyCheck.async(this, self.cb);
|
this._keyCheck.async(this, self.cb);
|
||||||
yield;
|
yield;
|
||||||
|
|
||||||
if (Utils.prefs.getBoolPref("bookmarks")) {
|
let engines = Engines.getAll();
|
||||||
this._notify(Engines.get("bookmarks").name + "-engine:sync",
|
for (let i = 0; i < engines.length; i++) {
|
||||||
this._syncEngine, Engines.get("bookmarks")).async(this, self.cb);
|
if (engines[i].enabled) {
|
||||||
yield;
|
this._notify(engines[i].name + "-engine:sync",
|
||||||
Engines.get("bookmarks").syncMounts(self.cb); // FIXME
|
this._syncEngine, engines[i]).async(this, self.cb);
|
||||||
yield;
|
engines[i].resetServer(self.cb);
|
||||||
}
|
yield;
|
||||||
if (Utils.prefs.getBoolPref("history")) {
|
if (engines[i].name == "bookmarks") { // FIXME
|
||||||
this._notify(Engines.get("history").name + "-engine:sync",
|
Engines.get("bookmarks").syncMounts(self.cb);
|
||||||
this._syncEngine, Engines.get("history")).async(this, self.cb);
|
yield;
|
||||||
yield;
|
}
|
||||||
}
|
}
|
||||||
if (Utils.prefs.getBoolPref("cookies")) {
|
|
||||||
this._notify(Engines.get("cookies").name + "-engine:sync",
|
|
||||||
this._syncEngine, Engines.get("cookies")).async(this, self.cb);
|
|
||||||
yield;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_syncEngine: function WeaveSvc__syncEngine(engine) {
|
_syncEngine: function WeaveSvc__syncEngine(engine) {
|
||||||
|
@ -520,6 +520,8 @@ WeaveSvc.prototype = {
|
||||||
|
|
||||||
let engines = Engines.getAll();
|
let engines = Engines.getAll();
|
||||||
for (let i = 0; i < engines.length; i++) {
|
for (let i = 0; i < engines.length; i++) {
|
||||||
|
if (!engines[i].enabled)
|
||||||
|
continue;
|
||||||
engines[i].resetServer(self.cb);
|
engines[i].resetServer(self.cb);
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
|
@ -533,6 +535,8 @@ WeaveSvc.prototype = {
|
||||||
let self = yield;
|
let self = yield;
|
||||||
let engines = Engines.getAll();
|
let engines = Engines.getAll();
|
||||||
for (let i = 0; i < engines.length; i++) {
|
for (let i = 0; i < engines.length; i++) {
|
||||||
|
if (!engines[i].enabled)
|
||||||
|
continue;
|
||||||
engines[i].resetClient(self.cb);
|
engines[i].resetClient(self.cb);
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
|
@ -545,6 +549,8 @@ WeaveSvc.prototype = {
|
||||||
},
|
},
|
||||||
_shareBookmarks: function WeaveSync__shareBookmarks(username) {
|
_shareBookmarks: function WeaveSync__shareBookmarks(username) {
|
||||||
let self = yield;
|
let self = yield;
|
||||||
|
if (Engines.get("bookmarks").enabled)
|
||||||
|
return;
|
||||||
Engines.get("bookmarks").share(self.cb, username);
|
Engines.get("bookmarks").share(self.cb, username);
|
||||||
let ret = yield;
|
let ret = yield;
|
||||||
self.done(ret);
|
self.done(ret);
|
||||||
|
|
|
@ -11,10 +11,10 @@ pref("extensions.weave.ui.sharebookmarks", false);
|
||||||
pref("extensions.weave.rememberpassword", true);
|
pref("extensions.weave.rememberpassword", true);
|
||||||
pref("extensions.weave.autoconnect", true);
|
pref("extensions.weave.autoconnect", true);
|
||||||
pref("extensions.weave.enabled", true);
|
pref("extensions.weave.enabled", true);
|
||||||
pref("extensions.weave.bookmarks", true);
|
|
||||||
pref("extensions.weave.history", true);
|
|
||||||
pref("extensions.weave.cookies", false );
|
|
||||||
pref("extensions.weave.schedule", 1);
|
pref("extensions.weave.schedule", 1);
|
||||||
|
pref("extensions.weave.engine.bookmarks", true);
|
||||||
|
pref("extensions.weave.engine.history", true);
|
||||||
|
pref("extensions.weave.engine.cookies", false );
|
||||||
|
|
||||||
pref("extensions.weave.log.appender.console", "Warn");
|
pref("extensions.weave.log.appender.console", "Warn");
|
||||||
pref("extensions.weave.log.appender.dump", "Error");
|
pref("extensions.weave.log.appender.dump", "Error");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче