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