Bug 429061 ��� webcals scheme not supported (i.e., for https); r=mvl

This commit is contained in:
daniel.boelzle%sun.com 2008-04-26 17:40:26 +00:00
Родитель 9c44fea7d4
Коммит 043adbc0e1
2 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -189,6 +189,11 @@ const componentData =
script: "calProtocolHandler.js",
constructor: "calProtocolHandler"},
{cid: Components.ID("{b2ee6f91-b061-4527-97a1-b85361775fc1}"),
contractid: "@mozilla.org/network/protocol;1?name=webcals",
script: "calProtocolHandler.js",
constructor: "calProtocolHandler"},
{cid: Components.ID("{6fe88047-75b6-4874-80e8-5f5800f14984}"),
contractid: "@mozilla.org/calendar/ics-parser;1",
script: "calIcsParser.js",
@ -279,7 +284,7 @@ var calItemModule = {
}
},
makeFactoryFor: function(constructor) {
makeFactoryFor: function(constructor, contractid) {
var factory = {
QueryInterface: function (aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
@ -291,7 +296,7 @@ var calItemModule = {
createInstance: function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return (new constructor()).QueryInterface(iid);
return (new constructor(contractid)).QueryInterface(iid);
}
};
@ -316,7 +321,9 @@ var calItemModule = {
eval(componentData[i].onComponentLoad);
}
// eval to get usual scope-walking
return this.makeFactoryFor(eval(componentData[i].constructor));
// somebody knows why we eval the constructor function's name?
return this.makeFactoryFor(eval(componentData[i].constructor),
componentData[i].contractid);
}
}

Просмотреть файл

@ -34,24 +34,17 @@
*
* ***** END LICENSE BLOCK ***** */
function calProtocolHandler() {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
this.mHttpProtocol = ios.getProtocolHandler("http");
function calProtocolHandler(contractid) {
this.scheme = contractid.substr("@mozilla.org/network/protocol;1?name=".length);
this.mHttpProtocol = getIOService().getProtocolHandler(this.scheme == "webcal" ? "http" : "https");
}
calProtocolHandler.prototype = {
QueryInterface: function cph_QueryInterface(aIID) {
if (!aIID.equals(Components.interfaces.nsISupports) &&
!aIID.equals(Components.interfaces.nsIProtocolHandler)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
return doQueryInterface(this, calProtocolHandler.prototype, aIID,
[ Components.interfaces.nsIProtocolHandler, Components.interfaces.nsISupports ]);
},
scheme: "webcal",
get defaultPort() {
return this.mHttpProtocol.defaultPort;
},
@ -64,7 +57,7 @@ calProtocolHandler.prototype = {
var uri = Components.classes["@mozilla.org/network/standard-url;1"].
createInstance(Components.interfaces.nsIStandardURL);
uri.init(Components.interfaces.nsIStandardURL.URLTYPE_STANDARD,
80, aSpec, anOriginalCharset, aBaseURI);
this.mHttpProtocol.defaultPort, aSpec, anOriginalCharset, aBaseURI);
return uri;
},
@ -72,14 +65,9 @@ calProtocolHandler.prototype = {
// make sure to clone the uri, because we are about to change
// it, and we don't want to change the original uri.
var uri = aUri.clone();
if (uri.scheme == 'webcal')
uri.scheme = 'http';
if (uri.scheme == 'webcals')
uri.scheme = 'https';
uri.scheme = this.mHttpProtocol.scheme;
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var channel = ios.newChannelFromURI(uri, null);
var channel = getIOService().newChannelFromURI(uri, null);
channel.originalURI = aUri;
return channel;
},