зеркало из https://github.com/mozilla/pjs.git
primitive text/calendar display for Thunderbird, NPOTB
This commit is contained in:
Родитель
776c3f6556
Коммит
b6a383f345
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Oracle Corporation code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Oracle Corporation
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = lightning
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
lightningTextCalendarConverter.js \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,103 @@
|
|||
/* -*- Mode: javascript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
|
||||
const CI = Components.interfaces;
|
||||
|
||||
function ltnMimeConverter() { }
|
||||
|
||||
ltnMimeConverter.prototype = {
|
||||
QueryInterface: function (aIID) {
|
||||
if (!aIID.equals(CI.nsISupports) &&
|
||||
!aIID.equals(CI.nsISimpleMimeConverter))
|
||||
throw Components.interfaces.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
convertToHTML: function(contentType, data) {
|
||||
dump("converting " + contentType + " to HTML\n");
|
||||
|
||||
var event = Components.classes["@mozilla.org/calendar/event;1"]
|
||||
.createInstance(CI.calIEvent);
|
||||
event.icalString = data;
|
||||
|
||||
var html = "<center><table bgcolor='#CCFFFF'>\n";
|
||||
var organizer = event.organizer;
|
||||
html += "<tr><td>Invitation from</td><td><a href='" +
|
||||
organizer.id + "'>" + organizer.commonName + "</a></td></tr>\n";
|
||||
html += "<tr><td>Subject:</td><td>" + event.title + "</td></tr>\n";
|
||||
html += "</table></center>";
|
||||
|
||||
return html;
|
||||
}
|
||||
};
|
||||
|
||||
var myModule = {
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
debug("*** Registering Lightning text/calendar handler\n");
|
||||
compMgr = compMgr.QueryInterface(CI.nsIComponentRegistrar);
|
||||
compMgr.registerFactoryLocation(this.myCID,
|
||||
"Lightning text/calendar handler",
|
||||
this.myContractID,
|
||||
fileSpec,
|
||||
location,
|
||||
type);
|
||||
|
||||
var catman = Components.classes["@mozilla.org/categorymanager;1"]
|
||||
.getService(CI.nsICategoryManager);
|
||||
|
||||
catman.addCategoryEntry("simple-mime-converters", "text/calendar",
|
||||
this.myContractID, true, true);
|
||||
},
|
||||
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(this.myCID))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return this.myFactory;
|
||||
},
|
||||
|
||||
myCID: Components.ID("{c70acb08-464e-4e55-899d-b2c84c5409fa}"),
|
||||
|
||||
/* ProgID for this class */
|
||||
myContractID: "@mozilla.org/lightning/mime-converter;1",
|
||||
|
||||
/* factory object */
|
||||
myFactory: {
|
||||
/*
|
||||
* Construct an instance of the interface specified by iid, possibly
|
||||
* aggregating it with the provided outer. (If you don't know what
|
||||
* aggregation is all about, you don't need to. It reduces even the
|
||||
* mightiest of XPCOM warriors to snivelling cowards.)
|
||||
*/
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new ltnMimeConverter()).QueryInterface(iid);
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* The canUnload method signals that the component is about to be unloaded.
|
||||
* C++ components can return false to indicate that they don't wish to be
|
||||
* unloaded, but the return value from JS components' canUnload is ignored:
|
||||
* mark-and-sweep will keep everything around until it's no longer in use,
|
||||
* making unconditional ``unload'' safe.
|
||||
*
|
||||
* You still need to provide a (likely useless) canUnload method, though:
|
||||
* it's part of the nsIModule interface contract, and the JS loader _will_
|
||||
* call it.
|
||||
*/
|
||||
canUnload: function(compMgr) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return myModule;
|
||||
}
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче