diff --git a/mozilla/modules/plugin/bad/badapter.cpp b/mozilla/modules/plugin/bad/badapter.cpp
index d5e4845cf78..d2cbbdca919 100644
--- a/mozilla/modules/plugin/bad/badapter.cpp
+++ b/mozilla/modules/plugin/bad/badapter.cpp
@@ -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)
diff --git a/mozilla/modules/plugin/base/public/Makefile b/mozilla/modules/plugin/base/public/Makefile
index a9a67df8278..d0c3e5b5848 100644
--- a/mozilla/modules/plugin/base/public/Makefile
+++ b/mozilla/modules/plugin/base/public/Makefile
@@ -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
diff --git a/mozilla/modules/plugin/base/public/Makefile.in b/mozilla/modules/plugin/base/public/Makefile.in
index f10c41b5676..6d5122e405e 100644
--- a/mozilla/modules/plugin/base/public/Makefile.in
+++ b/mozilla/modules/plugin/base/public/Makefile.in
@@ -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
diff --git a/mozilla/modules/plugin/base/public/makefile.win b/mozilla/modules/plugin/base/public/makefile.win
index 9db9fe57661..37a54a3c85a 100644
--- a/mozilla/modules/plugin/base/public/makefile.win
+++ b/mozilla/modules/plugin/base/public/makefile.win
@@ -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>
diff --git a/mozilla/modules/plugin/base/public/nsIPluginInstance.h b/mozilla/modules/plugin/base/public/nsIPluginInstance.h
index 4f0a6b1256e..2d27139a05f 100644
--- a/mozilla/modules/plugin/base/public/nsIPluginInstance.h
+++ b/mozilla/modules/plugin/base/public/nsIPluginInstance.h
@@ -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.
diff --git a/mozilla/modules/plugin/base/public/nsIPluginManager.h b/mozilla/modules/plugin/base/public/nsIPluginManager.h
index de04e5ec71e..4b1c09c24b7 100644
--- a/mozilla/modules/plugin/base/public/nsIPluginManager.h
+++ b/mozilla/modules/plugin/base/public/nsIPluginManager.h
@@ -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
};
diff --git a/mozilla/modules/plugin/base/public/nsIPluginManager2.h b/mozilla/modules/plugin/base/public/nsIPluginManager2.h
index ec4aad7e6a9..3ebd1c7fa9f 100644
--- a/mozilla/modules/plugin/base/public/nsIPluginManager2.h
+++ b/mozilla/modules/plugin/base/public/nsIPluginManager2.h
@@ -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 \
diff --git a/mozilla/modules/plugin/base/public/nsIPluginStream.h b/mozilla/modules/plugin/base/public/nsIPluginStream.h
index 4389b6280da..99f29c0aa03 100644
--- a/mozilla/modules/plugin/base/public/nsIPluginStream.h
+++ b/mozilla/modules/plugin/base/public/nsIPluginStream.h
@@ -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___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.h b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.h
index 3b9de94d8e0..50e9512fd04 100644
--- a/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.h
+++ b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer.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___ */
diff --git a/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.h b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.h
index bc686306c3c..07b0b174608 100644
--- a/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.h
+++ b/mozilla/modules/plugin/base/public/nsIPluginStreamPeer2.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___ */
diff --git a/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.h b/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.h
index 85b2ced1bfb..6e7ed03fdce 100644
--- a/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.h
+++ b/mozilla/modules/plugin/base/public/nsISeekablePluginStreamPeer.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___ */
diff --git a/mozilla/modules/plugin/base/public/nsplugin.h b/mozilla/modules/plugin/base/public/nsplugin.h
index d901c8bc672..9f6645a7763 100644
--- a/mozilla/modules/plugin/base/public/nsplugin.h
+++ b/mozilla/modules/plugin/base/public/nsplugin.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
+
////////////////////////////////////////////////////////////////////////////////
/**
* 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___
diff --git a/mozilla/modules/plugin/public/Makefile b/mozilla/modules/plugin/public/Makefile
index a9a67df8278..d0c3e5b5848 100644
--- a/mozilla/modules/plugin/public/Makefile
+++ b/mozilla/modules/plugin/public/Makefile
@@ -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
diff --git a/mozilla/modules/plugin/public/Makefile.in b/mozilla/modules/plugin/public/Makefile.in
index f10c41b5676..6d5122e405e 100644
--- a/mozilla/modules/plugin/public/Makefile.in
+++ b/mozilla/modules/plugin/public/Makefile.in
@@ -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
diff --git a/mozilla/modules/plugin/public/makefile.win b/mozilla/modules/plugin/public/makefile.win
index 9db9fe57661..37a54a3c85a 100644
--- a/mozilla/modules/plugin/public/makefile.win
+++ b/mozilla/modules/plugin/public/makefile.win
@@ -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>
diff --git a/mozilla/modules/plugin/public/nsIPluginInstance.h b/mozilla/modules/plugin/public/nsIPluginInstance.h
index 4f0a6b1256e..2d27139a05f 100644
--- a/mozilla/modules/plugin/public/nsIPluginInstance.h
+++ b/mozilla/modules/plugin/public/nsIPluginInstance.h
@@ -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.
diff --git a/mozilla/modules/plugin/public/nsIPluginManager.h b/mozilla/modules/plugin/public/nsIPluginManager.h
index de04e5ec71e..4b1c09c24b7 100644
--- a/mozilla/modules/plugin/public/nsIPluginManager.h
+++ b/mozilla/modules/plugin/public/nsIPluginManager.h
@@ -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
};
diff --git a/mozilla/modules/plugin/public/nsIPluginManager2.h b/mozilla/modules/plugin/public/nsIPluginManager2.h
index ec4aad7e6a9..3ebd1c7fa9f 100644
--- a/mozilla/modules/plugin/public/nsIPluginManager2.h
+++ b/mozilla/modules/plugin/public/nsIPluginManager2.h
@@ -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 \
diff --git a/mozilla/modules/plugin/public/nsIPluginStream.h b/mozilla/modules/plugin/public/nsIPluginStream.h
index 4389b6280da..99f29c0aa03 100644
--- a/mozilla/modules/plugin/public/nsIPluginStream.h
+++ b/mozilla/modules/plugin/public/nsIPluginStream.h
@@ -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___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginStreamPeer.h b/mozilla/modules/plugin/public/nsIPluginStreamPeer.h
index 3b9de94d8e0..50e9512fd04 100644
--- a/mozilla/modules/plugin/public/nsIPluginStreamPeer.h
+++ b/mozilla/modules/plugin/public/nsIPluginStreamPeer.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___ */
diff --git a/mozilla/modules/plugin/public/nsIPluginStreamPeer2.h b/mozilla/modules/plugin/public/nsIPluginStreamPeer2.h
index bc686306c3c..07b0b174608 100644
--- a/mozilla/modules/plugin/public/nsIPluginStreamPeer2.h
+++ b/mozilla/modules/plugin/public/nsIPluginStreamPeer2.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___ */
diff --git a/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.h b/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.h
index 85b2ced1bfb..6e7ed03fdce 100644
--- a/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.h
+++ b/mozilla/modules/plugin/public/nsISeekablePluginStreamPeer.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___ */
diff --git a/mozilla/modules/plugin/public/nsplugin.h b/mozilla/modules/plugin/public/nsplugin.h
index d901c8bc672..9f6645a7763 100644
--- a/mozilla/modules/plugin/public/nsplugin.h
+++ b/mozilla/modules/plugin/public/nsplugin.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
+
////////////////////////////////////////////////////////////////////////////////
/**
* 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___
diff --git a/mozilla/modules/plugin/samples/backward/badapter.cpp b/mozilla/modules/plugin/samples/backward/badapter.cpp
index d5e4845cf78..d2cbbdca919 100644
--- a/mozilla/modules/plugin/samples/backward/badapter.cpp
+++ b/mozilla/modules/plugin/samples/backward/badapter.cpp
@@ -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)
diff --git a/mozilla/modules/plugin/samples/simple/makefile.win b/mozilla/modules/plugin/samples/simple/makefile.win
index 94ce1054697..c5ccfd69d0e 100644
--- a/mozilla/modules/plugin/samples/simple/makefile.win
+++ b/mozilla/modules/plugin/samples/simple/makefile.win
@@ -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
diff --git a/mozilla/modules/plugin/samples/simple/npsimple.cpp b/mozilla/modules/plugin/samples/simple/npsimple.cpp
index 89d8d677c4e..b550dc9ce34 100644
--- a/mozilla/modules/plugin/samples/simple/npsimple.cpp
+++ b/mozilla/modules/plugin/samples/simple/npsimple.cpp
@@ -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.
+ *
+ * @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...
+ *
+ * @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.
+ *
+ * This method is called regardless of whether the URL loaded successfully.
+ *
+ * @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
/*******************************************************************************
diff --git a/mozilla/modules/plugin/src/makefile.win b/mozilla/modules/plugin/src/makefile.win
index d59836e1adf..83ff08ac706 100644
--- a/mozilla/modules/plugin/src/makefile.win
+++ b/mozilla/modules/plugin/src/makefile.win
@@ -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)
diff --git a/mozilla/modules/plugin/src/npglue.cpp b/mozilla/modules/plugin/src/npglue.cpp
index 0e20d4a8fca..13739079da0 100644
--- a/mozilla/modules/plugin/src/npglue.cpp
+++ b/mozilla/modules/plugin/src/npglue.cpp
@@ -62,6 +62,11 @@ int np_debug = 0;
static XP_Bool gForcingRedraw = FALSE;
#endif /* XP_MAC */
+#define NP_GET_URL_APP(urls) ((NPEmbeddedApp*)((urls)->fe_data))
+#define NP_SET_URL_APP(urls, a) ((urls)->fe_data = (void*)(a))
+
+#define NP_GET_PLUGIN_INSTANCE(npp) ((nsIPluginInstance*)((np_data*)((np_instance*)(npp)->ndata)->app->np_data)->sdata)
+
NPNetscapeFuncs npp_funcs;
/*
@@ -78,18 +83,18 @@ np_is50StylePlugin(np_handle* handle)
static np_mimetype *
np_getmimetype(np_handle *handle, const char *mimeStr, XP_Bool wildCard)
{
- np_mimetype *mimetype;
+ np_mimetype *mimetype;
- for (mimetype = handle->mimetypes; mimetype; mimetype = mimetype->next)
- {
- if (mimetype->enabled)
- {
- if ((wildCard && !strcmp(mimetype->type, "*")) ||
- !strcasecomp(mimetype->type, mimeStr))
- return (mimetype);
- }
- }
- return (NULL);
+ for (mimetype = handle->mimetypes; mimetype; mimetype = mimetype->next)
+ {
+ if (mimetype->enabled)
+ {
+ if ((wildCard && !strcmp(mimetype->type, "*")) ||
+ !strcasecomp(mimetype->type, mimeStr))
+ return (mimetype);
+ }
+ }
+ return (NULL);
}
@@ -100,12 +105,12 @@ np_getmimetype(np_handle *handle, const char *mimeStr, XP_Bool wildCard)
static NPReason
np_statusToReason(int status)
{
- if (status == MK_DATA_LOADED)
- return NPRES_DONE;
- else if (status == MK_INTERRUPTED)
- return NPRES_USER_BREAK;
- else
- return NPRES_NETWORK_ERR;
+ if (status == MK_DATA_LOADED)
+ return NPRES_DONE;
+ else if (status == MK_INTERRUPTED)
+ return NPRES_USER_BREAK;
+ else
+ return NPRES_NETWORK_ERR;
}
@@ -117,23 +122,23 @@ np_statusToReason(int status)
static np_urlsnode*
np_addURLtoList(np_instance* instance)
{
- np_urlsnode* node;
+ np_urlsnode* node;
- if (!instance)
- return NULL;
+ if (!instance)
+ return NULL;
- if (!instance->url_list)
- instance->url_list = XP_ListNew();
- if (!instance->url_list)
- return NULL;
+ if (!instance->url_list)
+ instance->url_list = XP_ListNew();
+ if (!instance->url_list)
+ return NULL;
- node = XP_NEW_ZAP(np_urlsnode);
- if (!node)
- return NULL;
+ node = XP_NEW_ZAP(np_urlsnode);
+ if (!node)
+ return NULL;
- XP_ListAddObject(instance->url_list, node);
+ XP_ListAddObject(instance->url_list, node);
- return node;
+ return node;
}
@@ -148,36 +153,46 @@ np_addURLtoList(np_instance* instance)
static void
np_processURLNode(np_urlsnode* node, np_instance* instance, int status)
{
- if (node->cached)
- {
- /* Unlock the cache file */
- XP_ASSERT(!node->notify);
- if (node->urls)
- {
- NET_ChangeCacheFileLock(node->urls, NP_UNLOCK);
+ if (node->cached)
+ {
+ /* Unlock the cache file */
+ XP_ASSERT(!node->notify);
+ if (node->urls)
+ {
+ NET_ChangeCacheFileLock(node->urls, NP_UNLOCK);
- NET_FreeURLStruct(node->urls);
- node->urls = NULL;
+ NET_FreeURLStruct(node->urls);
+ node->urls = NULL;
}
- return;
- }
+ return;
+ }
- if (node->notify)
- {
- /* Notify the plug-in */
- XP_ASSERT(!node->cached);
+ if (node->notify)
+ {
+ /* Notify the plug-in */
+ XP_ASSERT(!node->cached);
if (instance) {
TRACEMSG(("npglue.c: CallNPP_URLNotifyProc"));
if (np_is50StylePlugin(instance->handle)) {
- nsPluginInstancePeer* peerInst = (nsPluginInstancePeer*)instance->npp->pdata;
- nsIPluginInstance* pluginInst = peerInst->GetPluginInstance();
+#ifdef NEW_PLUGIN_STREAM_API
+
+ nsPluginInputStream* inStr = (nsPluginInputStream*)node->notifyData;
+ nsIPluginStreamListener* listener = inStr->GetListener();
+ nsresult err = listener->OnStopBinding(node->urls->address,
+ (nsPluginReason)np_statusToReason(status));
+ // XXX ignore error?
+
+#else // !NEW_PLUGIN_STREAM_API
+
+ nsIPluginInstance* pluginInst = NP_GET_PLUGIN_INSTANCE(instance->npp);
if (pluginInst != NULL) {
pluginInst->URLNotify(node->urls->address, node->urls->window_target,
- (nsPluginReason)np_statusToReason(status),
- node->notifyData);
- pluginInst->Release();
+ (nsPluginReason)np_statusToReason(status),
+ node->notifyData);
}
+
+#endif // !NEW_PLUGIN_STREAM_API
}
else if (ISFUNCPTR(instance->handle->f->urlnotify)) {
CallNPP_URLNotifyProc(instance->handle->f->urlnotify,
@@ -186,15 +201,35 @@ np_processURLNode(np_urlsnode* node, np_instance* instance, int status)
np_statusToReason(status),
node->notifyData);
}
- }
- }
+ }
+ }
- /* Break the reference from the URL to the instance */
- if (node->urls)
- node->urls->fe_data = NULL;
+ /* Break the reference from the URL to the instance */
+ if (node->urls) {
+ NP_SET_URL_APP(node->urls, NULL);
+ }
}
+static np_urlsnode*
+np_getURLfromList(np_instance* instance, URL_Struct* urls)
+{
+ XP_List* url_list;
+ np_urlsnode* node;
+
+ if (!instance || !urls || !instance->url_list)
+ return NULL;
+
+ /* Look for the URL in the list */
+ url_list = instance->url_list;
+ while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
+ {
+ if (node->urls == urls)
+ return node;
+ }
+ return NULL;
+}
+
/*
* Remove an individual URL from the list of URLs for this instance.
*/
@@ -213,20 +248,20 @@ np_removeURLfromList(np_instance* instance, URL_Struct* urls, int status)
{
if (node->urls == urls)
{
- XP_ASSERT(!node->cached);
- np_processURLNode(node, instance, status);
+ XP_ASSERT(!node->cached);
+ np_processURLNode(node, instance, status);
- XP_ListRemoveObject(instance->url_list, node);
- XP_FREE(node);
+ XP_ListRemoveObject(instance->url_list, node);
+ XP_FREE(node);
- /* If the list is now empty, delete it */
- if (XP_ListCount(instance->url_list) == 0)
- {
- XP_ListDestroy(instance->url_list);
- instance->url_list = NULL;
- }
+ /* If the list is now empty, delete it */
+ if (XP_ListCount(instance->url_list) == 0)
+ {
+ XP_ListDestroy(instance->url_list);
+ instance->url_list = NULL;
+ }
- return;
+ return;
}
}
}
@@ -238,29 +273,29 @@ np_removeURLfromList(np_instance* instance, URL_Struct* urls, int status)
static void
np_removeAllURLsFromList(np_instance* instance)
{
- XP_List* url_list;
+ XP_List* url_list;
np_urlsnode* node;
if (!instance || !instance->url_list)
return;
- url_list = instance->url_list;
- while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
- {
- /* No notification of URLs now: the instance is going away */
- node->notify = FALSE;
- np_processURLNode(node, instance, 0);
- }
+ url_list = instance->url_list;
+ while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
+ {
+ /* No notification of URLs now: the instance is going away */
+ node->notify = FALSE;
+ np_processURLNode(node, instance, 0);
+ }
- /* Remove all elements from the list */
- url_list = instance->url_list;
+ /* Remove all elements from the list */
+ url_list = instance->url_list;
while ((node = (np_urlsnode*)XP_ListRemoveTopObject(url_list)) != NULL)
XP_FREE(node);
- /* The list should now be empty, so delete it */
- XP_ASSERT(XP_ListCount(instance->url_list) == 0);
- XP_ListDestroy(instance->url_list);
- instance->url_list = NULL;
+ /* The list should now be empty, so delete it */
+ XP_ASSERT(XP_ListCount(instance->url_list) == 0);
+ XP_ListDestroy(instance->url_list);
+ instance->url_list = NULL;
}
@@ -277,7 +312,7 @@ np_get_stream(URL_Struct *urls)
{
if(urls)
{
- NPEmbeddedApp *pEmbeddedApp = (NPEmbeddedApp*)urls->fe_data;
+ NPEmbeddedApp *pEmbeddedApp = NP_GET_URL_APP(urls);
if(pEmbeddedApp)
{
np_data *ndata = (np_data *)pEmbeddedApp->np_data;
@@ -286,23 +321,23 @@ np_get_stream(URL_Struct *urls)
np_stream *stream;
for (stream=ndata->instance->streams; stream; stream=stream->next)
{
- /*
- * Matching algorithm: Either this URL is the inital URL for
- * the stream, or it's a URL generated by a subsequent byte-
- * range request. We don't bother to keep track of all the
- * URLs for byte-range requests, but we can still detect if
- * the URL matches this stream: since we know that this URL
- * belongs to one of the streams for this instance and that
- * there can only be one seekable stream for an instance
- * active at a time, then we know if this stream is seekable
- * and the URL is a byte-range URL then they must match.
- * NOTE: We check both urls->high_range and urls->range_header
- * because we could have been called before the range_header
- * has been parsed and the high_range set.
- */
- if ((stream->initial_urls == urls) ||
- (stream->seek && (urls->high_range || urls->range_header)))
- return stream;
+ /*
+ * Matching algorithm: Either this URL is the inital URL for
+ * the stream, or it's a URL generated by a subsequent byte-
+ * range request. We don't bother to keep track of all the
+ * URLs for byte-range requests, but we can still detect if
+ * the URL matches this stream: since we know that this URL
+ * belongs to one of the streams for this instance and that
+ * there can only be one seekable stream for an instance
+ * active at a time, then we know if this stream is seekable
+ * and the URL is a byte-range URL then they must match.
+ * NOTE: We check both urls->high_range and urls->range_header
+ * because we could have been called before the range_header
+ * has been parsed and the high_range set.
+ */
+ if ((stream->initial_urls == urls) ||
+ (stream->seek && (urls->high_range || urls->range_header)))
+ return stream;
}
}
}
@@ -323,15 +358,15 @@ np_get_stream(URL_Struct *urls)
static np_stream*
np_makestreamobjects(np_instance* instance, NET_StreamClass* netstream, URL_Struct* urls)
{
- np_stream* stream;
- NPStream* pstream;
+ np_stream* stream;
+ NPStream* pstream;
XP_List* url_list;
np_urlsnode* node;
void* notifyData;
- /* check params */
- if (!instance || !netstream || !urls)
- return NULL;
+ /* check params */
+ if (!instance || !netstream || !urls)
+ return NULL;
/* make a npglue stream */
stream = XP_NEW_ZAP(np_stream);
@@ -347,15 +382,15 @@ np_makestreamobjects(np_instance* instance, NET_StreamClass* netstream, URL_Stru
StrAllocCopy(stream->url, urls->address);
stream->len = urls->content_length;
- /* Look for notification data for this URL */
- notifyData = NULL;
+ /* Look for notification data for this URL */
+ notifyData = NULL;
url_list = instance->url_list;
while ((node = (np_urlsnode*)XP_ListNextObject(url_list)) != NULL)
{
if (node->urls == urls && node->notify)
{
- notifyData = node->notifyData;
- break;
+ notifyData = node->notifyData;
+ break;
}
}
@@ -370,7 +405,7 @@ np_makestreamobjects(np_instance* instance, NET_StreamClass* netstream, URL_Stru
pstream->url = stream->url;
pstream->end = urls->content_length;
pstream->lastmodified = (uint32) urls->last_modified;
- pstream->notifyData = notifyData;
+ pstream->notifyData = notifyData;
/* make a record of it */
stream->pstream = pstream;
@@ -379,7 +414,7 @@ np_makestreamobjects(np_instance* instance, NET_StreamClass* netstream, URL_Stru
NPTRACE(0,("np: new stream, %s, %s", instance->mimetype->type, urls->address));
- return stream;
+ return stream;
}
/*
@@ -391,7 +426,7 @@ np_makestreamobjects(np_instance* instance, NET_StreamClass* netstream, URL_Stru
static void
np_deletestreamobjects(np_stream* stream)
{
- np_instance* instance = stream->instance;
+ np_instance* instance = stream->instance;
/* remove it from the instance list */
if (stream == instance->streams)
@@ -427,7 +462,7 @@ np_deletestreamobjects(np_stream* stream)
static void
np_dofetch(URL_Struct *urls, int status, MWContext *window_id)
{
- np_stream *stream = np_get_stream(urls);
+ np_stream *stream = np_get_stream(urls);
if(stream && stream->instance)
{
FE_GetURL(stream->instance->cx, stream->instance->delayedload);
@@ -445,15 +480,15 @@ NPL_WriteReady(NET_StreamClass *stream)
if(!(newstream = np_get_stream(urls)))
return 0;
- if (newstream->asfile == NP_ASFILEONLY)
- return NP_MAXREADY;
+ if (newstream->asfile == NP_ASFILEONLY)
+ return NP_MAXREADY;
- /* if prev_stream is not ready to write, then neither is this one... */
- if (newstream->prev_stream != NULL){
- ret = (newstream->prev_stream->is_write_ready(newstream->prev_stream));
- if (ret == FALSE)
- return FALSE;
- }
+ /* if prev_stream is not ready to write, then neither is this one... */
+ if (newstream->prev_stream != NULL){
+ ret = (newstream->prev_stream->is_write_ready(newstream->prev_stream));
+ if (ret == FALSE)
+ return FALSE;
+ }
XP_ASSERT(newstream->instance);
newstream->instance->reentrant = 1;
@@ -478,18 +513,18 @@ NPL_WriteReady(NET_StreamClass *stream)
ret = NP_MAXREADY;
#if defined(XP_WIN) || defined(XP_OS2)
- /* Prevent WinFE from going to sleep when plug-in blocks */
- if (ret == 0){
- if(!newstream->instance->calling_netlib_all_the_time){
- newstream->instance->calling_netlib_all_the_time = TRUE;
- NET_SetCallNetlibAllTheTime(newstream->instance->cx, "npglue");
- }
- else{
+ /* Prevent WinFE from going to sleep when plug-in blocks */
+ if (ret == 0){
+ if(!newstream->instance->calling_netlib_all_the_time){
+ newstream->instance->calling_netlib_all_the_time = TRUE;
+ NET_SetCallNetlibAllTheTime(newstream->instance->cx, "npglue");
+ }
+ else{
- NET_ClearCallNetlibAllTheTime(newstream->instance->cx, "npglue");
- newstream->instance->calling_netlib_all_the_time = FALSE;
- }
- }
+ NET_ClearCallNetlibAllTheTime(newstream->instance->cx, "npglue");
+ newstream->instance->calling_netlib_all_the_time = FALSE;
+ }
+ }
#endif
if(!newstream->instance->reentrant)
{
@@ -511,13 +546,13 @@ NPL_Write(NET_StreamClass *stream, const unsigned char *str, int32 len)
if(!newstream || !(newstream->handle->userPlugin ? 1 : ISFUNCPTR(newstream->handle->f->write)))
return -1;
- if (newstream->asfile == NP_ASFILEONLY)
- return len;
+ if (newstream->asfile == NP_ASFILEONLY)
+ return len;
- if (newstream->prev_stream != NULL){
- ret = newstream->prev_stream->put_block(newstream->prev_stream,(const char *)str,len);
- /* should put check here for ret == len? if not, then what? */
- }
+ if (newstream->prev_stream != NULL){
+ ret = newstream->prev_stream->put_block(newstream->prev_stream,(const char *)str,len);
+ /* should put check here for ret == len? if not, then what? */
+ }
/* if this is the first non seek write after we turned the
@@ -541,14 +576,26 @@ NPL_Write(NET_StreamClass *stream, const unsigned char *str, int32 len)
urls->position = urls->low_range;
}
/*TRACEMSG(("npglue.c: CallNPP_WriteProc"));
- */
+ */
if (newstream->handle->userPlugin) {
+#ifdef NEW_PLUGIN_STREAM_API
+
+ nsPluginInputStream* instr = (nsPluginInputStream*)newstream->pstream->pdata;
+ nsIPluginStreamListener* listener = instr->GetListener();
+ instr->SetReadBuffer(len, (const char*)str);
+ nsresult err = listener->OnDataAvailable((const char*)urls->address, instr, urls->position, len);
+ PR_ASSERT(err == NS_OK); // XXX this error should go somewhere
+
+#else // !NEW_PLUGIN_STREAM_API
+
nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)newstream->pstream->pdata;
nsIPluginStream* userStream = peerStream->GetUserStream();
PRInt32 written;
nsresult err = userStream->Write((const char*)str, 0, len, &written);
PR_ASSERT(err == NS_OK); // XXX this error should go somewhere
PR_ASSERT(written == len);
+
+#endif // !NEW_PLUGIN_STREAM_API
}
else if (ISFUNCPTR(newstream->handle->f->write)) {
ret = CallNPP_WriteProc(newstream->handle->f->write, newstream->instance->npp, newstream->pstream,
@@ -588,11 +635,11 @@ np_make_byterange_string(NPByteRange *ranges)
iBytesEqualsLen = strlen(RANGE_EQUALS);
- /* the range must begin with bytes=
- * a final range string looks like:
- * bytes=5-8,12-56
- */
- XP_STRCPY(burl, RANGE_EQUALS);
+ /* the range must begin with bytes=
+ * a final range string looks like:
+ * bytes=5-8,12-56
+ */
+ XP_STRCPY(burl, RANGE_EQUALS);
for(br=ranges; br; br=br->next)
{
@@ -659,13 +706,13 @@ np_unlock(np_stream *stream)
}
static void
-np_GetURL(URL_Struct *pURL,FO_Present_Types iFormatOut,MWContext *cx, Net_GetUrlExitFunc *pExitFunc, NPBool notify){
-
- XP_ASSERT(pURL->owner_data == NULL);
- pURL->owner_id = 0x0000BAC0; /* plugin's unique identifier */
- pURL->owner_data = pURL->fe_data;
- pURL->fe_data = NULL;
- FE_GetURL(cx,pURL);
+np_GetURL(URL_Struct *pURL,FO_Present_Types iFormatOut,MWContext *cx, Net_GetUrlExitFunc *pExitFunc, NPBool notify)
+{
+ XP_ASSERT(pURL->owner_data == NULL);
+ pURL->owner_id = 0x0000BAC0; /* plugin's unique identifier */
+ pURL->owner_data = pURL->fe_data;
+ pURL->fe_data = NULL;
+ FE_GetURL(cx,pURL);
}
@@ -735,7 +782,7 @@ npn_requestread(NPStream *pstream, NPByteRange *rangeList)
XP_ASSERT(stream->instance);
if(stream->instance)
{
- urls->fe_data = (void *)stream->instance->app;
+ NP_SET_URL_APP(urls, stream->instance->app);
(void) NET_GetURL(urls, FO_CACHE_AND_BYTERANGE, stream->instance->cx, NPL_URLExit);
}
}
@@ -755,18 +802,23 @@ np_destroystream(np_stream *stream, NPError reason)
np_instance *instance = stream->instance;
TRACEMSG(("npglue.c: CallNPP_DestroyStreamProc"));
if (stream->handle->userPlugin) {
+#ifdef NEW_PLUGIN_STREAM_API
+ nsPluginInputStream* inStr = (nsPluginInputStream*)stream->pstream->pdata;
+ inStr->Release();
+#else // !NEW_PLUGIN_STREAM_API
nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)stream->pstream->pdata;
nsIPluginStream* userStream = peerStream->GetUserStream();
peerStream->SetReason((nsPluginReason)reason);
userStream->Close();
peerStream->Release();
+#endif // !NEW_PLUGIN_STREAM_API
}
else if (ISFUNCPTR(stream->handle->f->destroystream)) {
CallNPP_DestroyStreamProc(stream->handle->f->destroystream, instance->npp, stream->pstream, reason);
}
- /* Delete the np_stream and associated NPStream objects */
- np_deletestreamobjects(stream);
+ /* Delete the np_stream and associated NPStream objects */
+ np_deletestreamobjects(stream);
}
}
@@ -820,9 +872,17 @@ np_streamAsFile(np_stream* stream)
/* fname can be NULL if something went wrong */
TRACEMSG(("npglue.c: CallNPP_StreamAsFileProc"));
if (stream->handle->userPlugin) {
+#ifdef NEW_PLUGIN_STREAM_API
+ nsPluginInputStream* instr = (nsPluginInputStream*)stream->pstream->pdata;
+ nsIPluginStreamListener* listener = instr->GetListener();
+ nsresult err = listener->OnFileAvailable(stream->url, fname);
+ PR_ASSERT(err == NS_OK);
+ // XXX ignore error?
+#else // !NEW_PLUGIN_STREAM_API
nsPluginStreamPeer* peerStream = (nsPluginStreamPeer*)stream->pstream->pdata;
nsIPluginStream* userStream = peerStream->GetUserStream();
userStream->AsFile(fname);
+#endif // !NEW_PLUGIN_STREAM_API
}
else if (ISFUNCPTR(stream->handle->f->asfile)) {
CallNPP_StreamAsFileProc(stream->handle->f->asfile, stream->instance->npp,
@@ -963,7 +1023,7 @@ NPL_URLExit(URL_Struct *urls, int status, MWContext *cx)
(urls->owner_id == 0x0000BAC0))
urls->fe_data = urls->owner_data;
- app = (NPEmbeddedApp*) urls->fe_data;
+ app = NP_GET_URL_APP(urls);
pstream = np_get_stream(urls);
if (pstream)
@@ -1004,8 +1064,6 @@ NPL_URLExit(URL_Struct *urls, int status, MWContext *cx)
}
}
-
-
static URL_Struct*
np_makeurlstruct(np_instance* instance, const char* relativeURL,
@@ -1099,7 +1157,7 @@ np_geturlinternal(NPP npp, const char* relativeURL, const char* target,
np_urlsnode* node = NULL;
NPError err = NPERR_NO_ERROR;
#ifdef XP_WIN32
- void* pPrevState;
+ void* pPrevState;
#endif
if (!npp || !relativeURL) /* OK for window to be NULL */
@@ -1115,29 +1173,29 @@ np_geturlinternal(NPP npp, const char* relativeURL, const char* target,
{
err = NPERR_OUT_OF_MEMORY_ERROR;
goto error;
- }
+ }
- /*
- * Add this URL to the list of URLs for this instance,
- * and remember if the instance would like notification.
- */
- node = np_addURLtoList(instance);
- if (node)
- {
- node->urls = urls;
- if (notify)
- {
- node->notify = TRUE;
- node->notifyData = notifyData;
- }
- }
- else
- {
+ /*
+ * Add this URL to the list of URLs for this instance,
+ * and remember if the instance would like notification.
+ */
+ node = np_addURLtoList(instance);
+ if (node)
+ {
+ node->urls = urls;
+ if (notify)
+ {
+ node->notify = TRUE;
+ node->notifyData = notifyData;
+ }
+ }
+ else
+ {
err = NPERR_OUT_OF_MEMORY_ERROR;
goto error;
- }
+ }
- urls->fe_data = (void*) instance->app;
+ NP_SET_URL_APP(urls, instance->app);
/*
* If the plug-in passed NULL for the target, load the URL with a special stream
@@ -1146,35 +1204,35 @@ np_geturlinternal(NPP npp, const char* relativeURL, const char* target,
* the plug-in in the process, if the target context is the plug-in's context).
*/
if (!target)
- {
+ {
#ifdef XP_WIN32
- pPrevState = WFE_BeginSetModuleState();
+ pPrevState = WFE_BeginSetModuleState();
#endif
(void) NET_GetURL(urls, FO_CACHE_AND_PLUGIN, instance->cx, NPL_URLExit);
#ifdef XP_WIN32
- WFE_EndSetModuleState(pPrevState);
+ WFE_EndSetModuleState(pPrevState);
#endif
}
- else
+ else
{
cx = np_makecontext(instance, target);
- if (!cx)
- {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- goto error;
- }
+ if (!cx)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
- /*
- * Prevent loading "about:" URLs into the plug-in's context: NET_GetURL
- * for these URLs will complete immediately, and the new layout thus
- * generated will blow away the plug-in and possibly unload its code,
- * causing us to crash when we return from this function.
- */
- if (cx == instance->cx && NET_URL_Type(urls->address) == ABOUT_TYPE_URL)
- {
- err = NPERR_INVALID_URL;
- goto error;
- }
+ /*
+ * Prevent loading "about:" URLs into the plug-in's context: NET_GetURL
+ * for these URLs will complete immediately, and the new layout thus
+ * generated will blow away the plug-in and possibly unload its code,
+ * causing us to crash when we return from this function.
+ */
+ if (cx == instance->cx && NET_URL_Type(urls->address) == ABOUT_TYPE_URL)
+ {
+ err = NPERR_INVALID_URL;
+ goto error;
+ }
if (forceJSEnabled && !cx->forceJSEnabled) {
LM_ForceJSEnabled(cx);
@@ -1182,144 +1240,144 @@ np_geturlinternal(NPP npp, const char* relativeURL, const char* target,
}
#ifdef XP_MAC
- /*
- * One day the code below should call FE_GetURL, and this call will be
- * unnecessary since the FE will do the right thing. Right now (3.0b6)
- * starting to use FE_GetURL is not an option so we'll just create
- * (yet another) FE callback for our purposes: we need to ask the FE
- * to reset any timer it might have (for META REFRESH) so that the
- * timer doesn't go off after leaving the original page via plug-in
- * request.
- */
- FE_ResetRefreshURLTimer(cx);
+ /*
+ * One day the code below should call FE_GetURL, and this call will be
+ * unnecessary since the FE will do the right thing. Right now (3.0b6)
+ * starting to use FE_GetURL is not an option so we'll just create
+ * (yet another) FE callback for our purposes: we need to ask the FE
+ * to reset any timer it might have (for META REFRESH) so that the
+ * timer doesn't go off after leaving the original page via plug-in
+ * request.
+ */
+ FE_ResetRefreshURLTimer(cx);
#endif
/* reentrancy matters for this case because it will cause the current
stream to be unloaded which netlib can't deal with */
if (instance->reentrant && (cx == instance->cx))
{
- XP_ASSERT(instance->delayedload == NULL); /* We lose queued requests if this is non-NULL! */
+ XP_ASSERT(instance->delayedload == NULL); /* We lose queued requests if this is non-NULL! */
if (instance->delayedload)
NET_FreeURLStruct(instance->delayedload);
instance->delayedload = urls;
instance->reentrant = 0;
}
else
- {
- if ((cx == instance->cx) ||
- (XP_IsChildContext(cx,instance->cx)) )
- {
- /* re-target: use this until figure out why thread violation.
- this method obviates question of self-trouncing... */
- if ((instance->cx->type == MWContextBrowser ||
- instance->cx->type == MWContextPane)
- && ((XP_STRNCMP(urls->address, "mailbox:", 8)==0)
- || (XP_STRNCMP(urls->address, "mailto:" , 7)==0)
- || (XP_STRNCMP(urls->address, "news:" , 5)==0)))
- cx = np_makecontext(instance,"_self");
- else{
- /* Since the previous stuff generally worked for this, keep using it */
- urls->fe_data = NULL;
+ {
+ if ((cx == instance->cx) ||
+ (XP_IsChildContext(cx,instance->cx)) )
+ {
+ /* re-target: use this until figure out why thread violation.
+ this method obviates question of self-trouncing... */
+ if ((instance->cx->type == MWContextBrowser ||
+ instance->cx->type == MWContextPane)
+ && ((XP_STRNCMP(urls->address, "mailbox:", 8)==0)
+ || (XP_STRNCMP(urls->address, "mailto:" , 7)==0)
+ || (XP_STRNCMP(urls->address, "news:" , 5)==0)))
+ cx = np_makecontext(instance,"_self");
+ else{
+ /* Since the previous stuff generally worked for this, keep using it */
+ NP_SET_URL_APP(urls, NULL);
#ifdef XP_WIN32
- pPrevState = WFE_BeginSetModuleState();
+ pPrevState = WFE_BeginSetModuleState();
#endif
- /* clear the exit routine, since the recipient may not be present! */
- (void) NET_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit);
+ /* clear the exit routine, since the recipient may not be present! */
+ (void) NET_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit);
#ifdef XP_WIN32
- WFE_EndSetModuleState(pPrevState);
+ WFE_EndSetModuleState(pPrevState);
#endif
- return NPERR_NO_ERROR;
- }
- /* Eventually, we should shut down the current instance and
- startup a new one */
- }
+ return NPERR_NO_ERROR;
+ }
+ /* Eventually, we should shut down the current instance and
+ startup a new one */
+ }
#ifdef XP_WIN32
- pPrevState = WFE_BeginSetModuleState();
+ pPrevState = WFE_BeginSetModuleState();
#endif
- (void) np_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit,notify);
+ (void) np_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit,notify);
#ifdef XP_WIN32
- WFE_EndSetModuleState(pPrevState);
+ WFE_EndSetModuleState(pPrevState);
#endif
- }
+ }
}
return NPERR_NO_ERROR;
-error:
- if (node)
- {
- node->notify = FALSE; /* Remove node without notification */
- np_removeURLfromList(instance, urls, 0);
- }
- if (urls)
- NET_FreeURLStruct(urls);
- return err;
+ error:
+ if (node)
+ {
+ node->notify = FALSE; /* Remove node without notification */
+ np_removeURLfromList(instance, urls, 0);
+ }
+ if (urls)
+ NET_FreeURLStruct(urls);
+ return err;
}
static NPError
np_parsepostbuffer(URL_Struct* urls, const char* buf, uint32 len)
{
- /*
- * Search the buffer passed in for a /n/n. If we find it, break the
- * buffer in half: the first part is the header, the rest is the body.
+ /*
+ * Search the buffer passed in for a /n/n. If we find it, break the
+ * buffer in half: the first part is the header, the rest is the body.
*/
- uint32 index;
- for (index = 0; index < len; index++)
- {
- if (buf[index] == '\n' && ++index < len && buf[index] == '\n')
- break;
- }
+ uint32 index;
+ for (index = 0; index < len; index++)
+ {
+ if (buf[index] == '\n' && ++index < len && buf[index] == '\n')
+ break;
+ }
- /*
+ /*
* If we found '\n\n' somewhere in the middle of the string then we
* have headers, so we need to allocate a new string for the headers,
* copy the header data from the plug-in's buffer into it, and put
* it in the appropriate place of the URL struct.
*/
- if (index > 1 && index < len)
- {
- uint32 headerLength = index;
- char* headers = (char*) XP_ALLOC(headerLength + 1);
- if (!headers)
- return NPERR_OUT_OF_MEMORY_ERROR;
- XP_MEMCPY(headers, buf, headerLength);
- headers[headerLength] = 0;
- urls->post_headers = headers;
- }
+ if (index > 1 && index < len)
+ {
+ uint32 headerLength = index;
+ char* headers = (char*) XP_ALLOC(headerLength + 1);
+ if (!headers)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ XP_MEMCPY(headers, buf, headerLength);
+ headers[headerLength] = 0;
+ urls->post_headers = headers;
+ }
- /*
+ /*
* If we didn't find '\n\n', then the body starts at the beginning;
* otherwise, it starts right after the second '\n'. Make sure the
* body is non-emtpy, allocate a new string for it, copy the data
* from the plug-in's buffer, and put it in the URL struct.
*/
- if (index >= len)
- index = 0; /* No '\n\n', start body from beginning */
- else
- index++; /* Found '\n\n', start body after it */
+ if (index >= len)
+ index = 0; /* No '\n\n', start body from beginning */
+ else
+ index++; /* Found '\n\n', start body after it */
- if (len - index > 0) /* Non-empty body? */
- {
- uint32 bodyLength = len - index + 1;
- char* body = (char*) XP_ALLOC(bodyLength);
- if (!body)
- return NPERR_OUT_OF_MEMORY_ERROR;
- XP_MEMCPY(body, &(buf[index]), bodyLength);
- urls->post_data = body;
- urls->post_data_size = bodyLength;
- urls->post_data_is_file = FALSE;
- }
- else
- {
- /* Uh-oh, no data to post */
- return NPERR_NO_DATA;
- }
+ if (len - index > 0) /* Non-empty body? */
+ {
+ uint32 bodyLength = len - index + 1;
+ char* body = (char*) XP_ALLOC(bodyLength);
+ if (!body)
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ XP_MEMCPY(body, &(buf[index]), bodyLength);
+ urls->post_data = body;
+ urls->post_data_size = bodyLength;
+ urls->post_data_is_file = FALSE;
+ }
+ else
+ {
+ /* Uh-oh, no data to post */
+ return NPERR_NO_DATA;
+ }
- return NPERR_NO_ERROR;
+ return NPERR_NO_ERROR;
}
@@ -1335,7 +1393,7 @@ np_posturlinternal(NPP npp, const char* relativeURL, const char *target,
np_urlsnode* node = NULL;
NPError err = NPERR_NO_ERROR;
#ifdef XP_WIN32
- void* pPrevState;
+ void* pPrevState;
#endif
/* Validate paramters */
@@ -1352,203 +1410,203 @@ np_posturlinternal(NPP npp, const char* relativeURL, const char *target,
return NPERR_INVALID_URL;
- /*
- * Add this URL to the list of URLs for this instance,
- * and remember if the instance would like notification.
- */
- node = np_addURLtoList(instance);
- if (node)
- {
- node->urls = urls;
- if (notify)
- {
- node->notify = TRUE;
- node->notifyData = notifyData;
- }
- }
- else
- {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- goto error;
- }
+ /*
+ * Add this URL to the list of URLs for this instance,
+ * and remember if the instance would like notification.
+ */
+ node = np_addURLtoList(instance);
+ if (node)
+ {
+ node->urls = urls;
+ if (notify)
+ {
+ node->notify = TRUE;
+ node->notifyData = notifyData;
+ }
+ }
+ else
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
- /*
- * FTP protocol requires that the data be in a file.
- * If we really wanted to, we could write code to dump the buffer to
- * a temporary file, give the temp file to netlib, and delete it when
- * the exit routine fires.
- */
- ftp = (strncasecomp(urls->address, "ftp:", 4) == 0);
- if (ftp && !file)
- {
- err = NPERR_INVALID_URL;
- goto error;
- }
+ /*
+ * FTP protocol requires that the data be in a file.
+ * If we really wanted to, we could write code to dump the buffer to
+ * a temporary file, give the temp file to netlib, and delete it when
+ * the exit routine fires.
+ */
+ ftp = (strncasecomp(urls->address, "ftp:", 4) == 0);
+ if (ftp && !file)
+ {
+ err = NPERR_INVALID_URL;
+ goto error;
+ }
- if (file)
- {
- XP_StatStruct stat;
+ if (file)
+ {
+ XP_StatStruct stat;
- /* If the plug-in passed a file URL, strip the 'file://' */
- if (!strncasecomp(buf, "file://", 7))
- filename = XP_STRDUP((char*) buf + 7);
- else
- filename = XP_STRDUP((char*) buf);
+ /* If the plug-in passed a file URL, strip the 'file://' */
+ if (!strncasecomp(buf, "file://", 7))
+ filename = XP_STRDUP((char*) buf + 7);
+ else
+ filename = XP_STRDUP((char*) buf);
- if (!filename)
- {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- goto error;
- }
+ if (!filename)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
- /* If the file doesn't exist, return an error NOW before netlib get it */
- if (XP_Stat(filename, &stat, xpURL))
- {
- err = NPERR_FILE_NOT_FOUND;
- goto error;
- }
- }
+ /* If the file doesn't exist, return an error NOW before netlib get it */
+ if (XP_Stat(filename, &stat, xpURL))
+ {
+ err = NPERR_FILE_NOT_FOUND;
+ goto error;
+ }
+ }
- /*
- * NET_GetURL handles FTP posts differently: the post_data fields are
- * ignored; instead, files_to_post contains an array of the files.
- */
- if (ftp)
- {
- XP_ASSERT(filename);
- urls->files_to_post = (char**) XP_ALLOC(sizeof(char*) + sizeof(char*));
- if (!(urls->files_to_post))
- {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- goto error;
- }
- urls->files_to_post[0] = filename;
- urls->files_to_post[1] = NULL;
- urls->post_data = NULL;
- urls->post_data_size = 0;
- urls->post_data_is_file = FALSE;
- }
- else if (file)
- {
- XP_ASSERT(filename);
- urls->post_data = filename;
- urls->post_data_size = XP_STRLEN(filename);
- urls->post_data_is_file = TRUE;
- }
- else
- {
- /*
- * There are two different sets of buffer-parsing code.
- * The new code is contained within np_parsepostbuffer,
- * and is used when the plug-in calls NPN_PostURLNotify.
- * The old code, below, is preserved for compatibility
- * for when the plug-in calls NPN_PostURL.
- */
- if (notify)
- {
- NPError err = np_parsepostbuffer(urls, buf, len);
- if (err != NPERR_NO_ERROR)
- goto error;
- }
- else
- {
- urls->post_data = (char*)XP_ALLOC(len);
- if (!urls->post_data)
- {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- goto error;
- }
- XP_MEMCPY(urls->post_data, buf, len);
- urls->post_data_size = len;
- urls->post_data_is_file = FALSE;
- }
- }
+ /*
+ * NET_GetURL handles FTP posts differently: the post_data fields are
+ * ignored; instead, files_to_post contains an array of the files.
+ */
+ if (ftp)
+ {
+ XP_ASSERT(filename);
+ urls->files_to_post = (char**) XP_ALLOC(sizeof(char*) + sizeof(char*));
+ if (!(urls->files_to_post))
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+ urls->files_to_post[0] = filename;
+ urls->files_to_post[1] = NULL;
+ urls->post_data = NULL;
+ urls->post_data_size = 0;
+ urls->post_data_is_file = FALSE;
+ }
+ else if (file)
+ {
+ XP_ASSERT(filename);
+ urls->post_data = filename;
+ urls->post_data_size = XP_STRLEN(filename);
+ urls->post_data_is_file = TRUE;
+ }
+ else
+ {
+ /*
+ * There are two different sets of buffer-parsing code.
+ * The new code is contained within np_parsepostbuffer,
+ * and is used when the plug-in calls NPN_PostURLNotify.
+ * The old code, below, is preserved for compatibility
+ * for when the plug-in calls NPN_PostURL.
+ */
+ if (notify)
+ {
+ NPError err = np_parsepostbuffer(urls, buf, len);
+ if (err != NPERR_NO_ERROR)
+ goto error;
+ }
+ else
+ {
+ urls->post_data = (char*)XP_ALLOC(len);
+ if (!urls->post_data)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+ XP_MEMCPY(urls->post_data, buf, len);
+ urls->post_data_size = len;
+ urls->post_data_is_file = FALSE;
+ }
+ }
urls->method = URL_POST_METHOD;
if (!target)
{
- urls->fe_data = (void*) instance->app;
+ NP_SET_URL_APP(urls, instance->app);
#ifdef XP_WIN32
- pPrevState = WFE_BeginSetModuleState();
+ pPrevState = WFE_BeginSetModuleState();
#endif
(void) NET_GetURL(urls, FO_CACHE_AND_PLUGIN, instance->cx, NPL_URLExit);
#ifdef XP_WIN32
- WFE_EndSetModuleState(pPrevState);
+ WFE_EndSetModuleState(pPrevState);
#endif
}
else
{
MWContext* cx = np_makecontext(instance, target);
- if (!cx)
- {
- err = NPERR_OUT_OF_MEMORY_ERROR;
- goto error;
- }
- urls->fe_data = (void*) instance->app;
+ if (!cx)
+ {
+ err = NPERR_OUT_OF_MEMORY_ERROR;
+ goto error;
+ }
+ NP_SET_URL_APP(urls, instance->app);
if (forceJSEnabled && !cx->forceJSEnabled) {
LM_ForceJSEnabled(cx);
urls->pre_exit_fn = np_redisable_js;
}
- /*
- * NOTE: The following (compound) if block was added to avoid the crash
- * encountered when np_GetURL is used when the target resolves to replacing
- * the context in which the plugin lives, thereby shutting down the context.
- * The problem here was that np_GetURL was copying the fe_data pointer
- * into owner_data, and that fe_data was being (correctly) deleted and nulled
- * somewhere, but not so the owner_data. Other possible solutions to this
- * problem would be to null out the owner_data in the appropriate place,
- * or perhaps to call np_GetURL w/ a null exit routine.
- */
- if ((cx == instance->cx) ||
- (XP_IsChildContext(cx,instance->cx)) ) {
- /* use NET_GetURL here to avoid crashing... */
+ /*
+ * NOTE: The following (compound) if block was added to avoid the crash
+ * encountered when np_GetURL is used when the target resolves to replacing
+ * the context in which the plugin lives, thereby shutting down the context.
+ * The problem here was that np_GetURL was copying the fe_data pointer
+ * into owner_data, and that fe_data was being (correctly) deleted and nulled
+ * somewhere, but not so the owner_data. Other possible solutions to this
+ * problem would be to null out the owner_data in the appropriate place,
+ * or perhaps to call np_GetURL w/ a null exit routine.
+ */
+ if ((cx == instance->cx) ||
+ (XP_IsChildContext(cx,instance->cx)) ) {
+ /* use NET_GetURL here to avoid crashing... */
#ifdef XP_WIN32
- pPrevState = WFE_BeginSetModuleState();
+ pPrevState = WFE_BeginSetModuleState();
#endif
- (void) NET_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit);
+ (void) NET_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit);
#ifdef XP_WIN32
- WFE_EndSetModuleState(pPrevState);
+ WFE_EndSetModuleState(pPrevState);
#endif
- return NPERR_NO_ERROR;
- }
+ return NPERR_NO_ERROR;
+ }
#ifdef XP_MAC
- /*
- * One day the code below should call FE_GetURL, and this call will be
- * unnecessary since the FE will do the right thing. Right now (3.0b6)
- * starting to use FE_GetURL is not an option so we'll just create
- * (yet another) FE callback for our purposes: we need to ask the FE
- * to reset any timer it might have (for META REFRESH) so that the
- * timer doesn't go off after leaving the original page via plug-in
- * request.
- */
- FE_ResetRefreshURLTimer(cx);
+ /*
+ * One day the code below should call FE_GetURL, and this call will be
+ * unnecessary since the FE will do the right thing. Right now (3.0b6)
+ * starting to use FE_GetURL is not an option so we'll just create
+ * (yet another) FE callback for our purposes: we need to ask the FE
+ * to reset any timer it might have (for META REFRESH) so that the
+ * timer doesn't go off after leaving the original page via plug-in
+ * request.
+ */
+ FE_ResetRefreshURLTimer(cx);
#endif
#ifdef XP_WIN32
- pPrevState = WFE_BeginSetModuleState();
+ pPrevState = WFE_BeginSetModuleState();
#endif
- (void) np_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit,notify);
+ (void) np_GetURL(urls, FO_CACHE_AND_PRESENT, cx, NPL_URLExit,notify);
#ifdef XP_WIN32
- WFE_EndSetModuleState(pPrevState);
+ WFE_EndSetModuleState(pPrevState);
#endif
- }
+ }
return NPERR_NO_ERROR;
-error:
- if (node)
- {
- node->notify = FALSE; /* Remove node without notification */
- np_removeURLfromList(instance, urls, 0);
- }
- if (urls)
- NET_FreeURLStruct(urls);
- return err;
+ error:
+ if (node)
+ {
+ node->notify = FALSE; /* Remove node without notification */
+ np_removeURLfromList(instance, urls, 0);
+ }
+ if (urls)
+ NET_FreeURLStruct(urls);
+ return err;
}
@@ -1556,51 +1614,51 @@ error:
NPError NP_EXPORT
npn_geturlnotify(NPP npp, const char* relativeURL, const char* target, void* notifyData)
{
- return np_geturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, TRUE, notifyData);
+ return np_geturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, TRUE, notifyData);
}
NPError NP_EXPORT
npn_getvalue(NPP npp, NPNVariable variable, void *r_value)
{
np_instance* instance;
- NPError ret = NPERR_NO_ERROR;
+ NPError ret = NPERR_NO_ERROR;
- if (r_value == NULL)
- return NPERR_INVALID_PARAM;
+ if (r_value == NULL)
+ return NPERR_INVALID_PARAM;
- /* Some of these variabled may be handled by backend. The rest is FE.
- * So Handle all the backend variables and pass the rest over to FE.
- */
+ /* Some of these variabled may be handled by backend. The rest is FE.
+ * So Handle all the backend variables and pass the rest over to FE.
+ */
- switch(variable) {
- case NPNVjavascriptEnabledBool :
- ret = PREF_GetBoolPref("javascript.enabled", (XP_Bool*)r_value);
- break;
- case NPNVasdEnabledBool :
- ret = PREF_GetBoolPref("autoupdate.enabled", (XP_Bool*)r_value);
- break;
+ switch(variable) {
+ case NPNVjavascriptEnabledBool :
+ ret = PREF_GetBoolPref("javascript.enabled", (XP_Bool*)r_value);
+ break;
+ case NPNVasdEnabledBool :
+ ret = PREF_GetBoolPref("autoupdate.enabled", (XP_Bool*)r_value);
+ break;
#ifdef MOZ_OFFLINE
- case NPNVisOfflineBool :{
- XP_Bool *bptr = (XP_Bool *)r_value;
- *bptr = NET_IsOffline();
- ret = NPERR_NO_ERROR;
- break; }
+ case NPNVisOfflineBool :{
+ XP_Bool *bptr = (XP_Bool *)r_value;
+ *bptr = NET_IsOffline();
+ ret = NPERR_NO_ERROR;
+ break; }
#endif /* MOZ_OFFLINE */
- default:
- instance = NULL;
- if (npp != NULL) {
- instance = (np_instance*) npp->ndata;
- }
+ default:
+ instance = NULL;
+ if (npp != NULL) {
+ instance = (np_instance*) npp->ndata;
+ }
#ifdef XP_UNIX
- ret = FE_PluginGetValue(instance?instance->handle->pdesc:NULL,
- variable, r_value);
+ ret = FE_PluginGetValue(instance?instance->handle->pdesc:NULL,
+ variable, r_value);
#else
- ret = FE_PluginGetValue(instance->cx, instance->app, variable,
- r_value);
+ ret = FE_PluginGetValue(instance->cx, instance->app, variable,
+ r_value);
#endif /* XP_UNIX */
- }
+ }
- return(ret);
+ return(ret);
}
NPError
@@ -1668,7 +1726,7 @@ NPError NP_EXPORT
npn_setvalue(NPP npp, NPPVariable variable, void *r_value)
{
np_instance* instance = NULL;
- NPError ret = NPERR_NO_ERROR;
+ NPError ret = NPERR_NO_ERROR;
if (npp != NULL) {
instance = (np_instance*) npp->ndata;
@@ -1705,21 +1763,21 @@ npn_setvalue(NPP npp, NPPVariable variable, void *r_value)
NPError NP_EXPORT
npn_geturl(NPP npp, const char* relativeURL, const char* target)
{
- return np_geturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, FALSE, NULL);
+ return np_geturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, FALSE, NULL);
}
NPError NP_EXPORT
npn_posturlnotify(NPP npp, const char* relativeURL, const char *target, uint32 len, const char *buf, NPBool file, void* notifyData)
{
- return np_posturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, len, buf, file, TRUE, notifyData);
+ return np_posturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, len, buf, file, TRUE, notifyData);
}
NPError NP_EXPORT
npn_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len, const char *buf, NPBool file)
{
- return np_posturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, len, buf, file, FALSE, NULL);
+ return np_posturlinternal(npp, relativeURL, target, NULL, NULL, PR_FALSE, len, buf, file, FALSE, NULL);
}
@@ -1728,11 +1786,11 @@ NPError NP_EXPORT
npn_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream)
{
np_instance* instance;
- np_stream* stream;
+ np_stream* stream;
NET_StreamClass* netstream;
URL_Struct* urls;
MWContext* cx;
- *pstream = NULL;
+ *pstream = NULL;
if (!npp || !type)
return NPERR_INVALID_PARAM;
@@ -1740,22 +1798,22 @@ npn_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream)
if (!instance)
return NPERR_INVALID_PARAM;
- /* Convert the window name to a context */
- cx = np_makecontext(instance, window);
+ /* Convert the window name to a context */
+ cx = np_makecontext(instance, window);
if (!cx)
return NPERR_OUT_OF_MEMORY_ERROR;
- /*
- * Make a bogus URL struct. The URL doesn't point to
- * anything, but we need it to build the stream.
- */
+ /*
+ * Make a bogus URL struct. The URL doesn't point to
+ * anything, but we need it to build the stream.
+ */
urls = NET_CreateURLStruct("", NET_DONT_RELOAD);
if (!urls)
return NPERR_OUT_OF_MEMORY_ERROR;
StrAllocCopy(urls->content_type, type);
- /* Make a netlib stream */
+ /* Make a netlib stream */
netstream = NET_StreamBuilder(FO_PRESENT, urls, cx);
if (!netstream)
{
@@ -1772,7 +1830,7 @@ npn_newstream(NPP npp, NPMIMEType type, const char* window, NPStream** pstream)
return NPERR_OUT_OF_MEMORY_ERROR;
}
- *pstream = stream->pstream;
+ *pstream = stream->pstream;
return NPERR_NO_ERROR;
}
@@ -1831,32 +1889,32 @@ npn_destroystream(NPP npp, NPStream *pstream, NPError reason)
* stream around because stream->dontclose was TRUE),
* just inform the plug-in and delete our objects.
*/
- stream->dontclose = FALSE; /* Make sure we really delete */
+ stream->dontclose = FALSE; /* Make sure we really delete */
if (urls)
{
- if (NET_InterruptStream(urls) < 0)
- {
- /* Netlib doesn't know about this stream; we must have made it */
- /*MWContext* cx = netstream->window_id;*/
- switch (reason)
- {
- case NPRES_DONE:
- (*netstream->complete)(netstream);
- break;
- case NPRES_USER_BREAK:
- (*netstream->abort)(netstream, MK_INTERRUPTED);
- break;
- case NPRES_NETWORK_ERR:
- (*netstream->abort)(netstream, MK_BAD_CONNECT);
- break;
- default: /* Unknown reason code */
- (*netstream->abort)(netstream, -1);
- break;
- }
- np_destroystream(stream, reason);
- XP_FREE(netstream);
- }
- }
+ if (NET_InterruptStream(urls) < 0)
+ {
+ /* Netlib doesn't know about this stream; we must have made it */
+ /*MWContext* cx = netstream->window_id;*/
+ switch (reason)
+ {
+ case NPRES_DONE:
+ (*netstream->complete)(netstream);
+ break;
+ case NPRES_USER_BREAK:
+ (*netstream->abort)(netstream, MK_INTERRUPTED);
+ break;
+ case NPRES_NETWORK_ERR:
+ (*netstream->abort)(netstream, MK_BAD_CONNECT);
+ break;
+ default: /* Unknown reason code */
+ (*netstream->abort)(netstream, -1);
+ break;
+ }
+ np_destroystream(stream, reason);
+ XP_FREE(netstream);
+ }
+ }
else
np_destroystream(stream, reason);
@@ -1878,10 +1936,10 @@ npn_status(NPP npp, const char *message)
np_instance *instance = (np_instance *)npp->ndata;
if(instance && instance->cx)
#ifdef XP_MAC
- /* Special entry point so MacFE can save/restore port state */
- FE_PluginProgress(instance->cx, message);
+ /* Special entry point so MacFE can save/restore port state */
+ FE_PluginProgress(instance->cx, message);
#else
- FE_Progress(instance->cx, message);
+ FE_Progress(instance->cx, message);
#endif
}
}
@@ -1935,7 +1993,7 @@ npn_memflush(uint32 size)
return size;
else
#endif
- return 0;
+ return 0;
}
@@ -1954,24 +2012,24 @@ np_switchHandlers(np_instance* instance,
np_mimetype* newMimeType,
char* requestedType)
{
- NPEmbeddedApp* app = instance->app;
- MWContext* cx = instance->cx;
+ NPEmbeddedApp* app = instance->app;
+ MWContext* cx = instance->cx;
np_data* ndata = (np_data*) app->np_data;
- if (app == NULL || cx == NULL || ndata == NULL)
- return NPERR_INVALID_PARAM;
+ if (app == NULL || cx == NULL || ndata == NULL)
+ return NPERR_INVALID_PARAM;
- /*
- * If it's a full-page plug-in, just reload the document.
- * We have to reload the data anyway to send it to the
- * new instance, and since the instance is the only thing
- * on the page it's easier to just reload the whole thing.
- * NOTE: This case shouldn't ever happen, since you can't
- * have full-page Default plug-ins currently.
- */
- XP_ASSERT(app->pagePluginType != NP_FullPage);
- if (app->pagePluginType == NP_FullPage)
- {
+ /*
+ * If it's a full-page plug-in, just reload the document.
+ * We have to reload the data anyway to send it to the
+ * new instance, and since the instance is the only thing
+ * on the page it's easier to just reload the whole thing.
+ * NOTE: This case shouldn't ever happen, since you can't
+ * have full-page Default plug-ins currently.
+ */
+ XP_ASSERT(app->pagePluginType != NP_FullPage);
+ if (app->pagePluginType == NP_FullPage)
+ {
History_entry* history = SHIST_GetCurrent(&cx->hist);
URL_Struct* urls = SHIST_CreateURLStructFromHistoryEntry(cx, history);
if (urls != NULL)
@@ -1981,42 +2039,42 @@ np_switchHandlers(np_instance* instance,
return NPERR_NO_ERROR;
}
else
- return NPERR_GENERIC_ERROR;
- }
+ return NPERR_GENERIC_ERROR;
+ }
- /* Nuke the old instance */
- np_delete_instance(instance);
- if (ndata != NULL && ndata->instance == instance)
- ndata->instance = NULL;
+ /* Nuke the old instance */
+ np_delete_instance(instance);
+ if (ndata != NULL && ndata->instance == instance)
+ ndata->instance = NULL;
- /* Make a new instance */
- ndata->instance = np_newinstance(newHandle, cx, app, newMimeType, requestedType);
- NPL_EmbedSize(app);
+ /* Make a new instance */
+ ndata->instance = np_newinstance(newHandle, cx, app, newMimeType, requestedType);
+ NPL_EmbedSize(app);
- if (ndata->instance == NULL)
+ if (ndata->instance == NULL)
return NPERR_GENERIC_ERROR;
/* Get the data stream for the new instance, if necessary */
if (ndata->lo_struct->embed_src != NULL)
{
- char* address;
+ char* address;
URL_Struct* urls;
- PA_LOCK(address, char*, ndata->lo_struct->embed_src);
- XP_ASSERT(address);
+ PA_LOCK(address, char*, ndata->lo_struct->embed_src);
+ XP_ASSERT(address);
urls = NET_CreateURLStruct(address, NET_DONT_RELOAD);
- PA_UNLOCK(ndata->lo_struct->embed_src);
+ PA_UNLOCK(ndata->lo_struct->embed_src);
if (urls != NULL)
{
- urls->fe_data = (void*) app;
- (void) NET_GetURL(urls, FO_CACHE_AND_EMBED, cx, NPL_EmbedURLExit);
- return NPERR_NO_ERROR;
- }
+ NP_SET_URL_APP(urls, app);
+ (void) NET_GetURL(urls, FO_CACHE_AND_EMBED, cx, NPL_EmbedURLExit);
+ return NPERR_NO_ERROR;
+ }
else
- return NPERR_GENERIC_ERROR;
+ return NPERR_GENERIC_ERROR;
}
return NPERR_NO_ERROR;
@@ -2037,18 +2095,18 @@ np_switchHandlers(np_instance* instance,
void NP_EXPORT
npn_reloadplugins(NPBool reloadPages)
{
- np_handle* oldHead = NULL;
+ np_handle* oldHead = NULL;
- /*
- * We won't unregister old plug-ins, we just register new ones.
- * The new plug-ins will go on the front of the list, so to see
- * if we got any new ones we just need to save a pointer to the
- * current front of the list.
- */
- if (reloadPages)
- oldHead = np_plist;
+ /*
+ * We won't unregister old plug-ins, we just register new ones.
+ * The new plug-ins will go on the front of the list, so to see
+ * if we got any new ones we just need to save a pointer to the
+ * current front of the list.
+ */
+ if (reloadPages)
+ oldHead = np_plist;
- /* Ask the FE to load new plug-ins */
+ /* Ask the FE to load new plug-ins */
FE_RegisterPlugins();
/*
@@ -2064,69 +2122,69 @@ npn_reloadplugins(NPBool reloadPages)
/* First look for the default plug-in */
while (defaultPlugin != NULL)
{
- if (defaultPlugin->mimetypes != NULL &&
- defaultPlugin->mimetypes->type &&
- XP_STRCMP(defaultPlugin->mimetypes->type, "*") == 0)
- {
- break;
- }
- defaultPlugin = defaultPlugin->next;
+ if (defaultPlugin->mimetypes != NULL &&
+ defaultPlugin->mimetypes->type &&
+ XP_STRCMP(defaultPlugin->mimetypes->type, "*") == 0)
+ {
+ break;
+ }
+ defaultPlugin = defaultPlugin->next;
}
if (defaultPlugin == NULL)
- return;
+ return;
/* Found the default plug-in; now check its instances */
instance = defaultPlugin->instances;
while (instance != NULL)
{
- NPBool switchedHandler = FALSE;
- char* type = instance->typeString;
- XP_ASSERT(instance->mimetype == defaultPlugin->mimetypes);
+ NPBool switchedHandler = FALSE;
+ char* type = instance->typeString;
+ XP_ASSERT(instance->mimetype == defaultPlugin->mimetypes);
- if (type != NULL)
- {
- /*
- * Try to match this instance's type against the
- * types of all new plug-ins to see if any of them
- * can handle it. Since the new plug-is were added
- * to the front of the list, we only need to look
- * at plug-ins up to the old head of the list.
- */
- np_handle* handle = np_plist;
- while (handle != NULL && handle != oldHead)
- {
- np_mimetype* mimeType;
- XP_ASSERT(handle != defaultPlugin);
- mimeType = np_getmimetype(handle, type, FALSE);
+ if (type != NULL)
+ {
+ /*
+ * Try to match this instance's type against the
+ * types of all new plug-ins to see if any of them
+ * can handle it. Since the new plug-is were added
+ * to the front of the list, we only need to look
+ * at plug-ins up to the old head of the list.
+ */
+ np_handle* handle = np_plist;
+ while (handle != NULL && handle != oldHead)
+ {
+ np_mimetype* mimeType;
+ XP_ASSERT(handle != defaultPlugin);
+ mimeType = np_getmimetype(handle, type, FALSE);
- /*
- * We found a new handler for this type! Now we
- * can destroy the plug-in instance and make a
- * new instance handled by the new plug-in.
- * Note that we have to point "instance" to the
- * next object NOW, because np_switchHandlers
- * will remove it from the list.
- */
- if (mimeType != NULL)
- {
- np_instance* switcher = instance;
- instance = instance->next;
- (void) np_switchHandlers(switcher, handle, mimeType, type);
- switchedHandler = TRUE;
- break; /* Out of handle "while" loop */
- }
+ /*
+ * We found a new handler for this type! Now we
+ * can destroy the plug-in instance and make a
+ * new instance handled by the new plug-in.
+ * Note that we have to point "instance" to the
+ * next object NOW, because np_switchHandlers
+ * will remove it from the list.
+ */
+ if (mimeType != NULL)
+ {
+ np_instance* switcher = instance;
+ instance = instance->next;
+ (void) np_switchHandlers(switcher, handle, mimeType, type);
+ switchedHandler = TRUE;
+ break; /* Out of handle "while" loop */
+ }
- handle = handle->next;
- }
- }
+ handle = handle->next;
+ }
+ }
- /*
- * In the case where we switch the handler (above),
- * "instance" already points to the next objTag.
- */
- if (!switchedHandler)
- instance = instance->next;
+ /*
+ * In the case where we switch the handler (above),
+ * "instance" already points to the next objTag.
+ */
+ if (!switchedHandler)
+ instance = instance->next;
}
}
}
@@ -2135,8 +2193,8 @@ npn_reloadplugins(NPBool reloadPages)
NPError
NPL_RefreshPluginList(XP_Bool reloadPages)
{
- npn_reloadplugins(reloadPages);
- return NPERR_NO_ERROR; /* Always succeeds for now */
+ npn_reloadplugins(reloadPages);
+ return NPERR_NO_ERROR; /* Always succeeds for now */
}
@@ -2182,7 +2240,7 @@ npn_invalidateregion(NPP npp, NPRegion invalidRegion)
*/
XP_Bool NPL_IsForcingRedraw()
{
- return gForcingRedraw;
+ return gForcingRedraw;
}
#endif /* XP_MAC */
@@ -2224,8 +2282,8 @@ npn_getJavaEnv(void)
{
#ifdef XP_MAC
- short resNum1, resNum2;
- resNum1 = CurResFile();
+ short resNum1, resNum2;
+ resNum1 = CurResFile();
#endif /* XP_MAC */
JNIEnv *pJNIEnv = NULL;
@@ -2236,10 +2294,10 @@ npn_getJavaEnv(void)
pJNIEnv = JVM_GetJNIEnv(); /* This may startup the VM. */
#ifdef XP_MAC
- /* if Java changed the res file, change it back to the plugin's res file */
- resNum2 = CurResFile();
- if(resNum1 != resNum2)
- UseResFile(resNum1);
+ /* if Java changed the res file, change it back to the plugin's res file */
+ resNum2 = CurResFile();
+ if(resNum1 != resNum2)
+ UseResFile(resNum1);
#endif /* XP_MAC */
return pJNIEnv;
@@ -2249,20 +2307,20 @@ JRIEnv* NP_EXPORT
npn_getJavaEnv(void)
{
#ifdef JAVA
- JRIEnv* env;
+ JRIEnv* env;
#ifdef XP_MAC
- short resNum1, resNum2;
- resNum1 = CurResFile();
+ short resNum1, resNum2;
+ resNum1 = CurResFile();
#endif /* XP_MAC */
- env = LJ_EnsureJavaEnv(NULL); /* NULL means for the current thread */
+ env = LJ_EnsureJavaEnv(NULL); /* NULL means for the current thread */
#ifdef XP_MAC
- /* if Java changed the res file, change it back to the plugin's res file */
- resNum2 = CurResFile();
- if(resNum1 != resNum2)
- UseResFile(resNum1);
+ /* if Java changed the res file, change it back to the plugin's res file */
+ resNum2 = CurResFile();
+ if(resNum1 != resNum2)
+ UseResFile(resNum1);
#endif /* XP_MAC */
return env;
@@ -2287,14 +2345,14 @@ npn_getJavaClass(np_handle* handle);
static void
np_recover_mochaWindow(JNIEnv * env, np_instance * instance)
{
- if (env && instance && instance->mochaWindow && instance->javaInstance){
- /* Store the JavaScript context as the window object: */
- env->SetObjectField(instance->javaInstance,
- env->GetFieldID(npn_getJavaClass(instance->handle),
- fieldname_netscape_plugin_Plugin_window, fieldsig_netscape_plugin_Plugin_window),
- (jobject)instance->mochaWindow);
+ if (env && instance && instance->mochaWindow && instance->javaInstance){
+ /* Store the JavaScript context as the window object: */
+ env->SetObjectField(instance->javaInstance,
+ env->GetFieldID(npn_getJavaClass(instance->handle),
+ fieldname_netscape_plugin_Plugin_window, fieldsig_netscape_plugin_Plugin_window),
+ (jobject)instance->mochaWindow);
- }
+ }
}
jobject classPlugin = NULL;
#define NPN_NO_JAVA_INSTANCE ((jobject)-1)
@@ -2303,18 +2361,18 @@ jobject classPlugin = NULL;
static void
np_recover_mochaWindow(JRIEnv * env, np_instance * instance)
{
- netscape_plugin_Plugin* javaInstance = NULL;
+ netscape_plugin_Plugin* javaInstance = NULL;
- if (env && instance && instance->mochaWindow && instance->javaInstance){
- javaInstance = (struct netscape_plugin_Plugin *)
- JRI_GetGlobalRef(env, instance->javaInstance);
- if (javaInstance) {
- /* Store the JavaScript context as the window object: */
- set_netscape_plugin_Plugin_window(env, javaInstance,
+ if (env && instance && instance->mochaWindow && instance->javaInstance){
+ javaInstance = (struct netscape_plugin_Plugin *)
+ JRI_GetGlobalRef(env, instance->javaInstance);
+ if (javaInstance) {
+ /* Store the JavaScript context as the window object: */
+ set_netscape_plugin_Plugin_window(env, javaInstance,
(netscape_javascript_JSObject*)
JRI_GetGlobalRef(env, instance->mochaWindow));
- }
- }
+ }
+ }
}
jglobal classPlugin = NULL;
#define NPN_NO_JAVA_INSTANCE ((jglobal)-1)
@@ -2342,7 +2400,7 @@ npn_getJavaClass(np_handle* handle)
nsIPlugin* userPluginClass = (nsIPlugin*)handle->userPlugin;
nsILiveConnectPlugin* lcPlugin;
if (userPluginClass->QueryInterface(kLiveConnectPluginIID,
- (void**)&lcPlugin) != NS_NOINTERFACE) {
+ (void**)&lcPlugin) == NS_OK) {
jclass clazz;
nsresult err = lcPlugin->GetJavaClass(&clazz);
PR_ASSERT(err == NS_OK);
@@ -2413,7 +2471,7 @@ npn_getJavaPeer(NPP npp)
** create the instance that we're just about to return.
*/
- /* But first, see if we need to recover the mochaWindow... */
+ /* But first, see if we need to recover the mochaWindow... */
np_recover_mochaWindow(npn_getJavaEnv(), instance);
return (jref)instance->javaInstance;
@@ -2431,7 +2489,7 @@ npn_getJavaPeer(NPP npp)
classPlugin = env->NewGlobalRef(clazz);
}
- /* instantiate the plugin's class: */
+ /* instantiate the plugin's class: */
#define methodname_netscape_plugin_Plugin_new "
");
- PUT("File name: ");
- PUT(handle->filename);
- PUT("
");
+ PUT("File name: ");
+ PUT(handle->filename);
+ PUT("
");
- PUT("MIME types:
");
- PUT("");
+ PUT("MIME types:
");
PUT("
");
+ PUT("");
for (mimetype = handle->mimetypes; mimetype; mimetype = mimetype->next)
{
- int index = 0;
- char** extents = mimetype->fassoc->extentlist;
+ int index = 0;
+ char** extents = mimetype->fassoc->extentlist;
- PUT("Type: ");
- PUT(mimetype->type);
- if (!mimetype->enabled)
- PUT(" (disabled)");
- PUT("
");
+ PUT("File extensions: ");
+ while (extents[index])
+ {
+ PUT(extents[index]);
+ index++;
+ if (extents[index])
+ PUT(", ");
+ }
+ PUT("
");
+ PUT("Type: ");
+ PUT(mimetype->type);
+ if (!mimetype->enabled)
+ PUT(" (disabled)");
+ PUT("
");
- PUT("File extensions: ");
- while (extents[index])
- {
- PUT(extents[index]);
- index++;
- if (extents[index])
- PUT(", ");
- }
- PUT("
");
- }
- PUT("
");
+ }
+ PUT("
"); PUT("