1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is AboutDebian.
16
* The Initial Developer of the Original Code is
18
* Portions created by the Initial Developer are Copyright (C) 2007
19
* the Initial Developer. All Rights Reserved.
23
* Alternatively, the contents of this file may be used under the terms of
24
* either the GNU General Public License Version 2 or later (the "GPL"), or
25
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
* in which case the provisions of the GPL or the LGPL are applicable instead
27
* of those above. If you wish to allow use of your version of this file only
28
* under the terms of either the GPL or the LGPL, and not to allow others to
29
* use your version of this file under the terms of the MPL, indicate your
30
* decision by deleting the provisions above and replace them with the notice
31
* and other provisions required by the GPL or the LGPL. If you do not delete
32
* the provisions above, a recipient may use your version of this file under
33
* the terms of any one of the MPL, the GPL or the LGPL.
35
* ***** END LICENSE BLOCK ***** */
37
/* Used Javascript XPCOM component generator from
38
http://ted.mielczarek.org/code/mozilla/jscomponentwiz/ to get a skeleton */
40
const nsISupports = Components.interfaces.nsISupports;
41
const nsIAboutModule = Components.interfaces.nsIAboutModule;
43
// You can change these if you like
44
const CLASS_ID = Components.ID("1359a506-95b6-4fec-9f03-3d81ce131fc0");
45
const CLASS_NAME = "about: handler for Debian and package related information";
46
const CONTRACT_ID_PREFIX = "@mozilla.org/network/protocol/about;1?what=";
48
// This is your constructor.
49
// You can do stuff here.
50
function AboutDebian() {
51
// you can cheat and use this
52
// while testing without
53
// writing your own interface
54
this.wrappedJSObject = this;
57
// This is the implementation of your component.
58
AboutDebian.prototype = {
60
QueryInterface: function(aIID)
62
// add any other interfaces you support here
63
if (!aIID.equals(nsISupports) && !aIID.equals(nsIAboutModule))
64
throw Components.results.NS_ERROR_NO_INTERFACE;
68
newChannel: function(uri)
70
var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService();
71
ioService = ioService.QueryInterface(Components.interfaces.nsIIOService);
72
var request = uri.path.toLowerCase();
74
if (request == "readme.debian") {
75
redirect = "file:///usr/share/doc/seamonkey-browser/README.Debian";
76
} else if (request == "bugs") {
77
redirect = "https://bugs.launchpad.net/seamonkey/";
79
redirect = "http://debian.org/";
81
var uri = ioService.newURI(redirect, null, null);
82
return ioService.newChannelFromURI(uri);
86
//=================================================
87
// Note: You probably don't want to edit anything
88
// below this unless you know what you're doing.
91
var AboutDebianFactory = {
92
createInstance: function (aOuter, aIID)
95
throw Components.results.NS_ERROR_NO_AGGREGATION;
96
return (new AboutDebian()).QueryInterface(aIID);
101
var AboutDebianModule = {
102
registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)
104
aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
105
aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID_PREFIX + "readme.debian", aFileSpec, aLocation, aType);
106
aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID_PREFIX + "bugs", aFileSpec, aLocation, aType);
107
aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID_PREFIX + "debian", aFileSpec, aLocation, aType);
110
unregisterSelf: function(aCompMgr, aLocation, aType)
112
aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
113
aCompMgr.unregisterFactoryLocation(CLASS_ID_PREFIX + "readme.debian", aLocation);
114
aCompMgr.unregisterFactoryLocation(CLASS_ID_PREFIX + "bugs", aLocation);
115
aCompMgr.unregisterFactoryLocation(CLASS_ID_PREFIX + "debian", aLocation);
118
getClassObject: function(aCompMgr, aCID, aIID)
120
if (!aIID.equals(Components.interfaces.nsIFactory))
121
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
123
if (aCID.equals(CLASS_ID))
124
return AboutDebianFactory;
126
throw Components.results.NS_ERROR_NO_INTERFACE;
129
canUnload: function(aCompMgr) { return true; }
132
//module initialization
133
function NSGetModule(aCompMgr, aFileSpec) { return AboutDebianModule; }