1 |
|
---|
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 XPCOM.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
26 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | ////////////////////////////////////////////////////////////////////////////////
|
---|
39 | // Global Static Component Manager Methods
|
---|
40 | // (for when you need to link with xpcom)
|
---|
41 |
|
---|
42 | #include "nsIComponentManagerObsolete.h"
|
---|
43 | #include "nsComponentManagerObsolete.h"
|
---|
44 |
|
---|
45 |
|
---|
46 | nsresult
|
---|
47 | nsComponentManager::Initialize(void)
|
---|
48 | {
|
---|
49 | return NS_OK;
|
---|
50 | }
|
---|
51 |
|
---|
52 | nsresult
|
---|
53 | nsComponentManager::FindFactory(const nsCID &aClass,
|
---|
54 | nsIFactory **aFactory)
|
---|
55 | {
|
---|
56 | nsIComponentManagerObsolete* cm;
|
---|
57 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
58 | if (NS_FAILED(rv)) return rv;
|
---|
59 | return cm->FindFactory(aClass, aFactory);
|
---|
60 | }
|
---|
61 |
|
---|
62 | nsresult
|
---|
63 | nsComponentManager::GetClassObject(const nsCID &aClass, const nsIID &aIID,
|
---|
64 | void **aResult)
|
---|
65 | {
|
---|
66 | nsIComponentManagerObsolete* cm;
|
---|
67 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
68 | if (NS_FAILED(rv)) return rv;
|
---|
69 | return cm->GetClassObject(aClass, aIID, aResult);
|
---|
70 | }
|
---|
71 |
|
---|
72 | nsresult
|
---|
73 | nsComponentManager::ContractIDToClassID(const char *aContractID,
|
---|
74 | nsCID *aClass)
|
---|
75 | {
|
---|
76 | nsIComponentManagerObsolete* cm;
|
---|
77 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
78 | if (NS_FAILED(rv)) return rv;
|
---|
79 | return cm->ContractIDToClassID(aContractID, aClass);
|
---|
80 | }
|
---|
81 |
|
---|
82 | nsresult
|
---|
83 | nsComponentManager::CLSIDToContractID(nsCID *aClass,
|
---|
84 | char* *aClassName,
|
---|
85 | char* *aContractID)
|
---|
86 | {
|
---|
87 | nsIComponentManagerObsolete* cm;
|
---|
88 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
89 | if (NS_FAILED(rv)) return rv;
|
---|
90 | return cm->CLSIDToContractID(*aClass, aClassName, aContractID);
|
---|
91 | }
|
---|
92 |
|
---|
93 | nsresult
|
---|
94 | nsComponentManager::CreateInstance(const nsCID &aClass,
|
---|
95 | nsISupports *aDelegate,
|
---|
96 | const nsIID &aIID,
|
---|
97 | void **aResult)
|
---|
98 | {
|
---|
99 | nsIComponentManagerObsolete* cm;
|
---|
100 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
101 | if (NS_FAILED(rv)) return rv;
|
---|
102 | return cm->CreateInstance(aClass, aDelegate, aIID, aResult);
|
---|
103 | }
|
---|
104 |
|
---|
105 | nsresult
|
---|
106 | nsComponentManager::CreateInstance(const char *aContractID,
|
---|
107 | nsISupports *aDelegate,
|
---|
108 | const nsIID &aIID,
|
---|
109 | void **aResult)
|
---|
110 | {
|
---|
111 | nsIComponentManagerObsolete* cm;
|
---|
112 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
113 | if (NS_FAILED(rv)) return rv;
|
---|
114 | return cm->CreateInstanceByContractID(aContractID, aDelegate, aIID, aResult);
|
---|
115 | }
|
---|
116 |
|
---|
117 | nsresult
|
---|
118 | nsComponentManager::RegisterFactory(const nsCID &aClass,
|
---|
119 | const char *aClassName,
|
---|
120 | const char *aContractID,
|
---|
121 | nsIFactory *aFactory,
|
---|
122 | PRBool aReplace)
|
---|
123 | {
|
---|
124 | nsIComponentManagerObsolete* cm;
|
---|
125 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
126 | if (NS_FAILED(rv)) return rv;
|
---|
127 | return cm->RegisterFactory(aClass, aClassName, aContractID,
|
---|
128 | aFactory, aReplace);
|
---|
129 | }
|
---|
130 |
|
---|
131 | nsresult
|
---|
132 | nsComponentManager::RegisterComponent(const nsCID &aClass,
|
---|
133 | const char *aClassName,
|
---|
134 | const char *aContractID,
|
---|
135 | const char *aLibraryPersistentDescriptor,
|
---|
136 | PRBool aReplace,
|
---|
137 | PRBool aPersist)
|
---|
138 | {
|
---|
139 | nsIComponentManagerObsolete* cm;
|
---|
140 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
141 | if (NS_FAILED(rv)) return rv;
|
---|
142 | return cm->RegisterComponent(aClass, aClassName, aContractID,
|
---|
143 | aLibraryPersistentDescriptor, aReplace, aPersist);
|
---|
144 | }
|
---|
145 |
|
---|
146 | nsresult
|
---|
147 | nsComponentManager::RegisterComponentSpec(const nsCID &aClass,
|
---|
148 | const char *aClassName,
|
---|
149 | const char *aContractID,
|
---|
150 | nsIFile *aLibrary,
|
---|
151 | PRBool aReplace,
|
---|
152 | PRBool aPersist)
|
---|
153 | {
|
---|
154 | nsIComponentManagerObsolete* cm;
|
---|
155 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
156 | if (NS_FAILED(rv)) return rv;
|
---|
157 | return cm->RegisterComponentSpec(aClass, aClassName, aContractID,
|
---|
158 | aLibrary, aReplace, aPersist);
|
---|
159 | }
|
---|
160 |
|
---|
161 | nsresult
|
---|
162 | nsComponentManager::RegisterComponentLib(const nsCID &aClass,
|
---|
163 | const char *aClassName,
|
---|
164 | const char *aContractID,
|
---|
165 | const char *adllName,
|
---|
166 | PRBool aReplace,
|
---|
167 | PRBool aPersist)
|
---|
168 | {
|
---|
169 | nsIComponentManagerObsolete* cm;
|
---|
170 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
171 | if (NS_FAILED(rv)) return rv;
|
---|
172 | return cm->RegisterComponentLib(aClass, aClassName, aContractID,
|
---|
173 | adllName, aReplace, aPersist);
|
---|
174 | }
|
---|
175 |
|
---|
176 | nsresult
|
---|
177 | nsComponentManager::UnregisterFactory(const nsCID &aClass,
|
---|
178 | nsIFactory *aFactory)
|
---|
179 | {
|
---|
180 | nsIComponentManagerObsolete* cm;
|
---|
181 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
182 | if (NS_FAILED(rv)) return rv;
|
---|
183 | return cm->UnregisterFactory(aClass, aFactory);
|
---|
184 | }
|
---|
185 |
|
---|
186 | nsresult
|
---|
187 | nsComponentManager::UnregisterComponent(const nsCID &aClass,
|
---|
188 | const char *aLibrary)
|
---|
189 | {
|
---|
190 | nsIComponentManagerObsolete* cm;
|
---|
191 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
192 | if (NS_FAILED(rv)) return rv;
|
---|
193 | return cm->UnregisterComponent(aClass, aLibrary);
|
---|
194 | }
|
---|
195 |
|
---|
196 | nsresult
|
---|
197 | nsComponentManager::UnregisterComponentSpec(const nsCID &aClass,
|
---|
198 | nsIFile *aLibrarySpec)
|
---|
199 | {
|
---|
200 | nsIComponentManagerObsolete* cm;
|
---|
201 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
202 | if (NS_FAILED(rv)) return rv;
|
---|
203 | return cm->UnregisterComponentSpec(aClass, aLibrarySpec);
|
---|
204 | }
|
---|
205 |
|
---|
206 | nsresult
|
---|
207 | nsComponentManager::FreeLibraries(void)
|
---|
208 | {
|
---|
209 | nsIComponentManagerObsolete* cm;
|
---|
210 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
211 | if (NS_FAILED(rv)) return rv;
|
---|
212 | return cm->FreeLibraries();
|
---|
213 | }
|
---|
214 |
|
---|
215 | nsresult
|
---|
216 | nsComponentManager::AutoRegister(PRInt32 when, nsIFile *directory)
|
---|
217 | {
|
---|
218 | nsIComponentManagerObsolete* cm;
|
---|
219 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
220 | if (NS_FAILED(rv)) return rv;
|
---|
221 | return cm->AutoRegister(when, directory);
|
---|
222 | }
|
---|
223 |
|
---|
224 | nsresult
|
---|
225 | nsComponentManager::AutoRegisterComponent(PRInt32 when,
|
---|
226 | nsIFile *fullname)
|
---|
227 | {
|
---|
228 | nsIComponentManagerObsolete* cm;
|
---|
229 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
230 | if (NS_FAILED(rv)) return rv;
|
---|
231 | return cm->AutoRegisterComponent(when, fullname);
|
---|
232 | }
|
---|
233 |
|
---|
234 | nsresult
|
---|
235 | nsComponentManager::AutoUnregisterComponent(PRInt32 when,
|
---|
236 | nsIFile *fullname)
|
---|
237 | {
|
---|
238 | nsIComponentManagerObsolete* cm;
|
---|
239 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
240 | if (NS_FAILED(rv)) return rv;
|
---|
241 | return cm->AutoUnregisterComponent(when, fullname);
|
---|
242 | }
|
---|
243 |
|
---|
244 | nsresult
|
---|
245 | nsComponentManager::IsRegistered(const nsCID &aClass,
|
---|
246 | PRBool *aRegistered)
|
---|
247 | {
|
---|
248 | nsIComponentManagerObsolete* cm;
|
---|
249 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
250 | if (NS_FAILED(rv)) return rv;
|
---|
251 | return cm->IsRegistered(aClass, aRegistered);
|
---|
252 | }
|
---|
253 |
|
---|
254 | nsresult
|
---|
255 | nsComponentManager::EnumerateCLSIDs(nsIEnumerator** aEnumerator)
|
---|
256 | {
|
---|
257 | nsIComponentManagerObsolete* cm;
|
---|
258 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
259 | if (NS_FAILED(rv)) return rv;
|
---|
260 | return cm->EnumerateCLSIDs(aEnumerator);
|
---|
261 | }
|
---|
262 |
|
---|
263 | nsresult
|
---|
264 | nsComponentManager::EnumerateContractIDs(nsIEnumerator** aEnumerator)
|
---|
265 | {
|
---|
266 | nsIComponentManagerObsolete* cm;
|
---|
267 | nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
---|
268 | if (NS_FAILED(rv)) return rv;
|
---|
269 | return cm->EnumerateContractIDs(aEnumerator);
|
---|
270 | }
|
---|
271 |
|
---|