1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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
15 * The Original Code is XPCOM.
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.
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.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsIServiceManagerObsolete_h___
39 #define nsIServiceManagerObsolete_h___
41 ////////////////////////////////////////////////////////////////////
43 // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
45 // Functions, classes, interfaces and types in this file are
46 // obsolete. Use at your own risk.
47 // Please see nsIServiceManager.idl for the supported interface
48 // to the service manager.
50 ////////////////////////////////////////////////////////////////////
52 #include "nsIComponentManager.h"
59 class nsIServiceManager
;
60 class nsIShutdownListener
;
61 class nsIDirectoryServiceProvider
;
63 class nsServiceManagerObsolete
;
65 #define NS_ISERVICEMANAGER_OBSOLETE_IID \
66 { /* cf0df3b0-3401-11d2-8163-006008119d7a */ \
70 {0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
74 * The nsIServiceManagerObsolete manager is obsolete. Please refer
75 * to nsIServiceManager.
77 class nsIServiceManagerObsolete
: public nsISupports
{
80 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISERVICEMANAGER_OBSOLETE_IID
)
83 * RegisterService may be called explicitly to register a service
84 * with the service manager. If a service is not registered explicitly,
85 * the component manager will be used to create an instance according
86 * to the class ID specified.
89 RegisterService(const nsCID
& aClass
, nsISupports
* aService
) = 0;
92 * Requests a service to be shut down, possibly unloading its DLL.
94 * @returns NS_OK - if shutdown was successful and service was unloaded,
95 * @returns NS_ERROR_SERVICE_NOT_FOUND - if shutdown failed because
96 * the service was not currently loaded
97 * @returns NS_ERROR_SERVICE_IN_USE - if shutdown failed because some
98 * user of the service wouldn't voluntarily release it by using
99 * a shutdown listener.
102 UnregisterService(const nsCID
& aClass
) = 0;
105 GetService(const nsCID
& aClass
, const nsIID
& aIID
,
106 nsISupports
* *result
,
107 nsIShutdownListener
* shutdownListener
= nsnull
) = 0;
109 /* OBSOLETE: use NS_RELEASE(service) instead. */
111 ReleaseService(const nsCID
& aClass
, nsISupports
* service
,
112 nsIShutdownListener
* shutdownListener
= nsnull
) = 0;
114 ////////////////////////////////////////////////////////////////////////////
115 // let's do it again, this time with ContractIDs...
118 RegisterService(const char* aContractID
, nsISupports
* aService
) = 0;
121 UnregisterService(const char* aContractID
) = 0;
124 GetService(const char* aContractID
, const nsIID
& aIID
,
125 nsISupports
* *result
,
126 nsIShutdownListener
* shutdownListener
= nsnull
) = 0;
130 ReleaseService(const char* aContractID
, nsISupports
* service
,
131 nsIShutdownListener
* shutdownListener
= nsnull
) = 0;
135 NS_DEFINE_STATIC_IID_ACCESSOR(nsIServiceManagerObsolete
,
136 NS_ISERVICEMANAGER_OBSOLETE_IID
)
138 // Interface to Global Services
139 class NS_COM nsServiceManager
{
143 RegisterService(const nsCID
& aClass
, nsISupports
* aService
);
146 UnregisterService(const nsCID
& aClass
);
149 GetService(const nsCID
& aClass
, const nsIID
& aIID
,
150 nsISupports
* *result
,
151 nsIShutdownListener
* shutdownListener
= nsnull
);
153 /* OBSOLETE: use NS_RELEASE(service) instead. */
155 ReleaseService(const nsCID
& aClass
, nsISupports
* service
,
156 nsIShutdownListener
* shutdownListener
= nsnull
);
158 ////////////////////////////////////////////////////////////////////////////
159 // let's do it again, this time with ContractIDs...
162 RegisterService(const char* aContractID
, nsISupports
* aService
);
165 UnregisterService(const char* aContractID
);
168 GetService(const char* aContractID
, const nsIID
& aIID
,
169 nsISupports
* *result
,
170 nsIShutdownListener
* shutdownListener
= nsnull
);
172 /* OBSOLETE: use NS_RELEASE(service) instead. */
174 ReleaseService(const char* aContractID
, nsISupports
* service
,
175 nsIShutdownListener
* shutdownListener
= nsnull
);
178 ////////////////////////////////////////////////////////////////////////////
179 // These methods return really nsIServiceManagerObsolete, but they are
180 // statically cast to nsIServiceManager to preserve backwards compatiblity.
181 static nsresult
GetGlobalServiceManager(nsIServiceManager
* *result
);
182 static nsresult
ShutdownGlobalServiceManager(nsIServiceManager
* *result
);
186 #define NS_DECL_NSISERVICEMANAGEROBSOLETE \
187 NS_IMETHOD RegisterService(const nsCID& aClass, nsISupports* aService); \
188 NS_IMETHOD UnregisterService(const nsCID& aClass);\
189 NS_IMETHOD GetService(const nsCID& aClass, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener);\
190 NS_IMETHOD ReleaseService(const nsCID& aClass, nsISupports* service, nsIShutdownListener* shutdownListener);\
191 NS_IMETHOD RegisterService(const char* aContractID, nsISupports* aService);\
192 NS_IMETHOD UnregisterService(const char* aContractID);\
193 NS_IMETHOD GetService(const char* aContractID, const nsIID& aIID, nsISupports* *result, nsIShutdownListener* shutdownListener);\
194 NS_IMETHOD ReleaseService(const char* aContractID, nsISupports* service, nsIShutdownListener* shutdownListener);
196 ////////////////////////////////////////////////////////////////////////////////
198 #define NS_ISHUTDOWNLISTENER_IID \
199 { /* 56decae0-3406-11d2-8163-006008119d7a */ \
203 {0x81, 0x63, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
206 ////////////////////////////////////////////////////////////////////////////////
209 #endif /* nsIServiceManagerObsolete_h___ */