Bug 588753 - mailContentHandler.js needs updating for component registration changes (opening text files as attachments broken); Initial patch by Nomis101, updated by Standard8. r=bienvenu
authorNomis101 <Nomis101>
Sun, 19 Sep 2010 11:14:00 +0100
changeset 6531 4fb233adeb33a4217796d6ee380436120d760a63
parent 6530 b0a859bb2d89a311bed00070ef19c66e84eea080
child 6532 f4637d5b56ccf2d58519c0db703e7b71253b7f52
push idunknown
push userunknown
push dateunknown
reviewersbienvenu
bugs588753
Bug 588753 - mailContentHandler.js needs updating for component registration changes (opening text files as attachments broken); Initial patch by Nomis101, updated by Standard8. r=bienvenu
mail/components/mailComponents.manifest
mail/components/mailContentHandler.js
--- a/mail/components/mailComponents.manifest
+++ b/mail/components/mailComponents.manifest
@@ -1,7 +1,11 @@
 component {8cc51368-6aa0-43e8-b762-bde9b9fd828c} aboutRights.js
 contract @mozilla.org/network/protocol/about;1?what=rights {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
 
 component {44346520-c5d2-44e5-a1ec-034e04d7fac4} nsMailDefaultHandler.js
 contract @mozilla.org/mail/clh;1 {44346520-c5d2-44e5-a1ec-034e04d7fac4}
 category command-line-handler x-default @mozilla.org/mail/clh;1
 category command-line-validator b-default @mozilla.org/mail/clh;1
+
+component {1c73f03a-b817-4640-b984-18c3478a9ae3} mailContentHandler.js
+contract @mozilla.org/uriloader/content-handler;1?type=text/html {1c73f03a-b817-4640-b984-18c3478a9ae3}
+contract @mozilla.org/uriloader/content-handler;1?type=text/plain {1c73f03a-b817-4640-b984-18c3478a9ae3}
--- a/mail/components/mailContentHandler.js
+++ b/mail/components/mailContentHandler.js
@@ -39,26 +39,30 @@ Components.utils.import("resource://gre/
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 const Cr = Components.results;
 
 // defined in nsIContentHandler.idl.
 const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
 
-const mch_CID = Components.ID("{1c73f03a-b817-4640-b984-18c3478a9ae3}");
-const CONTRACTID_PREFIX = "@mozilla.org/uriloader/content-handler;1?type=";
+function mailContentHandler() {
+}
+mailContentHandler.prototype = {
+  classID: Components.ID("{1c73f03a-b817-4640-b984-18c3478a9ae3}"),
 
-const CONTENT_TYPES =
-  [ "text/html",
-    "text/plain"
-  ];
+  _xpcom_factory: {
+    createInstance: function mch_factory_ci(outer, iid) {
+      if (outer)
+        throw Components.results.NS_ERROR_NO_AGGREGATION;
+      return gMailContentHandler.QueryInterface(iid);
+    }
+  },
 
-var mailContentHandler = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler, Ci.nsIFactory]),
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler]),
 
   openInExternal: function mch_OpenInExternal(uri) {
     Cc["@mozilla.org/uriloader/external-protocol-service;1"]
       .getService(Ci.nsIExternalProtocolService)
       .loadUrl(uri);
   },
 
   // nsIContentHandler
@@ -95,45 +99,11 @@ var mailContentHandler = {
 
     return this.QueryInterface(iid);
   },
 
   lockFactory: function mch_lock(lock) {
     // No-op.
   }
 };
-
-var Module = {
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIModule]),
-
-  getClassObject: function mod_getClassObject(compMgr, cid, iid) {
-    if (cid.equals(mch_CID))
-      return mailContentHandler.QueryInterface(iid);
-
-    throw Components.results.NS_ERROR_NO_INTERFACE;
-  },
-
-  registerSelf: function mod_registerSelf(compMgr, fileSpec, location, type) {
-    var compReg = compMgr.QueryInterface(Ci.nsIComponentRegistrar);
+var gMailContentHandler = new mailContentHandler();
 
-    function registerType(contentType) {
-      compReg.registerFactoryLocation(mch_CID,
-                                      "mailContentHandler",
-                                      CONTRACTID_PREFIX + contentType,
-                                      fileSpec, location, type);
-    }
-
-    CONTENT_TYPES.forEach(registerType);
-  },
-
-  unregisterSelf: function mod_unregisterSelf(compMgr, location, type) {
-    compMgr.QueryInterface(Ci.nsIComponentRegistrar)
-           .unregisterFactoryLocation(mch_CID, location);
-  },
-
-  canUnload: function(compMgr) {
-    return true;
-  }
-};
-
-function NSGetModule(compMgr, fileSpec) {
-  return Module;
-}
+const NSGetFactory = XPCOMUtils.generateNSGetFactory([mailContentHandler]);