home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 December / PCWorld_2005-12_cd.bin / komunikace / netscape / nsb-install-8-0.exe / components / smime-service.js < prev    next >
Text File  |  2005-09-26  |  4KB  |  117 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is mozilla.org code.
  13.  * 
  14.  * The Initial Developer of the Original Code is Netscape
  15.  * Communications Corporation.  Portions created by Netscape are
  16.  * Copyright (C) 1999 Netscape Communications Corporation.  All
  17.  * Rights Reserved.
  18.  * 
  19.  * Contributor(s): 
  20.  * Seth Spitzer <sspitzer@netscape.com>
  21.  */
  22.  
  23.  
  24. /* components defined in this file */
  25. const SMIME_EXTENSION_SERVICE_CONTRACTID =
  26.     "@mozilla.org/accountmanager/extension;1?name=smime";
  27. const SMIME_EXTENSION_SERVICE_CID =
  28.     Components.ID("{f2809796-1dd1-11b2-8c1b-8f15f007c699}");
  29.  
  30. /* interafces used in this file */
  31. const nsIMsgAccountManagerExtension  = Components.interfaces.nsIMsgAccountManagerExtension;
  32. const nsICategoryManager = Components.interfaces.nsICategoryManager;
  33. const nsISupports        = Components.interfaces.nsISupports;
  34.  
  35. function SMIMEService()
  36. {}
  37.  
  38. SMIMEService.prototype.name = "smime";
  39. SMIMEService.prototype.chromePackageName = "messenger";
  40. SMIMEService.prototype.showPanel =
  41.  
  42. function (server)
  43.  
  44. {
  45.   // don't show the S/MIME panel for news accounts
  46.   return (server.type != "nntp");
  47. }
  48.  
  49. /* factory for command line handler service (SMIMEService) */
  50. var SMIMEFactory = new Object();
  51.  
  52. SMIMEFactory.createInstance =
  53. function (outer, iid) {
  54.   if (outer != null)
  55.     throw Components.results.NS_ERROR_NO_AGGREGATION;
  56.  
  57.   if (!iid.equals(nsIMsgAccountManagerExtension) && !iid.equals(nsISupports))
  58.     throw Components.results.NS_ERROR_INVALID_ARG;
  59.  
  60.   return new SMIMEService();
  61. }
  62.  
  63.  
  64. var SMIMEModule = new Object();
  65.  
  66. SMIMEModule.registerSelf =
  67. function (compMgr, fileSpec, location, type)
  68. {
  69.   debug("*** Registering smime account manager extension.\n");
  70.   compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  71.   compMgr.registerFactoryLocation(SMIME_EXTENSION_SERVICE_CID,
  72.                                   "SMIME Account Manager Extension Service",
  73.                                   SMIME_EXTENSION_SERVICE_CONTRACTID, 
  74.                                   fileSpec,
  75.                                   location, 
  76.                                   type);
  77.   catman = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
  78.   catman.addCategoryEntry("mailnews-accountmanager-extensions",
  79.                             "smime account manager extension",
  80.                             SMIME_EXTENSION_SERVICE_CONTRACTID, true, true);
  81. }
  82.  
  83. SMIMEModule.unregisterSelf =
  84. function(compMgr, fileSpec, location)
  85. {
  86.   compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
  87.   compMgr.unregisterFactoryLocation(SMIME_EXTENSION_SERVICE_CID, fileSpec);
  88.   catman = Components.classes["@mozilla.org/categorymanager;1"].getService(nsICategoryManager);
  89.   catman.deleteCategoryEntry("mailnews-accountmanager-extensions",
  90.                              SMIME_EXTENSION_SERVICE_CONTRACTID, true);
  91. }
  92.  
  93. SMIMEModule.getClassObject =
  94. function (compMgr, cid, iid) {
  95.   if (cid.equals(SMIME_EXTENSION_SERVICE_CID))
  96.     return SMIMEFactory;
  97.  
  98.  
  99.   if (!iid.equals(Components.interfaces.nsIFactory))
  100.     throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  101.  
  102.   throw Components.results.NS_ERROR_NO_INTERFACE;    
  103. }
  104.  
  105. SMIMEModule.canUnload =
  106. function(compMgr)
  107. {
  108.   return true;
  109. }
  110.  
  111. /* entrypoint */
  112. function NSGetModule(compMgr, fileSpec) {
  113.   return SMIMEModule;
  114. }
  115.  
  116.  
  117.