52 #include <nsILocalFile.h>
54 #include <nsStringAPI.h>
58 #include <mach-o/dyld.h>
73 #if defined(XP_MACOSX)
76 static const char *CLModuleLib =
"sbIPDDevice_d.dylib";
78 static const char *CLModuleLib =
"sbIPDDevice.dylib";
81 static const char *CLLibList[] =
86 "libgobject-2.0.dylib",
93 static const char *CLModuleLib =
"sbIPDDevice_d.so";
95 static const char *CLModuleLib =
"sbIPDDevice.so";
98 static const char *CLLibList[] =
103 #elif defined(XP_WIN)
106 static const char *CLModuleLib =
"sbIPDDevice_d.dll";
108 static const char *CLModuleLib =
"sbIPDDevice.dll";
111 static const char *CLLibList[] =
116 "libgobject-2.0-0.dll",
122 #error "Unsupported OS."
135 static nsresult
LoadLibrary(nsCOMPtr<nsIFile> aLibDir,
151 nsIFile* aComponentFile,
152 nsIModule** aComponentModule)
157 nsCOMPtr<nsIFile> pLibDir;
158 nsCOMPtr<nsIFile> _pLibDir;
159 rv = aComponentFile->GetParent(getter_AddRefs(pLibDir));
160 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
162 rv = _pLibDir->GetParent(getter_AddRefs(pLibDir));
163 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
164 rv = pLibDir->Append(NS_LITERAL_STRING(
"libraries"));
167 PRUint32 libCount =
sizeof (CLLibList) /
sizeof (CLLibList[0]);
168 for (PRUint32
i = 0;
i < libCount;
i++) {
169 rv =
LoadLibrary(pLibDir, NS_ConvertUTF8toUTF16(CLLibList[
i]));
170 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
174 nsCOMPtr<nsILocalFile> pLibFile;
175 nsCOMPtr<nsIFile> _pLibFile;
176 rv = pLibDir->Clone(getter_AddRefs(_pLibFile));
177 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
178 pLibFile = do_QueryInterface(_pLibFile, &rv);
179 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
180 rv = pLibFile->Append(NS_ConvertUTF8toUTF16(CLModuleLib));
181 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
185 rv = pLibFile->Load(&pLibrary);
186 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
189 nsGetModuleProc getModuleProc = (nsGetModuleProc)
190 PR_FindFunctionSymbol(pLibrary,
191 NS_GET_MODULE_SYMBOL);
192 NS_ENSURE_TRUE(getModuleProc, NS_ERROR_NOT_AVAILABLE);
195 rv = getModuleProc(aComponentManager,
198 NS_ENSURE_SUCCESS(rv, NS_ERROR_NOT_AVAILABLE);
219 nsCOMPtr<nsILocalFile> pLibFile;
220 nsCOMPtr<nsIFile> _pLibFile;
221 rv = aLibDir->Clone(getter_AddRefs(_pLibFile));
222 NS_ENSURE_SUCCESS(rv, rv);
223 pLibFile = do_QueryInterface(_pLibFile, &rv);
224 NS_ENSURE_SUCCESS(rv, rv);
225 rv = pLibFile->Append(aLibPath);
226 NS_ENSURE_SUCCESS(rv, rv);
231 rv = pLibFile->Load(&pLibrary);
232 NS_ENSURE_SUCCESS(rv, rv);
235 rv = pLibFile->GetNativePath(filePath);
236 NS_ENSURE_SUCCESS(rv, rv);
237 NS_ENSURE_TRUE(NSAddImage(filePath.get(),
238 NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME),
239 NS_ERROR_NOT_AVAILABLE);
static nsresult LoadLibrary(nsCOMPtr< nsIFile > aLibDir, nsString aLibPath)
NS_EXPORT nsresult NSGetModule(nsIComponentManager *aComponentManager, nsIFile *aComponentFile, nsIModule **aComponentModule)
_getSelectedPageStyle s i