3
Copyright (C) 2006-2009 Eric H. Jung and LeahScape, Inc.
4
http://foxyproxy.mozdev.org/
3
Copyright (C) 2006-#%#% Eric H. Jung and LeahScape, Inc.
4
http://getfoxyproxy.org/
7
7
This source code is released under the GPL license,
8
8
available in the LICENSE file at the root of this installation
9
9
and also online at http://www.gnu.org/licenses/gpl.txt
12
11
// common fcns used throughout foxyproxy, exposed a an xpcom service
14
13
const CI = Components.interfaces;
15
14
const CC = Components.classes;
15
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
17
17
function Common() {
18
18
this.wrappedJSObject = this;
19
uuid = CC["@leahscape.org/foxyproxy/service;1"].getService().wrappedJSObject.
20
isFoxyProxySimple() ? "foxyproxy-basic@eric.h.jung" : "foxyproxy@eric.h.jung";
22
// Get installed version
23
if ("@mozilla.org/extensions/manager;1" in CC) {
25
this.version = CC["@mozilla.org/extensions/manager;1"]
26
.getService(CI.nsIExtensionManager)
32
Components.utils.import("resource://gre/modules/AddonManager.jsm");
34
AddonManager.getAddonByID(uuid, function(addon) {self.version = addon.version;});
21
38
Common.prototype = {
39
QueryInterface: XPCOMUtils.generateQI([CI.nsISupports]),
22
40
_ios : CC["@mozilla.org/network/io-service;1"].getService(CI.nsIIOService),
24
QueryInterface: function(aIID) {
25
if (!aIID.equals(CI.nsISupports))
26
throw Components.results.NS_ERROR_NO_INTERFACE;
30
43
// Application-independent version of getMostRecentWindow()
31
44
getMostRecentWindow : function(wm) {
130
143
getVersion : function() {
132
var fp = CC["@leahscape.org/foxyproxy/service;1"].getService().wrappedJSObject;
133
return CC["@mozilla.org/extensions/manager;1"]
134
.getService(CI.nsIExtensionManager)
135
.getItemForID(fp.isFoxyProxySimple() ? "foxyproxy-basic@eric.h.jung" : "foxyproxy@eric.h.jung")
139
/* this is for development only, really. The only time we'd get into this catch block is if
140
* the extension isn't installed with the correct UUID. That happens when you install FoxyProxy Standard
141
* using this technique: https://developer.mozilla.org/en/Setting_up_extension_development_environment#Firefox_extension_proxy_file
142
* but then switch to using FoxyProxy Basic via the build script (or vice-versa)
148
147
applyTemplate : function(url, strTemplate, caseSensitive) {
294
293
"chrome://foxyproxy/content/images/16x16.gif",
295
294
nb.PRIORITY_WARNING_MEDIUM, buttons);
301
var CommonFactory = {
303
createInstance: function (aOuter, aIID) {
305
throw Components.results.NS_ERROR_NO_AGGREGATION;
306
if (this.singleton == null)
307
this.singleton = new Common();
308
return this.singleton.QueryInterface(aIID);
313
const CLASS_ID = Components.ID("ecbe324b-9ad7-401a-a272-5cc1efba9be6");
317
registerSelf: function(aCompMgr, aFileSpec, aLocation, aType) {
318
aCompMgr = aCompMgr.QueryInterface(CI.nsIComponentRegistrar);
319
aCompMgr.registerFactoryLocation(CLASS_ID, "FoxyProxy Common", "@leahscape.org/foxyproxy/common;1", aFileSpec, aLocation, aType);
322
unregisterSelf: function(aCompMgr, aLocation, aType) {
323
aCompMgr = aCompMgr.QueryInterface(CI.nsIComponentRegistrar);
324
aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
327
getClassObject: function(aCompMgr, aCID, aIID) {
328
if (!aIID.equals(CI.nsIFactory))
329
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
331
if (aCID.equals(CLASS_ID))
332
return CommonFactory;
334
throw Components.results.NS_ERROR_NO_INTERFACE;
337
canUnload: function(aCompMgr) { return true; }
298
classDescription: "FoxyProxy Common Utils",
299
classID: Components.ID("{ecbe324b-9ad7-401a-a272-5cc1efba9be6}"),
300
contractID: "@leahscape.org/foxyproxy/common;1",
303
createInstance: function (aOuter, aIID) {
305
throw Components.results.NS_ERROR_NO_AGGREGATION;
307
this.singleton = new Common();
308
return this.singleton.QueryInterface(aIID);
340
//module initialization
341
function NSGetModule(aCompMgr, aFileSpec) { return CommonModule; }
b'\\ No newline at end of file'
314
* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4)
315
* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 and earlier (Firefox 3.6)
317
if (XPCOMUtils.generateNSGetFactory)
318
var NSGetFactory = XPCOMUtils.generateNSGetFactory([Common]);
320
var NSGetModule = XPCOMUtils.generateNSGetModule([Common]);
b'\\ No newline at end of file'