2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-07-08 00:18:27 +04:00
|
|
|
|
2008-09-15 16:45:01 +04:00
|
|
|
#include "nsNPAPIPlugin.h"
|
|
|
|
#include "nsNPAPIPluginInstance.h"
|
2000-07-20 01:43:46 +04:00
|
|
|
#include "nsIMemory.h"
|
1999-07-08 00:18:27 +04:00
|
|
|
#include "nsPluginsDir.h"
|
2002-04-13 09:10:30 +04:00
|
|
|
#include "nsPluginsDirUtils.h"
|
2000-07-20 01:43:46 +04:00
|
|
|
#include "prmem.h"
|
2000-10-12 02:33:20 +04:00
|
|
|
#include "prenv.h"
|
2001-08-28 02:14:52 +04:00
|
|
|
#include "prerror.h"
|
|
|
|
#include <sys/stat.h>
|
2003-03-15 04:04:32 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsILocalFile.h"
|
2005-02-07 04:56:03 +03:00
|
|
|
#include "nsIPrefBranch.h"
|
|
|
|
#include "nsIPrefService.h"
|
2000-10-12 02:33:20 +04:00
|
|
|
|
2001-08-28 02:14:52 +04:00
|
|
|
#define LOCAL_PLUGIN_DLL_SUFFIX ".so"
|
2002-05-22 18:54:23 +04:00
|
|
|
#if defined(__hpux)
|
2001-08-28 02:14:52 +04:00
|
|
|
#define DEFAULT_X11_PATH "/usr/lib/X11R6/"
|
|
|
|
#undef LOCAL_PLUGIN_DLL_SUFFIX
|
|
|
|
#define LOCAL_PLUGIN_DLL_SUFFIX ".sl"
|
2002-05-22 18:54:23 +04:00
|
|
|
#define LOCAL_PLUGIN_DLL_ALT_SUFFIX ".so"
|
|
|
|
#elif defined(_AIX)
|
|
|
|
#define DEFAULT_X11_PATH "/usr/lib"
|
|
|
|
#define LOCAL_PLUGIN_DLL_ALT_SUFFIX ".a"
|
2001-08-28 02:14:52 +04:00
|
|
|
#elif defined(SOLARIS)
|
|
|
|
#define DEFAULT_X11_PATH "/usr/openwin/lib/"
|
|
|
|
#elif defined(LINUX)
|
|
|
|
#define DEFAULT_X11_PATH "/usr/X11R6/lib/"
|
2009-04-20 16:36:49 +04:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
#define DEFAULT_X11_PATH "/usr/X11R6/lib"
|
|
|
|
#undef LOCAL_PLUGIN_DLL_SUFFIX
|
|
|
|
#define LOCAL_PLUGIN_DLL_SUFFIX ".dylib"
|
|
|
|
#define LOCAL_PLUGIN_DLL_ALT_SUFFIX ".so"
|
2001-08-28 02:14:52 +04:00
|
|
|
#else
|
|
|
|
#define DEFAULT_X11_PATH ""
|
|
|
|
#endif
|
|
|
|
|
2007-05-01 03:52:44 +04:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
2001-10-03 02:06:08 +04:00
|
|
|
|
2001-08-28 02:14:52 +04:00
|
|
|
#define PLUGIN_MAX_LEN_OF_TMP_ARR 512
|
|
|
|
|
|
|
|
static void DisplayPR_LoadLibraryErrorMessage(const char *libName)
|
|
|
|
{
|
|
|
|
char errorMsg[PLUGIN_MAX_LEN_OF_TMP_ARR] = "Cannot get error from NSPR.";
|
|
|
|
if (PR_GetErrorTextLength() < (int) sizeof(errorMsg))
|
|
|
|
PR_GetErrorText(errorMsg);
|
|
|
|
|
|
|
|
fprintf(stderr, "LoadPlugin: failed to initialize shared library %s [%s]\n",
|
|
|
|
libName, errorMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SearchForSoname(const char* name, char** soname)
|
|
|
|
{
|
|
|
|
if (!(name && soname))
|
|
|
|
return;
|
|
|
|
PRDir *fdDir = PR_OpenDir(DEFAULT_X11_PATH);
|
|
|
|
if (!fdDir)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int n = PL_strlen(name);
|
|
|
|
PRDirEntry *dirEntry;
|
|
|
|
while ((dirEntry = PR_ReadDir(fdDir, PR_SKIP_BOTH))) {
|
|
|
|
if (!PL_strncmp(dirEntry->name, name, n)) {
|
|
|
|
if (dirEntry->name[n] == '.' && dirEntry->name[n+1] && !dirEntry->name[n+2]) {
|
|
|
|
// name.N, wild guess this is what we need
|
|
|
|
char out[PLUGIN_MAX_LEN_OF_TMP_ARR] = DEFAULT_X11_PATH;
|
|
|
|
PL_strcat(out, dirEntry->name);
|
|
|
|
*soname = PL_strdup(out);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PR_CloseDir(fdDir);
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool LoadExtraSharedLib(const char *name, char **soname, bool tryToGetSoname)
|
2001-08-28 02:14:52 +04:00
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool ret = true;
|
2001-08-28 02:14:52 +04:00
|
|
|
PRLibSpec tempSpec;
|
|
|
|
PRLibrary *handle;
|
|
|
|
tempSpec.type = PR_LibSpec_Pathname;
|
|
|
|
tempSpec.value.pathname = name;
|
|
|
|
handle = PR_LoadLibraryWithFlags(tempSpec, PR_LD_NOW|PR_LD_GLOBAL);
|
|
|
|
if (!handle) {
|
2011-09-30 10:02:59 +04:00
|
|
|
ret = false;
|
2001-08-28 02:14:52 +04:00
|
|
|
DisplayPR_LoadLibraryErrorMessage(name);
|
|
|
|
if (tryToGetSoname) {
|
|
|
|
SearchForSoname(name, soname);
|
|
|
|
if (*soname) {
|
2011-09-30 10:02:59 +04:00
|
|
|
ret = LoadExtraSharedLib((const char *) *soname, NULL, false);
|
2001-08-28 02:14:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS 32
|
|
|
|
#define PREF_PLUGINS_SONAME "plugin.soname.list"
|
2003-10-21 08:47:32 +04:00
|
|
|
#if defined(SOLARIS) || defined(HPUX)
|
2002-03-22 23:20:27 +03:00
|
|
|
#define DEFAULT_EXTRA_LIBS_LIST "libXt" LOCAL_PLUGIN_DLL_SUFFIX ":libXext" LOCAL_PLUGIN_DLL_SUFFIX ":libXm" LOCAL_PLUGIN_DLL_SUFFIX
|
|
|
|
#else
|
2001-08-28 02:14:52 +04:00
|
|
|
#define DEFAULT_EXTRA_LIBS_LIST "libXt" LOCAL_PLUGIN_DLL_SUFFIX ":libXext" LOCAL_PLUGIN_DLL_SUFFIX
|
2002-03-22 23:20:27 +03:00
|
|
|
#endif
|
2001-08-28 02:14:52 +04:00
|
|
|
/*
|
|
|
|
this function looks for
|
2002-03-22 23:20:27 +03:00
|
|
|
user_pref("plugin.soname.list", "/usr/X11R6/lib/libXt.so.6:libXext.so");
|
2001-08-28 02:14:52 +04:00
|
|
|
in user's pref.js
|
|
|
|
and loads all libs in specified order
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void LoadExtraSharedLibs()
|
|
|
|
{
|
|
|
|
// check out if user's prefs.js has libs name
|
|
|
|
nsresult res;
|
2005-02-07 04:56:03 +03:00
|
|
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &res));
|
2001-08-28 02:14:52 +04:00
|
|
|
if (NS_SUCCEEDED(res) && (prefs != nsnull)) {
|
|
|
|
char *sonameList = NULL;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool prefSonameListIsSet = true;
|
2009-05-26 12:53:15 +04:00
|
|
|
res = prefs->GetCharPref(PREF_PLUGINS_SONAME, &sonameList);
|
2001-08-28 02:14:52 +04:00
|
|
|
if (!sonameList) {
|
|
|
|
// pref is not set, lets use hardcoded list
|
2011-09-30 10:02:59 +04:00
|
|
|
prefSonameListIsSet = false;
|
2001-11-07 09:24:10 +03:00
|
|
|
sonameList = PL_strdup(DEFAULT_EXTRA_LIBS_LIST);
|
2001-08-28 02:14:52 +04:00
|
|
|
}
|
|
|
|
if (sonameList) {
|
|
|
|
char *arrayOfLibs[PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS] = {0};
|
|
|
|
int numOfLibs = 0;
|
|
|
|
char *nextToken;
|
|
|
|
char *p = nsCRT::strtok(sonameList,":",&nextToken);
|
|
|
|
if (p) {
|
|
|
|
while (p && numOfLibs < PLUGIN_MAX_NUMBER_OF_EXTRA_LIBS) {
|
|
|
|
arrayOfLibs[numOfLibs++] = p;
|
|
|
|
p = nsCRT::strtok(nextToken,":",&nextToken);
|
|
|
|
}
|
|
|
|
} else // there is just one lib
|
|
|
|
arrayOfLibs[numOfLibs++] = sonameList;
|
|
|
|
|
|
|
|
char sonameListToSave[PLUGIN_MAX_LEN_OF_TMP_ARR] = "";
|
|
|
|
for (int i=0; i<numOfLibs; i++) {
|
|
|
|
// trim out head/tail white spaces (just in case)
|
2011-09-29 10:19:26 +04:00
|
|
|
bool head = true;
|
2001-08-28 02:14:52 +04:00
|
|
|
p = arrayOfLibs[i];
|
|
|
|
while (*p) {
|
|
|
|
if (*p == ' ' || *p == '\t') {
|
|
|
|
if (head) {
|
|
|
|
arrayOfLibs[i] = ++p;
|
|
|
|
} else {
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
} else {
|
2011-09-30 10:02:59 +04:00
|
|
|
head = false;
|
2001-08-28 02:14:52 +04:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!arrayOfLibs[i][0]) {
|
|
|
|
continue; // null string
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
bool tryToGetSoname = true;
|
2001-08-28 02:14:52 +04:00
|
|
|
if (PL_strchr(arrayOfLibs[i], '/')) {
|
|
|
|
//assuming it's real name, try to stat it
|
|
|
|
struct stat st;
|
|
|
|
if (stat((const char*) arrayOfLibs[i], &st)) {
|
|
|
|
//get just a file name
|
|
|
|
arrayOfLibs[i] = PL_strrchr(arrayOfLibs[i], '/') + 1;
|
|
|
|
} else
|
2011-09-30 10:02:59 +04:00
|
|
|
tryToGetSoname = false;
|
2001-08-28 02:14:52 +04:00
|
|
|
}
|
|
|
|
char *soname = NULL;
|
|
|
|
if (LoadExtraSharedLib(arrayOfLibs[i], &soname, tryToGetSoname)) {
|
|
|
|
//construct soname's list to save in prefs
|
|
|
|
p = soname ? soname : arrayOfLibs[i];
|
|
|
|
int n = PLUGIN_MAX_LEN_OF_TMP_ARR -
|
|
|
|
(PL_strlen(sonameListToSave) + PL_strlen(p));
|
|
|
|
if (n > 0) {
|
|
|
|
PL_strcat(sonameListToSave, p);
|
|
|
|
PL_strcat(sonameListToSave,":");
|
|
|
|
}
|
|
|
|
if (soname) {
|
|
|
|
PL_strfree(soname); // it's from strdup
|
|
|
|
}
|
|
|
|
if (numOfLibs > 1)
|
|
|
|
arrayOfLibs[i][PL_strlen(arrayOfLibs[i])] = ':'; //restore ":" in sonameList
|
|
|
|
}
|
|
|
|
}
|
2006-04-07 19:44:53 +04:00
|
|
|
|
|
|
|
// Check whether sonameListToSave is a empty String, Bug: 329205
|
|
|
|
if (sonameListToSave[0])
|
|
|
|
for (p = &sonameListToSave[PL_strlen(sonameListToSave) - 1]; *p == ':'; p--)
|
|
|
|
*p = 0; //delete tail ":" delimiters
|
2001-08-28 02:14:52 +04:00
|
|
|
|
|
|
|
if (!prefSonameListIsSet || PL_strcmp(sonameList, sonameListToSave)) {
|
|
|
|
// if user specified some bogus soname I overwrite it here,
|
|
|
|
// otherwise it'll decrease performance by calling popen() in SearchForSoname
|
|
|
|
// every time for each bogus name
|
2009-05-26 12:53:15 +04:00
|
|
|
prefs->SetCharPref(PREF_PLUGINS_SONAME, (const char *)sonameListToSave);
|
2001-08-28 02:14:52 +04:00
|
|
|
}
|
|
|
|
PL_strfree(sonameList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-05-01 03:52:44 +04:00
|
|
|
#endif //MOZ_WIDGET_GTK2
|
2001-08-28 02:14:52 +04:00
|
|
|
|
1999-07-08 00:18:27 +04:00
|
|
|
/* nsPluginsDir implementation */
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsPluginsDir::IsPluginFile(nsIFile* file)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2003-03-15 04:04:32 +03:00
|
|
|
nsCAutoString filename;
|
|
|
|
if (NS_FAILED(file->GetNativeLeafName(filename)))
|
2011-09-30 10:02:59 +04:00
|
|
|
return false;
|
2003-03-15 04:04:32 +03:00
|
|
|
|
2011-09-17 01:34:31 +04:00
|
|
|
#ifdef ANDROID
|
|
|
|
// It appears that if you load
|
|
|
|
// 'libstagefright_honeycomb.so' on froyo, or
|
|
|
|
// 'libstagefright_froyo.so' on honeycomb, we will abort.
|
|
|
|
// Since these are just helper libs, we can ignore.
|
|
|
|
const char *cFile = filename.get();
|
|
|
|
if (strstr(cFile, "libstagefright") != NULL)
|
2011-09-30 10:02:59 +04:00
|
|
|
return false;
|
2011-09-17 01:34:31 +04:00
|
|
|
#endif
|
|
|
|
|
2003-07-14 11:37:39 +04:00
|
|
|
NS_NAMED_LITERAL_CSTRING(dllSuffix, LOCAL_PLUGIN_DLL_SUFFIX);
|
|
|
|
if (filename.Length() > dllSuffix.Length() &&
|
|
|
|
StringEndsWith(filename, dllSuffix))
|
2011-09-30 10:02:59 +04:00
|
|
|
return true;
|
2003-03-15 04:04:32 +03:00
|
|
|
|
2002-05-22 18:54:23 +04:00
|
|
|
#ifdef LOCAL_PLUGIN_DLL_ALT_SUFFIX
|
2003-07-14 11:37:39 +04:00
|
|
|
NS_NAMED_LITERAL_CSTRING(dllAltSuffix, LOCAL_PLUGIN_DLL_ALT_SUFFIX);
|
|
|
|
if (filename.Length() > dllAltSuffix.Length() &&
|
|
|
|
StringEndsWith(filename, dllAltSuffix))
|
2011-09-30 10:02:59 +04:00
|
|
|
return true;
|
2000-10-29 02:17:53 +04:00
|
|
|
#endif
|
2011-09-30 10:02:59 +04:00
|
|
|
return false;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* nsPluginFile implementation */
|
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
nsPluginFile::nsPluginFile(nsIFile* file)
|
|
|
|
: mPlugin(file)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginFile::~nsPluginFile()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-18 04:05:48 +04:00
|
|
|
nsresult nsPluginFile::LoadPlugin(PRLibrary **outLibrary)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2000-04-23 00:50:22 +04:00
|
|
|
PRLibSpec libSpec;
|
2001-08-28 02:14:52 +04:00
|
|
|
libSpec.type = PR_LibSpec_Pathname;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool exists = false;
|
2003-03-15 04:04:32 +03:00
|
|
|
mPlugin->Exists(&exists);
|
|
|
|
if (!exists)
|
|
|
|
return NS_ERROR_FILE_NOT_FOUND;
|
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCAutoString path;
|
|
|
|
rv = mPlugin->GetNativePath(path);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
|
|
|
libSpec.value.pathname = path.get();
|
2001-08-28 02:14:52 +04:00
|
|
|
|
2007-05-01 03:52:44 +04:00
|
|
|
#if defined(MOZ_WIDGET_GTK2)
|
2000-05-13 16:39:16 +04:00
|
|
|
|
|
|
|
// Normally, Mozilla isn't linked against libXt and libXext
|
|
|
|
// since it's a Gtk/Gdk application. On the other hand,
|
|
|
|
// legacy plug-ins expect the libXt and libXext symbols
|
|
|
|
// to already exist in the global name space. This plug-in
|
|
|
|
// wrapper is linked against libXt and libXext, but since
|
|
|
|
// we never call on any of these libraries, plug-ins still
|
|
|
|
// fail to resolve Xt symbols when trying to do a dlopen
|
|
|
|
// at runtime. Explicitly opening Xt/Xext into the global
|
|
|
|
// namespace before attempting to load the plug-in seems to
|
|
|
|
// work fine.
|
2003-10-21 08:47:32 +04:00
|
|
|
|
2003-11-23 00:19:35 +03:00
|
|
|
|
|
|
|
#if defined(SOLARIS) || defined(HPUX)
|
|
|
|
// Acrobat/libXm: Lazy resolving might cause crash later (bug 211587)
|
2010-08-18 04:05:48 +04:00
|
|
|
*outLibrary = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);
|
|
|
|
pLibrary = *outLibrary;
|
2003-11-23 00:19:35 +03:00
|
|
|
#else
|
|
|
|
// Some dlopen() doesn't recover from a failed PR_LD_NOW (bug 223744)
|
2010-08-18 04:05:48 +04:00
|
|
|
*outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
|
|
|
|
pLibrary = *outLibrary;
|
2003-11-23 00:19:35 +03:00
|
|
|
#endif
|
2001-08-28 02:14:52 +04:00
|
|
|
if (!pLibrary) {
|
|
|
|
LoadExtraSharedLibs();
|
2003-09-20 03:37:38 +04:00
|
|
|
// try reload plugin once more
|
2010-08-18 04:05:48 +04:00
|
|
|
*outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
|
|
|
|
pLibrary = *outLibrary;
|
|
|
|
if (!pLibrary) {
|
2001-09-04 03:04:53 +04:00
|
|
|
DisplayPR_LoadLibraryErrorMessage(libSpec.value.pathname);
|
2010-08-18 04:05:48 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-08-28 02:14:52 +04:00
|
|
|
}
|
2003-10-21 08:47:32 +04:00
|
|
|
#else
|
2010-08-18 04:05:48 +04:00
|
|
|
*outLibrary = PR_LoadLibraryWithFlags(libSpec, 0);
|
|
|
|
pLibrary = *outLibrary;
|
2007-05-01 03:52:44 +04:00
|
|
|
#endif // MOZ_WIDGET_GTK2
|
2000-05-13 16:39:16 +04:00
|
|
|
|
2000-10-29 02:17:53 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
printf("LoadPlugin() %s returned %lx\n",
|
2000-04-23 00:50:22 +04:00
|
|
|
libSpec.value.pathname, (unsigned long)pLibrary);
|
2000-10-29 02:17:53 +04:00
|
|
|
#endif
|
2000-04-23 00:50:22 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2010-08-18 04:05:48 +04:00
|
|
|
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info, PRLibrary **outLibrary)
|
1999-07-08 00:18:27 +04:00
|
|
|
{
|
2010-08-18 04:05:48 +04:00
|
|
|
*outLibrary = nsnull;
|
|
|
|
|
2009-07-03 17:53:00 +04:00
|
|
|
info.fVersion = nsnull;
|
2000-07-20 01:43:46 +04:00
|
|
|
|
2010-08-18 04:05:48 +04:00
|
|
|
// Sadly we have to load the library for this to work.
|
|
|
|
nsresult rv = LoadPlugin(outLibrary);
|
2009-07-03 17:53:00 +04:00
|
|
|
if (NS_FAILED(rv))
|
2010-08-18 04:05:48 +04:00
|
|
|
return rv;
|
|
|
|
|
|
|
|
const char* (*npGetPluginVersion)() =
|
|
|
|
(const char* (*)()) PR_FindFunctionSymbol(pLibrary, "NP_GetPluginVersion");
|
|
|
|
if (npGetPluginVersion) {
|
|
|
|
info.fVersion = PL_strdup(npGetPluginVersion());
|
|
|
|
}
|
2010-08-13 10:42:42 +04:00
|
|
|
|
2010-08-18 04:05:48 +04:00
|
|
|
const char* (*npGetMIMEDescription)() =
|
|
|
|
(const char* (*)()) PR_FindFunctionSymbol(pLibrary, "NP_GetMIMEDescription");
|
|
|
|
if (!npGetMIMEDescription) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2010-08-13 10:42:42 +04:00
|
|
|
|
2010-08-18 04:05:48 +04:00
|
|
|
const char* mimedescr = npGetMIMEDescription();
|
|
|
|
if (!mimedescr) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = ParsePluginMimeDescription(mimedescr, info);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCAutoString path;
|
|
|
|
if (NS_FAILED(rv = mPlugin->GetNativePath(path)))
|
|
|
|
return rv;
|
|
|
|
info.fFullPath = PL_strdup(path.get());
|
|
|
|
|
|
|
|
nsCAutoString fileName;
|
|
|
|
if (NS_FAILED(rv = mPlugin->GetNativeLeafName(fileName)))
|
|
|
|
return rv;
|
|
|
|
info.fFileName = PL_strdup(fileName.get());
|
|
|
|
|
|
|
|
NP_GetValueFunc npGetValue = (NP_GetValueFunc)PR_FindFunctionSymbol(pLibrary, "NP_GetValue");
|
|
|
|
if (!npGetValue) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *name = NULL;
|
2012-02-04 16:48:02 +04:00
|
|
|
npGetValue(NULL, NPPVpluginNameString, &name);
|
2010-08-18 04:05:48 +04:00
|
|
|
if (name) {
|
|
|
|
info.fName = PL_strdup(name);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
info.fName = PL_strdup(fileName.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *description = NULL;
|
2012-02-04 16:48:02 +04:00
|
|
|
npGetValue(NULL, NPPVpluginDescriptionString, &description);
|
2010-08-18 04:05:48 +04:00
|
|
|
if (description) {
|
2000-08-03 03:01:35 +04:00
|
|
|
info.fDescription = PL_strdup(description);
|
2000-07-20 01:43:46 +04:00
|
|
|
}
|
2010-08-18 04:05:48 +04:00
|
|
|
else {
|
2010-08-31 04:40:13 +04:00
|
|
|
info.fDescription = PL_strdup("");
|
2010-08-18 04:05:48 +04:00
|
|
|
}
|
|
|
|
|
2000-10-12 02:33:20 +04:00
|
|
|
return NS_OK;
|
1999-07-08 00:18:27 +04:00
|
|
|
}
|
|
|
|
|
2000-04-22 04:04:24 +04:00
|
|
|
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info)
|
|
|
|
{
|
2003-03-15 04:04:32 +03:00
|
|
|
if (info.fName != nsnull)
|
2000-10-12 02:33:20 +04:00
|
|
|
PL_strfree(info.fName);
|
2000-08-03 03:01:35 +04:00
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
if (info.fDescription != nsnull)
|
2000-10-12 02:33:20 +04:00
|
|
|
PL_strfree(info.fDescription);
|
2000-08-03 03:01:35 +04:00
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
for (PRUint32 i = 0; i < info.fVariantCount; i++) {
|
2000-10-12 02:33:20 +04:00
|
|
|
if (info.fMimeTypeArray[i] != nsnull)
|
|
|
|
PL_strfree(info.fMimeTypeArray[i]);
|
2000-08-03 03:01:35 +04:00
|
|
|
|
2000-10-12 02:33:20 +04:00
|
|
|
if (info.fMimeDescriptionArray[i] != nsnull)
|
|
|
|
PL_strfree(info.fMimeDescriptionArray[i]);
|
2000-08-03 03:01:35 +04:00
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
if (info.fExtensionArray[i] != nsnull)
|
2000-10-12 02:33:20 +04:00
|
|
|
PL_strfree(info.fExtensionArray[i]);
|
|
|
|
}
|
|
|
|
|
2000-11-08 06:10:37 +03:00
|
|
|
PR_FREEIF(info.fMimeTypeArray);
|
|
|
|
PR_FREEIF(info.fMimeDescriptionArray);
|
|
|
|
PR_FREEIF(info.fExtensionArray);
|
|
|
|
|
2009-06-11 00:47:49 +04:00
|
|
|
if (info.fFullPath != nsnull)
|
|
|
|
PL_strfree(info.fFullPath);
|
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
if (info.fFileName != nsnull)
|
2001-01-23 03:10:38 +03:00
|
|
|
PL_strfree(info.fFileName);
|
|
|
|
|
2008-07-15 14:50:42 +04:00
|
|
|
if (info.fVersion != nsnull)
|
|
|
|
PL_strfree(info.fVersion);
|
|
|
|
|
2000-10-12 02:33:20 +04:00
|
|
|
return NS_OK;
|
2000-04-22 04:04:24 +04:00
|
|
|
}
|