Bug 610832 - Make about:sync-log a directory listing. r=rnewman,mconnor

This commit is contained in:
Philipp von Weitershausen 2011-06-13 20:40:08 +02:00
parent 3e28e5010d
commit 379d494c7c
2 changed files with 17 additions and 49 deletions

View File

@ -4,8 +4,6 @@ contract @mozilla.org/weave/service;1 {74b89fb0-f200-4ae8-a3ec-dd164117f6de}
category app-startup WeaveService service,@mozilla.org/weave/service;1
component {d28f8a0b-95da-48f4-b712-caf37097be41} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log {d28f8a0b-95da-48f4-b712-caf37097be41}
component {a08ee179-df50-48e0-9c87-79e4dd5caeb1} Weave.js
contract @mozilla.org/network/protocol/about;1?what=sync-log.1 {a08ee179-df50-48e0-9c87-79e4dd5caeb1}
# Register resource aliases
resource services-sync resource:///modules/services-sync/
resource services-crypto resource:///modules/services-crypto/

View File

@ -19,6 +19,7 @@
*
* Contributor(s):
* Dan Mills <thunder@mozilla.com>
* Philipp von Weitershausen <philipp@weitershausen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -39,6 +40,8 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
function WeaveService() {
this.wrappedJSObject = this;
@ -84,53 +87,20 @@ AboutWeaveLog.prototype = {
},
newChannel: function(aURI) {
let dir = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let file = dir.get("ProfD", Ci.nsILocalFile);
file.append("weave");
file.append("logs");
file.append("verbose-log.txt");
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let ch = ios.newChannel(ios.newFileURI(file).spec, null, null);
ch.originalURI = aURI;
return ch;
let dir = FileUtils.getDir("ProfD", ["weave", "logs"], true);
let uri = Services.io.newFileURI(dir);
let channel = Services.io.newChannelFromURI(uri);
channel.originalURI = aURI;
// 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.getCodebasePrincipal(uri);
channel.owner = principal;
return channel;
}
};
function AboutWeaveLog1() {}
AboutWeaveLog1.prototype = {
classID: Components.ID("{a08ee179-df50-48e0-9c87-79e4dd5caeb1}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule,
Ci.nsISupportsWeakReference]),
getURIFlags: function(aURI) {
return 0;
},
newChannel: function(aURI) {
let dir = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
let file = dir.get("ProfD", Ci.nsILocalFile);
file.append("weave");
file.append("logs");
file.append("verbose-log.txt.1");
let ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
let ch = ios.newChannel(ios.newFileURI(file).spec, null, null);
ch.originalURI = aURI;
return ch;
}
};
let components = [WeaveService, AboutWeaveLog, AboutWeaveLog1];
// Gecko <2.0
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule(components);
}
// Gecko >=2.0
if (typeof XPCOMUtils.generateNSGetFactory == "function")
const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
const components = [WeaveService, AboutWeaveLog];
const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);