259140 - r/sr=mkaply (OS/2 only) - patch from Peter Weilbacher - resync default plugin to match Windows

git-svn-id: svn://10.0.0.236/trunk@198245 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mkaply%us.ibm.com
2006-05-23 01:28:05 +00:00
parent e770e1ab94
commit e74ff78371
6 changed files with 162 additions and 62 deletions

View File

@@ -50,17 +50,18 @@ RESFILE = npnulos2.res
PACKAGE_FILE = npnul.pkg
REQUIRES = java \
plugin \
xpcom \
pref \
$(NULL)
CPPSRCS = \
maindll.cpp\
dbg.cpp\
npos2.cpp\
dialogs.cpp\
npshell.cpp\
plugin.cpp\
utils.cpp\
maindll.cpp \
plugin.cpp \
dbg.cpp \
dialogs.cpp \
npshell.cpp \
npos2.cpp \
utils.cpp \
$(NULL)
# plugins should always be shared, even in the "static" build

View File

@@ -44,6 +44,8 @@
#include "npupp.h"
#endif
#include "nsDefaultPlugin.h"
//\\// DEFINE
#define NP_EXPORT
@@ -169,6 +171,12 @@ NP_Shutdown()
return NPERR_NO_ERROR;
}
char * NP_GetMIMEDescription()
{
static char mimetype[] = NS_PLUGIN_DEFAULT_MIME_DESCRIPTION;
return mimetype;
}
// END - PLUGIN DLL entry points
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.

View File

@@ -41,7 +41,7 @@
#include "npnulos2.h"
#include "Plugin.h" // this includes npapi.h
#include "plugin.h" // this includes npapi.h
#include "utils.h"
#include "dbg.h"
@@ -105,9 +105,8 @@ NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
if(buf != NULL)
{
buf = strrchr(buf, '.');
if (buf) {
if(buf)
szFileExtension = ++buf;
}
}
CPlugin * pPlugin = new CPlugin(hInst,
@@ -235,7 +234,10 @@ NPP_NewStream(NPP pInstance,
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return NPERR_NO_ERROR;
if (!pPlugin)
return NPERR_GENERIC_ERROR;
return pPlugin->newStream(type, stream, seekable, stype);
}
//------------------------------------------------------------------------------------
@@ -251,6 +253,9 @@ NPP_WriteReady(NPP pInstance, NPStream *stream)
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
// We don't want any data, kill the stream
NPN_DestroyStream(pInstance, stream, NPRES_DONE);
return -1L; // don't accept any bytes in NPP_Write()
}
@@ -267,7 +272,10 @@ NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return -1; // tell Nav to abort the stream, don't need it
// We don't want any data, kill the stream
NPN_DestroyStream(pInstance, stream, NPRES_DONE);
return -1; // tell the browser to abort the stream, don't need it
}
//------------------------------------------------------------------------------------
@@ -283,7 +291,10 @@ NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return NPERR_NO_ERROR;
if (!pPlugin)
return NPERR_GENERIC_ERROR;
return pPlugin->destroyStream(stream, reason);
}
//------------------------------------------------------------------------------------

View File

@@ -38,8 +38,6 @@
#define INCL_GPI
#define INCL_WIN
#include <os2.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "npnulos2.h"
@@ -48,6 +46,10 @@
#include "utils.h"
#include "dialogs.h"
#include "dbg.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
nsIServiceManager * gServiceManager = NULL;
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
@@ -83,24 +85,26 @@ CPlugin::CPlugin(HMODULE hInst,
PSZ szFileURL,
PSZ szFileExtension,
BOOL bHidden) :
m_hInst(hInst),
m_pNPInstance(pNPInstance),
m_wMode(wMode),
m_hInst(hInst),
m_hWnd(NULL),
m_hWndParent(NULL),
m_hWndDialog(NULL),
m_hIcon(NULL),
m_szURLString(NULL),
m_szCommandMessage(NULL),
m_bWaitingStreamFromPFS(FALSE),
m_PFSStream(NULL),
m_bHidden(bHidden),
m_pNPMIMEType(NULL),
m_szPageURL(NULL),
m_szFileURL(NULL),
m_szFileExtension(NULL),
m_hWndDialog(NULL),
m_bOnline(TRUE),
m_bJava(TRUE),
m_bJavaScript(TRUE),
m_bSmartUpdate(TRUE),
m_szURLString(NULL),
m_szCommandMessage(NULL),
m_bHidden(bHidden)
m_bSmartUpdate(TRUE)
{
dbgOut1("CPlugin::CPlugin()");
assert(m_hInst != NULL);
@@ -197,6 +201,29 @@ BOOL CPlugin::init(HWND hWndParent)
{
dbgOut1("CPlugin::init()");
nsISupports * sm = NULL;
nsIPref * nsPrefService = NULL;
PRBool bSendUrls = PR_FALSE; // default to false if problem getting pref
// note that Mozilla will add reference, so do not forget to release
NPN_GetValue(NULL, NPNVserviceManager, &sm);
// do a QI on the service manager we get back to ensure it's the one we are expecting
if(sm) {
sm->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&gServiceManager);
NS_RELEASE(sm);
}
if (gServiceManager) {
// get service using its contract id and use it to allocate the memory
gServiceManager->GetServiceByContractID(NS_PREF_CONTRACTID, NS_GET_IID(nsIPref), (void **)&nsPrefService);
if(nsPrefService) {
nsPrefService->GetBoolPref("application.use_ns_plugin_finder", &bSendUrls);
NS_RELEASE(nsPrefService);
}
}
m_bSmartUpdate = bSendUrls;
if(!m_bHidden)
{
assert(WinIsWindow((HAB)0, hWndParent));
@@ -249,6 +276,10 @@ void CPlugin::shut()
WinDestroyWindow(m_hWnd);
m_hWnd = NULL;
}
// we should release the service manager
NS_IF_RELEASE(gServiceManager);
gServiceManager = NULL;
}
HWND CPlugin::getWindow()
@@ -284,7 +315,7 @@ PSZ CPlugin::createURLString()
}
// check if there is file URL first
if(m_szFileURL != NULL)
if(!m_bSmartUpdate && m_szFileURL != NULL)
{
m_szURLString = new char[strlen(m_szFileURL) + 1];
if(m_szURLString == NULL)
@@ -303,14 +334,15 @@ PSZ CPlugin::createURLString()
m_pNPMIMEType)) ? 1 : 0;
}
if(m_szPageURL != NULL && !contentTypeIsJava)
if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava)
{
szAddress = new char[strlen(m_szPageURL) + 1];
if(szAddress == NULL)
return NULL;
strcpy(szAddress, m_szPageURL);
m_szURLString = new char[strlen(szAddress) + 1 + strlen((PSZ)m_pNPMIMEType) + 1];
m_szURLString = new char[strlen(szAddress) + 1 +
strlen((PSZ)m_pNPMIMEType) + 1];
if(m_szURLString == NULL)
return NULL;
@@ -320,7 +352,7 @@ PSZ CPlugin::createURLString()
}
else // default
{
if(!m_bJavaScript)
if(!m_bSmartUpdate)
{
urlToOpen = szDefaultPluginFinderURL;
@@ -333,13 +365,15 @@ PSZ CPlugin::createURLString()
return NULL;
strcpy(szAddress, urlToOpen);
m_szURLString = new char[strlen(szAddress) + 1 + strlen((PSZ)m_pNPMIMEType) + 1];
m_szURLString = new char[strlen(szAddress) + 10 +
strlen((PSZ)m_pNPMIMEType) + 1];
if(m_szURLString == NULL)
return NULL;
// Append the MIME type to the URL
sprintf(m_szURLString, "%s?%s", szAddress, (PSZ)m_pNPMIMEType);
sprintf(m_szURLString, "%s?mimetype=%s",
szAddress, (PSZ)m_pNPMIMEType);
}
else
{
@@ -349,11 +383,26 @@ PSZ CPlugin::createURLString()
urlToOpen = szPageUrlForJVM;
}
// wsprintf doesn't like null pointers on NT or 98, so
// change any null string pointers to null strings
if (!m_szPageURL) {
m_szPageURL = new char[1];
m_szPageURL[0] = '\0';
}
if (!m_szFileURL) {
m_szFileURL = new char[1];
m_szFileURL[0] = '\0';
}
m_szURLString = new char[strlen(szPluginFinderCommandBeginning) + strlen(urlToOpen) + 10 +
strlen((PSZ)m_pNPMIMEType) + strlen(szPluginFinderCommandEnd) + 1];
sprintf(m_szURLString, "%s%s?mimetype=%s%s",
szPluginFinderCommandBeginning, urlToOpen,
(PSZ)m_pNPMIMEType, szPluginFinderCommandEnd);
strlen((PSZ)m_pNPMIMEType) + 13 +
strlen((PSZ)m_szPageURL) + 11 +
strlen((PSZ)m_szFileURL) +
strlen(szPluginFinderCommandEnd) + 1];
sprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s",
szPluginFinderCommandBeginning, urlToOpen,
(PSZ)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd);
}
}
@@ -375,14 +424,8 @@ void CPlugin::getPluginRegular()
dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);
if(m_szFileURL != NULL)
NPN_GetURL(m_pNPInstance, szURL, "_current");
else if(m_szPageURL != NULL)
NPN_GetURL(m_pNPInstance, szURL, "_blank");
else if(m_bJavaScript)
NPN_GetURL(m_pNPInstance, szURL, NULL);
else
NPN_GetURL(m_pNPInstance, szURL, "_blank");
NPN_GetURL(m_pNPInstance, szURL, NULL);
m_bWaitingStreamFromPFS = TRUE;
}
void CPlugin::getPluginSmart()
@@ -398,7 +441,7 @@ void CPlugin::getPluginSmart()
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
assert(strlen(szJSString) > 0);
assert(*szJSString);
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
*/
@@ -415,7 +458,7 @@ void CPlugin::showGetPluginDialog()
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
//NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
m_bOnline = !bOffline;
@@ -435,14 +478,19 @@ void CPlugin::showGetPluginDialog()
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
if((m_szPageURL != NULL) || (m_szFileURL != NULL) || !m_bJavaScript)
if((!m_bSmartUpdate && (m_szPageURL != NULL) || (m_szFileURL != NULL)) || !m_bJavaScript)
{
int iRet = WinDlgBox(HWND_DESKTOP, m_hWnd, (PFNWP)GetPluginDialogProc, m_hInst,
IDD_PLUGIN_DOWNLOAD, (PVOID)this);
if(iRet != IDC_GET_PLUGIN)
return;
}
else
getPlugin();
}
void CPlugin::getPlugin()
{
if(m_szCommandMessage != NULL)
{
delete [] m_szCommandMessage;
@@ -503,6 +551,32 @@ void CPlugin::URLNotify(const char * szURL)
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
}
NPError CPlugin::newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
{
if (!m_bWaitingStreamFromPFS)
return NPERR_NO_ERROR;
m_bWaitingStreamFromPFS = FALSE;
m_PFSStream = stream;
if (stream) {
if (type && !strcmp(type, "application/x-xpinstall"))
NPN_GetURL(m_pNPInstance, stream->url, "_self");
else
NPN_GetURL(m_pNPInstance, stream->url, "_blank");
}
return NPERR_NO_ERROR;
}
NPError CPlugin::destroyStream(NPStream *stream, NPError reason)
{
if (stream == m_PFSStream)
m_PFSStream = NULL;
return NPERR_NO_ERROR;
}
BOOL CPlugin::readyToRefresh()
{
char szString[1024] = {'\0'};
@@ -690,7 +764,7 @@ MRESULT EXPENTRY NP_LOADDS PluginWndProc(HWND hWnd, ULONG message, MPARAM mp1, M
case WM_BUTTON1UP:
pPlugin->onLButtonUp(hWnd,0,0,0);
return 0L;
case WM_BUTTON2UP:
case WM_BUTTON2UP:
pPlugin->onRButtonUp(hWnd,0,0,0);
return 0L;
case WM_PAINT:

View File

@@ -43,23 +43,25 @@
class CPlugin
{
private:
HMODULE m_hInst;
NPP m_pNPInstance;
SHORT m_wMode;
HWND m_hWnd;
HWND m_hWndParent;
HPOINTER m_hIcon;
char * m_szURLString;
HMODULE m_hInst;
NPP m_pNPInstance;
SHORT m_wMode;
HWND m_hWnd;
HWND m_hWndParent;
HPOINTER m_hIcon;
char * m_szURLString;
char * m_szCommandMessage;
char * m_szCommandMessage;
BOOL m_bWaitingStreamFromPFS;
NPStream* m_PFSStream;
public:
BOOL m_bHidden;
BOOL m_bHidden;
NPMIMEType m_pNPMIMEType;
PSZ m_szPageURL; // Location of plug-in HTML page
PSZ m_szFileURL; // Location of plug-in JAR file
PSZ m_szFileExtension; // File extension associated with the of the unknown mimetype
HWND m_hWndDialog;
PSZ m_szPageURL; // Location of plug-in HTML page
PSZ m_szFileURL; // Location of plug-in JAR file
PSZ m_szFileExtension; // File extension associated with the of the unknown mimetype
HWND m_hWndDialog;
// environment
BOOL m_bOnline;
@@ -89,27 +91,31 @@ public:
void shut();
HWND getWindow();
void showGetPluginDialog();
void getPlugin();
BOOL readyToRefresh();
// NP API handlers
void resize();
void print(NPPrint * pNPPrint);
void URLNotify(const char * szURL);
NPError newStream(NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype);
NPError destroyStream(NPStream *stream, NPError reason);
// Windows message handlers
void onCreate(HWND hWnd);
void onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
void onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags);
void onPaint(HWND hWnd);
void resize();
};
#define PAGE_URL_FOR_JAVASCRIPT "http://cgi.netscape.com/cgi-bin/plugins/get_plugin.cgi"
#define PAGE_URL_FOR_JAVASCRIPT "http://plugins.netscape.com/plug-in_finder.adp"
#define PLUGINFINDER_COMMAND_BEGINNING "javascript:window.open(\""
#define PLUGINFINDER_COMMAND_END "\",\"plugin\",\"toolbar=no,status=no,resizable=no,scrollbars=no,height=252,width=626\");"
#define DEFAULT_PLUGINFINDER_URL "http://plugins.netscape.com/plug-in_finder.adp"
#define JVM_SMARTUPDATE_URL "http://home.netscape.com/plugins/jvm.html"
#define DEFAULT_PLUGINFINDER_URL "http://plugindoc.mozdev.org/OS2.html"
#define JVM_SMARTUPDATE_URL "http://plugindoc.mozdev.org/OS2.html"
#define OS2INI_PLACE "Mozilla Default Plugin"
#define GWL_USERDATA 0

View File

@@ -76,7 +76,7 @@ static int getWindowStringLength(HWND hWnd, PSZ lpsz)
/****************************************************************/
/* */
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText) */
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText) */
/* */
/* helper to wrap long lines in a static control, which do not */
/* wrap automatically if they do not have space characters */