27 const Cc = Components.classes;
28 const Ci = Components.interfaces;
29 const Cr = Components.results;
30 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
35 classID: Components.ID(
"2c15f30e-815f-4414-8d18-277d943a2f68"),
36 contractID:
"@mozilla.org/network/protocol;1?name=ngale",
38 newChannel:
function(aUri) {
39 if (!(aUri.scheme ==
"ngale")) {
40 throw Components.Exception(
"URI " + aUri.spec +
" not supported",
41 Cr.NS_ERROR_UNEXPECTED);
43 aUri.QueryInterface(
Ci.nsIURL);
51 var params = this._parseQueryString(aUri.query);
52 var
ios =
Cc[
"@mozilla.org/network/io-service;1"]
53 .getService(
Ci.nsIIOService);
58 var channel = ios.newChannel(params[
"url"],
null,
null);
61 aUri.spec = params[
"url"];
62 if (aUri.scheme ==
"chrome") {
63 Components.utils.reportError(
64 "sbSongbirdProtocol::newChannel: " +
65 "chrome URLs are not permitted as an argument to open.");
66 return new BogusChannel(aUri,
"application/dummy-mime-type");
71 Components.utils.reportError(
72 "sbSongbirdProtocol::newChannel: " +
73 "failed to make a new channel/url for: " + aUri.query +
74 "\nThe syntax is: ngale:open?url=<encodedURL>");
75 return new BogusChannel(aUri,
"application/dummy-mime-type");
80 var origURISpec = aUri.spec.replace(/nocommand/,
"");
81 Components.utils.reportError(
82 "sbSongbirdProtocol::newChannel: no command: " + origURISpec);
83 return new BogusChannel(aUri,
"application/dummy-mime-type");
86 Components.utils.reportError(
87 "sbSongbirdProtocol::newChannel: bad command: " + aUri.host);
88 return new BogusChannel(aUri,
"application/dummy-mime-type");
92 Components.utils.reportError(
93 "sbSongbirdProtocol::newChannel: no command: " + aUri.spec);
94 return new BogusChannel(aUri,
"application/dummy-mime-type");
98 newURI:
function (spec, charSet, baseURI) {
99 var
url =
Cc[
"@mozilla.org/network/standard-url;1"]
100 .createInstance(
Ci.nsIURL);
105 Components.utils.reportError(
"sbSongbirdProtocol::newURI: no command provided.\n"+
106 "Syntax is in the form: ngale:<command>?p1=a&p2=b");
110 url.host =
"nocommand";
115 getURIFlags:
function(
uri) {
116 return Ci.nsIAboutModule.ALLOW_SCRIPT
120 _parseQueryString:
function(query) {
121 var queryString = query.split(
"&");
122 var queryObject = {};
124 for each (var pair
in queryString) {
145 this.originalURI = URI;
146 this.contentType = contentType;
150 function bc_QueryInterface(iid)
152 if (!iid.equals(
nsIChannel) && !iid.equals(nsIRequest) &&
154 throw Components.results.NS_ERROR_NO_INTERFACE;
170 throw Components.results.NS_ERROR_NO_CONTENT;
174 function bc_asyncRead(
listener, ctxt)
176 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
181 function bc_isPending()
186 BogusChannel.prototype.status = Components.results.NS_OK;
189 function bc_cancel(status)
191 this.status = status;
196 function bc_suspres()
198 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
function NSGetModule(compMgr, fileSpec)
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
BogusChannel prototype QueryInterface
function BogusChannel(URI, contentType)
function newURI(aURLString)
sbDeviceFirmwareAutoCheckForUpdate prototype classID
function sbSongbirdDispatch()