aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-09-01 10:29:28 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-09-01 10:53:51 +0200
commit5efc52cf5cec2b9b5f75351da8e473c2f90266b5 (patch)
tree4bb5bbc15dde0607737e642c0a5075875ebf58bb /lib
parentb6b75faa9ef841396731398a2882e869df5b8ae7 (diff)
downloadbugzilla-triage-5efc52cf5cec2b9b5f75351da8e473c2f90266b5.tar.gz
Eliminating MakeJSONRPC calls and fixing multiple logins.
Fixes #113.
Diffstat (limited to 'lib')
-rw-r--r--lib/libbugzilla.js47
-rw-r--r--lib/main.js31
2 files changed, 7 insertions, 71 deletions
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index 46356cc..4858a96 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 xrpc = require("xmlrpc");
var panelMod = require("panel");
var JSONURLDefault = "https://fedorahosted.org/released"+
@@ -87,8 +86,10 @@ function getRealBugNoSlow(bugNo, location, callback) {
}
function getPassword(login, domain, callback) {
- var passPrompt = "Enter your Bugzilla password for fixing MIME attachment types";
- var switchPrompt = "Do you want to switch off features requiring password completely";
+ var passPrompt = "Enter your Bugzilla password " +
+ "for accessing JSONRPC services";
+ 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
@@ -217,6 +218,7 @@ 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 = {
+ password: passwObj.password,
passAvailable: (passwObj.password !== null),
withoutPass: passwObj.withoutPass
};
@@ -283,41 +285,6 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subjectStr, comme
});
};
-// 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.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();
- }
- );
-};
-
exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method,
params, login, callback) {
var urlObj = urlMod.URL(url);
@@ -328,7 +295,7 @@ exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method
return;
}
- console.myDebug("makeJSONRPCCallWithLogin: passObj = " +
+ debug("makeJSONRPCCallWithLogin: passObj = " +
passObj.toSource());
makeJSONRPCCall(url, "User.login", {
login: login,
@@ -418,8 +385,6 @@ exports.initialize = function initialize(config, callback) {
config.constantData = config.gJSONData.constantData;
config.constantData.queryUpstreamBug = JSON.parse(
selfMod.data.load("queryUpstreamBug.json"));
- config.constantData.XMLRPCData = JSON.parse(
- selfMod.data.load("XMLRPCdata.json"));
config.constantData.bugzillaLabelNames =
JSON.parse(selfMod.data.load("bugzillalabelNames.json"));
config.constantData.newUpstreamBug =
diff --git a/lib/main.js b/lib/main.js
index b7ac152..1d97e81 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -86,36 +86,6 @@ var messageHandler = exports.messageHandler = function messageHandler(
case "OpenStringInPanel":
libbz.openStringInNewPanel(msg.data);
break;
- case "MakeXMLRPCall":
- // url, login, method, params, callback
- libbz
- .makeXMLRPCCall(msg.data.url, msg.data.login,
- msg.data.method, msg.data.params, function(ret) {
- worker.postMessage(new Message(msg.data.callRPC,
- ret));
- });
- break;
- case "MakeJSONRPCall":
- // url, login, method, params, callback
- console.myDebug("messageHandler: msg = " + msg.toSource());
- if (msg.data.login) {
- libbz
- .makeJSONRPCCallWithLogin(msg.data.url,
- msg.data.method, msg.data.params, msg.data.login,
- function(ret) {
- worker.postMessage(new Message(msg.data.callRPC,
- ret));
- });
- }
- else {
- libbz
- .makeJSONRPCCall(msg.data.url, msg.data.method,
- msg.data.params, function(ret) {
- worker.postMessage(new Message(msg.data.callRPC,
- ret));
- });
- }
- break;
// Needed because creating additional page-mods on remote bugzilla
case "OpenBugUpstream":
libbz.createUpstreamBug(msg.data.url, msg.data.subject,
@@ -133,6 +103,7 @@ var messageHandler = exports.messageHandler = function messageHandler(
var contentScriptLibraries = [
self.data.url('tweaks/urltest.js'),
self.data.url("lib/util.js"),
+ self.data.url("lib/rpcutils.js"),
self.data.url("lib/jumpNextBug.js"),
self.data.url("lib/queries.js"),
self.data.url("lib/collectingMetadata.js"),