diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-05-13 12:20:05 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-06-05 14:53:47 +0200 |
commit | 83fd7fd92e5b21a177bc16cc7318792cf63a343b (patch) | |
tree | 20f3e5a59eb9ce32a9b9973d7131e7135bd94999 /lib/libbugzilla.js | |
parent | 5b837d6739a12a516203fa0505ca562839463a79 (diff) | |
download | bugzilla-triage-83fd7fd92e5b21a177bc16cc7318792cf63a343b.tar.gz |
Really Eclipseize formatting.
Diffstat (limited to 'lib/libbugzilla.js')
-rw-r--r-- | lib/libbugzilla.js | 158 |
1 files changed, 79 insertions, 79 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 0eba70b..de93531 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -1,6 +1,6 @@ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php -// + "use strict"; var preferences = require("preferences-service"); var prompts = require("prompts"); @@ -16,12 +16,12 @@ var xrpc = require("xmlrpc"); var panelMod = require("panel"); var JSONURLDefault = "https://fedorahosted.org/released"+ - "/bugzilla-triage-scripts/Config_data.json"; +"/bugzilla-triage-scripts/Config_data.json"; var BTSPrefNS = "bugzilla-triage.setting."; var BTSPassRealm = "BTSXMLRPCPass"; var copiedAttributes = [ "queryButton", "upstreamButton", "parseAbrtBacktraces", - "submitsLogging", "XorgLogAnalysis", "objectStyle", "signature", - "suspiciousComponents" ]; + "submitsLogging", "XorgLogAnalysis", "objectStyle", "signature", + "suspiciousComponents" ]; var passwords = {}; // hash of passwords indexed by a hostname @@ -30,12 +30,12 @@ var debugOption = false; function Message(cmd, data) { console.log("Message: cmd = " + cmd + ", data = " + data); - this.cmd = cmd; - this.data = data; + this.cmd = cmd; + this.data = data; } function log(msg) { - postMessage(new Message("LogMessage", msg)); + postMessage(new Message("LogMessage", msg)); } function debug(str) { @@ -57,7 +57,7 @@ function parseXMLfromString (inStuff) { // this.response // and get just .text property out of it. TODO var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug - // 336551 + // 336551 return new XML(respStr); } @@ -92,8 +92,8 @@ function getPassword(login, domain, callback) { var switchPrompt = "Do you want to switch off features requiring password completely"; var prefName = BTSPrefNS+"withoutPassowrd"; var retObject = { - password: null, // password string or null if no password provided - withoutPass: false // whether user doesn't want to use password at all + password: null, // password string or null if no password provided + withoutPass: false // whether user doesn't want to use password at all }; passUtils.search({ @@ -218,8 +218,8 @@ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, c // In order to avoid sending whole password to the content script, // we are sending just these two Booleans. config.constantData.passwordState = { - passAvailable: (passwObj.password !== null), - withoutPass: passwObj.withoutPass + passAvailable: (passwObj.password !== null), + withoutPass: passwObj.withoutPass }; callback(new Message("CreateButtons", { @@ -252,7 +252,7 @@ exports.getURL = function getURL(url, callback) { exports.openStringInNewPanel = function openStringInNewPanel(inHTMLStr) { openURLInNewPanel("data:text/html;charset=utf-8," + - inHTMLStr); + inHTMLStr); }; var openURLInNewPanel = exports.openURLInNewPanel = function openURLInNewPanel(url) { @@ -294,33 +294,33 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) { var urlObj = urlMod.URL(url); getPassword(login, - urlObj.scheme + "://" + urlObj.host, - function (passwObj) { - if (!passwObj.password) { - // TODO this should happen, only when user presses Escape in password - // prompt - return null; - } - - var msg = new xrpc.XMLRPCMessage(method); - params.forEach(function (par) { - msg.addParameter(par); - }); - msg.addParameter(login); - msg.addParameter(passwObj.password); - - Request({ - url: url, - onComplete: function(response) { - if (response.status == 200) { - var resp = parseXMLfromString(response.text); - callback(resp.toXMLString()); - } - }, - content: msg.xml(), - contentType: "text/xml" - }).post(); - } + urlObj.scheme + "://" + urlObj.host, + function (passwObj) { + if (!passwObj.password) { + // TODO this should happen, only when user presses Escape in password + // prompt + return null; + } + + var msg = new xrpc.XMLRPCMessage(method); + params.forEach(function (par) { + msg.addParameter(par); + }); + msg.addParameter(login); + msg.addParameter(passwObj.password); + + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + var resp = parseXMLfromString(response.text); + callback(resp.toXMLString()); + } + }, + content: msg.xml(), + contentType: "text/xml" + }).post(); + } ); }; @@ -328,21 +328,21 @@ exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method login, callback) { var urlObj = urlMod.URL(url); getPassword(login, - urlObj.scheme + "://" + urlObj.host, + urlObj.scheme + "://" + urlObj.host, function (passObj) { - if (!passObj.password) { - return; - } - - makeJSONRPCCall(url, "User.login", { - login: login, - password: passObj.password, - remember: false - }, function(logResult) { - console.log("logResult = " + logResult.toSource()); - makeJSONRPCCall(url, method, params, callback); - }); + if (!passObj.password) { + return; } + + makeJSONRPCCall(url, "User.login", { + login: login, + password: passObj.password, + remember: false + }, function(logResult) { + console.log("logResult = " + logResult.toSource()); + makeJSONRPCCall(url, method, params, callback); + }); + } ); }; @@ -351,28 +351,28 @@ exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method // http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html var makeJSONRPCCall = exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback) { - var msg = { - "version": "1.1", - "method": method, - "params": params - }; + var msg = { + "version": "1.1", + "method": method, + "params": params + }; - debug("makeJSONRPCCall: out = " + JSON.stringify(msg)); + debug("makeJSONRPCCall: out = " + JSON.stringify(msg)); - Request({ - url: url, - onComplete: function(response) { - if (response.status == 200) { - debug("makeJSONRPCCall: in = " + response.text); - if ("error" in response.json) { + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + debug("makeJSONRPCCall: in = " + response.text); + if ("error" in response.json) { throw new Error("Error in JSON-RPC call:\n" + response.json.error); - } - callback(response.json.result); - } - }, - content: JSON.stringify(msg), - contentType: "application/json" - }).post(); + } + callback(response.json.result); + } + }, + content: JSON.stringify(msg), + contentType: "application/json" + }).post(); }; exports.initialize = function initialize(config, callback) { @@ -427,9 +427,9 @@ exports.initialize = function initialize(config, callback) { if ("constantData" in config.gJSONData) { config.constantData = config.gJSONData.constantData; config.constantData.queryUpstreamBug = JSON.parse( - selfMod.data.load("queryUpstreamBug.json")); + selfMod.data.load("queryUpstreamBug.json")); config.constantData.XMLRPCData = JSON.parse( - selfMod.data.load("XMLRPCdata.json")); + selfMod.data.load("XMLRPCdata.json")); config.constantData.bugzillaLabelNames = JSON.parse(selfMod.data.load("bugzillalabelNames.json")); config.constantData.newUpstreamBug = @@ -449,12 +449,12 @@ exports.initialize = function initialize(config, callback) { }); if ("submitsLogging" in config.gJSONData.configData && - config.gJSONData.configData.submitsLogging) { - logger.initialize(JSON.parse(selfMod.data.load( - "bugzillalabelAbbreviations.json"))); + config.gJSONData.configData.submitsLogging) { + logger.initialize(JSON.parse(selfMod.data.load( + "bugzillalabelAbbreviations.json"))); } - } - callback(); + } + callback(); } }).get(); } |