aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
Diffstat (limited to 'data')
-rw-r--r--data/XMLRPCdata.json14
-rw-r--r--data/lib/bzpage.js6
-rw-r--r--data/lib/collectingMetadata.js4
-rw-r--r--data/lib/rpcutils.js63
-rw-r--r--data/rhlib/addAttachmentRow.js10
-rw-r--r--data/rhlib/fixingAttMIME.js16
-rw-r--r--data/rhlib/rhbzpage.js6
-rw-r--r--data/tweaks/bug-page-mod.js42
8 files changed, 79 insertions, 82 deletions
diff --git a/data/XMLRPCdata.json b/data/XMLRPCdata.json
deleted file mode 100644
index 085f699..0000000
--- a/data/XMLRPCdata.json
+++ /dev/null
@@ -1,14 +0,0 @@
-{
- "bugzilla.redhat.com": {
- "url": "https://bugzilla.redhat.com/xmlrpc.cgi"
- },
- "bugzilla.mozilla.org": {
- "url": "https://bugzilla.mozilla.org/xmlrpc.cgi"
- },
- "bugs.freedesktop.org": {
- "url": "https://bugs.freedesktop.org/xmlrpc.cgi"
- },
- "bz-web2-test.devel.redhat.com": {
- "url": "https://bz-web2-test.devel.redhat.com/xmlrpc.cgi"
- }
-}
diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js
index 4401792..d4c393f 100644
--- a/data/lib/bzpage.js
+++ b/data/lib/bzpage.js
@@ -36,7 +36,7 @@ self.on('message', function onMessage(msg) {
equivalentComponents = ("equivalentComponents" in constantData) ?
constantData.equivalentComponents : null;
generateButtons(msg.data.instPkgs, msg.data.kNodes);
- completeInit();
+ JSONRPCLogin(completeInit);
break;
case "Error":
alert("Error " + msg.data);
@@ -44,8 +44,8 @@ self.on('message', function onMessage(msg) {
case "Unhandled":
break;
default:
- if (TweakOnMessageHandler) {
- TweakOnMessageHandler(msg, [RHOnMessageHandler, MozOnMessageHandler]);
+ if (RHOnMessageHandler) {
+ RHOnMessageHandler(msg, [MozOnMessageHandler]);
}
else {
console.error("Error: unknown RPC call " + msg.toSource());
diff --git a/data/lib/collectingMetadata.js b/data/lib/collectingMetadata.js
index 743c812..00b973d 100644
--- a/data/lib/collectingMetadata.js
+++ b/data/lib/collectingMetadata.js
@@ -170,11 +170,11 @@ AttachList.prototype.markBadAttachments = function markBadAttachments() {
createDeadLink("fixAllButton", "Fix all", titleElement, function () {
Array.forEach(badAttachments, function (x) {
- fixAttachById(x.id, constantData.XMLRPCData[window.location.hostname].url);
+ fixAttachById(x.id);
});
}, [], false, null, "f");
badAttachments.forEach(function (x, i, a) {
- addTextLink(x, constantData.XMLRPCData[window.location.hostname].url);
+ addTextLink(x);
});
}
};
diff --git a/data/lib/rpcutils.js b/data/lib/rpcutils.js
new file mode 100644
index 0000000..d29fd68
--- /dev/null
+++ b/data/lib/rpcutils.js
@@ -0,0 +1,63 @@
+//Released under the MIT/X11 license
+//http://www.opensource.org/licenses/mit-license.php
+"use strict";
+
+/*
+We should first login and then we shouldn't bother with it.
+It could be interesting to know how many logins per second are bad.
+ */
+
+function JSONRPCLogin(callback) {
+ if (!constantData.passwordState.password) {
+ return;
+ }
+
+ console.myDebug("JSONRPCLogin: passObj = " +
+ constantData.passwordState.toSource());
+ makeJSONRPCCall("User.login", {
+ login: getLogin(),
+ password: constantData.passwordState.password,
+ remember: false
+ }, function(logResult) {
+ 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
+function makeJSONRPCCall(method, params, callback) {
+
+ var msg = {
+ "version": "1.1",
+ "method": method,
+ "params": params
+ };
+
+ console.myDebug("makeJSONRPCCall(" + method +
+ "): out = " + JSON.stringify(msg));
+
+ var req = new XMLHttpRequest();
+ req.open('POST', "/jsonrpc.cgi", true);
+ req.onreadystatechange = function (aEvt) {
+ if (req.readyState == 4) {
+ if(req.status == 200) {
+ console.myDebug("makeJSONRPCCall (" + method +
+ "): in = " + req.responseText);
+ var JSONresponse = JSON.parse(req.responseText);
+ if ("error" in JSONresponse) {
+ throw new Error("Error in JSON-RPC call:\n" +
+ JSONresponse.error);
+ }
+ callback(JSONresponse);
+ }
+ else {
+ console.error('Error', req.statusText);
+ }
+ }
+ };
+ req.setRequestHeader('Content-Type', "application/json");
+ req.send(JSON.stringify(msg));
+};
+
diff --git a/data/rhlib/addAttachmentRow.js b/data/rhlib/addAttachmentRow.js
index c8724e3..6fab1bd 100644
--- a/data/rhlib/addAttachmentRow.js
+++ b/data/rhlib/addAttachmentRow.js
@@ -2,7 +2,7 @@
//http://www.opensource.org/licenses/mit-license.php
"use strict";
-//FIXME resp is JSON, not XML anymore
+// FIXME resp is JSON, not XML anymore
function addAttachmentCallback(resp) {
var newAttachID = parseInt(
resp.params.param.value.array.data.value.int, 10);
@@ -51,12 +51,6 @@ function addAttachment(data, callback, param) {
nomail : true
};
- self.postMessage(new Message("MakeJSONRPCall", {
- url : constantData.XMLRPCData[window.location.hostname].url
- .replace("xmlrpc.cgi", "jsonrpc.cgi"),
- method : "bugzilla.addAttachment",
- params : params,
- callRPC : "AddAttachmentCallback"
- }));
+ makeJSONRPCCall("bugzilla.addAttachment", params, addAttachmentCallback);
reqCounter++;
}
diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js
index f61ddbd..220b7ad 100644
--- a/data/rhlib/fixingAttMIME.js
+++ b/data/rhlib/fixingAttMIME.js
@@ -44,7 +44,7 @@ function XMLRPCcallback() {
* this change };
*
*/
-function fixAttachById(id, XMLRPCURL, type, email) {
+function fixAttachById(id, type, email) {
if (type === undefined) {
type = "text/plain";
}
@@ -61,13 +61,7 @@ function fixAttachById(id, XMLRPCURL, type, email) {
'nomail' : !email
};
- self.postMessage(new Message("MakeJSONRPCall", {
- url : XMLRPCURL.replace("xmlrpc.cgi", "jsonrpc.cgi"),
- method : "bugzilla.updateAttachMimeType",
- login : getLogin(),
- params : params,
- callRPC : "FixAttachmentMIMECallback"
- }));
+ makeJSONRPCCall("bugzilla.updateAttachMimeType", params, XMLRPCcallback);
reqCounter++;
}
@@ -78,11 +72,9 @@ function fixAttachById(id, XMLRPCURL, type, email) {
* <TR> DOM jQuery element with a bad attachment
* @return none
*/
-function addTextLink(att, xmlRpcUrl) {
+function addTextLink(att) {
var elemS = att.element.getElementsByTagName("td");
var elem = elemS[elemS.length - 1];
createDeadLink("addFix2TextLink", "text", elem, fixAttachById,
- [
- att.id, xmlRpcUrl
- ], "br");
+ [ att.id ], "br");
}
diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js
index 944b9a6..abc84c7 100644
--- a/data/rhlib/rhbzpage.js
+++ b/data/rhlib/rhbzpage.js
@@ -71,12 +71,6 @@ function RHOnMessageHandler(msg, nextHandlerList) {
break;
case "Unhandled":
break;
- case "AddAttachmentCallback":
- addAttachmentCallback(msg.data);
- break;
- case "FixAttachmentMIMECallback":
- XMLRPCcallback();
- break;
case "queryUpstream":
queryUpstreamCallback(msg.data, constantData.queryUpstreamBug);
break;
diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js
index f5d154e..32672b0 100644
--- a/data/tweaks/bug-page-mod.js
+++ b/data/tweaks/bug-page-mod.js
@@ -33,27 +33,6 @@
* ***** END LICENSE BLOCK *****
*/
-function TweakOnMessageHandler(msg, nextHandlerList) {
- switch (msg.cmd) {
- case "Unhandled":
- break;
- case "returnedHistory":
- processHistory(msg.data);
- break;
- default:
- if (nextHandlerList) {
- var nextHandler = nextHandlerList.splice(0, 1);
- if (nextHandler[0]) {
- nextHandler[0](msg, nextHandlerList);
- }
- }
- else {
- console.error("Error: unknown RPC call " + msg.toSource());
- }
- break;
- }
-}
-
/**
* generate XML-RPC call to collect complete history of the bug
*
@@ -61,9 +40,8 @@ function TweakOnMessageHandler(msg, nextHandlerList) {
* URL of the XML-RPC gateway on the particular bugzilla
* @returns nothing
*
- * As part of the message is name of the signal "returnedHistory"
*/
-function collectHistory(rpcURL) {
+function collectHistory() {
// https://bugzilla.redhat.com/docs/en/html/api/Bugzilla\
// /WebService/Bug.html#Bug_Information
/*
@@ -96,14 +74,7 @@ function collectHistory(rpcURL) {
The change will be made to the production servers in early May, with
notification to the announce list prior to the change.
*/
- var bugId = getBugNo();
- self.postMessage(new Message("MakeJSONRPCall", {
- url : rpcURL.replace("xmlrpc.cgi","jsonrpc.cgi"),
- login : getLogin(),
- method : "Bug.history",
- params : { "ids": [ bugId ] },
- callRPC : "returnedHistory"
- }));
+ makeJSONRPCCall("Bug.history", { "ids": [ getBugNo() ] }, processHistory);
}
function tweakBugzilla(things, cData) {
@@ -199,10 +170,7 @@ function tweakBugzilla(things, cData) {
var CheckinComment = new CheckinCommentCtor();
CheckinComment.initialize(AttachmentFlagHandler._interestingFlags);
- if (document.location.hostname in cData.XMLRPCData) {
- var XMLRPCUrl = cData.XMLRPCData[document.location.hostname].url;
- collectHistory(XMLRPCUrl);
- }
+ collectHistory();
tbplbotSpamCollapser();
}
@@ -334,7 +302,7 @@ return ; // FIXME just to get rid of this unfinished and unanalyzed function
// §§§§ This is a function addToInlineHistory or something TODO
var currentDiv = document.createElement("div");
var userPrefix = '';
- if (inline) {
+ if (inline) {
// assume that the change was made by the same user // XXX? §§§
commentHead.appendChild(currentDiv);
currentDiv.setAttribute("class", "bztw_inlinehistory");
@@ -408,7 +376,7 @@ return ; // FIXME just to get rid of this unfinished and unanalyzed function
formatTransition(trimContent(item[3]), trimContent(item[4]),
trimContent(item[2]), iframe.contentDocument);
-//
+//
var nextItemsCount = item[0].rowSpan;
for (var k = 1; k < nextItemsCount; ++k) {
// XXX doing once more the same for non-first elements of the imte array.