2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-11-06 17:37:48 -08:00
|
|
|
|
2009-05-26 14:18:45 -07:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2011-06-13 11:40:08 -07:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
Cu.import("resource://gre/modules/FileUtils.jsm");
|
2008-11-06 17:37:48 -08:00
|
|
|
|
2010-06-23 07:28:10 -07:00
|
|
|
function WeaveService() {
|
|
|
|
this.wrappedJSObject = this;
|
|
|
|
}
|
2008-11-06 17:37:48 -08:00
|
|
|
WeaveService.prototype = {
|
|
|
|
classID: Components.ID("{74b89fb0-f200-4ae8-a3ec-dd164117f6de}"),
|
|
|
|
|
2009-05-26 14:18:45 -07:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
|
|
|
|
Ci.nsISupportsWeakReference]),
|
2008-11-06 17:37:48 -08:00
|
|
|
|
|
|
|
observe: function BSS__observe(subject, topic, data) {
|
|
|
|
switch (topic) {
|
|
|
|
case "app-startup":
|
2009-05-26 14:18:45 -07:00
|
|
|
let os = Cc["@mozilla.org/observer-service;1"].
|
2010-08-12 08:03:58 -07:00
|
|
|
getService(Ci.nsIObserverService);
|
2009-10-22 12:31:45 -07:00
|
|
|
os.addObserver(this, "final-ui-startup", true);
|
2008-11-06 17:37:48 -08:00
|
|
|
break;
|
2009-10-22 17:03:51 -07:00
|
|
|
|
2009-10-22 12:31:45 -07:00
|
|
|
case "final-ui-startup":
|
2009-12-15 14:21:12 -08:00
|
|
|
// Force Weave service to load if it hasn't triggered from overlays
|
|
|
|
this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
|
|
this.timer.initWithCallback({
|
|
|
|
notify: function() {
|
2010-08-25 15:49:45 -07:00
|
|
|
Cu.import("resource://services-sync/main.js");
|
|
|
|
if (Weave.Status.checkSetup() != Weave.CLIENT_NOT_CONFIGURED)
|
|
|
|
Weave.Service;
|
2009-12-15 14:21:12 -08:00
|
|
|
}
|
|
|
|
}, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
|
2008-11-06 17:37:48 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-05-07 15:24:51 -07:00
|
|
|
function AboutWeaveLog() {}
|
|
|
|
AboutWeaveLog.prototype = {
|
|
|
|
classID: Components.ID("{d28f8a0b-95da-48f4-b712-caf37097be41}"),
|
|
|
|
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule,
|
|
|
|
Ci.nsISupportsWeakReference]),
|
|
|
|
|
|
|
|
getURIFlags: function(aURI) {
|
|
|
|
return 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
newChannel: function(aURI) {
|
2011-06-13 11:40:08 -07:00
|
|
|
let dir = FileUtils.getDir("ProfD", ["weave", "logs"], true);
|
|
|
|
let uri = Services.io.newFileURI(dir);
|
|
|
|
let channel = Services.io.newChannelFromURI(uri);
|
|
|
|
channel.originalURI = aURI;
|
|
|
|
|
2012-08-14 12:37:04 -07:00
|
|
|
// Ensure that the about page has the same privileges as a regular directory
|
|
|
|
// view. That way links to files can be opened.
|
|
|
|
let ssm = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
|
|
|
.getService(Ci.nsIScriptSecurityManager);
|
|
|
|
let principal = ssm.getSimpleCodebasePrincipal(uri);
|
|
|
|
channel.owner = principal;
|
2011-06-13 11:40:08 -07:00
|
|
|
return channel;
|
2010-05-07 15:24:51 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-06-13 11:40:08 -07:00
|
|
|
const components = [WeaveService, AboutWeaveLog];
|
2012-10-31 09:13:28 -07:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|