1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
---|
2 | /* vim:set ts=4 sw=4 et cindent: */
|
---|
3 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
4 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
5 | *
|
---|
6 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
7 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
8 | * the License. You may obtain a copy of the License at
|
---|
9 | * http://www.mozilla.org/MPL/
|
---|
10 | *
|
---|
11 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
13 | * for the specific language governing rights and limitations under the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * The Original Code is mozilla.org code.
|
---|
17 | *
|
---|
18 | * The Initial Developer of the Original Code is
|
---|
19 | * Netscape Communications Corporation.
|
---|
20 | * Portions created by the Initial Developer are Copyright (C) 1998
|
---|
21 | * the Initial Developer. All Rights Reserved.
|
---|
22 | *
|
---|
23 | * Contributor(s):
|
---|
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 | #ifndef nsXPComPrivate_h__
|
---|
40 | #define nsXPComPrivate_h__
|
---|
41 |
|
---|
42 | #include "nscore.h"
|
---|
43 | #include "nsXPCOM.h"
|
---|
44 |
|
---|
45 | class nsStringContainer;
|
---|
46 | class nsCStringContainer;
|
---|
47 |
|
---|
48 | #ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
|
---|
49 | #define NS_GetFrozenFunctions VBoxNsxpNS_GetFrozenFunctions
|
---|
50 | #define NS_RegisterXPCOMExitRoutine VBoxNsxpNS_RegisterXPCOMExitRoutine
|
---|
51 | #define NS_UnregisterXPCOMExitRoutine VBoxNsxpNS_UnregisterXPCOMExitRoutine
|
---|
52 | #endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Private Method to register an exit routine. This method
|
---|
56 | * allows you to setup a callback that will be called from
|
---|
57 | * the NS_ShutdownXPCOM function after all services and
|
---|
58 | * components have gone away.
|
---|
59 | *
|
---|
60 | * This API is for the exclusive use of the xpcom glue library.
|
---|
61 | *
|
---|
62 | * Note that these APIs are NOT threadsafe and must be called on the
|
---|
63 | * main thread.
|
---|
64 | *
|
---|
65 | * @status FROZEN
|
---|
66 | * @param exitRoutine pointer to user defined callback function
|
---|
67 | * of type XPCOMExitRoutine.
|
---|
68 | * @param priority higher priorities are called before lower
|
---|
69 | * priorities.
|
---|
70 | *
|
---|
71 | * @return NS_OK for success;
|
---|
72 | * other error codes indicate a failure.
|
---|
73 | *
|
---|
74 | */
|
---|
75 | typedef NS_CALLBACK(XPCOMExitRoutine)(void);
|
---|
76 |
|
---|
77 | extern "C" NS_COM nsresult
|
---|
78 | NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
---|
79 |
|
---|
80 | extern "C" NS_COM nsresult
|
---|
81 | NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine exitRoutine);
|
---|
82 |
|
---|
83 |
|
---|
84 | // PUBLIC
|
---|
85 | typedef nsresult (* InitFunc)(nsIServiceManager* *result, nsIFile* binDirectory, nsIDirectoryServiceProvider* appFileLocationProvider);
|
---|
86 | typedef nsresult (* ShutdownFunc)(nsIServiceManager* servMgr);
|
---|
87 | typedef nsresult (* GetServiceManagerFunc)(nsIServiceManager* *result);
|
---|
88 | typedef nsresult (* GetComponentManagerFunc)(nsIComponentManager* *result);
|
---|
89 | typedef nsresult (* GetComponentRegistrarFunc)(nsIComponentRegistrar* *result);
|
---|
90 | typedef nsresult (* NewLocalFileFunc)(const nsAString &path, PRBool followLinks, nsILocalFile* *result);
|
---|
91 | typedef nsresult (* NewNativeLocalFileFunc)(const nsACString &path, PRBool followLinks, nsILocalFile* *result);
|
---|
92 |
|
---|
93 | typedef nsresult (* GetDebugFunc)(nsIDebug* *result);
|
---|
94 | typedef nsresult (* GetTraceRefcntFunc)(nsITraceRefcnt* *result);
|
---|
95 |
|
---|
96 | typedef nsresult (* StringContainerInitFunc)(nsStringContainer&);
|
---|
97 | typedef void (* StringContainerFinishFunc)(nsStringContainer&);
|
---|
98 | typedef PRUint32 (* StringGetDataFunc)(const nsAString&, const PRUnichar**, PRBool*);
|
---|
99 | typedef PRUnichar* (* StringCloneDataFunc)(const nsAString&);
|
---|
100 | typedef nsresult (* StringSetDataFunc)(nsAString&, const PRUnichar*, PRUint32);
|
---|
101 | typedef nsresult (* StringSetDataRangeFunc)(nsAString&, PRUint32, PRUint32, const PRUnichar*, PRUint32);
|
---|
102 | typedef nsresult (* StringCopyFunc)(nsAString &, const nsAString &);
|
---|
103 |
|
---|
104 | typedef nsresult (* CStringContainerInitFunc)(nsCStringContainer&);
|
---|
105 | typedef void (* CStringContainerFinishFunc)(nsCStringContainer&);
|
---|
106 | typedef PRUint32 (* CStringGetDataFunc)(const nsACString&, const char**, PRBool*);
|
---|
107 | typedef char* (* CStringCloneDataFunc)(const nsACString&);
|
---|
108 | typedef nsresult (* CStringSetDataFunc)(nsACString&, const char*, PRUint32);
|
---|
109 | typedef nsresult (* CStringSetDataRangeFunc)(nsACString&, PRUint32, PRUint32, const char*, PRUint32);
|
---|
110 | typedef nsresult (* CStringCopyFunc)(nsACString &, const nsACString &);
|
---|
111 |
|
---|
112 | typedef nsresult (* CStringToUTF16)(const nsACString &, PRUint32, const nsAString &);
|
---|
113 | typedef nsresult (* UTF16ToCString)(const nsAString &, PRUint32, const nsACString &);
|
---|
114 |
|
---|
115 | // PRIVATE
|
---|
116 | typedef nsresult (* RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine, PRUint32 priority);
|
---|
117 | typedef nsresult (* UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine exitRoutine);
|
---|
118 |
|
---|
119 | typedef struct XPCOMFunctions{
|
---|
120 | PRUint32 version;
|
---|
121 | PRUint32 size;
|
---|
122 |
|
---|
123 | InitFunc init;
|
---|
124 | ShutdownFunc shutdown;
|
---|
125 | GetServiceManagerFunc getServiceManager;
|
---|
126 | GetComponentManagerFunc getComponentManager;
|
---|
127 | GetComponentRegistrarFunc getComponentRegistrar;
|
---|
128 | GetMemoryManagerFunc getMemoryManager;
|
---|
129 | NewLocalFileFunc newLocalFile;
|
---|
130 | NewNativeLocalFileFunc newNativeLocalFile;
|
---|
131 |
|
---|
132 | RegisterXPCOMExitRoutineFunc registerExitRoutine;
|
---|
133 | UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
|
---|
134 |
|
---|
135 | // Added for Mozilla 1.5
|
---|
136 | GetDebugFunc getDebug;
|
---|
137 | GetTraceRefcntFunc getTraceRefcnt;
|
---|
138 |
|
---|
139 | // Added for Mozilla 1.7
|
---|
140 | StringContainerInitFunc stringContainerInit;
|
---|
141 | StringContainerFinishFunc stringContainerFinish;
|
---|
142 | StringGetDataFunc stringGetData;
|
---|
143 | StringSetDataFunc stringSetData;
|
---|
144 | StringSetDataRangeFunc stringSetDataRange;
|
---|
145 | StringCopyFunc stringCopy;
|
---|
146 | CStringContainerInitFunc cstringContainerInit;
|
---|
147 | CStringContainerFinishFunc cstringContainerFinish;
|
---|
148 | CStringGetDataFunc cstringGetData;
|
---|
149 | CStringSetDataFunc cstringSetData;
|
---|
150 | CStringSetDataRangeFunc cstringSetDataRange;
|
---|
151 | CStringCopyFunc cstringCopy;
|
---|
152 | CStringToUTF16 cstringToUTF16;
|
---|
153 | UTF16ToCString utf16ToCString;
|
---|
154 | StringCloneDataFunc stringCloneData;
|
---|
155 | CStringCloneDataFunc cstringCloneData;
|
---|
156 |
|
---|
157 | } XPCOMFunctions;
|
---|
158 |
|
---|
159 | typedef nsresult (PR_CALLBACK *GetFrozenFunctionsFunc)(XPCOMFunctions *entryPoints, const char* libraryPath);
|
---|
160 | extern "C" NS_COM nsresult
|
---|
161 | NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
---|
162 |
|
---|
163 | // think hard before changing this
|
---|
164 | #define XPCOM_GLUE_VERSION 1
|
---|
165 |
|
---|
166 |
|
---|
167 | /* XPCOM Specific Defines
|
---|
168 | *
|
---|
169 | * XPCOM_DLL - name of the loadable xpcom library on disk.
|
---|
170 | * XPCOM_SEARCH_KEY - name of the environment variable that can be
|
---|
171 | * modified to include additional search paths.
|
---|
172 | * GRE_CONF_NAME - Name of the GRE Configuration file
|
---|
173 | */
|
---|
174 |
|
---|
175 | #ifdef XPCOM_DLL_BASE
|
---|
176 | #define XPCOM_DLL XPCOM_DLL_BASE MOZ_DLL_SUFFIX
|
---|
177 | #endif
|
---|
178 |
|
---|
179 | #if defined(XP_WIN32) || defined(XP_OS2)
|
---|
180 |
|
---|
181 | #define XPCOM_SEARCH_KEY "PATH"
|
---|
182 | #define GRE_CONF_NAME "gre.config"
|
---|
183 | #define GRE_WIN_REG_LOC "Software\\mozilla.org\\GRE\\"
|
---|
184 | #ifndef XPCOM_DLL
|
---|
185 | #define XPCOM_DLL "xpcom"MOZ_DLL_SUFFIX
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | #elif defined(XP_BEOS)
|
---|
189 |
|
---|
190 | #define XPCOM_SEARCH_KEY "ADDON_PATH"
|
---|
191 | #define GRE_CONF_NAME ".gre.config"
|
---|
192 | #define GRE_CONF_PATH "/boot/home/config/settings/GRE/gre.conf"
|
---|
193 | #ifndef XPCOM_DLL
|
---|
194 | #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
---|
195 | #endif
|
---|
196 |
|
---|
197 | #else // Unix
|
---|
198 |
|
---|
199 | #ifndef XPCOM_DLL
|
---|
200 | #define XPCOM_DLL "libxpcom"MOZ_DLL_SUFFIX
|
---|
201 | #endif
|
---|
202 |
|
---|
203 | // you have to love apple..
|
---|
204 | #ifdef XP_MACOSX
|
---|
205 | #define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
|
---|
206 | #else
|
---|
207 | #define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
|
---|
208 | #endif
|
---|
209 |
|
---|
210 | #define GRE_CONF_NAME ".gre.config"
|
---|
211 | #define GRE_CONF_PATH "/etc/gre.conf"
|
---|
212 | #define GRE_CONF_DIR "/etc/gre.d/"
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | #if defined(XP_WIN) || defined(XP_OS2)
|
---|
216 | #define XPCOM_FILE_PATH_SEPARATOR "\\"
|
---|
217 | #define XPCOM_ENV_PATH_SEPARATOR ";"
|
---|
218 | #elif defined(XP_UNIX) || defined(XP_BEOS)
|
---|
219 | #define XPCOM_FILE_PATH_SEPARATOR "/"
|
---|
220 | #define XPCOM_ENV_PATH_SEPARATOR ":"
|
---|
221 | #else
|
---|
222 | #error need_to_define_your_file_path_separator_and_illegal_characters
|
---|
223 | #endif
|
---|
224 |
|
---|
225 | #endif
|
---|
226 |
|
---|
227 |
|
---|