mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Added networking changes under ifdef NEW_PLUGIN_STREAM_API
This commit is contained in:
parent
25b2080e5a
commit
51c2d71bae
@ -68,9 +68,34 @@ public:
|
||||
NS_IMETHOD
|
||||
UserAgent(const char* *result);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsINetworkManager:
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
const char* altHost = NULL,
|
||||
const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE);
|
||||
|
||||
NS_IMETHOD
|
||||
PostURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
PRUint32 postDataLen,
|
||||
const char* postData,
|
||||
PRBool isFile = PR_FALSE,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
const char* altHost = NULL,
|
||||
const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0,
|
||||
const char* postHeaders = NULL);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* peer, const char* url, const char* target,
|
||||
void* notifyData = NULL, const char* altHost = NULL,
|
||||
@ -84,8 +109,7 @@ public:
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL);
|
||||
|
||||
NS_IMETHOD
|
||||
FindProxyForURL(const char* url, char* *result);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
};
|
||||
|
||||
@ -235,6 +259,92 @@ protected:
|
||||
char** values_list;
|
||||
};
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
class CPluginInputStream : public nsIPluginInputStream {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIBaseStream:
|
||||
|
||||
/** Close the stream. */
|
||||
NS_IMETHOD
|
||||
Close(void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIInputStream:
|
||||
|
||||
/** Return the number of bytes in the stream
|
||||
* @param aLength out parameter to hold the length
|
||||
* of the stream. if an error occurs, the length
|
||||
* will be undefined
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetLength(PRInt32 *aLength);
|
||||
|
||||
/** Read data from the stream.
|
||||
* @param aErrorCode the error code if an error occurs
|
||||
* @param aBuf the buffer into which the data is read
|
||||
* @param aOffset the start offset of the data
|
||||
* @param aCount the maximum number of bytes to read
|
||||
* @param aReadCount out parameter to hold the number of
|
||||
* bytes read, eof if 0. if an error occurs, the
|
||||
* read count will be undefined
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginInputStream:
|
||||
|
||||
// (Corresponds to NPStream's lastmodified field.)
|
||||
NS_IMETHOD
|
||||
GetLastModified(PRUint32 *result);
|
||||
|
||||
NS_IMETHOD
|
||||
RequestRead(nsByteRange* rangeList);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CPluginInputStream specific methods:
|
||||
|
||||
CPluginInputStream(nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType);
|
||||
virtual ~CPluginInputStream(void);
|
||||
|
||||
void SetStreamInfo(NPP npp, NPStream* stream) {
|
||||
mNPP = npp;
|
||||
mStream = stream;
|
||||
}
|
||||
|
||||
nsIPluginStreamListener* GetListener(void) { return mListener; }
|
||||
nsPluginStreamType GetStreamType(void) { return mStreamType; }
|
||||
|
||||
nsresult SetReadBuffer(PRUint32 len, const char* buffer) {
|
||||
// XXX this has to be way more sophisticated
|
||||
mBuffer = strdup(buffer);
|
||||
mBufferLength = len;
|
||||
mAmountRead = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* mURL;
|
||||
nsIPluginStreamListener* mListener;
|
||||
nsPluginStreamType mStreamType;
|
||||
NPP mNPP;
|
||||
NPStream* mStream;
|
||||
char* mBuffer;
|
||||
PRUint32 mBufferLength;
|
||||
PRUint32 mAmountRead;
|
||||
|
||||
};
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CPluginStreamPeer
|
||||
@ -299,6 +409,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef XP_UNIX
|
||||
@ -350,8 +462,13 @@ NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
||||
NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
||||
NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID);
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
NS_DEFINE_IID(kIPluginInputStreamIID, NS_IPLUGININPUTSTREAM_IID);
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID);
|
||||
NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// mapping from NPError to nsresult
|
||||
nsresult fromNPError[] = {
|
||||
@ -510,18 +627,19 @@ jref
|
||||
NPP_GetJavaClass(void)
|
||||
{
|
||||
// Only call initialize the plugin if it hasn't been `d.
|
||||
/* if (thePluginManager == NULL) {
|
||||
#if 0
|
||||
if (thePluginManager == NULL) {
|
||||
// Create the plugin manager and plugin objects.
|
||||
NPError result = CPluginManager::Create();
|
||||
if (result) return NULL;
|
||||
assert( thePluginManager != NULL );
|
||||
assert( thePluginManager != NULL );
|
||||
thePluginManager->AddRef();
|
||||
NP_CreatePlugin(thePluginManager, (nsIPlugin** )(&thePlugin));
|
||||
assert( thePlugin != NULL );
|
||||
}
|
||||
*/
|
||||
// return thePlugin->GetJavaClass();
|
||||
return NULL;
|
||||
}
|
||||
return thePlugin->GetJavaClass();
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -535,19 +653,19 @@ NPP_GetJavaClass(void)
|
||||
void
|
||||
NPP_Shutdown(void)
|
||||
{
|
||||
// TRACE("NPP_Shutdown\n");
|
||||
// TRACE("NPP_Shutdown\n");
|
||||
|
||||
if (thePlugin)
|
||||
{
|
||||
thePlugin->Shutdown();
|
||||
thePlugin->Release();
|
||||
thePlugin = NULL;
|
||||
}
|
||||
if (thePlugin)
|
||||
{
|
||||
thePlugin->Shutdown();
|
||||
thePlugin->Release();
|
||||
thePlugin = NULL;
|
||||
}
|
||||
|
||||
if (thePluginManager) {
|
||||
thePluginManager->Release();
|
||||
thePluginManager = NULL;
|
||||
}
|
||||
if (thePluginManager) {
|
||||
thePluginManager->Release();
|
||||
thePluginManager = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -664,10 +782,10 @@ NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
|
||||
NPError
|
||||
NPP_NewStream(NPP instance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
PRUint16 *stype)
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
PRUint16 *stype)
|
||||
{
|
||||
// XXX - How do you set the fields of the peer stream and stream?
|
||||
// XXX - Looks like these field will have to be created since
|
||||
@ -678,11 +796,29 @@ NPP_NewStream(NPP instance,
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->notifyData;
|
||||
if (inStr == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
nsPluginStreamInfo info;
|
||||
info.contentType = type;
|
||||
info.seekable = seekable;
|
||||
nsresult err = inStr->GetListener()->OnStartBinding(stream->url, &info);
|
||||
if (err) return err;
|
||||
|
||||
inStr->SetStreamInfo(instance, stream);
|
||||
stream->pdata = inStr;
|
||||
*stype = inStr->GetStreamType();
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// Create a new plugin stream peer and plugin stream.
|
||||
CPluginStreamPeer* speer = new CPluginStreamPeer((nsMIMEType)type, stream,
|
||||
(PRBool)seekable, stype);
|
||||
if (speer == NULL) return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
speer->AddRef();
|
||||
|
||||
nsIPluginStream* pluginStream = NULL;
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
@ -697,6 +833,8 @@ NPP_NewStream(NPP instance,
|
||||
err = pluginStream->GetStreamType((nsPluginStreamType*)stype);
|
||||
assert(err == NS_OK);
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
@ -714,11 +852,22 @@ NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
if (instance == NULL)
|
||||
return -1;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return -1;
|
||||
return NP_MAXREADY;
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return -1;
|
||||
|
||||
return 8192;
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
|
||||
|
||||
@ -735,6 +884,19 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
if (instance == NULL)
|
||||
return -1;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return -1;
|
||||
nsresult err = inStr->SetReadBuffer((PRUint32)len, (const char*)buffer);
|
||||
if (err != NS_OK) return -1;
|
||||
err = inStr->GetListener()->OnDataAvailable(stream->url, inStr, offset, len);
|
||||
if (err != NS_OK) return -1;
|
||||
return len;
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return -1;
|
||||
@ -742,6 +904,8 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
PRInt32 count;
|
||||
nsresult err = theStream->Write((const char* )buffer, offset, len, &count);
|
||||
return (err == NS_OK) ? count : -1;
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -760,12 +924,25 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
inStr->GetListener()->OnStopBinding(stream->url, (nsPluginReason)reason);
|
||||
inStr->Release();
|
||||
stream->pdata = NULL;
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
theStream->Release();
|
||||
stream->pdata = NULL;
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
@ -778,16 +955,27 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
|
||||
void
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
// TRACE("NPP_StreamAsFile\n");
|
||||
// TRACE("NPP_StreamAsFile\n");
|
||||
|
||||
if (instance == NULL)
|
||||
return;
|
||||
if (instance == NULL)
|
||||
return;
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return;
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
theStream->AsFile( fname );
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return;
|
||||
(void)inStr->GetListener()->OnFileAvailable(stream->url, fname);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return;
|
||||
|
||||
theStream->AsFile( fname );
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -802,12 +990,12 @@ NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
if(printInfo == NULL) // trap invalid parm
|
||||
return;
|
||||
|
||||
if (instance != NULL)
|
||||
{
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->Print((nsPluginPrint* ) printInfo );
|
||||
}
|
||||
if (instance != NULL)
|
||||
{
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->Print((nsPluginPrint* ) printInfo );
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -818,14 +1006,22 @@ NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
void
|
||||
NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
// TRACE("NPP_URLNotify\n");
|
||||
// TRACE("NPP_URLNotify\n");
|
||||
|
||||
if( instance != NULL )
|
||||
{
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->URLNotify(url, NULL, (nsPluginReason)reason, notifyData);
|
||||
}
|
||||
if (instance != NULL) {
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)notifyData;
|
||||
(void)inStr->GetListener()->OnStopBinding(url, (nsPluginReason)reason);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->URLNotify(url, NULL, (nsPluginReason)reason, notifyData);
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -839,29 +1035,29 @@ int16
|
||||
NPP_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
// TRACE("NPP_HandleEvent\n");
|
||||
int16 eventHandled = FALSE;
|
||||
if (instance == NULL)
|
||||
return eventHandled;
|
||||
int16 eventHandled = FALSE;
|
||||
if (instance == NULL)
|
||||
return eventHandled;
|
||||
|
||||
NPEvent* npEvent = (NPEvent*) event;
|
||||
nsPluginEvent pluginEvent = {
|
||||
NPEvent* npEvent = (NPEvent*) event;
|
||||
nsPluginEvent pluginEvent = {
|
||||
#ifdef XP_MAC
|
||||
npEvent, NULL
|
||||
npEvent, NULL
|
||||
#else
|
||||
npEvent->event, npEvent->wParam, npEvent->lParam
|
||||
npEvent->event, npEvent->wParam, npEvent->lParam
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
if (pluginInstance) {
|
||||
if (pluginInstance) {
|
||||
PRBool handled;
|
||||
nsresult err = pluginInstance->HandleEvent(&pluginEvent, &handled);
|
||||
nsresult err = pluginInstance->HandleEvent(&pluginEvent, &handled);
|
||||
if (err) return FALSE;
|
||||
eventHandled = (handled == PR_TRUE);
|
||||
}
|
||||
|
||||
return eventHandled;
|
||||
return eventHandled;
|
||||
}
|
||||
#endif // ndef XP_UNIX
|
||||
|
||||
@ -923,9 +1119,9 @@ NS_METHOD
|
||||
CPluginManager::MemFlush(PRUint32 size)
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
return NPN_MemFlush(size);
|
||||
return NPN_MemFlush(size);
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -937,10 +1133,109 @@ CPluginManager::MemFlush(PRUint32 size)
|
||||
NS_METHOD
|
||||
CPluginManager::ReloadPlugins(PRBool reloadPages)
|
||||
{
|
||||
NPN_ReloadPlugins(reloadPages);
|
||||
NPN_ReloadPlugins(reloadPages);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_METHOD
|
||||
CPluginManager::GetURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* streamListener,
|
||||
nsPluginStreamType streamType,
|
||||
const char* altHost,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled)
|
||||
{
|
||||
if (altHost != NULL || referrer != NULL || forceJSEnabled != PR_FALSE) {
|
||||
return NPERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
nsIPluginInstance* inst = NULL;
|
||||
nsresult rslt = pluginInst->QueryInterface(kIPluginInstanceIID, (void**)&inst);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
CPluginInstancePeer* instancePeer = NULL;
|
||||
rslt = inst->GetPeer((nsIPluginInstancePeer**)&instancePeer);
|
||||
if (rslt != NS_OK) {
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
if (streamListener) {
|
||||
CPluginInputStream* inStr = new CPluginInputStream(streamListener, streamType);
|
||||
if (inStr == NULL) {
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
inStr->AddRef();
|
||||
|
||||
err = NPN_GetURLNotify(npp, url, target, inStr);
|
||||
}
|
||||
else {
|
||||
err = NPN_GetURL(npp, url, target);
|
||||
}
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginManager::PostURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
PRUint32 postDataLen,
|
||||
const char* postData,
|
||||
PRBool isFile,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* streamListener,
|
||||
nsPluginStreamType streamType,
|
||||
const char* altHost,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled,
|
||||
PRUint32 postHeadersLength,
|
||||
const char* postHeaders)
|
||||
{
|
||||
if (altHost != NULL || referrer != NULL || forceJSEnabled != PR_FALSE
|
||||
|| postHeadersLength != 0 || postHeaders != NULL) {
|
||||
return NPERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
nsIPluginInstance* inst = NULL;
|
||||
nsresult rslt = pluginInst->QueryInterface(kIPluginInstanceIID, (void**)&inst);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
CPluginInstancePeer* instancePeer = NULL;
|
||||
rslt = inst->GetPeer((nsIPluginInstancePeer**)&instancePeer);
|
||||
if (rslt != NS_OK) {
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
if (streamListener) {
|
||||
CPluginInputStream* inStr = new CPluginInputStream(streamListener, streamType);
|
||||
if (inStr == NULL) {
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
inStr->AddRef();
|
||||
|
||||
err = NPN_PostURLNotify(npp, url, target, postDataLen, postData, isFile, inStr);
|
||||
}
|
||||
else {
|
||||
err = NPN_PostURL(npp, url, target, postDataLen, postData, isFile);
|
||||
}
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
|
||||
// notifyData: When present, URLNotify is called passing the notifyData back
|
||||
@ -968,7 +1263,7 @@ CPluginManager::GetURL(nsISupports* pinst, const char* url, const char* target,
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
// Call the correct GetURL* function.
|
||||
@ -1001,7 +1296,7 @@ CPluginManager::PostURL(nsISupports* pinst, const char* url, const char* target,
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
// Call the correct PostURL* function.
|
||||
@ -1016,11 +1311,7 @@ CPluginManager::PostURL(nsISupports* pinst, const char* url, const char* target,
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginManager::FindProxyForURL(const char* url, char* *result)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// UserAgent:
|
||||
@ -1122,33 +1413,33 @@ CPluginInstancePeer::CPluginInstancePeer(nsIPluginInstance* pluginInstance,
|
||||
|
||||
mInstance->AddRef();
|
||||
|
||||
attribute_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
values_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
attribute_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
values_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
attribute_list[i] = (char*) NPN_MemAlloc(strlen(attr_list[i]) + 1);
|
||||
if (attribute_list[i] != NULL)
|
||||
strcpy(attribute_list[i], attr_list[i]);
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
attribute_list[i] = (char*) NPN_MemAlloc(strlen(attr_list[i]) + 1);
|
||||
if (attribute_list[i] != NULL)
|
||||
strcpy(attribute_list[i], attr_list[i]);
|
||||
|
||||
values_list[i] = (char*) NPN_MemAlloc(strlen(val_list[i]) + 1);
|
||||
if (values_list[i] != NULL)
|
||||
strcpy(values_list[i], val_list[i]);
|
||||
}
|
||||
}
|
||||
values_list[i] = (char*) NPN_MemAlloc(strlen(val_list[i]) + 1);
|
||||
if (values_list[i] != NULL)
|
||||
strcpy(values_list[i], val_list[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPluginInstancePeer::~CPluginInstancePeer(void)
|
||||
{
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
NPN_MemFree(attribute_list[i]);
|
||||
NPN_MemFree(values_list[i]);
|
||||
}
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
NPN_MemFree(attribute_list[i]);
|
||||
NPN_MemFree(values_list[i]);
|
||||
}
|
||||
|
||||
NPN_MemFree(attribute_list);
|
||||
NPN_MemFree(values_list);
|
||||
}
|
||||
NPN_MemFree(attribute_list);
|
||||
NPN_MemFree(values_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1212,45 +1503,45 @@ CPluginInstancePeer::GetMode(nsPluginMode *result)
|
||||
NS_METHOD
|
||||
CPluginInstancePeer::GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values)
|
||||
{
|
||||
n = attribute_cnt;
|
||||
names = attribute_list;
|
||||
values = values_list;
|
||||
n = attribute_cnt;
|
||||
names = attribute_list;
|
||||
values = values_list;
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_MAC)
|
||||
|
||||
inline unsigned char toupper(unsigned char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
|
||||
return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
|
||||
}
|
||||
|
||||
static int strcasecmp(const char * str1, const char * str2)
|
||||
{
|
||||
#if __POWERPC__
|
||||
|
||||
const unsigned char * p1 = (unsigned char *) str1 - 1;
|
||||
const unsigned char * p2 = (unsigned char *) str2 - 1;
|
||||
unsigned long c1, c2;
|
||||
const unsigned char * p1 = (unsigned char *) str1 - 1;
|
||||
const unsigned char * p2 = (unsigned char *) str2 - 1;
|
||||
unsigned long c1, c2;
|
||||
|
||||
while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
|
||||
if (!c1)
|
||||
return(0);
|
||||
while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
|
||||
if (!c1)
|
||||
return(0);
|
||||
|
||||
#else
|
||||
|
||||
const unsigned char * p1 = (unsigned char *) str1;
|
||||
const unsigned char * p2 = (unsigned char *) str2;
|
||||
unsigned char c1, c2;
|
||||
const unsigned char * p1 = (unsigned char *) str1;
|
||||
const unsigned char * p2 = (unsigned char *) str2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
|
||||
if (!c1)
|
||||
return(0);
|
||||
while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
|
||||
if (!c1)
|
||||
return(0);
|
||||
|
||||
#endif
|
||||
|
||||
return(toupper(c1) - toupper(c2));
|
||||
return(toupper(c1) - toupper(c2));
|
||||
}
|
||||
|
||||
#endif /* XP_MAC */
|
||||
@ -1260,19 +1551,19 @@ static int strcasecmp(const char * str1, const char * str2)
|
||||
NS_METHOD
|
||||
CPluginInstancePeer::GetAttribute(const char* name, const char* *result)
|
||||
{
|
||||
for (int i=0; i < attribute_cnt; i++) {
|
||||
for (int i=0; i < attribute_cnt; i++) {
|
||||
#if defined(XP_UNIX) || defined(XP_MAC)
|
||||
if (strcasecmp(name, attribute_list[i]) == 0)
|
||||
if (strcasecmp(name, attribute_list[i]) == 0)
|
||||
#else
|
||||
if (stricmp(name, attribute_list[i]) == 0)
|
||||
if (stricmp(name, attribute_list[i]) == 0)
|
||||
#endif
|
||||
{
|
||||
*result = values_list[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
{
|
||||
*result = values_list[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -1280,7 +1571,7 @@ CPluginInstancePeer::GetAttribute(const char* name, const char* *result)
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
NS_METHOD
|
||||
CPluginInstancePeer::NewStream(nsMIMEType type, const char* target,
|
||||
nsIOutputStream* *result)
|
||||
nsIOutputStream* *result)
|
||||
{
|
||||
assert( npp != NULL );
|
||||
|
||||
@ -1464,13 +1755,77 @@ NS_IMPL_QUERY_INTERFACE(CPluginManagerStream, kIOutputStreamIID);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream::CPluginInputStream(nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType)
|
||||
: mListener(listener), mStreamType(streamType),
|
||||
mNPP(NULL), mStream(NULL),
|
||||
mBuffer(NULL), mBufferLength(0), mAmountRead(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mListener->AddRef();
|
||||
}
|
||||
|
||||
CPluginInputStream::~CPluginInputStream(void)
|
||||
{
|
||||
mListener->Release();
|
||||
free(mBuffer);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(CPluginInputStream, kIPluginInputStreamIID);
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::Close(void)
|
||||
{
|
||||
if (mNPP == NULL || mStream == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
NPError err = NPN_DestroyStream(mNPP, mStream, NPRES_USER_BREAK);
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::GetLength(PRInt32 *aLength)
|
||||
{
|
||||
*aLength = mStream->end;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount)
|
||||
{
|
||||
if (aOffset > (PRInt32)mBufferLength)
|
||||
return NS_ERROR_FAILURE; // XXX right error?
|
||||
PRUint32 cnt = PR_MIN(aCount, (PRInt32)mBufferLength - aOffset);
|
||||
memcpy(aBuf, &mBuffer[aOffset], cnt);
|
||||
*aReadCount = cnt;
|
||||
mAmountRead -= cnt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::GetLastModified(PRUint32 *result)
|
||||
{
|
||||
*result = mStream->lastmodified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::RequestRead(nsByteRange* rangeList)
|
||||
{
|
||||
NPError err = NPN_RequestRead(mStream, (NPByteRange*)rangeList);
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CPluginStreamPeer
|
||||
//
|
||||
|
||||
CPluginStreamPeer::CPluginStreamPeer(nsMIMEType type, NPStream* npStream,
|
||||
PRBool seekable, PRUint16* stype)
|
||||
PRBool seekable, PRUint16* stype)
|
||||
: type(type), npStream(npStream), seekable(seekable),
|
||||
stype(stype), reason(nsPluginReason_NoReason)
|
||||
{
|
||||
@ -1583,6 +1938,8 @@ nsresult CPluginStreamPeer::QueryInterface(const nsIID& iid, void** ptr)
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -33,13 +33,20 @@ EXPORTS = \
|
||||
nsIPluginManager.h \
|
||||
nsIPluginManager2.h \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsIPluginTagInfo.h \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h
|
||||
|
||||
# DEPRECATED -- remove before we ship 5.0
|
||||
EXPORTS += \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
@ -38,15 +38,22 @@ EXPORTS = \
|
||||
nsIPluginManager.h \
|
||||
nsIPluginManager2.h \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsIPluginTagInfo.h \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h
|
||||
|
||||
# DEPRECATED -- remove before we ship 5.0
|
||||
EXPORTS += \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -34,15 +34,21 @@ EXPORTS = \
|
||||
nsIPluginInstancePeer.h \
|
||||
nsIPluginManager.h \
|
||||
nsIPluginManager2.h \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsIPluginTagInfo.h \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h
|
||||
|
||||
# DEPRECATED -- remove before we ship 5.0
|
||||
EXPORTS = $(EXPORTS) \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
|
@ -126,6 +126,7 @@ public:
|
||||
NS_IMETHOD
|
||||
SetWindow(nsPluginWindow* window) = 0;
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
/**
|
||||
* Called when a new plugin stream must be constructed in order for the plugin
|
||||
* instance to receive a stream of data from the browser.
|
||||
@ -139,6 +140,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to print itself to a printer.
|
||||
@ -151,6 +153,7 @@ 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).
|
||||
@ -166,6 +169,7 @@ public:
|
||||
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.
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIPluginStreamListener;
|
||||
|
||||
/**
|
||||
* The nsIPluginManager interface defines the minimum set of functionality that
|
||||
* the browser will support if it allows plugins. Plugins can call QueryInterface
|
||||
@ -82,11 +84,41 @@ 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,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
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,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
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.
|
||||
*
|
||||
* (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
|
||||
*
|
||||
* @param pluginInst - the plugin making the request. If NULL, the URL
|
||||
* is fetched in the background.
|
||||
* @param url - the URL to fetch
|
||||
* @param target - the target window into which to load the URL
|
||||
* @param notifyData - when present, URLNotify is called passing the
|
||||
@ -102,7 +134,7 @@ public:
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* peer, const char* url, const char* target,
|
||||
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;
|
||||
|
||||
@ -111,6 +143,8 @@ public:
|
||||
*
|
||||
* (Corresponds to NPN_PostURL and NPN_PostURLNotify.)
|
||||
*
|
||||
* @param pluginInst - the plugin making the request. If NULL, the URL
|
||||
* is fetched in the background.
|
||||
* @param url - the URL to fetch
|
||||
* @param target - the target window into which to load the URL
|
||||
* @param postDataLength - the length of postData (if non-NULL)
|
||||
@ -134,12 +168,13 @@ public:
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
PostURL(nsISupports* peer, const char* url, const char* target,
|
||||
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,
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0;
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
};
|
||||
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
NS_IMETHOD
|
||||
HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result) = 0;
|
||||
|
||||
#if 0 // problematic
|
||||
/**
|
||||
* This operation causes the next browser event to be processed. This is
|
||||
* handy for implement nested event loops where some other activity must
|
||||
@ -171,7 +172,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
ProcessNextEvent(PRBool *bEventHandled) = 0;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_IPLUGINMANAGER2_IID \
|
||||
|
@ -34,13 +34,15 @@
|
||||
#ifndef nsIPluginStream_h___
|
||||
#define nsIPluginStream_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
/**
|
||||
* The nsIPluginStream interface specifies the minimal set of operations that
|
||||
* must be implemented by a plugin stream in order to receive data from the
|
||||
* browser. When a nsIPluginManager::FetchURL request is made, a subsequent
|
||||
* browser. When a nsIPluginManager::GetURL request is made, a subsequent
|
||||
* nsIPluginInstance::NewStream request will be made to instruct the plugin
|
||||
* instance to construct a new stream to receive the data.
|
||||
*/
|
||||
@ -80,6 +82,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStream_h___ */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#ifndef nsIPluginStreamPeer_h___
|
||||
#define nsIPluginStreamPeer_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
@ -80,6 +82,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStreamPeer_h___ */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#ifndef nsIPluginStreamPeer2_h___
|
||||
#define nsIPluginStreamPeer2_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsIPluginStreamPeer.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -65,6 +67,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStreamPeer2_h___ */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#ifndef nsISeekablePluginStreamPeer_h___
|
||||
#define nsISeekablePluginStreamPeer_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
@ -63,6 +65,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsISeekablePluginStreamPeer_h___ */
|
||||
|
@ -57,11 +57,10 @@
|
||||
* | v v
|
||||
* | +---------------------------------+ +----------------------------+
|
||||
* | | nsIPluginInstancePeer |+ | nsIPluginStreamPeer |+
|
||||
* | | nsIPluginInstancePeer2 || | nsISeekablePluginStreamPeer||
|
||||
* | | nsIWindowlessPluginInstancePeer || | nsIPluginstreamPeer2 ||
|
||||
* | | nsILiveConnectPluginInstancePeer|| +----------------------------+|
|
||||
* | | nsIPluginTagInfo || +---------------------------+
|
||||
* | | nsIPluginTagInfo2 ||
|
||||
* | | nsIWindowlessPluginInstancePeer || | nsISeekablePluginStreamPeer||
|
||||
* | | nsILiveConnectPluginInstancePeer|| | nsIPluginstreamPeer2 ||
|
||||
* | | nsIPluginTagInfo || +----------------------------+|
|
||||
* | | nsIPluginTagInfo2 || +---------------------------+
|
||||
* | +---------------------------------+|
|
||||
* | +--------------------------------+
|
||||
* |
|
||||
@ -110,12 +109,23 @@
|
||||
*/
|
||||
#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
|
||||
@ -162,6 +172,15 @@
|
||||
*/
|
||||
#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
|
||||
@ -177,6 +196,8 @@
|
||||
*/
|
||||
#include "nsISeekablePluginStreamPeer.h"
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* <B>Interfaces implemented by the browser (new for 5.0):
|
||||
@ -210,6 +231,15 @@
|
||||
*/
|
||||
#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.
|
||||
@ -218,6 +248,8 @@
|
||||
*/
|
||||
#include "nsIPluginStreamPeer2.h"
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
/**
|
||||
* The nsIPluginTagInfo2 interface provides additional html tag information
|
||||
* only available in Communicator 5.0.
|
||||
@ -226,5 +258,7 @@
|
||||
*/
|
||||
#include "nsIPluginTagInfo2.h"
|
||||
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // nsplugins_h___
|
||||
|
@ -33,13 +33,20 @@ EXPORTS = \
|
||||
nsIPluginManager.h \
|
||||
nsIPluginManager2.h \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsIPluginTagInfo.h \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h
|
||||
|
||||
# DEPRECATED -- remove before we ship 5.0
|
||||
EXPORTS += \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
@ -38,15 +38,22 @@ EXPORTS = \
|
||||
nsIPluginManager.h \
|
||||
nsIPluginManager2.h \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsIPluginTagInfo.h \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h
|
||||
|
||||
# DEPRECATED -- remove before we ship 5.0
|
||||
EXPORTS += \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -34,15 +34,21 @@ EXPORTS = \
|
||||
nsIPluginInstancePeer.h \
|
||||
nsIPluginManager.h \
|
||||
nsIPluginManager2.h \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsIPluginTagInfo.h \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h
|
||||
|
||||
# DEPRECATED -- remove before we ship 5.0
|
||||
EXPORTS = $(EXPORTS) \
|
||||
nsIPluginStream.h \
|
||||
nsIPluginStreamPeer.h \
|
||||
nsIPluginStreamPeer2.h \
|
||||
nsISeekablePluginStreamPeer.h \
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
|
@ -126,6 +126,7 @@ public:
|
||||
NS_IMETHOD
|
||||
SetWindow(nsPluginWindow* window) = 0;
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
/**
|
||||
* Called when a new plugin stream must be constructed in order for the plugin
|
||||
* instance to receive a stream of data from the browser.
|
||||
@ -139,6 +140,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Called to instruct the plugin instance to print itself to a printer.
|
||||
@ -151,6 +153,7 @@ 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).
|
||||
@ -166,6 +169,7 @@ public:
|
||||
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.
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIPluginStreamListener;
|
||||
|
||||
/**
|
||||
* The nsIPluginManager interface defines the minimum set of functionality that
|
||||
* the browser will support if it allows plugins. Plugins can call QueryInterface
|
||||
@ -82,11 +84,41 @@ 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,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
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,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
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.
|
||||
*
|
||||
* (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
|
||||
*
|
||||
* @param pluginInst - the plugin making the request. If NULL, the URL
|
||||
* is fetched in the background.
|
||||
* @param url - the URL to fetch
|
||||
* @param target - the target window into which to load the URL
|
||||
* @param notifyData - when present, URLNotify is called passing the
|
||||
@ -102,7 +134,7 @@ public:
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* peer, const char* url, const char* target,
|
||||
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;
|
||||
|
||||
@ -111,6 +143,8 @@ public:
|
||||
*
|
||||
* (Corresponds to NPN_PostURL and NPN_PostURLNotify.)
|
||||
*
|
||||
* @param pluginInst - the plugin making the request. If NULL, the URL
|
||||
* is fetched in the background.
|
||||
* @param url - the URL to fetch
|
||||
* @param target - the target window into which to load the URL
|
||||
* @param postDataLength - the length of postData (if non-NULL)
|
||||
@ -134,12 +168,13 @@ public:
|
||||
* @result - NS_OK if this operation was successful
|
||||
*/
|
||||
NS_IMETHOD
|
||||
PostURL(nsISupports* peer, const char* url, const char* target,
|
||||
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,
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL) = 0;
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
};
|
||||
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
NS_IMETHOD
|
||||
HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result) = 0;
|
||||
|
||||
#if 0 // problematic
|
||||
/**
|
||||
* This operation causes the next browser event to be processed. This is
|
||||
* handy for implement nested event loops where some other activity must
|
||||
@ -171,7 +172,7 @@ public:
|
||||
*/
|
||||
NS_IMETHOD
|
||||
ProcessNextEvent(PRBool *bEventHandled) = 0;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#define NS_IPLUGINMANAGER2_IID \
|
||||
|
@ -34,13 +34,15 @@
|
||||
#ifndef nsIPluginStream_h___
|
||||
#define nsIPluginStream_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
/**
|
||||
* The nsIPluginStream interface specifies the minimal set of operations that
|
||||
* must be implemented by a plugin stream in order to receive data from the
|
||||
* browser. When a nsIPluginManager::FetchURL request is made, a subsequent
|
||||
* browser. When a nsIPluginManager::GetURL request is made, a subsequent
|
||||
* nsIPluginInstance::NewStream request will be made to instruct the plugin
|
||||
* instance to construct a new stream to receive the data.
|
||||
*/
|
||||
@ -80,6 +82,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStream_h___ */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#ifndef nsIPluginStreamPeer_h___
|
||||
#define nsIPluginStreamPeer_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
@ -80,6 +82,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStreamPeer_h___ */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#ifndef nsIPluginStreamPeer2_h___
|
||||
#define nsIPluginStreamPeer2_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsIPluginStreamPeer.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -65,6 +67,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStreamPeer2_h___ */
|
||||
|
@ -34,6 +34,8 @@
|
||||
#ifndef nsISeekablePluginStreamPeer_h___
|
||||
#define nsISeekablePluginStreamPeer_h___
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
@ -63,6 +65,8 @@ public:
|
||||
{0x81, 0x5b, 0x00, 0x60, 0x08, 0x11, 0x9d, 0x7a} \
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsISeekablePluginStreamPeer_h___ */
|
||||
|
@ -57,11 +57,10 @@
|
||||
* | v v
|
||||
* | +---------------------------------+ +----------------------------+
|
||||
* | | nsIPluginInstancePeer |+ | nsIPluginStreamPeer |+
|
||||
* | | nsIPluginInstancePeer2 || | nsISeekablePluginStreamPeer||
|
||||
* | | nsIWindowlessPluginInstancePeer || | nsIPluginstreamPeer2 ||
|
||||
* | | nsILiveConnectPluginInstancePeer|| +----------------------------+|
|
||||
* | | nsIPluginTagInfo || +---------------------------+
|
||||
* | | nsIPluginTagInfo2 ||
|
||||
* | | nsIWindowlessPluginInstancePeer || | nsISeekablePluginStreamPeer||
|
||||
* | | nsILiveConnectPluginInstancePeer|| | nsIPluginstreamPeer2 ||
|
||||
* | | nsIPluginTagInfo || +----------------------------+|
|
||||
* | | nsIPluginTagInfo2 || +---------------------------+
|
||||
* | +---------------------------------+|
|
||||
* | +--------------------------------+
|
||||
* |
|
||||
@ -110,12 +109,23 @@
|
||||
*/
|
||||
#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
|
||||
@ -162,6 +172,15 @@
|
||||
*/
|
||||
#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
|
||||
@ -177,6 +196,8 @@
|
||||
*/
|
||||
#include "nsISeekablePluginStreamPeer.h"
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* <B>Interfaces implemented by the browser (new for 5.0):
|
||||
@ -210,6 +231,15 @@
|
||||
*/
|
||||
#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.
|
||||
@ -218,6 +248,8 @@
|
||||
*/
|
||||
#include "nsIPluginStreamPeer2.h"
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
/**
|
||||
* The nsIPluginTagInfo2 interface provides additional html tag information
|
||||
* only available in Communicator 5.0.
|
||||
@ -226,5 +258,7 @@
|
||||
*/
|
||||
#include "nsIPluginTagInfo2.h"
|
||||
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#endif // nsplugins_h___
|
||||
|
@ -68,9 +68,34 @@ public:
|
||||
NS_IMETHOD
|
||||
UserAgent(const char* *result);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsINetworkManager:
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
const char* altHost = NULL,
|
||||
const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE);
|
||||
|
||||
NS_IMETHOD
|
||||
PostURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
PRUint32 postDataLen,
|
||||
const char* postData,
|
||||
PRBool isFile = PR_FALSE,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
const char* altHost = NULL,
|
||||
const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0,
|
||||
const char* postHeaders = NULL);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* peer, const char* url, const char* target,
|
||||
void* notifyData = NULL, const char* altHost = NULL,
|
||||
@ -84,8 +109,7 @@ public:
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL);
|
||||
|
||||
NS_IMETHOD
|
||||
FindProxyForURL(const char* url, char* *result);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
};
|
||||
|
||||
@ -235,6 +259,92 @@ protected:
|
||||
char** values_list;
|
||||
};
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
class CPluginInputStream : public nsIPluginInputStream {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIBaseStream:
|
||||
|
||||
/** Close the stream. */
|
||||
NS_IMETHOD
|
||||
Close(void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIInputStream:
|
||||
|
||||
/** Return the number of bytes in the stream
|
||||
* @param aLength out parameter to hold the length
|
||||
* of the stream. if an error occurs, the length
|
||||
* will be undefined
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetLength(PRInt32 *aLength);
|
||||
|
||||
/** Read data from the stream.
|
||||
* @param aErrorCode the error code if an error occurs
|
||||
* @param aBuf the buffer into which the data is read
|
||||
* @param aOffset the start offset of the data
|
||||
* @param aCount the maximum number of bytes to read
|
||||
* @param aReadCount out parameter to hold the number of
|
||||
* bytes read, eof if 0. if an error occurs, the
|
||||
* read count will be undefined
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginInputStream:
|
||||
|
||||
// (Corresponds to NPStream's lastmodified field.)
|
||||
NS_IMETHOD
|
||||
GetLastModified(PRUint32 *result);
|
||||
|
||||
NS_IMETHOD
|
||||
RequestRead(nsByteRange* rangeList);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// CPluginInputStream specific methods:
|
||||
|
||||
CPluginInputStream(nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType);
|
||||
virtual ~CPluginInputStream(void);
|
||||
|
||||
void SetStreamInfo(NPP npp, NPStream* stream) {
|
||||
mNPP = npp;
|
||||
mStream = stream;
|
||||
}
|
||||
|
||||
nsIPluginStreamListener* GetListener(void) { return mListener; }
|
||||
nsPluginStreamType GetStreamType(void) { return mStreamType; }
|
||||
|
||||
nsresult SetReadBuffer(PRUint32 len, const char* buffer) {
|
||||
// XXX this has to be way more sophisticated
|
||||
mBuffer = strdup(buffer);
|
||||
mBufferLength = len;
|
||||
mAmountRead = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* mURL;
|
||||
nsIPluginStreamListener* mListener;
|
||||
nsPluginStreamType mStreamType;
|
||||
NPP mNPP;
|
||||
NPStream* mStream;
|
||||
char* mBuffer;
|
||||
PRUint32 mBufferLength;
|
||||
PRUint32 mAmountRead;
|
||||
|
||||
};
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CPluginStreamPeer
|
||||
@ -299,6 +409,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef XP_UNIX
|
||||
@ -350,8 +462,13 @@ NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
||||
NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
||||
NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID);
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
NS_DEFINE_IID(kIPluginInputStreamIID, NS_IPLUGININPUTSTREAM_IID);
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID);
|
||||
NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// mapping from NPError to nsresult
|
||||
nsresult fromNPError[] = {
|
||||
@ -510,18 +627,19 @@ jref
|
||||
NPP_GetJavaClass(void)
|
||||
{
|
||||
// Only call initialize the plugin if it hasn't been `d.
|
||||
/* if (thePluginManager == NULL) {
|
||||
#if 0
|
||||
if (thePluginManager == NULL) {
|
||||
// Create the plugin manager and plugin objects.
|
||||
NPError result = CPluginManager::Create();
|
||||
if (result) return NULL;
|
||||
assert( thePluginManager != NULL );
|
||||
assert( thePluginManager != NULL );
|
||||
thePluginManager->AddRef();
|
||||
NP_CreatePlugin(thePluginManager, (nsIPlugin** )(&thePlugin));
|
||||
assert( thePlugin != NULL );
|
||||
}
|
||||
*/
|
||||
// return thePlugin->GetJavaClass();
|
||||
return NULL;
|
||||
}
|
||||
return thePlugin->GetJavaClass();
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -535,19 +653,19 @@ NPP_GetJavaClass(void)
|
||||
void
|
||||
NPP_Shutdown(void)
|
||||
{
|
||||
// TRACE("NPP_Shutdown\n");
|
||||
// TRACE("NPP_Shutdown\n");
|
||||
|
||||
if (thePlugin)
|
||||
{
|
||||
thePlugin->Shutdown();
|
||||
thePlugin->Release();
|
||||
thePlugin = NULL;
|
||||
}
|
||||
if (thePlugin)
|
||||
{
|
||||
thePlugin->Shutdown();
|
||||
thePlugin->Release();
|
||||
thePlugin = NULL;
|
||||
}
|
||||
|
||||
if (thePluginManager) {
|
||||
thePluginManager->Release();
|
||||
thePluginManager = NULL;
|
||||
}
|
||||
if (thePluginManager) {
|
||||
thePluginManager->Release();
|
||||
thePluginManager = NULL;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -664,10 +782,10 @@ NPP_SetWindow(NPP instance, NPWindow* window)
|
||||
|
||||
NPError
|
||||
NPP_NewStream(NPP instance,
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
PRUint16 *stype)
|
||||
NPMIMEType type,
|
||||
NPStream *stream,
|
||||
NPBool seekable,
|
||||
PRUint16 *stype)
|
||||
{
|
||||
// XXX - How do you set the fields of the peer stream and stream?
|
||||
// XXX - Looks like these field will have to be created since
|
||||
@ -678,11 +796,29 @@ NPP_NewStream(NPP instance,
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->notifyData;
|
||||
if (inStr == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
nsPluginStreamInfo info;
|
||||
info.contentType = type;
|
||||
info.seekable = seekable;
|
||||
nsresult err = inStr->GetListener()->OnStartBinding(stream->url, &info);
|
||||
if (err) return err;
|
||||
|
||||
inStr->SetStreamInfo(instance, stream);
|
||||
stream->pdata = inStr;
|
||||
*stype = inStr->GetStreamType();
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// Create a new plugin stream peer and plugin stream.
|
||||
CPluginStreamPeer* speer = new CPluginStreamPeer((nsMIMEType)type, stream,
|
||||
(PRBool)seekable, stype);
|
||||
if (speer == NULL) return NPERR_OUT_OF_MEMORY_ERROR;
|
||||
speer->AddRef();
|
||||
|
||||
nsIPluginStream* pluginStream = NULL;
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
@ -697,6 +833,8 @@ NPP_NewStream(NPP instance,
|
||||
err = pluginStream->GetStreamType((nsPluginStreamType*)stype);
|
||||
assert(err == NS_OK);
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
@ -714,11 +852,22 @@ NPP_WriteReady(NPP instance, NPStream *stream)
|
||||
if (instance == NULL)
|
||||
return -1;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return -1;
|
||||
return NP_MAXREADY;
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return -1;
|
||||
|
||||
return 8192;
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
|
||||
|
||||
@ -735,6 +884,19 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
if (instance == NULL)
|
||||
return -1;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return -1;
|
||||
nsresult err = inStr->SetReadBuffer((PRUint32)len, (const char*)buffer);
|
||||
if (err != NS_OK) return -1;
|
||||
err = inStr->GetListener()->OnDataAvailable(stream->url, inStr, offset, len);
|
||||
if (err != NS_OK) return -1;
|
||||
return len;
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return -1;
|
||||
@ -742,6 +904,8 @@ NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
|
||||
PRInt32 count;
|
||||
nsresult err = theStream->Write((const char* )buffer, offset, len, &count);
|
||||
return (err == NS_OK) ? count : -1;
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -760,12 +924,25 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
|
||||
if (instance == NULL)
|
||||
return NPERR_INVALID_INSTANCE_ERROR;
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
inStr->GetListener()->OnStopBinding(stream->url, (nsPluginReason)reason);
|
||||
inStr->Release();
|
||||
stream->pdata = NULL;
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return NPERR_GENERIC_ERROR;
|
||||
|
||||
theStream->Release();
|
||||
stream->pdata = NULL;
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
@ -778,16 +955,27 @@ NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
|
||||
void
|
||||
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
|
||||
{
|
||||
// TRACE("NPP_StreamAsFile\n");
|
||||
// TRACE("NPP_StreamAsFile\n");
|
||||
|
||||
if (instance == NULL)
|
||||
return;
|
||||
if (instance == NULL)
|
||||
return;
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return;
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
theStream->AsFile( fname );
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
|
||||
if (inStr == NULL)
|
||||
return;
|
||||
(void)inStr->GetListener()->OnFileAvailable(stream->url, fname);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
nsIPluginStream* theStream = (nsIPluginStream*) stream->pdata;
|
||||
if( theStream == 0 )
|
||||
return;
|
||||
|
||||
theStream->AsFile( fname );
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -802,12 +990,12 @@ NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
if(printInfo == NULL) // trap invalid parm
|
||||
return;
|
||||
|
||||
if (instance != NULL)
|
||||
{
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->Print((nsPluginPrint* ) printInfo );
|
||||
}
|
||||
if (instance != NULL)
|
||||
{
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->Print((nsPluginPrint* ) printInfo );
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -818,14 +1006,22 @@ NPP_Print(NPP instance, NPPrint* printInfo)
|
||||
void
|
||||
NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
|
||||
{
|
||||
// TRACE("NPP_URLNotify\n");
|
||||
// TRACE("NPP_URLNotify\n");
|
||||
|
||||
if( instance != NULL )
|
||||
{
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->URLNotify(url, NULL, (nsPluginReason)reason, notifyData);
|
||||
}
|
||||
if (instance != NULL) {
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream* inStr = (CPluginInputStream*)notifyData;
|
||||
(void)inStr->GetListener()->OnStopBinding(url, (nsPluginReason)reason);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
pluginInstance->URLNotify(url, NULL, (nsPluginReason)reason, notifyData);
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
}
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -839,29 +1035,29 @@ int16
|
||||
NPP_HandleEvent(NPP instance, void* event)
|
||||
{
|
||||
// TRACE("NPP_HandleEvent\n");
|
||||
int16 eventHandled = FALSE;
|
||||
if (instance == NULL)
|
||||
return eventHandled;
|
||||
int16 eventHandled = FALSE;
|
||||
if (instance == NULL)
|
||||
return eventHandled;
|
||||
|
||||
NPEvent* npEvent = (NPEvent*) event;
|
||||
nsPluginEvent pluginEvent = {
|
||||
NPEvent* npEvent = (NPEvent*) event;
|
||||
nsPluginEvent pluginEvent = {
|
||||
#ifdef XP_MAC
|
||||
npEvent, NULL
|
||||
npEvent, NULL
|
||||
#else
|
||||
npEvent->event, npEvent->wParam, npEvent->lParam
|
||||
npEvent->event, npEvent->wParam, npEvent->lParam
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
|
||||
nsIPluginInstance* pluginInstance = peer->GetInstance();
|
||||
if (pluginInstance) {
|
||||
if (pluginInstance) {
|
||||
PRBool handled;
|
||||
nsresult err = pluginInstance->HandleEvent(&pluginEvent, &handled);
|
||||
nsresult err = pluginInstance->HandleEvent(&pluginEvent, &handled);
|
||||
if (err) return FALSE;
|
||||
eventHandled = (handled == PR_TRUE);
|
||||
}
|
||||
|
||||
return eventHandled;
|
||||
return eventHandled;
|
||||
}
|
||||
#endif // ndef XP_UNIX
|
||||
|
||||
@ -923,9 +1119,9 @@ NS_METHOD
|
||||
CPluginManager::MemFlush(PRUint32 size)
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
return NPN_MemFlush(size);
|
||||
return NPN_MemFlush(size);
|
||||
#else
|
||||
return 0;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -937,10 +1133,109 @@ CPluginManager::MemFlush(PRUint32 size)
|
||||
NS_METHOD
|
||||
CPluginManager::ReloadPlugins(PRBool reloadPages)
|
||||
{
|
||||
NPN_ReloadPlugins(reloadPages);
|
||||
NPN_ReloadPlugins(reloadPages);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_METHOD
|
||||
CPluginManager::GetURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* streamListener,
|
||||
nsPluginStreamType streamType,
|
||||
const char* altHost,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled)
|
||||
{
|
||||
if (altHost != NULL || referrer != NULL || forceJSEnabled != PR_FALSE) {
|
||||
return NPERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
nsIPluginInstance* inst = NULL;
|
||||
nsresult rslt = pluginInst->QueryInterface(kIPluginInstanceIID, (void**)&inst);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
CPluginInstancePeer* instancePeer = NULL;
|
||||
rslt = inst->GetPeer((nsIPluginInstancePeer**)&instancePeer);
|
||||
if (rslt != NS_OK) {
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
if (streamListener) {
|
||||
CPluginInputStream* inStr = new CPluginInputStream(streamListener, streamType);
|
||||
if (inStr == NULL) {
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
inStr->AddRef();
|
||||
|
||||
err = NPN_GetURLNotify(npp, url, target, inStr);
|
||||
}
|
||||
else {
|
||||
err = NPN_GetURL(npp, url, target);
|
||||
}
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginManager::PostURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
PRUint32 postDataLen,
|
||||
const char* postData,
|
||||
PRBool isFile,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* streamListener,
|
||||
nsPluginStreamType streamType,
|
||||
const char* altHost,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled,
|
||||
PRUint32 postHeadersLength,
|
||||
const char* postHeaders)
|
||||
{
|
||||
if (altHost != NULL || referrer != NULL || forceJSEnabled != PR_FALSE
|
||||
|| postHeadersLength != 0 || postHeaders != NULL) {
|
||||
return NPERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
nsIPluginInstance* inst = NULL;
|
||||
nsresult rslt = pluginInst->QueryInterface(kIPluginInstanceIID, (void**)&inst);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
CPluginInstancePeer* instancePeer = NULL;
|
||||
rslt = inst->GetPeer((nsIPluginInstancePeer**)&instancePeer);
|
||||
if (rslt != NS_OK) {
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
if (streamListener) {
|
||||
CPluginInputStream* inStr = new CPluginInputStream(streamListener, streamType);
|
||||
if (inStr == NULL) {
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
inStr->AddRef();
|
||||
|
||||
err = NPN_PostURLNotify(npp, url, target, postDataLen, postData, isFile, inStr);
|
||||
}
|
||||
else {
|
||||
err = NPN_PostURL(npp, url, target, postDataLen, postData, isFile);
|
||||
}
|
||||
instancePeer->Release();
|
||||
inst->Release();
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPN_GetURL and NPN_GetURLNotify.)
|
||||
// notifyData: When present, URLNotify is called passing the notifyData back
|
||||
@ -968,7 +1263,7 @@ CPluginManager::GetURL(nsISupports* pinst, const char* url, const char* target,
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
// Call the correct GetURL* function.
|
||||
@ -1001,7 +1296,7 @@ CPluginManager::PostURL(nsISupports* pinst, const char* url, const char* target,
|
||||
inst->Release();
|
||||
return rslt;
|
||||
}
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
NPP npp = instancePeer->GetNPPInstance();
|
||||
|
||||
NPError err;
|
||||
// Call the correct PostURL* function.
|
||||
@ -1016,11 +1311,7 @@ CPluginManager::PostURL(nsISupports* pinst, const char* url, const char* target,
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginManager::FindProxyForURL(const char* url, char* *result)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// UserAgent:
|
||||
@ -1122,33 +1413,33 @@ CPluginInstancePeer::CPluginInstancePeer(nsIPluginInstance* pluginInstance,
|
||||
|
||||
mInstance->AddRef();
|
||||
|
||||
attribute_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
values_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
attribute_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
values_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
|
||||
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
attribute_list[i] = (char*) NPN_MemAlloc(strlen(attr_list[i]) + 1);
|
||||
if (attribute_list[i] != NULL)
|
||||
strcpy(attribute_list[i], attr_list[i]);
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
attribute_list[i] = (char*) NPN_MemAlloc(strlen(attr_list[i]) + 1);
|
||||
if (attribute_list[i] != NULL)
|
||||
strcpy(attribute_list[i], attr_list[i]);
|
||||
|
||||
values_list[i] = (char*) NPN_MemAlloc(strlen(val_list[i]) + 1);
|
||||
if (values_list[i] != NULL)
|
||||
strcpy(values_list[i], val_list[i]);
|
||||
}
|
||||
}
|
||||
values_list[i] = (char*) NPN_MemAlloc(strlen(val_list[i]) + 1);
|
||||
if (values_list[i] != NULL)
|
||||
strcpy(values_list[i], val_list[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPluginInstancePeer::~CPluginInstancePeer(void)
|
||||
{
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
NPN_MemFree(attribute_list[i]);
|
||||
NPN_MemFree(values_list[i]);
|
||||
}
|
||||
if (attribute_list != NULL && values_list != NULL) {
|
||||
for (int i = 0; i < attribute_cnt; i++) {
|
||||
NPN_MemFree(attribute_list[i]);
|
||||
NPN_MemFree(values_list[i]);
|
||||
}
|
||||
|
||||
NPN_MemFree(attribute_list);
|
||||
NPN_MemFree(values_list);
|
||||
}
|
||||
NPN_MemFree(attribute_list);
|
||||
NPN_MemFree(values_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1212,45 +1503,45 @@ CPluginInstancePeer::GetMode(nsPluginMode *result)
|
||||
NS_METHOD
|
||||
CPluginInstancePeer::GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values)
|
||||
{
|
||||
n = attribute_cnt;
|
||||
names = attribute_list;
|
||||
values = values_list;
|
||||
n = attribute_cnt;
|
||||
names = attribute_list;
|
||||
values = values_list;
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(XP_MAC)
|
||||
|
||||
inline unsigned char toupper(unsigned char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
|
||||
return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
|
||||
}
|
||||
|
||||
static int strcasecmp(const char * str1, const char * str2)
|
||||
{
|
||||
#if __POWERPC__
|
||||
|
||||
const unsigned char * p1 = (unsigned char *) str1 - 1;
|
||||
const unsigned char * p2 = (unsigned char *) str2 - 1;
|
||||
unsigned long c1, c2;
|
||||
const unsigned char * p1 = (unsigned char *) str1 - 1;
|
||||
const unsigned char * p2 = (unsigned char *) str2 - 1;
|
||||
unsigned long c1, c2;
|
||||
|
||||
while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
|
||||
if (!c1)
|
||||
return(0);
|
||||
while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
|
||||
if (!c1)
|
||||
return(0);
|
||||
|
||||
#else
|
||||
|
||||
const unsigned char * p1 = (unsigned char *) str1;
|
||||
const unsigned char * p2 = (unsigned char *) str2;
|
||||
unsigned char c1, c2;
|
||||
const unsigned char * p1 = (unsigned char *) str1;
|
||||
const unsigned char * p2 = (unsigned char *) str2;
|
||||
unsigned char c1, c2;
|
||||
|
||||
while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
|
||||
if (!c1)
|
||||
return(0);
|
||||
while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
|
||||
if (!c1)
|
||||
return(0);
|
||||
|
||||
#endif
|
||||
|
||||
return(toupper(c1) - toupper(c2));
|
||||
return(toupper(c1) - toupper(c2));
|
||||
}
|
||||
|
||||
#endif /* XP_MAC */
|
||||
@ -1260,19 +1551,19 @@ static int strcasecmp(const char * str1, const char * str2)
|
||||
NS_METHOD
|
||||
CPluginInstancePeer::GetAttribute(const char* name, const char* *result)
|
||||
{
|
||||
for (int i=0; i < attribute_cnt; i++) {
|
||||
for (int i=0; i < attribute_cnt; i++) {
|
||||
#if defined(XP_UNIX) || defined(XP_MAC)
|
||||
if (strcasecmp(name, attribute_list[i]) == 0)
|
||||
if (strcasecmp(name, attribute_list[i]) == 0)
|
||||
#else
|
||||
if (stricmp(name, attribute_list[i]) == 0)
|
||||
if (stricmp(name, attribute_list[i]) == 0)
|
||||
#endif
|
||||
{
|
||||
*result = values_list[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
{
|
||||
*result = values_list[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@ -1280,7 +1571,7 @@ CPluginInstancePeer::GetAttribute(const char* name, const char* *result)
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
NS_METHOD
|
||||
CPluginInstancePeer::NewStream(nsMIMEType type, const char* target,
|
||||
nsIOutputStream* *result)
|
||||
nsIOutputStream* *result)
|
||||
{
|
||||
assert( npp != NULL );
|
||||
|
||||
@ -1464,13 +1755,77 @@ NS_IMPL_QUERY_INTERFACE(CPluginManagerStream, kIOutputStreamIID);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
CPluginInputStream::CPluginInputStream(nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType)
|
||||
: mListener(listener), mStreamType(streamType),
|
||||
mNPP(NULL), mStream(NULL),
|
||||
mBuffer(NULL), mBufferLength(0), mAmountRead(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mListener->AddRef();
|
||||
}
|
||||
|
||||
CPluginInputStream::~CPluginInputStream(void)
|
||||
{
|
||||
mListener->Release();
|
||||
free(mBuffer);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(CPluginInputStream, kIPluginInputStreamIID);
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::Close(void)
|
||||
{
|
||||
if (mNPP == NULL || mStream == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
NPError err = NPN_DestroyStream(mNPP, mStream, NPRES_USER_BREAK);
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::GetLength(PRInt32 *aLength)
|
||||
{
|
||||
*aLength = mStream->end;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount)
|
||||
{
|
||||
if (aOffset > (PRInt32)mBufferLength)
|
||||
return NS_ERROR_FAILURE; // XXX right error?
|
||||
PRUint32 cnt = PR_MIN(aCount, (PRInt32)mBufferLength - aOffset);
|
||||
memcpy(aBuf, &mBuffer[aOffset], cnt);
|
||||
*aReadCount = cnt;
|
||||
mAmountRead -= cnt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::GetLastModified(PRUint32 *result)
|
||||
{
|
||||
*result = mStream->lastmodified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
CPluginInputStream::RequestRead(nsByteRange* rangeList)
|
||||
{
|
||||
NPError err = NPN_RequestRead(mStream, (NPByteRange*)rangeList);
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CPluginStreamPeer
|
||||
//
|
||||
|
||||
CPluginStreamPeer::CPluginStreamPeer(nsMIMEType type, NPStream* npStream,
|
||||
PRBool seekable, PRUint16* stype)
|
||||
PRBool seekable, PRUint16* stype)
|
||||
: type(type), npStream(npStream), seekable(seekable),
|
||||
stype(stype), reason(nsPluginReason_NoReason)
|
||||
{
|
||||
@ -1583,6 +1938,8 @@ nsresult CPluginStreamPeer::QueryInterface(const nsIID& iid, void** ptr)
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -78,6 +78,11 @@ include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl -I$(PUBLIC)\raptor -I_jri
|
||||
|
||||
!ifdef NEW_PLUGIN_STREAM_API
|
||||
LCFLAGS = $(LCFLAGS) -DNEW_PLUGIN_STREAM_API
|
||||
!endif
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
# $(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
$(MAKE_INSTALL) Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
$(MAKE_INSTALL) $(OBJDIR)\npsimple.dll $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
|
@ -249,19 +249,27 @@ public:
|
||||
NS_IMETHOD
|
||||
SetWindow(nsPluginWindow* window);
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPP_NewStream.)
|
||||
NS_IMETHOD
|
||||
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result);
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPP_Print.)
|
||||
NS_IMETHOD
|
||||
Print(nsPluginPrint* platformPrint);
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPP_URLNotify.)
|
||||
NS_IMETHOD
|
||||
URLNotify(const char* url, const char* target,
|
||||
nsPluginReason reason, void* notifyData);
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_IMETHOD
|
||||
GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
|
||||
@ -302,6 +310,70 @@ protected:
|
||||
// SimplePluginStream represents the stream used by SimplePluginInstances
|
||||
// to receive data from the browser.
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
class SimplePluginStreamListener : public nsIPluginStreamListener {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginStreamListener:
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*
|
||||
* @return The return value is currently ignored. In the future it may be
|
||||
* used to cancel the URL load..
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStartBinding(const char* url, const nsPluginStreamInfo* info);
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(const char* url, nsIPluginInputStream* input,
|
||||
PRUint32 offset, PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(const char* url, const char* fileName);
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading. This method is
|
||||
* called once when the networking library has finished processing the
|
||||
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
|
||||
*
|
||||
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
|
||||
*
|
||||
* @param status Status code for the URL load.
|
||||
* @param msg A text string describing the error.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStopBinding(const char* url, nsresult status);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginStreamListener specific methods:
|
||||
|
||||
SimplePluginStreamListener(SimplePluginInstance* inst);
|
||||
virtual ~SimplePluginStreamListener(void);
|
||||
|
||||
protected:
|
||||
SimplePluginInstance* fInst;
|
||||
|
||||
};
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
class SimplePluginStream : public nsIPluginStream {
|
||||
public:
|
||||
|
||||
@ -350,19 +422,34 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// Interface IDs we'll need:
|
||||
static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID);
|
||||
static NS_DEFINE_IID(kIJRILiveConnectPluginIID, NS_IJRILIVECONNECTPLUGIN_IID);
|
||||
static NS_DEFINE_IID(kIJRILiveConnectPluginInstancePeerIID, NS_IJRILIVECONNECTPLUGININSTANCEPEER_IID);
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamIID, NS_IPLUGINSTREAM_IID);
|
||||
static NS_DEFINE_IID(kIJRIEnvIID, NS_IJRIENV_IID);
|
||||
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
static NS_DEFINE_IID(kIPluginStreamIID, NS_IPLUGINSTREAM_IID);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*******************************************************************************
|
||||
* SECTION 3 - API Plugin Implementations
|
||||
******************************************************************************/
|
||||
|
||||
// This counter is used to keep track of the number of outstanding objects.
|
||||
// It is used to determine whether the plugin's DLL can be unloaded.
|
||||
static PRUint32 gPluginObjectCount = 0;
|
||||
|
||||
// This flag is used to keep track of whether the plugin's DLL is explicitly
|
||||
// being retained by some client.
|
||||
static PRBool gPluginLocked = PR_FALSE;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePlugin Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -371,10 +458,12 @@ SimplePlugin::SimplePlugin()
|
||||
: mgr(NULL)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gPluginObjectCount++;
|
||||
}
|
||||
|
||||
SimplePlugin::~SimplePlugin(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
if (env)
|
||||
Simple::_unuse(env);
|
||||
}
|
||||
@ -436,6 +525,12 @@ NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
|
||||
return NS_ERROR_FAILURE; // XXX right error?
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRBool
|
||||
NSCanUnload(void)
|
||||
{
|
||||
return gPluginObjectCount == 1 && !gPluginLocked;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePlugin::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
@ -443,13 +538,14 @@ SimplePlugin::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
inst->AddRef();
|
||||
*aResult = inst;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePlugin::LockFactory(PRBool aLock)
|
||||
{
|
||||
// XXX what to do here?
|
||||
gPluginLocked = aLock;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -457,7 +553,7 @@ NS_METHOD
|
||||
SimplePlugin::Initialize(nsISupports* browserInterfaces)
|
||||
{
|
||||
if (browserInterfaces->QueryInterface(kIPluginManagerIID,
|
||||
(void**)mgr) != NS_OK) {
|
||||
(void**)&mgr) != NS_OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
@ -542,10 +638,12 @@ SimplePluginInstance::SimplePluginInstance(void)
|
||||
: fPeer(NULL), fWindow(NULL), fMode(nsPluginMode_Embedded)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gPluginObjectCount++;
|
||||
}
|
||||
|
||||
SimplePluginInstance::~SimplePluginInstance(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
PlatformDestroy(); // Perform platform specific cleanup
|
||||
DisplayJavaMessage("Calling SimplePluginInstance::Release.", -1);
|
||||
}
|
||||
@ -572,6 +670,7 @@ NS_METHOD
|
||||
SimplePluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||
{
|
||||
fPeer = peer;
|
||||
peer->AddRef();
|
||||
nsresult err = peer->GetMode(&fMode);
|
||||
if (err) return err;
|
||||
PlatformNew(); /* Call Platform-specific initializations */
|
||||
@ -656,6 +755,8 @@ SimplePluginInstance::SetWindow(nsPluginWindow* window)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* NewStream:
|
||||
* Notifies an instance of a new data stream and returns an error value.
|
||||
@ -678,6 +779,8 @@ SimplePluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *res
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* NPP_Print:
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
@ -754,6 +857,8 @@ SimplePluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* URLNotify:
|
||||
* Notifies the instance of the completion of a URL request.
|
||||
@ -781,12 +886,76 @@ SimplePluginInstance::URLNotify(const char* url, const char* target,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginInstance::GetValue(nsPluginInstanceVariable variable, void *value)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginStreamListener Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SimplePluginStreamListener::SimplePluginStreamListener(SimplePluginInstance* inst)
|
||||
: fInst(inst)
|
||||
{
|
||||
gPluginObjectCount++;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
SimplePluginStreamListener::~SimplePluginStreamListener(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
fInst->DisplayJavaMessage("Calling SimplePluginStream destructor.", -1);
|
||||
}
|
||||
|
||||
// This macro produces a simple version of QueryInterface, AddRef and Release.
|
||||
// See the nsISupports.h header file for details.
|
||||
|
||||
NS_IMPL_ISUPPORTS(SimplePluginStreamListener, kIPluginStreamListenerIID);
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnStartBinding(const char* url, const nsPluginStreamInfo* info)
|
||||
{
|
||||
fInst->DisplayJavaMessage("Opening plugin stream.", -1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnDataAvailable(const char* url, nsIPluginInputStream* input,
|
||||
PRUint32 offset, PRUint32 length)
|
||||
{
|
||||
char* buffer = new char[length];
|
||||
if (buffer) {
|
||||
PRInt32 amountRead = 0;
|
||||
nsresult rslt = input->Read(buffer, offset, length, &amountRead);
|
||||
if (rslt == NS_OK)
|
||||
fInst->DisplayJavaMessage(buffer, amountRead);
|
||||
delete buffer;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnFileAvailable(const char* url, const char* fileName)
|
||||
{
|
||||
fInst->DisplayJavaMessage("Calling SimplePluginStreamListener::OnFileAvailable.", -1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnStopBinding(const char* url, nsresult status)
|
||||
{
|
||||
fInst->DisplayJavaMessage("Closing plugin stream.", -1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginStream Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -795,11 +964,13 @@ SimplePluginStream::SimplePluginStream(nsIPluginStreamPeer* peer,
|
||||
SimplePluginInstance* inst)
|
||||
: fPeer(peer), fInst(inst)
|
||||
{
|
||||
gPluginObjectCount++;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
SimplePluginStream::~SimplePluginStream(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
fInst->DisplayJavaMessage("Calling SimplePluginStream::Release.", -1);
|
||||
}
|
||||
|
||||
@ -875,7 +1046,7 @@ SimplePluginStream::AsFile(const char* fname)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -19,6 +19,8 @@ IGNORE_MANIFEST=1
|
||||
|
||||
DEPTH= ..\..\..
|
||||
|
||||
include <$(DEPTH)/config/config.mak>
|
||||
|
||||
MODULE = plugimpl
|
||||
|
||||
EXPORTS = \
|
||||
@ -48,6 +50,10 @@ OBJS = .\$(OBJDIR)\npassoc.obj \
|
||||
.\$(OBJDIR)\npglue.obj \
|
||||
.\$(OBJDIR)\nsMalloc.obj
|
||||
|
||||
!ifdef NEW_PLUGIN_STREAM_API
|
||||
LCFLAGS = $(LCFLAGS) -DNEW_PLUGIN_STREAM_API
|
||||
!endif
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
install:: $(LIBRARY)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -64,6 +64,8 @@ struct nsIJVMManager;
|
||||
class nsHashtable;
|
||||
#endif /* OJI */
|
||||
|
||||
#include "plstr.h"
|
||||
|
||||
extern int XP_PLUGIN_LOADING_PLUGIN;
|
||||
extern int MK_BAD_CONNECT;
|
||||
extern int XP_PLUGIN_NOT_FOUND;
|
||||
@ -299,6 +301,34 @@ public:
|
||||
NS_IMETHOD
|
||||
UserAgent(const char* *result);
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
const char* altHost = NULL,
|
||||
const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE);
|
||||
|
||||
NS_IMETHOD
|
||||
PostURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
PRUint32 postDataLen,
|
||||
const char* postData,
|
||||
PRBool isFile = PR_FALSE,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
nsPluginStreamType streamType = nsPluginStreamType_Normal,
|
||||
const char* altHost = NULL,
|
||||
const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0,
|
||||
const char* postHeaders = NULL);
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHOD
|
||||
GetURL(nsISupports* peer, const char* url, const char* target,
|
||||
void* notifyData = NULL, const char* altHost = NULL,
|
||||
@ -311,6 +341,7 @@ public:
|
||||
const char* altHost = NULL, const char* referrer = NULL,
|
||||
PRBool forceJSEnabled = PR_FALSE,
|
||||
PRUint32 postHeadersLength = 0, const char* postHeaders = NULL);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginManager2:
|
||||
@ -355,6 +386,7 @@ public:
|
||||
NS_IMETHOD
|
||||
HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PRBool *result);
|
||||
|
||||
#if 0
|
||||
// On the mac (and most likely win16), network activity can
|
||||
// only occur on the main thread. Therefore, we provide a hook
|
||||
// here for the case that the main thread needs to tickle itself.
|
||||
@ -362,6 +394,7 @@ public:
|
||||
// the tickle code can notify it without freezing.
|
||||
NS_IMETHOD
|
||||
ProcessNextEvent(PRBool *bEventHandled);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsPluginManager specific methods:
|
||||
@ -660,6 +693,112 @@ protected:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "nsIPluginInputStream2.h"
|
||||
|
||||
class nsPluginInputStream;
|
||||
|
||||
// stored in the fe_data of the URL_Struct:
|
||||
struct nsPluginURLData {
|
||||
NPEmbeddedApp* app;
|
||||
nsIPluginStreamListener* listener;
|
||||
nsPluginInputStream* inStr;
|
||||
};
|
||||
|
||||
class nsPluginInputStream : public nsIPluginInputStream2 {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIBaseStream:
|
||||
|
||||
/** Close the stream. */
|
||||
NS_IMETHOD
|
||||
Close(void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIInputStream:
|
||||
|
||||
/** Return the number of bytes in the stream
|
||||
* @param aLength out parameter to hold the length
|
||||
* of the stream. if an error occurs, the length
|
||||
* will be undefined
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
GetLength(PRInt32 *aLength);
|
||||
|
||||
/** Read data from the stream.
|
||||
* @param aErrorCode the error code if an error occurs
|
||||
* @param aBuf the buffer into which the data is read
|
||||
* @param aOffset the start offset of the data
|
||||
* @param aCount the maximum number of bytes to read
|
||||
* @param aReadCount out parameter to hold the number of
|
||||
* bytes read, eof if 0. if an error occurs, the
|
||||
* read count will be undefined
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD
|
||||
Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount, PRInt32 *aReadCount);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginInputStream:
|
||||
|
||||
// (Corresponds to NPStream's lastmodified field.)
|
||||
NS_IMETHOD
|
||||
GetLastModified(PRUint32 *result);
|
||||
|
||||
NS_IMETHOD
|
||||
RequestRead(nsByteRange* rangeList);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginInputStream2:
|
||||
|
||||
NS_IMETHOD
|
||||
GetContentLength(PRUint32 *result);
|
||||
|
||||
NS_IMETHOD
|
||||
GetHeaderFields(PRUint16& n, const char*const*& names, const char*const*& values);
|
||||
|
||||
NS_IMETHOD
|
||||
GetHeaderField(const char* name, const char* *result);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsPluginInputStream specific methods:
|
||||
|
||||
nsPluginInputStream(nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType);
|
||||
virtual ~nsPluginInputStream(void);
|
||||
|
||||
nsIPluginStreamListener* GetListener(void) { return mListener; }
|
||||
nsPluginStreamType GetStreamType(void) { return mStreamType; }
|
||||
|
||||
void SetStreamInfo(URL_Struct* urls, np_stream* stream) {
|
||||
mUrls = urls;
|
||||
mStream = stream;
|
||||
}
|
||||
|
||||
void SetReadBuffer(PRUint32 len, const char* buffer) {
|
||||
mBuffer = PL_strdup(buffer);
|
||||
mBufferLength = len;
|
||||
mAmountRead = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsIPluginStreamListener* mListener;
|
||||
nsPluginStreamType mStreamType;
|
||||
URL_Struct* mUrls;
|
||||
np_stream* mStream;
|
||||
char* mBuffer;
|
||||
PRUint32 mBufferLength;
|
||||
PRUint32 mAmountRead;
|
||||
|
||||
};
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
class nsPluginStreamPeer : public nsIPluginStreamPeer2,
|
||||
public nsISeekablePluginStreamPeer
|
||||
{
|
||||
@ -742,6 +881,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- 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
|
||||
@ -141,6 +141,9 @@ struct _np_urlsnode {
|
||||
void* notifyData;
|
||||
XP_Bool cached;
|
||||
XP_Bool notify;
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
uint16 streamType;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* MWContext.pluginReconnect -> np_reconnect */
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "jvmmgr.h"
|
||||
#include "nsILiveconnect.h"
|
||||
#endif
|
||||
#include "plstr.h" /* PL_strcasecmp */
|
||||
|
||||
#include "xp_mem.h"
|
||||
#include "xpassert.h"
|
||||
@ -66,10 +65,16 @@ static NS_DEFINE_IID(kIPluginInstancePeerIID, NS_IPLUGININSTANCEPEER_IID);
|
||||
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
||||
static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
|
||||
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
static NS_DEFINE_IID(kIFileUtilitiesIID, NS_IFILEUTILITIES_IID);
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
static NS_DEFINE_IID(kIPluginInputStreamIID, NS_IPLUGININPUTSTREAM_IID);
|
||||
static NS_DEFINE_IID(kIPluginInputStream2IID, NS_IPLUGININPUTSTREAM2_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
static NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamPeer2IID, NS_IPLUGINSTREAMPEER2_IID);
|
||||
static NS_DEFINE_IID(kIFileUtilitiesIID, NS_IFILEUTILITIES_IID);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
#include "prerror.h"
|
||||
|
||||
@ -263,37 +268,37 @@ nsPluginManager::GetCapsManager(const nsIID& aIID)
|
||||
PRThread *threadAttached = NULL;
|
||||
#ifdef OJI
|
||||
if (fCapsManager == NULL) {
|
||||
if ( PR_GetCurrentThread() == NULL )
|
||||
{
|
||||
threadAttached = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL);
|
||||
}
|
||||
if ( PR_GetCurrentThread() == NULL )
|
||||
{
|
||||
threadAttached = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL);
|
||||
}
|
||||
|
||||
NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
|
||||
nsresult err = NS_OK;
|
||||
err = nsRepository::CreateInstance(kCCapsManagerCID,
|
||||
(nsIPluginManager*)this, /* outer */
|
||||
kISupportsIID,
|
||||
(void **)&fCapsManager);
|
||||
NS_DEFINE_IID(kICapsManagerIID, NS_ICAPSMANAGER_IID);
|
||||
if ( (err == NS_OK)
|
||||
&& (fCapsManager != NULL)
|
||||
&& (err = (fCapsManager->QueryInterface(kICapsManagerIID, (void**)&result)) == NS_OK)
|
||||
)
|
||||
{
|
||||
((nsCCapsManager*)result)->SetSystemPrivilegeManager();
|
||||
result->Release();
|
||||
}
|
||||
}
|
||||
if ( (err == NS_OK)
|
||||
&&(fCapsManager->QueryInterface(aIID, (void**)&result) != NS_OK)
|
||||
NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
|
||||
nsresult err = NS_OK;
|
||||
err = nsRepository::CreateInstance(kCCapsManagerCID,
|
||||
(nsIPluginManager*)this, /* outer */
|
||||
kISupportsIID,
|
||||
(void **)&fCapsManager);
|
||||
NS_DEFINE_IID(kICapsManagerIID, NS_ICAPSMANAGER_IID);
|
||||
if ( (err == NS_OK)
|
||||
&& (fCapsManager != NULL)
|
||||
&& (err = (fCapsManager->QueryInterface(kICapsManagerIID, (void**)&result)) == NS_OK)
|
||||
)
|
||||
{
|
||||
((nsCCapsManager*)result)->SetSystemPrivilegeManager();
|
||||
result->Release();
|
||||
}
|
||||
}
|
||||
if ( (err == NS_OK)
|
||||
&&(fCapsManager->QueryInterface(aIID, (void**)&result) != NS_OK)
|
||||
)
|
||||
{
|
||||
result = NULL;
|
||||
}
|
||||
if (threadAttached != NULL )
|
||||
{
|
||||
PR_DetachThread();
|
||||
}
|
||||
{
|
||||
result = NULL;
|
||||
}
|
||||
if (threadAttached != NULL )
|
||||
{
|
||||
PR_DetachThread();
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
@ -527,6 +532,7 @@ nsPluginManager::HasAllocatedMenuID(nsIEventHandler* handler, PRInt16 menuID, PR
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0 // problematic
|
||||
static NPL_ProcessNextEventProc npl_ProcessNextEventProc = NULL;
|
||||
static void* npl_ProcessNextEventData = NULL;
|
||||
|
||||
@ -549,6 +555,7 @@ nsPluginManager::ProcessNextEvent(PRBool *bEventHandled)
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -559,6 +566,220 @@ extern PREventQueue* mozilla_event_queue;
|
||||
extern PRThread* mozilla_thread;
|
||||
};
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
struct GetURLEvent {
|
||||
PLEvent event;
|
||||
nsPluginInstancePeer* peer;
|
||||
const char* url;
|
||||
const char* target;
|
||||
void* notifyData;
|
||||
const char* altHost;
|
||||
const char* referrer;
|
||||
PRBool forceJSEnabled;
|
||||
};
|
||||
|
||||
static void*
|
||||
HandleGetURLEvent(PLEvent* event)
|
||||
{
|
||||
PR_ASSERT(PR_CurrentThread() == mozilla_thread);
|
||||
GetURLEvent* e = (GetURLEvent*)event;
|
||||
NPP npp = e->peer->GetNPP();
|
||||
NPError rslt = np_geturlinternal(npp,
|
||||
e->url,
|
||||
e->target,
|
||||
e->altHost,
|
||||
e->referrer,
|
||||
e->forceJSEnabled,
|
||||
e->notifyData != NULL,
|
||||
e->notifyData);
|
||||
return (void*)rslt;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyGetURLEvent(PLEvent* event)
|
||||
{
|
||||
GetURLEvent* e = (GetURLEvent*)event;
|
||||
PR_Free(event);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginManager::GetURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType,
|
||||
const char* altHost,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled)
|
||||
{
|
||||
NPError rslt = NPERR_INVALID_PARAM;
|
||||
nsIPluginInstance* inst = NULL;
|
||||
if (pluginInst->QueryInterface(kIPluginInstanceIID, (void**)&inst) == NS_OK) {
|
||||
// Warning: Casting to our implementation type of plugin instance peer here:
|
||||
nsPluginInstancePeer* peer;
|
||||
nsresult err = inst->GetPeer((nsIPluginInstancePeer**)&peer);
|
||||
if (err == NS_OK) {
|
||||
void* notifyData = NULL;
|
||||
if (listener) {
|
||||
nsPluginInputStream* inStr = new nsPluginInputStream(listener, streamType);
|
||||
notifyData = inStr;
|
||||
}
|
||||
|
||||
if (PR_CurrentThread() == mozilla_thread) {
|
||||
NPP npp = peer->GetNPP();
|
||||
rslt = np_geturlinternal(npp,
|
||||
url,
|
||||
target,
|
||||
altHost,
|
||||
referrer,
|
||||
forceJSEnabled,
|
||||
notifyData != NULL,
|
||||
notifyData);
|
||||
}
|
||||
else {
|
||||
GetURLEvent* e = PR_NEW(GetURLEvent);
|
||||
if (e == NULL) {
|
||||
rslt = NPERR_OUT_OF_MEMORY_ERROR;
|
||||
}
|
||||
else {
|
||||
PL_InitEvent(&e->event, NULL, HandleGetURLEvent, DestroyGetURLEvent);
|
||||
e->peer = peer;
|
||||
e->url = url;
|
||||
e->target = target;
|
||||
e->notifyData = notifyData;
|
||||
e->altHost = altHost;
|
||||
e->referrer = referrer;
|
||||
e->forceJSEnabled = forceJSEnabled;
|
||||
/*rslt = (NPError)*/PL_PostSynchronousEvent(mozilla_event_queue, &e->event);
|
||||
rslt = NPERR_NO_ERROR; /* XXX irix c++ compiler doesn't like the above cast */
|
||||
}
|
||||
}
|
||||
peer->Release();
|
||||
}
|
||||
inst->Release();
|
||||
}
|
||||
return fromNPError[rslt];
|
||||
}
|
||||
|
||||
struct PostURLEvent {
|
||||
PLEvent event;
|
||||
nsPluginInstancePeer* peer;
|
||||
const char* url;
|
||||
const char* target;
|
||||
PRUint32 postDataLen;
|
||||
const char* postData;
|
||||
PRBool isFile;
|
||||
void* notifyData;
|
||||
const char* altHost;
|
||||
const char* referrer;
|
||||
PRBool forceJSEnabled;
|
||||
PRUint32 postHeadersLen;
|
||||
const char* postHeaders;
|
||||
};
|
||||
|
||||
static void*
|
||||
HandlePostURLEvent(PLEvent* event)
|
||||
{
|
||||
PR_ASSERT(PR_CurrentThread() == mozilla_thread);
|
||||
PostURLEvent* e = (PostURLEvent*)event;
|
||||
NPP npp = e->peer->GetNPP();
|
||||
NPError rslt = np_posturlinternal(npp,
|
||||
e->url,
|
||||
e->target,
|
||||
e->altHost,
|
||||
e->referrer,
|
||||
e->forceJSEnabled,
|
||||
e->postDataLen,
|
||||
e->postData,
|
||||
e->isFile,
|
||||
e->notifyData != NULL,
|
||||
e->notifyData);
|
||||
return (void*)rslt;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyPostURLEvent(PLEvent* event)
|
||||
{
|
||||
PostURLEvent* e = (PostURLEvent*)event;
|
||||
PR_Free(event);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginManager::PostURL(nsISupports* pluginInst,
|
||||
const char* url,
|
||||
PRUint32 postDataLen,
|
||||
const char* postData,
|
||||
PRBool isFile,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType,
|
||||
const char* altHost,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled,
|
||||
PRUint32 postHeadersLen,
|
||||
const char* postHeaders)
|
||||
{
|
||||
NPError rslt = NPERR_INVALID_PARAM;
|
||||
nsIPluginInstance* inst = NULL;
|
||||
if (pluginInst->QueryInterface(kIPluginInstanceIID, (void**)&inst) == NS_OK) {
|
||||
// Warning: Casting to our implementation type of plugin instance peer here:
|
||||
nsPluginInstancePeer* peer;
|
||||
nsresult err = inst->GetPeer((nsIPluginInstancePeer**)&peer);
|
||||
if (err == NS_OK) {
|
||||
void* notifyData = NULL;
|
||||
if (listener) {
|
||||
nsPluginInputStream* inStr = new nsPluginInputStream(listener, streamType);
|
||||
notifyData = inStr;
|
||||
}
|
||||
|
||||
if (PR_CurrentThread() == mozilla_thread) {
|
||||
NPP npp = peer->GetNPP();
|
||||
PR_ASSERT(postHeaders == NULL); // XXX need to deal with postHeaders
|
||||
rslt = np_posturlinternal(npp,
|
||||
url,
|
||||
target,
|
||||
altHost,
|
||||
referrer,
|
||||
forceJSEnabled,
|
||||
postDataLen,
|
||||
postData,
|
||||
isFile,
|
||||
notifyData != NULL,
|
||||
notifyData);
|
||||
}
|
||||
else {
|
||||
PostURLEvent* e = PR_NEW(PostURLEvent);
|
||||
if (e == NULL) {
|
||||
rslt = NPERR_OUT_OF_MEMORY_ERROR;
|
||||
}
|
||||
else {
|
||||
PL_InitEvent(&e->event, NULL, HandlePostURLEvent, DestroyPostURLEvent);
|
||||
e->peer = peer;
|
||||
e->url = url;
|
||||
e->target = target;
|
||||
e->notifyData = notifyData;
|
||||
e->altHost = altHost;
|
||||
e->referrer = referrer;
|
||||
e->forceJSEnabled = forceJSEnabled;
|
||||
e->postDataLen = postDataLen;
|
||||
e->postData = postData;
|
||||
e->isFile = isFile;
|
||||
e->postHeadersLen = postHeadersLen;
|
||||
e->postHeaders = postHeaders;
|
||||
/*rslt = (NPError)*/PL_PostSynchronousEvent(mozilla_event_queue, &e->event);
|
||||
rslt = NPERR_NO_ERROR; /* XXX irix c++ compiler doesn't like the above cast */
|
||||
}
|
||||
}
|
||||
peer->Release();
|
||||
}
|
||||
inst->Release();
|
||||
}
|
||||
return fromNPError[rslt];
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
struct GetURLEvent {
|
||||
PLEvent event;
|
||||
nsPluginInstancePeer* peer;
|
||||
@ -745,6 +966,8 @@ nsPluginManager::PostURL(nsISupports* pinst, const char* url, const char* target
|
||||
return fromNPError[rslt];
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
extern "C" char *pacf_find_proxies_for_url(MWContext *context,
|
||||
URL_Struct *URL_s);
|
||||
|
||||
@ -1003,13 +1226,20 @@ nsPluginInstancePeer::GetJavaPeer(jref *peer)
|
||||
|
||||
void nsPluginInstancePeer::SetPluginInstance(nsIPluginInstance* inst)
|
||||
{
|
||||
// We're now maintaining our reference to plugin instance in the
|
||||
// npp->ndata->sdata (saved data) field, and we access the peer
|
||||
// from there. This method should be totally unnecessary.
|
||||
#if 0
|
||||
if (fPluginInst != NULL) {
|
||||
fPluginInst->Release();
|
||||
}
|
||||
#endif
|
||||
fPluginInst = inst;
|
||||
#if 0
|
||||
if (fPluginInst != NULL) {
|
||||
fPluginInst->AddRef();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsIPluginInstance* nsPluginInstancePeer::GetPluginInstance()
|
||||
@ -1168,7 +1398,7 @@ nsPluginTagInfo::GetAttribute(const char* name, const char* *result)
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
@ -1257,7 +1487,7 @@ nsPluginTagInfo::GetParameter(const char* name, const char* *result)
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
@ -1390,6 +1620,123 @@ NS_IMPL_QUERY_INTERFACE(nsPluginManagerStream, kIOutputStreamIID);
|
||||
NS_IMPL_ADDREF(nsPluginManagerStream);
|
||||
NS_IMPL_RELEASE(nsPluginManagerStream);
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Plugin Input Stream Interface
|
||||
|
||||
nsPluginInputStream::nsPluginInputStream(nsIPluginStreamListener* listener,
|
||||
nsPluginStreamType streamType)
|
||||
: mListener(listener), mStreamType(streamType),
|
||||
mUrls(NULL), mStream(NULL),
|
||||
mBuffer(NULL), mBufferLength(0), mAmountRead(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
listener->AddRef();
|
||||
}
|
||||
|
||||
nsPluginInputStream::~nsPluginInputStream(void)
|
||||
{
|
||||
mListener->Release();
|
||||
PL_strfree(mBuffer);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsPluginInputStream);
|
||||
NS_IMPL_RELEASE(nsPluginInputStream);
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIPluginInputStream2IID) ||
|
||||
aIID.Equals(kIPluginInputStreamIID) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (nsIPluginInputStream2*)this;
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::Close(void)
|
||||
{
|
||||
NPError err = npn_destroystream(mStream->instance->npp, mStream->pstream,
|
||||
nsPluginReason_UserBreak);
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::GetLength(PRInt32 *aLength)
|
||||
{
|
||||
*aLength = mStream->pstream->end;
|
||||
return NS_OK;
|
||||
#if 0
|
||||
*aLength = mBufferLength;
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::Read(char* aBuf, PRInt32 aOffset, PRInt32 aCount,
|
||||
PRInt32 *aReadCount)
|
||||
{
|
||||
if (aOffset > (PRInt32)mBufferLength)
|
||||
return NS_ERROR_FAILURE; // XXX right error?
|
||||
PRUint32 cnt = PR_MIN(aCount, (PRInt32)mBufferLength - aOffset);
|
||||
memcpy(aBuf, &mBuffer[aOffset], cnt);
|
||||
*aReadCount = cnt;
|
||||
mAmountRead -= cnt;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::GetLastModified(PRUint32 *result)
|
||||
{
|
||||
*result = mStream->pstream->lastmodified;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::RequestRead(nsByteRange* rangeList)
|
||||
{
|
||||
NPError err = npn_requestread(mStream->pstream,
|
||||
(NPByteRange*)rangeList);
|
||||
return fromNPError[err];
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::GetContentLength(PRUint32 *result)
|
||||
{
|
||||
*result = mUrls->content_length;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::GetHeaderFields(PRUint16& n, const char*const*& names,
|
||||
const char*const*& values)
|
||||
{
|
||||
n = (PRUint16)mUrls->all_headers.empty_index;
|
||||
names = (const char*const*)mUrls->all_headers.key;
|
||||
values = (const char*const*)mUrls->all_headers.value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsPluginInputStream::GetHeaderField(const char* name, const char* *result)
|
||||
{
|
||||
PRUint16 i;
|
||||
for (i = 0; i < mUrls->all_headers.empty_index; i++) {
|
||||
if (PL_strcmp(mUrls->all_headers.key[i], name) == 0) {
|
||||
*result = mUrls->all_headers.value[i];
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Plugin Stream Peer Interface
|
||||
|
||||
@ -1554,4 +1901,6 @@ nsPluginStreamPeer::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -78,6 +78,11 @@ include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl -I$(PUBLIC)\raptor -I_jri
|
||||
|
||||
!ifdef NEW_PLUGIN_STREAM_API
|
||||
LCFLAGS = $(LCFLAGS) -DNEW_PLUGIN_STREAM_API
|
||||
!endif
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
# $(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
$(MAKE_INSTALL) Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
$(MAKE_INSTALL) $(OBJDIR)\npsimple.dll $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple
|
||||
|
@ -249,19 +249,27 @@ public:
|
||||
NS_IMETHOD
|
||||
SetWindow(nsPluginWindow* window);
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPP_NewStream.)
|
||||
NS_IMETHOD
|
||||
NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result);
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPP_Print.)
|
||||
NS_IMETHOD
|
||||
Print(nsPluginPrint* platformPrint);
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
// (Corresponds to NPP_URLNotify.)
|
||||
NS_IMETHOD
|
||||
URLNotify(const char* url, const char* target,
|
||||
nsPluginReason reason, void* notifyData);
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_IMETHOD
|
||||
GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
|
||||
@ -302,6 +310,70 @@ protected:
|
||||
// SimplePluginStream represents the stream used by SimplePluginInstances
|
||||
// to receive data from the browser.
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
class SimplePluginStreamListener : public nsIPluginStreamListener {
|
||||
public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIPluginStreamListener:
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has started to load. This method is
|
||||
* called only once, at the beginning of a URL load.<BR><BR>
|
||||
*
|
||||
* @return The return value is currently ignored. In the future it may be
|
||||
* used to cancel the URL load..
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStartBinding(const char* url, const nsPluginStreamInfo* info);
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(const char* url, nsIPluginInputStream* input,
|
||||
PRUint32 offset, PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(const char* url, const char* fileName);
|
||||
|
||||
/**
|
||||
* Notify the observer that the URL has finished loading. This method is
|
||||
* called once when the networking library has finished processing the
|
||||
* URL transaction initiatied via the nsINetService::Open(...) call.<BR><BR>
|
||||
*
|
||||
* This method is called regardless of whether the URL loaded successfully.<BR><BR>
|
||||
*
|
||||
* @param status Status code for the URL load.
|
||||
* @param msg A text string describing the error.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnStopBinding(const char* url, nsresult status);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginStreamListener specific methods:
|
||||
|
||||
SimplePluginStreamListener(SimplePluginInstance* inst);
|
||||
virtual ~SimplePluginStreamListener(void);
|
||||
|
||||
protected:
|
||||
SimplePluginInstance* fInst;
|
||||
|
||||
};
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
class SimplePluginStream : public nsIPluginStream {
|
||||
public:
|
||||
|
||||
@ -350,19 +422,34 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
// Interface IDs we'll need:
|
||||
static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID);
|
||||
static NS_DEFINE_IID(kIJRILiveConnectPluginIID, NS_IJRILIVECONNECTPLUGIN_IID);
|
||||
static NS_DEFINE_IID(kIJRILiveConnectPluginInstancePeerIID, NS_IJRILIVECONNECTPLUGININSTANCEPEER_IID);
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamIID, NS_IPLUGINSTREAM_IID);
|
||||
static NS_DEFINE_IID(kIJRIEnvIID, NS_IJRIENV_IID);
|
||||
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
static NS_DEFINE_IID(kIPluginStreamIID, NS_IPLUGINSTREAM_IID);
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*******************************************************************************
|
||||
* SECTION 3 - API Plugin Implementations
|
||||
******************************************************************************/
|
||||
|
||||
// This counter is used to keep track of the number of outstanding objects.
|
||||
// It is used to determine whether the plugin's DLL can be unloaded.
|
||||
static PRUint32 gPluginObjectCount = 0;
|
||||
|
||||
// This flag is used to keep track of whether the plugin's DLL is explicitly
|
||||
// being retained by some client.
|
||||
static PRBool gPluginLocked = PR_FALSE;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePlugin Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -371,10 +458,12 @@ SimplePlugin::SimplePlugin()
|
||||
: mgr(NULL)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gPluginObjectCount++;
|
||||
}
|
||||
|
||||
SimplePlugin::~SimplePlugin(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
if (env)
|
||||
Simple::_unuse(env);
|
||||
}
|
||||
@ -436,6 +525,12 @@ NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
|
||||
return NS_ERROR_FAILURE; // XXX right error?
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRBool
|
||||
NSCanUnload(void)
|
||||
{
|
||||
return gPluginObjectCount == 1 && !gPluginLocked;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePlugin::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
@ -443,13 +538,14 @@ SimplePlugin::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
if (inst == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
inst->AddRef();
|
||||
*aResult = inst;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePlugin::LockFactory(PRBool aLock)
|
||||
{
|
||||
// XXX what to do here?
|
||||
gPluginLocked = aLock;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -457,7 +553,7 @@ NS_METHOD
|
||||
SimplePlugin::Initialize(nsISupports* browserInterfaces)
|
||||
{
|
||||
if (browserInterfaces->QueryInterface(kIPluginManagerIID,
|
||||
(void**)mgr) != NS_OK) {
|
||||
(void**)&mgr) != NS_OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
@ -542,10 +638,12 @@ SimplePluginInstance::SimplePluginInstance(void)
|
||||
: fPeer(NULL), fWindow(NULL), fMode(nsPluginMode_Embedded)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
gPluginObjectCount++;
|
||||
}
|
||||
|
||||
SimplePluginInstance::~SimplePluginInstance(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
PlatformDestroy(); // Perform platform specific cleanup
|
||||
DisplayJavaMessage("Calling SimplePluginInstance::Release.", -1);
|
||||
}
|
||||
@ -572,6 +670,7 @@ NS_METHOD
|
||||
SimplePluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||
{
|
||||
fPeer = peer;
|
||||
peer->AddRef();
|
||||
nsresult err = peer->GetMode(&fMode);
|
||||
if (err) return err;
|
||||
PlatformNew(); /* Call Platform-specific initializations */
|
||||
@ -656,6 +755,8 @@ SimplePluginInstance::SetWindow(nsPluginWindow* window)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* NewStream:
|
||||
* Notifies an instance of a new data stream and returns an error value.
|
||||
@ -678,6 +779,8 @@ SimplePluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *res
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* NPP_Print:
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++*/
|
||||
@ -754,6 +857,8 @@ SimplePluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* URLNotify:
|
||||
* Notifies the instance of the completion of a URL request.
|
||||
@ -781,12 +886,76 @@ SimplePluginInstance::URLNotify(const char* url, const char* target,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif // NEW_PLUGIN_STREAM_API
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginInstance::GetValue(nsPluginInstanceVariable variable, void *value)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginStreamListener Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SimplePluginStreamListener::SimplePluginStreamListener(SimplePluginInstance* inst)
|
||||
: fInst(inst)
|
||||
{
|
||||
gPluginObjectCount++;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
SimplePluginStreamListener::~SimplePluginStreamListener(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
fInst->DisplayJavaMessage("Calling SimplePluginStream destructor.", -1);
|
||||
}
|
||||
|
||||
// This macro produces a simple version of QueryInterface, AddRef and Release.
|
||||
// See the nsISupports.h header file for details.
|
||||
|
||||
NS_IMPL_ISUPPORTS(SimplePluginStreamListener, kIPluginStreamListenerIID);
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnStartBinding(const char* url, const nsPluginStreamInfo* info)
|
||||
{
|
||||
fInst->DisplayJavaMessage("Opening plugin stream.", -1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnDataAvailable(const char* url, nsIPluginInputStream* input,
|
||||
PRUint32 offset, PRUint32 length)
|
||||
{
|
||||
char* buffer = new char[length];
|
||||
if (buffer) {
|
||||
PRInt32 amountRead = 0;
|
||||
nsresult rslt = input->Read(buffer, offset, length, &amountRead);
|
||||
if (rslt == NS_OK)
|
||||
fInst->DisplayJavaMessage(buffer, amountRead);
|
||||
delete buffer;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnFileAvailable(const char* url, const char* fileName)
|
||||
{
|
||||
fInst->DisplayJavaMessage("Calling SimplePluginStreamListener::OnFileAvailable.", -1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnStopBinding(const char* url, nsresult status)
|
||||
{
|
||||
fInst->DisplayJavaMessage("Closing plugin stream.", -1);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginStream Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -795,11 +964,13 @@ SimplePluginStream::SimplePluginStream(nsIPluginStreamPeer* peer,
|
||||
SimplePluginInstance* inst)
|
||||
: fPeer(peer), fInst(inst)
|
||||
{
|
||||
gPluginObjectCount++;
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
SimplePluginStream::~SimplePluginStream(void)
|
||||
{
|
||||
gPluginObjectCount--;
|
||||
fInst->DisplayJavaMessage("Calling SimplePluginStream::Release.", -1);
|
||||
}
|
||||
|
||||
@ -875,7 +1046,7 @@ SimplePluginStream::AsFile(const char* fname)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#endif // !NEW_PLUGIN_STREAM_API
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user