Redesigned plugin cache code for StreamAsFile operations. Removed NEW_PLUGIN_STREAM_API ifdefs.

This commit is contained in:
amusil%netscape.com 1999-03-11 22:48:58 +00:00
Родитель 6daa1cc59f
Коммит a170265a54
32 изменённых файлов: 1364 добавлений и 1986 удалений

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

@ -36,10 +36,7 @@
#include "nsplugindefs.h"
#include "nsISupports.h"
#ifdef NEW_PLUGIN_STREAM_API
#include "nsIPluginStreamListener.h"
#endif
#define NS_IPLUGININSTANCE_IID \
{ /* ebe00f40-0199-11d2-815b-006008119d7a */ \
@ -140,7 +137,6 @@ public:
NS_IMETHOD
SetWindow(nsPluginWindow* window) = 0;
#ifdef NEW_PLUGIN_STREAM_API
/**
* Called to tell the plugin that the initial src/data stream is
* ready. Expects the plugin to return a nsIPluginStreamListener.
@ -152,21 +148,6 @@ public:
*/
NS_IMETHOD
NewStream(nsIPluginStreamListener** listener) = 0;
#else
/**
* Called when a new plugin stream must be constructed in order for the plugin
* instance to receive a stream of data from the browser.
*
* (Corresponds to NPP_NewStream.)
*
* @param peer - the plugin stream peer, representing information about the
* incoming stream, and stream-specific callbacks into the browser
* @param result - the resulting plugin stream
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0;
#endif
/**
* Called to instruct the plugin instance to print itself to a printer.
@ -179,24 +160,6 @@ public:
NS_IMETHOD
Print(nsPluginPrint* platformPrint) = 0;
#ifndef NEW_PLUGIN_STREAM_API
/**
* Called to notify the plugin instance that a URL request has been
* completed. (See nsIPluginManager::GetURL and nsIPluginManager::PostURL).
*
* (Corresponds to NPP_URLNotify.)
*
* @param url - the requested URL
* @param target - the target window name
* @param reason - the reason for completion
* @param notifyData - the notify data supplied to GetURL or PostURL
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
URLNotify(const char* url, const char* target,
nsPluginReason reason, void* notifyData) = 0;
#endif
/**
* Returns the value of a variable associated with the plugin instance.
*

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

@ -102,32 +102,6 @@ public:
NS_IMETHOD
UserAgent(const char* *resultingAgentString) = 0;
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
GetURL(nsISupports* pluginInst,
const char* url,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE) = 0;
NS_IMETHOD
PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
PRBool isFile = PR_FALSE,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL) = 0;
#else // !NEW_PLUGIN_STREAM_API
/**
* Fetches a URL.
*
@ -149,10 +123,15 @@ public:
* specify PR_FALSE)
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
GetURL(nsISupports* pluginInst, const char* url, const char* target,
void* notifyData = NULL, const char* altHost = NULL,
const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE) = 0;
GetURL(nsISupports* pluginInst,
const char* url,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE) = 0;
/**
* Posts to a URL with post data and/or post headers.
@ -183,14 +162,20 @@ public:
* are no post headers
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
PostURL(nsISupports* pluginInst, const char* url, const char* target,
PRUint32 postDataLen, const char* postData,
PRBool isFile = PR_FALSE, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
PRBool isFile = PR_FALSE,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0;
#endif // !NEW_PLUGIN_STREAM_API
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL) = 0;
};

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

@ -38,6 +38,9 @@ public:
NS_IMETHOD
GetLastModified(PRUint32* result) = 0;
NS_IMETHOD
GetURL(const char** result) = 0;
NS_IMETHOD
RequestRead(nsByteRange* rangeList) = 0;
};

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

@ -56,7 +56,7 @@ public:
* used to cancel the URL load..
*/
NS_IMETHOD
OnStartBinding(const char* url, nsIPluginStreamInfo* pluginInfo) = 0;
OnStartBinding(nsIPluginStreamInfo* pluginInfo) = 0;
/**
* Notify the client that data is available in the input stream. This
@ -69,11 +69,11 @@ public:
* @return The return value is currently ignored.
*/
NS_IMETHOD
OnDataAvailable(const char* url, nsIInputStream* input,
PRUint32 offset, PRUint32 length, nsIPluginStreamInfo* pluginInfo) = 0;
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) = 0;
NS_IMETHOD
OnFileAvailable(const char* url, const char* fileName) = 0;
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) = 0;
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
@ -86,10 +86,8 @@ public:
* @return The return value is currently ignored.
*/
NS_IMETHOD
OnStopBinding(const char* url, nsresult status, nsIPluginStreamInfo* pluginInfo) = 0;
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status) = 0;
NS_IMETHOD
OnNotify(const char* url, nsresult status) = 0;
NS_IMETHOD
GetStreamType(nsPluginStreamType *result) = 0;

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

@ -79,8 +79,7 @@
#ifndef nsplugins_h___
#define nsplugins_h___
#define NEW_PLUGIN_STREAM_API
#include "nsRepository.h" // for NSGetFactory
#include "nsIComponentManager.h" // for NSGetFactory
////////////////////////////////////////////////////////////////////////////////
@ -114,23 +113,11 @@
*/
#include "nsIPluginInstance.h"
#ifdef NEW_PLUGIN_STREAM_API
/**
* A plugin stream listener ...
*/
#include "nsIPluginStreamListener.h"
#else // !NEW_PLUGIN_STREAM_API
/**
* A plugin stream gets instantiated when a plugin instance receives data from
* the browser.
*/
#include "nsIPluginStream.h"
#endif // !NEW_PLUGIN_STREAM_API
/**
* The nsILiveConnectPlugin interface provides additional operations that a
* plugin must implement if it is to be controlled by JavaScript through
@ -177,32 +164,11 @@
*/
#include "nsIWindowlessPlugInstPeer.h"
#ifdef NEW_PLUGIN_STREAM_API
/**
*
*/
#include "nsIPluginInputStream.h"
#else // !NEW_PLUGIN_STREAM_API
/**
* A plugin stream peer gets create by the browser and associated with each
* plugin stream to represent stream and URL information, and provides
* other callbacks needed by the plugin stream.
*/
#include "nsIPluginStreamPeer.h"
/**
* The nsISeekablePluginStreamPeer provides additional operations for seekable
* plugin streams.
*
* To obtain: QueryInterface on nsIPluginStreamPeer
*/
#include "nsISeekablePluginStreamPeer.h"
#endif // !NEW_PLUGIN_STREAM_API
////////////////////////////////////////////////////////////////////////////////
/**
* <B>Interfaces implemented by the browser (new for 5.0):
@ -236,25 +202,11 @@
*/
//#include "nsILiveConnectPlugInstPeer.h"
#ifdef NEW_PLUGIN_STREAM_API
/**
*
*/
#include "nsIPluginInputStream2.h"
#else // !NEW_PLUGIN_STREAM_API
/**
* The nsIPluginStreamPeer2 interface provides additional plugin stream
* peer features only available in Communicator 5.0.
*
* To obtain: QueryInterface on nsIPluginStreamPeer
*/
#include "nsIPluginStreamPeer2.h"
#endif // !NEW_PLUGIN_STREAM_API
/**
* The nsIPluginTagInfo2 interface provides additional html tag information
* only available in Communicator 5.0.

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

@ -34,8 +34,6 @@
#ifndef nsplugindefs_h___
#define nsplugindefs_h___
#define NEW_PLUGIN_STREAM_API
#ifndef prtypes_h___
#include "prtypes.h"
#endif

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

@ -41,7 +41,6 @@ CPPSRCS = \
ns4xPlugin.cpp \
ns4xPluginInstance.cpp \
nsPluginInstancePeer.cpp \
nsMalloc.cpp \
$(NULL)
REQUIRES = raptor plugin java xpcom netlib libplc21 oji

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

@ -37,10 +37,7 @@ OBJS = \
.\$(OBJDIR)\nsPluginFactory.obj \
.\$(OBJDIR)\ns4xPlugin.obj \
.\$(OBJDIR)\ns4xPluginInstance.obj \
# .\$(OBJDIR)\ns4xPluginStream.obj \
.\$(OBJDIR)\nsPluginInstancePeer.obj \
# .\$(OBJDIR)\nsPluginStreamPeer.obj \
.\$(OBJDIR)\nsMalloc.obj \
$(NULL)
LINCS = \

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

@ -24,6 +24,7 @@
#include "ns4xPluginInstance.h"
#include "nsIServiceManager.h"
#include "nsIAllocator.h"
#include "nsIPluginStreamListener.h"
////////////////////////////////////////////////////////////////////////
@ -87,32 +88,23 @@ static NS_DEFINE_IID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
static NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
#ifndef NEW_PLUGIN_STREAM_API
static NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID);
#endif
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
////////////////////////////////////////////////////////////////////////
#ifdef NEW_PLUGIN_STREAM_API
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr)
#else
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown)
#endif
{
NS_INIT_REFCNT();
memcpy((void*) &fCallbacks, (void*) callbacks, sizeof(fCallbacks));
fShutdownEntry = aShutdown;
#ifdef NEW_PLUGIN_STREAM_API
// set up the connections to the plugin manager
if (nsnull == mPluginManager)
serviceMgr->GetService(kPluginManagerCID, kIPluginManagerIID, (nsISupports**)&mPluginManager);
if (nsnull == mMalloc)
serviceMgr->GetService(kAllocatorCID, kIAllocatorIID, (nsISupports**)&mMalloc);
#endif
}
@ -165,7 +157,8 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
nsresult
ns4xPlugin::CreatePlugin(PRLibrary *library,
nsIPlugin **result, nsIServiceManager* serviceMgr)
nsIPlugin **result,
nsIServiceManager* serviceMgr)
{
CheckClassInitialized();
@ -203,11 +196,7 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
// we must init here because the plugin may call NPN functions
// when we call into the NP_Initialize entry point - NPN functions
// require that mBrowserManager be set up
#ifdef NEW_PLUGIN_STREAM_API
(*result)->Initialize();
#else
(*result)->Initialize(browserInterfaces);
#endif
// the NP_Initialize entry point was misnamed as NP_PluginInit,
// early in plugin project development. Its correct name is
@ -273,30 +262,11 @@ nsresult ns4xPlugin :: LockFactory(PRBool aLock)
return NS_OK;
}
#ifndef NEW_PLUGIN_STREAM_API
nsresult
ns4xPlugin::Initialize(nsISupports* browserInterfaces)
{
nsresult rv = NS_OK;
// set up the connections to the plugin manager
if (nsnull == mPluginManager)
if((rv = browserInterfaces->QueryInterface(kIPluginManagerIID, (void **)&mPluginManager)) != NS_OK)
return rv;
if (nsnull == mMalloc)
if((rv = browserInterfaces->QueryInterface(kIMallocIID, (void **)&mMalloc)) != NS_OK)
return rv;
return rv;
}
#else
nsresult
ns4xPlugin::Initialize(void)
{
return NS_OK;
}
#endif
nsresult
ns4xPlugin::Shutdown(void)
@ -336,101 +306,106 @@ printf("plugin getvalue %d called\n", variable);
// Static callbacks that get routed back through the new C++ API
//
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_geturl(NPP npp, const char* relativeURL, const char* target)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
inst->NewStream(&listener);
return mPluginManager->GetURL(inst, relativeURL, target, listener);
#else
return mPluginManager->GetURL(inst, relativeURL, target);
#endif
if(mPluginManager->GetURL(inst, relativeURL, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_geturlnotify(NPP npp, const char* relativeURL, const char* target,
void* notifyData)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
((ns4xPluginInstance*)inst)->NewNotifyStream(&listener, notifyData);
return mPluginManager->GetURL(inst, relativeURL, target, listener);
#else
return mPluginManager->GetURL(inst, relativeURL, target,
notifyData);
#endif
if(mPluginManager->GetURL(inst, relativeURL, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file,
void* notifyData)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
((ns4xPluginInstance*)inst)->NewNotifyStream(&listener, notifyData);
return mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener);
#else
return mPluginManager->PostURL(inst, relativeURL, target,
len, buf, file, notifyData);
#endif
if(mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
inst->NewStream(&listener);
return mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener);
#else
return mPluginManager->PostURL(inst, relativeURL, target,
len, buf, file);
#endif
if(mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
////////////////////////////////////////////////////////////////////////
@ -449,8 +424,7 @@ public:
ns4xStreamWrapper(nsIOutputStream* stream);
~ns4xStreamWrapper();
nsIOutputStream*
GetStream(void);
void GetStream(nsIOutputStream* &result);
NPStream*
GetNPStream(void) {
@ -464,7 +438,6 @@ ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream)
NS_ASSERTION(stream != NULL, "bad stream");
fStream = stream;
NS_ADDREF(fStream);
memset(&fNPStream, 0, sizeof(fNPStream));
@ -474,41 +447,42 @@ ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream)
ns4xStreamWrapper::~ns4xStreamWrapper(void)
{
fStream->Close();
NS_IF_RELEASE(fStream);
}
nsIOutputStream*
ns4xStreamWrapper::GetStream(void)
{
NS_IF_ADDREF(fStream);
return fStream;
void
ns4xStreamWrapper::GetStream(nsIOutputStream* &result)
{
result = fStream;
NS_IF_ADDREF(fStream);
}
////////////////////////////////////////////////////////////////////////
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_newstream(NPP npp, NPMIMEType type, const char* window, NPStream* *result)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
nsresult error;
nsIOutputStream* stream;
nsIPluginInstancePeer *peer;
if (NS_OK == inst->GetPeer(&peer))
{
if ((error = peer->NewStream((const char*) type, window, &stream)) != NS_OK)
if (peer->NewStream((const char*) type, window, &stream) != NS_OK)
{
NS_RELEASE(peer);
return error;
return NPERR_GENERIC_ERROR;
}
ns4xStreamWrapper* wrapper = new ns4xStreamWrapper(stream);
@ -517,58 +491,83 @@ ns4xPlugin::_newstream(NPP npp, NPMIMEType type, const char* window, NPStream* *
{
NS_RELEASE(peer);
NS_RELEASE(stream);
return NS_ERROR_OUT_OF_MEMORY;
return NPERR_OUT_OF_MEMORY_ERROR;
}
(*result) = wrapper->GetNPStream();
NS_RELEASE(peer);
return error;
return NPERR_NO_ERROR;
}
else
return NS_ERROR_UNEXPECTED;
return NPERR_GENERIC_ERROR;
}
int32 NP_EXPORT
ns4xPlugin::_write(NPP npp, NPStream *pstream, int32 len, void *buffer)
{
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) pstream->ndata;
// negative return indicates failure to the plugin
if(!npp)
return -1;
NS_ASSERTION(wrapper != NULL, "null wrapper");
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) pstream->ndata;
NS_ASSERTION(wrapper != NULL, "null stream");
if (wrapper == NULL)
return 0;
return -1;
nsIOutputStream* stream = wrapper->GetStream();
nsIOutputStream* stream;
wrapper->GetStream(stream);
PRUint32 count = 0;
nsresult rv = stream->Write((char *)buffer, len, &count);
NS_RELEASE(stream);
if(rv != NS_OK)
return -1;
return (int32)count;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_destroystream(NPP npp, NPStream *pstream, NPError reason)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsISupports* stream = (nsISupports*) pstream->ndata;
nsIPluginStreamListener* listener;
// DestroyStream can kill two kinds of streams: NPP derived and
// NPN derived.
// check to see if they're trying to kill a NPP stream
if(stream->QueryInterface(kIPluginStreamListenerIID, (void**)&listener) == NS_OK)
{
// XXX we should try to kill this listener here somehow
NS_RELEASE(listener);
return NPERR_NO_ERROR;
}
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) pstream->ndata;
NS_ASSERTION(wrapper != NULL, "null wrapper");
if (wrapper == NULL)
return 0;
return NPERR_INVALID_PARAM;
// This will release the wrapped nsIOutputStream.
delete wrapper;
return NS_OK;
return NPERR_NO_ERROR;
}
void NP_EXPORT
ns4xPlugin::_status(NPP npp, const char *message)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -588,6 +587,7 @@ ns4xPlugin::_status(NPP npp, const char *message)
void NP_EXPORT
ns4xPlugin::_memfree (void *ptr)
{
if(ptr)
mMalloc->Free(ptr);
}
@ -608,6 +608,9 @@ ns4xPlugin::_reloadplugins(NPBool reloadPages)
void NP_EXPORT
ns4xPlugin::_invalidaterect(NPP npp, NPRect *invalidRect)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -634,6 +637,9 @@ ns4xPlugin::_invalidaterect(NPP npp, NPRect *invalidRect)
void NP_EXPORT
ns4xPlugin::_invalidateregion(NPP npp, NPRegion invalidRegion)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -660,6 +666,9 @@ ns4xPlugin::_invalidateregion(NPP npp, NPRegion invalidRegion)
void NP_EXPORT
ns4xPlugin::_forceredraw(NPP npp)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -682,15 +691,18 @@ ns4xPlugin::_forceredraw(NPP npp)
}
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_getvalue(NPP npp, NPNVariable variable, void *result)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_FAILURE; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstancePeer *peer;
@ -705,18 +717,21 @@ ns4xPlugin::_getvalue(NPP npp, NPNVariable variable, void *result)
return rv;
}
else
return NS_ERROR_UNEXPECTED;
return NPERR_GENERIC_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_FAILURE; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
switch (variable)
{
@ -727,7 +742,7 @@ ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
return inst->SetTransparent(*((NPBool *)result));
default:
return NS_OK;
return NPERR_NO_ERROR;
}
#if 0
@ -748,31 +763,10 @@ ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
#endif
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_requestread(NPStream *pstream, NPByteRange *rangeList)
{
#ifndef NEW_PLUGIN_STREAM_API
nsIPluginStreamPeer* streamPeer = (nsIPluginStreamPeer*) pstream->ndata;
NS_ASSERTION(streamPeer != NULL, "null streampeer");
if (streamPeer == NULL)
return NS_ERROR_FAILURE; // XXX
nsISeekablePluginStreamPeer* seekablePeer = NULL;
if (streamPeer->QueryInterface(kISeekablePluginStreamPeerIID,
(void**)seekablePeer) == NS_OK)
{
nsresult error;
// XXX nsByteRange & NPByteRange are structurally equivalent.
error = seekablePeer->RequestRead((nsByteRange *)rangeList);
NS_RELEASE(seekablePeer);
return error;
}
#endif
return NS_ERROR_UNEXPECTED;
return NPERR_STREAM_NOT_SEEKABLE;
}

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

@ -54,6 +54,7 @@ class nsIAllocator;
class ns4xPlugin : public nsIPlugin
{
public:
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr);
~ns4xPlugin(void);
@ -69,13 +70,8 @@ public:
//nsIPlugin interface
#ifndef NEW_PLUGIN_STREAM_API
NS_IMETHOD
Initialize(nsISupports* browserInterfaces);
#else
NS_IMETHOD
Initialize(void);
#endif
NS_IMETHOD
Shutdown(void);
@ -109,36 +105,36 @@ protected:
// Static stub functions that are exported to the 4.x plugin as entry
// points via the CALLBACKS variable.
//
static nsresult NP_EXPORT
static NPError NP_EXPORT
_requestread(NPStream *pstream, NPByteRange *rangeList);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_getvalue(NPP npp, NPNVariable variable, void *r_value);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_setvalue(NPP npp, NPPVariable variable, void *r_value);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_geturl(NPP npp, const char* relativeURL, const char* target);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
static nsresult NP_EXPORT
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 nsresult NP_EXPORT
static NPError NP_EXPORT
_destroystream(NPP npp, NPStream *pstream, NPError reason);
static void NP_EXPORT

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

@ -17,20 +17,11 @@
*/
#include "ns4xPluginInstance.h"
#ifdef NEW_PLUGIN_STREAM_API
#include "nsIPluginStreamListener.h"
#else
#include "ns4xPluginStream.h"
#endif
#include "prlog.h"
#include "prmem.h"
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
#ifdef NEW_PLUGIN_STREAM_API
class ns4xPluginStreamListener : public nsIPluginStreamListener {
@ -42,24 +33,20 @@ public:
// from nsIPluginStreamListener:
NS_IMETHOD
OnStartBinding(const char* url, nsIPluginStreamInfo* pluginInfo);
OnStartBinding(nsIPluginStreamInfo* pluginInfo);
NS_IMETHOD
OnDataAvailable(const char* url, nsIInputStream* input,
PRUint32 offset, PRUint32 length, nsIPluginStreamInfo* pluginInfo);
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
NS_IMETHOD
OnFileAvailable(const char* url, const char* fileName);
OnFileAvailable( nsIPluginStreamInfo* pluginInfo, const char* fileName);
NS_IMETHOD
OnStopBinding(const char* url, nsresult status, nsIPluginStreamInfo* pluginInfo);
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
NS_IMETHOD
GetStreamType(nsPluginStreamType *result);
NS_IMETHOD
OnNotify(const char* url, nsresult status);
////////////////////////////////////////////////////////////////////////////
// ns4xPluginStreamListener specific methods:
@ -75,6 +62,7 @@ protected:
nsPluginStreamType mStreamType;
};
////////////////////////////////////////////////////////////////////////////////
// ns4xPluginStreamListener Methods
////////////////////////////////////////////////////////////////////////////////
@ -102,16 +90,17 @@ ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
NS_IMPL_ISUPPORTS(ns4xPluginStreamListener, kIPluginStreamListenerIID);
NS_IMETHODIMP
ns4xPluginStreamListener::OnStartBinding(const char* url, nsIPluginStreamInfo* pluginInfo)
ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
{
NPP npp;
const NPPluginFuncs *callbacks;
PRBool seekable;
nsMIMEType contentType;
PRUint16 streamType = NP_NORMAL;
NPError error;
mNPStream.ndata = (void*) this;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
mNPStream.notifyData = mNotifyData;
pluginInfo->GetLength((PRUint32*)&(mNPStream.end));
@ -122,19 +111,36 @@ ns4xPluginStreamListener::OnStartBinding(const char* url, nsIPluginStreamInfo* p
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
nsresult error
= (nsresult)CallNPP_NewStreamProc(callbacks->newstream,
error = CallNPP_NewStreamProc(callbacks->newstream,
npp,
(char *)contentType,
&mNPStream,
seekable,
(PRUint16*)&mStreamType);
&streamType);
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
// translate the old 4x style stream type to the new one
switch(streamType)
{
case NP_NORMAL : mStreamType = nsPluginStreamType_Normal; break;
case NP_ASFILEONLY : mStreamType = nsPluginStreamType_AsFileOnly; break;
case NP_ASFILE : mStreamType = nsPluginStreamType_AsFile; break;
case NP_SEEK : mStreamType = nsPluginStreamType_Seek; break;
default: return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input,
PRUint32 /*offset*/, PRUint32 length, nsIPluginStreamInfo* pluginInfo)
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
nsIInputStream* input,
PRUint32 length)
{
const NPPluginFuncs *callbacks;
NPP npp;
@ -142,17 +148,17 @@ ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input
PRUint32 amountRead = 0;
PRInt32 writeCount = 0;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
if (callbacks->write == NULL)
if (callbacks->write == NULL || length == 0)
return NS_OK; // XXX ?
// Get the data from the input stream
char* buffer = new char[length];
char* buffer = (char*) PR_Malloc(length);
if (buffer)
input->Read(buffer, length, &amountRead);
@ -174,7 +180,10 @@ ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input
else // if WriteReady is not supported by the plugin, just write the whole buffer
numtowrite = length;
// if WriteReady returned 0, the plugin is not ready to handle the data,
// so just skip the Write until WriteReady returns a >0 value
if(numtowrite > 0)
{
writeCount = CallNPP_WriteProc(callbacks->write,
npp,
&mNPStream,
@ -187,17 +196,18 @@ ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input
amountRead -= numtowrite;
mPosition += numtowrite;
}
}
return NS_OK;
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnFileAvailable(const char* url, const char* fileName)
ns4xPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName)
{
const NPPluginFuncs *callbacks;
NPP npp;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
@ -214,12 +224,13 @@ ns4xPluginStreamListener::OnFileAvailable(const char* url, const char* fileName)
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnStopBinding(const char* url, nsresult status, nsIPluginStreamInfo* pluginInfo)
ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status)
{
const NPPluginFuncs *callbacks;
NPP npp;
NPError error;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
mInst->GetCallbacks(&callbacks);
@ -227,10 +238,23 @@ ns4xPluginStreamListener::OnStopBinding(const char* url, nsresult status, nsIPlu
if (callbacks->destroystream != NULL)
{
CallNPP_DestroyStreamProc(callbacks->destroystream,
// XXX need to convert status to NPReason
error = CallNPP_DestroyStreamProc(callbacks->destroystream,
npp,
&mNPStream,
nsPluginReason_Done);
NPRES_DONE);
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
}
// check to see if we have a call back
if (callbacks->urlnotify != NULL && mNotifyData != nsnull)
{
CallNPP_URLNotifyProc(callbacks->urlnotify,
npp,
mNPStream.url,
nsPluginReason_Done,
mNotifyData);
}
return NS_OK;
@ -243,32 +267,6 @@ ns4xPluginStreamListener::GetStreamType(nsPluginStreamType *result)
return NS_OK;
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnNotify(const char* url, nsresult status)
{
const NPPluginFuncs *callbacks;
NPP npp;
mNPStream.url = url;
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
// check to see if we have a call back
if (callbacks->urlnotify != NULL && mNotifyData != nsnull)
{
CallNPP_URLNotifyProc(callbacks->urlnotify,
npp,
url,
nsPluginReason_Done,
mNotifyData);
}
return NS_OK;
}
#endif
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks)
: fCallbacks(callbacks)
{
@ -293,6 +291,7 @@ ns4xPluginInstance :: ~ns4xPluginInstance(void)
NS_RELEASE(fPeer);
}
////////////////////////////////////////////////////////////////////////
NS_IMPL_ADDREF(ns4xPluginInstance);
@ -332,19 +331,18 @@ NS_IMETHODIMP ns4xPluginInstance :: Initialize(nsIPluginInstancePeer* peer)
PRUint16 count = 0;
const char* const* names = nsnull;
const char* const* values = nsnull;
nsresult rv;
NPError error;
nsIPluginTagInfo* taginfo;
NS_ASSERTION(peer != NULL, "null peer");
fPeer = peer;
NS_ADDREF(fPeer);
nsresult error;
nsIPluginTagInfo *taginfo = nsnull;
rv = fPeer->QueryInterface(kIPluginTagInfoIID, (void **)&taginfo);
error = fPeer->QueryInterface(kIPluginTagInfoIID, (void **)&taginfo);
if (NS_OK == error)
if (NS_OK == rv)
{
taginfo->GetAttributes(count, names, values);
NS_IF_RELEASE(taginfo);
@ -362,8 +360,7 @@ NS_IMETHODIMP ns4xPluginInstance :: Initialize(nsIPluginInstancePeer* peer)
fPeer->GetMode(&mode);
fPeer->GetMIMEType(&mimetype);
error = (nsresult)
CallNPP_NewProc(fCallbacks->newp,
error = CallNPP_NewProc(fCallbacks->newp,
(char *)mimetype,
&fNPP,
(PRUint16)mode,
@ -372,7 +369,10 @@ NS_IMETHODIMP ns4xPluginInstance :: Initialize(nsIPluginInstancePeer* peer)
(char**)values,
NULL); // saved data
return error;
if(error != NPERR_NO_ERROR)
rv = NS_ERROR_FAILURE;
return rv;
}
NS_IMETHODIMP ns4xPluginInstance :: GetPeer(nsIPluginInstancePeer* *resultingPeer)
@ -400,7 +400,7 @@ printf("instance stop called\n");
NS_IMETHODIMP ns4xPluginInstance::Destroy(void)
{
nsresult error;
NPError error;
printf("instance destroy called\n");
if (fCallbacks->destroy == NULL)
@ -411,7 +411,10 @@ printf("instance destroy called\n");
error = (nsresult)CallNPP_DestroyProc(fCallbacks->destroy,
&fNPP, &sdata); // saved data
return error;
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
else
return NS_OK;
}
NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
@ -421,14 +424,14 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
if (window == NULL)
return NS_OK;
nsresult error = NS_OK;
NPError error;
if (fCallbacks->setwindow)
{
// XXX Turns out that NPPluginWindow and NPWindow are structurally
// identical (on purpose!), so there's no need to make a copy.
error = (nsresult) CallNPP_SetWindowProc(fCallbacks->setwindow,
error = CallNPP_SetWindowProc(fCallbacks->setwindow,
&fNPP,
(NPWindow*) window);
@ -436,15 +439,13 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
// back from the plugin's SetWindow(). Is this the correct
// behavior?!?
if (error != NS_OK)
if (error != NPERR_NO_ERROR)
printf("error in setwindow %d\n", error);
}
return error;
return NS_OK;
}
#ifdef NEW_PLUGIN_STREAM_API
/* NOTE: the caller must free the stream listener */
NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamListener** listener)
@ -470,33 +471,6 @@ nsresult ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener** listener,
return NS_OK;
}
#else
NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result)
{
(*result) = NULL;
ns4xPluginStream* stream = new ns4xPluginStream();
if (stream == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
nsresult error;
// does it need the peer?
if ((error = stream->Initialize(this, peer)) != NS_OK)
{
NS_RELEASE(stream);
return error;
}
(*result) = stream;
return NS_OK;
}
#endif
NS_IMETHODIMP ns4xPluginInstance::Print(nsPluginPrint* platformPrint)
{
printf("instance print called\n");
@ -511,23 +485,6 @@ printf("instance handleevent called\n");
return NS_OK;
}
#ifndef NEW_PLUGIN_STREAM_API
NS_IMETHODIMP ns4xPluginInstance::URLNotify(const char* url, const char* target,
nsPluginReason reason, void* notifyData)
{
if (fCallbacks->urlnotify != NULL)
{
CallNPP_URLNotifyProc(fCallbacks->urlnotify,
&fNPP,
url,
reason,
notifyData);
}
return NS_OK; //XXX this seems bad...
}
#endif
NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable, void *value)
{
nsresult rv = NS_OK;

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

@ -61,23 +61,12 @@ public:
NS_IMETHOD
SetWindow(nsPluginWindow* window);
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
NewStream(nsIPluginStreamListener** listener);
#else
NS_IMETHOD
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result);
#endif
NS_IMETHOD
Print(nsPluginPrint* platformPrint);
#ifndef NEW_PLUGIN_STREAM_API
NS_IMETHOD
URLNotify(const char* url, const char* target,
nsPluginReason reason, void* notifyData);
#endif
NS_IMETHOD
GetValue(nsPluginInstanceVariable variable, void *value);

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

@ -50,7 +50,7 @@ public:
GetPluginFactory(const char *aMimeType, nsIPlugin** aPlugin) = 0;
NS_IMETHOD
InstantiateEmbededPlugin(const char *aMimeType, nsString& aURLSpec, nsIPluginInstanceOwner *aOwner) = 0;
InstantiateEmbededPlugin(const char *aMimeType, nsIURL* aURL, nsIPluginInstanceOwner *aOwner) = 0;
NS_IMETHOD
InstantiateFullPagePlugin(const char *aMimeType, nsString& aURLSpec, nsIStreamListener *&aStreamListener, nsIPluginInstanceOwner *aOwner) = 0;

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

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

@ -79,8 +79,6 @@ public:
NS_IMETHOD
UserAgent(const char* *resultingAgentString);
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
GetURL(nsISupports* pluginInst,
const char* url,
@ -103,21 +101,6 @@ public:
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL);
#else
NS_IMETHOD
GetURL(nsISupports* inst, const char* url, const char* target,
void* notifyData = NULL, const char* altHost = NULL,
const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE);
NS_IMETHOD
PostURL(nsISupports* inst, const char* url, const char* target,
PRUint32 postDataLen, const char* postData,
PRBool isFile = PR_FALSE, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL);
#endif
//nsIPluginHost interface - used to communicate to the nsPluginInstanceOwner
@ -134,7 +117,7 @@ public:
GetPluginFactory(const char *aMimeType, nsIPlugin** aPlugin);
NS_IMETHOD
InstantiateEmbededPlugin(const char *aMimeType, nsString& aURLSpec, nsIPluginInstanceOwner *aOwner);
InstantiateEmbededPlugin(const char *aMimeType, nsIURL* aURL, nsIPluginInstanceOwner *aOwner);
NS_IMETHOD
InstantiateFullPagePlugin(const char *aMimeType, nsString& aURLSpec, nsIStreamListener *&aStreamListener, nsIPluginInstanceOwner *aOwner);
@ -195,20 +178,15 @@ public:
/* Called by GetURL and PostURL */
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
NewPluginURLStream(const nsString& aURL, nsIPluginInstance *aInstance, nsIPluginStreamListener *aListener);
#else
NS_IMETHOD
NewPluginURLStream(const nsString& aURL, nsIPluginInstance *aInstance, void *aNotifyData);
#endif
private:
/* Called by InstantiatePlugin */
nsresult
NewEmbededPluginStream(const nsString& aURL, nsIPluginInstanceOwner *aOwner, nsIPluginInstance* aInstance);
NewEmbededPluginStream(nsIURL* aURL, nsIPluginInstanceOwner *aOwner, nsIPluginInstance* aInstance);
nsresult
NewFullPagePluginStream(nsIStreamListener *&aStreamListener, nsIPluginInstance *aInstance);

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

@ -157,7 +157,6 @@ public:
Close(void);
protected:
char* mTarget;
nsFileURL mFileURL;
nsFileSpec mFileSpec;
@ -165,11 +164,16 @@ protected:
nsIPluginInstanceOwner* mOwner;
};
NS_IMPL_ADDREF(nsPluginStreamToFile);
NS_IMPL_RELEASE(nsPluginStreamToFile);
nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner)
: mTarget(PL_strdup(target))
, mFileURL(nsnull)
, mOwner(owner)
{
NS_INIT_REFCNT();
// open the file and prepare it for writing
char buf[400], tpath[300];
#ifdef XP_PC
@ -192,7 +196,7 @@ nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstance
// Create and validate the file spec object. (When we have a constructor for the temp
// directory, we should use this instead of the per-platform hack above).
mFileSpec = buf;
mFileSpec = PL_strdup(buf);
if (mFileSpec.Error())
return;
@ -218,10 +222,6 @@ nsPluginStreamToFile::~nsPluginStreamToFile()
}
NS_IMPL_ADDREF(nsPluginStreamToFile)
NS_IMPL_RELEASE(nsPluginStreamToFile)
nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{

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

@ -41,7 +41,6 @@ CPPSRCS = \
ns4xPlugin.cpp \
ns4xPluginInstance.cpp \
nsPluginInstancePeer.cpp \
nsMalloc.cpp \
$(NULL)
REQUIRES = raptor plugin java xpcom netlib libplc21 oji

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

@ -37,10 +37,7 @@ OBJS = \
.\$(OBJDIR)\nsPluginFactory.obj \
.\$(OBJDIR)\ns4xPlugin.obj \
.\$(OBJDIR)\ns4xPluginInstance.obj \
# .\$(OBJDIR)\ns4xPluginStream.obj \
.\$(OBJDIR)\nsPluginInstancePeer.obj \
# .\$(OBJDIR)\nsPluginStreamPeer.obj \
.\$(OBJDIR)\nsMalloc.obj \
$(NULL)
LINCS = \

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

@ -24,6 +24,7 @@
#include "ns4xPluginInstance.h"
#include "nsIServiceManager.h"
#include "nsIAllocator.h"
#include "nsIPluginStreamListener.h"
////////////////////////////////////////////////////////////////////////
@ -87,32 +88,23 @@ static NS_DEFINE_IID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
static NS_DEFINE_IID(kIAllocatorIID, NS_IALLOCATOR_IID);
#ifndef NEW_PLUGIN_STREAM_API
static NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID);
#endif
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
////////////////////////////////////////////////////////////////////////
#ifdef NEW_PLUGIN_STREAM_API
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr)
#else
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown)
#endif
{
NS_INIT_REFCNT();
memcpy((void*) &fCallbacks, (void*) callbacks, sizeof(fCallbacks));
fShutdownEntry = aShutdown;
#ifdef NEW_PLUGIN_STREAM_API
// set up the connections to the plugin manager
if (nsnull == mPluginManager)
serviceMgr->GetService(kPluginManagerCID, kIPluginManagerIID, (nsISupports**)&mPluginManager);
if (nsnull == mMalloc)
serviceMgr->GetService(kAllocatorCID, kIAllocatorIID, (nsISupports**)&mMalloc);
#endif
}
@ -165,7 +157,8 @@ ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
nsresult
ns4xPlugin::CreatePlugin(PRLibrary *library,
nsIPlugin **result, nsIServiceManager* serviceMgr)
nsIPlugin **result,
nsIServiceManager* serviceMgr)
{
CheckClassInitialized();
@ -203,11 +196,7 @@ ns4xPlugin::CreatePlugin(PRLibrary *library,
// we must init here because the plugin may call NPN functions
// when we call into the NP_Initialize entry point - NPN functions
// require that mBrowserManager be set up
#ifdef NEW_PLUGIN_STREAM_API
(*result)->Initialize();
#else
(*result)->Initialize(browserInterfaces);
#endif
// the NP_Initialize entry point was misnamed as NP_PluginInit,
// early in plugin project development. Its correct name is
@ -273,30 +262,11 @@ nsresult ns4xPlugin :: LockFactory(PRBool aLock)
return NS_OK;
}
#ifndef NEW_PLUGIN_STREAM_API
nsresult
ns4xPlugin::Initialize(nsISupports* browserInterfaces)
{
nsresult rv = NS_OK;
// set up the connections to the plugin manager
if (nsnull == mPluginManager)
if((rv = browserInterfaces->QueryInterface(kIPluginManagerIID, (void **)&mPluginManager)) != NS_OK)
return rv;
if (nsnull == mMalloc)
if((rv = browserInterfaces->QueryInterface(kIMallocIID, (void **)&mMalloc)) != NS_OK)
return rv;
return rv;
}
#else
nsresult
ns4xPlugin::Initialize(void)
{
return NS_OK;
}
#endif
nsresult
ns4xPlugin::Shutdown(void)
@ -336,101 +306,106 @@ printf("plugin getvalue %d called\n", variable);
// Static callbacks that get routed back through the new C++ API
//
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_geturl(NPP npp, const char* relativeURL, const char* target)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
inst->NewStream(&listener);
return mPluginManager->GetURL(inst, relativeURL, target, listener);
#else
return mPluginManager->GetURL(inst, relativeURL, target);
#endif
if(mPluginManager->GetURL(inst, relativeURL, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_geturlnotify(NPP npp, const char* relativeURL, const char* target,
void* notifyData)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
((ns4xPluginInstance*)inst)->NewNotifyStream(&listener, notifyData);
return mPluginManager->GetURL(inst, relativeURL, target, listener);
#else
return mPluginManager->GetURL(inst, relativeURL, target,
notifyData);
#endif
if(mPluginManager->GetURL(inst, relativeURL, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file,
void* notifyData)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
((ns4xPluginInstance*)inst)->NewNotifyStream(&listener, notifyData);
return mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener);
#else
return mPluginManager->PostURL(inst, relativeURL, target,
len, buf, file, notifyData);
#endif
if(mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
#ifdef NEW_PLUGIN_STREAM_API
nsIPluginStreamListener* listener = nsnull;
if(target == nsnull)
inst->NewStream(&listener);
return mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener);
#else
return mPluginManager->PostURL(inst, relativeURL, target,
len, buf, file);
#endif
if(mPluginManager->PostURL(inst, relativeURL, len, buf, file, target, listener) != NS_OK)
return NPERR_GENERIC_ERROR;
return NPERR_NO_ERROR;
}
////////////////////////////////////////////////////////////////////////
@ -449,8 +424,7 @@ public:
ns4xStreamWrapper(nsIOutputStream* stream);
~ns4xStreamWrapper();
nsIOutputStream*
GetStream(void);
void GetStream(nsIOutputStream* &result);
NPStream*
GetNPStream(void) {
@ -464,7 +438,6 @@ ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream)
NS_ASSERTION(stream != NULL, "bad stream");
fStream = stream;
NS_ADDREF(fStream);
memset(&fNPStream, 0, sizeof(fNPStream));
@ -474,41 +447,42 @@ ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream)
ns4xStreamWrapper::~ns4xStreamWrapper(void)
{
fStream->Close();
NS_IF_RELEASE(fStream);
}
nsIOutputStream*
ns4xStreamWrapper::GetStream(void)
{
NS_IF_ADDREF(fStream);
return fStream;
void
ns4xStreamWrapper::GetStream(nsIOutputStream* &result)
{
result = fStream;
NS_IF_ADDREF(fStream);
}
////////////////////////////////////////////////////////////////////////
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_newstream(NPP npp, NPMIMEType type, const char* window, NPStream* *result)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
nsresult error;
nsIOutputStream* stream;
nsIPluginInstancePeer *peer;
if (NS_OK == inst->GetPeer(&peer))
{
if ((error = peer->NewStream((const char*) type, window, &stream)) != NS_OK)
if (peer->NewStream((const char*) type, window, &stream) != NS_OK)
{
NS_RELEASE(peer);
return error;
return NPERR_GENERIC_ERROR;
}
ns4xStreamWrapper* wrapper = new ns4xStreamWrapper(stream);
@ -517,58 +491,83 @@ ns4xPlugin::_newstream(NPP npp, NPMIMEType type, const char* window, NPStream* *
{
NS_RELEASE(peer);
NS_RELEASE(stream);
return NS_ERROR_OUT_OF_MEMORY;
return NPERR_OUT_OF_MEMORY_ERROR;
}
(*result) = wrapper->GetNPStream();
NS_RELEASE(peer);
return error;
return NPERR_NO_ERROR;
}
else
return NS_ERROR_UNEXPECTED;
return NPERR_GENERIC_ERROR;
}
int32 NP_EXPORT
ns4xPlugin::_write(NPP npp, NPStream *pstream, int32 len, void *buffer)
{
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) pstream->ndata;
// negative return indicates failure to the plugin
if(!npp)
return -1;
NS_ASSERTION(wrapper != NULL, "null wrapper");
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) pstream->ndata;
NS_ASSERTION(wrapper != NULL, "null stream");
if (wrapper == NULL)
return 0;
return -1;
nsIOutputStream* stream = wrapper->GetStream();
nsIOutputStream* stream;
wrapper->GetStream(stream);
PRUint32 count = 0;
nsresult rv = stream->Write((char *)buffer, len, &count);
NS_RELEASE(stream);
if(rv != NS_OK)
return -1;
return (int32)count;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_destroystream(NPP npp, NPStream *pstream, NPError reason)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsISupports* stream = (nsISupports*) pstream->ndata;
nsIPluginStreamListener* listener;
// DestroyStream can kill two kinds of streams: NPP derived and
// NPN derived.
// check to see if they're trying to kill a NPP stream
if(stream->QueryInterface(kIPluginStreamListenerIID, (void**)&listener) == NS_OK)
{
// XXX we should try to kill this listener here somehow
NS_RELEASE(listener);
return NPERR_NO_ERROR;
}
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) pstream->ndata;
NS_ASSERTION(wrapper != NULL, "null wrapper");
if (wrapper == NULL)
return 0;
return NPERR_INVALID_PARAM;
// This will release the wrapped nsIOutputStream.
delete wrapper;
return NS_OK;
return NPERR_NO_ERROR;
}
void NP_EXPORT
ns4xPlugin::_status(NPP npp, const char *message)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -588,6 +587,7 @@ ns4xPlugin::_status(NPP npp, const char *message)
void NP_EXPORT
ns4xPlugin::_memfree (void *ptr)
{
if(ptr)
mMalloc->Free(ptr);
}
@ -608,6 +608,9 @@ ns4xPlugin::_reloadplugins(NPBool reloadPages)
void NP_EXPORT
ns4xPlugin::_invalidaterect(NPP npp, NPRect *invalidRect)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -634,6 +637,9 @@ ns4xPlugin::_invalidaterect(NPP npp, NPRect *invalidRect)
void NP_EXPORT
ns4xPlugin::_invalidateregion(NPP npp, NPRegion invalidRegion)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -660,6 +666,9 @@ ns4xPlugin::_invalidateregion(NPP npp, NPRegion invalidRegion)
void NP_EXPORT
ns4xPlugin::_forceredraw(NPP npp)
{
if(!npp)
return;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
@ -682,15 +691,18 @@ ns4xPlugin::_forceredraw(NPP npp)
}
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_getvalue(NPP npp, NPNVariable variable, void *result)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_FAILURE; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
nsIPluginInstancePeer *peer;
@ -705,18 +717,21 @@ ns4xPlugin::_getvalue(NPP npp, NPNVariable variable, void *result)
return rv;
}
else
return NS_ERROR_UNEXPECTED;
return NPERR_GENERIC_ERROR;
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
{
if(!npp)
return NPERR_INVALID_INSTANCE_ERROR;
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_FAILURE; // XXX
return NPERR_INVALID_INSTANCE_ERROR;
switch (variable)
{
@ -727,7 +742,7 @@ ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
return inst->SetTransparent(*((NPBool *)result));
default:
return NS_OK;
return NPERR_NO_ERROR;
}
#if 0
@ -748,31 +763,10 @@ ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
#endif
}
nsresult NP_EXPORT
NPError NP_EXPORT
ns4xPlugin::_requestread(NPStream *pstream, NPByteRange *rangeList)
{
#ifndef NEW_PLUGIN_STREAM_API
nsIPluginStreamPeer* streamPeer = (nsIPluginStreamPeer*) pstream->ndata;
NS_ASSERTION(streamPeer != NULL, "null streampeer");
if (streamPeer == NULL)
return NS_ERROR_FAILURE; // XXX
nsISeekablePluginStreamPeer* seekablePeer = NULL;
if (streamPeer->QueryInterface(kISeekablePluginStreamPeerIID,
(void**)seekablePeer) == NS_OK)
{
nsresult error;
// XXX nsByteRange & NPByteRange are structurally equivalent.
error = seekablePeer->RequestRead((nsByteRange *)rangeList);
NS_RELEASE(seekablePeer);
return error;
}
#endif
return NS_ERROR_UNEXPECTED;
return NPERR_STREAM_NOT_SEEKABLE;
}

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

@ -54,6 +54,7 @@ class nsIAllocator;
class ns4xPlugin : public nsIPlugin
{
public:
ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown, nsIServiceManager* serviceMgr);
~ns4xPlugin(void);
@ -69,13 +70,8 @@ public:
//nsIPlugin interface
#ifndef NEW_PLUGIN_STREAM_API
NS_IMETHOD
Initialize(nsISupports* browserInterfaces);
#else
NS_IMETHOD
Initialize(void);
#endif
NS_IMETHOD
Shutdown(void);
@ -109,36 +105,36 @@ protected:
// Static stub functions that are exported to the 4.x plugin as entry
// points via the CALLBACKS variable.
//
static nsresult NP_EXPORT
static NPError NP_EXPORT
_requestread(NPStream *pstream, NPByteRange *rangeList);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_getvalue(NPP npp, NPNVariable variable, void *r_value);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_setvalue(NPP npp, NPPVariable variable, void *r_value);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_geturl(NPP npp, const char* relativeURL, const char* target);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file, void* notifyData);
static nsresult NP_EXPORT
static NPError NP_EXPORT
_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file);
static nsresult NP_EXPORT
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 nsresult NP_EXPORT
static NPError NP_EXPORT
_destroystream(NPP npp, NPStream *pstream, NPError reason);
static void NP_EXPORT

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

@ -17,20 +17,11 @@
*/
#include "ns4xPluginInstance.h"
#ifdef NEW_PLUGIN_STREAM_API
#include "nsIPluginStreamListener.h"
#else
#include "ns4xPluginStream.h"
#endif
#include "prlog.h"
#include "prmem.h"
////////////////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////////////////
#ifdef NEW_PLUGIN_STREAM_API
class ns4xPluginStreamListener : public nsIPluginStreamListener {
@ -42,24 +33,20 @@ public:
// from nsIPluginStreamListener:
NS_IMETHOD
OnStartBinding(const char* url, nsIPluginStreamInfo* pluginInfo);
OnStartBinding(nsIPluginStreamInfo* pluginInfo);
NS_IMETHOD
OnDataAvailable(const char* url, nsIInputStream* input,
PRUint32 offset, PRUint32 length, nsIPluginStreamInfo* pluginInfo);
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length);
NS_IMETHOD
OnFileAvailable(const char* url, const char* fileName);
OnFileAvailable( nsIPluginStreamInfo* pluginInfo, const char* fileName);
NS_IMETHOD
OnStopBinding(const char* url, nsresult status, nsIPluginStreamInfo* pluginInfo);
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
NS_IMETHOD
GetStreamType(nsPluginStreamType *result);
NS_IMETHOD
OnNotify(const char* url, nsresult status);
////////////////////////////////////////////////////////////////////////////
// ns4xPluginStreamListener specific methods:
@ -75,6 +62,7 @@ protected:
nsPluginStreamType mStreamType;
};
////////////////////////////////////////////////////////////////////////////////
// ns4xPluginStreamListener Methods
////////////////////////////////////////////////////////////////////////////////
@ -102,16 +90,17 @@ ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
NS_IMPL_ISUPPORTS(ns4xPluginStreamListener, kIPluginStreamListenerIID);
NS_IMETHODIMP
ns4xPluginStreamListener::OnStartBinding(const char* url, nsIPluginStreamInfo* pluginInfo)
ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
{
NPP npp;
const NPPluginFuncs *callbacks;
PRBool seekable;
nsMIMEType contentType;
PRUint16 streamType = NP_NORMAL;
NPError error;
mNPStream.ndata = (void*) this;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
mNPStream.notifyData = mNotifyData;
pluginInfo->GetLength((PRUint32*)&(mNPStream.end));
@ -122,19 +111,36 @@ ns4xPluginStreamListener::OnStartBinding(const char* url, nsIPluginStreamInfo* p
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
nsresult error
= (nsresult)CallNPP_NewStreamProc(callbacks->newstream,
error = CallNPP_NewStreamProc(callbacks->newstream,
npp,
(char *)contentType,
&mNPStream,
seekable,
(PRUint16*)&mStreamType);
&streamType);
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
// translate the old 4x style stream type to the new one
switch(streamType)
{
case NP_NORMAL : mStreamType = nsPluginStreamType_Normal; break;
case NP_ASFILEONLY : mStreamType = nsPluginStreamType_AsFileOnly; break;
case NP_ASFILE : mStreamType = nsPluginStreamType_AsFile; break;
case NP_SEEK : mStreamType = nsPluginStreamType_Seek; break;
default: return NS_ERROR_FAILURE;
}
return NS_OK;
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input,
PRUint32 /*offset*/, PRUint32 length, nsIPluginStreamInfo* pluginInfo)
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
nsIInputStream* input,
PRUint32 length)
{
const NPPluginFuncs *callbacks;
NPP npp;
@ -142,17 +148,17 @@ ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input
PRUint32 amountRead = 0;
PRInt32 writeCount = 0;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
if (callbacks->write == NULL)
if (callbacks->write == NULL || length == 0)
return NS_OK; // XXX ?
// Get the data from the input stream
char* buffer = new char[length];
char* buffer = (char*) PR_Malloc(length);
if (buffer)
input->Read(buffer, length, &amountRead);
@ -174,7 +180,10 @@ ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input
else // if WriteReady is not supported by the plugin, just write the whole buffer
numtowrite = length;
// if WriteReady returned 0, the plugin is not ready to handle the data,
// so just skip the Write until WriteReady returns a >0 value
if(numtowrite > 0)
{
writeCount = CallNPP_WriteProc(callbacks->write,
npp,
&mNPStream,
@ -187,17 +196,18 @@ ns4xPluginStreamListener::OnDataAvailable(const char* url, nsIInputStream* input
amountRead -= numtowrite;
mPosition += numtowrite;
}
}
return NS_OK;
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnFileAvailable(const char* url, const char* fileName)
ns4xPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName)
{
const NPPluginFuncs *callbacks;
NPP npp;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
@ -214,12 +224,13 @@ ns4xPluginStreamListener::OnFileAvailable(const char* url, const char* fileName)
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnStopBinding(const char* url, nsresult status, nsIPluginStreamInfo* pluginInfo)
ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status)
{
const NPPluginFuncs *callbacks;
NPP npp;
NPError error;
mNPStream.url = url;
pluginInfo->GetURL(&mNPStream.url);
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
mInst->GetCallbacks(&callbacks);
@ -227,10 +238,23 @@ ns4xPluginStreamListener::OnStopBinding(const char* url, nsresult status, nsIPlu
if (callbacks->destroystream != NULL)
{
CallNPP_DestroyStreamProc(callbacks->destroystream,
// XXX need to convert status to NPReason
error = CallNPP_DestroyStreamProc(callbacks->destroystream,
npp,
&mNPStream,
nsPluginReason_Done);
NPRES_DONE);
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
}
// check to see if we have a call back
if (callbacks->urlnotify != NULL && mNotifyData != nsnull)
{
CallNPP_URLNotifyProc(callbacks->urlnotify,
npp,
mNPStream.url,
nsPluginReason_Done,
mNotifyData);
}
return NS_OK;
@ -243,32 +267,6 @@ ns4xPluginStreamListener::GetStreamType(nsPluginStreamType *result)
return NS_OK;
}
NS_IMETHODIMP
ns4xPluginStreamListener::OnNotify(const char* url, nsresult status)
{
const NPPluginFuncs *callbacks;
NPP npp;
mNPStream.url = url;
mInst->GetCallbacks(&callbacks);
mInst->GetNPP(&npp);
// check to see if we have a call back
if (callbacks->urlnotify != NULL && mNotifyData != nsnull)
{
CallNPP_URLNotifyProc(callbacks->urlnotify,
npp,
url,
nsPluginReason_Done,
mNotifyData);
}
return NS_OK;
}
#endif
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks)
: fCallbacks(callbacks)
{
@ -293,6 +291,7 @@ ns4xPluginInstance :: ~ns4xPluginInstance(void)
NS_RELEASE(fPeer);
}
////////////////////////////////////////////////////////////////////////
NS_IMPL_ADDREF(ns4xPluginInstance);
@ -332,19 +331,18 @@ NS_IMETHODIMP ns4xPluginInstance :: Initialize(nsIPluginInstancePeer* peer)
PRUint16 count = 0;
const char* const* names = nsnull;
const char* const* values = nsnull;
nsresult rv;
NPError error;
nsIPluginTagInfo* taginfo;
NS_ASSERTION(peer != NULL, "null peer");
fPeer = peer;
NS_ADDREF(fPeer);
nsresult error;
nsIPluginTagInfo *taginfo = nsnull;
rv = fPeer->QueryInterface(kIPluginTagInfoIID, (void **)&taginfo);
error = fPeer->QueryInterface(kIPluginTagInfoIID, (void **)&taginfo);
if (NS_OK == error)
if (NS_OK == rv)
{
taginfo->GetAttributes(count, names, values);
NS_IF_RELEASE(taginfo);
@ -362,8 +360,7 @@ NS_IMETHODIMP ns4xPluginInstance :: Initialize(nsIPluginInstancePeer* peer)
fPeer->GetMode(&mode);
fPeer->GetMIMEType(&mimetype);
error = (nsresult)
CallNPP_NewProc(fCallbacks->newp,
error = CallNPP_NewProc(fCallbacks->newp,
(char *)mimetype,
&fNPP,
(PRUint16)mode,
@ -372,7 +369,10 @@ NS_IMETHODIMP ns4xPluginInstance :: Initialize(nsIPluginInstancePeer* peer)
(char**)values,
NULL); // saved data
return error;
if(error != NPERR_NO_ERROR)
rv = NS_ERROR_FAILURE;
return rv;
}
NS_IMETHODIMP ns4xPluginInstance :: GetPeer(nsIPluginInstancePeer* *resultingPeer)
@ -400,7 +400,7 @@ printf("instance stop called\n");
NS_IMETHODIMP ns4xPluginInstance::Destroy(void)
{
nsresult error;
NPError error;
printf("instance destroy called\n");
if (fCallbacks->destroy == NULL)
@ -411,7 +411,10 @@ printf("instance destroy called\n");
error = (nsresult)CallNPP_DestroyProc(fCallbacks->destroy,
&fNPP, &sdata); // saved data
return error;
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
else
return NS_OK;
}
NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
@ -421,14 +424,14 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
if (window == NULL)
return NS_OK;
nsresult error = NS_OK;
NPError error;
if (fCallbacks->setwindow)
{
// XXX Turns out that NPPluginWindow and NPWindow are structurally
// identical (on purpose!), so there's no need to make a copy.
error = (nsresult) CallNPP_SetWindowProc(fCallbacks->setwindow,
error = CallNPP_SetWindowProc(fCallbacks->setwindow,
&fNPP,
(NPWindow*) window);
@ -436,15 +439,13 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
// back from the plugin's SetWindow(). Is this the correct
// behavior?!?
if (error != NS_OK)
if (error != NPERR_NO_ERROR)
printf("error in setwindow %d\n", error);
}
return error;
return NS_OK;
}
#ifdef NEW_PLUGIN_STREAM_API
/* NOTE: the caller must free the stream listener */
NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamListener** listener)
@ -470,33 +471,6 @@ nsresult ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener** listener,
return NS_OK;
}
#else
NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result)
{
(*result) = NULL;
ns4xPluginStream* stream = new ns4xPluginStream();
if (stream == NULL)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
nsresult error;
// does it need the peer?
if ((error = stream->Initialize(this, peer)) != NS_OK)
{
NS_RELEASE(stream);
return error;
}
(*result) = stream;
return NS_OK;
}
#endif
NS_IMETHODIMP ns4xPluginInstance::Print(nsPluginPrint* platformPrint)
{
printf("instance print called\n");
@ -511,23 +485,6 @@ printf("instance handleevent called\n");
return NS_OK;
}
#ifndef NEW_PLUGIN_STREAM_API
NS_IMETHODIMP ns4xPluginInstance::URLNotify(const char* url, const char* target,
nsPluginReason reason, void* notifyData)
{
if (fCallbacks->urlnotify != NULL)
{
CallNPP_URLNotifyProc(fCallbacks->urlnotify,
&fNPP,
url,
reason,
notifyData);
}
return NS_OK; //XXX this seems bad...
}
#endif
NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable, void *value)
{
nsresult rv = NS_OK;

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

@ -61,23 +61,12 @@ public:
NS_IMETHOD
SetWindow(nsPluginWindow* window);
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
NewStream(nsIPluginStreamListener** listener);
#else
NS_IMETHOD
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result);
#endif
NS_IMETHOD
Print(nsPluginPrint* platformPrint);
#ifndef NEW_PLUGIN_STREAM_API
NS_IMETHOD
URLNotify(const char* url, const char* target,
nsPluginReason reason, void* notifyData);
#endif
NS_IMETHOD
GetValue(nsPluginInstanceVariable variable, void *value);

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

@ -50,7 +50,7 @@ public:
GetPluginFactory(const char *aMimeType, nsIPlugin** aPlugin) = 0;
NS_IMETHOD
InstantiateEmbededPlugin(const char *aMimeType, nsString& aURLSpec, nsIPluginInstanceOwner *aOwner) = 0;
InstantiateEmbededPlugin(const char *aMimeType, nsIURL* aURL, nsIPluginInstanceOwner *aOwner) = 0;
NS_IMETHOD
InstantiateFullPagePlugin(const char *aMimeType, nsString& aURLSpec, nsIStreamListener *&aStreamListener, nsIPluginInstanceOwner *aOwner) = 0;

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

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

@ -79,8 +79,6 @@ public:
NS_IMETHOD
UserAgent(const char* *resultingAgentString);
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
GetURL(nsISupports* pluginInst,
const char* url,
@ -103,21 +101,6 @@ public:
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL);
#else
NS_IMETHOD
GetURL(nsISupports* inst, const char* url, const char* target,
void* notifyData = NULL, const char* altHost = NULL,
const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE);
NS_IMETHOD
PostURL(nsISupports* inst, const char* url, const char* target,
PRUint32 postDataLen, const char* postData,
PRBool isFile = PR_FALSE, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL);
#endif
//nsIPluginHost interface - used to communicate to the nsPluginInstanceOwner
@ -134,7 +117,7 @@ public:
GetPluginFactory(const char *aMimeType, nsIPlugin** aPlugin);
NS_IMETHOD
InstantiateEmbededPlugin(const char *aMimeType, nsString& aURLSpec, nsIPluginInstanceOwner *aOwner);
InstantiateEmbededPlugin(const char *aMimeType, nsIURL* aURL, nsIPluginInstanceOwner *aOwner);
NS_IMETHOD
InstantiateFullPagePlugin(const char *aMimeType, nsString& aURLSpec, nsIStreamListener *&aStreamListener, nsIPluginInstanceOwner *aOwner);
@ -195,20 +178,15 @@ public:
/* Called by GetURL and PostURL */
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
NewPluginURLStream(const nsString& aURL, nsIPluginInstance *aInstance, nsIPluginStreamListener *aListener);
#else
NS_IMETHOD
NewPluginURLStream(const nsString& aURL, nsIPluginInstance *aInstance, void *aNotifyData);
#endif
private:
/* Called by InstantiatePlugin */
nsresult
NewEmbededPluginStream(const nsString& aURL, nsIPluginInstanceOwner *aOwner, nsIPluginInstance* aInstance);
NewEmbededPluginStream(nsIURL* aURL, nsIPluginInstanceOwner *aOwner, nsIPluginInstance* aInstance);
nsresult
NewFullPagePluginStream(nsIStreamListener *&aStreamListener, nsIPluginInstance *aInstance);

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

@ -157,7 +157,6 @@ public:
Close(void);
protected:
char* mTarget;
nsFileURL mFileURL;
nsFileSpec mFileSpec;
@ -165,11 +164,16 @@ protected:
nsIPluginInstanceOwner* mOwner;
};
NS_IMPL_ADDREF(nsPluginStreamToFile);
NS_IMPL_RELEASE(nsPluginStreamToFile);
nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner)
: mTarget(PL_strdup(target))
, mFileURL(nsnull)
, mOwner(owner)
{
NS_INIT_REFCNT();
// open the file and prepare it for writing
char buf[400], tpath[300];
#ifdef XP_PC
@ -192,7 +196,7 @@ nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstance
// Create and validate the file spec object. (When we have a constructor for the temp
// directory, we should use this instead of the per-platform hack above).
mFileSpec = buf;
mFileSpec = PL_strdup(buf);
if (mFileSpec.Error())
return;
@ -218,10 +222,6 @@ nsPluginStreamToFile::~nsPluginStreamToFile()
}
NS_IMPL_ADDREF(nsPluginStreamToFile)
NS_IMPL_RELEASE(nsPluginStreamToFile)
nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
void** aInstancePtrResult)
{

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

@ -36,10 +36,7 @@
#include "nsplugindefs.h"
#include "nsISupports.h"
#ifdef NEW_PLUGIN_STREAM_API
#include "nsIPluginStreamListener.h"
#endif
#define NS_IPLUGININSTANCE_IID \
{ /* ebe00f40-0199-11d2-815b-006008119d7a */ \
@ -140,7 +137,6 @@ public:
NS_IMETHOD
SetWindow(nsPluginWindow* window) = 0;
#ifdef NEW_PLUGIN_STREAM_API
/**
* Called to tell the plugin that the initial src/data stream is
* ready. Expects the plugin to return a nsIPluginStreamListener.
@ -152,21 +148,6 @@ public:
*/
NS_IMETHOD
NewStream(nsIPluginStreamListener** listener) = 0;
#else
/**
* Called when a new plugin stream must be constructed in order for the plugin
* instance to receive a stream of data from the browser.
*
* (Corresponds to NPP_NewStream.)
*
* @param peer - the plugin stream peer, representing information about the
* incoming stream, and stream-specific callbacks into the browser
* @param result - the resulting plugin stream
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0;
#endif
/**
* Called to instruct the plugin instance to print itself to a printer.
@ -179,24 +160,6 @@ public:
NS_IMETHOD
Print(nsPluginPrint* platformPrint) = 0;
#ifndef NEW_PLUGIN_STREAM_API
/**
* Called to notify the plugin instance that a URL request has been
* completed. (See nsIPluginManager::GetURL and nsIPluginManager::PostURL).
*
* (Corresponds to NPP_URLNotify.)
*
* @param url - the requested URL
* @param target - the target window name
* @param reason - the reason for completion
* @param notifyData - the notify data supplied to GetURL or PostURL
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
URLNotify(const char* url, const char* target,
nsPluginReason reason, void* notifyData) = 0;
#endif
/**
* Returns the value of a variable associated with the plugin instance.
*

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

@ -102,32 +102,6 @@ public:
NS_IMETHOD
UserAgent(const char* *resultingAgentString) = 0;
#ifdef NEW_PLUGIN_STREAM_API
NS_IMETHOD
GetURL(nsISupports* pluginInst,
const char* url,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE) = 0;
NS_IMETHOD
PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
PRBool isFile = PR_FALSE,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL) = 0;
#else // !NEW_PLUGIN_STREAM_API
/**
* Fetches a URL.
*
@ -149,10 +123,15 @@ public:
* specify PR_FALSE)
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
GetURL(nsISupports* pluginInst, const char* url, const char* target,
void* notifyData = NULL, const char* altHost = NULL,
const char* referrer = NULL, PRBool forceJSEnabled = PR_FALSE) = 0;
GetURL(nsISupports* pluginInst,
const char* url,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE) = 0;
/**
* Posts to a URL with post data and/or post headers.
@ -183,14 +162,20 @@ public:
* are no post headers
* @result - NS_OK if this operation was successful
*/
NS_IMETHOD
PostURL(nsISupports* pluginInst, const char* url, const char* target,
PRUint32 postDataLen, const char* postData,
PRBool isFile = PR_FALSE, void* notifyData = NULL,
const char* altHost = NULL, const char* referrer = NULL,
PostURL(nsISupports* pluginInst,
const char* url,
PRUint32 postDataLen,
const char* postData,
PRBool isFile = PR_FALSE,
const char* target = NULL,
nsIPluginStreamListener* streamListener = NULL,
const char* altHost = NULL,
const char* referrer = NULL,
PRBool forceJSEnabled = PR_FALSE,
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0;
#endif // !NEW_PLUGIN_STREAM_API
PRUint32 postHeadersLength = 0,
const char* postHeaders = NULL) = 0;
};

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

@ -38,6 +38,9 @@ public:
NS_IMETHOD
GetLastModified(PRUint32* result) = 0;
NS_IMETHOD
GetURL(const char** result) = 0;
NS_IMETHOD
RequestRead(nsByteRange* rangeList) = 0;
};

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

@ -56,7 +56,7 @@ public:
* used to cancel the URL load..
*/
NS_IMETHOD
OnStartBinding(const char* url, nsIPluginStreamInfo* pluginInfo) = 0;
OnStartBinding(nsIPluginStreamInfo* pluginInfo) = 0;
/**
* Notify the client that data is available in the input stream. This
@ -69,11 +69,11 @@ public:
* @return The return value is currently ignored.
*/
NS_IMETHOD
OnDataAvailable(const char* url, nsIInputStream* input,
PRUint32 offset, PRUint32 length, nsIPluginStreamInfo* pluginInfo) = 0;
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) = 0;
NS_IMETHOD
OnFileAvailable(const char* url, const char* fileName) = 0;
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) = 0;
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
@ -86,10 +86,8 @@ public:
* @return The return value is currently ignored.
*/
NS_IMETHOD
OnStopBinding(const char* url, nsresult status, nsIPluginStreamInfo* pluginInfo) = 0;
OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status) = 0;
NS_IMETHOD
OnNotify(const char* url, nsresult status) = 0;
NS_IMETHOD
GetStreamType(nsPluginStreamType *result) = 0;

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

@ -79,8 +79,7 @@
#ifndef nsplugins_h___
#define nsplugins_h___
#define NEW_PLUGIN_STREAM_API
#include "nsRepository.h" // for NSGetFactory
#include "nsIComponentManager.h" // for NSGetFactory
////////////////////////////////////////////////////////////////////////////////
@ -114,23 +113,11 @@
*/
#include "nsIPluginInstance.h"
#ifdef NEW_PLUGIN_STREAM_API
/**
* A plugin stream listener ...
*/
#include "nsIPluginStreamListener.h"
#else // !NEW_PLUGIN_STREAM_API
/**
* A plugin stream gets instantiated when a plugin instance receives data from
* the browser.
*/
#include "nsIPluginStream.h"
#endif // !NEW_PLUGIN_STREAM_API
/**
* The nsILiveConnectPlugin interface provides additional operations that a
* plugin must implement if it is to be controlled by JavaScript through
@ -177,32 +164,11 @@
*/
#include "nsIWindowlessPlugInstPeer.h"
#ifdef NEW_PLUGIN_STREAM_API
/**
*
*/
#include "nsIPluginInputStream.h"
#else // !NEW_PLUGIN_STREAM_API
/**
* A plugin stream peer gets create by the browser and associated with each
* plugin stream to represent stream and URL information, and provides
* other callbacks needed by the plugin stream.
*/
#include "nsIPluginStreamPeer.h"
/**
* The nsISeekablePluginStreamPeer provides additional operations for seekable
* plugin streams.
*
* To obtain: QueryInterface on nsIPluginStreamPeer
*/
#include "nsISeekablePluginStreamPeer.h"
#endif // !NEW_PLUGIN_STREAM_API
////////////////////////////////////////////////////////////////////////////////
/**
* <B>Interfaces implemented by the browser (new for 5.0):
@ -236,25 +202,11 @@
*/
//#include "nsILiveConnectPlugInstPeer.h"
#ifdef NEW_PLUGIN_STREAM_API
/**
*
*/
#include "nsIPluginInputStream2.h"
#else // !NEW_PLUGIN_STREAM_API
/**
* The nsIPluginStreamPeer2 interface provides additional plugin stream
* peer features only available in Communicator 5.0.
*
* To obtain: QueryInterface on nsIPluginStreamPeer
*/
#include "nsIPluginStreamPeer2.h"
#endif // !NEW_PLUGIN_STREAM_API
/**
* The nsIPluginTagInfo2 interface provides additional html tag information
* only available in Communicator 5.0.

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

@ -34,8 +34,6 @@
#ifndef nsplugindefs_h___
#define nsplugindefs_h___
#define NEW_PLUGIN_STREAM_API
#ifndef prtypes_h___
#include "prtypes.h"
#endif