From 7d9edeaada8e817a914afe2460e13e609c364811 Mon Sep 17 00:00:00 2001 From: "robert%accettura.com" Date: Wed, 6 Apr 2005 22:58:43 +0000 Subject: [PATCH] add buildconfig to reporter (code by bz and debugged by biesi). Not part of any build, a=asa over IRC as this is step 1 to enabling. --- .../content/reporter/reportWizard.js | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/extensions/reporter/resources/content/reporter/reportWizard.js b/extensions/reporter/resources/content/reporter/reportWizard.js index 7cebd33f30cb..d441e971c54b 100644 --- a/extensions/reporter/resources/content/reporter/reportWizard.js +++ b/extensions/reporter/resources/content/reporter/reportWizard.js @@ -315,21 +315,38 @@ function showdetail(){ } function getBuildConfig() { - /* Commented out until it works - var ioservice = - Components.classes["@mozilla.org/network/io-service;1"]. - getService(Components.interfaces.nsIIOService); - var channel = ioservice.newChannel("chrome://global/content/buildconfig.html", - null, null); - var stream = channel.open(); - var parser = new DOMParser(); - - var buildconfig = parser.parseFromStream(stream, "UTF-8", stream.available(), - "application/xhtml+xml"); - - return buildconfig.documentElement.firstChild.textContent; - */ - return 'buildconfig'; + // bz and Biesi are my hero's for writing/debugging this chunk. + try { + netscape.security.PrivilegeManager. + enablePrivilege("UniversalXPConnect UniversalBrowserRead UniversalBrowserWrite"); + var ioservice = + Components.classes["@mozilla.org/network/io-service;1"]. + getService(Components.interfaces.nsIIOService); + var channel = ioservice.newChannel("chrome://global/content/buildconfig.html", + null, null); + var stream = channel.open(); + var scriptableInputStream = + Components.classes["@mozilla.org/scriptableinputstream;1"]. + createInstance(Components.interfaces.nsIScriptableInputStream); + scriptableInputStream.init(stream); + var data = ""; + var curBit = scriptableInputStream.read(4096); + while (curBit.length) { + data += curBit; + curBit = scriptableInputStream.read(4096); + } + // Strip out the part, since it's not valid XML + data = data.replace(/^]*>/, ""); + // Probably not strictly needed, but what the heck + data = data.replace(/^/, ""); + var parser = new DOMParser(); + var buildconfig = parser.parseFromString(data, "application/xhtml+xml"); + var text = buildconfig.getElementsByTagName("body")[0].textContent; + var start= text.indexOf('Configure arguments')+19; + return text.substring(start); + } catch(ex) { + alert(ex); + } } function makeIntBool(boolStr){ @@ -342,12 +359,6 @@ function makeIntBool(boolStr){ /* NEW WEB SERVICE MODULE */ /* Based on Apple's example implementation of SOAP at: developer.apple.com/internet/webservices/mozgoogle_source.html */ function callReporter(method,params,callback){ - try { - netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); - } catch (e) { - alert(e); - return false; - } var soapCall = new SOAPCall(); soapCall.transportURI = RMOURI; soapCall.encode(0, method, "urn:MozillaReporter", 0, null, params.length, params);