Alex Musil's long awaited plugin changes.

This commit is contained in:
edburns%acm.org 1999-07-07 00:28:34 +00:00
Родитель 4e75c69eb5
Коммит 86858cc900
12 изменённых файлов: 4440 добавлений и 4156 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,248 +1,249 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef ns4xPlugin_h__
#define ns4xPlugin_h__
#include "nsplugin.h"
#include "prlink.h" // for PRLibrary
#include "npupp.h"
#include "nsPluginHostImpl.h"
////////////////////////////////////////////////////////////////////////
/*
* Use this macro before each exported function
* (between the return address and the function
* itself), to ensure that the function has the
* right calling conventions on Win16.
*/
#define NP_EXPORT
////////////////////////////////////////////////////////////////////////
// XXX These are defined in platform specific FE directories right now :-/
#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS)
typedef NS_CALLBACK_(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
#endif
#ifdef XP_MAC
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
typedef NS_CALLBACK_(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
#endif
class nsIServiceManager;
class nsIAllocator;
////////////////////////////////////////////////////////////////////////
/**
* A 5.0 wrapper for a 4.x style plugin.
*/
class ns4xPlugin : public nsIPlugin
{
public:
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr);
virtual ~ns4xPlugin(void);
NS_DECL_ISUPPORTS
//nsIFactory interface
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//nsIPlugin interface
/**
* Creates a new plugin instance, based on a MIME type. This
* allows different impelementations to be created depending on
* the specified MIME type.
*/
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
const char* aPluginMIMEType,
void **aResult);
NS_IMETHOD
Initialize(void);
NS_IMETHOD
Shutdown(void);
NS_IMETHOD
GetMIMEDescription(const char* *resultingDesc);
NS_IMETHOD
GetValue(nsPluginVariable variable, void *value);
////////////////////////////////////////////////////////////////////
// ns4xPlugin-specific methods
/**
* A static factory method for constructing 4.x plugins. Constructs
* and initializes an ns4xPlugin object, and returns it in
* <b>result</b>.
*/
static nsresult
CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr);
#ifdef XP_MAC
void
SetPluginRefNum(short aRefNum);
#endif
protected:
/**
* Ensures that the static CALLBACKS is properly initialized
*/
static void CheckClassInitialized(void);
////////////////////////////////////////////////////////////////////////
// Static stub functions that are exported to the 4.x plugin as entry
// points via the CALLBACKS variable.
//
static NPError NP_EXPORT
_requestread(NPStream *pstream, NPByteRange *rangeList);
static NPError NP_EXPORT
_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
static NPError NP_EXPORT
_getvalue(NPP npp, NPNVariable variable, void *r_value);
static NPError NP_EXPORT
_setvalue(NPP npp, NPPVariable variable, void *r_value);
static NPError NP_EXPORT
_geturl(NPP npp, const char* relativeURL, const char* target);
static NPError NP_EXPORT
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
static NPError NP_EXPORT
_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
static NPError NP_EXPORT
_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
static int32 NP_EXPORT
_write(NPP npp, NPStream *pstream, int32 len, void *buffer);
static NPError NP_EXPORT
_destroystream(NPP npp, NPStream *pstream, NPError reason);
static void NP_EXPORT
_status(NPP npp, const char *message);
#if 0
static void NP_EXPORT
_registerwindow(NPP npp, void* window);
static void NP_EXPORT
_unregisterwindow(NPP npp, void* window);
static int16 NP_EXPORT
_allocateMenuID(NPP npp, NPBool isSubmenu);
#endif
static void NP_EXPORT
_memfree (void *ptr);
static uint32 NP_EXPORT
_memflush(uint32 size);
static void NP_EXPORT
_reloadplugins(NPBool reloadPages);
static void NP_EXPORT
_invalidaterect(NPP npp, NPRect *invalidRect);
static void NP_EXPORT
_invalidateregion(NPP npp, NPRegion invalidRegion);
static void NP_EXPORT
_forceredraw(NPP npp);
////////////////////////////////////////////////////////////////////////
// Anything that returns a pointer needs to be _HERE_ for 68K Mac to
// work.
//
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
static const char* NP_EXPORT
_useragent(NPP npp);
static void* NP_EXPORT
_memalloc (uint32 size);
static JRIEnv* NP_EXPORT
_getJavaEnv(void);
#if 1
static jref NP_EXPORT
_getJavaPeer(NPP npp);
static java_lang_Class* NP_EXPORT
_getJavaClass(void* handle);
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
#ifdef XP_MAC
short fPluginRefNum;
#endif
/**
* The plugin-side callbacks that the browser calls. One set of
* plugin callbacks for each plugin.
*/
NPPluginFuncs fCallbacks;
NP_PLUGINSHUTDOWN fShutdownEntry;
/**
* The browser-side callbacks that a 4.x-style plugin calls.
*/
static NPNetscapeFuncs CALLBACKS;
static nsIPluginManager *mPluginManager;
static nsIAllocator *mMalloc;
};
#endif // ns4xPlugin_h__
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef ns4xPlugin_h__
#define ns4xPlugin_h__
#include "nsplugin.h"
#include "prlink.h" // for PRLibrary
#include "npupp.h"
#include "nsPluginHostImpl.h"
////////////////////////////////////////////////////////////////////////
/*
* Use this macro before each exported function
* (between the return address and the function
* itself), to ensure that the function has the
* right calling conventions on Win16.
*/
#define NP_EXPORT
////////////////////////////////////////////////////////////////////////
// XXX These are defined in platform specific FE directories right now :-/
#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS)
typedef NS_CALLBACK_(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks,NPPluginFuncs* fCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
#endif
#ifdef XP_MAC
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
typedef NS_CALLBACK_(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
#endif
class nsIServiceManager;
class nsIAllocator;
////////////////////////////////////////////////////////////////////////
/**
* A 5.0 wrapper for a 4.x style plugin.
*/
class ns4xPlugin : public nsIPlugin
{
public:
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr);
virtual ~ns4xPlugin(void);
NS_DECL_ISUPPORTS
//nsIFactory interface
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//nsIPlugin interface
/**
* Creates a new plugin instance, based on a MIME type. This
* allows different impelementations to be created depending on
* the specified MIME type.
*/
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
const char* aPluginMIMEType,
void **aResult);
NS_IMETHOD
Initialize(void);
NS_IMETHOD
Shutdown(void);
NS_IMETHOD
GetMIMEDescription(const char* *resultingDesc);
NS_IMETHOD
GetValue(nsPluginVariable variable, void *value);
////////////////////////////////////////////////////////////////////
// ns4xPlugin-specific methods
/**
* A static factory method for constructing 4.x plugins. Constructs
* and initializes an ns4xPlugin object, and returns it in
* <b>result</b>.
*/
static nsresult
CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr);
#ifdef XP_MAC
void
SetPluginRefNum(short aRefNum);
#endif
protected:
/**
* Ensures that the static CALLBACKS is properly initialized
*/
static void CheckClassInitialized(void);
////////////////////////////////////////////////////////////////////////
// Static stub functions that are exported to the 4.x plugin as entry
// points via the CALLBACKS variable.
//
static NPError NP_EXPORT
_requestread(NPStream *pstream, NPByteRange *rangeList);
static NPError NP_EXPORT
_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
static NPError NP_EXPORT
_getvalue(NPP npp, NPNVariable variable, void *r_value);
static NPError NP_EXPORT
_setvalue(NPP npp, NPPVariable variable, void *r_value);
static NPError NP_EXPORT
_geturl(NPP npp, const char* relativeURL, const char* target);
static NPError NP_EXPORT
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
static NPError NP_EXPORT
_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
static NPError NP_EXPORT
_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
static int32 NP_EXPORT
_write(NPP npp, NPStream *pstream, int32 len, void *buffer);
static NPError NP_EXPORT
_destroystream(NPP npp, NPStream *pstream, NPError reason);
static void NP_EXPORT
_status(NPP npp, const char *message);
#if 0
static void NP_EXPORT
_registerwindow(NPP npp, void* window);
static void NP_EXPORT
_unregisterwindow(NPP npp, void* window);
static int16 NP_EXPORT
_allocateMenuID(NPP npp, NPBool isSubmenu);
#endif
static void NP_EXPORT
_memfree (void *ptr);
static uint32 NP_EXPORT
_memflush(uint32 size);
static void NP_EXPORT
_reloadplugins(NPBool reloadPages);
static void NP_EXPORT
_invalidaterect(NPP npp, NPRect *invalidRect);
static void NP_EXPORT
_invalidateregion(NPP npp, NPRegion invalidRegion);
static void NP_EXPORT
_forceredraw(NPP npp);
////////////////////////////////////////////////////////////////////////
// Anything that returns a pointer needs to be _HERE_ for 68K Mac to
// work.
//
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
static const char* NP_EXPORT
_useragent(NPP npp);
static void* NP_EXPORT
_memalloc (uint32 size);
static JRIEnv* NP_EXPORT
_getJavaEnv(void);
#if 1
static jref NP_EXPORT
_getJavaPeer(NPP npp);
static java_lang_Class* NP_EXPORT
_getJavaClass(void* handle);
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
#ifdef XP_MAC
short fPluginRefNum;
#endif
/**
* The plugin-side callbacks that the browser calls. One set of
* plugin callbacks for each plugin.
*/
NPPluginFuncs fCallbacks;
NP_PLUGINSHUTDOWN fShutdownEntry;
/**
* The browser-side callbacks that a 4.x-style plugin calls.
*/
static NPNetscapeFuncs CALLBACKS;
static nsIPluginManager *mPluginManager;
static nsIAllocator *mMalloc;
};
#endif // ns4xPlugin_h__

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1592,8 +1592,16 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbededPlugin(const char *aMimeType,
nsresult rv;
nsIPluginInstance *instance = nsnull;
#ifdef NS_DEBUG
printf("InstantiateEmbededPlugin for %s\n",aMimeType);
#endif
if(FindStoppedPluginForURL(aURL, aOwner) == NS_OK)
{
#ifdef NS_DEBUG
printf("InstantiateEmbededPlugin find stopped\n");
#endif
aOwner->GetInstance(instance);
if(!aMimeType || PL_strcasecmp(aMimeType, "application/x-java-vm"))
rv = NewEmbededPluginStream(aURL, nsnull, instance);
@ -1642,6 +1650,9 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbededPlugin(const char *aMimeType,
}
}
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin.. returning\n");
#endif
return rv;
}
@ -1654,6 +1665,10 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
nsresult rv;
nsIURI *url;
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin for %s\n",aMimeType);
#endif
//create a URL so that the instantiator can do file ext.
//based plugin lookups...
#ifndef NECKO
@ -1667,6 +1682,10 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
if(FindStoppedPluginForURL(url, aOwner) == NS_OK)
{
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin, got a stopped plugin\n");
#endif
nsIPluginInstance* instance;
aOwner->GetInstance(instance);
if(!aMimeType || PL_strcasecmp(aMimeType, "application/x-java-vm"))
@ -1683,6 +1702,9 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
nsIPluginInstance *instance = nsnull;
nsPluginWindow *window = nsnull;
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin, got it... now stream\n");
#endif
//we got a plugin built, now stream
aOwner->GetInstance(instance);

Просмотреть файл

@ -1,89 +1,90 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsPluginsDir_h___
#define nsPluginsDir_h___
#include "nsError.h"
#include "nsFileSpec.h"
/**
* Provides a cross-platform way to obtain the location of the plugins
* directory. Once constructed, can be used with nsDirectoryIterator to
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
* nsFileSpec returned by the iterator.
*/
class nsPluginsDir : public nsFileSpec {
public:
/**
* Locates the plugins directory in a platform-dependent manner.
*/
nsPluginsDir();
virtual ~nsPluginsDir();
/**
* Determines whether or not the given file is actually a plugin file.
*/
PRBool IsPluginFile(const nsFileSpec& fileSpec);
};
struct PRLibrary;
struct nsPluginInfo {
PRUint32 fPluginInfoSize; // indicates how large the structure is currently.
char* fName; // name of the plugin
char* fDescription; // etc.
char* fMimeType;
char* fMimeDescription;
char* fExtensions;
PRUint32 fVariantCount;
char** fMimeTypeArray;
char** fMimeDescriptionArray;
char** fExtensionArray;
char* fFileName;
};
/**
* Provides cross-platform access to a plugin file. Deals with reading
* properties from the plugin file, and loading the plugin's shared
* library. Insulates core nsIPluginHost implementations from these
* details.
*/
class nsPluginFile : public nsFileSpec {
public:
/**
* If spec corresponds to a valid plugin file, constructs a reference
* to a plugin file on disk. Plugins are typically located using the
* nsPluginsDir class.
*/
nsPluginFile(const nsFileSpec& spec);
virtual ~nsPluginFile();
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult LoadPlugin(PRLibrary* &outLibrary);
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult GetPluginInfo(nsPluginInfo &outPluginInfo);
};
#endif /* nsPluginsDir_h___ */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsPluginsDir_h___
#define nsPluginsDir_h___
#include "nsError.h"
#include "nsFileSpec.h"
/**
* Provides a cross-platform way to obtain the location of the plugins
* directory. Once constructed, can be used with nsDirectoryIterator to
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
* nsFileSpec returned by the iterator.
*/
class nsPluginsDir : public nsFileSpec {
public:
/**
* Locates the plugins directory in a platform-dependent manner.
*/
nsPluginsDir();
virtual ~nsPluginsDir();
/**
* Determines whether or not the given file is actually a plugin file.
*/
PRBool IsPluginFile(const nsFileSpec& fileSpec);
};
struct PRLibrary;
struct nsPluginInfo {
PRUint32 fPluginInfoSize; // indicates how large the structure is currently.
char* fName; // name of the plugin
char* fDescription; // etc.
char* fMimeType;
char* fMimeDescription;
char* fExtensions;
PRUint32 fVariantCount;
char** fMimeTypeArray;
char** fMimeDescriptionArray;
char** fExtensionArray;
char* fFileName;
};
/**
* Provides cross-platform access to a plugin file. Deals with reading
* properties from the plugin file, and loading the plugin's shared
* library. Insulates core nsIPluginHost implementations from these
* details.
*/
class nsPluginFile : public nsFileSpec {
PRLibrary* pLibrary;
public:
/**
* If spec corresponds to a valid plugin file, constructs a reference
* to a plugin file on disk. Plugins are typically located using the
* nsPluginsDir class.
*/
nsPluginFile(const nsFileSpec& spec);
virtual ~nsPluginFile();
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult LoadPlugin(PRLibrary* &outLibrary);
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult GetPluginInfo(nsPluginInfo &outPluginInfo);
};
#endif /* nsPluginsDir_h___ */

Просмотреть файл

@ -1,175 +1,247 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
nsPluginsDirUNIX.cpp
Windows implementation of the nsPluginsDir/nsPluginsFile classes.
by Alex Musil
*/
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsSpecialSystemDirectory.h"
/* Local helper functions */
static char* GetFileName(const char* pathname)
{
const char* filename = nsnull;
// this is most likely a path, so skip to the filename
filename = PL_strrchr(pathname, '/');
if(filename)
++filename;
else
filename = pathname;
return PL_strdup(filename);
}
static PRUint32 CalculateVariantCount(char* mimeTypes)
{
PRUint32 variants = 0;
char* index = mimeTypes;
while (*index)
{
if (*index == '|')
variants++;
++index;
}
return variants;
}
static char** MakeStringArray(PRUint32 variants, char* data)
{
char** buffer = NULL;
char* index = data;
PRUint32 count = 0;
buffer = (char **)PR_Malloc(variants * sizeof(char *));
buffer[count++] = index;
while (*index && count<variants)
{
if (*index == '|')
{
buffer[count++] = index + 1;
*index = 0;
}
++index;
}
return buffer;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginsDir implementation */
nsPluginsDir::nsPluginsDir()
{
// this is somewhat lacking, in that it doesn't fall back to any other directories.
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
// should continue to be) loaded from both <libdir>/plugins and ~/.mozilla/plugins. There
// doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening.
//
// use MOZILLA_FIVE_HOME/plugins
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
sysdir += "plugins";
const char *pluginsDir = sysdir.GetCString(); // native path
if (pluginsDir != NULL)
{
const char* allocPath;
allocPath = PL_strdup(pluginsDir);
*(nsFileSpec*)this = allocPath;
}
}
nsPluginsDir::~nsPluginsDir()
{
// do nothing
}
PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
{
const char* pathname = fileSpec.GetCString();
printf("IsPluginFile(%s)\n", pathname);
return PR_TRUE;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginFile implementation */
nsPluginFile::nsPluginFile(const nsFileSpec& spec)
: nsFileSpec(spec)
{
// nada
}
nsPluginFile::~nsPluginFile()
{
// nada
}
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
const char* path = this->GetCString();
outLibrary = PR_LoadLibrary(path);
return NS_OK;
}
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
#if 0
/*
** XXX this needs to change to probe the plugin for mime types/descriptions/etc.
*/
const char *path = this->GetCString();
info.fName = GetFileName(path);
info.fMimeType = "application/x-java-vm";
info.fMimeDescription = "OJI Plugin";
info.fExtensions = "class";
info.fVariantCount = CalculateVariantCount(info.fMimeType) + 1;
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
#endif
return NS_OK;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
nsPluginsDirUNIX.cpp
UNIX implementation of the nsPluginsDir/nsPluginsFile classes.
by Alex Musil
*/
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsSpecialSystemDirectory.h"
/* Local helper functions */
static char* GetFileName(const char* pathname)
{
const char* filename = nsnull;
// this is most likely a path, so skip to the filename
filename = PL_strrchr(pathname, '/');
if(filename)
++filename;
else
filename = pathname;
return PL_strdup(filename);
}
static PRUint32 CalculateVariantCount(char* mimeTypes)
{
PRUint32 variants = 0;
char* index = mimeTypes;
while (*index)
{
if (*index == ';')
variants++;
++index;
}
return variants;
}
static char** MakeStringArray(PRUint32 variants, char* data)
{
char** buffer = NULL;
char* index = data;
PRUint32 count = 0;
buffer = (char **)PR_Malloc(variants * sizeof(char *));
buffer[count++] = index;
while (*index && count<variants)
{
if (*index == '|')
{
buffer[count++] = index + 1;
*index = 0;
}
++index;
}
return buffer;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginsDir implementation */
nsPluginsDir::nsPluginsDir()
{
// this is somewhat lacking, in that it doesn't fall back to any other directories.
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
// should continue to be) loaded from both <libdir>/plugins and ~/.mozilla/plugins. There
// doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening.
//
// use MOZILLA_FIVE_HOME/plugins
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
sysdir += "plugins";
const char *pluginsDir = sysdir.GetCString(); // native path
if (pluginsDir != NULL)
{
const char* allocPath;
allocPath = PL_strdup(pluginsDir);
*(nsFileSpec*)this = allocPath;
}
}
nsPluginsDir::~nsPluginsDir()
{
// do nothing
}
PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
{
const char* pathname = fileSpec.GetCString();
#ifdef NS_DEBUG
printf("IsPluginFile(%s)\n", pathname);
#endif
return PR_TRUE;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginFile implementation */
nsPluginFile::nsPluginFile(const nsFileSpec& spec)
: nsFileSpec(spec)
{
// nada
}
nsPluginFile::~nsPluginFile()
{
// nada
}
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
const char* path = this->GetCString();
pLibrary = outLibrary = PR_LoadLibrary(path);
#ifdef NS_DEBUG
printf("LoadPlugin() %s returned %lx\n",path,pLibrary);
#endif
return NS_OK;
}
typedef char* (*UNIX_Plugin_GetMIMEDescription)();
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
const char *path = this->GetCString();
char *mimedescr,*mdesc,*start,*nexttoc,*mtype,*exten,*descr;
int i,num;
UNIX_Plugin_GetMIMEDescription procedure = nsnull;
mimedescr="";
if(procedure = (UNIX_Plugin_GetMIMEDescription)PR_FindSymbol(pLibrary,"NP_GetMIMEDescription")) {
mimedescr = procedure();
} else {
#ifdef NS_DEBUG
printf("Cannot get plugin info: no GetMIMEDescription procedure!\n");
#endif
return NS_ERROR_FAILURE;
}
info.fName = GetFileName(path);
#ifdef NS_DEBUG
printf("GetMIMEDescription() %lx returned \"%s\"\n",procedure,mimedescr);
#endif
// copy string
mdesc = (char *)PR_Malloc(strlen(mimedescr)+1);
strcpy(mdesc,mimedescr);
num=CalculateVariantCount(mimedescr)+1;
info.fVariantCount = num;
info.fMimeTypeArray =(char **)PR_Malloc(num * sizeof(char *));
info.fMimeDescriptionArray =(char **)PR_Malloc(num * sizeof(char *));
info.fExtensionArray =(char **)PR_Malloc(num * sizeof(char *));
start=mdesc;
for(i=0;i<num && *start;i++) {
// search start of next token (separator is ';')
if(i+1<num) {
if(nexttoc=PL_strchr(start, ';'))
*nexttoc++=0;
else
nexttoc=start+strlen(start);
} else
nexttoc=start+strlen(start);
// split string into: mime type ':' extensions ':' description
mtype=start;
exten=PL_strchr(start, ':');
if(exten) {
*exten++=0;
descr=PL_strchr(exten, ':');
} else
descr=NULL;
if(descr)
*descr++=0;
#ifdef NS_DEBUG
printf("Registering plugin for: \"%s\",\"%s\",\"%s\"\n", mtype,descr ? descr : "null",exten ? exten : "null");
#endif
if(i==0) {
info.fMimeType = mtype ? mtype : "";
info.fMimeDescription = descr ? descr : "";
info.fExtensions = exten ? exten : "";
}
if(!*mtype && !descr && !exten) {
i--;
info.fVariantCount--;
} else {
info.fMimeTypeArray[i] = mtype ? mtype : "";
info.fMimeDescriptionArray[i] = descr ? descr : "";
info.fExtensionArray[i] = exten ? exten : "";
}
start=nexttoc;
}
return NS_OK;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,248 +1,249 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef ns4xPlugin_h__
#define ns4xPlugin_h__
#include "nsplugin.h"
#include "prlink.h" // for PRLibrary
#include "npupp.h"
#include "nsPluginHostImpl.h"
////////////////////////////////////////////////////////////////////////
/*
* Use this macro before each exported function
* (between the return address and the function
* itself), to ensure that the function has the
* right calling conventions on Win16.
*/
#define NP_EXPORT
////////////////////////////////////////////////////////////////////////
// XXX These are defined in platform specific FE directories right now :-/
#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS)
typedef NS_CALLBACK_(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
#endif
#ifdef XP_MAC
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
typedef NS_CALLBACK_(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
#endif
class nsIServiceManager;
class nsIAllocator;
////////////////////////////////////////////////////////////////////////
/**
* A 5.0 wrapper for a 4.x style plugin.
*/
class ns4xPlugin : public nsIPlugin
{
public:
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr);
virtual ~ns4xPlugin(void);
NS_DECL_ISUPPORTS
//nsIFactory interface
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//nsIPlugin interface
/**
* Creates a new plugin instance, based on a MIME type. This
* allows different impelementations to be created depending on
* the specified MIME type.
*/
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
const char* aPluginMIMEType,
void **aResult);
NS_IMETHOD
Initialize(void);
NS_IMETHOD
Shutdown(void);
NS_IMETHOD
GetMIMEDescription(const char* *resultingDesc);
NS_IMETHOD
GetValue(nsPluginVariable variable, void *value);
////////////////////////////////////////////////////////////////////
// ns4xPlugin-specific methods
/**
* A static factory method for constructing 4.x plugins. Constructs
* and initializes an ns4xPlugin object, and returns it in
* <b>result</b>.
*/
static nsresult
CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr);
#ifdef XP_MAC
void
SetPluginRefNum(short aRefNum);
#endif
protected:
/**
* Ensures that the static CALLBACKS is properly initialized
*/
static void CheckClassInitialized(void);
////////////////////////////////////////////////////////////////////////
// Static stub functions that are exported to the 4.x plugin as entry
// points via the CALLBACKS variable.
//
static NPError NP_EXPORT
_requestread(NPStream *pstream, NPByteRange *rangeList);
static NPError NP_EXPORT
_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
static NPError NP_EXPORT
_getvalue(NPP npp, NPNVariable variable, void *r_value);
static NPError NP_EXPORT
_setvalue(NPP npp, NPPVariable variable, void *r_value);
static NPError NP_EXPORT
_geturl(NPP npp, const char* relativeURL, const char* target);
static NPError NP_EXPORT
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
static NPError NP_EXPORT
_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
static NPError NP_EXPORT
_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
static int32 NP_EXPORT
_write(NPP npp, NPStream *pstream, int32 len, void *buffer);
static NPError NP_EXPORT
_destroystream(NPP npp, NPStream *pstream, NPError reason);
static void NP_EXPORT
_status(NPP npp, const char *message);
#if 0
static void NP_EXPORT
_registerwindow(NPP npp, void* window);
static void NP_EXPORT
_unregisterwindow(NPP npp, void* window);
static int16 NP_EXPORT
_allocateMenuID(NPP npp, NPBool isSubmenu);
#endif
static void NP_EXPORT
_memfree (void *ptr);
static uint32 NP_EXPORT
_memflush(uint32 size);
static void NP_EXPORT
_reloadplugins(NPBool reloadPages);
static void NP_EXPORT
_invalidaterect(NPP npp, NPRect *invalidRect);
static void NP_EXPORT
_invalidateregion(NPP npp, NPRegion invalidRegion);
static void NP_EXPORT
_forceredraw(NPP npp);
////////////////////////////////////////////////////////////////////////
// Anything that returns a pointer needs to be _HERE_ for 68K Mac to
// work.
//
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
static const char* NP_EXPORT
_useragent(NPP npp);
static void* NP_EXPORT
_memalloc (uint32 size);
static JRIEnv* NP_EXPORT
_getJavaEnv(void);
#if 1
static jref NP_EXPORT
_getJavaPeer(NPP npp);
static java_lang_Class* NP_EXPORT
_getJavaClass(void* handle);
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
#ifdef XP_MAC
short fPluginRefNum;
#endif
/**
* The plugin-side callbacks that the browser calls. One set of
* plugin callbacks for each plugin.
*/
NPPluginFuncs fCallbacks;
NP_PLUGINSHUTDOWN fShutdownEntry;
/**
* The browser-side callbacks that a 4.x-style plugin calls.
*/
static NPNetscapeFuncs CALLBACKS;
static nsIPluginManager *mPluginManager;
static nsIAllocator *mMalloc;
};
#endif // ns4xPlugin_h__
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef ns4xPlugin_h__
#define ns4xPlugin_h__
#include "nsplugin.h"
#include "prlink.h" // for PRLibrary
#include "npupp.h"
#include "nsPluginHostImpl.h"
////////////////////////////////////////////////////////////////////////
/*
* Use this macro before each exported function
* (between the return address and the function
* itself), to ensure that the function has the
* right calling conventions on Win16.
*/
#define NP_EXPORT
////////////////////////////////////////////////////////////////////////
// XXX These are defined in platform specific FE directories right now :-/
#if defined(XP_PC) || defined(XP_UNIX) || defined(XP_BEOS)
typedef NS_CALLBACK_(NPError, NP_GETENTRYPOINTS) (NPPluginFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGININIT) (const NPNetscapeFuncs* pCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINUNIXINIT) (const NPNetscapeFuncs* pCallbacks,NPPluginFuncs* fCallbacks);
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
#endif
#ifdef XP_MAC
typedef NS_CALLBACK_(NPError, NP_PLUGINSHUTDOWN) (void);
typedef NS_CALLBACK_(NPError, NP_MAIN) (NPNetscapeFuncs* nCallbacks, NPPluginFuncs* pCallbacks, NPP_ShutdownUPP* unloadUpp);
#endif
class nsIServiceManager;
class nsIAllocator;
////////////////////////////////////////////////////////////////////////
/**
* A 5.0 wrapper for a 4.x style plugin.
*/
class ns4xPlugin : public nsIPlugin
{
public:
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr);
virtual ~ns4xPlugin(void);
NS_DECL_ISUPPORTS
//nsIFactory interface
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
//nsIPlugin interface
/**
* Creates a new plugin instance, based on a MIME type. This
* allows different impelementations to be created depending on
* the specified MIME type.
*/
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
const char* aPluginMIMEType,
void **aResult);
NS_IMETHOD
Initialize(void);
NS_IMETHOD
Shutdown(void);
NS_IMETHOD
GetMIMEDescription(const char* *resultingDesc);
NS_IMETHOD
GetValue(nsPluginVariable variable, void *value);
////////////////////////////////////////////////////////////////////
// ns4xPlugin-specific methods
/**
* A static factory method for constructing 4.x plugins. Constructs
* and initializes an ns4xPlugin object, and returns it in
* <b>result</b>.
*/
static nsresult
CreatePlugin(nsPluginTag* pluginTag, nsIServiceManager* serviceMgr);
#ifdef XP_MAC
void
SetPluginRefNum(short aRefNum);
#endif
protected:
/**
* Ensures that the static CALLBACKS is properly initialized
*/
static void CheckClassInitialized(void);
////////////////////////////////////////////////////////////////////////
// Static stub functions that are exported to the 4.x plugin as entry
// points via the CALLBACKS variable.
//
static NPError NP_EXPORT
_requestread(NPStream *pstream, NPByteRange *rangeList);
static NPError NP_EXPORT
_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
static NPError NP_EXPORT
_getvalue(NPP npp, NPNVariable variable, void *r_value);
static NPError NP_EXPORT
_setvalue(NPP npp, NPPVariable variable, void *r_value);
static NPError NP_EXPORT
_geturl(NPP npp, const char* relativeURL, const char* target);
static NPError NP_EXPORT
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
static NPError NP_EXPORT
_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
static NPError NP_EXPORT
_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream);
static int32 NP_EXPORT
_write(NPP npp, NPStream *pstream, int32 len, void *buffer);
static NPError NP_EXPORT
_destroystream(NPP npp, NPStream *pstream, NPError reason);
static void NP_EXPORT
_status(NPP npp, const char *message);
#if 0
static void NP_EXPORT
_registerwindow(NPP npp, void* window);
static void NP_EXPORT
_unregisterwindow(NPP npp, void* window);
static int16 NP_EXPORT
_allocateMenuID(NPP npp, NPBool isSubmenu);
#endif
static void NP_EXPORT
_memfree (void *ptr);
static uint32 NP_EXPORT
_memflush(uint32 size);
static void NP_EXPORT
_reloadplugins(NPBool reloadPages);
static void NP_EXPORT
_invalidaterect(NPP npp, NPRect *invalidRect);
static void NP_EXPORT
_invalidateregion(NPP npp, NPRegion invalidRegion);
static void NP_EXPORT
_forceredraw(NPP npp);
////////////////////////////////////////////////////////////////////////
// Anything that returns a pointer needs to be _HERE_ for 68K Mac to
// work.
//
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
static const char* NP_EXPORT
_useragent(NPP npp);
static void* NP_EXPORT
_memalloc (uint32 size);
static JRIEnv* NP_EXPORT
_getJavaEnv(void);
#if 1
static jref NP_EXPORT
_getJavaPeer(NPP npp);
static java_lang_Class* NP_EXPORT
_getJavaClass(void* handle);
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
#ifdef XP_MAC
short fPluginRefNum;
#endif
/**
* The plugin-side callbacks that the browser calls. One set of
* plugin callbacks for each plugin.
*/
NPPluginFuncs fCallbacks;
NP_PLUGINSHUTDOWN fShutdownEntry;
/**
* The browser-side callbacks that a 4.x-style plugin calls.
*/
static NPNetscapeFuncs CALLBACKS;
static nsIPluginManager *mPluginManager;
static nsIAllocator *mMalloc;
};
#endif // ns4xPlugin_h__

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1592,8 +1592,16 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbededPlugin(const char *aMimeType,
nsresult rv;
nsIPluginInstance *instance = nsnull;
#ifdef NS_DEBUG
printf("InstantiateEmbededPlugin for %s\n",aMimeType);
#endif
if(FindStoppedPluginForURL(aURL, aOwner) == NS_OK)
{
#ifdef NS_DEBUG
printf("InstantiateEmbededPlugin find stopped\n");
#endif
aOwner->GetInstance(instance);
if(!aMimeType || PL_strcasecmp(aMimeType, "application/x-java-vm"))
rv = NewEmbededPluginStream(aURL, nsnull, instance);
@ -1642,6 +1650,9 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateEmbededPlugin(const char *aMimeType,
}
}
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin.. returning\n");
#endif
return rv;
}
@ -1654,6 +1665,10 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
nsresult rv;
nsIURI *url;
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin for %s\n",aMimeType);
#endif
//create a URL so that the instantiator can do file ext.
//based plugin lookups...
#ifndef NECKO
@ -1667,6 +1682,10 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
if(FindStoppedPluginForURL(url, aOwner) == NS_OK)
{
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin, got a stopped plugin\n");
#endif
nsIPluginInstance* instance;
aOwner->GetInstance(instance);
if(!aMimeType || PL_strcasecmp(aMimeType, "application/x-java-vm"))
@ -1683,6 +1702,9 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
nsIPluginInstance *instance = nsnull;
nsPluginWindow *window = nsnull;
#ifdef NS_DEBUG
printf("InstantiateFullPagePlugin, got it... now stream\n");
#endif
//we got a plugin built, now stream
aOwner->GetInstance(instance);

Просмотреть файл

@ -1,89 +1,90 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsPluginsDir_h___
#define nsPluginsDir_h___
#include "nsError.h"
#include "nsFileSpec.h"
/**
* Provides a cross-platform way to obtain the location of the plugins
* directory. Once constructed, can be used with nsDirectoryIterator to
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
* nsFileSpec returned by the iterator.
*/
class nsPluginsDir : public nsFileSpec {
public:
/**
* Locates the plugins directory in a platform-dependent manner.
*/
nsPluginsDir();
virtual ~nsPluginsDir();
/**
* Determines whether or not the given file is actually a plugin file.
*/
PRBool IsPluginFile(const nsFileSpec& fileSpec);
};
struct PRLibrary;
struct nsPluginInfo {
PRUint32 fPluginInfoSize; // indicates how large the structure is currently.
char* fName; // name of the plugin
char* fDescription; // etc.
char* fMimeType;
char* fMimeDescription;
char* fExtensions;
PRUint32 fVariantCount;
char** fMimeTypeArray;
char** fMimeDescriptionArray;
char** fExtensionArray;
char* fFileName;
};
/**
* Provides cross-platform access to a plugin file. Deals with reading
* properties from the plugin file, and loading the plugin's shared
* library. Insulates core nsIPluginHost implementations from these
* details.
*/
class nsPluginFile : public nsFileSpec {
public:
/**
* If spec corresponds to a valid plugin file, constructs a reference
* to a plugin file on disk. Plugins are typically located using the
* nsPluginsDir class.
*/
nsPluginFile(const nsFileSpec& spec);
virtual ~nsPluginFile();
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult LoadPlugin(PRLibrary* &outLibrary);
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult GetPluginInfo(nsPluginInfo &outPluginInfo);
};
#endif /* nsPluginsDir_h___ */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsPluginsDir_h___
#define nsPluginsDir_h___
#include "nsError.h"
#include "nsFileSpec.h"
/**
* Provides a cross-platform way to obtain the location of the plugins
* directory. Once constructed, can be used with nsDirectoryIterator to
* scan the plugins directory. An nsPluginFileSpec can be constructed from the
* nsFileSpec returned by the iterator.
*/
class nsPluginsDir : public nsFileSpec {
public:
/**
* Locates the plugins directory in a platform-dependent manner.
*/
nsPluginsDir();
virtual ~nsPluginsDir();
/**
* Determines whether or not the given file is actually a plugin file.
*/
PRBool IsPluginFile(const nsFileSpec& fileSpec);
};
struct PRLibrary;
struct nsPluginInfo {
PRUint32 fPluginInfoSize; // indicates how large the structure is currently.
char* fName; // name of the plugin
char* fDescription; // etc.
char* fMimeType;
char* fMimeDescription;
char* fExtensions;
PRUint32 fVariantCount;
char** fMimeTypeArray;
char** fMimeDescriptionArray;
char** fExtensionArray;
char* fFileName;
};
/**
* Provides cross-platform access to a plugin file. Deals with reading
* properties from the plugin file, and loading the plugin's shared
* library. Insulates core nsIPluginHost implementations from these
* details.
*/
class nsPluginFile : public nsFileSpec {
PRLibrary* pLibrary;
public:
/**
* If spec corresponds to a valid plugin file, constructs a reference
* to a plugin file on disk. Plugins are typically located using the
* nsPluginsDir class.
*/
nsPluginFile(const nsFileSpec& spec);
virtual ~nsPluginFile();
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult LoadPlugin(PRLibrary* &outLibrary);
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult GetPluginInfo(nsPluginInfo &outPluginInfo);
};
#endif /* nsPluginsDir_h___ */

Просмотреть файл

@ -1,175 +1,247 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
nsPluginsDirUNIX.cpp
Windows implementation of the nsPluginsDir/nsPluginsFile classes.
by Alex Musil
*/
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsSpecialSystemDirectory.h"
/* Local helper functions */
static char* GetFileName(const char* pathname)
{
const char* filename = nsnull;
// this is most likely a path, so skip to the filename
filename = PL_strrchr(pathname, '/');
if(filename)
++filename;
else
filename = pathname;
return PL_strdup(filename);
}
static PRUint32 CalculateVariantCount(char* mimeTypes)
{
PRUint32 variants = 0;
char* index = mimeTypes;
while (*index)
{
if (*index == '|')
variants++;
++index;
}
return variants;
}
static char** MakeStringArray(PRUint32 variants, char* data)
{
char** buffer = NULL;
char* index = data;
PRUint32 count = 0;
buffer = (char **)PR_Malloc(variants * sizeof(char *));
buffer[count++] = index;
while (*index && count<variants)
{
if (*index == '|')
{
buffer[count++] = index + 1;
*index = 0;
}
++index;
}
return buffer;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginsDir implementation */
nsPluginsDir::nsPluginsDir()
{
// this is somewhat lacking, in that it doesn't fall back to any other directories.
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
// should continue to be) loaded from both <libdir>/plugins and ~/.mozilla/plugins. There
// doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening.
//
// use MOZILLA_FIVE_HOME/plugins
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
sysdir += "plugins";
const char *pluginsDir = sysdir.GetCString(); // native path
if (pluginsDir != NULL)
{
const char* allocPath;
allocPath = PL_strdup(pluginsDir);
*(nsFileSpec*)this = allocPath;
}
}
nsPluginsDir::~nsPluginsDir()
{
// do nothing
}
PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
{
const char* pathname = fileSpec.GetCString();
printf("IsPluginFile(%s)\n", pathname);
return PR_TRUE;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginFile implementation */
nsPluginFile::nsPluginFile(const nsFileSpec& spec)
: nsFileSpec(spec)
{
// nada
}
nsPluginFile::~nsPluginFile()
{
// nada
}
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
const char* path = this->GetCString();
outLibrary = PR_LoadLibrary(path);
return NS_OK;
}
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
#if 0
/*
** XXX this needs to change to probe the plugin for mime types/descriptions/etc.
*/
const char *path = this->GetCString();
info.fName = GetFileName(path);
info.fMimeType = "application/x-java-vm";
info.fMimeDescription = "OJI Plugin";
info.fExtensions = "class";
info.fVariantCount = CalculateVariantCount(info.fMimeType) + 1;
info.fMimeTypeArray = MakeStringArray(info.fVariantCount, info.fMimeType);
info.fMimeDescriptionArray = MakeStringArray(info.fVariantCount, info.fMimeDescription);
info.fExtensionArray = MakeStringArray(info.fVariantCount, info.fExtensions);
#endif
return NS_OK;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
nsPluginsDirUNIX.cpp
UNIX implementation of the nsPluginsDir/nsPluginsFile classes.
by Alex Musil
*/
#include "nsPluginsDir.h"
#include "prlink.h"
#include "plstr.h"
#include "prmem.h"
#include "nsSpecialSystemDirectory.h"
/* Local helper functions */
static char* GetFileName(const char* pathname)
{
const char* filename = nsnull;
// this is most likely a path, so skip to the filename
filename = PL_strrchr(pathname, '/');
if(filename)
++filename;
else
filename = pathname;
return PL_strdup(filename);
}
static PRUint32 CalculateVariantCount(char* mimeTypes)
{
PRUint32 variants = 0;
char* index = mimeTypes;
while (*index)
{
if (*index == ';')
variants++;
++index;
}
return variants;
}
static char** MakeStringArray(PRUint32 variants, char* data)
{
char** buffer = NULL;
char* index = data;
PRUint32 count = 0;
buffer = (char **)PR_Malloc(variants * sizeof(char *));
buffer[count++] = index;
while (*index && count<variants)
{
if (*index == '|')
{
buffer[count++] = index + 1;
*index = 0;
}
++index;
}
return buffer;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginsDir implementation */
nsPluginsDir::nsPluginsDir()
{
// this is somewhat lacking, in that it doesn't fall back to any other directories.
// then again, I'm not sure we should be falling back at all. plugins have been (and probably
// should continue to be) loaded from both <libdir>/plugins and ~/.mozilla/plugins. There
// doesn't seem to be any way to do this in the current nsPluginsDir code, which is disheartening.
//
// use MOZILLA_FIVE_HOME/plugins
nsSpecialSystemDirectory sysdir(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
sysdir += "plugins";
const char *pluginsDir = sysdir.GetCString(); // native path
if (pluginsDir != NULL)
{
const char* allocPath;
allocPath = PL_strdup(pluginsDir);
*(nsFileSpec*)this = allocPath;
}
}
nsPluginsDir::~nsPluginsDir()
{
// do nothing
}
PRBool nsPluginsDir::IsPluginFile(const nsFileSpec& fileSpec)
{
const char* pathname = fileSpec.GetCString();
#ifdef NS_DEBUG
printf("IsPluginFile(%s)\n", pathname);
#endif
return PR_TRUE;
}
///////////////////////////////////////////////////////////////////////////
/* nsPluginFile implementation */
nsPluginFile::nsPluginFile(const nsFileSpec& spec)
: nsFileSpec(spec)
{
// nada
}
nsPluginFile::~nsPluginFile()
{
// nada
}
/**
* Loads the plugin into memory using NSPR's shared-library loading
* mechanism. Handles platform differences in loading shared libraries.
*/
nsresult nsPluginFile::LoadPlugin(PRLibrary* &outLibrary)
{
const char* path = this->GetCString();
pLibrary = outLibrary = PR_LoadLibrary(path);
#ifdef NS_DEBUG
printf("LoadPlugin() %s returned %lx\n",path,pLibrary);
#endif
return NS_OK;
}
typedef char* (*UNIX_Plugin_GetMIMEDescription)();
/**
* Obtains all of the information currently available for this plugin.
*/
nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info)
{
const char *path = this->GetCString();
char *mimedescr,*mdesc,*start,*nexttoc,*mtype,*exten,*descr;
int i,num;
UNIX_Plugin_GetMIMEDescription procedure = nsnull;
mimedescr="";
if(procedure = (UNIX_Plugin_GetMIMEDescription)PR_FindSymbol(pLibrary,"NP_GetMIMEDescription")) {
mimedescr = procedure();
} else {
#ifdef NS_DEBUG
printf("Cannot get plugin info: no GetMIMEDescription procedure!\n");
#endif
return NS_ERROR_FAILURE;
}
info.fName = GetFileName(path);
#ifdef NS_DEBUG
printf("GetMIMEDescription() %lx returned \"%s\"\n",procedure,mimedescr);
#endif
// copy string
mdesc = (char *)PR_Malloc(strlen(mimedescr)+1);
strcpy(mdesc,mimedescr);
num=CalculateVariantCount(mimedescr)+1;
info.fVariantCount = num;
info.fMimeTypeArray =(char **)PR_Malloc(num * sizeof(char *));
info.fMimeDescriptionArray =(char **)PR_Malloc(num * sizeof(char *));
info.fExtensionArray =(char **)PR_Malloc(num * sizeof(char *));
start=mdesc;
for(i=0;i<num && *start;i++) {
// search start of next token (separator is ';')
if(i+1<num) {
if(nexttoc=PL_strchr(start, ';'))
*nexttoc++=0;
else
nexttoc=start+strlen(start);
} else
nexttoc=start+strlen(start);
// split string into: mime type ':' extensions ':' description
mtype=start;
exten=PL_strchr(start, ':');
if(exten) {
*exten++=0;
descr=PL_strchr(exten, ':');
} else
descr=NULL;
if(descr)
*descr++=0;
#ifdef NS_DEBUG
printf("Registering plugin for: \"%s\",\"%s\",\"%s\"\n", mtype,descr ? descr : "null",exten ? exten : "null");
#endif
if(i==0) {
info.fMimeType = mtype ? mtype : "";
info.fMimeDescription = descr ? descr : "";
info.fExtensions = exten ? exten : "";
}
if(!*mtype && !descr && !exten) {
i--;
info.fVariantCount--;
} else {
info.fMimeTypeArray[i] = mtype ? mtype : "";
info.fMimeDescriptionArray[i] = descr ? descr : "";
info.fExtensionArray[i] = exten ? exten : "";
}
start=nexttoc;
}
return NS_OK;
}