diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cookiemanager.js | 48 | ||||
-rw-r--r-- | lib/libbugzilla.js | 158 | ||||
-rw-r--r-- | lib/main.js | 37 | ||||
-rw-r--r-- | lib/prompts.js | 12 | ||||
-rw-r--r-- | lib/util.js | 8 | ||||
-rw-r--r-- | lib/xmlrpc.js | 20 |
6 files changed, 140 insertions, 143 deletions
diff --git a/lib/cookiemanager.js b/lib/cookiemanager.js index b777ab9..6eac7f7 100644 --- a/lib/cookiemanager.js +++ b/lib/cookiemanager.js @@ -1,43 +1,41 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 +/******************************************************************************* + * ***** BEGIN LICENSE BLOCK Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ + * 1.1 (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. * * The Original Code is Bugzilla Tweaks. * - * The Initial Developer of the Original Code is Ehsan Akhgari. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. + * The Initial Developer of the Original Code is Ehsan Akhgari. Portions created + * by the Initial Developer are Copyright (C) 2010 the Initial Developer. All + * Rights Reserved. * - * Contributor(s): - * Ehsan Akhgari <ehsan@mozilla.com> + * Contributor(s): Ehsan Akhgari <ehsan@mozilla.com> * * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. + * either the GNU General Public License Version 2 or later (the "GPL"), or the + * GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which + * case the provisions of the GPL or the LGPL are applicable instead of those + * above. If you wish to allow use of your version of this file only under the + * terms of either the GPL or the LGPL, and not to allow others to use your + * version of this file under the terms of the MPL, indicate your decision by + * deleting the provisions above and replace them with the notice and other + * provisions required by the GPL or the LGPL. If you do not delete the + * provisions above, a recipient may use your version of this file under the + * terms of any one of the MPL, the GPL or the LGPL. * - * ***** END LICENSE BLOCK ***** */ + * ***** END LICENSE BLOCK ***** + */ exports.getHostCookies = function getHostCookies(host) { var {Cc, Ci} = require("chrome"); var cm = Cc["@mozilla.org/cookiemanager;1"]. - getService(Ci.nsICookieManager2); + getService(Ci.nsICookieManager2); var e = cm.getCookiesFromHost(host); var result = []; while (e.hasMoreElements()) { 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(); } diff --git a/lib/main.js b/lib/main.js index 431ffe6..c857a08 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,14 +1,14 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php -// -// Links to read through -// http://ehsanakhgari.org/blog/2010-01-07/bugzilla-tweaks-enhanced -// http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/tip/bugzillatweaks -// http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/ecfa0f028b81/bugzillatweaks/lib/main.js -// http://hg.mozilla.org/users/avarma_mozilla.com/atul-packages/file/42ac1e99a107/packages\ -// /facebook-acquaintances/lib/main.js#l11 -// http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253 -// +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php + +//Links to read through +//http://ehsanakhgari.org/blog/2010-01-07/bugzilla-tweaks-enhanced +//http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/tip/bugzillatweaks +//http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/ecfa0f028b81/bugzillatweaks/lib/main.js +//http://hg.mozilla.org/users/avarma_mozilla.com/atul-packages/file/42ac1e99a107/packages\ +///facebook-acquaintances/lib/main.js#l11 +//http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253 + "use strict"; var browser = require("tab-browser"); var self = require("self"); @@ -103,21 +103,20 @@ var messageHandler = exports.messageHandler = function messageHandler( // url, login, method, params, callback if (msg.data.login) { libbz - .makeJSONRPCCallWithLogin(msg.data.url, msg.data.method, - msg.data.params, msg.data.login, function(ret) { + .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) { + msg.data.params, function(ret) { worker.postMessage(new Message(msg.data.callRPC, ret)); - } - ); + }); } break; case "GetURL": @@ -192,7 +191,7 @@ pageMod.PageMod({ contentScriptFile : self.data.url("lib/skip-bug.js") }); -// Allow toggling of CC event displays using a context menu entry +//Allow toggling of CC event displays using a context menu entry contextMenu.Item({ label : "Toggle CC History", contentScriptFile : [ diff --git a/lib/prompts.js b/lib/prompts.js index 3f34e0d..18edaaf 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -1,5 +1,5 @@ -/*global exports: false, require: false, console: false */ -/*jslint onevar: false */ +/* global exports: false, require: false, console: false */ +/* jslint onevar: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -11,7 +11,7 @@ var promptTitle = "Bugzilla Triage Script"; /** * shows the text in a simple window - * + * * @return none */ exports.alert = function alert(msg) { @@ -22,7 +22,7 @@ exports.alert = function alert(msg) { /** * general prompts for a string method - * + * * @return String with the password */ exports.prompt = function prompt(prompt, defaultValue) { @@ -44,7 +44,7 @@ exports.prompt = function prompt(prompt, defaultValue) { /** * returns password with a special password - * + * * @return String with the password */ exports.promptPassword = function promptPassword(prompt) { @@ -98,7 +98,7 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) { }; /** - * + * * documentation is https://developer.mozilla.org/en/NsIFilePicker */ exports.promptFileOpenPicker = function promptFilePicker(win) { diff --git a/lib/util.js b/lib/util.js index 008d6fb..2a9bea3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,5 +1,5 @@ -/*global exports: false, require: false, console: false, Cc: false, Ci: false */ -/*jslint onevar: false */ +/* global exports: false, require: false, console: false, Cc: false, Ci: false */ +/* jslint onevar: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -37,7 +37,7 @@ function getParamsFromURL(url, base) { /** * Get a bug no from URL ... fails with aliases It should theoretically belong * to bzpage.js, but we don't have unit tests there yet, so keeping here. - * + * * @param url * String with URL to be analyzed * @return String with the bug ID (hopefully number, but not for aliases) @@ -51,7 +51,7 @@ exports.getBugNo = function getBugNo(url) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js index 3991b04..c369e52 100644 --- a/lib/xmlrpc.js +++ b/lib/xmlrpc.js @@ -1,39 +1,39 @@ -/*global exports: false */ +/* global exports: false */ "use strict"; // Modification of Matěj Cepl released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php /* - * + * * xmlrpc.js beta version 1 Tool for creating XML-RPC formatted requests in * JavaScript - * + * * Copyright 2001 Scott Andrew LePera scott@scottandrew.com - * - * + * + * * License: You are granted the right to use and/or redistribute this code only * if this license and the copyright notice are included and you accept that no * warranty of any kind is made or implied by the author. - * + * */ /** * checks whether parameter is an array - * + * * @param obj * Object * @return Boolean true if obj is array - * + * * The problem is that in different contexts, Array is not same, and so obj is * not an instance of SAME Array. */ /** * pads a single number with a leading zero. Heh. - * + * * @param n * String or Number * @return String with leading zero added if necessary - * + * * If the real parameter is not numerical, it is just returned as it is. */ var leadingZero = exports.leadingZero = function leadingZero(n) { |