bug 350287 create a webcal protocol handler. r=lilmatt, dmose

This commit is contained in:
mvl%exedo.nl 2006-09-13 19:29:37 +00:00
parent 1258b8cec1
commit 4c7b608d3f
5 changed files with 12 additions and 75 deletions

View File

@ -84,6 +84,7 @@ EXTRA_SCRIPTS = \
calEvent.js \
calItemBase.js \
calItipItem.js \
calProtocolHandler.js \
calRecurrenceInfo.js \
calTodo.js \
calUtils.js \

View File

@ -137,7 +137,12 @@ const componentData =
{cid: Components.ID("{b84de879-4b85-4d68-8550-e0C527e46f98}"),
contractid: "@mozilla.org/calendar/itip-item;1",
script: "calItipItem.js",
constructor: "calItipItem"}
constructor: "calItipItem"},
{cid: Components.ID("{1e2fc0e2-bf5f-4d60-9f1e-5e92cf517c0b}"),
contractid: "@mozilla.org/network/protocol;1?name=webcal",
script: "calProtocolHandler.js",
constructor: "calProtocolHandler"}
];
var calItemModule = {

View File

@ -218,6 +218,7 @@ bin\js\calItipItem.js
bin\js\calListFormatter.js
bin\js\calMonthGridPrinter.js
bin\js\calOutlookCSVImportExport.js
bin\js\calProtocolHandler.js
bin\js\calRecurrenceInfo.js
bin\js\calTodo.js
bin\js\calUtils.js

View File

@ -148,7 +148,7 @@ calICSCalendar.prototype = {
// right hooks to use easier.
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var channel = ioService.newChannelFromURI(fixupUri(this.mUri));
var channel = ioService.newChannelFromURI(this.mUri);
if (channel instanceof Components.interfaces.nsIHttpChannel) {
this.mHooks = new httpHooks();
@ -168,7 +168,7 @@ calICSCalendar.prototype = {
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var channel = ioService.newChannelFromURI(fixupUri(this.mUri));
var channel = ioService.newChannelFromURI(this.mUri);
channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
channel.notificationCallbacks = this;
@ -363,8 +363,7 @@ calICSCalendar.prototype = {
var ioService = Components.classes
["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var channel = ioService.newChannelFromURI(
fixupUri(savedthis.mUri));
var channel = ioService.newChannelFromURI(savedthis.mUri);
// Allow the hook to add things to the channel, like a
// header that checks etags
@ -751,7 +750,7 @@ calICSCalendar.prototype = {
// Now go download the remote file, and store it somewhere local.
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(CI.nsIIOService);
var channel = ioService.newChannelFromURI(fixupUri(this.mUri));
var channel = ioService.newChannelFromURI(this.mUri);
channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
channel.notificationCallbacks = this;
@ -785,15 +784,6 @@ calICSCalendar.prototype = {
}
};
function fixupUri(aUri) {
var uri = aUri;
if (uri.scheme == 'webcal')
uri.scheme = 'http';
if (uri.scheme == 'webcals')
uri.scheme = 'https';
return uri;
}
function calICSObserver(aCalendar) {
this.mCalendar = aCalendar;
this.mObservers = new Array();

View File

@ -58,8 +58,6 @@ const ICALCNT_HANDLER_CONTRACTID =
"@mozilla.org/uriloader/content-handler;1?type=text/calendar";
const ICALCNT_HANDLER_CID =
Components.ID("{9ebf4c8a-7770-40a6-aeed-e1738129535a}");
const ICALPROT_HANDLER_CONTRACTID =
"@mozilla.org/network/protocol;1?name=webcal";
const ICALPROT_HANDLER_CID =
Components.ID("{d320ba05-88cf-44a6-b718-87a72ef05918}");
@ -216,52 +214,6 @@ function (outer, iid) {
return new ICALContentHandler();
}
/* webcal protocol handler component */
function ICALProtocolHandler()
{
}
ICALProtocolHandler.prototype.scheme = "webcal";
ICALProtocolHandler.prototype.defaultPort = 8080;
ICALProtocolHandler.prototype.protocolFlags =
nsIProtocolHandler.URI_NORELATIVE |
nsIProtocolHandler.ALLOWS_PROXY;
ICALProtocolHandler.prototype.allowPort =
function (aPort, aScheme)
{
return false;
}
ICALProtocolHandler.prototype.newURI =
function (aSpec, aCharset, aBaseURI)
{
var url = Components.classes[STANDARDURL_CONTRACTID].
createInstance(nsIStandardURL);
url.init(nsIStandardURL.URLTYPE_STANDARD, 8080, aSpec, aCharset, aBaseURI);
return url.QueryInterface(nsIURI);
}
ICALProtocolHandler.prototype.newChannel =
function (aURI)
{
return new BogusChannel (aURI);
}
/* protocol handler factory object (ICALProtocolHandler) */
var ICALProtocolHandlerFactory = new Object();
ICALProtocolHandlerFactory.createInstance =
function (outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (!iid.equals(nsIProtocolHandler) && !iid.equals(nsISupports))
throw Components.results.NS_ERROR_INVALID_ARG;
return new ICALProtocolHandler();
}
/* bogus webcal channel used by the ICALProtocolHandler */
function BogusChannel (aURI)
@ -363,14 +315,6 @@ function (compMgr, fileSpec, location, type)
fileSpec,
location,
type);
// dump("*** Registering webcal protocol handler.\n");
compMgr.registerFactoryLocation(ICALPROT_HANDLER_CID,
"Webcal protocol handler",
ICALPROT_HANDLER_CONTRACTID,
fileSpec,
location,
type);
}
CalendarModule.unregisterSelf =
@ -380,7 +324,6 @@ function(compMgr, fileSpec, location)
compMgr.unregisterFactoryLocation(CLINE_SERVICE_CID, fileSpec);
compMgr.unregisterFactoryLocation(ICALCNT_HANDLER_CID, fileSpec);
compMgr.unregisterFactoryLocation(ICALPROT_HANDLER_CID, fileSpec);
catman = Components.classes["@mozilla.org/categorymanager;1"]
.getService(nsICategoryManager);
@ -398,9 +341,6 @@ function (compMgr, cid, iid) {
if (cid.equals(ICALCNT_HANDLER_CID))
return ICALContentHandlerFactory;
if (cid.equals(ICALPROT_HANDLER_CID))
return ICALProtocolHandlerFactory;
throw Components.results.NS_ERROR_NO_INTERFACE;
}