From 3fe9f14f10381242a193d91f7dc8ea0307091f8e Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 25 Mar 2011 01:17:49 +0100 Subject: Working on cutting down lines from bug-page-mod.js --- lib/libbugzilla.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 45a1fc4..613dbb3 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -170,7 +170,7 @@ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, c var allIdx = null; if ((allIdx = enabledPackages.indexOf("all")) != -1) { enabledPackages = enabledPackages.splice(allIdx, - config.gJSONData.commentPackages.keys()); + Object.keys(config.gJSONData.commentPackages)); } // TODO To be decided, whether we cannot just eliminate packages in -- cgit From 2b19aaeb2f2af979920bc9f2dd4d8df180f25c5c Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 26 Apr 2011 23:54:37 +0200 Subject: We were missing many attributes from configData. --- lib/libbugzilla.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 613dbb3..7e2398b 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -19,6 +19,10 @@ var JSONURLDefault = "https://fedorahosted.org/released"+ "/bugzilla-triage-scripts/Config_data.json"; var BTSPrefNS = "bugzilla-triage.setting."; var BTSPassRealm = "BTSXMLRPCPass"; +var copiedAttributes = [ "queryButton", "upstreamButton", "parseAbrtBacktraces", + "submitsLogging", "XorgLogAnalysis", "objectStyle", "signature", + "suspiciousComponents" ]; + var passwords = {}; // hash of passwords indexed by a hostname var config = exports.config = {}; @@ -167,6 +171,7 @@ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, c } } + var allIdx = null; if ((allIdx = enabledPackages.indexOf("all")) != -1) { enabledPackages = enabledPackages.splice(allIdx, @@ -377,15 +382,11 @@ exports.initialize = function initialize(config, callback) { config.configData.defBugzillaMaintainerArr = config.constantData.CCmaintainer; } - if ("suspiciousComponents" in config.gJSONData.configData) { - config.configData.suspiciousComponents = - config.gJSONData.configData.suspiciousComponents; - } - - if ("XorgLogAnalysis" in config.gJSONData.configData) { - config.configData.xorglogAnalysis = - config.gJSONData.configData.XorgLogAnalysis; - } + copiedAttributes.forEach(function (attrib) { + if (attrib in config.gJSONData.configData) { + config.configData[attrib] = config.gJSONData.configData[attrib]; + } + }); if ("submitsLogging" in config.gJSONData.configData && config.gJSONData.configData.submitsLogging) { -- cgit From 55d9a312fbba91f1bcf5e3f3291b7bece8abb178 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 28 Apr 2011 13:28:55 +0200 Subject: Reformatting to MoFo coding style --- lib/libbugzilla.js | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 7e2398b..c85d331 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -38,23 +38,26 @@ function log(msg) { } /** - * parse XML object out of string working around various bugs in Gecko implementation - * see https://developer.mozilla.org/en/E4X for more information - * - * @param inStr String with unparsed XML string + * parse XML object out of string working around various bugs in Gecko + * implementation see https://developer.mozilla.org/en/E4X for more information + * + * @param inStr + * String with unparsed XML string * @return XML object */ function parseXMLfromString (inStuff) { - // if (typeof inStuff !== 'string') In future we should recognize this.response + // if (typeof inStuff !== 'string') In future we should recognize + // this.response // and get just .text property out of it. TODO - var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug 336551 + var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug + // 336551 return new XML(respStr); } /** - * In case URL contains alias, not the real bug number, get the real bug no - * from the XML representation. Sets correct value to this.bugNo. - * + * In case URL contains alias, not the real bug number, get the real bug no from + * the XML representation. Sets correct value to this.bugNo. + * * This is a slow variant for bugs other than actual window */ function getRealBugNoSlow(bugNo, location, callback) { @@ -141,14 +144,11 @@ exports.changeJSONURL = function changeJSONURL() { }; /** - * - libbz.getInstalledPackages(msg.data, function (pkgsMsg) { - worker.postMessage(pkgsMsg); - - locationLoginObj: { - location: window.location.href, - login: getLogin() - } + * + * libbz.getInstalledPackages(msg.data, function (pkgsMsg) { + * worker.postMessage(pkgsMsg); + * + * locationLoginObj: { location: window.location.href, login: getLogin() } */ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) { var installedPackages = {}; @@ -283,14 +283,16 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) }); }; -// Make a XML-RPC call ... most of the business logic should stay in the content script +// Make a XML-RPC call ... most of the business logic should stay in the content +// script exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) { var urlObj = urlMod.URL(url); getPassword(login, urlObj.schema + "://" + urlObj.host, function (passwObj) { if (!passwObj.password) { - // TODO this should happen, only when user presses Escape in password prompt + // TODO this should happen, only when user presses Escape in password + // prompt return null; } -- cgit From 272ab432ddc4562237c7235f8e0ab8a11bad3d3d Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 29 Apr 2011 01:22:18 +0200 Subject: All XML-RPC calls are rewritten as JSON-RPC ones. * also MakeJSONRPCall is a functional call now * reorganization for dealing with the history. --- lib/libbugzilla.js | 87 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 30 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index c85d331..aa2d0b7 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -40,7 +40,7 @@ function log(msg) { /** * parse XML object out of string working around various bugs in Gecko * implementation see https://developer.mozilla.org/en/E4X for more information - * + * * @param inStr * String with unparsed XML string * @return XML object @@ -57,7 +57,7 @@ function parseXMLfromString (inStuff) { /** * In case URL contains alias, not the real bug number, get the real bug no from * the XML representation. Sets correct value to this.bugNo. - * + * * This is a slow variant for bugs other than actual window */ function getRealBugNoSlow(bugNo, location, callback) { @@ -144,10 +144,10 @@ exports.changeJSONURL = function changeJSONURL() { }; /** - * + * * libbz.getInstalledPackages(msg.data, function (pkgsMsg) { * worker.postMessage(pkgsMsg); - * + * * locationLoginObj: { location: window.location.href, login: getLogin() } */ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, callback) { @@ -288,36 +288,63 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) { var urlObj = urlMod.URL(url); getPassword(login, - urlObj.schema + "://" + urlObj.host, - function (passwObj) { - if (!passwObj.password) { - // TODO this should happen, only when user presses Escape in password - // prompt - return null; - } + urlObj.schema + "://" + 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(); - } + 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(); + } ); }; +// Make a JSONL-RPC call ... most of the business logic should stay in the +// content script +// http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html +exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback) { + +// {"version":"1.1", "method":"Bug.history", "params":{ "ids":[12345] } } + var msg = { + "version": "1.1", + "method": method, + "params": params + }; + + console.myDebug("makeJSONRPCCall: out = " + JSON.stringify(msg)); + + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + console.myDebug("makeJSONRPCCall: in = " + response.text); + callback(response.json.result); + } + }, + content: JSON.stringify(msg), + contentType: "application/json" + }).post(); +}; + exports.initialize = function initialize(config, callback) { var prefName = BTSPrefNS+"JSONURL"; var urlStr = ""; -- cgit From 92421b51663ce34939fee936ddcbeec91a67bced Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 2 May 2011 21:59:55 +0200 Subject: "all" keyword in enabledPackages configuration didn't work. Bad use of Array.slice. Fixes #89 --- lib/libbugzilla.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index aa2d0b7..a1792ea 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -171,11 +171,10 @@ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, c } } - var allIdx = null; if ((allIdx = enabledPackages.indexOf("all")) != -1) { - enabledPackages = enabledPackages.splice(allIdx, - Object.keys(config.gJSONData.commentPackages)); + enabledPackages.splice(allIdx, 1); + enabledPackages = enabledPackages.concat(Object.keys(config.gJSONData.commentPackages)); } // TODO To be decided, whether we cannot just eliminate packages in -- cgit From c603f0a1a2985bf225786122beeaf248ca87cd99 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 5 May 2011 12:02:51 +0200 Subject: Make the script more reliable against JSON-hosting sites being down. Fixes #92 --- lib/libbugzilla.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index a1792ea..3763eff 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -379,6 +379,8 @@ exports.initialize = function initialize(config, callback) { onComplete: function(response) { if (response.status == 200) { config.constantData[title] = response.json; + } else { + console.error("Cannot download " + title + " from URL " + url); } } }).get(); -- cgit From da49b6460ae02a1a1f0e86aef8f541798730a18f Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 5 May 2011 12:27:10 +0200 Subject: Make my console.myDebug configurable via about:config preference. That is the Boolean variable bugzilla-triage.setting.debug --- lib/libbugzilla.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 3763eff..990c759 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -329,13 +329,13 @@ exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback "params": params }; - console.myDebug("makeJSONRPCCall: out = " + JSON.stringify(msg)); +// console.log("makeJSONRPCCall: out = " + JSON.stringify(msg)); Request({ url: url, onComplete: function(response) { if (response.status == 200) { - console.myDebug("makeJSONRPCCall: in = " + response.text); +// console.log("makeJSONRPCCall: in = " + response.text); callback(response.json.result); } }, @@ -345,15 +345,24 @@ exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback }; exports.initialize = function initialize(config, callback) { - var prefName = BTSPrefNS+"JSONURL"; - var urlStr = ""; + var prefJSONURLName = BTSPrefNS+"JSONURL"; + var prefDebugName = BTSPrefNS+"debug"; + var urlStr = "", + debugOption = false; // should we spit out a lot of debugging output - if (preferences.isSet(prefName)) { - urlStr = preferences.get(prefName); + if (preferences.isSet(prefJSONURLName)) { + urlStr = preferences.get(prefJSONURLName); } else { urlStr = JSONURLDefault; - preferences.set(prefName, JSONURLDefault); + preferences.set(prefJSONURLName, JSONURLDefault); + } + + if (preferences.isSet(prefDebugName)) { + debugOption = preferences.get(prefDebugName); + } + else { + preferences.set(prefDebugName, debugOption); } // Randomize URL to avoid caching @@ -388,6 +397,7 @@ exports.initialize = function initialize(config, callback) { } config.configData = {}; + config.configData.debuggingVerbose = debugOption; config.configData.matches = config.gJSONData.configData.matches; config.configData.skipMatches = config.configData.matches.map(function(x) { return x.replace("show_bug.cgi.*","((process|post)_bug|attachment)\.cgi$"); -- cgit From 49feb276224dfa812339b94cfe52ea8f0ee5c491 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 5 May 2011 18:41:00 +0200 Subject: Add makeJSONRPCCallWithLogin, and other small issues. * Release 0.102 * Don't react on bugzilla.gnome.org per default * Simplify handling of preferences and debugging output. --- lib/libbugzilla.js | 67 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 990c759..ae4ea01 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -26,6 +26,7 @@ var copiedAttributes = [ "queryButton", "upstreamButton", "parseAbrtBacktraces", var passwords = {}; // hash of passwords indexed by a hostname var config = exports.config = {}; +var debugOption = false; function Message(cmd, data) { console.log("Message: cmd = " + cmd + ", data = " + data); @@ -37,6 +38,12 @@ function log(msg) { postMessage(new Message("LogMessage", msg)); } +function debug(str) { + if (debugOption) { + console.log(str); + } +} + /** * parse XML object out of string working around various bugs in Gecko * implementation see https://developer.mozilla.org/en/E4X for more information @@ -61,7 +68,7 @@ function parseXMLfromString (inStuff) { * This is a slow variant for bugs other than actual window */ function getRealBugNoSlow(bugNo, location, callback) { - console.log("We have to deal with bug aliased as " + this.bugNo); + debug("We have to deal with bug aliased as " + this.bugNo); // https://bugzilla.redhat.com/show_bug.cgi?ctype=xml&id=serialWacom Request({ url: location.href+"&ctype=xml", @@ -73,7 +80,7 @@ function getRealBugNoSlow(bugNo, location, callback) { if (isNaN(bugID)) { throw new Error("Cannot get bug no. even from XML representation!"); } - console.log("The real bug no. is " + bugID); + debug("The real bug no. is " + bugID); callback(bugID) } } @@ -133,7 +140,7 @@ function getPassword(login, domain, callback) { exports.changeJSONURL = function changeJSONURL() { var prfNm = BTSPrefNS+"JSONURL"; - var url = preferences.get(prfNm,""); + var url = preferences.get(prfNm, JSONURLDefault); var reply = prompts.prompt("New location of JSON configuration file", url); if (reply && (reply != url)) { @@ -287,7 +294,7 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) { var urlObj = urlMod.URL(url); getPassword(login, - urlObj.schema + "://" + urlObj.host, + urlObj.scheme + "://" + urlObj.host, function (passwObj) { if (!passwObj.password) { // TODO this should happen, only when user presses Escape in password @@ -317,25 +324,46 @@ exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, cal ); }; +exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method, params, + login, callback) { + var urlObj = urlMod.URL(url); + getPassword(login, + 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); + }); + } + ); +}; + // Make a JSONL-RPC call ... most of the business logic should stay in the // content script // http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html -exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback) { +var makeJSONRPCCall = exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback) { -// {"version":"1.1", "method":"Bug.history", "params":{ "ids":[12345] } } var msg = { "version": "1.1", "method": method, "params": params }; -// console.log("makeJSONRPCCall: out = " + JSON.stringify(msg)); + debug("makeJSONRPCCall: out = " + JSON.stringify(msg)); Request({ url: url, onComplete: function(response) { if (response.status == 200) { -// console.log("makeJSONRPCCall: in = " + response.text); + debug("makeJSONRPCCall: in = " + response.text); callback(response.json.result); } }, @@ -346,24 +374,13 @@ exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback exports.initialize = function initialize(config, callback) { var prefJSONURLName = BTSPrefNS+"JSONURL"; - var prefDebugName = BTSPrefNS+"debug"; - var urlStr = "", - debugOption = false; // should we spit out a lot of debugging output + var urlStr = preferences.get(prefJSONURLName, JSONURLDefault); + preferences.set(prefJSONURLName, urlStr); - if (preferences.isSet(prefJSONURLName)) { - urlStr = preferences.get(prefJSONURLName); - } - else { - urlStr = JSONURLDefault; - preferences.set(prefJSONURLName, JSONURLDefault); - } - - if (preferences.isSet(prefDebugName)) { - debugOption = preferences.get(prefDebugName); - } - else { - preferences.set(prefDebugName, debugOption); - } + // should we spit out a lot of debugging output + var prefDebugName = BTSPrefNS+"debug"; + debugOption = preferences.get(prefDebugName, false); + preferences.set(prefDebugName, debugOption); // Randomize URL to avoid caching // TODO see https://fedorahosted.org/bugzilla-triage-scripts/ticket/21 -- cgit From 8e501abd49e5aeac70a84ceef96a72b5078df221 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 7 May 2011 00:53:06 +0200 Subject: Another massive cleanup and simplification of tweak scripts. bugs on bugzilla.mozilla.org now work as well, although the history is still not shown inline, which remains for 1.1. Fixes #88 --- lib/libbugzilla.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index ae4ea01..0eba70b 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -364,6 +364,9 @@ var makeJSONRPCCall = exports.makeJSONRPCCall = function makeJSONRPCCall(url, me 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); } }, -- cgit From 83fd7fd92e5b21a177bc16cc7318792cf63a343b Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 13 May 2011 12:20:05 +0200 Subject: Really Eclipseize formatting. --- lib/libbugzilla.js | 158 ++++++++++++++++++++++++++--------------------------- 1 file changed, 79 insertions(+), 79 deletions(-) (limited to 'lib/libbugzilla.js') 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(); } -- cgit From 9954df923e6b54a4cf6bf66c5eaa1306197c21bc Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 21 May 2011 18:27:50 +0200 Subject: Revert [e6762f8883], we actually want caching. See #21 for the original discussion. Lately JSON configuration is more or less stable, so we actually want caching. --- lib/libbugzilla.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index de93531..c2ee51d 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -385,11 +385,6 @@ exports.initialize = function initialize(config, callback) { debugOption = preferences.get(prefDebugName, false); preferences.set(prefDebugName, debugOption); - // Randomize URL to avoid caching - // TODO see https://fedorahosted.org/bugzilla-triage-scripts/ticket/21 - // for more thorough discussion and possible further improvement - urlStr += (urlStr.match(/\?/) == null ? "?" : "&") + (new Date()).getTime(); - Request({ url: urlStr, onComplete: function (response) { -- cgit From 70800020bb6731136f1df1fd42f7de1607cd2767 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 28 May 2011 13:18:44 +0200 Subject: Use new tab.attach() internal page-mod method of creating new upstream bug. Fixes #100 --- lib/libbugzilla.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index c2ee51d..b49e776 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -274,17 +274,23 @@ var openURLInNewTab = exports.openURLInNewTab = function openURLInNewTab(url) { }); }; -exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) { +exports.createUpstreamBug = function createUpstreamBug(urlStr, subjectStr, commentStr) { + var payload = JSON.stringify({ + subject: subjectStr, + comment: commentStr + }); tabs.open({ url: urlStr, inBackground: true, - onReady: function (t) { - var otherElems = t.contentDocument.forms.namedItem("Create").elements; - // Summary - otherElems.namedItem("short_desc").value = subject; - // Comment - otherElems.namedItem("comment").value = collectComments(); - t.activate(); + onReady: function (tab) { + tab.attach({ + contentScriptFile: selfMod.data.url("internalMods/createBugElsewhere.js"), + contentScript: "fillTheForm(" + payload + ");", + onMessage: function(str) { + tab.activate(); + } + }); + } }); }; -- cgit From ffa6d74ddbf28c7fb7be1ad473847807d0301eac Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 4 Jun 2011 02:30:57 +0200 Subject: Moving ahead ... storing the progress for future. --- lib/libbugzilla.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index b49e776..5b77e25 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -21,7 +21,7 @@ var BTSPrefNS = "bugzilla-triage.setting."; var BTSPassRealm = "BTSXMLRPCPass"; var copiedAttributes = [ "queryButton", "upstreamButton", "parseAbrtBacktraces", "submitsLogging", "XorgLogAnalysis", "objectStyle", "signature", - "suspiciousComponents" ]; + "suspiciousComponents", "verboseInlineHistory" ]; var passwords = {}; // hash of passwords indexed by a hostname -- cgit From 2d67008193187991bb61de59597925f3b776df35 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 6 Jun 2011 13:30:49 +0200 Subject: Make fixing MIME types of attachments working again. When the Attachment is suddenly object instead of an array. --- lib/libbugzilla.js | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 5b77e25..2f0bebb 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -345,7 +345,6 @@ exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method password: passObj.password, remember: false }, function(logResult) { - console.log("logResult = " + logResult.toSource()); makeJSONRPCCall(url, method, params, callback); }); } -- cgit From 4ef203c974e889b74e4064ee04eddc55ba7b8c08 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 15 Jul 2011 23:59:22 +0200 Subject: Stabilization to make it merged to next. --- lib/libbugzilla.js | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/libbugzilla.js') diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 2f0bebb..2dc1dc5 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -11,7 +11,6 @@ var passUtils = require("passwords"); var Request = require("request").Request; var selfMod = require("self"); var urlMod = require("url"); -var dataUtils = require("utils/data"); var xrpc = require("xmlrpc"); var panelMod = require("panel"); -- cgit