Fix bug 576746 - Change Module Registration - Make calendar XPCOM components use new manifests and data tables. r=mschroeder
authorPhilipp Kewisch <mozilla@kewis.ch>
Mon, 09 Aug 2010 09:55:43 +0200
changeset 6108 c2cb7f16ade972e323526bd0fcb1fd94008a31f6
parent 6107 4f513cc9160913e0b6763aa3d3e0c52164d6b092
child 6109 b5e4c1df95ef213bd6218a81cdd21dcb9980cd12
push idunknown
push userunknown
push dateunknown
reviewersmschroeder
bugs576746
Fix bug 576746 - Change Module Registration - Make calendar XPCOM components use new manifests and data tables. r=mschroeder
calendar/base/src/Makefile.in
calendar/base/src/calItemModule.js
calendar/base/src/calItemModule.manifest
calendar/import-export/Makefile.in
calendar/import-export/calImportExportModule.js
calendar/import-export/calImportExportModule.manifest
calendar/installer/removed-files.in
calendar/installer/windows/packages-static
calendar/itip/Makefile.in
calendar/itip/calItipEmailTransport.js
calendar/itip/calItipEmailTransport.manifest
calendar/lightning/components/Makefile.in
calendar/lightning/components/calItipProtocolHandler.js
calendar/lightning/components/calItipProtocolHandler.manifest
calendar/lightning/components/lightningTextCalendarConverter.js
calendar/lightning/components/lightningTextCalendarConverter.manifest
calendar/providers/caldav/Makefile.in
calendar/providers/caldav/calDavCalendar.js
calendar/providers/caldav/calDavCalendar.manifest
calendar/providers/composite/Makefile.in
calendar/providers/composite/calCompositeCalendar.js
calendar/providers/composite/calCompositeCalendar.manifest
calendar/providers/gdata/components/Makefile.in
calendar/providers/gdata/components/calGoogleCalendarModule.js
calendar/providers/gdata/components/calGoogleCalendarModule.manifest
calendar/providers/ics/Makefile.in
calendar/providers/ics/calICSCalendar.js
calendar/providers/ics/calICSCalendar.manifest
calendar/providers/memory/Makefile.in
calendar/providers/memory/calMemoryCalendar.js
calendar/providers/memory/calMemoryCalendar.manifest
calendar/providers/storage/Makefile.in
calendar/providers/storage/calStorageCalendar.js
calendar/providers/storage/calStorageCalendar.manifest
calendar/providers/wcap/Makefile.in
calendar/providers/wcap/calWcapCalendarModule.js
calendar/providers/wcap/calWcapCalendarModule.manifest
calendar/providers/wcap/calWcapRequest.js
calendar/providers/wcap/calWcapSession.js
--- a/calendar/base/src/Makefile.in
+++ b/calendar/base/src/Makefile.in
@@ -65,16 +65,17 @@ CPPSRCS = calDateTime.cpp \
 	  calTimezone.cpp \
 	  calRecurrenceRule.cpp \
 	  calRecurrenceDate.cpp \
 	  calRecurrenceDateSet.cpp \
 	  calUtils.cpp \
 	  $(NULL)
 
 EXTRA_COMPONENTS = \
+    calItemModule.manifest \
     calItemModule.js \
     $(NULL)
 
 EXTRA_SCRIPTS = \
     calAlarm.js \
     calAlarmService.js \
     calAlarmMonitor.js \
     calAttachment.js \
--- a/calendar/base/src/calItemModule.js
+++ b/calendar/base/src/calItemModule.js
@@ -1,282 +1,105 @@
-/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* ***** 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 Original Code is Mozilla Calendar code.
  *
  * The Initial Developer of the Original Code is
- *  Oracle Corporation
- * Portions created by the Initial Developer are Copyright (C) 2004
+ *   Philipp Kewisch <mozilla@kewis.ch>
+ * Portions created by the Initial Developer are Copyright (C) 2010
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
- *   Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
- *   Mike Shaver <shaver@off.net>
- *   Matthew Willis <lilmatt@mozilla.com>
- *   Philipp Kewisch <mozilla@kewis.ch>
+ *   Daniel Boelzle <dbo.moz@boelzle.org>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either 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 ***** */
 
-/* Update these in calBaseCID.h */
-const componentData =
-    [
-     /* calItemBase and calUtils must be first: later scripts depend on them */
-    {cid: null,
-     contractid: null,
-     script: "calItemBase.js",
-     constructor: null},
-
-    {cid: null,
-     contractid: null,
-     script: "calUtils.js",
-     constructor: null},
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
 
-    {cid: null,
-     contractid: null,
-     script: "calCachedCalendar.js",
-     constructor: null},
-
-    {cid: Components.ID("{f42585e7-e736-4600-985d-9624c1c51992}"),
-     contractid: "@mozilla.org/calendar/manager;1",
-     script: "calCalendarManager.js",
-     constructor: "calCalendarManager",
-     service: true},
-
-    {cid: Components.ID("{b8db7c7f-c168-4e11-becb-f26c1c4f5f8f}"),
-     contractid: "@mozilla.org/calendar/alarm;1",
-     script: "calAlarm.js",
-     constructor: "calAlarm"},
+const scriptLoadOrder = [
+    "calItemBase.js",
+    "calUtils.js",
+    "calCachedCalendar.js",
 
-    {cid: Components.ID("{7a9200dd-6a64-4fff-a798-c5802186e2cc}"),
-     contractid: "@mozilla.org/calendar/alarm-service;1",
-     script: "calAlarmService.js",
-     constructor: "calAlarmService",
-     categories: {"app-startup": "alarm-service-startup"},
-     service: true},
-
-    {cid: Components.ID("{29c56cd5-d36e-453a-acde-0083bd4fe6d3}"),
-     contractid: "@mozilla.org/calendar/freebusy-service;1",
-     script: "calFreeBusyService.js",
-     constructor: "calFreeBusyService",
-     service: true},
-
-    {cid: Components.ID("{f5f743cd-8997-428e-bc1b-644e73f61203}"),
-     contractid: "@mozilla.org/calendar/calendarsearch-service;1",
-     script: "calCalendarSearchService.js",
-     constructor: "calCalendarSearchService",
-     service: true},
-
-    {cid: Components.ID("{4b7ae030-ed79-11d9-8cd6-0800200c9a66}"),
-     contractid: "@mozilla.org/calendar/alarm-monitor;1",
-     script: "calAlarmMonitor.js",
-     constructor: "calAlarmMonitor",
-     service: true,
-     categories: {"alarm-service-startup": "calendar-alarm-monitor",
-                  "alarm-service-shutdown": "calendar-alarm-monitor"}},
-
-    {cid: Components.ID("{974339d5-ab86-4491-aaaf-2b2ca177c12b}"),
-     contractid: "@mozilla.org/calendar/event;1",
-     script: "calEvent.js",
-     constructor: "calEvent"},
-
-    {cid: Components.ID("{7af51168-6abe-4a31-984d-6f8a3989212d}"),
-     contractid: "@mozilla.org/calendar/todo;1",
-     script: "calTodo.js",
-     constructor: "calTodo"},
+    "calAlarm.js",
+    "calAlarmService.js",
+    "calAlarmMonitor.js",
+    "calAttendee.js",
+    "calAttachment.js",
+    "calCalendarManager.js",
+    "calCalendarSearchService.js",
+    "calDateTimeFormatter.js",
+    "calEvent.js",
+    "calFreeBusyService.js",
+    "calIcsParser.js",
+    "calIcsSerializer.js",
+    "calItipItem.js",
+    "calProtocolHandler.js",
+    "calRecurrenceInfo.js",
+    "calRelation.js",
+    "calStartupService.js",
+    "calTransactionManager.js",
+    "calTimezoneService.js",
+    "calTodo.js",
+    "calWeekInfoService.js"
+];
 
-    {cid: Components.ID("{5c8dcaa3-170c-4a73-8142-d531156f664d}"),
-     contractid: "@mozilla.org/calendar/attendee;1",
-     script: "calAttendee.js",
-     constructor: "calAttendee"},
-
-    {cid: Components.ID("{5f76b352-ab75-4c2b-82c9-9206dbbf8571}"),
-     contractid: "@mozilla.org/calendar/attachment;1",
-     script: "calAttachment.js",
-     constructor: "calAttachment"},
-
-    {cid: Components.ID("{04027036-5884-4a30-b4af-f2cad79f6edf}"),
-     contractid: "@mozilla.org/calendar/recurrence-info;1",
-     script: "calRecurrenceInfo.js",
-     constructor: "calRecurrenceInfo"},
-
-    {cid: Components.ID("{76810fae-abad-4019-917a-08e95d5bbd68}"),
-     contractid: "@mozilla.org/calendar/relation;1",
-     script: "calRelation.js",
-     constructor: "calRelation"},
-
-    {cid: Components.ID("{4123da9a-f047-42da-a7d0-cc4175b9f36a}"),
-     contractid: "@mozilla.org/calendar/datetime-formatter;1",
-     script: "calDateTimeFormatter.js",
-     constructor: "calDateTimeFormatter"},
-
-    {cid: Components.ID("{6877bbdd-f336-46f5-98ce-fe86d0285cc1}"),
-     contractid: "@mozilla.org/calendar/weekinfo-service;1",
-     script: "calWeekInfoService.js",
-     constructor: "calWeekInfoService"},
-
-    {cid: Components.ID("{f41392ab-dcad-4bad-818f-b3d1631c4d93}"),
-     contractid: "@mozilla.org/calendar/itip-item;1",
-     script: "calItipItem.js",
-     constructor: "calItipItem"},
-
-    {cid: Components.ID("{1153c73a-39be-46aa-9ba9-656d188865ca}"),
-     contractid: "@mozilla.org/network/protocol;1?name=webcal",
-     script: "calProtocolHandler.js",
-     constructor: "calProtocolHandlerWebcal"},
-
-    {cid: Components.ID("{bdf71224-365d-4493-856a-a7e74026f766}"),
-     contractid: "@mozilla.org/network/protocol;1?name=webcals",
-     script: "calProtocolHandler.js",
-     constructor: "calProtocolHandlerWebcals"},
-
-    {cid: Components.ID("{6fe88047-75b6-4874-80e8-5f5800f14984}"),
-     contractid: "@mozilla.org/calendar/ics-parser;1",
-     script: "calIcsParser.js",
-     constructor: "calIcsParser"},
-
-    {cid: Components.ID("{207a6682-8ff1-4203-9160-729ec28c8766}"),
-     contractid: "@mozilla.org/calendar/ics-serializer;1",
-     script: "calIcsSerializer.js",
-     constructor: "calIcsSerializer"},
-
-    {cid: Components.ID("{40a1ccf4-5f54-4815-b842-abf06f84dbfd}"),
-     contractid: "@mozilla.org/calendar/transactionmanager;1",
-     script: "calTransactionManager.js",
-     constructor: "calTransactionManager"},
-
-    {cid: Components.ID("{1a23ace4-a0dd-43b4-96a8-b3cd419a14a5}"),
-     contractid: "@mozilla.org/calendar/timezone-service;1",
-     script: "calTimezoneService.js",
-     constructor: "calTimezoneService",
-     service: true},
-
-    // This should be last, or at least after all services it calls
-    {cid: Components.ID("{2547331f-34c0-4a4b-b93c-b503538ba6d6}"),
-     contractid: "@mozilla.org/calendar/startup-service;1",
-     script: "calStartupService.js",
-     constructor: "calStartupService",
-     categories: {"app-startup": "calendar-startup-startup"},
-     service: true}
+function NSGetFactory(cid) {
+    if (!this.scriptsLoaded) {
+        Services.io.getProtocolHandler("resource")
+                .QueryInterface(Components.interfaces.nsIResProtocolHandler)
+                .setSubstitution("calendar", Services.io.newFileURI(__LOCATION__.parent.parent));
+        Components.utils.import("resource://calendar/modules/calUtils.jsm");
+        cal.loadScripts(scriptLoadOrder, Components.utils.getGlobalForObject(this));
+        this.scriptsLoaded = true;
+    }
+    let components = [
+        calAlarm,
+        calAlarmService,
+        calAlarmMonitor,
+        calAttendee,
+        calAttachment,
+        calCalendarManager,
+        calCalendarSearchService,
+        calDateTimeFormatter,
+        calEvent,
+        calFreeBusyService,
+        calIcsParser,
+        calIcsSerializer,
+        calItipItem,
+        calProtocolHandlerWebcal,
+        calProtocolHandlerWebcals,
+        calRecurrenceInfo,
+        calRelation,
+        calStartupService,
+        calTransaction,
+        calTransactionManager,
+        calTimezoneService,
+        calTodo,
+        calWeekInfoService,
     ];
 
-var calItemModule = {
-    mScriptsLoaded: false,
-    loadScripts: function () {
-        if (this.mScriptsLoaded)
-            return;
-
-        // Register our alias here: this code always needs to run first (triggered by app-startup)
-        let ioService = Components.classes["@mozilla.org/network/io-service;1"]
-                                  .getService(Components.interfaces.nsIIOService2);
-        ioService.getProtocolHandler("resource")
-                 .QueryInterface(Components.interfaces.nsIResProtocolHandler)
-                 .setSubstitution("calendar", ioService.newFileURI(__LOCATION__.parent.parent));
-
-        Components.utils.import("resource://calendar/modules/calUtils.jsm");
-        cal.loadScripts(componentData.map(function(entry) { return entry.script; }),
-                        Components.utils.getGlobalForObject(this));
-
-        this.mScriptsLoaded = true;
-    },
-
-    registerSelf: function (compMgr, fileSpec, location, type) {
-        compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
-
-        var catman = Components.classes["@mozilla.org/categorymanager;1"]
-            .getService(Components.interfaces.nsICategoryManager);
-        for (var i = 0; i < componentData.length; i++) {
-            var comp = componentData[i];
-            if (!comp.cid)
-                continue;
-            compMgr.registerFactoryLocation(comp.cid,
-                                            "",
-                                            comp.contractid,
-                                            fileSpec,
-                                            location,
-                                            type);
-
-            if (comp.categories) {
-                var contractid;
-                if (comp.service)
-                    contractid = "service," + comp.contractid;
-                else
-                    contractid = comp.contractid;
-                for (var category in comp.categories) {
-                    catman.addCategoryEntry(category, comp.categories[category],
-                                            contractid, true, true);
-                }
-            }
-        }
-    },
-
-    makeFactoryFor: function(constructor, contractid) {
-        var factory = {
-            QueryInterface: function (aIID) {
-                if (!aIID.equals(Components.interfaces.nsISupports) &&
-                    !aIID.equals(Components.interfaces.nsIFactory))
-                    throw Components.results.NS_ERROR_NO_INTERFACE;
-                return this;
-            },
-
-            createInstance: function (outer, iid) {
-                if (outer != null)
-                    throw Components.results.NS_ERROR_NO_AGGREGATION;
-                return (new constructor(contractid)).QueryInterface(iid);
-            }
-        };
-
-        return factory;
-    },
-
-    getClassObject: function (compMgr, cid, iid) {
-        if (!iid.equals(Components.interfaces.nsIFactory))
-            throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-
-        if (!this.mScriptsLoaded)
-            this.loadScripts();
-
-        for (var i = 0; i < componentData.length; i++) {
-            if (cid.equals(componentData[i].cid)) {
-                if (componentData[i].onComponentLoad) {
-                    eval(componentData[i].onComponentLoad);
-                }
-                // eval to get usual scope-walking
-                // somebody knows why we eval the constructor function's name?
-                return this.makeFactoryFor(eval(componentData[i].constructor),
-                                           componentData[i].contractid);
-            }
-        }
-
-        throw Components.results.NS_ERROR_NO_INTERFACE;
-    },
-
-    canUnload: function(compMgr) {
-        return true;
-    }
-};
-
-function NSGetModule(compMgr, fileSpec) {
-    return calItemModule;
+    return (XPCOMUtils.generateNSGetFactory(components))(cid);
 }
new file mode 100644
--- /dev/null
+++ b/calendar/base/src/calItemModule.manifest
@@ -0,0 +1,71 @@
+component {b8db7c7f-c168-4e11-becb-f26c1c4f5f8f} calItemModule.js
+contract @mozilla.org/calendar/alarm;1 {b8db7c7f-c168-4e11-becb-f26c1c4f5f8f}
+
+component {7a9200dd-6a64-4fff-a798-c5802186e2cc} calItemModule.js
+contract @mozilla.org/calendar/alarm-service;1 {7a9200dd-6a64-4fff-a798-c5802186e2cc}
+
+component {4b7ae030-ed79-11d9-8cd6-0800200c9a66} calItemModule.js
+contract @mozilla.org/calendar/alarm-monitor;1 {4b7ae030-ed79-11d9-8cd6-0800200c9a66}
+category alarm-service-startup calendar-alarm-monitor @mozilla.org/calendar/alarm-monitor;1
+category alarm-service-shutdown calendar-alarm-monitor @mozilla.org/calendar/alarm-monitor;1
+
+component {5c8dcaa3-170c-4a73-8142-d531156f664d} calItemModule.js
+contract @mozilla.org/calendar/attendee;1 {5c8dcaa3-170c-4a73-8142-d531156f664d}
+
+component {5f76b352-ab75-4c2b-82c9-9206dbbf8571} calItemModule.js
+contract @mozilla.org/calendar/attachment;1 {5f76b352-ab75-4c2b-82c9-9206dbbf8571}
+
+component {f42585e7-e736-4600-985d-9624c1c51992} calItemModule.js
+contract @mozilla.org/calendar/manager;1 {f42585e7-e736-4600-985d-9624c1c51992}
+
+component {f5f743cd-8997-428e-bc1b-644e73f61203} calItemModule.js
+contract @mozilla.org/calendar/calendarsearch-service;1 {f5f743cd-8997-428e-bc1b-644e73f61203}
+
+component {4123da9a-f047-42da-a7d0-cc4175b9f36a} calItemModule.js
+contract @mozilla.org/calendar/datetime-formatter;1 {4123da9a-f047-42da-a7d0-cc4175b9f36a}
+
+component {974339d5-ab86-4491-aaaf-2b2ca177c12b} calItemModule.js
+contract @mozilla.org/calendar/event;1 {974339d5-ab86-4491-aaaf-2b2ca177c12b}
+
+component {29c56cd5-d36e-453a-acde-0083bd4fe6d3} calItemModule.js
+contract @mozilla.org/calendar/freebusy-service;1 {29c56cd5-d36e-453a-acde-0083bd4fe6d3}
+
+component {6fe88047-75b6-4874-80e8-5f5800f14984} calItemModule.js
+contract @mozilla.org/calendar/ics-parser;1 {6fe88047-75b6-4874-80e8-5f5800f14984}
+
+component {207a6682-8ff1-4203-9160-729ec28c8766} calItemModule.js
+contract @mozilla.org/calendar/ics-serializer;1 {207a6682-8ff1-4203-9160-729ec28c8766}
+
+component {f41392ab-dcad-4bad-818f-b3d1631c4d93} calItemModule.js
+contract @mozilla.org/calendar/itip-item;1 {f41392ab-dcad-4bad-818f-b3d1631c4d93}
+
+component {1e2fc0e2-bf5f-4d60-9f1e-5e92cf517c0b} calItemModule.js
+contract @mozilla.org/network/protocol;1?name=webcal {1e2fc0e2-bf5f-4d60-9f1e-5e92cf517c0b}
+
+component {b2ee6f91-b061-4527-97a1-b85361775fc1} calItemModule.js
+contract @mozilla.org/network/protocol;1?name=webcals {b2ee6f91-b061-4527-97a1-b85361775fc1}
+
+component {04027036-5884-4a30-b4af-f2cad79f6edf} calItemModule.js
+contract @mozilla.org/calendar/recurrence-info;1 {04027036-5884-4a30-b4af-f2cad79f6edf}
+
+component {76810fae-abad-4019-917a-08e95d5bbd68} calItemModule.js
+contract @mozilla.org/calendar/relation;1 {76810fae-abad-4019-917a-08e95d5bbd68}
+
+component {2547331f-34c0-4a4b-b93c-b503538ba6d6} calItemModule.js
+contract @mozilla.org/calendar/startup-service;1 {2547331f-34c0-4a4b-b93c-b503538ba6d6}
+category profile-after-change calendar-startup-service @mozilla.org/calendar/startup-service;1
+
+component {fcb54c82-2fb9-42cb-bf44-1e197a55e520} calItemModule.js
+contract @mozilla.org/calendar/transaction;1 {fcb54c82-2fb9-42cb-bf44-1e197a55e520}
+
+component {40a1ccf4-5f54-4815-b842-abf06f84dbfd} calItemModule.js
+contract @mozilla.org/calendar/transactionmanager;1 {40a1ccf4-5f54-4815-b842-abf06f84dbfd}
+
+component {1a23ace4-a0dd-43b4-96a8-b3cd419a14a5} calItemModule.js
+contract @mozilla.org/calendar/timezone-service;1 {1a23ace4-a0dd-43b4-96a8-b3cd419a14a5}
+
+component {7af51168-6abe-4a31-984d-6f8a3989212d} calItemModule.js
+contract @mozilla.org/calendar/todo;1 {7af51168-6abe-4a31-984d-6f8a3989212d}
+
+component {6877bbdd-f336-46f5-98ce-fe86d0285cc1} calItemModule.js
+contract @mozilla.org/calendar/weekinfo-service;1 {6877bbdd-f336-46f5-98ce-fe86d0285cc1}
--- a/calendar/import-export/Makefile.in
+++ b/calendar/import-export/Makefile.in
@@ -15,16 +15,17 @@
 # The Original Code is Mozilla Calendar code.
 #
 # The Initial Developer of the Original Code is
 #   Michiel van Leeuwen <mvl@exedo.nl>
 # Portions created by the Initial Developer are Copyright (C) 2005
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
+#   Philipp Kewisch <mozilla@kewis.ch>
 #
 # 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
@@ -39,16 +40,17 @@ DEPTH   = ../..
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH   = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 EXTRA_COMPONENTS = \
     calImportExportModule.js \
+    calImportExportModule.manifest \
     $(NULL)
 
 EXTRA_SCRIPTS = \
     calHtmlExport.js \
     calIcsImportExport.js \
     calListFormatter.js \
     calMonthGridPrinter.js \
     calOutlookCSVImportExport.js \
--- a/calendar/import-export/calImportExportModule.js
+++ b/calendar/import-export/calImportExportModule.js
@@ -17,181 +17,58 @@
  * 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>
  *   Mike Shaver <shaver@off.net>
+ *   Philipp Kewisch <mozilla@kewis.ch>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either 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 ***** */
 
-const componentData =
-    [
-    {cid: Components.ID("{1e3e33dc-445a-49de-b2b6-15b2a050bb9d}"),
-     contractid: "@mozilla.org/calendar/import;1?type=ics",
-     script: "calIcsImportExport.js",
-     constructor: "calIcsImporter",
-     category: "cal-importers",
-     categoryEntry: "cal-ics-importer",
-     service: false},
-    {cid: Components.ID("{a6a524ce-adff-4a0f-bb7d-d1aaad4adc60}"),
-     contractid: "@mozilla.org/calendar/export;1?type=ics",
-     constructor: "calIcsExporter",
-     category: "cal-exporters",
-     categoryEntry: "cal-ics-exporter",
-     service: false},
-
-    {cid: Components.ID("{72d9ab35-9b1b-442a-8cd0-ae49f00b159b}"),
-     contractid: "@mozilla.org/calendar/export;1?type=htmllist",
-     script: "calHtmlExport.js",
-     constructor: "calHtmlExporter",
-     category: "cal-exporters",
-     categoryEntry: "cal-html-list-exporter",
-     service: false},
+const scriptLoadOrder = [
+    "calIcsImportExport.js",
+    "calHtmlExport.js",
+    "calOutlookCSVImportExport.js",
 
-    {cid: Components.ID("{9ae04413-fee3-45b9-8bbb-1eb39a4cbd1b}"),
-     contractid: "@mozilla.org/calendar/printformatter;1?type=list",
-     script: "calListFormatter.js",
-     constructor: "calListFormatter",
-     category: "cal-print-formatters",
-     categoryEntry: "cal-list-printformatter",
-     service: false},
-    {cid: Components.ID("{f42d5132-92c4-487b-b5c8-38bf292d74c1}"),
-     contractid: "@mozilla.org/calendar/printformatter;1?type=monthgrid",
-     script: "calMonthGridPrinter.js",
-     constructor: "calMonthPrinter",
-     category: "cal-print-formatters",
-     categoryEntry: "cal-month-printer",
-     service: false},
-    {cid: Components.ID("{2d6ec97b-9109-4b92-89c5-d4b4806619ce}"),
-     contractid: "@mozilla.org/calendar/printformatter;1?type=weekplan",
-     script: "calWeekPrinter.js",
-     constructor: "calWeekPrinter",
-     category: "cal-print-formatters",
-     categoryEntry: "cal-week-planner-printer",
-     service: false},
+    "calListFormatter.js",
+    "calMonthGridPrinter.js",
+    "calWeekPrinter.js"
+];
+
 
-    {cid: Components.ID("{64a5d17a-0497-48c5-b54f-72b15c9e9a14}"),
-     contractid: "@mozilla.org/calendar/import;1?type=csv",
-     script: "calOutlookCSVImportExport.js",
-     constructor: "calOutlookCSVImporter",
-     category: "cal-importers",
-     categoryEntry: "cal-outlookcsv-importer",
-     service: false},
-    {cid: Components.ID("{48e6d3a6-b41b-4052-9ed2-40b27800bd4b}"),
-     contractid: "@mozilla.org/calendar/export;1?type=csv",
-     constructor: "calOutlookCSVExporter",
-     category: "cal-exporters",
-     categoryEntry: "cal-outlookcsv-exporter",
-     service: false},
-
-    {cid: null,
-     contractid: null,
-     script: "calUtils.js",
-     constructor: null,
-     category: null,
-     categoryEntry: null,
-     service: false},
-
-    ];
-
-var calImportExportModule = {
-    mScriptsLoaded: false,
-    loadScripts: function () {
-        if (this.mScriptsLoaded)
-            return;
-
+function NSGetFactory(cid) {
+    if (!this.scriptsLoaded) {
+        Services.io.getProtocolHandler("resource")
+                .QueryInterface(Components.interfaces.nsIResProtocolHandler)
+                .setSubstitution("calendar", Services.io.newFileURI(__LOCATION__.parent.parent));
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
-        cal.loadScripts(componentData.map(function(entry) { return entry.script; }),
-                        Components.utils.getGlobalForObject(this));
-
-        this.mScriptsLoaded = true;
-    },
-
-    registerSelf: function (compMgr, fileSpec, location, type) {
-        compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
-
-        var catman = Components.classes["@mozilla.org/categorymanager;1"]
-            .getService(Components.interfaces.nsICategoryManager);
-        for (var i = 0; i < componentData.length; i++) {
-            var comp = componentData[i];
-            if (!comp.cid)
-                continue;
-            compMgr.registerFactoryLocation(comp.cid,
-                                            "",
-                                            comp.contractid,
-                                            fileSpec,
-                                            location,
-                                            type);
-
-            if (comp.category) {
-                var contractid;
-                if (comp.service)
-                    contractid = "service," + comp.contractid;
-                else
-                    contractid = comp.contractid;
-                catman.addCategoryEntry(comp.category, comp.categoryEntry,
-                                        contractid, true, true);
-            }
-        }
-    },
+        cal.loadScripts(scriptLoadOrder, Components.utils.getGlobalForObject(this));
+        this.scriptsLoaded = true;
+    }
 
-    makeFactoryFor: function(constructor) {
-        var factory = {
-            QueryInterface: function (aIID) {
-                if (!aIID.equals(Components.interfaces.nsISupports) &&
-                    !aIID.equals(Components.interfaces.nsIFactory))
-                    throw Components.results.NS_ERROR_NO_INTERFACE;
-                return this;
-            },
-
-            createInstance: function (outer, iid) {
-                if (outer != null)
-                    throw Components.results.NS_ERROR_NO_AGGREGATION;
-                return (new constructor()).QueryInterface(iid);
-            }
-        };
-
-        return factory;
-    },
-
-    getClassObject: function (compMgr, cid, iid) {
-        if (!iid.equals(Components.interfaces.nsIFactory))
-            throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
+    let components = [
+        calIcsImporter,
+        calIcsExporter,
+        calHtmlExporter,
+        calOutlookCSVImporter,
+        calOutlookCSVExporter,
 
-        if (!this.mScriptsLoaded)
-            this.loadScripts();
-
-        for (var i = 0; i < componentData.length; i++) {
-            if (cid.equals(componentData[i].cid)) {
-                if (componentData[i].onComponentLoad) {
-                    eval(componentData[i].onComponentLoad);
-                }
-                // eval to get usual scope-walking
-                return this.makeFactoryFor(eval(componentData[i].constructor));
-            }
-        }
-
-        throw Components.results.NS_ERROR_NO_INTERFACE;
-    },
-
-    canUnload: function(compMgr) {
-        return true;
-    }
-};
-
-function NSGetModule(compMgr, fileSpec) {
-    return calImportExportModule;
+        calListFormatter,
+        calMonthPrinter,
+        calWeekPrinter
+    ];
+    return (XPCOMUtils.generateNSGetFactory(components))(cid);
 }
new file mode 100644
--- /dev/null
+++ b/calendar/import-export/calImportExportModule.manifest
@@ -0,0 +1,31 @@
+component {1e3e33dc-445a-49de-b2b6-15b2a050bb9d} calIcsImportExport.js
+contract @mozilla.org/calendar/import;1?type=ics {1e3e33dc-445a-49de-b2b6-15b2a050bb9d}
+category cal-importers cal-ics-importer @mozilla.org/calendar/import;1?type=ics
+
+component {a6a524ce-adff-4a0f-bb7d-d1aaad4adc60} calIcsImportExport.js
+contract @mozilla.org/calendar/export;1?type=ics {a6a524ce-adff-4a0f-bb7d-d1aaad4adc60}
+category cal-exporters cal-ics-exporter @mozilla.org/calendar/export;1?type=ics
+
+component {72d9ab35-9b1b-442a-8cd0-ae49f00b159b} calHtmlExport.js
+contract @mozilla.org/calendar/export;1?type=htmllist {72d9ab35-9b1b-442a-8cd0-ae49f00b159b}
+category cal-exporters cal-html-list-exporter @mozilla.org/calendar/export;1?type=htmllist
+
+component {9ae04413-fee3-45b9-8bbb-1eb39a4cbd1b} calListFormatter.js
+contract @mozilla.org/calendar/printformatter;1?type=list {9ae04413-fee3-45b9-8bbb-1eb39a4cbd1b}
+category cal-print-formatters cal-list-printformatter @mozilla.org/calendar/printformatter;1?type=list
+
+component {f42d5132-92c4-487b-b5c8-38bf292d74c1} calMonthGridPrinter.js
+contract @mozilla.org/calendar/printformatter;1?type=monthgrid {f42d5132-92c4-487b-b5c8-38bf292d74c1}
+category cal-print-formatters cal-month-printer @mozilla.org/calendar/printformatter;1?type=monthgrid
+
+component {2d6ec97b-9109-4b92-89c5-d4b4806619ce} calWeekPrinter.js
+contract @mozilla.org/calendar/printformatter;1?type=weekplan {2d6ec97b-9109-4b92-89c5-d4b4806619ce}
+category cal-print-formatters cal-week-planner-printer @mozilla.org/calendar/printformatter;1?type=weekplan
+
+component {64a5d17a-0497-48c5-b54f-72b15c9e9a14} calOutlookCSVImportExport.js
+contract @mozilla.org/calendar/import;1?type=csv {64a5d17a-0497-48c5-b54f-72b15c9e9a14}
+category cal-importers cal-outlookcsv-importer @mozilla.org/calendar/import;1?type=csv
+
+component {48e6d3a6-b41b-4052-9ed2-40b27800bd4b} calOutlookCSVImportExport.js
+contract @mozilla.org/calendar/export;1?type=csv {48e6d3a6-b41b-4052-9ed2-40b27800bd4b}
+category cal-exporters cal-outlookcsv-exporter @mozilla.org/calendar/export;1?type=csv
--- a/calendar/installer/removed-files.in
+++ b/calendar/installer/removed-files.in
@@ -360,23 +360,17 @@ extensions/talkback@mozilla.org/componen
 #endif
 #
 # Clean out update service components if MOZ_UPDATER isn't defined
 #
 #ifndef MOZ_UPDATER
 components/nsUpdateService.js
 components/nsUpdateServiceStub.js
 #endif
-#
-# bug 404085 (Consolidate provider methods into a default calendar
-# implementation)
-components/calDavCalendar.js
-components/calICSCalendar.js
-components/calMemoryCalendar.js
-components/calStorageCalendar.js
+
 # bug 381049 (Moved crashreporter interface)
 components/crashreporter.xpt
 # bug 415330 (Remove XPInstall leftovers)
 @DLL_PREFIX@xpistub@DLL_SUFFIX@
 res/cmessage.txt
 #ifdef XP_WIN
 xpicleanup.exe
 #else
@@ -477,8 +471,13 @@ js3250.dll
 #ifdef XP_WIN
 components/calbscmp.dll
 #endif
 
 components/contentprefs.xpt
 
 # Bug 522712 - Port |Bug 511761 - Only use compatibility.ini (not .autoreg, or stat()s) to invalidate fastloads and other caches| to comm-central (apps)
 .autoreg
+
+# Bug 576746 - new xpcom registration, we're cleaning up some extra files here
+components/calStorageCalendarModule.js
+components/calMemoryCalendarModule.js
+components/calICSCalendarModule.js
--- a/calendar/installer/windows/packages-static
+++ b/calendar/installer/windows/packages-static
@@ -183,23 +183,23 @@ bin\components\xpconnect.xpt
 bin\components\xpinstall.xpt
 bin\components\xulapp.xpt
 bin\components\xuldoc.xpt
 bin\components\xultmpl.xpt
 bin\components\zipwriter.xpt
 
 ; JavaScript components
 bin\components\calCompositeCalendar.js
-bin\components\calDavCalendarModule.js
+bin\components\calDavCalendar.js
 bin\components\calendarService.js
-bin\components\calICSCalendarModule.js
+bin\components\calICSCalendar.js
 bin\components\calImportExportModule.js
 bin\components\calItemModule.js
-bin\components\calMemoryCalendarModule.js
-bin\components\calStorageCalendarModule.js
+bin\components\calMemoryCalendar.js
+bin\components\calStorageCalendar.js
 bin\components\calWcapCalendarModule.js
 bin\components\jsconsole-clhandler.js
 bin\components\NetworkGeolocationProvider.js
 bin\components\nsAddonRepository.js
 bin\components\nsBadCertHandler.js
 bin\components\nsBlocklistService.js
 bin\components\nsContentDispatchChooser.js
 bin\components\nsContentPrefService.js
@@ -229,36 +229,32 @@ bin\calendar-js\calAlarm.js
 bin\calendar-js\calAlarmMonitor.js
 bin\calendar-js\calAlarmService.js
 bin\calendar-js\calAttachment.js
 bin\calendar-js\calAttendee.js
 bin\calendar-js\calCachedCalendar.js
 bin\calendar-js\calCalendarManager.js
 bin\calendar-js\calCalendarSearchService.js
 bin\calendar-js\calDateTimeFormatter.js
-bin\calendar-js\calDavCalendar.js
 bin\calendar-js\calDavRequestHandlers.js
 bin\calendar-js\calEvent.js
 bin\calendar-js\calFilter.js
 bin\calendar-js\calFreeBusyService.js
 bin\calendar-js\calHtmlExport.js
-bin\calendar-js\calICSCalendar.js
 bin\calendar-js\calIcsImportExport.js
 bin\calendar-js\calIcsParser.js
 bin\calendar-js\calIcsSerializer.js
 bin\calendar-js\calItemBase.js
 bin\calendar-js\calItipItem.js
 bin\calendar-js\calListFormatter.js
-bin\calendar-js\calMemoryCalendar.js
 bin\calendar-js\calMonthGridPrinter.js
 bin\calendar-js\calOutlookCSVImportExport.js
 bin\calendar-js\calProtocolHandler.js
 bin\calendar-js\calRecurrenceInfo.js
 bin\calendar-js\calRelation.js
-bin\calendar-js\calStorageCalendar.js
 bin\calendar-js\calTimezoneService.js
 bin\calendar-js\calTodo.js
 bin\calendar-js\calTransactionManager.js
 bin\calendar-js\calUtils.js
 bin\calendar-js\calWcapCalendar.js
 bin\calendar-js\calWcapCalendarItems.js
 bin\calendar-js\calWcapErrors.js
 bin\calendar-js\calWcapRequest.js
--- a/calendar/itip/Makefile.in
+++ b/calendar/itip/Makefile.in
@@ -15,16 +15,17 @@
 # The Original Code is Simdesk Technologies Code.
 #
 # The Initial Developer of the Original Code is Simdesk Technologies.
 # Portions created by the Initial Developer are Copyright (C) 2007
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Clint Talbert <ctalbert.moz@gmail.com>
+#   Philipp Kewisch <mozilla@kewis.ch>
 #
 # Alternatively, the contents of this file may be used under the terms of
 # either 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
@@ -39,11 +40,14 @@ DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = calItipEmailTransport
 
-EXTRA_COMPONENTS = calItipEmailTransport.js
+EXTRA_COMPONENTS = \
+    calItipEmailTransport.js \
+    calItipEmailTransport.manifest \
+    $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/calendar/itip/calItipEmailTransport.js
+++ b/calendar/itip/calItipEmailTransport.js
@@ -407,9 +407,9 @@ calItipEmailTransport.prototype = {
             return tempFile;
         } catch (exc) {
             cal.ASSERT(false, exc);
             return null;
         }
     }
 };
 
-var NSGetModule = XPCOMUtils.generateNSGetModule([calItipEmailTransport]);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([calItipEmailTransport]);
new file mode 100644
--- /dev/null
+++ b/calendar/itip/calItipEmailTransport.manifest
@@ -0,0 +1,2 @@
+component {d4d7b59e-c9e0-4a7a-b5e8-5958f85515f0} calItipEmailTransport.js
+contract @mozilla.org/calendar/itip-transport;1?type=email {d4d7b59e-c9e0-4a7a-b5e8-5958f85515f0}
--- a/calendar/lightning/components/Makefile.in
+++ b/calendar/lightning/components/Makefile.in
@@ -16,16 +16,17 @@
 #
 # 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>
+#   Philipp Kewisch <mozilla@kewis.ch>
 #
 # 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
@@ -42,12 +43,14 @@ srcdir    = @srcdir@
 VPATH   = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE           = lightning
 
 EXTRA_COMPONENTS = \
 	lightningTextCalendarConverter.js \
+	lightningTextCalendarConverter.manifest \
 	calItipProtocolHandler.js \
+	calItipProtocolHandler.manifest \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/calendar/lightning/components/calItipProtocolHandler.js
+++ b/calendar/lightning/components/calItipProtocolHandler.js
@@ -187,9 +187,9 @@ ItipContentHandler.prototype = {
             event.organizer.id + " (" + event.id + ")\n");
         let calMgr = cal.getCalendarManager();
         let cals = calMgr.getCalendars({});
         cals[0].addItem(event, null);
     }
 };
 
 var components = [ItipChannel, ItipProtocolHandler, ItipContentHandler];
-var NSGetModule = XPCOMUtils.generateNSGetModule(components);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
new file mode 100644
--- /dev/null
+++ b/calendar/lightning/components/calItipProtocolHandler.manifest
@@ -0,0 +1,8 @@
+component {643e0328-36f6-411d-a107-16238dff9cd7} calItipProtocolHandler.js
+contract @mozilla.org/calendar/itip-channel;1 {643e0328-36f6-411d-a107-16238dff9cd7}
+
+component {6e957006-b4ce-11d9-b053-001124736B74} calItipProtocolHandler.js
+contract @mozilla.org/network/protocol;1?name=moz-cal-handle-itip {6e957006-b4ce-11d9-b053-001124736B74}
+
+component {47c31f2b-b4de-11d9-bfe6-001124736B74} calItipProtocolHandler.js
+contract @mozilla.org/uriloader/content-handler;1?type=application/x-itip-internal {47c31f2b-b4de-11d9-bfe6-001124736B74}
--- a/calendar/lightning/components/lightningTextCalendarConverter.js
+++ b/calendar/lightning/components/lightningTextCalendarConverter.js
@@ -200,21 +200,16 @@ ltnMimeConverter.prototype = {
         return ifaces;
     },
     getHelperForLanguage: function getHelperForLanguage(language) {
         return null;
     },
     implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
     flags: 0,
 
-    _xpcom_categories: [{
-        category: 'simple-mime-converters',
-        entry: 'text/calendar'
-    }],
-
     QueryInterface: function QI(aIID) {
         return cal.doQueryInterface(this, ltnMimeConverter.prototype, aIID, null, this);
     },
 
     mUri: null,
     get uri() {
         return this.mUri;
     },
@@ -275,9 +270,9 @@ ltnMimeConverter.prototype = {
         } catch (e) {
             Components.utils.reportError("[ltnMimeConverter] convertToHTML: " + e);
         }
 
         return html;
     }
 };
 
-var NSGetModule = XPCOMUtils.generateNSGetModule([ltnMimeConverter]);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([ltnMimeConverter]);
new file mode 100644
--- /dev/null
+++ b/calendar/lightning/components/lightningTextCalendarConverter.manifest
@@ -0,0 +1,3 @@
+component {c70acb08-464e-4e55-899d-b2c84c5409fa} lightningTextCalendarConverter.js
+contract @mozilla.org/lightning/mime-converter;1 {c70acb08-464e-4e55-899d-b2c84c5409fa}
+category simple-mime-converters text/calendar @mozilla.org/lightning-mime-converter;1
--- a/calendar/providers/caldav/Makefile.in
+++ b/calendar/providers/caldav/Makefile.in
@@ -42,17 +42,17 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = caldav
 
 DIRS = public
 
-EXTRA_COMPONENTS = calDavCalendar.js
+EXTRA_COMPONENTS = calDavCalendar.js calDavCalendar.manifest
 EXTRA_SCRIPTS = calDavRequestHandlers.js
 
 libs:: $(EXTRA_SCRIPTS)
 	if test ! -d $(FINAL_TARGET)/calendar-js; then $(NSINSTALL) -D $(FINAL_TARGET)/calendar-js; fi
 	$(INSTALL) $^ $(FINAL_TARGET)/calendar-js
 
 # The install target must use SYSINSTALL, which is NSINSTALL in copy mode.
 install:: $(EXTRA_SCRIPTS)
--- a/calendar/providers/caldav/calDavCalendar.js
+++ b/calendar/providers/caldav/calDavCalendar.js
@@ -502,17 +502,17 @@ calDavCalendar.prototype = {
      * Performs the actual addition of the item to CalDAV store
      *
      * @param aItem       item to add
      * @param aListener   listener for method completion
      * @param aIgnoreEtag ignore item etag
      */
     doAdoptItem: function caldav_doAdoptItem(aItem, aListener, aIgnoreEtag) {
         if (aItem.id == null && aItem.isMutable) {
-            aItem.id = getUUID();
+            aItem.id = cal.getUUID();
         }
 
         if (aItem.id == null) {
             this.notifyOperationComplete(aListener,
                                          Components.results.NS_ERROR_FAILURE,
                                          Components.interfaces.calIOperationListener.ADD,
                                          aItem.id,
                                          "Can't set ID on non-mutable item to addItem");
@@ -2017,17 +2017,17 @@ calDavCalendar.prototype = {
         fbQuery.addProperty(prop);
         var fbComp = getIcsService().createIcalComponent("VFREEBUSY");
         fbComp.stampTime = now().getInTimezone(UTC());
         prop = getIcsService().createIcalProperty("ORGANIZER");
         prop.value = organizer;
         fbComp.addProperty(prop);
         fbComp.startTime = aRangeStart.getInTimezone(UTC());
         fbComp.endTime = aRangeEnd.getInTimezone(UTC());
-        fbComp.uid = getUUID();
+        fbComp.uid = cal.getUUID();
         prop = getIcsService().createIcalProperty("ATTENDEE");
         prop.setParameter("PARTSTAT", "NEEDS-ACTION");
         prop.setParameter("ROLE", "REQ-PARTICIPANT");
         prop.setParameter("CUTYPE", "INDIVIDUAL");
         prop.value = mailto_aCalId;
         fbComp.addProperty(prop);
         fbQuery.addSubcomponent(fbComp);
         fbQuery = fbQuery.serializeToICS();
@@ -2499,20 +2499,20 @@ calDavObserver.prototype = {
 };
 
 /** Module Registration */
 const scriptLoadOrder = [
     "calUtils.js",
     "calDavRequestHandlers.js"
 ];
 
-function NSGetModule(cid) {
+function NSGetFactory(cid) {
     if (!this.scriptsLoaded) {
         Services.io.getProtocolHandler("resource")
                 .QueryInterface(Components.interfaces.nsIResProtocolHandler)
                 .setSubstitution("calendar", Services.io.newFileURI(__LOCATION__.parent.parent));
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
         cal.loadScripts(scriptLoadOrder, Components.utils.getGlobalForObject(this));
         this.scriptsLoaded = true;
     }
 
-    return (XPCOMUtils.generateNSGetModule([calDavCalendar]))(cid);
+    return (XPCOMUtils.generateNSGetFactory([calDavCalendar]))(cid);
 }
new file mode 100644
--- /dev/null
+++ b/calendar/providers/caldav/calDavCalendar.manifest
@@ -0,0 +1,2 @@
+component {a35fc6ea-3d92-11d9-89f9-00045ace3b8d} calDavCalendar.js
+contract @mozilla.org/calendar/calendar;1?type=caldav {a35fc6ea-3d92-11d9-89f9-00045ace3b8d}
--- a/calendar/providers/composite/Makefile.in
+++ b/calendar/providers/composite/Makefile.in
@@ -40,11 +40,11 @@ DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = calCompositeCalendar
 
-EXTRA_COMPONENTS = calCompositeCalendar.js
+EXTRA_COMPONENTS = calCompositeCalendar.js calCompositeCalendar.manifest
 
 include $(topsrcdir)/config/rules.mk
--- a/calendar/providers/composite/calCompositeCalendar.js
+++ b/calendar/providers/composite/calCompositeCalendar.js
@@ -589,9 +589,9 @@ calCompositeGetListenerHelper.prototype 
         // send GetResults to the real listener
         this.mRealListener.onGetResult (aCalendar, aStatus, aItemType, aDetail, aCount, aItems);
         this.mItemsReceived += aCount;
     }
 
 };
 
 /** Module Registration */
-var NSGetModule = XPCOMUtils.generateNSGetModule([calCompositeCalendar]);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([calCompositeCalendar]);
new file mode 100644
--- /dev/null
+++ b/calendar/providers/composite/calCompositeCalendar.manifest
@@ -0,0 +1,2 @@
+component {aeff788d-63b0-4996-91fb-40a7654c6224} calCompositeCalendar.js
+contract @mozilla.org/calendar/calendar;1?type=composite {aeff788d-63b0-4996-91fb-40a7654c6224}
--- a/calendar/providers/gdata/components/Makefile.in
+++ b/calendar/providers/gdata/components/Makefile.in
@@ -37,17 +37,17 @@
 DEPTH = ../../../..
 topsrcdir = @top_srcdir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = gdata-provider
-EXTRA_COMPONENTS = calGoogleCalendarModule.js
+EXTRA_COMPONENTS = calGoogleCalendarModule.js calGoogleCalendarModule.manifest
 
 EXTRA_SCRIPTS = \
     calGoogleCalendar.js \
     calGoogleRequest.js \
     calGoogleSession.js \
     calGoogleUtils.js \
     $(NULL)
 
--- a/calendar/providers/gdata/components/calGoogleCalendarModule.js
+++ b/calendar/providers/gdata/components/calGoogleCalendarModule.js
@@ -49,17 +49,17 @@ const calendarScriptLoadOrder = [
 
 const gdataScriptLoadOrder = [
     "calGoogleCalendar.js",
     "calGoogleSession.js",
     "calGoogleRequest.js",
     "calGoogleUtils.js"
 ];
 
-function NSGetModule(cid) {
+function NSGetFactory(cid) {
     if (!this.scriptsLoaded) {
         // First load the calendar scripts
         cal.loadScripts(calendarScriptLoadOrder, Components.utils.getGlobalForObject(this));
 
         // Now load gdata extension scripts. __LOCATION__ is the current
         // filename, so  __LOCATION__.parent == . We expect to find the
         // subscripts in ./../js
         let thisDir = __LOCATION__.parent.parent.clone();
@@ -70,10 +70,10 @@ function NSGetModule(cid) {
 
     let components = [
         calGoogleCalendar,
         calGoogleSession,
         calGoogleSessionManager,
         calGoogleRequest
     ];
 
-    return (XPCOMUtils.generateNSGetModule(components))(cid);
+    return (XPCOMUtils.generateNSGetFactory(components))(cid);
 }
new file mode 100644
--- /dev/null
+++ b/calendar/providers/gdata/components/calGoogleCalendarModule.manifest
@@ -0,0 +1,11 @@
+component {d1a6e988-4b4d-45a5-ba46-43e501ea96e3} calGoogleCalendarModule.js
+contract @mozilla.org/calendar/calendar;1?type=gdata {d1a6e988-4b4d-45a5-ba46-43e501ea96e3}
+
+component {652f6233-e03f-438a-bd3b-39877f68c0f4} calGoogleCalendarModule.js
+contract @mozilla.org/calendar/providers/gdata/session;1 {652f6233-e03f-438a-bd3b-39877f68c0f4}
+
+component {6a7ba1f0-f271-49b0-8e93-5ca33651b4af} calGoogleCalendarModule.js
+contract @mozilla.org/calendar/providers/gdata/session-manager;1 {6a7ba1f0-f271-49b0-8e93-5ca33651b4af}
+
+component {53a3438a-21bc-4a0f-b813-77a8b4f19282} calGoogleCalendarModule.js
+contract @mozilla.org/calendar/providers/gdata/request;1 {53a3438a-21bc-4a0f-b813-77a8b4f19282}
--- a/calendar/providers/ics/Makefile.in
+++ b/calendar/providers/ics/Makefile.in
@@ -41,11 +41,11 @@ DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = calICSCalendar
 
-EXTRA_COMPONENTS = calICSCalendar.js
+EXTRA_COMPONENTS = calICSCalendar.js calICSCalendar.manifest
 
 include $(topsrcdir)/config/rules.mk
--- a/calendar/providers/ics/calICSCalendar.js
+++ b/calendar/providers/ics/calICSCalendar.js
@@ -1055,20 +1055,20 @@ fileHooks.prototype = {
     }
 };
 
 /** Module Registration */
 const scriptLoadOrder = [
     "calUtils.js",
 ];
 
-function NSGetModule(cid) {
+function NSGetFactory(cid) {
     if (!this.scriptsLoaded) {
         Services.io.getProtocolHandler("resource")
                 .QueryInterface(Components.interfaces.nsIResProtocolHandler)
                 .setSubstitution("calendar", Services.io.newFileURI(__LOCATION__.parent.parent));
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
         cal.loadScripts(scriptLoadOrder, Components.utils.getGlobalForObject(this));
         this.scriptsLoaded = true;
     }
 
-    return (XPCOMUtils.generateNSGetModule([calICSCalendar]))(cid);
+    return (XPCOMUtils.generateNSGetFactory([calICSCalendar]))(cid);
 }
new file mode 100644
--- /dev/null
+++ b/calendar/providers/ics/calICSCalendar.manifest
@@ -0,0 +1,2 @@
+component {f8438bff-a3c9-4ed5-b23f-2663b5469abf} calICSCalendar.js
+contract @mozilla.org/calendar/calendar;1?type=ics {f8438bff-a3c9-4ed5-b23f-2663b5469abf}
--- a/calendar/providers/memory/Makefile.in
+++ b/calendar/providers/memory/Makefile.in
@@ -40,11 +40,11 @@ DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = calMemoryCalendar
 
-EXTRA_COMPONENTS = calMemoryCalendar.js
+EXTRA_COMPONENTS = calMemoryCalendar.js calMemoryCalendar.manifest
 
 include $(topsrcdir)/config/rules.mk
--- a/calendar/providers/memory/calMemoryCalendar.js
+++ b/calendar/providers/memory/calMemoryCalendar.js
@@ -146,17 +146,17 @@ calMemoryCalendar.prototype = {
         return this.adoptItem(newItem, aListener);
     },
     
     // void adoptItem( in calIItemBase aItem, in calIOperationListener aListener );
     adoptItem: function (aItem, aListener) {
         if (this.readOnly) 
             throw Components.interfaces.calIErrors.CAL_IS_READONLY;
         if (aItem.id == null && aItem.isMutable)
-            aItem.id = getUUID();
+            aItem.id = cal.getUUID();
 
         if (aItem.id == null) {
             this.notifyOperationComplete(aListener,
                                          Components.results.NS_ERROR_FAILURE,
                                          Components.interfaces.calIOperationListener.ADD,
                                          aItem.id,
                                          "Can't set ID on non-mutable item to addItem");
             return;
@@ -505,9 +505,9 @@ calMemoryCalendar.prototype = {
                                                    out_ids,
                                                    out_values) {
         this.mMetaData.getAllProperties(out_ids, out_values);
         out_count.value = out_ids.value.length;
     }
 };
 
 /** Module Registration */
-var NSGetModule = XPCOMUtils.generateNSGetModule([calMemoryCalendar]);
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([calMemoryCalendar]);
new file mode 100644
--- /dev/null
+++ b/calendar/providers/memory/calMemoryCalendar.manifest
@@ -0,0 +1,2 @@
+component {bda0dd7f-0a2f-4fcf-ba08-5517e6fbf133} calMemoryCalendar.js
+contract @mozilla.org/calendar/calendar;1?type=memory {bda0dd7f-0a2f-4fcf-ba08-5517e6fbf133}
--- a/calendar/providers/storage/Makefile.in
+++ b/calendar/providers/storage/Makefile.in
@@ -39,15 +39,19 @@ DEPTH		= ../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE = calStorageCalendar
 
-EXTRA_COMPONENTS = calStorageCalendar.js
+EXTRA_COMPONENTS = \
+    calStorageCalendar.js \
+    calStorageCalendar.manifest \
+    $(NULL)
+
 EXTRA_JS_MODULES = \
     calStorageHelpers.jsm \
     calStorageUpgrade.jsm \
     $(NULL)
 
 include $(topsrcdir)/config/rules.mk
--- a/calendar/providers/storage/calStorageCalendar.js
+++ b/calendar/providers/storage/calStorageCalendar.js
@@ -2369,20 +2369,20 @@ calStorageCalendar.prototype = {
     }
 };
 
 /** Module Registration */
 const scriptLoadOrder = [
     "calUtils.js",
 ];
 
-function NSGetModule(cid) {
+function NSGetFactory(cid) {
     if (!this.scriptsLoaded) {
         Services.io.getProtocolHandler("resource")
                 .QueryInterface(Components.interfaces.nsIResProtocolHandler)
                 .setSubstitution("calendar", Services.io.newFileURI(__LOCATION__.parent.parent));
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
         cal.loadScripts(scriptLoadOrder, Components.utils.getGlobalForObject(this));
         this.scriptsLoaded = true;
     }
 
-    return (XPCOMUtils.generateNSGetModule([calStorageCalendar]))(cid);
+    return (XPCOMUtils.generateNSGetFactory([calStorageCalendar]))(cid);
 }
new file mode 100644
--- /dev/null
+++ b/calendar/providers/storage/calStorageCalendar.manifest
@@ -0,0 +1,2 @@
+component {b3eaa1c4-5dfe-4c0a-b62a-b3a514218461} calStorageCalendar.js
+contract @mozilla.org/calendar/calendar;1?type=storage {b3eaa1c4-5dfe-4c0a-b62a-b3a514218461}
--- a/calendar/providers/wcap/Makefile.in
+++ b/calendar/providers/wcap/Makefile.in
@@ -52,23 +52,23 @@ EXTRA_SCRIPTS = \
                 calWcapErrors.js \
                 calWcapSession.js \
                 calWcapCalendarItems.js \
                 calWcapCalendar.js \
                 $(NULL)
 
 EXTRA_COMPONENTS = \
                 calWcapCalendarModule.js \
+                calWcapCalendarModule.manifest \
                 $(NULL)
 
 # installing EXTRA_SCRIPTS into js/
 
 # using NSINSTALL to make directory: no mtime to preserve:
 libs:: $(EXTRA_SCRIPTS)
 	if test ! -d $(FINAL_TARGET)/calendar-js; then $(NSINSTALL) -D $(FINAL_TARGET)/calendar-js; fi
 	$(INSTALL) $^ $(FINAL_TARGET)/calendar-js
 
 # using SYSINSTALL (i.e. NSINSTALL in copy mode):
 install:: $(EXTRA_SCRIPTS)
 	$(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/calendar-js
 
 include $(topsrcdir)/config/rules.mk
-
--- a/calendar/providers/wcap/calWcapCalendarModule.js
+++ b/calendar/providers/wcap/calWcapCalendarModule.js
@@ -78,17 +78,17 @@ var LOG_LEVEL = 0;
 function initWcapProvider() {
     try {        
         initLogging();
 
         // some string resources:
         g_privateItemTitle = calGetString("wcap", "privateItem.title.text");
         g_confidentialItemTitle = calGetString("wcap", "confidentialItem.title.text");
         g_busyItemTitle = calGetString("wcap", "busyItem.title.text");
-        g_busyPhantomItemUuidPrefix = ("PHANTOM_uuid_" + getUUID());
+        g_busyPhantomItemUuidPrefix = ("PHANTOM_uuid_" + cal.getUUID());
 
         CACHE_LAST_RESULTS = getPref("calendar.wcap.cache_last_results", 4);
         CACHE_LAST_RESULTS_INVALIDATE = getPref("calendar.wcap.cache_last_results_invalidate", 120);
     } catch (exc) {
         logError(exc, "error in init sequence");
     }
 }
 
@@ -98,17 +98,17 @@ const scriptLoadOrder = [
     "calWcapUtils.js",
     "calWcapErrors.js",
     "calWcapRequest.js",
     "calWcapSession.js",
     "calWcapCalendar.js",
     "calWcapCalendarItems.js"
 ];
 
-function NSGetModule(cid) {
+function NSGetFactory(cid) {
     try {
     if (!this.scriptsLoaded) {
         Services.io.getProtocolHandler("resource")
                 .QueryInterface(Components.interfaces.nsIResProtocolHandler)
                 .setSubstitution("calendar", Services.io.newFileURI(__LOCATION__.parent.parent));
         Components.utils.import("resource://calendar/modules/calUtils.jsm");
         cal.loadScripts(scriptLoadOrder, Components.utils.getGlobalForObject(this));
         initWcapProvider();
@@ -117,14 +117,14 @@ function NSGetModule(cid) {
     }
 
     let components = [
         calWcapCalendar,
         calWcapNetworkRequest,
         calWcapSession
     ];
 
-    return (XPCOMUtils.generateNSGetModule(components))(cid);
+    return (XPCOMUtils.generateNSGetFactory(components))(cid);
 
     } catch (e) {
         cal.WARN("ERROR: " + e);
     }
 }
new file mode 100644
--- /dev/null
+++ b/calendar/providers/wcap/calWcapCalendarModule.manifest
@@ -0,0 +1,8 @@
+component {cf4d93e5-af79-451a-95f3-109055b32ef0} calWcapCalendarModule.js
+contract @mozilla.org/calendar/calendar;1?type=wcap {cf4d93e5-af79-451a-95f3-109055b32ef0}
+
+component {cbf803fd-4469-4999-ae39-367af1c7b077} calWcapCalendarModule.js
+contract @mozilla.org/calendar/wcap/session;1 {cbf803fd-4469-4999-ae39-367af1c7b077}
+
+component {e3c62b37-83cf-41ec-9872-0af9f952430a} calWcapCalendarModule.js
+contract @mozilla.org/calendar/wcap/network-request;1 {e3c62b37-83cf-41ec-9872-0af9f952430a}
--- a/calendar/providers/wcap/calWcapRequest.js
+++ b/calendar/providers/wcap/calWcapRequest.js
@@ -48,17 +48,17 @@
    The request function itself may return either
    - a further calIOperation request object, i.e. an async continuation
    - some data (incl null/undefined) which is the result of the async function,
      indicating that there is no further continuation
 */
 
 function generateRequestId() {
     if (!generateRequestId.mRequestPrefix) {
-        generateRequestId.mRequestPrefix = (getUUID() + "-");
+        generateRequestId.mRequestPrefix = (cal.getUUID() + "-");
         generateRequestId.mRequestId = 0;
     }
     ++generateRequestId.mRequestId;
     return (generateRequestId.mRequestPrefix + generateRequestId.mRequestId);
 }
 
 function calWcapRequest(respFunc, logContext) {
     this.wrappedJSObject = this;
--- a/calendar/providers/wcap/calWcapSession.js
+++ b/calendar/providers/wcap/calWcapSession.js
@@ -69,17 +69,17 @@ function splitUriParams(uri) {
     return ((qmPos != -1)
             ? [spec.substring(0, qmPos), spec.substring(qmPos)]
             : [spec, ""]);
 }
 
 function getWcapSessionFor(calendar, uri) {
     let contextId = calendar.getProperty("shared_context");
     if (!contextId) {
-        contextId = getUUID();
+        contextId = cal.getUUID();
         calendar.setProperty("shared_context", contextId);
     }
 
     if (!getWcapSessionFor.m_sessions) {
         getWcapSessionFor.m_sessions = {};
     }
     let session = getWcapSessionFor.m_sessions[contextId];