This commit was manufactured by cvs2svn to create branch

'AVIARY_1_0_20040515_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/AVIARY_1_0_20040515_BRANCH@155145 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
(no author)
2004-04-19 19:34:57 +00:00
parent 8edd7b09d6
commit 6c06bfad8c
25514 changed files with 0 additions and 5725722 deletions

View File

@@ -1,28 +0,0 @@
/*
acmeIScriptObject.idl
*/
#include "nsISupports.idl"
[scriptable, uuid(f78d64e0-1dd1-11b2-a9b4-ae998c529d3e)]
interface acmeIScriptObject : nsISupports {
acmeIScriptObject getProperty(in string name);
void setProperty(in string name, in string value);
/**
* Evaluates a string expression.
*/
acmeIScriptObject evaluate(in string expression);
/**
* Conversions.
*/
string toString();
double toNumber();
/**
* Constructors.
*/
acmeIScriptObject fromString(in string value);
acmeIScriptObject fromNumber(in double value);
};

View File

@@ -1,220 +0,0 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.76 [en]C-AOLNSCP (Win98; U) [Netscape]">
<title>Scripting Old Style Plugins with Mozilla</title>
</head>
<body>
<center><b><font size=+2>Scripting Old Style Plugins in Mozilla</font></b>
<br><i>April 11, 2001</i>
<br>(see online version for the latest updates:
<a href="http://mozilla.org/docs/scripting-plugins.html">http://mozilla.org/docs/scripting-plugins.html</a>)
</center>
<p><a href="readme.html#introduction">Introduction</a>
<br><a href="readme.html#mozilla">New in Mozilla code</a>
<br><a href="readme.html#plugin">New in plugin code</a>
<br><a href="readme.html#script">JavaScript code</a>
<br><a href="readme.html#build">Building and installing the plugin</a>
<br><a href="readme.html#more">What else to read</a>
<br><a href="readme.html#example1">Examples</a>
<p><a NAME="introduction"></a><b>Introduction</b>
<p>Plugins that used to take advantage of being scriptable via LiveConnect
in 4.x Netscape browsers lost this possibility in the new world. The main
reason for this is that there is no guarantee of Java compatibility on
a binary level due to the jri/jni switch. The newly introduced <a href="http://www.mozilla.org/docs/plugin.html">Mozilla
Plugin API</a> allows plugins be scriptable via a different mechanism called
<a href="http://www.mozilla.org/scriptable/index.html">XPConnect.</a>&nbsp;
Basically, this means that in order to use and take full advantage of this
new API, which is interface-based,&nbsp; and to be scriptable, plugins
must be rewritten to become <a href="http://www.mozilla.org/projects/xpcom/">XPCOM</a>
components. Switching to the new world may not be immediately desirable
by some plugin makers, since the task involves a fair amount of effort,
and if the plugin mostly works fine lacking only scriptability, developers
will probably just give up on this feature, which may result in unpleasant
experience for the end user.
<p>In order to make the transtion smoother, some changes have been made
to the Mozilla code. The changes allow to make existing 4.x plugins scriptable
with only minor modifications in their code. The present document describes
the steps of what should be done to the plugin code to turn it scriptable
again.
<p><a NAME="mozilla"></a><b>What's in the Mozilla code?</b>
<p>A couple of lines have been added to the DOM code asking a plugin to
return a scriptable iid and a pointer to a scriptable instance object.
The old Plugin API call <tt>NPP_GetValue</tt> is used to retrieve this
information from the plugin. So the plugin project should be aware of two
new additions to <tt>NPPVariable</tt> enumeration type which are now defined
in npapi.h as
<p><tt>&nbsp; NPPVpluginScriptableInstance = 10,</tt>
<br><tt>&nbsp; NPPVpluginScriptableIID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
11</tt>
<p>and two analogous additions to nsPluginInstanceVariable type in nsplugindefs.h
as
<p><tt>&nbsp; nsPluginInstanceVariable_ScriptableInstance = 10,</tt>
<br><tt>&nbsp; nsPluginInstanceVariable_ScriptableIID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
= 11</tt>
<p><a NAME="plugin"></a><b>What's in the plugin code?</b>
<p>1. A unique interface id should be obtained. Windows command <tt>uuidgen</tt>
should be sufficient.
<p>2. An Interface Definition (<tt>.idl</tt>) file describing the plugin
scriptable interface should be added to the project (<a href="#example1">see
example 1</a>).
<p>3. A Scriptable instance object should be implemented in the plugin.
This class will contain native methods callable from JavaScript. This class
should also inherit from nsISecurityCheckedComponent and implement its
methods to be able to request all necessary privileges from the Mozilla
security manager (<a href="#example2">see example 2</a>).
<p>4. Two new cases for the above mentioned new variables should be added
to the plugin implementation of <tt>NPP_GetValue</tt> (<a href="#example3">see
example 3</a>).
<p><a NAME="script"></a><b>How to call plugin native methods</b>
<p>The following HTML code will do the job:
<p><tt>&lt;embed type="application/plugin-mimetype"></tt>
<br><tt>&lt;script></tt>
<br><tt>var embed = document.embeds[0];</tt>
<br><tt>embed.nativeMethod();</tt>
<br><tt>&lt;/script></tt>
<p><a NAME="build"></a><b>How to build and install</b>
<p>Having the built Mozilla tree is probably not necessary, but building
the plugin with a scriptable instance interface will require Mozilla headers
and the XPCOM compatible idl compiler -- xpidl.exe. <i>MS DevStudio MIDL
should not be used</i>. (Let's assume 'TestPlugin' as a plugin name-place
holder.)
<p>1. Compile nsITestPlugin.idl with the idl compiler. This will generate
nsITestPlugin.h and nsITestPlugin.xpt files.
<p>2. Put nsITestPlugin.xpt to the Components folder.
<p>3. Build nptestplugin.dll with nsITestPlugin.h included for compiling
scriptable instance class implementaion.
<p>4. Put nptestplugin.dll to the Plugins folder.
<p><a NAME="more"></a><b>Related sources</b>
<br>&nbsp;
<ul>
<li>
<a href="http://bugzilla.mozilla.org/">http://bugzilla.mozilla.org</a>
has two bugs in its database which are related to this topic: <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=73856">73856
</a>and <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=73874">73874</a>.
The latter contains the full sample plugin code.</li>
<li>
IBM Developer Works has published <a href="http://www-106.ibm.com/developerworks/components/library/co-xpcom.html">a
good article on XPCOM.</a></li>
</ul>
<p><a NAME="example1"></a><b>Example 1. Sample .idl file</b>
<p><tt>#include "nsISupports.idl"</tt>
<p><tt>[scriptable, uuid(bedb0778-2ee0-11d5-9cf8-0060b0fbd8ac)]</tt>
<br><tt>interface nsITestPlugin : nsISupports {</tt>
<br><tt>&nbsp; void nativeMethod();</tt>
<br><tt>};</tt>
<p><a NAME="example2"></a><b>Example 2. Scriptable instance class</b>
<p><tt>#include "nsITestPlugin.h"</tt>
<br><tt>#include "nsISecurityCheckedComponent.h"</tt>
<p><tt>class nsScriptablePeer : public nsITestPlugin,</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
public nsISecurityCheckedComponent</tt>
<br><tt>{</tt>
<br><tt>public:</tt>
<br><tt>&nbsp; nsScriptablePeer();</tt>
<br><tt>&nbsp; ~nsScriptablePeer();</tt>
<p><tt>&nbsp; NS_DECL_ISUPPORTS</tt>
<br><tt>&nbsp; NS_DECL_NSITESTPLUGIN</tt>
<br><tt>&nbsp; NS_DECL_NSISECURITYCHECKEDCOMPONENT</tt>
<br><tt>};</tt>
<p><tt>nsScriptablePeer::nsScriptablePeer()</tt>
<br><tt>{</tt>
<br><tt>&nbsp; NS_INIT_ISUPPORTS();</tt>
<br><tt>}</tt>
<p><tt>nsScriptablePeer::~nsScriptablePeer()</tt>
<br><tt>{</tt>
<br><tt>}</tt>
<p><tt>NS_IMPL_ISUPPORTS2(nsScriptablePeer, nsITestPlugin, nsISecurityCheckedComponent)</tt>
<p><tt>// the following method will be callable from JavaScript</tt>
<br><tt>NS_IMETHODIMP nsScriptablePeer::NativeMethod()</tt>
<br><tt>{</tt>
<br><tt>&nbsp; return NS_OK;</tt>
<br><tt>}</tt>
<p><tt>// the purpose of the rest of the code is to get succesfully</tt>
<br><tt>// through the Mozilla Security Manager</tt>
<br><tt>static const char gAllAccess[] = "AllAccess";</tt>
<br><tt>NS_IMETHODIMP nsScriptablePeer::CanCreateWrapper(const nsIID *
iid, char **_retval)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if (!_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_NULL_POINTER;</tt>
<br><tt>&nbsp; *_retval = (char*)NPN_MemAlloc(sizeof(gAllAccess)+1);</tt>
<br><tt>&nbsp; if (!*_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_OUT_OF_MEMORY;</tt>
<br><tt>&nbsp; strcpy(*_retval, gAllAccess);</tt>
<br><tt>&nbsp; return NS_OK;</tt>
<br><tt>}</tt>
<p><tt>NS_IMETHODIMP nsScriptablePeer::CanCallMethod(const nsIID * iid,
const PRUnichar *methodName, char **_retval)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if (!_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_NULL_POINTER;</tt>
<br><tt>&nbsp; *_retval = (char*)NPN_MemAlloc(sizeof(gAllAccess)+1);</tt>
<br><tt>&nbsp; if (!*_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_OUT_OF_MEMORY;</tt>
<br><tt>&nbsp; strcpy(*_retval, gAllAccess);</tt>
<br><tt>&nbsp; return NS_OK;</tt>
<br><tt>}</tt>
<p><tt>NS_IMETHODIMP nsScriptablePeer::CanGetProperty(const nsIID * iid,
const PRUnichar *propertyName, char **_retval)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if (!_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_NULL_POINTER;</tt>
<br><tt>&nbsp; *_retval = (char*)NPN_MemAlloc(sizeof(gAllAccess)+1);</tt>
<br><tt>&nbsp; if (!*_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_OUT_OF_MEMORY;</tt>
<br><tt>&nbsp; strcpy(*_retval, gAllAccess);</tt>
<br><tt>&nbsp; return NS_OK;</tt>
<br><tt>}</tt>
<p><tt>NS_IMETHODIMP nsScriptablePeer::CanSetProperty(const nsIID * iid,
const PRUnichar *propertyName, char **_retval)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if (!_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_NULL_POINTER;</tt>
<br><tt>&nbsp; *_retval = (char*)NPN_MemAlloc(sizeof(gAllAccess)+1);</tt>
<br><tt>&nbsp; if (!*_retval)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NS_ERROR_OUT_OF_MEMORY;</tt>
<br><tt>&nbsp; strcpy(*_retval, gAllAccess);</tt>
<br><tt>&nbsp; return NS_OK;</tt>
<br><tt>}</tt>
<p><a NAME="example3"></a><b>Example 3. NPP_GetValue implementation</b>
<p><tt>#include "nsITestPlugin.h"</tt>
<p><tt>NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)</tt>
<br><tt>{</tt>
<br><tt>&nbsp; if(instance == NULL)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; return NPERR_INVALID_INSTANCE_ERROR;</tt>
<p><tt>&nbsp; NPError rv = NPERR_NO_ERROR;</tt>
<br><tt>&nbsp; static nsIID scriptableIID = NS_ITESTPLUGIN_IID;</tt>
<p><tt>&nbsp; if (variable == NPPVpluginScriptableInstance)</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; if (this is first time and we haven't created
it yet)</tt>
<br><tt>&nbsp;&nbsp;&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nsITestPlugin * scriptablePeer =
new nsScriptablePeer();</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(scriptablePeer)</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // addref for ourself,
don't forget to release on shutdown to trigger its destruction</tt>
<br><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NS_ADDREF(scriptablePeer);</tt>
<br><tt>&nbsp;&nbsp;&nbsp; }</tt>
<br><tt>&nbsp;&nbsp;&nbsp; // add reference for the caller requesting the
object</tt>
<br><tt>&nbsp;&nbsp;&nbsp; NS_ADDREF(scriptablePeer);</tt>
<br><tt>&nbsp;&nbsp; *(nsISupports **)value = scriptablePeer;</tt>
<br><tt>&nbsp; }</tt>
<br><tt>&nbsp; else if (variable == NPPVpluginScriptableIID)</tt>
<br><tt>&nbsp; {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));</tt>
<br><tt>&nbsp;&nbsp;&nbsp; *ptr = scriptableIID;</tt>
<br><tt>&nbsp;&nbsp;&nbsp; *(nsIID **)value = ptr;</tt>
<br><tt>&nbsp; }</tt>
<br><tt>&nbsp; return rv;</tt>
<br><tt>}</tt>
<br>&nbsp;
</body>
</html>

View File

@@ -1,56 +0,0 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ..\..\..\..
include <$(DEPTH)/config/config.mak>
MODULE = np4xscr
XPIDLSRCS = \
.\nsI4xScriptablePlugin.idl \
$(NULL)
MAKE_OBJ_TYPE = DLL
DLLNAME = np4xscr
RESFILE = np4xscr.res
DEFFILE = np4xscr.def
DLL=.\$(OBJDIR)\$(DLLNAME).dll
OBJS = \
.\$(OBJDIR)\np_entry.obj \
.\$(OBJDIR)\npn_gate.obj \
.\$(OBJDIR)\npp_gate.obj \
.\$(OBJDIR)\plugin.obj \
.\$(OBJDIR)\nsScriptablePeer.obj \
$(NULL)
WIN_LIBS = version.lib
#uncomment if you are building the nsScriptablePeer1 version
#LLIBS= $(LIBNSPR) \
# $(DIST)\lib\xpcom.lib \
# $(NULL)
include <$(DEPTH)/config/rules.mak>
#MAKE_INSTALL=echo $(MAKE_INSTALL)
libs:: $(DLL)
# $(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\plugins
clobber::
rm -f *.sbr $(DIST)\bin\plugins\$(DLLNAME).dll $(DIST)\bin\components\$(DLLNAME).xpt

View File

@@ -1,6 +0,0 @@
LIBRARY NP4XSCR
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3

View File

@@ -1,112 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", " \0"
VALUE "FileDescription", "np4xscr\0"
VALUE "FileExtents", "4sc\0"
VALUE "FileOpenName", "np4xscr\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "np4xscr\0"
VALUE "LegalCopyright", "Copyright © 1999\0"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "application/mozilla-4x-scriptable-plugin\0"
VALUE "OriginalFilename", "ns4xscr.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "4x scriptable example plugin for Mozilla\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -1,119 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//////////////////////////////////////////////////////////////
//
// Main plugin entry point implementation
//
#include "npapi.h"
#include "npupp.h"
NPNetscapeFuncs NPNFuncs;
#ifdef XP_WIN
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
{
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(pFuncs->size < sizeof(NPPluginFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
pFuncs->newp = NPP_New;
pFuncs->destroy = NPP_Destroy;
pFuncs->setwindow = NPP_SetWindow;
pFuncs->newstream = NPP_NewStream;
pFuncs->destroystream = NPP_DestroyStream;
pFuncs->asfile = NPP_StreamAsFile;
pFuncs->writeready = NPP_WriteReady;
pFuncs->write = NPP_Write;
pFuncs->print = NPP_Print;
pFuncs->event = NPP_HandleEvent;
pFuncs->urlnotify = NPP_URLNotify;
pFuncs->getvalue = NPP_GetValue;
pFuncs->setvalue = NPP_SetValue;
pFuncs->javaClass = NULL;
return NPERR_NO_ERROR;
}
#endif /* XP_WIN */
NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs)
{
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
if(pFuncs->size < sizeof NPNetscapeFuncs)
return NPERR_INVALID_FUNCTABLE_ERROR;
NPNFuncs.size = pFuncs->size;
NPNFuncs.version = pFuncs->version;
NPNFuncs.geturlnotify = pFuncs->geturlnotify;
NPNFuncs.geturl = pFuncs->geturl;
NPNFuncs.posturlnotify = pFuncs->posturlnotify;
NPNFuncs.posturl = pFuncs->posturl;
NPNFuncs.requestread = pFuncs->requestread;
NPNFuncs.newstream = pFuncs->newstream;
NPNFuncs.write = pFuncs->write;
NPNFuncs.destroystream = pFuncs->destroystream;
NPNFuncs.status = pFuncs->status;
NPNFuncs.uagent = pFuncs->uagent;
NPNFuncs.memalloc = pFuncs->memalloc;
NPNFuncs.memfree = pFuncs->memfree;
NPNFuncs.memflush = pFuncs->memflush;
NPNFuncs.reloadplugins = pFuncs->reloadplugins;
NPNFuncs.getJavaEnv = pFuncs->getJavaEnv;
NPNFuncs.getJavaPeer = pFuncs->getJavaPeer;
NPNFuncs.getvalue = pFuncs->getvalue;
NPNFuncs.setvalue = pFuncs->setvalue;
NPNFuncs.invalidaterect = pFuncs->invalidaterect;
NPNFuncs.invalidateregion = pFuncs->invalidateregion;
NPNFuncs.forceredraw = pFuncs->forceredraw;
return NPERR_NO_ERROR;
}
NPError OSCALL NP_Shutdown()
{
return NPERR_NO_ERROR;
}

View File

@@ -1,732 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// npmac.cpp
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <Processes.h>
#include <Gestalt.h>
#include <CodeFragments.h>
#include <Timer.h>
#include <Resources.h>
#include <ToolUtils.h>
#define XP_MAC 1
#define NDEBUG 1
//
// A4Stuff.h contains the definition of EnterCodeResource and
// EnterCodeResource, used for setting up the code resource¹s
// globals for 68K (analagous to the function SetCurrentA5
// defined by the toolbox).
//
#if TARGET_CPU_68K
#include <A4Stuff.h>
#else
#define EnterCodeResource()
#define ExitCodeResource()
#endif
#include "jri.h"
#include "npapi.h"
//
// The Mixed Mode procInfos defined in npupp.h assume Think C-
// style calling conventions. These conventions are used by
// Metrowerks with the exception of pointer return types, which
// in Metrowerks 68K are returned in A0, instead of the standard
// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
// Mixed Mode will return the values to a 68K plugin in D0, but
// a 68K plugin compiled by Metrowerks will expect the result in
// A0. The following pragma forces Metrowerks to use D0 instead.
//
#ifdef __MWERKS__
#ifndef powerc
#pragma pointers_in_D0
#endif
#endif
#include "npupp.h"
#ifdef __MWERKS__
#ifndef powerc
#pragma pointers_in_A0
#endif
#endif
// The following fix for static initializers (which fixes a preious
// incompatibility with some parts of PowerPlant, was submitted by
// Jan Ulbrich.
#ifdef __MWERKS__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef powerc
extern void __InitCode__(void);
#else
extern void __sinit(void);
#define __InitCode__ __sinit
#endif
extern void __destroy_global_chain(void);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __MWERKS__
//
// Define PLUGIN_TRACE to 1 to have the wrapper functions emit
// DebugStr messages whenever they are called.
//
#define PLUGIN_TRACE 0
#if PLUGIN_TRACE
#define PLUGINDEBUGSTR(msg) ::DebugStr(msg)
#else
#define PLUGINDEBUGSTR
#endif
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Globals
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#if !TARGET_API_MAC_CARBON
QDGlobals* gQDPtr; // Pointer to Netscape's QuickDraw globals
#endif
short gResFile; // Refnum of the plugin's resource file
NPNetscapeFuncs gNetscapeFuncs; // Function table for procs in Netscape called by plugin
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Wrapper functions for all calls from the plugin to Netscape.
// These functions let the plugin developer just call the APIs
// as documented and defined in npapi.h, without needing to know
// about the function table and call macros in npupp.h.
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = gNetscapeFuncs.version >> 8; // Major version is in high byte
*netscape_minor = gNetscapeFuncs.version & 0xFF; // Minor version is in low byte
}
NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_GetURL(NPP instance, const char* url, const char* window)
{
return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url,
window, len, buf, file, notifyData);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance, url, window, len, buf, file);
}
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return CallNPN_RequestReadProc(gNetscapeFuncs.requestread, stream, rangeList);
}
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStream** stream)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{
err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{
err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{
err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
void NPN_Status(NPP instance, const char* message)
{
CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
}
const char* NPN_UserAgent(NPP instance)
{
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
}
#define DEBUG_MEMORY 0
void* NPN_MemAlloc(uint32 size)
{
#if DEBUG_MEMORY
return (void*) NewPtrClear(size);
#else
return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
#endif
}
void NPN_MemFree(void* ptr)
{
#if DEBUG_MEMORY
DisposePtr(Ptr(ptr));
#else
CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
#endif
}
uint32 NPN_MemFlush(uint32 size)
{
return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
}
JRIEnv* NPN_GetJavaEnv(void)
{
return CallNPN_GetJavaEnvProc( gNetscapeFuncs.getJavaEnv );
}
jref NPN_GetJavaPeer(NPP instance)
{
return CallNPN_GetJavaPeerProc( gNetscapeFuncs.getJavaPeer, instance );
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
return CallNPN_GetValueProc( gNetscapeFuncs.getvalue, instance, variable, value);
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
return CallNPN_SetValueProc( gNetscapeFuncs.setvalue, instance, variable, value);
}
void NPN_InvalidateRect(NPP instance, NPRect *rect)
{
CallNPN_InvalidateRectProc( gNetscapeFuncs.invalidaterect, instance, rect);
}
void NPN_InvalidateRegion(NPP instance, NPRegion region)
{
CallNPN_InvalidateRegionProc( gNetscapeFuncs.invalidateregion, instance, region);
}
void NPN_ForceRedraw(NPP instance)
{
CallNPN_ForceRedrawProc( gNetscapeFuncs.forceredraw, instance);
}
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Wrapper functions for all calls from Netscape to the plugin.
// These functions let the plugin developer just create the APIs
// as documented and defined in npapi.h, without needing to
// install those functions in the function table or worry about
// setting up globals for 68K plugins.
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
NPError Private_Initialize(void);
void Private_Shutdown(void);
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
NPError Private_Destroy(NPP instance, NPSavedData** save);
NPError Private_SetWindow(NPP instance, NPWindow* window);
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
int32 Private_WriteReady(NPP instance, NPStream* stream);
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
void Private_Print(NPP instance, NPPrint* platformPrint);
int16 Private_HandleEvent(NPP instance, void* event);
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
jref Private_GetJavaClass(void);
NPError Private_GetValue(NPP instance, NPPVariable variable, void *result);
NPError Private_SetValue(NPP instance, NPNVariable variable, void *value);
NPError Private_Initialize(void)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pInitialize;g;");
err = NPP_Initialize();
ExitCodeResource();
return err;
}
void Private_Shutdown(void)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pShutdown;g;");
NPP_Shutdown();
__destroy_global_chain();
ExitCodeResource();
}
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
EnterCodeResource();
NPError ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
PLUGINDEBUGSTR("\pNew;g;");
ExitCodeResource();
return ret;
}
NPError Private_Destroy(NPP instance, NPSavedData** save)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pDestroy;g;");
err = NPP_Destroy(instance, save);
ExitCodeResource();
return err;
}
NPError Private_SetWindow(NPP instance, NPWindow* window)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pSetWindow;g;");
err = NPP_SetWindow(instance, window);
ExitCodeResource();
return err;
}
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pNewStream;g;");
err = NPP_NewStream(instance, type, stream, seekable, stype);
ExitCodeResource();
return err;
}
int32 Private_WriteReady(NPP instance, NPStream* stream)
{
int32 result;
EnterCodeResource();
PLUGINDEBUGSTR("\pWriteReady;g;");
result = NPP_WriteReady(instance, stream);
ExitCodeResource();
return result;
}
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
{
int32 result;
EnterCodeResource();
PLUGINDEBUGSTR("\pWrite;g;");
result = NPP_Write(instance, stream, offset, len, buffer);
ExitCodeResource();
return result;
}
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pStreamAsFile;g;");
NPP_StreamAsFile(instance, stream, fname);
ExitCodeResource();
}
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pDestroyStream;g;");
err = NPP_DestroyStream(instance, stream, reason);
ExitCodeResource();
return err;
}
int16 Private_HandleEvent(NPP instance, void* event)
{
int16 result;
EnterCodeResource();
PLUGINDEBUGSTR("\pHandleEvent;g;");
result = NPP_HandleEvent(instance, event);
ExitCodeResource();
return result;
}
void Private_Print(NPP instance, NPPrint* platformPrint)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pPrint;g;");
NPP_Print(instance, platformPrint);
ExitCodeResource();
}
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pURLNotify;g;");
NPP_URLNotify(instance, url, reason, notifyData);
ExitCodeResource();
}
jref Private_GetJavaClass(void)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pGetJavaClass;g;");
jref clazz = NPP_GetJavaClass();
ExitCodeResource();
if (clazz)
{
JRIEnv* env = NPN_GetJavaEnv();
return (jref)JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
NPError Private_GetValue(NPP instance, NPPVariable variable, void *result)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pGetValue;g;");
err = NPP_GetValue(instance, variable, result);
ExitCodeResource();
return err;
}
NPError Private_SetValue(NPP instance, NPNVariable variable, void *value)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pSetValue;g;");
err = NPP_SetValue(instance, variable, value);
ExitCodeResource();
return err;
}
void SetUpQD(void);
void SetUpQD(void)
{
ProcessSerialNumber PSN;
FSSpec myFSSpec;
Str63 name;
ProcessInfoRec infoRec;
OSErr result = noErr;
CFragConnectionID connID;
Str255 errName;
//
// Memorize the plugin¹s resource file
// refnum for later use.
//
gResFile = CurResFile();
#if !TARGET_API_MAC_CARBON
//
// Ask the system if CFM is available.
//
long response;
OSErr err = Gestalt(gestaltCFMAttr, &response);
Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
if (hasCFM)
{
//
// GetProcessInformation takes a process serial number and
// will give us back the name and FSSpec of the application.
// See the Process Manager in IM.
//
infoRec.processInfoLength = sizeof(ProcessInfoRec);
infoRec.processName = name;
infoRec.processAppSpec = &myFSSpec;
PSN.highLongOfPSN = 0;
PSN.lowLongOfPSN = kCurrentProcess;
result = GetProcessInformation(&PSN, &infoRec);
if (result != noErr)
PLUGINDEBUGSTR("\pFailed in GetProcessInformation");
}
else
//
// If no CFM installed, assume it must be a 68K app.
//
result = -1;
if (result == noErr)
{
//
// Now that we know the app name and FSSpec, we can call GetDiskFragment
// to get a connID to use in a subsequent call to FindSymbol (it will also
// return the address of ³main² in app, which we ignore). If GetDiskFragment
// returns an error, we assume the app must be 68K.
//
Ptr mainAddr;
result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
kReferenceCFrag, &connID, (Ptr*)&mainAddr, errName);
}
if (result == noErr)
{
//
// The app is a PPC code fragment, so call FindSymbol
// to get the exported ³qd² symbol so we can access its
// QuickDraw globals.
//
CFragSymbolClass symClass;
result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
if (result != noErr)
PLUGINDEBUGSTR("\pFailed in FindSymbol qd");
}
else
{
//
// The app is 68K, so use its A5 to compute the address
// of its QuickDraw globals.
//
gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
}
#endif /* !TARGET_API_MAC_CARBON */
}
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
#pragma export on
#if !TARGET_API_MAC_CARBON
RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
#endif
#pragma export off
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pmain");
NPError err = NPERR_NO_ERROR;
//
// Ensure that everything Netscape passed us is valid!
//
if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL))
err = NPERR_INVALID_FUNCTABLE_ERROR;
//
// Check the ³major² version passed in Netscape¹s function table.
// We won¹t load if the major version is newer than what we expect.
// Also check that the function tables passed in are big enough for
// all the functions we need (they could be bigger, if Netscape added
// new APIs, but that¹s OK with us -- we¹ll just ignore them).
//
if (err == NPERR_NO_ERROR)
{
if ((nsTable->version >> 8) > NP_VERSION_MAJOR) // Major version is in high byte
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
// if (nsTable->size < sizeof(NPNetscapeFuncs))
// err = NPERR_INVALID_FUNCTABLE_ERROR;
// if (pluginFuncs->size < sizeof(NPPluginFuncs))
// err = NPERR_INVALID_FUNCTABLE_ERROR;
}
if (err == NPERR_NO_ERROR)
{
//
// Copy all the fields of Netscape¹s function table into our
// copy so we can call back into Netscape later. Note that
// we need to copy the fields one by one, rather than assigning
// the whole structure, because the Netscape function table
// could actually be bigger than what we expect.
//
int navMinorVers = nsTable->version & 0xFF;
gNetscapeFuncs.version = nsTable->version;
gNetscapeFuncs.size = nsTable->size;
gNetscapeFuncs.posturl = nsTable->posturl;
gNetscapeFuncs.geturl = nsTable->geturl;
gNetscapeFuncs.requestread = nsTable->requestread;
gNetscapeFuncs.newstream = nsTable->newstream;
gNetscapeFuncs.write = nsTable->write;
gNetscapeFuncs.destroystream = nsTable->destroystream;
gNetscapeFuncs.status = nsTable->status;
gNetscapeFuncs.uagent = nsTable->uagent;
gNetscapeFuncs.memalloc = nsTable->memalloc;
gNetscapeFuncs.memfree = nsTable->memfree;
gNetscapeFuncs.memflush = nsTable->memflush;
gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
{
gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
}
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
}
gNetscapeFuncs.getvalue = nsTable->getvalue;
gNetscapeFuncs.setvalue = nsTable->setvalue;
gNetscapeFuncs.invalidaterect = nsTable->invalidaterect;
gNetscapeFuncs.invalidateregion = nsTable->invalidateregion;
gNetscapeFuncs.forceredraw = nsTable->forceredraw;
// defer static constructors until the global functions are initialized.
__InitCode__();
//
// Set up the plugin function table that Netscape will use to
// call us. Netscape needs to know about our version and size
// and have a UniversalProcPointer for every function we implement.
//
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
pluginFuncs->size = sizeof(NPPluginFuncs);
pluginFuncs->newp = NewNPP_NewProc(Private_New);
pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
pluginFuncs->write = NewNPP_WriteProc(Private_Write);
pluginFuncs->print = NewNPP_PrintProc(Private_Print);
pluginFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
}
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
{
pluginFuncs->javaClass = (JRIGlobalRef) Private_GetJavaClass();
pluginFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
pluginFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
}
*unloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
SetUpQD();
err = Private_Initialize();
}
ExitCodeResource();
return err;
}

View File

@@ -1,213 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
////////////////////////////////////////////////////////////
//
// Implementation of Netscape entry points (NPN_*)
//
#include "npapi.h"
#include "npupp.h"
extern NPNetscapeFuncs NPNFuncs;
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = HIBYTE(NPNFuncs.version);
*netscape_minor = LOBYTE(NPNFuncs.version);
}
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
int navMinorVers = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
NPError rv = NPNFuncs.geturl(instance, url, target);
return rv;
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
return rv;
}
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
NPError rv = NPNFuncs.requestread(stream, rangeList);
return rv;
}
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
{
int navMinorVersion = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = NPNFuncs.newstream(instance, type, target, stream);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
{
int navMinorVersion = NPNFuncs.version & 0xFF;
int32 rv = 0;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = NPNFuncs.write(instance, stream, len, buffer);
else
rv = -1;
return rv;
}
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVersion = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = NPNFuncs.destroystream(instance, stream, reason);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
void NPN_Status(NPP instance, const char *message)
{
NPNFuncs.status(instance, message);
}
const char* NPN_UserAgent(NPP instance)
{
const char * rv = NULL;
rv = NPNFuncs.uagent(instance);
return rv;
}
void* NPN_MemAlloc(uint32 size)
{
void * rv = NULL;
rv = NPNFuncs.memalloc(size);
return rv;
}
void NPN_MemFree(void* ptr)
{
NPNFuncs.memfree(ptr);
}
uint32 NPN_MemFlush(uint32 size)
{
uint32 rv = NPNFuncs.memflush(size);
return rv;
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
NPNFuncs.reloadplugins(reloadPages);
}
JRIEnv* NPN_GetJavaEnv(void)
{
JRIEnv * rv = NULL;
rv = NPNFuncs.getJavaEnv();
return rv;
}
jref NPN_GetJavaPeer(NPP instance)
{
jref rv;
rv = NPNFuncs.getJavaPeer(instance);
return rv;
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
NPError rv = NPNFuncs.getvalue(instance, variable, value);
return rv;
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
NPError rv = NPNFuncs.setvalue(instance, variable, value);
return rv;
}
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
NPNFuncs.invalidaterect(instance, invalidRect);
}
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
NPNFuncs.invalidateregion(instance, invalidRegion);
}
void NPN_ForceRedraw(NPP instance)
{
NPNFuncs.forceredraw(instance);
}

View File

@@ -1,265 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
////////////////////////////////////////////////////////////
//
// Implementation of plugin entry points (NPP_*)
// most are just empty stubs for this particular plugin
//
#include "plugin.h"
NPError NPP_Initialize(void)
{
return NPERR_NO_ERROR;
}
void NPP_Shutdown(void)
{
}
// here the plugin creates an instance of our CPlugin object which
// will be associated with this newly created plugin instance and
// will do all the neccessary job
NPError NPP_New(NPMIMEType pluginType,
NPP instance,
uint16 mode,
int16 argc,
char* argn[],
char* argv[],
NPSavedData* saved)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
CPlugin * pPlugin = new CPlugin(instance);
if(pPlugin == NULL)
return NPERR_OUT_OF_MEMORY_ERROR;
instance->pdata = (void *)pPlugin;
return rv;
}
// here is the place to clean up and destroy the CPlugin object
NPError NPP_Destroy (NPP instance, NPSavedData** save)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
CPlugin * pPlugin = (CPlugin *)instance->pdata;
if(pPlugin != NULL) {
pPlugin->shut();
delete pPlugin;
}
return rv;
}
// during this call we know when the plugin window is ready or
// is about to be destroyed so we can do some gui specific
// initialization and shutdown
NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
if(pNPWindow == NULL)
return NPERR_GENERIC_ERROR;
CPlugin * pPlugin = (CPlugin *)instance->pdata;
if(pPlugin == NULL)
return NPERR_GENERIC_ERROR;
// window just created
if(!pPlugin->isInitialized() && (pNPWindow->window != NULL)) {
if(!pPlugin->init(pNPWindow)) {
delete pPlugin;
pPlugin = NULL;
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
// window goes away
if((pNPWindow->window == NULL) && pPlugin->isInitialized())
return NPERR_NO_ERROR;
// window resized
if(pPlugin->isInitialized() && (pNPWindow->window != NULL))
return NPERR_NO_ERROR;
// this should not happen, nothing to do
if((pNPWindow->window == NULL) && !pPlugin->isInitialized())
return NPERR_NO_ERROR;
return rv;
}
// ==============================
// ! Scriptability related code !
// ==============================
//
// here the plugin is asked by Mozilla to tell if it is scriptable
// we should return a valid interface id and a pointer to
// nsScriptablePeer interface which we should have implemented
// and which should be defined in the corressponding *.xpt file
// in the bin/components folder
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
if(instance == NULL)
return NPERR_GENERIC_ERROR;
CPlugin * pPlugin = (CPlugin *)instance->pdata;
if(pPlugin == NULL)
return NPERR_GENERIC_ERROR;
if (variable == NPPVpluginScriptableInstance) {
// addref happens in getter, so we don't addref here
nsI4xScriptablePlugin * scriptablePeer = pPlugin->getScriptablePeer();
if (scriptablePeer) {
*(nsISupports **)value = scriptablePeer;
} else {
rv = NPERR_OUT_OF_MEMORY_ERROR;
}
}
else if (variable == NPPVpluginScriptableIID) {
static nsIID scriptableIID = NS_I4XSCRIPTABLEPLUGIN_IID;
nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
if (ptr) {
*ptr = scriptableIID;
*(nsIID **)value = ptr;
} else {
rv = NPERR_OUT_OF_MEMORY_ERROR;
}
}
return rv;
}
NPError NPP_NewStream(NPP instance,
NPMIMEType type,
NPStream* stream,
NPBool seekable,
uint16* stype)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
return rv;
}
int32 NPP_WriteReady (NPP instance, NPStream *stream)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
int32 rv = 0x0fffffff;
return rv;
}
int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
int32 rv = len;
return rv;
}
NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
return rv;
}
void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
{
if(instance == NULL)
return;
}
void NPP_Print (NPP instance, NPPrint* printInfo)
{
if(instance == NULL)
return;
}
void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
if(instance == NULL)
return;
}
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
{
if(instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
NPError rv = NPERR_NO_ERROR;
return rv;
}
int16 NPP_HandleEvent(NPP instance, void* event)
{
if(instance == NULL)
return 0;
int16 rv = 0;
CPlugin * pPlugin = (CPlugin *)instance->pdata;
if (pPlugin)
rv = pPlugin->handleEvent(event);
return rv;
}
jref NPP_GetJavaClass (void)
{
return NULL;
}

View File

@@ -1,35 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface acmeIScriptObject;
[scriptable, uuid(482e1890-1fe5-11d5-9cf8-0060b0fbd8ac)]
interface nsI4xScriptablePlugin : nsISupports {
void showVersion();
void clear();
readonly attribute string version;
void setWindow(in acmeIScriptObject window);
};

View File

@@ -1,168 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// ==============================
// ! Scriptability related code !
// ==============================
//
/////////////////////////////////////////////////////
//
// This file implements the nsScriptablePeer object
// The native methods of this class are supposed to
// be callable from JavaScript
//
#include "plugin.h"
#include "acmeIScriptObject.h"
#include "npapi.h"
static NS_DEFINE_IID(kI4xScriptablePluginIID, NS_I4XSCRIPTABLEPLUGIN_IID);
static NS_DEFINE_IID(kIClassInfoIID, NS_ICLASSINFO_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
nsScriptablePeer::nsScriptablePeer(CPlugin* aPlugin)
{
mRefCnt = 0;
mPlugin = aPlugin;
mWindow = nsnull;
}
nsScriptablePeer::~nsScriptablePeer()
{
}
// AddRef, Release and QueryInterface are common methods and must
// be implemented for any interface
NS_IMETHODIMP_(nsrefcnt) nsScriptablePeer::AddRef()
{
++mRefCnt;
return mRefCnt;
}
NS_IMETHODIMP_(nsrefcnt) nsScriptablePeer::Release()
{
--mRefCnt;
if (mRefCnt == 0) {
delete this;
return 0;
}
return mRefCnt;
}
// here nsScriptablePeer should return three interfaces it can be asked for by their iid's
// static casts are necessary to ensure that correct pointer is returned
NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if(!aInstancePtr)
return NS_ERROR_NULL_POINTER;
if(aIID.Equals(kI4xScriptablePluginIID)) {
*aInstancePtr = static_cast<nsI4xScriptablePlugin*>(this);
AddRef();
return NS_OK;
}
if(aIID.Equals(kIClassInfoIID)) {
*aInstancePtr = static_cast<nsIClassInfo*>(this);
AddRef();
return NS_OK;
}
if(aIID.Equals(kISupportsIID)) {
*aInstancePtr = static_cast<nsISupports*>(static_cast<nsI4xScriptablePlugin*>(this));
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
//
// the following two methods will be callable from JavaScript
//
NS_IMETHODIMP nsScriptablePeer::ShowVersion()
{
if (mPlugin)
mPlugin->showVersion();
return NS_OK;
}
NS_IMETHODIMP nsScriptablePeer::Clear()
{
if (mPlugin)
mPlugin->clear();
return NS_OK;
}
NS_IMETHODIMP nsScriptablePeer::GetVersion(char * *aVersion)
{
if (mPlugin)
mPlugin->getVersion(aVersion);
return NS_OK;
}
NS_IMETHODIMP nsScriptablePeer::SetWindow(acmeIScriptObject *window)
{
NS_IF_ADDREF(window);
NS_IF_RELEASE(mWindow);
mWindow = window;
// evaluate a JavaScript expression.
acmeIScriptObject* result;
nsresult rv = window->Evaluate("Math.PI", &result);
if (NS_SUCCEEDED(rv) && result) {
double value;
result->ToNumber(&value);
NS_RELEASE(result);
}
// read the current window's location.
acmeIScriptObject* location = nsnull;
rv = window->GetProperty("location", &location);
if (NS_SUCCEEDED(rv) && location) {
char* locationStr = NULL;
rv = location->ToString(&locationStr);
if (NS_SUCCEEDED(rv) && locationStr) {
NPN_MemFree(locationStr);
}
NS_RELEASE(location);
}
return NS_OK;
}

View File

@@ -1,106 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// ==============================
// ! Scriptability related code !
// ==============================
//
// nsScriptablePeer - xpconnect scriptable peer
//
#ifndef __nsScriptablePeer_h__
#define __nsScriptablePeer_h__
#include "nsI4xScriptablePlugin.h"
#include "nsIClassInfo.h"
class CPlugin;
// We must implement nsIClassInfo because it signals the
// Mozilla Security Manager to allow calls from JavaScript.
class nsClassInfoMixin : public nsIClassInfo
{
// These flags are used by the DOM and security systems to signal that
// JavaScript callers are allowed to call this object's scritable methods.
NS_IMETHOD GetFlags(PRUint32 *aFlags)
{*aFlags = nsIClassInfo::PLUGIN_OBJECT | nsIClassInfo::DOM_OBJECT;
return NS_OK;}
NS_IMETHOD GetImplementationLanguage(PRUint32 *aImplementationLanguage)
{*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;}
// The rest of the methods can safely return error codes...
NS_IMETHOD GetInterfaces(PRUint32 *count, nsIID * **array)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetContractID(char * *aContractID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassDescription(char * *aClassDescription)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassID(nsCID * *aClassID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{return NS_ERROR_NOT_IMPLEMENTED;}
};
class nsScriptablePeer : public nsI4xScriptablePlugin,
public nsClassInfoMixin
{
public:
nsScriptablePeer(CPlugin* plugin);
~nsScriptablePeer();
public:
// methods from nsISupports
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
NS_IMETHOD_(nsrefcnt) AddRef();
NS_IMETHOD_(nsrefcnt) Release();
protected:
nsrefcnt mRefCnt;
public:
// native methods callable from JavaScript
NS_DECL_NSI4XSCRIPTABLEPLUGIN
protected:
CPlugin* mPlugin;
acmeIScriptObject* mWindow;
};
#endif

View File

@@ -1,81 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// ==============================
// ! Scriptability related code !
// ==============================
//
/////////////////////////////////////////////////////
//
// This file implements the nsScriptablePeer object
// The native methods of this class are supposed to
// be callable from JavaScript
//
#include "plugin.h"
nsScriptablePeer::nsScriptablePeer(CPlugin* aPlugin)
{
mPlugin = aPlugin;
}
nsScriptablePeer::~nsScriptablePeer()
{
}
// Notice that we expose our claim to implement nsIClassInfo.
NS_IMPL_ISUPPORTS2(nsScriptablePeer, nsI4xScriptablePlugin, nsIClassInfo)
//
// the following two methods will be callable from JavaScript
//
NS_IMETHODIMP nsScriptablePeer::ShowVersion()
{
if (mPlugin)
mPlugin->showVersion();
return NS_OK;
}
NS_IMETHODIMP nsScriptablePeer::Clear()
{
if (mPlugin)
mPlugin->clear();
return NS_OK;
}

View File

@@ -1,95 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// ==============================
// ! Scriptability related code !
// ==============================
//
// nsScriptablePeer - xpconnect scriptable peer
//
#ifndef __nsScriptablePeer_h__
#define __nsScriptablePeer_h__
#include "nsI4xScriptablePlugin.h"
#include "nsIClassInfo.h"
class CPlugin;
// We must implement nsIClassInfo because it signals the
// Mozilla Security Manager to allow calls from JavaScript.
class nsClassInfoMixin : public nsIClassInfo
{
// These flags are used by the DOM and security systems to signal that
// JavaScript callers are allowed to call this object's scritable methods.
NS_IMETHOD GetFlags(PRUint32 *aFlags)
{*aFlags = nsIClassInfo::PLUGIN_OBJECT | nsIClassInfo::DOM_OBJECT;
return NS_OK;}
NS_IMETHOD GetImplementationLanguage(PRUint32 *aImplementationLanguage)
{*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;}
// The rest of the methods can safely return error codes...
NS_IMETHOD GetInterfaces(PRUint32 *count, nsIID * **array)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetContractID(char * *aContractID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassDescription(char * *aClassDescription)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassID(nsCID * *aClassID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{return NS_ERROR_NOT_IMPLEMENTED;}
};
class nsScriptablePeer : public nsI4xScriptablePlugin,
public nsClassInfoMixin
{
public:
nsScriptablePeer(CPlugin* plugin);
~nsScriptablePeer();
NS_DECL_ISUPPORTS
NS_DECL_NSI4XSCRIPTABLEPLUGIN
protected:
CPlugin* mPlugin;
};
#endif

View File

@@ -1,215 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//////////////////////////////////////////////////
//
// CPlugin class implementation
//
#ifdef XP_WIN
#include <windows.h>
#include <windowsx.h>
#endif
#ifdef XP_MAC
#include <TextEdit.h>
#endif
#include "plugin.h"
CPlugin::CPlugin(NPP pNPInstance) :
m_pNPInstance(pNPInstance),
m_pNPStream(NULL),
m_bInitialized(FALSE),
m_pScriptablePeer(NULL)
{
#ifdef XP_WIN
m_hWnd = NULL;
#endif
const char *ua = NPN_UserAgent(m_pNPInstance);
strcpy(m_String, ua);
}
CPlugin::~CPlugin()
{
NS_IF_RELEASE(m_pScriptablePeer);
}
#ifdef XP_WIN
static LRESULT CALLBACK PluginWinProc(HWND, UINT, WPARAM, LPARAM);
static WNDPROC lpOldProc = NULL;
#endif
NPBool CPlugin::init(NPWindow* pNPWindow)
{
if(pNPWindow == NULL)
return FALSE;
#ifdef XP_WIN
m_hWnd = (HWND)pNPWindow->window;
if(m_hWnd == NULL)
return FALSE;
// subclass window so we can intercept window messages and
// do our drawing to it
lpOldProc = SubclassWindow(m_hWnd, (WNDPROC)PluginWinProc);
// associate window with our CPlugin object so we can access
// it in the window procedure
SetWindowLong(m_hWnd, GWL_USERDATA, (LONG)this);
#endif
m_Window = pNPWindow;
m_bInitialized = TRUE;
return TRUE;
}
void CPlugin::shut()
{
#ifdef XP_WIN
// subclass it back
SubclassWindow(m_hWnd, lpOldProc);
m_hWnd = NULL;
#endif
m_bInitialized = FALSE;
}
NPBool CPlugin::isInitialized()
{
return m_bInitialized;
}
int16 CPlugin::handleEvent(void* event)
{
#ifdef XP_MAC
NPEvent* ev = (NPEvent*)event;
if (m_Window) {
Rect box = { m_Window->y, m_Window->x,
m_Window->y + m_Window->height, m_Window->x + m_Window->width };
if (ev->what == updateEvt) {
::TETextBox(m_String, strlen(m_String), &box, teJustCenter);
}
}
#endif
return 0;
}
// this will force to draw a version string in the plugin window
void CPlugin::showVersion()
{
const char *ua = NPN_UserAgent(m_pNPInstance);
strcpy(m_String, ua);
#ifdef XP_WIN
InvalidateRect(m_hWnd, NULL, TRUE);
UpdateWindow(m_hWnd);
#endif
if (m_Window) {
NPRect r = { m_Window->y, m_Window->x,
m_Window->y + m_Window->height, m_Window->x + m_Window->width };
NPN_InvalidateRect(m_pNPInstance, &r);
}
}
// this will clean the plugin window
void CPlugin::clear()
{
strcpy(m_String, "");
#ifdef XP_WIN
InvalidateRect(m_hWnd, NULL, TRUE);
UpdateWindow(m_hWnd);
#endif
}
void CPlugin::getVersion(char* *aVersion)
{
const char *ua = NPN_UserAgent(m_pNPInstance);
char*& version = *aVersion;
version = (char*)NPN_MemAlloc(1 + strlen(ua));
if (version)
strcpy(version, ua);
}
// ==============================
// ! Scriptability related code !
// ==============================
//
// this method will return the scriptable object (and create it if necessary)
nsI4xScriptablePlugin* CPlugin::getScriptablePeer()
{
if (!m_pScriptablePeer) {
m_pScriptablePeer = new nsScriptablePeer(this);
if(!m_pScriptablePeer)
return NULL;
NS_ADDREF(m_pScriptablePeer);
}
// add reference for the caller requesting the object
NS_ADDREF(m_pScriptablePeer);
return m_pScriptablePeer;
}
#ifdef XP_WIN
static LRESULT CALLBACK PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_PAINT:
{
// draw a frame and display the string
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
RECT rc;
GetClientRect(hWnd, &rc);
FrameRect(hdc, &rc, GetStockBrush(BLACK_BRUSH));
CPlugin * p = (CPlugin *)GetWindowLong(hWnd, GWL_USERDATA);
if(p)
DrawText(hdc, p->m_String, strlen(p->m_String), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hWnd, &ps);
}
break;
default:
break;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
#endif

View File

@@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __PLUGIN_H__
#define __PLUGIN_H__
#include "npapi.h"
#include "nsScriptablePeer.h"
class CPlugin
{
private:
NPP m_pNPInstance;
#ifdef XP_WIN
HWND m_hWnd;
#endif
NPWindow * m_Window;
NPStream * m_pNPStream;
NPBool m_bInitialized;
nsI4xScriptablePlugin * m_pScriptablePeer;
public:
char m_String[128];
public:
CPlugin(NPP pNPInstance);
~CPlugin();
NPBool init(NPWindow* pNPWindow);
void shut();
NPBool isInitialized();
int16 handleEvent(void* event);
void showVersion();
void clear();
void getVersion(char* *aVersion);
nsI4xScriptablePlugin* getScriptablePeer();
};
#endif // __PLUGIN_H__

View File

@@ -1,39 +0,0 @@
This is a plugin sample which demonstrates how with minimal modifications
in the 4.x legacy plugin code to achieve scripting functionality despite
of Mozilla not supporting LiveConnect in the way it was supported in
Netscape Communicator.
To build the sample:
1. create .xpt and nsI4xScrPlugin.h out of nsI4xScrPlugin.idl file
using Netscape idl compiler xpidl.exe. The command options are:
xpidl -m header nsI4xScrPlugin.idl
xpidl -m typelib nsI4xScrPlugin.idl
nsISupports.idl and nsrootidl.idl are needed for this.
2. create a project and build np4xscr.dll -- the plugin itself
3. place .xpt file in the components directory and the dll in the
plugins directory
4. load test.html and see it in work
The current sample code was written for Windows but can be easily
modified for other platforms.
Important notice: although developers who work on xpcom plugins
are strongly encouraged to use Netscape macros for common interface
method declarations and implementations, in the present sample we
decided to use their manual implementation. This is because the technique
shown in the sample may be useful for plugins which are supposed to
work under both Mozilla based browsers and Netscape Communicator
(4.x browsers). Using the macros requires linking against some
libraries which are not present in 4.x browsers (xpcom.lib, nspr.lib).
Files which under other circumstances would benefit from using
the macros are nsScriptablePeer.h and nsScriptablePeer.cpp. The versions
which use macros are also included (nsScriptablePeer1.h and
nsScriptablePeer1.cpp) for reference purposes.
Some header files from mozilla/dist/include and some .idl files from
mozilla/dist/idl are still needed to successfully build the sample.

View File

@@ -1,20 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by np4xscr.rc
//
#define IDD_MAIN 101
#define IDC_BUTTON_GO 1002
#define IDC_STATIC_UA 1003
#define IDC_BUTTON1 1005
#define IDC_BUTTON_DONT 1005
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1006
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -1,53 +0,0 @@
<html>
<body>
<embed type="application/mozilla-4x-scriptable-plugin" width=0 height=0>
</embed>
<script language="javascript">
var plugin = document.embeds[0];
document.write("version = " + plugin.version);
function jsScriptObject(obj)
{
// implementation detail, to allow unwrapping.
this.wrappedJSObject = obj;
}
jsScriptObject.prototype = {
getProperty : function(name)
{
return new jsScriptObject(this.wrappedJSObject[name]);
}
,
setProperty : function(name, value)
{
this.wrappedJSObject[name] = value;
}
,
evaluate : function(expression)
{
return new jsScriptObject(eval(expression));
}
,
toString : function()
{
return this.wrappedJSObject.toString();
}
,
toNumber : function()
{
return this.wrappedJSObject.valueOf();
}
,
fromString : function(value)
{
return new jsScriptObject(value);
}
,
fromNumber : function(value)
{
return new jsScriptObject(value);
}
};
plugin.setWindow(new jsScriptObject(window));
</script>
</body>
</html>

View File

@@ -1,48 +0,0 @@
<HTML>
<HEAD>
<TITLE>4x Scriptable Plug-in Test</TITLE>
</HEAD>
<BODY>
<center>
<h1> XPConnect Scriptable Old Style Sample Plug-in </h1>
</center>
This page contains a testcase which demonstrates the work of scriptable 4.x style
Navigator plug-in with Mozilla. The example plug-in occupies the area right below this text,
and you should see a frame the plug-in draws around its window. Below the plug-in window
there are two buttons. Clicking on the buttons will result in calling native plugin
methods from JavaScript. Show Version will instruct the plug-in to retrieve the
Mozilla user agent string and display it in the plug-in window, Clear button will
call plug-in method to erase the window.
<br><br>
<center>
<embed type="application/mozilla-4x-scriptable-plugin" width=600 height=40><br>
<script>
var embed = document.embeds[0];
function ShowVersion()
{
embed.showVersion();
}
function Clear()
{
embed.clear();
}
</script>
<br>
<form name="formname">
<input type=button value="Show Version" onclick='ShowVersion()'>
<input type=button value="Clear" onclick='Clear()'>
</form>
</center>
</BODY>
</HTML>

View File

@@ -1,57 +0,0 @@
############################################################################
## Makefile.in (Generic SANE Plugin Tree)
##
## The contents of this file are subject to the Mozilla Public
## License Version 1.1 (the "License"); you may not use this file
## except in compliance with the License. You may obtain a copy of
## the License at http://www.mozilla.org/MPL/
##
## Software distributed under the License is distributed on an "AS
## IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
## implied. See the License for the specific language governing
## rights and limitations under the License.
## Contributor(s):
##
## Rusty Lynch <rusty.lynch@intel.com>
############################################################################
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = SanePlugin
LIBRARY_NAME = Sane
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
CPPSRCS = \
nsSanePluginFactory.cpp \
nsSanePlugin.cpp \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../../public \
-I/usr/lib/glib/include
EXTRA_DSO_LDOPTS += -L$(DIST)/lib -lgtksuperwin \
$(TK_LIBS) -lsane -ljpeg
XPIDLSRCS = nsSanePluginControl.idl
include $(topsrcdir)/config/rules.mk
libs:: $(TARGETS)
$(INSTALL) $(srcdir)/test/camera.html $(DIST)/bin/res/samples
$(INSTALL) $(srcdir)/test/scanner.html $(DIST)/bin/res/samples
$(INSTALL) $(srcdir)/test/camera.html /home/httpd/html/test
$(INSTALL) $(srcdir)/test/scanner.html /home/httpd/html/test
superclean: clean
rm -f *~ test/*~

View File

@@ -1,45 +0,0 @@
What is this plug-in?
---------------------
This is a Linux/Mozilla plug-in that enables a scanner/digital
camera application to be created with JavaScript. To this end
the SANE plug-in provides two things:
1. I have attempted to export all of the SANE API's
from the SANE native libraries to JavaScript.
(I have provided two brain-dead samples for a
CPia USB digital camera and HP 6300 scanner.)
2. A drawing surface for displaying the scanned image.
=====================================================================
Why did you bother?
------------------
Originally, I used this plug-in to cut my teeth on the new Mozilla
XPCom plug-in model. Now I am hoping to provide a Linux/Mozilla
plug-in sample that exercises most of the functionality that the
Linux community would want to use (like connecting JavaScript
to native code.)
=====================================================================
You know, Linux isn't the only UN*X around!
-------------------------------------------
I say Linux because that is the only platform I have built/tested on.
SANE is supported by a long list of UN*X OS's so there is no reason
that other platforms shouldn't work with this plug-in.
(I have tried to stick to NSPR functions for this reason, but it's easy
to over look a couple of Linux specific functions.)
======================================================================
How do I build this beast?
-------------------------
In order to build this plug-in, you need the SANE (Scanner Access
Now Easy) libraries/headers installed on your system. For more
info on SANE, go to http://www.mostang.com/sane.

File diff suppressed because it is too large Load Diff

View File

@@ -1,238 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
* Contributor(s):
*
* Rusty Lynch <rusty.lynch@intel.com>
*/
/*
* Declares the nsSanePluginInterface class for the SANE plugin.
*/
#ifndef __NS_SANE_PLUGIN_H__
#define __NS_SANE_PLUGIN_H__
#include "prthread.h"
#include "nscore.h"
#include "nsplugin.h"
#include "gdksuperwin.h"
#include "gtkmozbox.h"
#include "gtk/gtk.h"
#include "nsIPlugin.h"
#include "nsSanePluginControl.h"
#include "nsIScriptContext.h"
#include "nsIServiceManager.h"
#include "nsISupports.h"
#include "nsISupportsUtils.h"
#include "nsIEventQueueService.h"
#include "nsIEventQueue.h"
///////////////////////////////////
// Needed for encoding jpeg images
extern "C"
{
#include <jpeglib.h>
}
///////////////////////////////////
// Needed for SANE interface
extern "C"
{
#include <sane/sane.h>
#include <sane/sanei.h>
#include <sane/saneopts.h>
}
typedef struct _PlatformInstance
{
Window window;
GtkWidget * widget;
GdkSuperWin * superwin;
Display * display;
uint16 x;
uint16 y;
uint32 width;
uint32 height;
} PlatformInstance;
// Threaded routine for grabbing a frame from device.
// If a callback for onScanComplete was set in the embed/object
// tag, then this routine will call it before exiting.
//void PR_CALLBACK scanimage_thread_routine( void * arg);
void PR_CALLBACK scanimage_thread_routine( void * arg );
class nsSanePluginInstance : public nsIPluginInstance,
public nsISanePluginInstance
{
friend void PR_CALLBACK scanimage_thread_routine( void *);
public:
nsSanePluginInstance(void);
virtual ~nsSanePluginInstance(void);
/////////////////////////////////////////////////////////////////////
// nsIPluginInstance inherited interface
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
NS_IMETHOD Start(void);
NS_IMETHOD Stop(void);
NS_IMETHOD Destroy( void );
NS_IMETHOD SetWindow( nsPluginWindow* window );
NS_IMETHOD NewStream( nsIPluginStreamListener** listener );
NS_IMETHOD Print( nsPluginPrint* platformPrint );
NS_IMETHOD GetValue( nsPluginInstanceVariable variable, void *value );
// Not used for this platform! Only a placeholder.
NS_IMETHOD HandleEvent( nsPluginEvent* event, PRBool* handled );
// End of nsIPlugIninstance inherited interface.
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// nsSanePluginInstance specific methods:
NS_DECL_ISUPPORTS ;
// Execute given callback in window's JavaScript
NS_IMETHOD DoScanCompleteCallback();
NS_IMETHOD DoInitCompleteCallback();
void SetMode(nsPluginMode mode) { fMode = mode; }
void SetState(PRInt32 aState) { mState = aState; };
NS_IMETHOD PaintImage(void);
char * GetImageFilename();
GtkWidget * GetFileSelection();
PRBool IsUIThread();
nsresult OpenSaneDeviceIF( void );
//*** Methods exposed through the XPConnect interface ***
NS_DECL_NSISANEPLUGININSTANCE
private:
GtkWidget *mDrawing_area;
GtkWidget *mEvent_box;
PlatformInstance fPlatform;
char mImageFilename[255];
GtkWidget *mFileSelection;
GdkRectangle mZoom_box;
unsigned char *mRGBData;
int mRGBWidth, mRGBHeight;
// line attributes for zoom box
PRInt32 mLineWidth;
GdkLineStyle mLineStyle;
GdkCapStyle mCapStyle;
GdkJoinStyle mJoinStyle;
// zoom box change variables
float mTopLeftXChange;
float mTopLeftYChange;
float mBottomRightXChange;
float mBottomRightYChange;
// jpeg compression attributes
int mCompQuality;
enum J_DCT_METHOD mCompMethod;
// sane specific members
SANE_Handle mSaneHandle;
SANE_String mSaneDevice;
SANE_Bool mSaneOpen;
PRBool mSuccess;
PRInt32 mState;
// needed for JavaScript Callbacks
char *mOnScanCompleteScript;
char *mOnInitCompleteScript;
PRThread *mScanThread;
PRThread *mUIThread;
protected:
nsIPluginInstancePeer* fPeer;
nsPluginWindow* fWindow;
nsPluginMode fMode;
nsIPluginManager* mPluginManager;
private:
int WritePNMHeader (int fd, SANE_Frame format,
int width, int height,
int depth);
void PlatformNew( void );
nsresult PlatformDestroy( void );
PRInt16 PlatformHandleEvent( nsPluginEvent* event );
nsresult PlatformSetWindow( nsPluginWindow* window );
};
class nsSanePluginStreamListener : public nsIPluginStreamListener
{
public:
NS_DECL_ISUPPORTS ;
/*
* Notify the observer that the URL has started to load. This method is
* called only once, at the beginning of a URL load.<BR><BR>
*
* @return The return value is currently ignored. In the future it may be
* used to cancel the URL load..
*/
NS_IMETHOD OnStartBinding( nsIPluginStreamInfo* pluginInfo );
/**
* Notify the client that data is available in the input stream. This
* method is called whenver data is written into the input stream by the
* networking library...<BR><BR>
*
* @param aIStream The input stream containing the data. This stream can
* be either a blocking or non-blocking stream.
* @param length The amount of data that was just pushed into the
* stream.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnDataAvailable( nsIPluginStreamInfo* pluginInfo,
nsIInputStream* input,
PRUint32 length );
NS_IMETHOD OnFileAvailable( nsIPluginStreamInfo* pluginInfo,
const char* fileName );
/**
* Notify the observer that the URL has finished loading. This method is
* called once when the networking library has finished processing the
* URL transaction initiatied via the nsINetService::Open(...) call.
* <BR><BR>
*
* This method is called regardless of whether the URL loaded
* successfully.<BR><BR>
*
* @param status Status code for the URL load.
* @param msg A text string describing the error.
* @return The return value is currently ignored.
*/
NS_IMETHOD OnStopBinding( nsIPluginStreamInfo* pluginInfo,
nsresult status );
NS_IMETHOD OnNotify( const char* url, nsresult status );
NS_IMETHOD GetStreamType( nsPluginStreamType *result );
///////////////////////////////////////////////////////////////////////////
// snPluginStreamListener specific methods:
nsSanePluginStreamListener( nsSanePluginInstance* inst );
virtual ~nsSanePluginStreamListener( void );
nsSanePluginInstance* mPlugInst;
};
#endif // __NS_SANE_PLUGIN_H__

View File

@@ -1,147 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
* Contributor(s):
*
* Rusty Lynch <rusty.lynch@intel.com>
*/
/*
* Defines scriptable interface to SANE plugin.
*/
#include "nsISupports.idl"
[scriptable, uuid(10982800-365e-11d3-a2bf-0004ac779ef3)]
/**
* This interface can be obtained with the following HTML/JavaScript sequence:
*
* <pre>
* <EMBED type="application/X-sane-plugin"
* id="SaneObject"
* onScanComplete="ScanCompleteCallback()"
* device="hp:/dev/usbscanner"
* line_width="5"
* line_style="dash"
* cap_style="round"
* join_style="round"
* width=320 height=240>
*
* <form name="myForm">
* <!-- Scan Selected Region -->
* <input type="button"
* value="Start Scan"
* onClick="scanner.ScanImage()">
* <!-- many more buttons for controlling scanner/camera... -->
* </form>
* <script>
* var scanner = document.SaneObject.nsISaneControl;
* dump("scanner = "+ scanner + "\n");
* </script>
* </pre>
*
* This fragment will create an embedded plugin, which can then be accessed
* and controlled by the nsISanePluginInstance interface which is instantiated
* in the script.
*/
interface nsISanePluginInstance : nsISupports
{
/////////////////////////////////////////////////////////////////////
// Plugin Status Interface
// Read-Only: Contains completion status of last operation
attribute boolean Success;
// Read-Only: Contains the current state of the scanner (IDLE|BUSY)
attribute string State;
/////////////////////////////////////////////////////////////////////
// Image Preview Interface
// Move zoom box to a given geometry in one step
void ZoomImage(in unsigned short x, in unsigned short y,
in unsigned short width, in unsigned short height);
void ZoomImageWithAttributes(in unsigned short x,
in unsigned short y,
in unsigned short width,
in unsigned short height,
in long req_line_width,
in string req_line_style,
in string req_cap_style,
in string req_join_style);
// Undo all croping and reset zoom box for entire image
void Restore ();
// Zoom in on the image and reset the zoom box to contain
// the entire image.
void Crop(in unsigned short x, in unsigned short y,
in unsigned short width, in unsigned short height);
// Read/Write zoom box geometry
// (Each write will trigger a refresh!)
attribute unsigned short ZoomX;
attribute unsigned short ZoomY;
attribute unsigned short ZoomWidth;
attribute unsigned short ZoomHeight;
// Read/Write zoom box line attributes
// (Each write will trigger a refresh!)
attribute long ZoomLineWidth;
attribute string ZoomLineStyle;
attribute string ZoomCapStyle;
attribute string ZoomJoinStyle;
// Read-Only zoom box change indicators
// (For SANE devices that support changing the scan area,
// this allows for the controling JavaScript to safely adjust
// the scan area in a device specific manner.)
attribute float ZoomBR_XChange; // % bottom right x change on last zoom
attribute float ZoomBR_YChange; // % bottom right y ...
attribute float ZoomTL_XChange; // % top left x ...
attribute float ZoomTL_YChange; // % top left y ...
// Read/Write JPEG compression attributes
attribute long Quality;
attribute string Method;
//////////////////////////////////////////////////////////////////////
// Generic SANE Interface
// READ_ONLY: returns a colon delimeted list of option descriptions
// where each option description is a comma delimited
// list of values
attribute string DeviceOptions;
// Returns or sets the active device.
attribute string ActiveDevice;
// READ_ONLY: returns a comma delimited list of image parameters
attribute string ImageParameters;
// READ_ONLY: returns a comma delimited list of available devices
attribute string AvailableDevices;
// Pull image from device with current option settings.
// As a side effect, the zoom box is set to contain the
// entire image.
void ScanImage();
void SetOption(in string name, in string value);
// Pop up a dialog to save current image to a file
void SaveImage();
};
%{ C++
//10982800-365e-11d3-a2bf-0004ac780ef3
#define NS_SANE_PLUGIN_CONTROL_CID \
{ 0x10982800, 0x365e, 0x11d3, { 0xa2, 0xbf, 0x0, 0x04, 0xac, 0x78, 0x0e, 0xf3 }}
%}

View File

@@ -1,319 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
* Contributor(s):
*
* Rusty Lynch <rusty.lynch@intel.com>
*/
/*
* Implements the SANE plugin factory class.
*/
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
#include "nsSanePlugin_CID.h"
#include "nsSanePlugin.h"
#include "nsSanePluginFactory.h"
#include "plstr.h"
#define PLUGIN_NAME "SANE Plugin"
#define PLUGIN_DESCRIPTION "SANE Plugin is a generic scanner interface"
#define PLUGIN_MIME_DESCRIPTION "application/X-sane-plugin::Scanner/Camera"
#define PLUGIN_MIME_TYPE "application/X-sane-plugin"
static NS_DEFINE_IID( kISupportsIID, NS_ISUPPORTS_IID );
static NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID );
static NS_DEFINE_IID( kIPluginIID, NS_IPLUGIN_IID );
static NS_DEFINE_CID( kComponentManagerCID, NS_COMPONENTMANAGER_CID );
static NS_DEFINE_CID( knsSanePluginControlCID, NS_SANE_PLUGIN_CONTROL_CID );
static NS_DEFINE_CID( knsSanePluginInst, NS_SANE_PLUGIN_CID );
////////////////////////////////////////////////////////////////////////
nsSanePluginFactoryImpl::nsSanePluginFactoryImpl( const nsCID &aClass,
const char* className,
const char* contractID )
: mClassID(aClass), mClassName(className), mContractID(contractID)
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::nsSanePluginFactoryImpl()\n");
#endif
}
nsSanePluginFactoryImpl::~nsSanePluginFactoryImpl()
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::~nsSanePluginFactoryImpl()\n");
#endif
printf("mRefCnt = %i\n", mRefCnt);
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
nsSanePluginFactoryImpl::QueryInterface(const nsIID &aIID,
void **aInstancePtr)
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::QueryInterface()\n");
#endif
if (!aInstancePtr)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = NS_STATIC_CAST(nsISupports*,this);
} else if (aIID.Equals(kIFactoryIID)) {
*aInstancePtr = NS_STATIC_CAST(nsISupports*,
NS_STATIC_CAST(nsIFactory*,this));
} else if (aIID.Equals(kIPluginIID)) {
*aInstancePtr = NS_STATIC_CAST(nsISupports*,
NS_STATIC_CAST(nsIPlugin*,this));
} else {
*aInstancePtr = nsnull;
return NS_ERROR_NO_INTERFACE;
}
NS_ADDREF(NS_REINTERPRET_CAST(nsISupports*,*aInstancePtr));
return NS_OK;
}
// Standard implementation of AddRef and Release
NS_IMPL_ADDREF( nsSanePluginFactoryImpl )
NS_IMPL_RELEASE( nsSanePluginFactoryImpl )
NS_IMETHODIMP
nsSanePluginFactoryImpl::CreateInstance( nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::CreateInstance()\n");
#endif
if ( !aResult )
return NS_ERROR_NULL_POINTER;
if ( aOuter )
return NS_ERROR_NO_AGGREGATION;
nsSanePluginInstance * inst = new nsSanePluginInstance();
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
inst->AddRef();
*aResult = inst;
return NS_OK;
}
nsresult
nsSanePluginFactoryImpl::LockFactory(PRBool aLock)
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::LockFactory()\n");
#endif
// Needs to be implemented
return NS_OK;
}
NS_METHOD
nsSanePluginFactoryImpl::Initialize()
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::Initialize()\n");
#endif
return NS_OK;
}
NS_METHOD
nsSanePluginFactoryImpl::Shutdown( void )
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::Shutdown()\n");
#endif
return NS_OK;
}
NS_METHOD
nsSanePluginFactoryImpl::GetMIMEDescription(const char* *result)
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::GetMIMEDescription()\n");
#endif
// caller is responsible for releasing
*result = PL_strdup( PLUGIN_MIME_DESCRIPTION );
return NS_OK;
}
NS_METHOD
nsSanePluginFactoryImpl::GetValue( nsPluginVariable variable, void *value )
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::GetValue()\n");
#endif
nsresult err = NS_OK;
if ( variable == nsPluginVariable_NameString ) {
*( ( char ** )value ) = strdup( PLUGIN_NAME );
} else if ( variable == nsPluginVariable_DescriptionString ) {
*( ( char ** )value ) = strdup( PLUGIN_DESCRIPTION );
} else {
err = NS_ERROR_FAILURE;
}
return err;
}
NS_IMETHODIMP
nsSanePluginFactoryImpl::CreatePluginInstance( nsISupports *aOuter,
REFNSIID aIID,
const char* aPluginMIMEType,
void **aResult)
{
#ifdef DEBUG
printf("nsSanePluginFactoryImpl::CreatePluginInstance()\n");
#endif
// Need to find out what this is used for. The npsimple
// plugin looks like it just does a CreateInstance and
// ignores the mime type.
return NS_ERROR_NOT_IMPLEMENTED;
}
////////////////////////////////////////////////////////////////////////
/**
* The XPCOM runtime will call this to get a new factory object for the
* CID/contractID it passes in. XPCOM is responsible for caching the resulting
* factory.
*
* return the proper factory to the caller
*/
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory( nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aContractID,
nsIFactory **aFactory)
{
if (! aFactory)
return NS_ERROR_NULL_POINTER;
nsSanePluginFactoryImpl* factory = new nsSanePluginFactoryImpl(aClass,
aClassName,
aContractID);
if ( factory == nsnull )
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*aFactory = factory;
return NS_OK;
}
char *buf;
extern "C" PR_IMPLEMENT( nsresult )
NSRegisterSelf( nsISupports* aServMgr, const char* aPath )
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr( do_QueryInterface( aServMgr, &rv ) );
if ( NS_FAILED( rv ) )
return rv;
nsCOMPtr<nsIComponentManager> compMgr =
do_GetService( kComponentManagerCID, &rv );
if ( NS_FAILED( rv ) )
return rv;
// Register the plugin control portion.
rv = compMgr->RegisterComponent(knsSanePluginControlCID,
"SANE Plugin Control",
"@mozilla.org/plugins/sane-control;1",
aPath, PR_TRUE, PR_TRUE );
// Register the plugin portion.
nsString contractID;
contractID.AssignWithConversion( NS_INLINE_PLUGIN_CONTRACTID_PREFIX );
contractID.AppendWithConversion(PLUGIN_MIME_TYPE);
buf = ( char * )calloc( 2000, sizeof( char ) );
contractID.ToCString( buf, 1999 );
rv = compMgr->RegisterComponent( knsSanePluginInst,
"SANE Plugin Component",
buf,
aPath, PR_TRUE, PR_TRUE);
free( buf );
if ( NS_FAILED( rv ) )
return rv;
return NS_OK;
}
extern "C" PR_IMPLEMENT( nsresult )
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIComponentManager> compMgr =
do_GetService(kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(knsSanePluginControlCID, aPath);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}

View File

@@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Contributor(s):
* Rusty Lynch <rusty.lynch@intel.com>
*/
/*
* Declares the SANE plugin factory class.
*/
#ifndef __NS_SANE_PLUGIN_FACTORY_H__
#define __NS_SANE_PLUGIN_FACTORY_H__
class nsSanePluginFactoryImpl : public nsIPlugin
{
public:
nsSanePluginFactoryImpl(const nsCID &aClass, const char* className,
const char* contractID);
// nsISupports methods
NS_DECL_ISUPPORTS ;
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
NS_IMETHOD Initialize(void);
NS_IMETHOD Shutdown(void);
NS_IMETHOD GetMIMEDescription(const char* *result);
NS_IMETHOD GetValue(nsPluginVariable variable, void *value);
NS_IMETHOD CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID,
const char* aPluginMIMEType,
void **aResult);
protected:
virtual ~nsSanePluginFactoryImpl();
nsCID mClassID;
const char* mClassName;
const char* mContractID;
};
#endif // __NS_SANE_PLUGIN_FACTORY_H__

View File

@@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
* Contributor(s):
*
* Rusty Lynch <rusty.lynch@intel.com>
*/
/*
* Defines the CID for the SANE plugin.
*/
#ifndef __NS_SANE_PLUGIN_CID_H__
#define __NS_SANE_PLUGIN_CID_H__
#define NS_SANE_PLUGIN_CID { 0x302da841, 0x3dbf, 0x11d3, { 0xbc, 0xfb, 0x0, 0xa0, 0xc9, 0xc8, 0xd9, 0x1d } }
#endif // __NS_SANE_PLUGIN_CID_H__

View File

@@ -1,167 +0,0 @@
<HTML>
<HEAD>
<TITLE>CPia Digital Camera Test Application</TITLE>
</HEAD>
<BODY>
<P>
This is a test page for grabing frames from a USB Cpia camera
using the v4l (Video4Linux) SANE module.
</P>
<TABLE>
<TR>
<TD>
<CENTER>
<EMBED type="application/X-sane-plugin"
name="camera"
onScanComplete="ScanCompleteCallback()"
onInitComplete="InitCompleteCallback()"
device="v4l:/dev/video"
width="400" height="400"
line_width="0" line_style="solid">
</CENTER>
</TD>
<TD>
<CENTER>
<!-- Start grabbing frames once a second -->
<INPUT type="button" onclick="start()" value="Start">
<!-- Stop grabbing frames -->
<INPUT type="button" onclick="stop()" value="Stop">
<!-- Save the current image to a file -->
<INPUT type="button" onclick="save()" value="Save"><BR>
<input type="button" onclick="doDump()" value="Dump">
<input type="button"
onclick="document.camera.nsISanePluginInstance.ScanImage()"
value="Single Shot">
</CENTER>
</TD>
</TR>
</TABLE>
<input type="text" id="status" size="20">
<!--
<textarea id="status" rows="20" cols="80"></textarea>
-->
<SCRIPT>
// globals
var gdelay = 500;
var multigrab = false;
var ingrab = false;
function sdump(str)
{
var status = document.getElementById('status');
status.value = str;
dump(str + "\n");
}
function doDump()
{
var aCamera = new Object;
try {
aCamera = document.camera.nsISanePluginInstance;
sdump("ActiveDevice = " + aCamera.ActiveDevice + "\n" +
"State = " + aCamera.State + "\n" +
"Quality = " + aCamera.Quality + "\n" +
"Method = " + aCamera.Method + "\n" +
"DeviceOptions = " + aCamera.DeviceOptions + "\n" +
"ImageParameters = " + aCamera.ImageParameters + "\n" +
"AvailableDevices = " + aCamera.AvailableDevices + "\n");
} catch (ex) {
sdump("Error trying dump data: " + ex + "\n");
}
}
function grabImage()
{
if (multigrab || ingrab)
return;
try {
document.camera.nsISanePluginInstance.ScanImage();
} catch (ex) {
sdump("Error trying to grab image!\n");
}
}
function save()
{
document.camera.nsISanePluginInstance.SaveImage();
}
function InitCompleteCallback()
{
try {
var aCamera = document.camera.nsISanePluginInstance;
aCamera.Quality = 100;
aCamera.ScanImage();
sdump("Initialization complete!\n");
} catch (ex) {
sdump("Error trying to set additional device specific parameters!" + ex);
}
}
function ScanCompleteCallback()
{
sdump("Scan Complete!\n");
ingrab = false;
if (multigrab)
window.setTimeout("document.camera.nsISanePluginInstance.ScanImage()",
gdelay);
}
function stop()
{
multigrab = false;
}
function start()
{
if (multigrab)
return;
multigrab = true;
if (!ingrab) {
try {
sdump("About to scan image!\n");
ingrab = true;
document.camera.nsISanePluginInstance.ScanImage();
} catch (ex) {
sdump("Error trying to grab frame!\n" + ex + "\n");
}
}
}
</SCRIPT>
</BODY>
</HTML>

View File

@@ -1,301 +0,0 @@
<HTML>
<HEAD>
<TITLE>Image Scanner Application</TITLE>
</HEAD>
<BODY>
<P>
This is a simple test page for the HP 6300C USB scanner.
</P>
<TABLE>
<TR>
<TD>
<CENTER>
<EMBED type="application/X-sane-plugin"
name="scanner"
onScanComplete="ScanCompleteCallback()"
onInitComplete="InitCompleteCallback()"
device="hp:/dev/usbscanner"
width="300" height="413"
line_width="4" line_style="solid">
</CENTER>
</TD>
<TD>
<CENTER>
<!-- Pan zoom box -->
<INPUT type="button" onclick="panRegionVert(-10)"
value="Pan Up" ><BR>
<INPUT type="button" onclick="panRegionHor(-10)"
value="Pan Left" >
<INPUT type="button" onclick="panRegionHor(10)"
value="Pan Right" ><BR>
<INPUT type="button" onclick="panRegionVert(10)"
value="Pan Down" ><BR><BR>
<!-- Zoom in/out -->
<INPUT type="button" onclick="adjustRegion(-10)"
value="Zoom In" >
<INPUT type="button" onclick="adjustRegion(10)"
value="Zoom Out" ><BR><BR>
<!-- Scanner controls -->
<INPUT type="button" onclick="ScanHi()"
value="Scan Selected Region">
<INPUT type="button" onclick="GetPreview()"
value="Preview"><BR>
<INPUT type="button" onclick="Save()"
value="Save Current Image"><br><br>
<!-- SANE test -->
<INPUT type="button" onclick="doDump()"
value="Dump">
</CENTER>
</TD>
</TR>
</TABLE>
<TEXTAREA id="status" rows="20" cols="80"></TEXTAREA>
<SCRIPT>
// globals
var inscan = true;
var br_x = 0, br_y = 0, tl_x = 0, tl_y = 0;
var max_br_x = 0, max_br_y = 0;
var last_br_x, last_br_y, last_tl_x, last_tl_y;
function sdump(str)
{
var status = document.getElementById('status');
status.value = str;
dump(str + "\n");
}
function doDump()
{
try {
var aScanner = document.scanner.nsISanePluginInstance;
sdump("ActiveDevice = " + aScanner.ActiveDevice + "\n" +
"State = " + aScanner.State + "\n" +
"Quality = " + aScanner.Quality + "\n" +
"Method = " + aScanner.Method + "\n" +
"DeviceOptions = " + aScanner.DeviceOptions + "\n" +
"ImageParameters = " + aScanner.ImageParameters + "\n" +
"AvailableDevices = " + aScanner.AvailableDevices + "\n");
} catch (ex) {
sdump("Error trying to dump: \n" + ex + "\n");
}
}
function adjustRegion(factor) {
try {
var aScanner = document.scanner.nsISanePluginInstance;
var x, y, height, width;
x = aScanner.ZoomX;
y = aScanner.ZoomY;
width = aScanner.ZoomWidth
+ factor;
height = Math.floor(width * 413/300);
aScanner.Crop(x, y, width, height);
} catch (ex) {
dump("Unable to zoom by " + factor + "\n" + ex + "\n");
}
}
function panRegionHor(factor) {
try {
var x, y, height, width;
var aScanner = document.scanner.nsISanePluginInstance;
if (aScanner.ZoomX + factor < 0)
x = aScanner.ZoomX;
else
x = aScanner.ZoomX + factor;
y = aScanner.ZoomY;
width = aScanner.ZoomWidth;
height = aScanner.ZoomHeight;
aScanner.Crop(x, y, width, height);
} catch (ex) {
dump("Unable to pan to requested location!\n");
}
}
function panRegionVert(factor) {
try {
var x, y, height, width;
var aScanner = document.scanner.nsISanePluginInstance;
if (aScanner.ZoomY + factor < 0)
y = aScanner.ZoomY;
else
y = aScanner.ZoomY + factor;
x = aScanner.ZoomX;
width = aScanner.ZoomWidth;
height = aScanner.ZoomHeight;
aScanner.Crop(x, y, width, height);
} catch (ex) {
dump("Unable to pan to requested location!\n");
}
}
function Save() {
try {
var aScanner = document.scanner.nsISanePluginInstance;
aScanner.SaveImage();
} catch (ex) {
dump("Error trying to save current image!\n");
}
}
function GetPreview()
{
if (inscan)
return;
try {
var aScanner = document.scanner.nsISanePluginInstance;
// Reset scan area for entire bed
tl_x = tl_y = 0;
br_x = max_br_x;
br_y = max_br_y;
aScanner.SetOption("tl-x", tl_x.toString(10));
aScanner.SetOption("tl-y", tl_y.toString(10));
aScanner.SetOption("br-x", br_x.toString(10));
aScanner.SetOption("br-y", br_y.toString(10));
// Set the lowest resolution the HP ScanJet 6300C supports
aScanner.SetOption("mode", "Color");
aScanner.SetOption("resolution", "12");
inscan = true;
aScanner.ScanImage();
// Scanning is a threaded function, so getting here
// only means that a scan operation was successfully started.
} catch (ex) {
dump("Error trying to get preview image!");
}
}
function ScanHi()
{
if (inscan)
return;
try {
var aScanner = document.scanner.nsISanePluginInstance;
// store last scan area coordinates
// so that Restore() knows what scan
// area coordinates to restore to.
last_br_x = br_x;
last_br_y = br_y;
last_tl_x = tl_x;
last_tl_y = tl_y;
// factors used in converting from zoom box
// to scanner coordinates
var xfactor = last_br_x/300;
var yfactor = last_br_y/413;
// zoom box coordinates
var z_br_x = aScanner.ZoomWidth + aScanner.ZoomX;
var z_br_y = aScanner.ZoomHeight + aScanner.ZoomY;
var z_tl_x = aScanner.ZoomX;
var z_tl_y = aScanner.ZoomY;
br_x = Math.floor(z_br_x * xfactor);
br_y = Math.floor(z_br_y * yfactor);
tl_x = Math.floor((z_tl_x * xfactor) + last_tl_x);
tl_y = Math.floor((z_tl_y * yfactor) + last_tl_y);
last_br_x = br_x;
last_br_y = br_y;
last_tl_x = tl_x;
last_tl_y = tl_y;
// set the scan area for zoom box
aScanner.SetOption("tl-x", tl_x);
aScanner.SetOption("tl-y", tl_y);
aScanner.SetOption("br-x", br_x);
aScanner.SetOption("br-y", br_y);
// For speed of testing, high resolution is set to
// just 150dpi
aScanner.SetOption("resolution", "150");
inscan = true;
aScanner.ScanImage();
// Scanning is a threaded operation so getting here
// only means that we have successfully started a scan.
} catch (ex) {
dump("Error trying to scan at 150!\n"+ ex + "\n");
}
}
function ScanCompleteCallback()
{
inscan = false;
dump("Completed Scan!\n");
}
function InitCompleteCallback()
{
// Additional device specific initialization
try {
var aScanner = document.scanner.nsISanePluginInstance;
// Reset scan area for entire bed
tl_x = tl_y = 0;
br_x = max_br_x;
br_y = max_br_y;
aScanner.SetOption("tl-x", tl_x.toString(10));
aScanner.SetOption("tl-y", tl_y.toString(10));
aScanner.SetOption("br-x", br_x.toString(10));
aScanner.SetOption("br-y", br_y.toString(10));
// this particular scan seems to scan in a
// a little dark by default
aScanner.SetOption("brightness", "30");
aScanner.SetOption("contrast", "10");
aScanner.Quality = 80;
aScanner.Method = "FAST";
aScanner.SetOption("mode", "Color");
// Set the maximum bottom x and bottom y
// for the HP ScanJet 6300C
last_br_x = br_x = max_br_x = 14141852;
last_br_y = br_y = max_br_y = 19456836;
last_tl_x = tl_x;
last_tl_y = tl_y;
inscan = false;
} catch (ex) {
dump("Error trying to set device specific initialization!\n");
}
}
</SCRIPT>
</BODY>
</HTML>

File diff suppressed because it is too large Load Diff

View File

@@ -1,387 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 38;
objects = {
089C1669FE841209C02AAC07 = {
buildStyles = (
4F9091AC011F3BD104CA0E50,
4F9091AD011F3BD104CA0E50,
F50EB520038ABFA401A9666E,
);
hasScannedForEncodings = 1;
isa = PBXProject;
mainGroup = 089C166AFE841209C02AAC07;
projectDirPath = "";
targets = (
089C1673FE841209C02AAC07,
F59D147102AC328B01000104,
);
};
089C166AFE841209C02AAC07 = {
children = (
08FB77ADFE841716C02AAC07,
089C167CFE841241C02AAC07,
089C1671FE841209C02AAC07,
19C28FB4FE9D528D11CA2CBB,
);
isa = PBXGroup;
name = MRJPlugin;
refType = 4;
};
089C1671FE841209C02AAC07 = {
children = (
F5A7D3AB036E359F01A96660,
08EA7FFBFE8413EDC02AAC07,
F51A400C0299CD65012FC976,
);
isa = PBXGroup;
name = "External Frameworks and Libraries";
refType = 4;
};
089C1673FE841209C02AAC07 = {
buildPhases = (
089C1674FE841209C02AAC07,
089C1675FE841209C02AAC07,
089C1676FE841209C02AAC07,
089C1677FE841209C02AAC07,
089C1679FE841209C02AAC07,
F5BFB5E8029AD01B01000102,
);
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/CoreFoundation.framework\"";
HEADER_SEARCH_PATHS = "../../../../../dist/sdk/xpcom/include ../../../../../dist/include/caps ../../../../../dist/include/java ../../../../../dist/include/js ../../../../../dist/include/nspr ../../../../../dist/include/nspr/obsolete ../../../../../dist/include/oji ../../../../../dist/include/plugin ../../../../../dist/include/xpcom ../../../../../dist/include/xpconnect ../../../../../dist/include /Developer/Headers/FlatCarbon";
LIBRARY_SEARCH_PATHS = /usr/lib;
OTHER_CFLAGS = "-DXP_MACOSX=1 -DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
PREFIX_HEADER = DefaultPluginPrefix.h;
PRODUCT_NAME = "Default Plugin";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
WRAPPER_EXTENSION = plugin;
};
dependencies = (
F59D147202AC350E01000104,
);
isa = PBXBundleTarget;
name = "Default Plugin";
productName = MRJPlugin;
productReference = 4F9091AB011F3BD104CA0E50;
productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Default Plugin</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.netscape.DefaultPlugin</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>NSPL</string>
<key>CFBundleSignature</key>
<string>MOSS</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
</plist>
";
};
089C1674FE841209C02AAC07 = {
buildActionMask = 2147483647;
files = (
0F64AF2D0433C8A200A96652,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
};
089C1675FE841209C02AAC07 = {
buildActionMask = 2147483647;
files = (
089C1680FE841241C02AAC07,
);
isa = PBXResourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
};
089C1676FE841209C02AAC07 = {
buildActionMask = 2147483647;
files = (
F5E0C350036A130901A96660,
F5E0C352036A130E01A96660,
);
isa = PBXSourcesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
};
089C1677FE841209C02AAC07 = {
buildActionMask = 2147483647;
files = (
08EA7FFCFE8413EDC02AAC07,
F51A400D0299CD65012FC976,
F5A7D695036E35A001A96660,
);
isa = PBXFrameworksBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
};
089C1679FE841209C02AAC07 = {
buildActionMask = 2147483647;
files = (
F5E0C34E036A12DF01A96660,
);
isa = PBXRezBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
};
089C167CFE841241C02AAC07 = {
children = (
089C167DFE841241C02AAC07,
F5E0C34D036A12DF01A96660,
);
isa = PBXGroup;
name = Resources;
refType = 4;
};
089C167DFE841241C02AAC07 = {
children = (
089C167EFE841241C02AAC07,
);
isa = PBXVariantGroup;
name = InfoPlist.strings;
path = "";
refType = 2;
};
089C167EFE841241C02AAC07 = {
fileEncoding = 10;
isa = PBXFileReference;
name = English;
path = English.lproj/InfoPlist.strings;
refType = 4;
};
089C1680FE841241C02AAC07 = {
fileRef = 089C167DFE841241C02AAC07;
isa = PBXBuildFile;
settings = {
};
};
08EA7FFBFE8413EDC02AAC07 = {
isa = PBXFrameworkReference;
name = Carbon.framework;
path = /System/Library/Frameworks/Carbon.framework;
refType = 0;
};
08EA7FFCFE8413EDC02AAC07 = {
fileRef = 08EA7FFBFE8413EDC02AAC07;
isa = PBXBuildFile;
settings = {
};
};
08FB77ADFE841716C02AAC07 = {
children = (
0F64AF2C0433C8A200A96652,
F5E0C34F036A130901A96660,
F5E0C351036A130E01A96660,
);
isa = PBXGroup;
name = Source;
refType = 4;
};
//080
//081
//082
//083
//084
//0F0
//0F1
//0F2
//0F3
//0F4
0F64AF2C0433C8A200A96652 = {
fileEncoding = 4;
isa = PBXFileReference;
path = DefaultPluginPrefix.h;
refType = 4;
};
0F64AF2D0433C8A200A96652 = {
fileRef = 0F64AF2C0433C8A200A96652;
isa = PBXBuildFile;
settings = {
};
};
//0F0
//0F1
//0F2
//0F3
//0F4
//190
//191
//192
//193
//194
19C28FB4FE9D528D11CA2CBB = {
children = (
4F9091AB011F3BD104CA0E50,
);
isa = PBXGroup;
name = Products;
refType = 4;
};
//190
//191
//192
//193
//194
//4F0
//4F1
//4F2
//4F3
//4F4
4F9091AB011F3BD104CA0E50 = {
isa = PBXBundleReference;
path = "Default Plugin.plugin";
refType = 3;
};
4F9091AC011F3BD104CA0E50 = {
buildRules = (
);
buildSettings = {
COPY_PHASE_STRIP = NO;
OPTIMIZATION_CFLAGS = "-O0";
};
isa = PBXBuildStyle;
name = Development;
};
4F9091AD011F3BD104CA0E50 = {
buildRules = (
);
buildSettings = {
COPY_PHASE_STRIP = YES;
};
isa = PBXBuildStyle;
name = Deployment;
};
//4F0
//4F1
//4F2
//4F3
//4F4
//F50
//F51
//F52
//F53
//F54
F50EB520038ABFA401A9666E = {
buildRules = (
);
buildSettings = {
COPY_PHASE_STRIP = NO;
DEBUGGING_SYMBOLS = YES;
};
isa = PBXBuildStyle;
name = DeploymentSymbols;
};
F51A400C0299CD65012FC976 = {
isa = PBXFileReference;
name = "libstdc++.a";
path = "/usr/lib/libstdc++.a";
refType = 0;
};
F51A400D0299CD65012FC976 = {
fileRef = F51A400C0299CD65012FC976;
isa = PBXBuildFile;
settings = {
};
};
F59D147102AC328B01000104 = {
buildArgumentsString = "$ACTION resources";
buildPhases = (
);
buildSettings = {
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
PRODUCT_NAME = Resources;
SECTORDER_FLAGS = "";
WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas";
};
buildToolPath = /usr/bin/gnumake;
buildWorkingDirectory = .;
dependencies = (
);
isa = PBXLegacyTarget;
name = Resources;
passBuildSettingsInEnvironment = 1;
productName = Resources;
settingsToExpand = 6;
settingsToPassInEnvironment = 287;
settingsToPassOnCommandLine = 280;
};
F59D147202AC350E01000104 = {
isa = PBXTargetDependency;
target = F59D147102AC328B01000104;
};
F5A7D3AB036E359F01A96660 = {
isa = PBXFrameworkReference;
name = CoreFoundation.framework;
path = /System/Library/Frameworks/CoreFoundation.framework;
refType = 0;
};
F5A7D695036E35A001A96660 = {
fileRef = F5A7D3AB036E359F01A96660;
isa = PBXBuildFile;
settings = {
};
};
F5BFB5E8029AD01B01000102 = {
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 6;
files = (
);
isa = PBXCopyFilesBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
};
F5E0C34D036A12DF01A96660 = {
isa = PBXFileReference;
path = _NullPlugin.rsrc;
refType = 2;
};
F5E0C34E036A12DF01A96660 = {
fileRef = F5E0C34D036A12DF01A96660;
isa = PBXBuildFile;
settings = {
};
};
F5E0C34F036A130901A96660 = {
fileEncoding = 30;
isa = PBXFileReference;
path = NullPlugin.cpp;
refType = 2;
};
F5E0C350036A130901A96660 = {
fileRef = F5E0C34F036A130901A96660;
isa = PBXBuildFile;
settings = {
};
};
F5E0C351036A130E01A96660 = {
fileEncoding = 30;
isa = PBXFileReference;
path = npmac.cpp;
refType = 2;
};
F5E0C352036A130E01A96660 = {
fileRef = F5E0C351036A130E01A96660;
isa = PBXBuildFile;
settings = {
};
};
};
rootObject = 089C1669FE841209C02AAC07;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
#include "mozilla-config.h"

View File

@@ -1,96 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications.
# Portions created by the Initial Developer are Copyright (C) 2001
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Brian Ryner <bryner@brianryner.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plugin
ifdef MOZ_DEBUG
BUILDSTYLE = Development
else
ifdef CHIMERA_OPT_SYMBOLS
BUILDSTYLE = DeploymentSymbols
else
BUILDSTYLE = Deployment
endif
endif
TARGET = "Default Plugin"
PACKAGE_FILE = npnul.pkg
include $(topsrcdir)/config/rules.mk
# decodes resource files from AppleSingle to Resource Manager format.
ASDECODE = $(DIST)/bin/asdecode
RESOURCE_FILES = _NullPlugin.rsrc
# for objdir builds, copy the project, and symlink the sources
ABS_topsrcdir := $(shell cd $(topsrcdir); pwd)
ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
export::
rsync -a --exclude .DS_Store --exclude "CVS/" $(srcdir)/DefaultPlugin.pbproj .
ln -fs $(srcdir)/English.lproj
ln -fs $(srcdir)/DefaultPluginPrefix.h
ln -fs $(srcdir)/NullPlugin.cpp
ln -fs $(srcdir)/npmac.cpp
endif
all:: build-plugin
libs install:: install-plugin
install-plugin: build-plugin
$(INSTALL) "build/Default Plugin.plugin" $(DIST)/bin/plugins
$(INSTALL) "build/DefaultPlugin.build/Default Plugin.build/PkgInfo" "$(DIST)/bin/plugins/Default Plugin.plugin/Contents"
resources: $(RESOURCE_FILES)
build-plugin: resources
$(PBBUILD) -target $(TARGET) -buildstyle $(BUILDSTYLE)
_%.rsrc: %.rsrc
$(ASDECODE) $< $@
clean clobber::
rm -f $(RESOURCE_FILES)
rm -rf build

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
#define XP_MAC 1

View File

@@ -1,2 +0,0 @@
#include "PluginConfig.h"

View File

@@ -1,5 +0,0 @@
#include "PluginConfig.h"
#define TARGET_CARBON 1

View File

@@ -1,769 +0,0 @@
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// npmac.cpp
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <string.h>
#include <Processes.h>
#include <Gestalt.h>
#include <CodeFragments.h>
#include <Timer.h>
#include <Resources.h>
#include <ToolUtils.h>
#define XP_MAC 1
//
// A4Stuff.h contains the definition of EnterCodeResource and
// EnterCodeResource, used for setting up the code resourceÕs
// globals for 68K (analagous to the function SetCurrentA5
// defined by the toolbox).
//
// A4Stuff does not exist as of CW 7. Define them to nothing.
//
#if (defined(__MWERKS__) && (__MWERKS__ >= 0x2400)) || defined(__GNUC__)
#define EnterCodeResource()
#define ExitCodeResource()
#else
#include <A4Stuff.h>
#endif
#include "npapi.h"
//
// The Mixed Mode procInfos defined in npupp.h assume Think C-
// style calling conventions. These conventions are used by
// Metrowerks with the exception of pointer return types, which
// in Metrowerks 68K are returned in A0, instead of the standard
// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
// Mixed Mode will return the values to a 68K plugin in D0, but
// a 68K plugin compiled by Metrowerks will expect the result in
// A0. The following pragma forces Metrowerks to use D0 instead.
//
#ifdef __MWERKS__
#ifndef powerc
#pragma pointers_in_D0
#endif
#endif
#include "npupp.h"
#ifdef __MWERKS__
#ifndef powerc
#pragma pointers_in_A0
#endif
#endif
// The following fix for static initializers (which fixes a previous
// incompatibility with some parts of PowerPlant, was submitted by
// Jan Ulbrich.
#ifdef __MWERKS__
#ifdef __cplusplus
extern "C" {
#endif
#ifndef powerc
extern void __InitCode__(void);
#else
extern void __sinit(void);
#define __InitCode__ __sinit
#endif
extern void __destroy_global_chain(void);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __MWERKS__
//
// Define PLUGIN_TRACE to 1 to have the wrapper functions emit
// DebugStr messages whenever they are called.
//
//#define PLUGIN_TRACE 1
#if PLUGIN_TRACE
#define PLUGINDEBUGSTR(msg) ::DebugStr(msg)
#else
#define PLUGINDEBUGSTR
#endif
#ifdef XP_MACOSX
// glue for mapping outgoing Macho function pointers to TVectors
struct TFPtoTVGlue{
void* glue[2];
};
struct {
TFPtoTVGlue newp;
TFPtoTVGlue destroy;
TFPtoTVGlue setwindow;
TFPtoTVGlue newstream;
TFPtoTVGlue destroystream;
TFPtoTVGlue asfile;
TFPtoTVGlue writeready;
TFPtoTVGlue write;
TFPtoTVGlue print;
TFPtoTVGlue event;
TFPtoTVGlue urlnotify;
TFPtoTVGlue getvalue;
TFPtoTVGlue setvalue;
TFPtoTVGlue shutdown;
} gPluginFuncsGlueTable;
static inline void* SetupFPtoTVGlue(TFPtoTVGlue* functionGlue, void* fp)
{
functionGlue->glue[0] = fp;
functionGlue->glue[1] = 0;
return functionGlue;
}
#define PLUGIN_TO_HOST_GLUE(name, fp) (SetupFPtoTVGlue(&gPluginFuncsGlueTable.name, (void*)fp))
// glue for mapping netscape TVectors to Macho function pointers
struct TTVtoFPGlue {
uint32 glue[6];
};
struct {
TTVtoFPGlue geturl;
TTVtoFPGlue posturl;
TTVtoFPGlue requestread;
TTVtoFPGlue newstream;
TTVtoFPGlue write;
TTVtoFPGlue destroystream;
TTVtoFPGlue status;
TTVtoFPGlue uagent;
TTVtoFPGlue memalloc;
TTVtoFPGlue memfree;
TTVtoFPGlue memflush;
TTVtoFPGlue reloadplugins;
TTVtoFPGlue getJavaEnv;
TTVtoFPGlue getJavaPeer;
TTVtoFPGlue geturlnotify;
TTVtoFPGlue posturlnotify;
TTVtoFPGlue getvalue;
TTVtoFPGlue setvalue;
TTVtoFPGlue invalidaterect;
TTVtoFPGlue invalidateregion;
TTVtoFPGlue forceredraw;
} gNetscapeFuncsGlueTable;
static void* SetupTVtoFPGlue(TTVtoFPGlue* functionGlue, void* tvp)
{
static const TTVtoFPGlue glueTemplate = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 };
memcpy(functionGlue, &glueTemplate, sizeof(TTVtoFPGlue));
functionGlue->glue[0] |= ((UInt32)tvp >> 16);
functionGlue->glue[1] |= ((UInt32)tvp & 0xFFFF);
::MakeDataExecutable(functionGlue, sizeof(TTVtoFPGlue));
return functionGlue;
}
#define HOST_TO_PLUGIN_GLUE(name, fp) (SetupTVtoFPGlue(&gNetscapeFuncsGlueTable.name, (void*)fp))
#else
#define PLUGIN_TO_HOST_GLUE(name, fp) (fp)
#define HOST_TO_PLUGIN_GLUE(name, fp) (fp)
#endif /* XP_MACOSX */
#pragma mark -
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Globals
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#if !TARGET_API_MAC_CARBON
QDGlobals* gQDPtr; // Pointer to NetscapeÕs QuickDraw globals
#endif
short gResFile; // Refnum of the pluginÕs resource file
NPNetscapeFuncs gNetscapeFuncs; // Function table for procs in Netscape called by plugin
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Wrapper functions for all calls from the plugin to Netscape.
// These functions let the plugin developer just call the APIs
// as documented and defined in npapi.h, without needing to know
// about the function table and call macros in npupp.h.
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = gNetscapeFuncs.version >> 8; // Major version is in high byte
*netscape_minor = gNetscapeFuncs.version & 0xFF; // Minor version is in low byte
}
NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_GetURL(NPP instance, const char* url, const char* window)
{
return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url,
window, len, buf, file, notifyData);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance, url, window, len, buf, file);
}
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return CallNPN_RequestReadProc(gNetscapeFuncs.requestread, stream, rangeList);
}
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStream** stream)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{
err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{
err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{
err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);
}
else
{
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
void NPN_Status(NPP instance, const char* message)
{
CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
}
const char* NPN_UserAgent(NPP instance)
{
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
}
void* NPN_MemAlloc(uint32 size)
{
return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
}
void NPN_MemFree(void* ptr)
{
CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
}
uint32 NPN_MemFlush(uint32 size)
{
return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
}
#ifdef OJI
JRIEnv* NPN_GetJavaEnv(void)
{
return CallNPN_GetJavaEnvProc( gNetscapeFuncs.getJavaEnv );
}
jobject NPN_GetJavaPeer(NPP instance)
{
return CallNPN_GetJavaPeerProc( gNetscapeFuncs.getJavaPeer, instance );
}
#endif
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
return CallNPN_GetValueProc( gNetscapeFuncs.getvalue, instance, variable, value);
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
return CallNPN_SetValueProc( gNetscapeFuncs.setvalue, instance, variable, value);
}
void NPN_InvalidateRect(NPP instance, NPRect *rect)
{
CallNPN_InvalidateRectProc( gNetscapeFuncs.invalidaterect, instance, rect);
}
void NPN_InvalidateRegion(NPP instance, NPRegion region)
{
CallNPN_InvalidateRegionProc( gNetscapeFuncs.invalidateregion, instance, region);
}
void NPN_ForceRedraw(NPP instance)
{
CallNPN_ForceRedrawProc( gNetscapeFuncs.forceredraw, instance);
}
#pragma mark -
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Wrapper functions for all calls from Netscape to the plugin.
// These functions let the plugin developer just create the APIs
// as documented and defined in npapi.h, without needing to
// install those functions in the function table or worry about
// setting up globals for 68K plugins.
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
NPError Private_Initialize(void);
void Private_Shutdown(void);
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
NPError Private_Destroy(NPP instance, NPSavedData** save);
NPError Private_SetWindow(NPP instance, NPWindow* window);
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
int32 Private_WriteReady(NPP instance, NPStream* stream);
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
void Private_Print(NPP instance, NPPrint* platformPrint);
int16 Private_HandleEvent(NPP instance, void* event);
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
jobject Private_GetJavaClass(void);
NPError Private_Initialize(void)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pInitialize;g;");
err = NPP_Initialize();
ExitCodeResource();
return err;
}
void Private_Shutdown(void)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pShutdown;g;");
NPP_Shutdown();
#ifdef __MWERKS__
__destroy_global_chain();
#endif
ExitCodeResource();
}
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
EnterCodeResource();
NPError ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
PLUGINDEBUGSTR("\pNew;g;");
ExitCodeResource();
return ret;
}
NPError Private_Destroy(NPP instance, NPSavedData** save)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pDestroy;g;");
err = NPP_Destroy(instance, save);
ExitCodeResource();
return err;
}
NPError Private_SetWindow(NPP instance, NPWindow* window)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pSetWindow;g;");
err = NPP_SetWindow(instance, window);
ExitCodeResource();
return err;
}
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pNewStream;g;");
err = NPP_NewStream(instance, type, stream, seekable, stype);
ExitCodeResource();
return err;
}
int32 Private_WriteReady(NPP instance, NPStream* stream)
{
int32 result;
EnterCodeResource();
PLUGINDEBUGSTR("\pWriteReady;g;");
result = NPP_WriteReady(instance, stream);
ExitCodeResource();
return result;
}
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
{
int32 result;
EnterCodeResource();
PLUGINDEBUGSTR("\pWrite;g;");
result = NPP_Write(instance, stream, offset, len, buffer);
ExitCodeResource();
return result;
}
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pStreamAsFile;g;");
NPP_StreamAsFile(instance, stream, fname);
ExitCodeResource();
}
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
NPError err;
EnterCodeResource();
PLUGINDEBUGSTR("\pDestroyStream;g;");
err = NPP_DestroyStream(instance, stream, reason);
ExitCodeResource();
return err;
}
int16 Private_HandleEvent(NPP instance, void* event)
{
int16 result;
EnterCodeResource();
PLUGINDEBUGSTR("\pHandleEvent;g;");
result = NPP_HandleEvent(instance, event);
ExitCodeResource();
return result;
}
void Private_Print(NPP instance, NPPrint* platformPrint)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pPrint;g;");
NPP_Print(instance, platformPrint);
ExitCodeResource();
}
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pURLNotify;g;");
NPP_URLNotify(instance, url, reason, notifyData);
ExitCodeResource();
}
#ifdef OJI
jobject Private_GetJavaClass(void)
{
EnterCodeResource();
PLUGINDEBUGSTR("\pGetJavaClass;g;");
jobject clazz = NPP_GetJavaClass();
ExitCodeResource();
if (clazz)
{
JRIEnv* env = NPN_GetJavaEnv();
return (jobject)JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
#endif
void SetUpQD(void);
void SetUpQD(void)
{
#if !TARGET_API_MAC_CARBON
ProcessSerialNumber PSN;
FSSpec myFSSpec;
Str63 name;
ProcessInfoRec infoRec;
OSErr result = noErr;
CFragConnectionID connID;
Str255 errName;
#endif
//
// Memorize the pluginÕs resource file
// refnum for later use.
//
gResFile = CurResFile();
#if !TARGET_API_MAC_CARBON
//
// Ask the system if CFM is available.
//
long response;
OSErr err = Gestalt(gestaltCFMAttr, &response);
Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
ProcessInfoRec infoRec;
if (hasCFM)
{
//
// GetProcessInformation takes a process serial number and
// will give us back the name and FSSpec of the application.
// See the Process Manager in IM.
//
Str63 name;
FSSpec myFSSpec;
infoRec.processInfoLength = sizeof(ProcessInfoRec);
infoRec.processName = name;
infoRec.processAppSpec = &myFSSpec;
ProcessSerialNumber PSN;
PSN.highLongOfPSN = 0;
PSN.lowLongOfPSN = kCurrentProcess;
result = GetProcessInformation(&PSN, &infoRec);
if (result != noErr)
PLUGINDEBUGSTR("\pFailed in GetProcessInformation");
}
else
//
// If no CFM installed, assume it must be a 68K app.
//
result = -1;
CFragConnectionID connID;
if (result == noErr)
{
//
// Now that we know the app name and FSSpec, we can call GetDiskFragment
// to get a connID to use in a subsequent call to FindSymbol (it will also
// return the address of ÒmainÓ in app, which we ignore). If GetDiskFragment
// returns an error, we assume the app must be 68K.
//
Ptr mainAddr;
Str255 errName;
result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
kLoadCFrag, &connID, (Ptr*)&mainAddr, errName);
}
if (result == noErr)
{
//
// The app is a PPC code fragment, so call FindSymbol
// to get the exported ÒqdÓ symbol so we can access its
// QuickDraw globals.
//
CFragSymbolClass symClass;
result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
if (result != noErr) { // this fails if we are in NS 6
gQDPtr = &qd; // so we default to the standard QD globals
}
}
else
{
//
// The app is 68K, so use its A5 to compute the address
// of its QuickDraw globals.
//
gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
}
#endif
}
#ifdef __GNUC__
// gcc requires that main have an 'int' return type
int main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
#else
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
#endif
#if !TARGET_API_MAC_CARBON
#pragma export on
#if GENERATINGCFM
RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
#endif
#pragma export off
#endif /* !TARGET_API_MAC_CARBON */
#ifdef __GNUC__
DEFINE_API_C(int) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp)
#else
DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp)
#endif
{
EnterCodeResource();
PLUGINDEBUGSTR("\pmain");
#ifdef __MWERKS__
__InitCode__();
#endif
NPError err = NPERR_NO_ERROR;
//
// Ensure that everything Netscape passed us is valid!
//
if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL))
err = NPERR_INVALID_FUNCTABLE_ERROR;
//
// Check the ÒmajorÓ version passed in NetscapeÕs function table.
// We wonÕt load if the major version is newer than what we expect.
// Also check that the function tables passed in are big enough for
// all the functions we need (they could be bigger, if Netscape added
// new APIs, but thatÕs OK with us -- weÕll just ignore them).
//
if (err == NPERR_NO_ERROR)
{
if ((nsTable->version >> 8) > NP_VERSION_MAJOR) // Major version is in high byte
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
if (err == NPERR_NO_ERROR)
{
//
// Copy all the fields of NetscapeÕs function table into our
// copy so we can call back into Netscape later. Note that
// we need to copy the fields one by one, rather than assigning
// the whole structure, because the Netscape function table
// could actually be bigger than what we expect.
//
int navMinorVers = nsTable->version & 0xFF;
gNetscapeFuncs.version = nsTable->version;
gNetscapeFuncs.size = nsTable->size;
gNetscapeFuncs.posturl = (NPN_PostURLUPP)HOST_TO_PLUGIN_GLUE(posturl, nsTable->posturl);
gNetscapeFuncs.geturl = (NPN_GetURLUPP)HOST_TO_PLUGIN_GLUE(geturl, nsTable->geturl);
gNetscapeFuncs.requestread = (NPN_RequestReadUPP)HOST_TO_PLUGIN_GLUE(requestread, nsTable->requestread);
gNetscapeFuncs.newstream = (NPN_NewStreamUPP)HOST_TO_PLUGIN_GLUE(newstream, nsTable->newstream);
gNetscapeFuncs.write = (NPN_WriteUPP)HOST_TO_PLUGIN_GLUE(write, nsTable->write);
gNetscapeFuncs.destroystream = (NPN_DestroyStreamUPP)HOST_TO_PLUGIN_GLUE(destroystream, nsTable->destroystream);
gNetscapeFuncs.status = (NPN_StatusUPP)HOST_TO_PLUGIN_GLUE(status, nsTable->status);
gNetscapeFuncs.uagent = (NPN_UserAgentUPP)HOST_TO_PLUGIN_GLUE(uagent, nsTable->uagent);
gNetscapeFuncs.memalloc = (NPN_MemAllocUPP)HOST_TO_PLUGIN_GLUE(memalloc, nsTable->memalloc);
gNetscapeFuncs.memfree = (NPN_MemFreeUPP)HOST_TO_PLUGIN_GLUE(memfree, nsTable->memfree);
gNetscapeFuncs.memflush = (NPN_MemFlushUPP)HOST_TO_PLUGIN_GLUE(memflush, nsTable->memflush);
gNetscapeFuncs.reloadplugins = (NPN_ReloadPluginsUPP)HOST_TO_PLUGIN_GLUE(reloadplugins, nsTable->reloadplugins);
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
{
gNetscapeFuncs.getJavaEnv = (NPN_GetJavaEnvUPP)HOST_TO_PLUGIN_GLUE(getJavaEnv, nsTable->getJavaEnv);
gNetscapeFuncs.getJavaPeer = (NPN_GetJavaPeerUPP)HOST_TO_PLUGIN_GLUE(getJavaPeer, nsTable->getJavaPeer);
}
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
gNetscapeFuncs.geturlnotify = (NPN_GetURLNotifyUPP)HOST_TO_PLUGIN_GLUE(geturlnotify, nsTable->geturlnotify);
gNetscapeFuncs.posturlnotify = (NPN_PostURLNotifyUPP)HOST_TO_PLUGIN_GLUE(posturlnotify, nsTable->posturlnotify);
}
gNetscapeFuncs.getvalue = (NPN_GetValueUPP)HOST_TO_PLUGIN_GLUE(getvalue, nsTable->getvalue);
gNetscapeFuncs.setvalue = (NPN_SetValueUPP)HOST_TO_PLUGIN_GLUE(setvalue, nsTable->setvalue);
gNetscapeFuncs.invalidaterect = (NPN_InvalidateRectUPP)HOST_TO_PLUGIN_GLUE(invalidaterect, nsTable->invalidaterect);
gNetscapeFuncs.invalidateregion = (NPN_InvalidateRegionUPP)HOST_TO_PLUGIN_GLUE(invalidateregion, nsTable->invalidateregion);
gNetscapeFuncs.forceredraw = (NPN_ForceRedrawUPP)HOST_TO_PLUGIN_GLUE(forceredraw, nsTable->forceredraw);
//
// Set up the plugin function table that Netscape will use to
// call us. Netscape needs to know about our version and size
// and have a UniversalProcPointer for every function we implement.
//
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
pluginFuncs->size = sizeof(NPPluginFuncs);
pluginFuncs->newp = NewNPP_NewProc(PLUGIN_TO_HOST_GLUE(newp, Private_New));
pluginFuncs->destroy = NewNPP_DestroyProc(PLUGIN_TO_HOST_GLUE(destroy, Private_Destroy));
pluginFuncs->setwindow = NewNPP_SetWindowProc(PLUGIN_TO_HOST_GLUE(setwindow, Private_SetWindow));
pluginFuncs->newstream = NewNPP_NewStreamProc(PLUGIN_TO_HOST_GLUE(newstream, Private_NewStream));
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(PLUGIN_TO_HOST_GLUE(destroystream, Private_DestroyStream));
pluginFuncs->asfile = NewNPP_StreamAsFileProc(PLUGIN_TO_HOST_GLUE(asfile, Private_StreamAsFile));
pluginFuncs->writeready = NewNPP_WriteReadyProc(PLUGIN_TO_HOST_GLUE(writeready, Private_WriteReady));
pluginFuncs->write = NewNPP_WriteProc(PLUGIN_TO_HOST_GLUE(write, Private_Write));
pluginFuncs->print = NewNPP_PrintProc(PLUGIN_TO_HOST_GLUE(print, Private_Print));
pluginFuncs->event = NewNPP_HandleEventProc(PLUGIN_TO_HOST_GLUE(event, Private_HandleEvent));
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(PLUGIN_TO_HOST_GLUE(urlnotify, Private_URLNotify));
}
#ifdef OJI
if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
{
pluginFuncs->javaClass = (JRIGlobalRef) Private_GetJavaClass();
}
#else
pluginFuncs->javaClass = NULL;
#endif
*unloadUpp = NewNPP_ShutdownProc(PLUGIN_TO_HOST_GLUE(shutdown, Private_Shutdown));
SetUpQD();
err = Private_Initialize();
}
ExitCodeResource();
return err;
}

View File

@@ -1,4 +0,0 @@
# the null plugin goes in gecko-support because we search for plugins
# in the application, not the GRE
[gecko-support]
dist/bin/plugins/Default\ Plugin.plugin

View File

@@ -1,71 +0,0 @@
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
# IBM Corp.
#
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plugin
LIBRARY_NAME = npnulos2
RESFILE = npnulos2.res
PACKAGE_FILE = npnul.pkg
REQUIRES = java \
plugin \
$(NULL)
CPPSRCS = \
maindll.cpp\
dbg.cpp\
npos2.cpp\
dialogs.cpp\
npshell.cpp\
plugin.cpp\
utils.cpp\
$(NULL)
# plugins should always be shared, even in the "static" build
FORCE_SHARED_LIB = 1
NO_DIST_INSTALL = 1
NO_INSTALL = 1
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) \
$(NULL)
install-plugin: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
endif
libs:: install-plugin
install:: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/plugins
endif

View File

@@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <os2.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
extern char szAppName[];
#ifdef _DEBUG
void dbgOut(PSZ format, ...) {
static char buf[1024];
strcpy(buf, szAppName);
strcat(buf, ": ");
va_list va;
va_start(va, format);
vsprintf(&buf[strlen(buf)], format, va);
va_end(va);
strcat(buf, "\n");
printf("%s\n", buf);
}
#endif

View File

@@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __DBG_HPP_
#define __DBG_HPP_
#ifdef _DEBUG
void dbgOut(PSZ format, ...);
#define dbgOut1(x) dbgOut(x)
#define dbgOut2(x,y) dbgOut(x, y)
#define dbgOut3(x,y,z) dbgOut(x, y, z)
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
#else
#define dbgOut1(x) ((void)0)
#define dbgOut2(x,y) ((void)0)
#define dbgOut3(x,y,z) ((void)0)
#define dbgOut4(x,y,z,t) ((void)0)
#define dbgOut5(x,y,z,t,u) ((void)0)
#define dbgOut6(x,y,z,t,u,v) ((void)0)
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
#endif
#endif

View File

@@ -1,197 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#define INCL_WIN
#include <os2.h>
#include <string.h>
#include "npnulos2.h"
#include "plugin.h"
#include "utils.h"
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
{
CPlugin * pPlugin = (CPlugin *)WinQueryWindowPtr(hWnd, QWL_USER);
switch (id)
{
case IDC_GET_PLUGIN:
WinDismissDlg(hWnd, IDC_GET_PLUGIN);
if(pPlugin !=NULL)
pPlugin->m_hWndDialog = NULL;
break;
case DID_CANCEL:
WinDismissDlg(hWnd, DID_CANCEL);
if(pPlugin !=NULL)
pPlugin->m_hWndDialog = NULL;
break;
default:
break;
}
}
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, MPARAM mParam)
{
CPlugin * pPlugin = (CPlugin *)mParam;
assert(pPlugin != NULL);
if(pPlugin == NULL)
return TRUE;
WinSetWindowPtr(hWnd, QWL_USER, (PVOID)pPlugin);
pPlugin->m_hWndDialog = hWnd;
char szString[512];
WinLoadString((HAB)0, hInst, IDS_TITLE, sizeof(szString), szString);
WinSetWindowText(hWnd, szString);
WinLoadString((HAB)0, hInst, IDS_INFO, sizeof(szString), szString);
WinSetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
WinSetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, pPlugin->m_pNPMIMEType);
WinLoadString((HAB)0, hInst, IDS_LOCATION, sizeof(szString), szString);
WinSetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
char contentTypeIsJava = 0;
if (NULL != pPlugin->m_pNPMIMEType) {
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
pPlugin->m_pNPMIMEType)) ? 1 : 0;
}
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
WinLoadString((HAB)0, hInst, IDS_FINDER_PAGE, sizeof(szString), szString);
else
strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
WinLoadString((HAB)0, hInst, IDS_QUESTION, sizeof(szString), szString);
WinSetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
WinSetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
if(!pPlugin->m_bOnline)
{
WinEnableWindow(WinWindowFromID(hWnd, IDC_GET_PLUGIN), FALSE);
WinLoadString((HAB)0, hInst, IDS_WARNING_OFFLINE, sizeof(szString), szString);
WinSetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
WinSetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
return TRUE;
}
if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
{
WinLoadString((HAB)0, hInst, IDS_WARNING_JS, sizeof(szString), szString);
WinSetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
return TRUE;
}
WinShowWindow(WinWindowFromID(hWnd, IDC_STATIC_WARNING), FALSE);
RECTL rc;
WinQueryWindowRect(WinWindowFromID(hWnd, IDC_STATIC_WARNING), &rc);
int iHeight = rc.yTop - rc.yBottom;
WinQueryWindowRect(hWnd, &rc);
WinSetWindowPos(hWnd, 0, 0, 0, rc.xRight - rc.xLeft, rc.yTop - rc.yBottom - iHeight, SWP_SIZE);
HWND hWndQuestion = WinWindowFromID(hWnd, IDC_STATIC_QUESTION);
HWND hWndButtonGetPlugin = WinWindowFromID(hWnd, IDC_GET_PLUGIN);
HWND hWndButtonCancel = WinWindowFromID(hWnd, IDC_BUTTON_CANCEL);
POINTL pt;
WinQueryWindowRect(hWndQuestion, &rc);
pt.x = rc.xLeft;
pt.y = rc.yBottom;
// ScreenToClient(hWnd, &pt);
WinSetWindowPos(hWndQuestion, 0, pt.x, pt.y - iHeight, 0, 0, SWP_MOVE);
WinQueryWindowRect(hWndButtonGetPlugin, &rc);
pt.x = rc.xLeft;
pt.y = rc.yBottom;
// ScreenToClient(hWnd, &pt);
WinSetWindowPos(hWndButtonGetPlugin, 0, pt.x, pt.y - iHeight, 0, 0, SWP_MOVE);
WinQueryWindowRect(hWndButtonCancel, &rc);
pt.x = rc.xLeft;
pt.y = rc.yBottom;
// ScreenToClient(hWnd, &pt);
WinSetWindowPos(hWndButtonCancel, 0, pt.x, pt.y - iHeight, 0, 0, SWP_MOVE);
if(pPlugin->m_bHidden)
WinSetActiveWindow(HWND_DESKTOP, hWnd);
return TRUE;
}
static void onClose(HWND hWnd)
{
WinDismissDlg(hWnd, DID_CANCEL);
CPlugin * pPlugin = (CPlugin *)WinQueryWindowPtr(hWnd, QWL_USER);
if(pPlugin !=NULL)
pPlugin->m_hWndDialog = NULL;
}
static void onDestroy(HWND hWnd)
{
}
MRESULT EXPENTRY NP_LOADDS GetPluginDialogProc(HWND hWnd, ULONG uMsg, MPARAM mp1, MPARAM mp2)
{
switch(uMsg)
{
case WM_INITDLG:
onInitDialog(hWnd,0,mp2);
return (MRESULT)FALSE;
case WM_COMMAND:
onCommand(hWnd, SHORT1FROMMP(mp1),0,0);
break;
case WM_DESTROY:
onDestroy(hWnd);
break;
case WM_CLOSE:
onClose(hWnd);
break;
default:
return WinDefDlgProc(hWnd, uMsg, mp1, mp2);
}
return (MRESULT)TRUE;
}

View File

@@ -1,43 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __DIALOGS_H__
#define __DIALOGS_H__
MRESULT EXPENTRY NP_LOADDS GetPluginDialogProc(HWND hWnd, ULONG uMsg, MPARAM mp1, MPARAM mp2);
#endif /* __DIALOGS_H__ */

View File

@@ -1,75 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <os2.h>
HMODULE hInst; // global
// Compiler run-time functions.
extern "C" {
int _CRT_init( void );
void _CRT_term( void );
void __ctordtorInit( void );
void __ctordtorTerm( void );
}
extern "C" unsigned long _System _DLL_InitTerm(unsigned long hModule,
unsigned long ulFlag)
{
switch (ulFlag) {
case 0 :
// Init: Prime compiler run-time and construct static C++ objects.
if ( _CRT_init() == -1 ) {
return 0UL;
} else {
__ctordtorInit();
hInst = hModule;
}
break;
case 1 :
__ctordtorTerm();
_CRT_term();
hInst = NULLHANDLE;
break;
default :
return 0UL;
}
return 1;
}

View File

@@ -1,4 +0,0 @@
# the null plugin goes in gecko-support because we search for plugins
# in the application, not the GRE
[gecko-support]
dist/bin/plugins/@SHARED_LIBRARY@

View File

@@ -1,102 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* RC_DATA types for version info - required */
#define NP_INFO_ProductVersion 1
#define NP_INFO_MIMEType 2
#define NP_INFO_FileOpenName 3
#define NP_INFO_FileExtents 4
/* RC_DATA types for version info - used if found */
#define NP_INFO_FileDescription 5
#define NP_INFO_ProductName 6
/* RC_DATA types for version info - optional */
#define NP_INFO_CompanyName 7
#define NP_INFO_FileVersion 8
#define NP_INFO_InternalName 9
#define NP_INFO_LegalCopyright 10
#define NP_INFO_OriginalFilename 11
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Npnul32.rc
//
#define IDD_PLUGIN_DOWNLOAD 301
#define IDI_PLUGICON 302
#define IDS_INFO 303
#define IDS_DEFAULT_URL 304
#define IDS_INSTALL_COMMAND 305
#define IDS_GET_PLUGIN_MSG2 306
#define IDS_LOCATION 306
#define IDS_TITLE 307
#define IDS_QUESTION 308
#define IDS_JS_DISABLED 309
#define IDS_ASDFINDER 310
#define IDS_ASDSIMP 311
#define IDS_QUERY_TEST 312
#define IDS_BLANK_JS 313
#define IDS_GOING2HTML 314
#define IDS_WARNING_JS 315
#define IDS_WARNING_OFFLINE 316
#define IDS_DEFAULT_URL_OLD 317
#define IDS_FINDER_PAGE 317
#define IDS_CLICK_TO_GET 318
#define IDS_CLICK_WHEN_DONE 319
#define IDC_JS_DIS_TEXT 2003
#define IDC_CONTINUE 2004
#define IDC_CONT_NOJS 2005
#define IDC_STATIC_INFO 2009
#define IDC_STATIC_LOCATION 2010
#define IDC_STATIC_QUESTION 2011
#define IDC_GET_PLUGIN 2012
#define IDC_BUTTON_CANCEL 2013
#define IDC_STATIC_URL 2014
#define IDC_STATIC_INFOTYPE 2015
#define IDC_STATIC_WARNING 2016
#define IDC_EDIT_URL 2017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 308
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 2018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#define INCL_NOBASEAPI
#include <os2.h>
#include "npnulos2.h"
RCDATA NP_INFO_ProductVersion { 1,0,0,15, }
RCDATA NP_INFO_MIMEType { "*\0" }
RCDATA NP_INFO_FileExtents { "*\0" }
RCDATA NP_INFO_FileOpenName{ "Mozilla Default Plug-in (*.*)\0" }
RCDATA NP_INFO_FileVersion { 1,0,0,15, }
RCDATA NP_INFO_CompanyName { "mozilla.org\0" }
RCDATA NP_INFO_FileDescription { "Default Plug-in file\0" }
RCDATA NP_INFO_InternalName { "DEFPLUGIN\0" }
RCDATA NP_INFO_LegalCopyright { "Copyright (C) 1995-2000\0" }
RCDATA NP_INFO_OriginalFilename { "NPNULOS2.DLL\0" }
RCDATA NP_INFO_ProductName { "Mozilla Default Plug-in\0" }
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
DLGTEMPLATE IDD_PLUGIN_DOWNLOAD DISCARDABLE
BEGIN
DIALOG "Title", IDD_PLUGIN_DOWNLOAD, 0, 125, 225, 122,
WS_VISIBLE | FS_DLGBORDER | FS_SCREENALIGN,
FCF_TITLEBAR | FCF_SYSMENU | FCF_NOMOVEWITHOWNER
PRESPARAMS PP_FONTNAMESIZE, "8.Helv"
BEGIN
LTEXT "Information on this page requires a plug-in for:",IDC_STATIC_INFO, 7, 108, 211, 8,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
LTEXT "Communicator can retrieve the plug-in for you from:",IDC_STATIC_LOCATION, 7, 89, 211, 7,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
CTEXT "What would you like to do?",IDC_STATIC_QUESTION, 7, 21, 211, 7,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
DEFPUSHBUTTON "Get the Plug-in",IDC_GET_PLUGIN, 41, 6, 64, 12,
PUSHBUTTON "Cancel", DID_CANCEL, 109, 6, 64, 12,
CTEXT "type/x-type",IDC_STATIC_INFOTYPE, 7, 100, 211, 7, SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
LTEXT "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page.",IDC_STATIC_WARNING, 7, 32, 211, 29,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
LTEXT "Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static ",IDC_STATIC_URL, 7, 67, 211, 20,SS_TEXT | DT_WORDBREAK | DT_MNEMONIC
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
ICON IDI_PLUGICON DISCARDABLE "npnulos2.ico"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INFO "Information on this page requires a plug-in for:"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_LOCATION "Navigator can retrieve the plug-in for you from:"
IDS_TITLE "Plug-in Not Loaded"
IDS_QUESTION "What would you like to do?"
IDS_WARNING_JS "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page."
IDS_WARNING_OFFLINE "However, you are currently offline. If you would like to get the plug-in, click Cancel, select ""Go Online"" from the File menu, then click the plug-in icon on the page."
IDS_FINDER_PAGE "Netscape's Plug-in Finder page"
IDS_CLICK_TO_GET "Click here to get the plugin"
IDS_CLICK_WHEN_DONE "Click here after installing the plugin"
END

View File

@@ -1,352 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <os2.h>
#ifndef _NPAPI_H_
#include "npapi.h"
#endif
#ifndef _NPUPP_H_
#include "npupp.h"
#endif
//\\// DEFINE
#define NP_EXPORT
//\\// GLOBAL DATA
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
#ifdef OJI
JRIGlobalRef Private_GetJavaClass(void);
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// Private_GetJavaClass (global function)
//
// Given a Java class reference (thru NPP_GetJavaClass) inform JRT
// of this class existence
//
JRIGlobalRef
Private_GetJavaClass(void)
{
jref clazz = NPP_GetJavaClass();
if (clazz) {
JRIEnv* env = NPN_GetJavaEnv();
return JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
#endif /* OJI */
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// PLUGIN DLL entry points
//
// These are the Windows specific DLL entry points. They must be exoprted
//
// we need these to be global since we have to fill one of its field
// with a data (class) which requires knowlwdge of the navigator
// jump-table. This jump table is known at Initialize time (NP_Initialize)
// which is called after NP_GetEntryPoint
static NPPluginFuncs* g_pluginFuncs;
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_GetEntryPoints
//
// fills in the func table used by Navigator to call entry points in
// plugin DLL. Note that these entry points ensure that DS is loaded
// by using the NP_LOADDS macro, when compiling for Win16
//
NPError OSCALL NP_EXPORT
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
// if the plugin's function table is smaller than the plugin expects,
// then they are incompatible, and should return an error
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
pFuncs->newp = NPP_New;
pFuncs->destroy = NPP_Destroy;
pFuncs->setwindow = NPP_SetWindow;
pFuncs->newstream = NPP_NewStream;
pFuncs->destroystream = NPP_DestroyStream;
pFuncs->asfile = NPP_StreamAsFile;
pFuncs->writeready = NPP_WriteReady;
pFuncs->write = NPP_Write;
pFuncs->print = NPP_Print;
pFuncs->event = 0; /// reserved
g_pluginFuncs = pFuncs;
return NPERR_NO_ERROR;
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_Initialize
//
// called immediately after the plugin DLL is loaded
//
NPError OSCALL NP_EXPORT
NP_Initialize(NPNetscapeFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
g_pNavigatorFuncs = pFuncs; // save it for future reference
// if the plugin's major ver level is lower than the Navigator's,
// then they are incompatible, and should return an error
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
// We have to defer these assignments until g_pNavigatorFuncs is set
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
g_pluginFuncs->urlnotify = NPP_URLNotify;
}
#ifdef OJI
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
g_pluginFuncs->javaClass = Private_GetJavaClass();
}
#endif
// NPP_Initialize is a standard (cross-platform) initialize function.
return NPP_Initialize();
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_Shutdown
//
// called immediately before the plugin DLL is unloaded.
// This functio shuold check for some ref count on the dll to see if it is
// unloadable or it needs to stay in memory.
//
NPError OSCALL NP_EXPORT
NP_Shutdown()
{
NPP_Shutdown();
g_pNavigatorFuncs = NULL;
return NPERR_NO_ERROR;
}
// END - PLUGIN DLL entry points
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
/* NAVIGATOR Entry points */
/* These entry points expect to be called from within the plugin. The
noteworthy assumption is that DS has already been set to point to the
plugin's DLL data segment. Don't call these functions from outside
the plugin without ensuring DS is set to the DLLs data segment first,
typically using the NP_LOADDS macro
*/
/* returns the major/minor version numbers of the Plugin API for the plugin
and the Navigator
*/
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
{
return g_pNavigatorFuncs->getvalue(instance, variable, result);
}
/* causes the specified URL to be fetched and streamed in
*/
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
return g_pNavigatorFuncs->geturl(instance, url, target);
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
}
/* Requests that a number of bytes be provided on a stream. Typically
this would be used if a stream was in "pull" mode. An optional
position can be provided for streams which are seekable.
*/
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return g_pNavigatorFuncs->requestread(stream, rangeList);
}
/* Creates a new stream of data from the plug-in to be interpreted
by Netscape in the current window.
*/
NPError NPN_NewStream(NPP instance, NPMIMEType type,
const char* target, NPStream** stream)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
/* Provides len bytes of data.
*/
int32 NPN_Write(NPP instance, NPStream *stream,
int32 len, void *buffer)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
int32 result;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
}
else {
result = -1;
}
return result;
}
/* Closes a stream object.
reason indicates why the stream was closed.
*/
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
/* Provides a text status message in the Netscape client user interface
*/
void NPN_Status(NPP instance, const char *message)
{
g_pNavigatorFuncs->status(instance, message);
}
/* returns the user agent string of Navigator, which contains version info
*/
const char* NPN_UserAgent(NPP instance)
{
return g_pNavigatorFuncs->uagent(instance);
}
/* allocates memory from the Navigator's memory space. Necessary so that
saved instance data may be freed by Navigator when exiting.
*/
void* NPN_MemAlloc(uint32 size)
{
return g_pNavigatorFuncs->memalloc(size);
}
/* reciprocal of MemAlloc() above
*/
void NPN_MemFree(void* ptr)
{
g_pNavigatorFuncs->memfree(ptr);
}
#ifdef OJI
/* private function to Netscape. do not use!
*/
void NPN_ReloadPlugins(NPBool reloadPages)
{
g_pNavigatorFuncs->reloadplugins(reloadPages);
}
JRIEnv* NPN_GetJavaEnv(void)
{
return g_pNavigatorFuncs->getJavaEnv();
}
jref NPN_GetJavaPeer(NPP instance)
{
return g_pNavigatorFuncs->getJavaPeer(instance);
}
#endif

View File

@@ -1,325 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <os2.h>
#include <string.h>
#include "npnulos2.h"
#include "Plugin.h" // this includes npapi.h
#include "utils.h"
#include "dbg.h"
char szAppName[] = "NPNULL";
//---------------------------------------------------------------------------
// NPP_Initialize:
//---------------------------------------------------------------------------
NPError NPP_Initialize(void)
{
RegisterNullPluginWindowClass();
return NPERR_NO_ERROR;
}
//---------------------------------------------------------------------------
// NPP_Shutdown:
//---------------------------------------------------------------------------
void NPP_Shutdown(void)
{
UnregisterNullPluginWindowClass();
}
//---------------------------------------------------------------------------
// NPP_New:
//---------------------------------------------------------------------------
NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
NPP pInstance,
uint16 mode,
int16 argc,
char* argn[],
char* argv[],
NPSavedData* saved)
{
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
// See if the content provider specified from where to fetch the plugin
char * szPageURL = NULL;
char * szFileURL = NULL;
char * szFileExtension = NULL;
char * buf = NULL;
BOOL bHidden = FALSE;
for(int i = 0; i < argc; i++)
{
if(stricmp(argn[i],"pluginspage") == 0 && argv[i] != NULL)
szPageURL = (char *)argv[i];
else if(stricmp(argn[i],"codebase") == 0 && argv[i] != NULL)
szPageURL = (char *)argv[i];
else if(stricmp(argn[i],"pluginurl") == 0 && argv[i] != NULL)
szFileURL = (char *)argv[i];
else if(stricmp(argn[i],"classid") == 0 && argv[i] != NULL)
szFileURL = (char *)argv[i];
else if(stricmp(argn[i],"SRC") == 0 && argv[i] != NULL)
buf = (char *)argv[i];
else if(stricmp(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
bHidden = (strcmp((char *)argv[i], "TRUE") == 0);
}
/* some post-processing on the filename to attempt to extract the extension: */
if(buf != NULL)
{
buf = strrchr(buf, '.');
if (buf) {
szFileExtension = ++buf;
}
}
CPlugin * pPlugin = new CPlugin(hInst,
pInstance,
mode,
pluginType,
szPageURL,
szFileURL,
szFileExtension,
bHidden);
if(pPlugin == NULL)
return NPERR_OUT_OF_MEMORY_ERROR;
if(bHidden)
{
if(!pPlugin->init(NULL))
{
delete pPlugin;
pPlugin = NULL;
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
pInstance->pdata = (void *)pPlugin;
return NPERR_NO_ERROR;
}
//---------------------------------------------------------------------------
// NPP_Destroy:
//---------------------------------------------------------------------------
NPError NP_LOADDS
NPP_Destroy(NPP pInstance, NPSavedData** save)
{
dbgOut1("NPP_Destroy");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
if(pPlugin != NULL)
{
pPlugin->shut();
delete pPlugin;
}
return NPERR_NO_ERROR;
}
//---------------------------------------------------------------------------
// NPP_SetWindow:
//---------------------------------------------------------------------------
NPError NP_LOADDS NPP_SetWindow(NPP pInstance, NPWindow * pNPWindow)
{
if(pInstance == NULL)
{
dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
return NPERR_INVALID_INSTANCE_ERROR;
}
if(pNPWindow == NULL)
{
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
return NPERR_GENERIC_ERROR;
}
HWND hWnd = (HWND)pNPWindow->window;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
if(pPlugin == NULL)
{
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
return NPERR_GENERIC_ERROR;
}
if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
{
dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
return NPERR_NO_ERROR;
}
if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
{ // window went away
dbgOut1("NPP_SetWindow, going away...");
pPlugin->shut();
return NPERR_NO_ERROR;
}
if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
{ // First time in -- no window created by plugin yet
dbgOut1("NPP_SetWindow, first time");
if(!pPlugin->init(hWnd))
{
delete pPlugin;
pPlugin = NULL;
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
{ // Netscape window has been resized
dbgOut1("NPP_SetWindow, resizing");
pPlugin->resize();
}
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_NewStream:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_NewStream(NPP pInstance,
NPMIMEType type,
NPStream *stream,
NPBool seekable,
uint16 *stype)
{
dbgOut1("NPP_NewStream");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_WriteReady:
//------------------------------------------------------------------------------------
int32 NP_LOADDS
NPP_WriteReady(NPP pInstance, NPStream *stream)
{
dbgOut1("NPP_WriteReady");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return -1L; // dont accept any bytes in NPP_Write()
}
//------------------------------------------------------------------------------------
// NPP_Write:
//------------------------------------------------------------------------------------
int32 NP_LOADDS
NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
//dbgOut1("NPP_Write");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return -1; // tell Nav to abort the stream, don't need it
}
//------------------------------------------------------------------------------------
// NPP_DestroyStream:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
{
dbgOut1("NPP_DestroyStream");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_StreamAsFile:
//------------------------------------------------------------------------------------
void NP_LOADDS
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
{
dbgOut1("NPP_StreamAsFile");
}
//------------------------------------------------------------------------------------
// NPP_Print:
//------------------------------------------------------------------------------------
void NP_LOADDS NPP_Print(NPP pInstance, NPPrint * printInfo)
{
dbgOut2("NPP_Print, printInfo = %#08x", printInfo);
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
pPlugin->print(printInfo);
}
void NP_LOADDS NPP_URLNotify(NPP pInstance, const char* url, NPReason reason, void* notifyData)
{
dbgOut2("NPP_URLNotify, URL '%s'", url);
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
pPlugin->URLNotify(url);
}
#ifdef OJI
jref NP_LOADDS NPP_GetJavaClass(void)
{
return NULL;
}
#endif

View File

@@ -1,704 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#define INCL_GPI
#define INCL_WIN
#include <os2.h>
#include <string.h>
#include "npnulos2.h"
#include "plugin.h"
#include "utils.h"
#include "dialogs.h"
#include "dbg.h"
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
MRESULT EXPENTRY PluginWndProc(HWND, ULONG, MPARAM, MPARAM);
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
static char szDefaultFileExt[] = "*";
BOOL RegisterNullPluginWindowClass()
{
return WinRegisterClass( (HAB)0, szNullPluginWindowClassName, (PFNWP)PluginWndProc, 0, sizeof(ULONG));
}
void UnregisterNullPluginWindowClass()
{
}
/*********************************************/
/* */
/* CPlugin class implementation */
/* */
/*********************************************/
CPlugin::CPlugin(HMODULE hInst,
NPP pNPInstance,
SHORT wMode,
NPMIMEType pluginType,
PSZ szPageURL,
PSZ szFileURL,
PSZ szFileExtension,
BOOL bHidden) :
m_pNPInstance(pNPInstance),
m_wMode(wMode),
m_hInst(hInst),
m_hWnd(NULL),
m_hWndParent(NULL),
m_hWndDialog(NULL),
m_hIcon(NULL),
m_pNPMIMEType(NULL),
m_szPageURL(NULL),
m_szFileURL(NULL),
m_szFileExtension(NULL),
m_bOnline(TRUE),
m_bJava(TRUE),
m_bJavaScript(TRUE),
m_bSmartUpdate(TRUE),
m_szURLString(NULL),
m_szCommandMessage(NULL),
m_bHidden(bHidden)
{
dbgOut1("CPlugin::CPlugin()");
assert(m_hInst != NULL);
assert(m_pNPInstance != NULL);
if(pluginType && *pluginType)
{
m_pNPMIMEType = (NPMIMEType)new char[strlen((PSZ)pluginType) + 1];
if(m_pNPMIMEType != NULL)
strcpy((PSZ)m_pNPMIMEType, pluginType);
}
if(szPageURL && *szPageURL)
{
m_szPageURL = new char[strlen(szPageURL) + 1];
if(m_szPageURL != NULL)
strcpy(m_szPageURL, szPageURL);
}
if(szFileURL && *szFileURL)
{
m_szFileURL = new char[strlen(szFileURL) + 1];
if(m_szFileURL != NULL)
strcpy(m_szFileURL, szFileURL);
}
if(szFileExtension && *szFileExtension)
{
m_szFileExtension = new char[strlen(szFileExtension) + 1];
if(m_szFileExtension != NULL)
strcpy(m_szFileExtension, szFileExtension);
}
m_hIcon = WinLoadPointer(HWND_DESKTOP, m_hInst, IDI_PLUGICON);
char szString[1024] = {'\0'};
WinLoadString((HAB)0, m_hInst, IDS_CLICK_TO_GET, sizeof(szString), szString);
if(*szString)
{
m_szCommandMessage = new char[strlen(szString) + 1];
if(m_szCommandMessage != NULL)
strcpy(m_szCommandMessage, szString);
}
}
CPlugin::~CPlugin()
{
dbgOut1("CPlugin::~CPlugin()");
if(m_pNPMIMEType != NULL)
{
delete [] m_pNPMIMEType;
m_pNPMIMEType = NULL;
}
if(m_szPageURL != NULL)
{
delete [] m_szPageURL;
m_szPageURL = NULL;
}
if(m_szFileURL != NULL)
{
delete [] m_szFileURL;
m_szFileURL = NULL;
}
if(m_szFileExtension != NULL)
{
delete [] m_szFileExtension;
m_szFileExtension = NULL;
}
if(m_szURLString != NULL)
{
delete [] m_szURLString;
m_szURLString = NULL;
}
if(m_hIcon != NULL)
{
WinDestroyPointer(m_hIcon);
m_hIcon = NULL;
}
if(m_szCommandMessage != NULL)
{
delete [] m_szCommandMessage;
m_szCommandMessage = NULL;
}
}
BOOL CPlugin::init(HWND hWndParent)
{
dbgOut1("CPlugin::init()");
if(!m_bHidden)
{
assert(WinIsWindow((HAB)0, hWndParent));
if(WinIsWindow((HAB)0, hWndParent))
m_hWndParent = hWndParent;
RECTL rcParent;
WinQueryWindowRect(m_hWndParent, &rcParent);
m_hWnd = WinCreateWindow(m_hWndParent,
szNullPluginWindowClassName,
"NULL Plugin",
0,
0,0, rcParent.xRight, rcParent.yTop,
m_hWndParent,
HWND_TOP,
255,
(PVOID)this,
0);
WinSetPresParam(m_hWnd, PP_FONTNAMESIZE, 10, (PVOID)"9.WarpSans");
assert(m_hWnd != NULL);
if((m_hWnd == NULL) || (!WinIsWindow((HAB)0, m_hWnd)))
return FALSE;
// UpdateWindow(m_hWnd);
WinShowWindow(m_hWnd, TRUE);
}
if(IsNewMimeType((PSZ)m_pNPMIMEType) || m_bHidden)
showGetPluginDialog();
return TRUE;
}
void CPlugin::shut()
{
dbgOut1("CPlugin::shut()");
if(m_hWndDialog != NULL)
{
WinDismissDlg(m_hWndDialog, DID_CANCEL);
m_hWndDialog = NULL;
}
if(m_hWnd != NULL)
{
WinDestroyWindow(m_hWnd);
m_hWnd = NULL;
}
}
HWND CPlugin::getWindow()
{
return m_hWnd;
}
BOOL CPlugin::useDefaultURL_P()
{
if((m_szPageURL == NULL) && (m_szFileURL == NULL))
return TRUE;
else
return FALSE;
}
BOOL CPlugin::doSmartUpdate_P()
{
// due to current JavaScript problems never do it smart for now 5.1.98
return FALSE;
if(m_bOnline && m_bJava && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
return TRUE;
else
return FALSE;
}
PSZ CPlugin::createURLString()
{
if(m_szURLString != NULL)
{
delete [] m_szURLString;
m_szURLString = NULL;
}
// check if there is file URL first
if(m_szFileURL != NULL)
{
m_szURLString = new char[strlen(m_szFileURL) + 1];
if(m_szURLString == NULL)
return NULL;
strcpy(m_szURLString, m_szFileURL);
return m_szURLString;
}
// if not get the page URL
char * szAddress = NULL;
char *urlToOpen = NULL;
char contentTypeIsJava = 0;
if (NULL != m_pNPMIMEType) {
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
m_pNPMIMEType)) ? 1 : 0;
}
if(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];
if(m_szURLString == NULL)
return NULL;
// Append the MIME type to the URL
sprintf(m_szURLString, "%s?%s", szAddress, (PSZ)m_pNPMIMEType);
}
else // default
{
if(!m_bJavaScript)
{
urlToOpen = szDefaultPluginFinderURL;
if (contentTypeIsJava) {
urlToOpen = szPageUrlForJVM;
}
szAddress = new char[strlen(urlToOpen) + 1];
if(szAddress == NULL)
return NULL;
strcpy(szAddress, urlToOpen);
m_szURLString = new char[strlen(szAddress) + 1 + 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);
}
else
{
urlToOpen = szPageUrlForJavaScript;
if (contentTypeIsJava) {
urlToOpen = szPageUrlForJVM;
}
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);
}
}
if(szAddress != NULL)
delete [] szAddress;
return m_szURLString;
}
void CPlugin::getPluginRegular()
{
assert(m_bOnline);
char * szURL = createURLString();
assert(szURL != NULL);
if(szURL == NULL)
return;
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");
}
void CPlugin::getPluginSmart()
{
/*
static char szJSString[2048];
sprintf(szJSString,
szPluginFinderCommandFormatString,
szDefaultPluginFinderURL,
m_pNPMIMEType,
(m_szFileExtension != NULL) ? m_szFileExtension : szDefaultFileExt);
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
assert(strlen(szJSString) > 0);
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
*/
}
void CPlugin::showGetPluginDialog()
{
assert(m_pNPMIMEType != NULL);
if(m_pNPMIMEType == NULL)
return;
// Get environment
BOOL bOffline = FALSE;
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
m_bOnline = !bOffline;
#ifdef OJI
if(m_bOnline && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
{
JRIEnv *penv = NPN_GetJavaEnv();
m_bJava = (penv != NULL);
}
#else
m_bJava = FALSE;
#endif
dbgOut1("Environment:");
dbgOut2("%s", m_bOnline ? "On-line" : "Off-line");
dbgOut2("Java %s", m_bJava ? "Enabled" : "Disabled");
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
if((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;
}
if(m_szCommandMessage != NULL)
{
delete [] m_szCommandMessage;
m_szCommandMessage = NULL;
}
char szString[1024] = {'\0'};
WinLoadString((HAB)0, m_hInst, IDS_CLICK_WHEN_DONE, sizeof(szString), szString);
if(*szString)
{
m_szCommandMessage = new char[strlen(szString) + 1];
if(m_szCommandMessage != NULL)
strcpy(m_szCommandMessage, szString);
}
WinInvalidateRect(m_hWnd, NULL, TRUE);
// UpdateWindow(m_hWnd);
getPluginRegular();
}
//*******************
// NP API handles
//*******************
void CPlugin::resize()
{
dbgOut1("CPlugin::resize()");
}
void CPlugin::print(NPPrint * pNPPrint)
{
dbgOut1("CPlugin::print()");
if(pNPPrint == NULL)
return;
}
void CPlugin::URLNotify(const char * szURL)
{
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
NPStream * pStream = NULL;
char buf[256];
assert(m_hInst != NULL);
assert(m_pNPInstance != NULL);
int iSize = WinLoadString((HAB)0, m_hInst, IDS_GOING2HTML, sizeof(buf), buf);
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
//char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
int32 iBytes = NPN_Write(m_pNPInstance, pStream, strlen(buf), buf);
NPN_DestroyStream(m_pNPInstance, pStream, NPRES_DONE);
}
BOOL CPlugin::readyToRefresh()
{
char szString[1024] = {'\0'};
WinLoadString((HAB)0, m_hInst, IDS_CLICK_WHEN_DONE, sizeof(szString), szString);
if(m_szCommandMessage == NULL)
return FALSE;
return (strcmp(m_szCommandMessage, szString) == 0);
}
//***************************
// Windows message handlers
//***************************
void CPlugin::onCreate(HWND hWnd)
{
m_hWnd = hWnd;
}
void CPlugin::onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
{
if(!readyToRefresh())
showGetPluginDialog();
else
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
}
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
{
if(!readyToRefresh())
showGetPluginDialog();
else
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
}
static void DrawCommandMessage(HPS hPS, PSZ szString, PRECTL lprc)
{
if(szString == NULL)
return;
POINTL ptls[5];
GpiQueryTextBox(hPS, strlen(szString), szString, 5, ptls);
/* If the text won't fit, don't draw anything */
if (ptls[TXTBOX_CONCAT].x > lprc->xRight)
return;
RECTL rcText = rcText = *lprc;
/* Reduce top of rectangle by twice the icon size so the */
/* text draws below the icon */
rcText.yTop -= 80;
WinDrawText(hPS, strlen(szString), szString, &rcText, 0, 0,
DT_TEXTATTRS | DT_CENTER | DT_VCENTER);
}
#define INSET 1
void CPlugin::onPaint(HWND hWnd)
{
RECTL rc;
HDC hPS;
int x, y;
hPS = WinBeginPaint(hWnd, NULLHANDLE, NULL);
GpiErase(hPS);
WinQueryWindowRect(hWnd, &rc);
x = (rc.xRight / 2) - (40 / 2);
y = (rc.yTop / 2) - ((40) / 2);
/* Only draw the icon if it fits */
if(rc.xRight > (40 + 6 + INSET) && rc.yTop > (40 + 6 + INSET) )
{
if(m_hIcon != NULL)
WinDrawPointer(hPS, x, y, m_hIcon, DP_NORMAL);
}
POINTL pt[5];
// white piece
GpiSetColor(hPS, CLR_WHITE);
pt[0].x = 1 + INSET;
pt[0].y = 1 + INSET;
GpiMove(hPS, &pt[0]);
pt[0].x = rc.xRight - 2 - INSET;
pt[0].y = 1 + INSET;
pt[1].x = rc.xRight - 2 - INSET;
pt[1].y = rc.yTop -1 - INSET;
GpiPolyLine(hPS, 2, pt);
pt[0].x = 2 + INSET;
pt[0].y = 3 + INSET;
GpiMove(hPS, &pt[0]);
pt[0].x = 2 + INSET;
pt[0].y = rc.yTop - 3 - INSET;
pt[1].x = rc.xRight - 4 - INSET;
pt[1].y = rc.yTop - 3 - INSET;
GpiPolyLine(hPS, 2, pt);
// pale gray pieces
GpiSetColor(hPS, CLR_PALEGRAY);
pt[0].x = INSET;
pt[0].y = 1 + INSET;
GpiMove(hPS, &pt[0]);
pt[0].x = INSET;
pt[0].y = rc.yTop - 1 - INSET;
pt[1].x = rc.xRight - 2 - INSET;
pt[1].y = rc.yTop - 1 - INSET;
GpiPolyLine(hPS, 2, pt);
pt[0].x = rc.xRight - 3 - INSET;
pt[0].y = rc.yTop - 2 - INSET;
GpiMove(hPS, &pt[0]);
pt[0].x = rc.xRight - 3 - INSET;
pt[0].y = 2 + INSET;
pt[1].x = 2 + INSET;
pt[1].y = 2 + INSET;
GpiPolyLine(hPS, 2, pt);
// dark gray piece
GpiSetColor(hPS, CLR_DARKGRAY);
pt[0].x = 1 + INSET;
pt[0].y = 2 + INSET;
GpiMove(hPS, &pt[0]);
pt[0].x = 1 + INSET;
pt[0].y = rc.yTop - 2 - INSET;
pt[1].x = rc.xRight - 4 - INSET;
pt[1].y = rc.yTop - 2 - INSET;
GpiPolyLine(hPS, 2, pt);
// black piece
GpiSetColor(hPS, CLR_BLACK);
pt[0].x = rc.xRight - 1 - INSET;
pt[0].y = rc.yTop - 1 - INSET;
GpiMove(hPS, &pt[0]);
pt[0].x = rc.xRight - 1 - INSET;
pt[0].y = 0 + INSET;
pt[1].x = 0 + INSET;
pt[1].y = 0 + INSET;
GpiPolyLine(hPS, 2, pt);
/* Offset rectangle by size of highlight(3) + 1 as well as inset */
/* so that text is not drawn over the border */
rc.xLeft += 4+INSET;
rc.xRight -= 4+INSET;
rc.yTop -= 4+INSET;
rc.yBottom += 4+INSET;
DrawCommandMessage(hPS, m_szCommandMessage, &rc);
WinEndPaint (hPS);
}
//**************************
// Plugin window procedure
//**************************
MRESULT EXPENTRY NP_LOADDS PluginWndProc(HWND hWnd, ULONG message, MPARAM mp1, MPARAM mp2)
{
CPlugin *pPlugin = (CPlugin *)WinQueryWindowULong(hWnd, QWL_USER);
switch(message)
{
case WM_CREATE:
pPlugin = (CPlugin *)(((PCREATESTRUCT)mp2)->pCtlData);
assert(pPlugin != NULL);
WinSetWindowULong(hWnd, QWL_USER, (ULONG)pPlugin);
pPlugin->onCreate(hWnd);
return 0L;
case WM_BUTTON1UP:
pPlugin->onLButtonUp(hWnd,0,0,0);
return 0L;
case WM_BUTTON2UP:
pPlugin->onRButtonUp(hWnd,0,0,0);
return 0L;
case WM_PAINT:
pPlugin->onPaint(hWnd);
return 0L;
case WM_MOUSEMOVE:
dbgOut1("MouseMove");
break;
default:
break;
}
return(WinDefWindowProc(hWnd, message, mp1, mp2));
}

View File

@@ -1,127 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __PLUGIN_HPP__
#define __PLUGIN_HPP__
#include "npapi.h"
class CPlugin
{
private:
HMODULE m_hInst;
NPP m_pNPInstance;
SHORT m_wMode;
HWND m_hWnd;
HWND m_hWndParent;
HPOINTER m_hIcon;
char * m_szURLString;
char * m_szCommandMessage;
public:
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;
// environment
BOOL m_bOnline;
BOOL m_bJava;
BOOL m_bJavaScript;
BOOL m_bSmartUpdate;
private:
BOOL useDefaultURL_P();
BOOL doSmartUpdate_P();
PSZ createURLString();
void getPluginSmart();
void getPluginRegular();
public:
CPlugin(HMODULE hInst,
NPP pNPInstance,
SHORT wMode,
NPMIMEType pluginType,
PSZ szPageURL,
PSZ szFileURL,
PSZ szFileExtension,
BOOL bHidden);
~CPlugin();
BOOL init(HWND hWnd);
void shut();
HWND getWindow();
void showGetPluginDialog();
BOOL readyToRefresh();
// NP API handlers
void resize();
void print(NPPrint * pNPPrint);
void URLNotify(const char * szURL);
// 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);
};
#define PAGE_URL_FOR_JAVASCRIPT "http://cgi.netscape.com/cgi-bin/plugins/get_plugin.cgi"
#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 OS2INI_PLACE "Mozilla Default Plugin"
#define GWL_USERDATA 0
#define COLOR_3DSHADOW COLOR_BTNFACE
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
#define CLASS_NULL_PLUGIN "NullPluginClass"
BOOL RegisterNullPluginWindowClass();
void UnregisterNullPluginWindowClass();
extern HMODULE hInst;
#endif // __PLUGIN_HPP__

View File

@@ -1,156 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#define INCL_GPI
#define INCL_WIN
#include <os2.h>
#include <string.h>
#include "plugin.h"
// return TRUE if we've never seen this MIME type before
BOOL IsNewMimeType(PSZ mime)
{
ULONG keysize = 512;
char keybuf[512];
PrfQueryProfileString(HINI_USERPROFILE, OS2INI_PLACE, mime, "", keybuf, keysize);
if (keybuf[0] != '\0') {
return FALSE;
}
else
{
if (!(PrfWriteProfileString(HINI_USERPROFILE, OS2INI_PLACE, mime, "(none)")))
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, "Error adding MIME type value", "Default Plugin", 0, MB_OK);
return TRUE;
}
}
// string length in pixels for the specific window (selected font)
static int getWindowStringLength(HWND hWnd, PSZ lpsz)
{
HPS hPS = WinGetPS(hWnd);
POINTL ptls[5];
GpiQueryTextBox(hPS, strlen(lpsz), lpsz, 5, ptls);
POINTL pt;
pt.x = ptls[TXTBOX_CONCAT].x;
pt.y = ptls[TXTBOX_TOPLEFT].y - ptls[TXTBOX_BOTTOMLEFT].y;
WinReleasePS(hPS);
return (int)pt.x;
}
/****************************************************************/
/* */
/* 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 */
/* */
/****************************************************************/
void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText)
{
HWND hWndStatic = WinWindowFromID(hWnd, iID);
if(!szText || !*szText)
{
WinSetDlgItemText(hWnd, iID, "");
return;
}
RECTL rc;
WinQueryWindowRect(hWndStatic, &rc);
int iStaticLength = rc.xRight - rc.xLeft;
int iStringLength = getWindowStringLength(hWndStatic, szText);
if(iStringLength <= iStaticLength)
{
WinSetDlgItemText(hWnd, iID, szText);
return;
}
int iBreaks = iStringLength/iStaticLength;
if(iBreaks <= 0)
return;
char * pBuf = new char[iStringLength + iBreaks + 1];
if(pBuf == NULL)
return;
strcpy(pBuf, "");
int iStart = 0;
int iLines = 0;
for(int i = 0; i < iStringLength; i++)
{
char * sz = &szText[iStart];
int iIndex = i - iStart;
char ch = sz[iIndex + 1];
sz[iIndex + 1] = '\0';
int iLength = getWindowStringLength(hWndStatic, sz);
if(iLength < iStaticLength)
{
sz[iIndex + 1] = ch;
if(iLines == iBreaks)
{
strcat(pBuf, sz);
break;
}
continue;
}
sz[iIndex + 1] = ch; // restore zeroed element
i--; // go one step back
ch = sz[iIndex];
sz[iIndex] = '\0'; // terminate string one char shorter
strcat(pBuf, sz); // append the string
strcat(pBuf, " "); // append space character for successful wrapping
iStart += strlen(sz);// shift new start position
sz[iIndex] = ch; // restore zeroed element
iLines++; // count lines
}
WinSetDlgItemText(hWnd, iID, pBuf);
delete [] pBuf;
}

View File

@@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __UTILS_H__
#define __UTILS_H__
BOOL IsNewMimeType(PSZ szMimeType);
void SetDlgItemTextWrapped(HWND hWnd, int iID, PSZ szText);
#endif // __UTILS_H__

View File

@@ -1,103 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plugin
LIBRARY_NAME = nullplugin
GRE_MODULE = 1
PACKAGE_FILE = npnul.pkg
REQUIRES = java \
plugin \
$(NULL)
CSRCS = \
npshell.c\
nullplugin.c\
npunix.c\
$(NULL)
# plugins should always be shared, even in the "static" build
FORCE_SHARED_LIB = 1
# Force use of PIC
FORCE_USE_PIC = 1
NO_DIST_INSTALL = 1
NO_INSTALL = 1
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS) $(XT_LIBS) \
$(NULL)
ifdef MOZ_ENABLE_GTK
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
CXXFLAGS += $(MOZ_GTK_CFLAGS)
CFLAGS += $(MOZ_GTK_CFLAGS)
endif
ifdef MOZ_ENABLE_GTK2
EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS) $(XLDFLAGS) $(XLIBS)
CXXFLAGS += $(MOZ_GTK2_CFLAGS)
CFLAGS += $(MOZ_GTK2_CFLAGS)
endif
ifeq ($(OS_ARCH), OpenVMS)
DEFINES += -DGENERIC_MOTIF_REDEFINES
OS_CXXFLAGS += -Wc,warn=disa=NOSIMPINT
endif
install-plugin: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
endif
libs:: install-plugin
ifdef SHARED_LIBRARY
install:: $(SHARED_LIBRARY)
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/plugins
endif

View File

@@ -1,40 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
# the null plugin goes in gecko-support because we search for plugins
# in the application, not the GRE
[gecko-support]
dist/bin/plugins/@SHARED_LIBRARY@

View File

@@ -1,378 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Stephen Mak <smak@sun.com>
*/
/*
* npshell.c
*
* Netscape Client Plugin API
* - Function that need to be implemented by plugin developers
*
* This file defines a "shell" plugin that plugin developers can use
* as the basis for a real plugin. This shell just provides empty
* implementations of all functions that the plugin can implement
* that will be called by Netscape (the NPP_xxx methods defined in
* npapi.h).
*
* dp Suresh <dp@netscape.com>
* updated 5/1998 <pollmann@netscape.com>
* updated 9/2000 <smak@sun.com>
*
*/
#include <stdio.h>
#include <string.h>
#include "npapi.h"
#include "nullplugin.h"
#include "strings.h"
#include "plstr.h"
/***********************************************************************
*
* Implementations of plugin API functions
*
***********************************************************************/
char*
NPP_GetMIMEDescription(void)
{
return(MIME_TYPES_HANDLED);
}
NPError
NPP_GetValue(NPP instance, NPPVariable variable, void *value)
{
NPError err = NPERR_NO_ERROR;
switch (variable) {
case NPPVpluginNameString:
*((char **)value) = PLUGIN_NAME;
break;
case NPPVpluginDescriptionString:
*((char **)value) = PLUGIN_DESCRIPTION;
break;
default:
err = NPERR_GENERIC_ERROR;
}
return err;
}
NPError
NPP_Initialize(void)
{
return NPERR_NO_ERROR;
}
#ifdef OJI
jref
NPP_GetJavaClass()
{
return NULL;
}
#endif
void
NPP_Shutdown(void)
{
}
NPError
NPP_New(NPMIMEType pluginType,
NPP instance,
uint16 mode,
int16 argc,
char* argn[],
char* argv[],
NPSavedData* saved)
{
PluginInstance* This;
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
instance->pdata = NPN_MemAlloc(sizeof(PluginInstance));
This = (PluginInstance*) instance->pdata;
if (This == NULL)
{
return NPERR_OUT_OF_MEMORY_ERROR;
}
memset(This, 0, sizeof(PluginInstance));
/* mode is NP_EMBED, NP_FULL, or NP_BACKGROUND (see npapi.h) */
This->mode = mode;
This->type = dupMimeType(pluginType);
This->instance = instance;
This->pluginsPageUrl = NULL;
This->exists = FALSE;
/* Parse argument list passed to plugin instance */
/* We are interested in these arguments
* PLUGINSPAGE = <url>
*/
while (argc > 0)
{
argc --;
if (argv[argc] != NULL)
{
if (!PL_strcasecmp(argn[argc], "PLUGINSPAGE"))
This->pluginsPageUrl = strdup(argv[argc]);
else if (!PL_strcasecmp(argn[argc], "PLUGINURL"))
This->pluginsFileUrl = strdup(argv[argc]);
else if (!PL_strcasecmp(argn[argc], "CODEBASE"))
This->pluginsPageUrl = strdup(argv[argc]);
else if (!PL_strcasecmp(argn[argc], "CLASSID"))
This->pluginsFileUrl = strdup(argv[argc]);
else if (!PL_strcasecmp(argn[argc], "HIDDEN"))
This->pluginsHidden = (!PL_strcasecmp(argv[argc],
"TRUE"));
}
}
return NPERR_NO_ERROR;
}
NPError
NPP_Destroy(NPP instance, NPSavedData** save)
{
PluginInstance* This;
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
This = (PluginInstance*) instance->pdata;
if (This != NULL) {
if (This->dialogBox)
destroyWidget(This);
if (This->type)
NPN_MemFree(This->type);
if (This->pluginsPageUrl)
NPN_MemFree(This->pluginsPageUrl);
if (This->pluginsFileUrl)
NPN_MemFree(This->pluginsFileUrl);
NPN_MemFree(instance->pdata);
instance->pdata = NULL;
}
return NPERR_NO_ERROR;
}
NPError
NPP_SetWindow(NPP instance, NPWindow* window)
{
PluginInstance* This;
NPSetWindowCallbackStruct *ws_info;
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
This = (PluginInstance*) instance->pdata;
if (This == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
#ifdef MOZ_X11
if (This->window == (Window) window->window) {
/* The page with the plugin is being resized.
Save any UI information because the next time
around expect a SetWindow with a new window
id.
*/
#ifdef DEBUG
fprintf(stderr, "Nullplugin: plugin received window resize.\n");
fprintf(stderr, "Window=(%i)\n", (int)window);
if (window) {
fprintf(stderr, "W=(%i) H=(%i)\n",
(int)window->width, (int)window->height);
}
#endif
return NPERR_NO_ERROR;
} else {
This->window = (Window) window->window;
This->x = window->x;
This->y = window->y;
This->width = window->width;
This->height = window->height;
This->display = ws_info->display;
This->visual = ws_info->visual;
This->depth = ws_info->depth;
This->colormap = ws_info->colormap;
makePixmap(This);
makeWidget(This);
}
#endif /* #ifdef MOZ_X11 */
return NPERR_NO_ERROR;
}
NPError
NPP_NewStream(NPP instance,
NPMIMEType type,
NPStream *stream,
NPBool seekable,
uint16 *stype)
{
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
return NPERR_NO_ERROR;
}
int32
NPP_WriteReady(NPP instance, NPStream *stream)
{
/***** Insert NPP_WriteReady code here *****\
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
\*******************************************/
/* Number of bytes ready to accept in NPP_Write() */
return -1L; /* don't accept any bytes in NPP_Write() */
}
int32
NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
/***** Insert NPP_Write code here *****\
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
\**************************************/
return -1; /* tell the browser to abort the stream, don't need it */
}
NPError
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
{
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
/***** Insert NPP_DestroyStream code here *****\
PluginInstance* This;
This = (PluginInstance*) instance->pdata;
\**********************************************/
return NPERR_NO_ERROR;
}
void
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
{
/***** Insert NPP_StreamAsFile code here *****\
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
\*********************************************/
}
void
NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData)
{
/***** Insert NPP_URLNotify code here *****\
PluginInstance* This;
if (instance != NULL)
This = (PluginInstance*) instance->pdata;
\*********************************************/
}
void
NPP_Print(NPP instance, NPPrint* printInfo)
{
if(printInfo == NULL)
return;
if (instance != NULL) {
/***** Insert NPP_Print code here *****\
PluginInstance* This = (PluginInstance*) instance->pdata;
\**************************************/
if (printInfo->mode == NP_FULL) {
/*
* PLUGIN DEVELOPERS:
* If your plugin would like to take over
* printing completely when it is in full-screen mode,
* set printInfo->pluginPrinted to TRUE and print your
* plugin as you see fit. If your plugin wants Netscape
* to handle printing in this case, set
* printInfo->pluginPrinted to FALSE (the default) and
* do nothing. If you do want to handle printing
* yourself, printOne is true if the print button
* (as opposed to the print menu) was clicked.
* On the Macintosh, platformPrint is a THPrint; on
* Windows, platformPrint is a structure
* (defined in npapi.h) containing the printer name, port,
* etc.
*/
/***** Insert NPP_Print code here *****\
void* platformPrint =
printInfo->print.fullPrint.platformPrint;
NPBool printOne =
printInfo->print.fullPrint.printOne;
\**************************************/
/* Do the default*/
printInfo->print.fullPrint.pluginPrinted = FALSE;
}
else { /* If not fullscreen, we must be embedded */
/*
* PLUGIN DEVELOPERS:
* If your plugin is embedded, or is full-screen
* but you returned false in pluginPrinted above, NPP_Print
* will be called with mode == NP_EMBED. The NPWindow
* in the printInfo gives the location and dimensions of
* the embedded plugin on the printed page. On the
* Macintosh, platformPrint is the printer port; on
* Windows, platformPrint is the handle to the printing
* device context.
*/
/***** Insert NPP_Print code here *****\
NPWindow* printWindow =
&(printInfo->print.embedPrint.window);
void* platformPrint =
printInfo->print.embedPrint.platformPrint;
\**************************************/
}
}
}

View File

@@ -1,507 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stephen Mak <smak@sun.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* npunix.c
*
* Netscape Client Plugin API
* - Wrapper function to interface with the Netscape Navigator
*
* dp Suresh <dp@netscape.com>
*
*----------------------------------------------------------------------
* PLUGIN DEVELOPERS:
* YOU WILL NOT NEED TO EDIT THIS FILE.
*----------------------------------------------------------------------
*/
#define XP_UNIX 1
#include <stdio.h>
#include "npapi.h"
#include "npupp.h"
/*
* Define PLUGIN_TRACE to have the wrapper functions print
* messages to stderr whenever they are called.
*/
#ifdef PLUGIN_TRACE
#include <stdio.h>
#define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
#else
#define PLUGINDEBUGSTR(msg)
#endif
/***********************************************************************
*
* Globals
*
***********************************************************************/
static NPNetscapeFuncs gNetscapeFuncs; /* Netscape Function table */
/***********************************************************************
*
* Wrapper functions : plugin calling Netscape Navigator
*
* These functions let the plugin developer just call the APIs
* as documented and defined in npapi.h, without needing to know
* about the function table and call macros in npupp.h.
*
***********************************************************************/
void
NPN_Version(int* plugin_major, int* plugin_minor,
int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
/* Major version is in high byte */
*netscape_major = gNetscapeFuncs.version >> 8;
/* Minor version is in low byte */
*netscape_minor = gNetscapeFuncs.version & 0xFF;
}
NPError
NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
{
return CallNPN_GetValueProc(gNetscapeFuncs.getvalue,
instance, variable, r_value);
}
NPError
NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
return CallNPN_SetValueProc(gNetscapeFuncs.setvalue,
instance, variable, value);
}
NPError
NPN_GetURL(NPP instance, const char* url, const char* window)
{
return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
}
NPError
NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
{
return CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
}
NPError
NPN_PostURL(NPP instance, const char* url, const char* window,
uint32 len, const char* buf, NPBool file)
{
return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance,
url, window, len, buf, file);
}
NPError
NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len,
const char* buf, NPBool file, void* notifyData)
{
return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify,
instance, url, window, len, buf, file, notifyData);
}
NPError
NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return CallNPN_RequestReadProc(gNetscapeFuncs.requestread,
stream, rangeList);
}
NPError
NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
NPStream** stream_ptr)
{
return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance,
type, window, stream_ptr);
}
int32
NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
{
return CallNPN_WriteProc(gNetscapeFuncs.write, instance,
stream, len, buffer);
}
NPError
NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream,
instance, stream, reason);
}
void
NPN_Status(NPP instance, const char* message)
{
CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
}
const char*
NPN_UserAgent(NPP instance)
{
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
}
void*
NPN_MemAlloc(uint32 size)
{
return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
}
void NPN_MemFree(void* ptr)
{
CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
}
uint32 NPN_MemFlush(uint32 size)
{
return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
}
#ifdef OJI
JRIEnv* NPN_GetJavaEnv()
{
return CallNPN_GetJavaEnvProc(gNetscapeFuncs.getJavaEnv);
}
jref NPN_GetJavaPeer(NPP instance)
{
return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer,
instance);
}
#endif
void
NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance,
invalidRect);
}
void
NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance,
invalidRegion);
}
void
NPN_ForceRedraw(NPP instance)
{
CallNPN_ForceRedrawProc(gNetscapeFuncs.forceredraw, instance);
}
/***********************************************************************
*
* Wrapper functions : Netscape Navigator -> plugin
*
* These functions let the plugin developer just create the APIs
* as documented and defined in npapi.h, without needing to
* install those functions in the function table or worry about
* setting up globals for 68K plugins.
*
***********************************************************************/
NPError
Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
NPError ret;
PLUGINDEBUGSTR("New");
ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
return ret;
}
NPError
Private_Destroy(NPP instance, NPSavedData** save)
{
PLUGINDEBUGSTR("Destroy");
return NPP_Destroy(instance, save);
}
NPError
Private_SetWindow(NPP instance, NPWindow* window)
{
NPError err;
PLUGINDEBUGSTR("SetWindow");
err = NPP_SetWindow(instance, window);
return err;
}
NPError
Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
NPBool seekable, uint16* stype)
{
NPError err;
PLUGINDEBUGSTR("NewStream");
err = NPP_NewStream(instance, type, stream, seekable, stype);
return err;
}
int32
Private_WriteReady(NPP instance, NPStream* stream)
{
unsigned int result;
PLUGINDEBUGSTR("WriteReady");
result = NPP_WriteReady(instance, stream);
return result;
}
int32
Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
void* buffer)
{
unsigned int result;
PLUGINDEBUGSTR("Write");
result = NPP_Write(instance, stream, offset, len, buffer);
return result;
}
void
Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
{
PLUGINDEBUGSTR("StreamAsFile");
NPP_StreamAsFile(instance, stream, fname);
}
NPError
Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
NPError err;
PLUGINDEBUGSTR("DestroyStream");
err = NPP_DestroyStream(instance, stream, reason);
return err;
}
void
Private_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData)
{
PLUGINDEBUGSTR("URLNotify");
NPP_URLNotify(instance, url, reason, notifyData);
}
void
Private_Print(NPP instance, NPPrint* platformPrint)
{
PLUGINDEBUGSTR("Print");
NPP_Print(instance, platformPrint);
}
#ifdef OJI
JRIGlobalRef
Private_GetJavaClass(void)
{
jref clazz = NPP_GetJavaClass();
if (clazz) {
JRIEnv* env = NPN_GetJavaEnv();
return JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
#endif
/***********************************************************************
*
* These functions are located automagically by netscape.
*
***********************************************************************/
/*
* NP_GetMIMEDescription
* - Netscape needs to know about this symbol
* - Netscape uses the return value to identify when an object instance
* of this plugin should be created.
*/
char *
NP_GetMIMEDescription(void)
{
return NPP_GetMIMEDescription();
}
/*
* NP_GetValue [optional]
* - Netscape needs to know about this symbol.
* - Interfaces with plugin to get values for predefined variables
* that the navigator needs.
*/
NPError
NP_GetValue(void* future, NPPVariable variable, void *value)
{
return NPP_GetValue(future, variable, value);
}
/*
* NP_Initialize
* - Netscape needs to know about this symbol.
* - It calls this function after looking up its symbol before it
* is about to create the first ever object of this kind.
*
* PARAMETERS
* nsTable - The netscape function table. If developers just use these
* wrappers, they dont need to worry about all these function
* tables.
* RETURN
* pluginFuncs
* - This functions needs to fill the plugin function table
* pluginFuncs and return it. Netscape Navigator plugin
* library will use this function table to call the plugin.
*
*/
NPError
NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
{
NPError err = NPERR_NO_ERROR;
PLUGINDEBUGSTR("NP_Initialize");
/* validate input parameters */
if ((nsTable == NULL) || (pluginFuncs == NULL))
err = NPERR_INVALID_FUNCTABLE_ERROR;
/*
* Check the major version passed in Netscape's function table.
* We won't load if the major version is newer than what we expect.
* Also check that the function tables passed in are big enough for
* all the functions we need (they could be bigger, if Netscape added
* new APIs, but that's OK with us -- we'll just ignore them).
*
*/
if (err == NPERR_NO_ERROR) {
if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
if (nsTable->size < sizeof(NPNetscapeFuncs))
err = NPERR_INVALID_FUNCTABLE_ERROR;
if (pluginFuncs->size < sizeof(NPPluginFuncs))
err = NPERR_INVALID_FUNCTABLE_ERROR;
}
if (err == NPERR_NO_ERROR) {
/*
* Copy all the fields of Netscape function table into our
* copy so we can call back into Netscape later. Note that
* we need to copy the fields one by one, rather than assigning
* the whole structure, because the Netscape function table
* could actually be bigger than what we expect.
*/
gNetscapeFuncs.version = nsTable->version;
gNetscapeFuncs.size = nsTable->size;
gNetscapeFuncs.posturl = nsTable->posturl;
gNetscapeFuncs.geturl = nsTable->geturl;
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
gNetscapeFuncs.requestread = nsTable->requestread;
gNetscapeFuncs.newstream = nsTable->newstream;
gNetscapeFuncs.write = nsTable->write;
gNetscapeFuncs.destroystream = nsTable->destroystream;
gNetscapeFuncs.status = nsTable->status;
gNetscapeFuncs.uagent = nsTable->uagent;
gNetscapeFuncs.memalloc = nsTable->memalloc;
gNetscapeFuncs.memfree = nsTable->memfree;
gNetscapeFuncs.memflush = nsTable->memflush;
gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
#ifdef OJI
gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
#endif
gNetscapeFuncs.getvalue = nsTable->getvalue;
/*
* Set up the plugin function table that Netscape will use to
* call us. Netscape needs to know about our version and size
* and have a UniversalProcPointer for every function we
* implement.
*/
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
pluginFuncs->size = sizeof(NPPluginFuncs);
pluginFuncs->newp = NewNPP_NewProc(Private_New);
pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
pluginFuncs->write = NewNPP_WriteProc(Private_Write);
pluginFuncs->print = NewNPP_PrintProc(Private_Print);
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
pluginFuncs->event = NULL;
#ifdef OJI
pluginFuncs->javaClass = Private_GetJavaClass();
#endif
err = NPP_Initialize();
}
return err;
}
/*
* NP_Shutdown [optional]
* - Netscape needs to know about this symbol.
* - It calls this function after looking up its symbol after
* the last object of this kind has been destroyed.
*
*/
NPError
NP_Shutdown(void)
{
PLUGINDEBUGSTR("NP_Shutdown");
NPP_Shutdown();
return NPERR_NO_ERROR;
}

View File

@@ -1,502 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stephen Mak <smak@sun.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* nullplugin.c
*
* Implementation of the null plugins for Unix.
*
* dp <dp@netscape.com>
* updated 5/1998 <pollmann@netscape.com>
* updated 9/2000 <smak@sun.com>
*
*/
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
/* Xlib/Xt stuff */
#ifdef MOZ_X11
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/cursorfont.h>
#endif
#include "npapi.h"
#include "nullplugin.h"
#include "prprf.h"
#define DIALOGID "dialog"
/* Global data */
static MimeTypeElement *head = NULL;
/* destroy the dialog box */
void
destroyWidget(PluginInstance *This)
{
if (This && This->dialogBox)
{
gtk_widget_destroy (GTK_WIDGET(This->dialogBox));
}
}
/* callback function for the OK button */
static void
DialogOKClicked (GtkButton *button, gpointer data)
{
PluginInstance* This = (PluginInstance*) data;
GtkWidget* dialogWindow = gtk_object_get_data(GTK_OBJECT(button), DIALOGID);
char *url;
gtk_object_remove_data(GTK_OBJECT(button), DIALOGID);
if (This->pluginsFileUrl != NULL)
{
/* Get the JavaScript command string */
static const char buf[] =
"javascript:netscape.softupdate.Trigger.StartSoftwareUpdate(\"%s\")";
url = NPN_MemAlloc(strlen(This->pluginsFileUrl) + (sizeof(buf) - 2));
if (url != NULL)
{
/* Insert the file URL into the JavaScript command */
sprintf(url, buf, This->pluginsFileUrl);
NPN_GetURL(This->instance, url, TARGET);
NPN_MemFree(url);
}
}
else
{
/* If necessary, get the default plug-ins page resource */
char* address = This->pluginsPageUrl;
if (address == NULL || *address == 0)
{
address = PLUGINSPAGE_URL;
}
url = NPN_MemAlloc(strlen(address) + 1 + strlen(This->type)+1);
if (url != NULL)
{
/* Append the MIME type to the URL */
sprintf(url, "%s?%s", address, This->type);
if (strcmp (This->type, JVM_MINETYPE) == 0)
{
NPN_GetURL(This->instance, JVM_SMARTUPDATE_URL , TARGET);
}
else
{
NPN_GetURL(This->instance, url, TARGET);
}
NPN_MemFree(url);
}
}
destroyWidget(This);
}
/* the call back function for cancel button */
static void
DialogCancelClicked (GtkButton *button, gpointer data)
{
destroyWidget((PluginInstance*) data);
}
/* function that closes the dialog if ESC is pressed */
static gboolean
DialogEscapePressed (GtkWidget *widget, GdkEventKey *event, gpointer data)
{
if (event->keyval == GDK_Escape)
{
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
gtk_object_destroy (GTK_OBJECT (widget));
return TRUE;
}
return FALSE;
}
/* a handy procedure to add a widget and pack it as well */
static GtkWidget *
AddWidget (GtkWidget *widget, GtkWidget *packingbox)
{
gtk_box_pack_start(GTK_BOX(packingbox), widget, TRUE, TRUE, 2);
return widget;
}
/* MIMETypeList maintenance routines */
static gboolean
isEqual(NPMIMEType t1, NPMIMEType t2)
{
return (t1 && t2) ? (strcmp(t1, t2) == 0) : FALSE;
}
static MimeTypeElement *
isExist(MimeTypeElement **typelist, NPMIMEType type)
{
MimeTypeElement *ele;
ele = *typelist;
while (ele != NULL) {
if (isEqual(ele->pinst->type, type))
return ele;
ele = ele->next;
}
return NULL;
}
NPMIMEType
dupMimeType(NPMIMEType type)
{
NPMIMEType mimetype = NPN_MemAlloc(strlen(type)+1);
if (mimetype)
strcpy(mimetype, type);
return(mimetype);
}
static gboolean
addToList(MimeTypeElement **typelist, PluginInstance *This)
{
if (This && This->type && !isExist(typelist, This->type))
{
MimeTypeElement *ele;
if ((ele = (MimeTypeElement *) NPN_MemAlloc(sizeof(MimeTypeElement))))
{
ele->pinst = This;
ele->next = *typelist;
*typelist = ele;
return(TRUE);
}
}
return(FALSE);
}
static gboolean
delFromList(MimeTypeElement **typelist, PluginInstance *This)
{
if (typelist && This)
{
MimeTypeElement *ele_prev;
MimeTypeElement *ele = *typelist;
while (ele)
{
if (isEqual(ele->pinst->type, This->type))
{
if (*typelist == ele)
{
*typelist = ele->next;
} else {
ele_prev->next = ele->next;
}
NPN_MemFree(ele);
return(TRUE);
}
ele_prev = ele;
ele = ele->next;
}
}
return(FALSE);
}
static void
onDestroyWidget(GtkWidget *w, gpointer data)
{
PluginInstance* This = (PluginInstance*) data;
if (This && This->dialogBox && This->dialogBox == w)
{
This->dialogBox = 0;
delFromList(&head, This);
}
}
/* create and display the dialog box */
void
makeWidget(PluginInstance *This)
{
GtkWidget *dialogWindow;
GtkWidget *dialogMessage;
GtkWidget *okButton;
GtkWidget *cancelButton;
char message[1024];
MimeTypeElement *ele;
if (!This) return;
/* need to check whether we already pop up a dialog box for previous
minetype in the same web page. It's require otherwise there will
be 2 dialog boxes pop if there are 2 plugin in the same web page
*/
if ((ele = isExist(&head, This->type)))
{
if (ele->pinst && ele->pinst->dialogBox)
{
GtkWidget *top_window = gtk_widget_get_toplevel(ele->pinst->dialogBox);
if (top_window && GTK_WIDGET_VISIBLE(top_window))
{ /* this will raise the toplevel window */
gdk_window_show(top_window->window);
}
}
return;
}
dialogWindow = gtk_dialog_new();
This->dialogBox = dialogWindow;
This->exists = TRUE;
This->dialogBox = dialogWindow;
addToList(&head, This);
gtk_window_set_title(GTK_WINDOW(dialogWindow), PLUGIN_NAME);
gtk_window_set_position(GTK_WINDOW(dialogWindow), GTK_WIN_POS_CENTER);
gtk_window_set_modal(GTK_WINDOW(dialogWindow), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(dialogWindow), 20);
gtk_window_set_policy(GTK_WINDOW(dialogWindow), FALSE, FALSE, TRUE);
PR_snprintf(message, sizeof(message) - 1, MESSAGE, This->type);
dialogMessage = AddWidget(gtk_label_new (message),
GTK_DIALOG(dialogWindow)->vbox);
okButton= AddWidget(gtk_button_new_with_label (OK_BUTTON),
GTK_DIALOG(dialogWindow)->action_area);
gtk_object_set_data(GTK_OBJECT(okButton), DIALOGID, dialogWindow);
GTK_WIDGET_SET_FLAGS (okButton, GTK_CAN_DEFAULT);
gtk_widget_grab_default(okButton);
cancelButton= AddWidget(gtk_button_new_with_label (CANCEL_BUTTON),
GTK_DIALOG(dialogWindow)->action_area);
gtk_signal_connect (GTK_OBJECT(okButton), "clicked",
GTK_SIGNAL_FUNC(DialogOKClicked), This);
gtk_signal_connect (GTK_OBJECT(cancelButton), "clicked",
GTK_SIGNAL_FUNC(DialogCancelClicked), This);
gtk_signal_connect(GTK_OBJECT(dialogWindow), "key_press_event",
GTK_SIGNAL_FUNC (DialogEscapePressed), NULL);
/* hookup to when the dialog is destroyed */
gtk_signal_connect(GTK_OBJECT(dialogWindow), "destroy",
GTK_SIGNAL_FUNC(onDestroyWidget), This);
gtk_widget_show_all(dialogWindow);
}
/* XPM */
static char * npnul320_xpm[] = {
"32 32 6 1",
" c None",
". c #808080",
"+ c #F8F8F8",
"@ c #C0C0C0",
"# c #000000",
"$ c #00F8F8",
"........................++++++++",
".++++++++++++++++++++++..+++++++",
".+++++++++++++++++++++@.@.++++++",
".++@@@@@@@@@@@@@@@@@@@@.+@.+++++",
".++@@@@@@@@@.....@@@@@@.++@.++++",
".++@@@@@@@@.+++++#@@@@@.+++@.+++",
".++@@@@@@@.++$$$$$#@@@@.++++@.++",
".++@@@@@@@.+$$$$$$#.@@@.+++++@.+",
".++@@@...@@.+$$$$#..###.#######+",
".++@@.+++$$++$$$$$##++$#......#+",
".++@@.+$$$++$$$$$$$+$$$#......#+",
".++@@.+$$$$$$$$$$$$$$$$#..@@++#+",
".++@@@$$$$$$$$$$$$$$$$#...@@++#+",
".++@@@$#$##.$$$$$$##$$#...@@++#+",
".++@@@@##...$$$$$#..##...@@@++#+",
".++@@@@@....+$$$$#.......@@@++#+",
".++@@@@@@...+$$$$#.@@@..@@@@++#+",
".++@@@@..@@.+$$$$#.@##@@@@@@++#+",
".++@@@.++$$++$$$$$##$$#@@@@@++#+",
".++@@@.+$$++$$$$$$$$$$#@@@@@++#+",
".++@@.++$$$$$$$$$$$$$$$#@@@@++#+",
".++@@.+$$$$$$$$$$$$$$$$#.@@@++#+",
".++@@.+$$##$$$$$$$##$$$#..@@++#+",
".++@@@###...$$$$$#.@###...@@++#+",
".++@@@@....$$$$$$$#.@.....@@++#+",
".++@@@@@...$$$$$$$#..@...@@@++#+",
".++@@@@@@@@#$$$$$#...@@@@@@@++#+",
".++@@@@@@@@@#####...@@@@@@@@++#+",
".++@@@@@@@@@@......@@@@@@@@@++#+",
".+++++++++++++....++++++++++++#+",
".+++++++++++++++++++++++++++++#+",
"###############################+"};
static GdkPixmap *nullPluginGdkPixmap = 0;
static GdkWindow *getGdkWindow(PluginInstance *This)
{
#ifdef MOZ_X11
GdkWindow *gdk_window;
Window xwin = (Window) This->window;
Widget xt_w = XtWindowToWidget(This->display, xwin);
if (xt_w) {
xt_w = XtParent(xt_w);
if (xt_w) {
xwin = XtWindow(xt_w);
/* xwin = xt_w->core.window; */
}
}
gdk_window = gdk_window_lookup(xwin);
return gdk_window;
#else
return NULL;
#endif
}
static void
createPixmap(PluginInstance *This)
{
int err = 0;
if (nullPluginGdkPixmap == 0)
{
GtkStyle *style;
GdkBitmap *mask;
GdkWindow *gdk_window = getGdkWindow(This);
if (gdk_window)
{
GtkWidget *widget;
#ifndef MOZ_WIDGET_GTK2
widget = (GtkWidget *)gdk_window->user_data;
#else
gpointer user_data = NULL;
gdk_window_get_user_data( gdk_window, &user_data);
widget = GTK_WIDGET(user_data);
#endif
style = gtk_widget_get_style(widget);
nullPluginGdkPixmap = gdk_pixmap_create_from_xpm_d(gdk_window , &mask,
&style->bg[GTK_STATE_NORMAL], npnul320_xpm);
#ifdef MOZ_X11
/* Pixmap is created on original X session but used by new session */
XSync(GDK_DISPLAY(), False);
#endif
}
}
}
static void
drawPixmap(PluginInstance *This)
{
if (nullPluginGdkPixmap)
{
int pixmap_with, pixmap_height, dest_x, dest_y;
gdk_window_get_size((GdkWindow *)nullPluginGdkPixmap, &pixmap_with, &pixmap_height);
dest_x = This->width/2 - pixmap_with/2;
dest_y = This->height/2 - pixmap_height/2;
if (dest_x >= 0 && dest_y >= 0)
{
#ifdef MOZ_X11
GC gc;
gc = XCreateGC(This->display, This->window, 0, NULL);
XCopyArea(This->display, GDK_WINDOW_XWINDOW(nullPluginGdkPixmap) , This->window, gc,
0, 0, pixmap_with, pixmap_height, dest_x, dest_y);
XFreeGC(This->display, gc);
#endif
}
}
}
static void
setCursor (PluginInstance *This)
{
#ifdef MOZ_X11
static Cursor nullPluginCursor = 0;
if (!nullPluginCursor)
{
nullPluginCursor = XCreateFontCursor(This->display, XC_hand2);
}
if (nullPluginCursor)
{
XDefineCursor(This->display, This->window, nullPluginCursor);
}
#endif
}
#ifdef MOZ_X11
static void
xt_event_handler(Widget xt_w, PluginInstance *This, XEvent *xevent, Boolean *b)
{
switch (xevent->type)
{
case Expose:
/* get rid of all other exposure events */
while(XCheckTypedWindowEvent(This->display, This->window, Expose, xevent));
drawPixmap(This);
break;
case ButtonRelease:
makeWidget(This);
break;
default:
break;
}
}
#endif
static void
addXtEventHandler(PluginInstance *This)
{
#ifdef MOZ_X11
Display *dpy = (Display*) This->display;
Window xwin = (Window) This->window;
Widget xt_w = XtWindowToWidget(dpy, xwin);
if (xt_w)
{
long event_mask = ExposureMask | ButtonReleaseMask | ButtonPressMask;
XSelectInput(dpy, xwin, event_mask);
XtAddEventHandler(xt_w, event_mask, False, (XtEventHandler)xt_event_handler, This);
}
#endif
}
void
makePixmap(PluginInstance *This)
{
createPixmap(This);
drawPixmap(This);
setCursor(This);
addXtEventHandler(This);
}

View File

@@ -1,122 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stephen Mak <smak@sun.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* nullplugin.h
*
* Implementation of the null plugins for Unix.
*
* dp <dp@netscape.com>
* updated 5/1998 <pollmann@netscape.com>
* updated 9/2000 <smak@sun.com>
*
*/
#define TARGET "_blank"
#define MIME_TYPES_HANDLED "*:.*:All types"
#define PLUGIN_NAME "Default Plugin"
#define PLUGIN_DESCRIPTION "The default plugin handles plugin data for mimetypes and extensions that are not specified and facilitates downloading of new plugins."
#define CLICK_TO_GET "Click here to get the plugin"
#define CLICK_WHEN_DONE "Click here after installing the plugin"
#define REFRESH_PLUGIN_LIST "javascript:navigator.plugins.refresh(true)"
#define PLUGINSPAGE_URL "http://plugins.netscape.com/plug-in_finder.adp" /* XXX Branding: make configurable via .properties or prefs */
#define OK_BUTTON "OK"
#define CANCEL_BUTTON "CANCEL"
#if defined(HPUX)
#define JVM_SMARTUPDATE_URL "http://www.hp.com/go/java"
#elif defined(VMS)
#define JVM_SMARTUPDATE_URL "http://www.openvms.compaq.com/openvms/products/ips/mozilla_relnotes.html#java"
#else
#define JVM_SMARTUPDATE_URL "http://home.netscape.com/plugins/jvm.html" /* XXX Branding: see above */
#endif /* HPUX */
#define JVM_MINETYPE "application/x-java-vm"
#define MESSAGE "\
This page contains information of a type (%s) that can\n\
only be viewed with the appropriate Plug-in.\n\
\n\
Click OK to download Plugin."
#define GET 1
#define REFRESH 2
#include <gtk/gtk.h>
typedef struct _PluginInstance
{
uint16 mode;
#ifdef MOZ_X11
Window window;
Display *display;
#endif
uint32 x, y;
uint32 width, height;
NPMIMEType type;
char *message;
NPP instance;
char *pluginsPageUrl;
char *pluginsFileUrl;
NPBool pluginsHidden;
#ifdef MOZ_X11
Visual* visual;
Colormap colormap;
#endif
unsigned int depth;
GtkWidget* dialogBox;
NPBool exists; /* Does the widget already exist? */
int action; /* What action should we take? (GET or REFRESH) */
} PluginInstance;
typedef struct _MimeTypeElement
{
PluginInstance *pinst;
struct _MimeTypeElement *next;
} MimeTypeElement;
/* Extern functions */
extern void makeWidget(PluginInstance *This);
extern NPMIMEType dupMimeType(NPMIMEType type);
extern void destroyWidget(PluginInstance *This);
extern void makePixmap(PluginInstance *This);
extern void destroyPixmap();

View File

@@ -1,85 +0,0 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 2001 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = plugin
LIBRARY_NAME = npnul32
RESFILE = npnul32.res
DEFFILE = $(srcdir)/npnul32.def
GRE_MODULE = 1
PACKAGE_FILE = npnul.pkg
REQUIRES = java \
xpcom \
pref \
$(NULL)
CPPSRCS = \
maindll.cpp \
plugin.cpp \
dbg.cpp \
dialogs.cpp \
npshell.cpp \
npwin.cpp \
utils.cpp \
$(NULL)
LOCAL_INCLUDES = -I$(srcdir)
# plugins should always be shared, even in the "static" build
FORCE_SHARED_LIB = 1
# Force use of PIC
FORCE_USE_PIC = 1
NO_DIST_INSTALL = 1
NO_INSTALL = 1
include $(topsrcdir)/config/rules.mk
_OS_LIBS = version
ifdef GNU_CC
CXXFLAGS += -fexceptions
_OS_LIBS += gdi32
else
CXXFLAGS += -GX
endif
OS_LIBS += $(call EXPAND_LIBNAME,$(_OS_LIBS))
install-plugin: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
$(INSTALL) $(SHARED_LIBRARY) $(DIST)/bin/plugins
endif
libs:: install-plugin
install:: $(SHARED_LIBRARY)
ifdef SHARED_LIBRARY
$(SYSINSTALL) $(IFLAGS2) $< $(DESTDIR)$(mozappdir)/plugins
endif

View File

@@ -1,157 +0,0 @@
# Microsoft Developer Studio Project File - Name="Npnul32" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=Npnul32 - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Npnul32.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Npnul32.mak" CFG="Npnul32 - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Npnul32 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Npnul32 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Npnul32 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\WinRel"
# PROP BASE Intermediate_Dir ".\WinRel"
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir ".\Release"
# PROP Intermediate_Dir ".\Release"
# PROP Ignore_Export_Lib 0
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FR /YX /c
# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /I "..\..\..\..\..\dist\include\xpcom" /I "..\..\..\..\..\dist\include\pref" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
# SUBTRACT CPP /Fr /YX
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib /nologo /subsystem:windows /dll /machine:I386
!ELSEIF "$(CFG)" == "Npnul32 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\WinDebug"
# PROP BASE Intermediate_Dir ".\WinDebug"
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir ".\Debug"
# PROP Intermediate_Dir ".\Debug"
# PROP Ignore_Export_Lib 0
# ADD BASE CPP /nologo /MT /W3 /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /I "..\..\..\..\..\dist\include\xpcom" /I "..\..\..\..\..\dist\include\pref" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FD /c
# SUBTRACT CPP /Fr /YX
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib advapi32.lib libc.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib /out:"..\..\..\..\..\dist\bin\Plugins\Npnul32.dll"
!ENDIF
# Begin Target
# Name "Npnul32 - Win32 Release"
# Name "Npnul32 - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\dbg.cpp
# End Source File
# Begin Source File
SOURCE=.\dialogs.cpp
# End Source File
# Begin Source File
SOURCE=.\maindll.cpp
# End Source File
# Begin Source File
SOURCE=.\npnul32.def
# End Source File
# Begin Source File
SOURCE=.\npnul32.rc
# End Source File
# Begin Source File
SOURCE=.\npshell.cpp
# End Source File
# Begin Source File
SOURCE=.\npwin.cpp
# End Source File
# Begin Source File
SOURCE=.\plugin.cpp
# End Source File
# Begin Source File
SOURCE=.\utils.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\dbg.h
# End Source File
# Begin Source File
SOURCE=.\dialogs.h
# End Source File
# Begin Source File
SOURCE=.\plugin.h
# End Source File
# Begin Source File
SOURCE=.\utils.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\plugicon.ico
# End Source File
# End Group
# End Target
# End Project

View File

@@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
extern char szAppName[];
#ifdef _DEBUG
void __cdecl dbgOut(LPSTR format, ...) {
static char buf[1024];
lstrcpy(buf, szAppName);
lstrcat(buf, ": ");
va_list va;
va_start(va, format);
wvsprintf(&buf[lstrlen(buf)], format, va);
va_end(va);
lstrcat(buf, "\n");
OutputDebugString(buf);
}
#endif

View File

@@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __DBG_HPP_
#define __DBG_HPP_
#ifdef _DEBUG
void __cdecl dbgOut(LPSTR format, ...);
#define dbgOut1(x) dbgOut(x)
#define dbgOut2(x,y) dbgOut(x, y)
#define dbgOut3(x,y,z) dbgOut(x, y, z)
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
#else
#define dbgOut1(x) ((void)0)
#define dbgOut2(x,y) ((void)0)
#define dbgOut3(x,y,z) ((void)0)
#define dbgOut4(x,y,z,t) ((void)0)
#define dbgOut5(x,y,z,t,u) ((void)0)
#define dbgOut6(x,y,z,t,u,v) ((void)0)
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
#endif
#endif

View File

@@ -1,198 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#include <windowsx.h>
#include <assert.h>
#include "resource.h"
#include "plugin.h"
#include "utils.h"
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
static void onCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
{
CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
switch (id)
{
case IDC_GET_PLUGIN:
DestroyWindow(hWnd);
if(pPlugin !=NULL)
{
pPlugin->m_hWndDialog = NULL;
pPlugin->getPlugin();
}
break;
case IDCANCEL:
case IDC_BUTTON_CANCEL:
DestroyWindow(hWnd);
if(pPlugin !=NULL)
pPlugin->m_hWndDialog = NULL;
break;
default:
break;
}
}
static BOOL onInitDialog(HWND hWnd, HWND hWndFocus, LPARAM lParam)
{
CPlugin * pPlugin = (CPlugin *)lParam;
assert(pPlugin != NULL);
if(pPlugin == NULL)
return TRUE;
SetWindowLong(hWnd, DWL_USER, (LONG)pPlugin);
pPlugin->m_hWndDialog = hWnd;
char szString[512];
LoadString(hInst, IDS_TITLE, szString, sizeof(szString));
SetWindowText(hWnd, szString);
LoadString(hInst, IDS_INFO, szString, sizeof(szString));
SetDlgItemText(hWnd, IDC_STATIC_INFO, szString);
SetDlgItemText(hWnd, IDC_STATIC_INFOTYPE, (LPSTR)pPlugin->m_pNPMIMEType);
LoadString(hInst, IDS_LOCATION, szString, sizeof(szString));
SetDlgItemText(hWnd, IDC_STATIC_LOCATION, szString);
char contentTypeIsJava = 0;
if (NULL != pPlugin->m_pNPMIMEType) {
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
pPlugin->m_pNPMIMEType)) ? 1 : 0;
}
if(pPlugin->m_szPageURL == NULL || contentTypeIsJava)
LoadString(hInst, IDS_FINDER_PAGE, szString, sizeof(szString));
else
strncpy(szString, pPlugin->m_szPageURL,511); // defect #362738
SetDlgItemTextWrapped(hWnd, IDC_STATIC_URL, szString);
LoadString(hInst, IDS_QUESTION, szString, sizeof(szString));
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, szString);
SetDlgItemText(hWnd, IDC_STATIC_WARNING, "");
if(!pPlugin->m_bOnline)
{
EnableWindow(GetDlgItem(hWnd, IDC_GET_PLUGIN), FALSE);
LoadString(hInst, IDS_WARNING_OFFLINE, szString, sizeof(szString));
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
SetDlgItemText(hWnd, IDC_STATIC_QUESTION, "");
return TRUE;
}
if((!pPlugin->m_bJava) || (!pPlugin->m_bJavaScript) || (!pPlugin->m_bSmartUpdate))
{
LoadString(hInst, IDS_WARNING_JS, szString, sizeof(szString));
SetDlgItemText(hWnd, IDC_STATIC_WARNING, szString);
return TRUE;
}
ShowWindow(GetDlgItem(hWnd, IDC_STATIC_WARNING), SW_HIDE);
RECT rc;
GetWindowRect(GetDlgItem(hWnd, IDC_STATIC_WARNING), &rc);
int iHeight = rc.bottom - rc.top;
GetWindowRect(hWnd, &rc);
SetWindowPos(hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top - iHeight, SWP_NOZORDER | SWP_NOMOVE);
HWND hWndQuestion = GetDlgItem(hWnd, IDC_STATIC_QUESTION);
HWND hWndButtonGetPlugin = GetDlgItem(hWnd, IDC_GET_PLUGIN);
HWND hWndButtonCancel = GetDlgItem(hWnd, IDC_BUTTON_CANCEL);
POINT pt;
GetWindowRect(hWndQuestion, &rc);
pt.x = rc.left;
pt.y = rc.top;
ScreenToClient(hWnd, &pt);
SetWindowPos(hWndQuestion, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
GetWindowRect(hWndButtonGetPlugin, &rc);
pt.x = rc.left;
pt.y = rc.top;
ScreenToClient(hWnd, &pt);
SetWindowPos(hWndButtonGetPlugin, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
GetWindowRect(hWndButtonCancel, &rc);
pt.x = rc.left;
pt.y = rc.top;
ScreenToClient(hWnd, &pt);
SetWindowPos(hWndButtonCancel, NULL, pt.x, pt.y - iHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
if(pPlugin->m_bHidden)
SetForegroundWindow(hWnd);
return TRUE;
}
static void onClose(HWND hWnd)
{
DestroyWindow(hWnd);
}
static void onDestroy(HWND hWnd)
{
}
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
case WM_COMMAND:
HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
break;
case WM_DESTROY:
HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
break;
case WM_CLOSE:
HANDLE_WM_CLOSE(hWnd, wParam, lParam, onClose);
break;
default:
return FALSE;
}
return TRUE;
}

View File

@@ -1,43 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __DIALOGS_H__
#define __DIALOGS_H__
BOOL CALLBACK NP_LOADDS GetPluginDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
#endif __DIALOGS_H__

View File

@@ -1,46 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
HINSTANCE hInst; // global
BOOL WINAPI DllMain(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
{
hInst = hDLL;
return TRUE;
}

View File

@@ -1,4 +0,0 @@
# the null plugin goes in gecko-support because we search for plugins
# in the application, not the GRE
[gecko-support]
dist/bin/plugins/@SHARED_LIBRARY@

View File

@@ -1,7 +0,0 @@
LIBRARY NPNUL32
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3
NP_GetMIMEDescription @4

View File

@@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Npnul32"=.\Npnul32.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,187 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winresrc.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""winresrc.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_PLUGIN_DOWNLOAD DIALOG DISCARDABLE 0, 0, 225, 165
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Title"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Information on this page requires a plug-in for:",
IDC_STATIC_INFO,7,7,211,10
LTEXT "Communicator can retrieve the plug-in for you from:",
IDC_STATIC_LOCATION,7,32,211,8
DEFPUSHBUTTON "Get the Plug-in",IDC_GET_PLUGIN,41,144,64,14
PUSHBUTTON "Cancel",IDC_BUTTON_CANCEL,109,144,64,14
CTEXT "type/x-type",IDC_STATIC_INFOTYPE,7,18,211,8
LTEXT "The SmartUpdate feature makes it easy to install new plug-ins. To take advantage of SmartUpdate, you must enable Java, JavaScript and AutoInstall in the Advanced panel of the Preferences, then click the plug-in icon on the page.",
IDC_STATIC_WARNING,7,74,211,61
LTEXT "Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static Static ",
IDC_STATIC_URL,7,43,211,24
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,15
PRODUCTVERSION 1,0,0,15
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "mozilla.org\0"
VALUE "FileDescription", "Default Plug-in\0"
VALUE "FileExtents", "*\0"
VALUE "FileOpenName", "Mozilla Default Plug-in (*.*)\0"
VALUE "FileVersion", "1, 0, 0, 15\0"
VALUE "InternalName", "DEFPLUGIN\0"
VALUE "LegalCopyright", "Copyright © 1995-2000\0"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "*\0"
VALUE "OriginalFilename", "NPNUL32.DLL\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Mozilla Default Plug-in\0"
VALUE "ProductVersion", "1, 0, 0, 15\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_PLUGICON ICON DISCARDABLE "plugicon.ico"
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_PLUGIN_DOWNLOAD, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 218
TOPMARGIN, 7
BOTTOMMARGIN, 158
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_INFO "Information on this page requires a plug-in for:"
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_LOCATION "Navigator can retrieve the plug-in for you from:"
IDS_TITLE "Plug-in Not Loaded"
IDS_QUESTION "What would you like to do?"
IDS_WARNING_JS "To retrieve the plug-in now, click the Get the Plug-in button and then select the plug-in you need from the page that appears. If you have trouble installing the plug-in, make sure that Java and JavaScript are enabled in Advanced preferences, and that software installation is enabled (in the Software Installation category under Advanced)."
IDS_WARNING_OFFLINE "However, you are currently offline. If you would like to get the plug-in, click Cancel, select ""Go Online"" from the File menu, then click the plug-in icon on the page."
IDS_FINDER_PAGE "Plug-in Finder page at Netscape.com"
IDS_CLICK_TO_GET "Click here to get the plugin"
IDS_CLICK_WHEN_DONE "After installing the plugin, click here."
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -1,330 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#include <assert.h>
#include "resource.h"
#include "plugin.h" // this includes npapi.h
#include "utils.h"
#include "dbg.h"
char szAppName[] = "NPNULL";
//---------------------------------------------------------------------------
// NPP_Initialize:
//---------------------------------------------------------------------------
NPError NPP_Initialize(void)
{
RegisterNullPluginWindowClass();
return NPERR_NO_ERROR;
}
//---------------------------------------------------------------------------
// NPP_Shutdown:
//---------------------------------------------------------------------------
void NPP_Shutdown(void)
{
UnregisterNullPluginWindowClass();
}
//---------------------------------------------------------------------------
// NPP_New:
//---------------------------------------------------------------------------
NPError NP_LOADDS NPP_New(NPMIMEType pluginType,
NPP pInstance,
uint16 mode,
int16 argc,
char* argn[],
char* argv[],
NPSavedData* saved)
{
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
// See if the content provider specified from where to fetch the plugin
char * szPageURL = NULL;
char * szFileURL = NULL;
char * szFileExtension = NULL;
char * buf = NULL;
BOOL bHidden = FALSE;
for(int i = 0; i < argc; i++)
{
if(lstrcmpi(argn[i],"pluginspage") == 0 && argv[i] != NULL)
szPageURL = (char *)argv[i];
else if(lstrcmpi(argn[i],"codebase") == 0 && argv[i] != NULL)
szPageURL = (char *)argv[i];
else if(lstrcmpi(argn[i],"pluginurl") == 0 && argv[i] != NULL)
szFileURL = (char *)argv[i];
else if(lstrcmpi(argn[i],"classid") == 0 && argv[i] != NULL)
szFileURL = (char *)argv[i];
else if(lstrcmpi(argn[i],"SRC") == 0 && argv[i] != NULL)
buf = (char *)argv[i];
else if(lstrcmpi(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
bHidden = (lstrcmp((char *)argv[i], "TRUE") == 0);
}
/* some post-processing on the filename to attempt to extract the extension: */
if(buf != NULL)
{
buf = strrchr(buf, '.');
if(buf)
szFileExtension = ++buf;
}
CPlugin * pPlugin = new CPlugin(hInst,
pInstance,
mode,
pluginType,
szPageURL,
szFileURL,
szFileExtension,
bHidden);
if(pPlugin == NULL)
return NPERR_OUT_OF_MEMORY_ERROR;
if(bHidden)
{
if(!pPlugin->init(NULL))
{
delete pPlugin;
pPlugin = NULL;
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
pInstance->pdata = (void *)pPlugin;
return NPERR_NO_ERROR;
}
//---------------------------------------------------------------------------
// NPP_Destroy:
//---------------------------------------------------------------------------
NPError NP_LOADDS
NPP_Destroy(NPP pInstance, NPSavedData** save)
{
dbgOut1("NPP_Destroy");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
if(pPlugin != NULL)
{
pPlugin->shut();
delete pPlugin;
}
return NPERR_NO_ERROR;
}
//---------------------------------------------------------------------------
// NPP_SetWindow:
//---------------------------------------------------------------------------
NPError NP_LOADDS NPP_SetWindow(NPP pInstance, NPWindow * pNPWindow)
{
if(pInstance == NULL)
{
dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
return NPERR_INVALID_INSTANCE_ERROR;
}
if(pNPWindow == NULL)
{
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
return NPERR_GENERIC_ERROR;
}
HWND hWnd = (HWND)(DWORD)pNPWindow->window;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
if(pPlugin == NULL)
{
dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
return NPERR_GENERIC_ERROR;
}
if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
{
dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
return NPERR_NO_ERROR;
}
if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
{ // window went away
dbgOut1("NPP_SetWindow, going away...");
pPlugin->shut();
return NPERR_NO_ERROR;
}
if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
{ // First time in -- no window created by plugin yet
dbgOut1("NPP_SetWindow, first time");
if(!pPlugin->init(hWnd))
{
delete pPlugin;
pPlugin = NULL;
return NPERR_MODULE_LOAD_FAILED_ERROR;
}
}
if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
{ // Netscape window has been resized
dbgOut1("NPP_SetWindow, resizing");
pPlugin->resize();
}
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_NewStream:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_NewStream(NPP pInstance,
NPMIMEType type,
NPStream *stream,
NPBool seekable,
uint16 *stype)
{
dbgOut1("NPP_NewStream");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
if (!pPlugin)
return NPERR_GENERIC_ERROR;
return pPlugin->newStream(type, stream, seekable, stype);
}
//------------------------------------------------------------------------------------
// NPP_WriteReady:
//------------------------------------------------------------------------------------
int32 NP_LOADDS
NPP_WriteReady(NPP pInstance, NPStream *stream)
{
dbgOut1("NPP_WriteReady");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return -1L; // dont accept any bytes in NPP_Write()
}
//------------------------------------------------------------------------------------
// NPP_Write:
//------------------------------------------------------------------------------------
int32 NP_LOADDS
NPP_Write(NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
//dbgOut1("NPP_Write");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
return -1; // tell the browser to abort the stream, don't need it
}
//------------------------------------------------------------------------------------
// NPP_DestroyStream:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_DestroyStream(NPP pInstance, NPStream *stream, NPError reason)
{
dbgOut1("NPP_DestroyStream");
if(pInstance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
if (!pPlugin)
return NPERR_GENERIC_ERROR;
return pPlugin->destroyStream(stream, reason);
}
//------------------------------------------------------------------------------------
// NPP_StreamAsFile:
//------------------------------------------------------------------------------------
void NP_LOADDS
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
{
dbgOut1("NPP_StreamAsFile");
}
//------------------------------------------------------------------------------------
// NPP_Print:
//------------------------------------------------------------------------------------
void NP_LOADDS NPP_Print(NPP pInstance, NPPrint * printInfo)
{
dbgOut2("NPP_Print, printInfo = %#08x", printInfo);
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
pPlugin->print(printInfo);
}
void NP_LOADDS NPP_URLNotify(NPP pInstance, const char* url, NPReason reason, void* notifyData)
{
dbgOut2("NPP_URLNotify, URL '%s'", url);
CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
assert(pPlugin != NULL);
pPlugin->URLNotify(url);
}
#ifdef OJI
jref NP_LOADDS NPP_GetJavaClass(void)
{
return NULL;
}
#endif

View File

@@ -1,358 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _NPAPI_H_
#include "npapi.h"
#endif
#ifndef _NPUPP_H_
#include "npupp.h"
#endif
#include "nsDefaultPlugin.h"
//\\// DEFINE
#define NP_EXPORT
//\\// GLOBAL DATA
NPNetscapeFuncs* g_pNavigatorFuncs = 0;
#ifdef OJI
JRIGlobalRef Private_GetJavaClass(void);
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// Private_GetJavaClass (global function)
//
// Given a Java class reference (thru NPP_GetJavaClass) inform JRT
// of this class existence
//
JRIGlobalRef
Private_GetJavaClass(void)
{
jref clazz = NPP_GetJavaClass();
if (clazz) {
JRIEnv* env = NPN_GetJavaEnv();
return JRI_NewGlobalRef(env, clazz);
}
return NULL;
}
#endif /* OJI */
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// PLUGIN DLL entry points
//
// These are the Windows specific DLL entry points. They must be exoprted
//
// we need these to be global since we have to fill one of its field
// with a data (class) which requires knowlwdge of the navigator
// jump-table. This jump table is known at Initialize time (NP_Initialize)
// which is called after NP_GetEntryPoint
static NPPluginFuncs* g_pluginFuncs;
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_GetEntryPoints
//
// fills in the func table used by Navigator to call entry points in
// plugin DLL. Note that these entry points ensure that DS is loaded
// by using the NP_LOADDS macro, when compiling for Win16
//
NPError WINAPI NP_EXPORT
NP_GetEntryPoints(NPPluginFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
// if the plugin's function table is smaller than the plugin expects,
// then they are incompatible, and should return an error
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
pFuncs->newp = NPP_New;
pFuncs->destroy = NPP_Destroy;
pFuncs->setwindow = NPP_SetWindow;
pFuncs->newstream = NPP_NewStream;
pFuncs->destroystream = NPP_DestroyStream;
pFuncs->asfile = NPP_StreamAsFile;
pFuncs->writeready = NPP_WriteReady;
pFuncs->write = NPP_Write;
pFuncs->print = NPP_Print;
pFuncs->event = 0; /// reserved
g_pluginFuncs = pFuncs;
return NPERR_NO_ERROR;
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_Initialize
//
// called immediately after the plugin DLL is loaded
//
NPError WINAPI NP_EXPORT
NP_Initialize(NPNetscapeFuncs* pFuncs)
{
// trap a NULL ptr
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
g_pNavigatorFuncs = pFuncs; // save it for future reference
// if the plugin's major ver level is lower than the Navigator's,
// then they are incompatible, and should return an error
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
// We have to defer these assignments until g_pNavigatorFuncs is set
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
g_pluginFuncs->urlnotify = NPP_URLNotify;
}
#ifdef OJI
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
g_pluginFuncs->javaClass = Private_GetJavaClass();
}
#endif
// NPP_Initialize is a standard (cross-platform) initialize function.
return NPP_Initialize();
}
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
// NP_Shutdown
//
// called immediately before the plugin DLL is unloaded.
// This functio shuold check for some ref count on the dll to see if it is
// unloadable or it needs to stay in memory.
//
NPError WINAPI NP_EXPORT
NP_Shutdown()
{
NPP_Shutdown();
g_pNavigatorFuncs = NULL;
return NPERR_NO_ERROR;
}
char * NP_GetMIMEDescription()
{
static char mimetype[] = NS_PLUGIN_DEFAULT_MIME_DESCRIPTION;
return mimetype;
}
// END - PLUGIN DLL entry points
////\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//.
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\.
/* NAVIGATOR Entry points */
/* These entry points expect to be called from within the plugin. The
noteworthy assumption is that DS has already been set to point to the
plugin's DLL data segment. Don't call these functions from outside
the plugin without ensuring DS is set to the DLLs data segment first,
typically using the NP_LOADDS macro
*/
/* returns the major/minor version numbers of the Plugin API for the plugin
and the Navigator
*/
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = HIBYTE(g_pNavigatorFuncs->version);
*netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
{
return g_pNavigatorFuncs->getvalue(instance, variable, result);
}
/* causes the specified URL to be fetched and streamed in
*/
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
return g_pNavigatorFuncs->geturl(instance, url, target);
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
}
/* Requests that a number of bytes be provided on a stream. Typically
this would be used if a stream was in "pull" mode. An optional
position can be provided for streams which are seekable.
*/
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
return g_pNavigatorFuncs->requestread(stream, rangeList);
}
/* Creates a new stream of data from the plug-in to be interpreted
by Netscape in the current window.
*/
NPError NPN_NewStream(NPP instance, NPMIMEType type,
const char* target, NPStream** stream)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
/* Provides len bytes of data.
*/
int32 NPN_Write(NPP instance, NPStream *stream,
int32 len, void *buffer)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
int32 result;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
}
else {
result = -1;
}
return result;
}
/* Closes a stream object.
reason indicates why the stream was closed.
*/
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
NPError err;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
}
else {
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
return err;
}
/* Provides a text status message in the Netscape client user interface
*/
void NPN_Status(NPP instance, const char *message)
{
g_pNavigatorFuncs->status(instance, message);
}
/* returns the user agent string of Navigator, which contains version info
*/
const char* NPN_UserAgent(NPP instance)
{
return g_pNavigatorFuncs->uagent(instance);
}
/* allocates memory from the Navigator's memory space. Necessary so that
saved instance data may be freed by Navigator when exiting.
*/
void* NPN_MemAlloc(uint32 size)
{
return g_pNavigatorFuncs->memalloc(size);
}
/* reciprocal of MemAlloc() above
*/
void NPN_MemFree(void* ptr)
{
g_pNavigatorFuncs->memfree(ptr);
}
#ifdef OJI
/* private function to Netscape. do not use!
*/
void NPN_ReloadPlugins(NPBool reloadPages)
{
g_pNavigatorFuncs->reloadplugins(reloadPages);
}
JRIEnv* NPN_GetJavaEnv(void)
{
return g_pNavigatorFuncs->getJavaEnv();
}
jref NPN_GetJavaPeer(NPP instance)
{
return g_pNavigatorFuncs->getJavaPeer(instance);
}
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

View File

@@ -1,765 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#include <windowsx.h>
#include <assert.h>
#include "resource.h"
#include "plugin.h"
#include "utils.h"
#include "dialogs.h"
#include "dbg.h"
#include "nsIServiceManager.h"
#include "nsIPref.h"
nsIServiceManager * gServiceManager = NULL;
static char szNullPluginWindowClassName[] = CLASS_NULL_PLUGIN;
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND, UINT, WPARAM, LPARAM);
static char szDefaultPluginFinderURL[] = DEFAULT_PLUGINFINDER_URL;
static char szPageUrlForJavaScript[] = PAGE_URL_FOR_JAVASCRIPT;
static char szPageUrlForJVM[] = JVM_SMARTUPDATE_URL;
//static char szPluginFinderCommandFormatString[] = PLUGINFINDER_COMMAND;
static char szPluginFinderCommandBeginning[] = PLUGINFINDER_COMMAND_BEGINNING;
static char szPluginFinderCommandEnd[] = PLUGINFINDER_COMMAND_END;
static char szDefaultFileExt[] = "*";
BOOL RegisterNullPluginWindowClass()
{
assert(hInst != NULL);
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.lpfnWndProc = (WNDPROC)PluginWndProc;
wc.cbWndExtra = sizeof(DWORD);
wc.hInstance = hInst;
wc.hIcon = LoadIcon(hInst, IDI_APPLICATION);
wc.hCursor = NULL;
wc.hbrBackground = HBRUSH(COLOR_WINDOW + 1);
wc.lpszClassName = szNullPluginWindowClassName;
ATOM aRet = RegisterClass(&wc);
return (aRet != NULL);
}
void UnregisterNullPluginWindowClass()
{
assert(hInst != NULL);
UnregisterClass(szNullPluginWindowClassName, hInst);
}
/*********************************************/
/* */
/* CPlugin class implementation */
/* */
/*********************************************/
CPlugin::CPlugin(HINSTANCE hInst,
NPP pNPInstance,
WORD wMode,
NPMIMEType pluginType,
LPSTR szPageURL,
LPSTR szFileURL,
LPSTR szFileExtension,
BOOL bHidden) :
m_pNPInstance(pNPInstance),
m_wMode(wMode),
m_hInst(hInst),
m_hWnd(NULL),
m_hWndParent(NULL),
m_hWndDialog(NULL),
m_hIcon(NULL),
m_pNPMIMEType(NULL),
m_szPageURL(NULL),
m_szFileURL(NULL),
m_szFileExtension(NULL),
m_bOnline(TRUE),
m_bJava(TRUE),
m_bJavaScript(TRUE),
m_bSmartUpdate(TRUE),
m_szURLString(NULL),
m_szCommandMessage(NULL),
m_bWaitingStreamFromPFS(FALSE),
m_PFSStream(NULL),
m_bHidden(bHidden)
{
dbgOut1("CPlugin::CPlugin()");
assert(m_hInst != NULL);
assert(m_pNPInstance != NULL);
if(pluginType && *pluginType)
{
m_pNPMIMEType = (NPMIMEType)new char[lstrlen((LPSTR)pluginType) + 1];
if(m_pNPMIMEType != NULL)
lstrcpy((LPSTR)m_pNPMIMEType, pluginType);
}
if(szPageURL && *szPageURL)
{
m_szPageURL = new char[lstrlen(szPageURL) + 1];
if(m_szPageURL != NULL)
lstrcpy(m_szPageURL, szPageURL);
}
if(szFileURL && *szFileURL)
{
m_szFileURL = new char[lstrlen(szFileURL) + 1];
if(m_szFileURL != NULL)
lstrcpy(m_szFileURL, szFileURL);
}
if(szFileExtension && *szFileExtension)
{
m_szFileExtension = new char[lstrlen(szFileExtension) + 1];
if(m_szFileExtension != NULL)
lstrcpy(m_szFileExtension, szFileExtension);
}
m_hIcon = LoadIcon(m_hInst, MAKEINTRESOURCE(IDI_PLUGICON));
char szString[1024] = {'\0'};
LoadString(m_hInst, IDS_CLICK_TO_GET, szString, sizeof(szString));
if(*szString)
{
m_szCommandMessage = new char[lstrlen(szString) + 1];
if(m_szCommandMessage != NULL)
lstrcpy(m_szCommandMessage, szString);
}
}
CPlugin::~CPlugin()
{
dbgOut1("CPlugin::~CPlugin()");
if(m_pNPMIMEType != NULL)
{
delete [] m_pNPMIMEType;
m_pNPMIMEType = NULL;
}
if(m_szPageURL != NULL)
{
delete [] m_szPageURL;
m_szPageURL = NULL;
}
if(m_szFileURL != NULL)
{
delete [] m_szFileURL;
m_szFileURL = NULL;
}
if(m_szFileExtension != NULL)
{
delete [] m_szFileExtension;
m_szFileExtension = NULL;
}
if(m_szURLString != NULL)
{
delete [] m_szURLString;
m_szURLString = NULL;
}
if(m_hIcon != NULL)
{
DestroyIcon(m_hIcon);
m_hIcon = NULL;
}
if(m_szCommandMessage != NULL)
{
delete [] m_szCommandMessage;
m_szCommandMessage = NULL;
}
}
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(IsWindow(hWndParent));
if(IsWindow(hWndParent))
m_hWndParent = hWndParent;
RECT rcParent;
GetClientRect(m_hWndParent, &rcParent);
CreateWindow(szNullPluginWindowClassName,
"NULL Plugin",
WS_CHILD,
0,0, rcParent.right, rcParent.bottom,
m_hWndParent,
(HMENU)NULL,
m_hInst,
(LPVOID)this);
assert(m_hWnd != NULL);
if((m_hWnd == NULL) || (!IsWindow(m_hWnd)))
return FALSE;
UpdateWindow(m_hWnd);
ShowWindow(m_hWnd, SW_SHOW);
}
if(IsNewMimeType((LPSTR)m_pNPMIMEType) || m_bHidden)
showGetPluginDialog();
return TRUE;
}
void CPlugin::shut()
{
dbgOut1("CPlugin::shut()");
if(m_hWndDialog != NULL)
{
DestroyWindow(m_hWndDialog);
m_hWndDialog = NULL;
}
if(m_hWnd != NULL)
{
DestroyWindow(m_hWnd);
m_hWnd = NULL;
}
// we should release the service manager
NS_IF_RELEASE(gServiceManager);
gServiceManager = NULL;
}
HWND CPlugin::getWindow()
{
return m_hWnd;
}
BOOL CPlugin::useDefaultURL_P()
{
if((m_szPageURL == NULL) && (m_szFileURL == NULL))
return TRUE;
else
return FALSE;
}
BOOL CPlugin::doSmartUpdate_P()
{
// due to current JavaScript problems never do it smart for now 5.1.98
return FALSE;
if(m_bOnline && m_bJava && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
return TRUE;
else
return FALSE;
}
LPSTR CPlugin::createURLString()
{
if(m_szURLString != NULL)
{
delete [] m_szURLString;
m_szURLString = NULL;
}
// check if there is file URL first
if(!m_bSmartUpdate && m_szFileURL != NULL)
{
m_szURLString = new char[lstrlen(m_szFileURL) + 1];
if(m_szURLString == NULL)
return NULL;
lstrcpy(m_szURLString, m_szFileURL);
return m_szURLString;
}
// if not get the page URL
char * szAddress = NULL;
char *urlToOpen = NULL;
char contentTypeIsJava = 0;
if (NULL != m_pNPMIMEType) {
contentTypeIsJava = (0 == strcmp("application/x-java-vm",
m_pNPMIMEType)) ? 1 : 0;
}
if(!m_bSmartUpdate && m_szPageURL != NULL && !contentTypeIsJava)
{
szAddress = new char[lstrlen(m_szPageURL) + 1];
if(szAddress == NULL)
return NULL;
lstrcpy(szAddress, m_szPageURL);
m_szURLString = new char[lstrlen(szAddress) + 1 + lstrlen((LPSTR)m_pNPMIMEType) + 1];
if(m_szURLString == NULL)
return NULL;
// Append the MIME type to the URL
wsprintf(m_szURLString, "%s?%s", szAddress, (LPSTR)m_pNPMIMEType);
}
else // default
{
if(!m_bSmartUpdate)
{
urlToOpen = szDefaultPluginFinderURL;
if (contentTypeIsJava) {
urlToOpen = szPageUrlForJVM;
}
szAddress = new char[lstrlen(urlToOpen) + 1];
if(szAddress == NULL)
return NULL;
lstrcpy(szAddress, urlToOpen);
m_szURLString = new char[lstrlen(szAddress) + 10 +
lstrlen((LPSTR)m_pNPMIMEType) + 1];
if(m_szURLString == NULL)
return NULL;
// Append the MIME type to the URL
wsprintf(m_szURLString, "%s?mimetype=%s",
szAddress, (LPSTR)m_pNPMIMEType);
}
else
{
urlToOpen = szPageUrlForJavaScript;
if (contentTypeIsJava) {
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[lstrlen(szPluginFinderCommandBeginning) + lstrlen(urlToOpen) + 10 +
lstrlen((LPSTR)m_pNPMIMEType) + 13 +
lstrlen((LPSTR)m_szPageURL) + 11 +
lstrlen((LPSTR)m_szFileURL) +
lstrlen(szPluginFinderCommandEnd) + 1];
wsprintf(m_szURLString, "%s%s?mimetype=%s&pluginspage=%s&pluginurl=%s%s",
szPluginFinderCommandBeginning, urlToOpen,
(LPSTR)m_pNPMIMEType, m_szPageURL, m_szFileURL, szPluginFinderCommandEnd);
}
}
if(szAddress != NULL)
delete [] szAddress;
return m_szURLString;
}
void CPlugin::getPluginRegular()
{
assert(m_bOnline);
char * szURL = createURLString();
assert(szURL != NULL);
if(szURL == NULL)
return;
dbgOut3("CPlugin::getPluginRegular(), %#08x '%s'", m_pNPInstance, szURL);
NPN_GetURL(m_pNPInstance, szURL, NULL);
m_bWaitingStreamFromPFS = TRUE;
}
void CPlugin::getPluginSmart()
{
/*
static char szJSString[2048];
wsprintf(szJSString,
szPluginFinderCommandFormatString,
szDefaultPluginFinderURL,
m_pNPMIMEType,
(m_szFileExtension != NULL) ? m_szFileExtension : szDefaultFileExt);
dbgOut3("%#08x '%s'", m_pNPInstance, szJSString);
assert(*szJSString);
NPN_GetURL(m_pNPInstance, szJSString, "smartupdate_plugin_finder");
*/
}
void CPlugin::showGetPluginDialog()
{
assert(m_pNPMIMEType != NULL);
if(m_pNPMIMEType == NULL)
return;
// Get environment
BOOL bOffline = FALSE;
NPN_GetValue(m_pNPInstance, NPNVisOfflineBool, (void *)&bOffline);
NPN_GetValue(m_pNPInstance, NPNVjavascriptEnabledBool, (void *)&m_bJavaScript);
//NPN_GetValue(m_pNPInstance, NPNVasdEnabledBool, (void *)&m_bSmartUpdate);
m_bOnline = !bOffline;
#ifdef OJI
if(m_bOnline && m_bJavaScript && m_bSmartUpdate && useDefaultURL_P())
{
JRIEnv *penv = NPN_GetJavaEnv();
m_bJava = (penv != NULL);
}
#else
m_bJava = FALSE;
#endif
dbgOut1("Environment:");
dbgOut2("%s", m_bOnline ? "On-line" : "Off-line");
dbgOut2("Java %s", m_bJava ? "Enabled" : "Disabled");
dbgOut2("JavaScript %s", m_bJavaScript ? "Enabled" : "Disabled");
dbgOut2("SmartUpdate %s", m_bSmartUpdate ? "Enabled" : "Disabled");
if((!m_bSmartUpdate && (m_szPageURL != NULL) || (m_szFileURL != NULL)) || !m_bJavaScript)
{
// we don't want it more than once
if(m_hWndDialog == NULL)
CreateDialogParam(m_hInst, MAKEINTRESOURCE(IDD_PLUGIN_DOWNLOAD), m_hWnd,
(DLGPROC)GetPluginDialogProc, (LPARAM)this);
}
else
getPlugin();
}
void CPlugin::getPlugin()
{
if(m_szCommandMessage != NULL)
{
delete [] m_szCommandMessage;
m_szCommandMessage = NULL;
}
char szString[1024] = {'\0'};
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
if(*szString)
{
m_szCommandMessage = new char[lstrlen(szString) + 1];
if(m_szCommandMessage != NULL)
lstrcpy(m_szCommandMessage, szString);
}
InvalidateRect(m_hWnd, NULL, TRUE);
UpdateWindow(m_hWnd);
getPluginRegular();
}
//*******************
// NP API handles
//*******************
void CPlugin::resize()
{
dbgOut1("CPlugin::resize()");
}
void CPlugin::print(NPPrint * pNPPrint)
{
dbgOut1("CPlugin::print()");
if(pNPPrint == NULL)
return;
}
void CPlugin::URLNotify(const char * szURL)
{
dbgOut2("CPlugin::URLNotify(), URL '%s'", szURL);
NPStream * pStream = NULL;
char buf[256];
assert(m_hInst != NULL);
assert(m_pNPInstance != NULL);
int iSize = LoadString(m_hInst, IDS_GOING2HTML, buf, sizeof(buf));
NPError rc = NPN_NewStream(m_pNPInstance, "text/html", "asd_plugin_finder", &pStream);
//char buf[] = "<html>\n<body>\n\n<h2 align=center>NPN_NewStream / NPN_Write - This seems to work.</h2>\n\n</body>\n</html>";
int32 iBytes = NPN_Write(m_pNPInstance, pStream, lstrlen(buf), buf);
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'};
LoadString(m_hInst, IDS_CLICK_WHEN_DONE, szString, sizeof(szString));
if(m_szCommandMessage == NULL)
return FALSE;
return (lstrcmp(m_szCommandMessage, szString) == 0);
}
//***************************
// Windows message handlers
//***************************
void CPlugin::onCreate(HWND hWnd)
{
m_hWnd = hWnd;
}
void CPlugin::onLButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
{
if(!readyToRefresh())
showGetPluginDialog();
else
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
}
void CPlugin::onRButtonUp(HWND hWnd, int x, int y, UINT keyFlags)
{
if(!readyToRefresh())
showGetPluginDialog();
else
NPN_GetURL(m_pNPInstance, "javascript:navigator.plugins.refresh(true)", "_self");
}
static void DrawCommandMessage(HDC hDC, LPSTR szString, LPRECT lprc)
{
if(szString == NULL)
return;
HFONT hFont = GetStockFont(DEFAULT_GUI_FONT);
if(hFont == NULL)
return;
HFONT hFontOld = SelectFont(hDC, hFont);
SIZE sz;
GetTextExtentPoint32(hDC, szString, lstrlen(szString), &sz);
POINT pt;
pt.x = sz.cx;
pt.y = sz.cy;
LPtoDP(hDC, &pt, 1);
int iY = (lprc->bottom / 2) - ((32) / 2) + 36;
int iX = 0;
if(lprc->right > pt.x)
iX = lprc->right/2 - pt.x/2;
else
iX = 1;
RECT rcText;
rcText.left = iX;
rcText.right = rcText.left + pt.x;
rcText.top = iY;
rcText.bottom = rcText.top + pt.y;
int iModeOld = SetBkMode(hDC, TRANSPARENT);
COLORREF crColorOld = SetTextColor(hDC, RGB(0,0,0));
DrawText(hDC, szString, lstrlen(szString), &rcText, DT_CENTER|DT_VCENTER);
SetTextColor(hDC, crColorOld);
SetBkMode(hDC, iModeOld);
SelectFont(hDC, hFontOld);
}
void CPlugin::onPaint(HWND hWnd)
{
RECT rc;
HDC hDC;
PAINTSTRUCT ps;
int x, y;
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rc);
x = (rc.right / 2) - (32 / 2);
y = (rc.bottom / 2) - ((32) / 2);
if(rc.right > 34 && rc.bottom > 34)
{
if(m_hIcon != NULL)
DrawIcon(hDC, x, y, m_hIcon);
POINT pt[5];
// left vert and top horiz highlight
pt[0].x = 1; pt[0].y = rc.bottom-1;
pt[1].x = 1; pt[1].y = 1;
pt[2].x = rc.right-1; pt[2].y = 1;
HPEN hPen3DLight = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DLIGHT));
HPEN hPen3DShadow = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
HPEN hPen3DDKShadow = CreatePen(PS_SOLID, 1, GetSysColor(COLOR_3DDKSHADOW));
HPEN hPenOld = SelectPen(hDC, hPen3DLight);
Polyline(hDC, pt, 3);
// left vert and top horiz shadow
pt[0].x = 2; pt[0].y = rc.bottom-3;
pt[1].x = 2; pt[1].y = 2;
pt[2].x = rc.right-2; pt[2].y = 2;
SelectPen(hDC, hPen3DShadow);
Polyline(hDC, pt, 3);
// right vert and bottom horiz highlight
pt[0].x = rc.right-3; pt[0].y = 2;
pt[1].x = rc.right-3; pt[1].y = rc.bottom-3;
pt[2].x = 2; pt[2].y = rc.bottom-3;
SelectPen(hDC, hPen3DLight);
Polyline(hDC, pt, 3);
// right vert and bottom horiz shadow
pt[0].x = rc.right-1; pt[0].y = 1;
pt[1].x = rc.right-1; pt[1].y = rc.bottom-1;
pt[2].x = 0; pt[2].y = rc.bottom-1;
SelectPen(hDC, hPen3DDKShadow);
Polyline(hDC, pt, 3);
// restore the old pen
SelectPen(hDC, hPenOld);
DeletePen(hPen3DDKShadow);
DeletePen(hPen3DShadow);
DeletePen(hPen3DLight);
DrawCommandMessage(hDC, m_szCommandMessage, &rc);
}
else
if(m_hIcon != NULL)
DrawIconEx(hDC, x, y, m_hIcon, rc.right - rc.left, rc.bottom - rc.top, 0, NULL, DI_NORMAL);
EndPaint (hWnd, &ps);
}
//**************************
// Plugin window procedure
//**************************
static LRESULT CALLBACK NP_LOADDS PluginWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
CPlugin *pPlugin = (CPlugin *)GetWindowLong(hWnd, GWL_USERDATA);
switch(message)
{
case WM_CREATE:
pPlugin = (CPlugin *)(((CREATESTRUCT FAR*)lParam)->lpCreateParams);
assert(pPlugin != NULL);
SetWindowLong(hWnd, GWL_USERDATA, (LONG)pPlugin);
pPlugin->onCreate(hWnd);
return 0L;
case WM_LBUTTONUP:
HANDLE_WM_LBUTTONUP(hWnd, wParam, lParam, pPlugin->onLButtonUp);
return 0L;
case WM_RBUTTONUP:
HANDLE_WM_RBUTTONUP(hWnd, wParam, lParam, pPlugin->onRButtonUp);
return 0L;
case WM_PAINT:
HANDLE_WM_PAINT(hWnd, wParam, lParam, pPlugin->onPaint);
return 0L;
case WM_MOUSEMOVE:
dbgOut1("MouseMove");
break;
default:
break;
}
return(DefWindowProc(hWnd, message, wParam, lParam));
}

View File

@@ -1,136 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __PLUGIN_HPP__
#define __PLUGIN_HPP__
#include "npapi.h"
class CPlugin
{
private:
HINSTANCE m_hInst;
NPP m_pNPInstance;
WORD m_wMode;
HWND m_hWnd;
HWND m_hWndParent;
HICON m_hIcon;
char* m_szURLString;
char* m_szCommandMessage;
BOOL m_bWaitingStreamFromPFS;
NPStream* m_PFSStream;
public:
BOOL m_bHidden;
NPMIMEType m_pNPMIMEType;
LPSTR m_szPageURL; // Location of plug-in HTML page
LPSTR m_szFileURL; // Location of plug-in JAR file
LPSTR m_szFileExtension; // File extension associated with the of the unknown mimetype
HWND m_hWndDialog;
// environment
BOOL m_bOnline;
BOOL m_bJava;
BOOL m_bJavaScript;
BOOL m_bSmartUpdate;
private:
BOOL useDefaultURL_P();
BOOL doSmartUpdate_P();
LPSTR createURLString();
void getPluginSmart();
void getPluginRegular();
public:
CPlugin(HINSTANCE hInst,
NPP pNPInstance,
WORD wMode,
NPMIMEType pluginType,
LPSTR szPageURL,
LPSTR szFileURL,
LPSTR szFileExtension,
BOOL bHidden);
~CPlugin();
BOOL init(HWND hWnd);
void shut();
HWND getWindow();
void showGetPluginDialog();
void getPlugin();
BOOL readyToRefresh();
// NP API handlers
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://plugins.netscape.com/plug-in_finder.adp"
#define PLUGINFINDER_COMMAND_BEGINNING ""
#define PLUGINFINDER_COMMAND_END ""
#define DEFAULT_PLUGINFINDER_URL "http://plugins.netscape.com/plug-in_finder.adp"
#define JVM_SMARTUPDATE_URL "http://plugins.netscape.com/plug-in_finder.adp"
#ifdef WIN32
#define REGISTRY_PLACE "Software\\Netscape\\Netscape Navigator\\Default Plugin"
#else
#define GWL_USERDATA 0
#define COLOR_3DSHADOW COLOR_BTNFACE
#define COLOR_3DLIGHT COLOR_BTNHIGHLIGHT
#define COLOR_3DDKSHADOW COLOR_BTNSHADOW
#endif
#define CLASS_NULL_PLUGIN "NullPluginClass"
BOOL RegisterNullPluginWindowClass();
void UnregisterNullPluginWindowClass();
extern HINSTANCE hInst;
#endif // __PLUGIN_HPP__

View File

@@ -1,48 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Npnul32.rc
//
#define IDD_PLUGIN_DOWNLOAD 301
#define IDI_PLUGICON 302
#define IDS_INFO 303
#define IDS_DEFAULT_URL 304
#define IDS_INSTALL_COMMAND 305
#define IDS_GET_PLUGIN_MSG2 306
#define IDS_LOCATION 306
#define IDS_TITLE 307
#define IDS_QUESTION 308
#define IDS_JS_DISABLED 309
#define IDS_ASDFINDER 310
#define IDS_ASDSIMP 311
#define IDS_QUERY_TEST 312
#define IDS_BLANK_JS 313
#define IDS_GOING2HTML 314
#define IDS_WARNING_JS 315
#define IDS_WARNING_OFFLINE 316
#define IDS_DEFAULT_URL_OLD 317
#define IDS_FINDER_PAGE 317
#define IDS_CLICK_TO_GET 318
#define IDS_CLICK_WHEN_DONE 319
#define IDC_JS_DIS_TEXT 2003
#define IDC_CONTINUE 2004
#define IDC_CONT_NOJS 2005
#define IDC_STATIC_INFO 2009
#define IDC_STATIC_LOCATION 2010
#define IDC_STATIC_QUESTION 2011
#define IDC_GET_PLUGIN 2012
#define IDC_BUTTON_CANCEL 2013
#define IDC_STATIC_URL 2014
#define IDC_STATIC_INFOTYPE 2015
#define IDC_STATIC_WARNING 2016
#define IDC_EDIT_URL 2017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 308
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 2018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -1,171 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#include <windowsx.h>
#include "plugin.h"
// open the registry, create if necessary
HKEY openRegistry()
{
HKEY phkResult;
if(RegCreateKey(HKEY_CURRENT_USER, REGISTRY_PLACE, &phkResult) != ERROR_SUCCESS)
MessageBox(0, "Error creating Default Plugin registry key", "Default Plugin", MB_OK);
return phkResult;
}
// return TRUE if we've never seen this MIME type before
BOOL IsNewMimeType(LPSTR mime)
{
HKEY hkey = openRegistry();
DWORD dwType, keysize = 512;
char keybuf[512];
if(RegQueryValueEx(hkey, mime, 0, &dwType, (LPBYTE) &keybuf, &keysize) == ERROR_SUCCESS)
{
// key exists, must have already been here...
return FALSE;
}
else
{
if(RegSetValueEx(hkey, mime, 0, REG_SZ, (LPBYTE) "(none)", 7) != ERROR_SUCCESS)
MessageBox(0, "Error adding MIME type value", "Default Plugin", MB_OK);
return TRUE;
}
}
// string length in pixels for the specific window (selected font)
static int getWindowStringLength(HWND hWnd, LPSTR lpsz)
{
SIZE sz;
HDC hDC = GetDC(hWnd);
HFONT hWindowFont = GetWindowFont(hWnd);
HFONT hFontOld = SelectFont(hDC, hWindowFont);
GetTextExtentPoint32(hDC, lpsz, lstrlen(lpsz), &sz);
POINT pt;
pt.x = sz.cx;
pt.y = sz.cy;
LPtoDP(hDC, &pt, 1);
SelectFont(hDC, hFontOld);
ReleaseDC(hWnd, hDC);
return (int)pt.x;
}
/****************************************************************/
/* */
/* void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText) */
/* */
/* helper to wrap long lines in a static control, which do not */
/* wrap automatically if they do not have space characters */
/* */
/****************************************************************/
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText)
{
HWND hWndStatic = GetDlgItem(hWnd, iID);
if((szText == NULL) || (lstrlen(szText) == 0))
{
SetDlgItemText(hWnd, iID, "");
return;
}
RECT rc;
GetClientRect(hWndStatic, &rc);
int iStaticLength = rc.right - rc.left;
int iStringLength = getWindowStringLength(hWndStatic, szText);
if(iStringLength <= iStaticLength)
{
SetDlgItemText(hWnd, iID, szText);
return;
}
int iBreaks = iStringLength/iStaticLength;
if(iBreaks <= 0)
return;
char * pBuf = new char[iStringLength + iBreaks + 1];
if(pBuf == NULL)
return;
lstrcpy(pBuf, "");
int iStart = 0;
int iLines = 0;
for(int i = 0; i < iStringLength; i++)
{
char * sz = &szText[iStart];
int iIndex = i - iStart;
char ch = sz[iIndex + 1];
sz[iIndex + 1] = '\0';
int iLength = getWindowStringLength(hWndStatic, sz);
if(iLength < iStaticLength)
{
sz[iIndex + 1] = ch;
if(iLines == iBreaks)
{
lstrcat(pBuf, sz);
break;
}
continue;
}
sz[iIndex + 1] = ch; // restore zeroed element
i--; // go one step back
ch = sz[iIndex];
sz[iIndex] = '\0'; // terminate string one char shorter
lstrcat(pBuf, sz); // append the string
lstrcat(pBuf, " "); // append space character for successful wrapping
iStart += lstrlen(sz);// shift new start position
sz[iIndex] = ch; // restore zeroed element
iLines++; // count lines
}
SetDlgItemText(hWnd, iID, pBuf);
delete [] pBuf;
}

View File

@@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __UTILS_H__
#define __UTILS_H__
HKEY openRegistry();
BOOL IsNewMimeType(LPSTR szMimeType);
void SetDlgItemTextWrapped(HWND hWnd, int iID, LPSTR szText);
#endif // __UTILS_H__

View File

@@ -1,161 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "action.h"
char * FormatAction(int aAction)
{
static char string[64] = {'\0'};
switch (aAction) {
case action_invalid:
strcpy(string, "invalid action");
break;
case action_npn_version:
strcpy(string, "npn_version");
break;
case action_npn_get_url_notify:
strcpy(string, "npn_get_url_notify");
break;
case action_npn_get_url:
strcpy(string, "npn_get_url");
break;
case action_npn_post_url_notify:
strcpy(string, "npn_post_url_notify");
break;
case action_npn_post_url:
strcpy(string, "npn_post_url");
break;
case action_npn_request_read:
strcpy(string, "npn_request_read");
break;
case action_npn_new_stream:
strcpy(string, "npn_new_stream");
break;
case action_npn_write:
strcpy(string, "npn_write");
break;
case action_npn_destroy_stream:
strcpy(string, "npn_destroy_stream");
break;
case action_npn_status:
strcpy(string, "npn_status");
break;
case action_npn_user_agent:
strcpy(string, "npn_user_agent");
break;
case action_npn_mem_alloc:
strcpy(string, "npn_mem_alloc");
break;
case action_npn_mem_free:
strcpy(string, "npn_mem_free");
break;
case action_npn_mem_flush:
strcpy(string, "npn_mem_flush");
break;
case action_npn_reload_plugins:
strcpy(string, "npn_reload_plugins");
break;
case action_npn_get_java_env:
strcpy(string, "npn_get_java_env");
break;
case action_npn_get_java_peer:
strcpy(string, "npn_get_java_peer");
break;
case action_npn_get_value:
strcpy(string, "npn_get_value");
break;
case action_npn_set_value:
strcpy(string, "npn_set_value");
break;
case action_npn_invalidate_rect:
strcpy(string, "npn_invalidate_rect");
break;
case action_npn_invalidate_region:
strcpy(string, "npn_invalidate_region");
break;
case action_npn_force_redraw:
strcpy(string, "npn_force_redraw");
break;
case action_npp_new:
strcpy(string, "npp_new");
break;
case action_npp_destroy:
strcpy(string, "npp_destroy");
break;
case action_npp_set_window:
strcpy(string, "npp_set_window");
break;
case action_npp_new_stream:
strcpy(string, "npp_new_stream");
break;
case action_npp_destroy_stream:
strcpy(string, "npp_destroy_stream");
break;
case action_npp_stream_as_file:
strcpy(string, "npp_stream_as_file");
break;
case action_npp_write_ready:
strcpy(string, "npp_write_ready");
break;
case action_npp_write:
strcpy(string, "npp_write");
break;
case action_npp_print:
strcpy(string, "npp_print");
break;
case action_npp_handle_event:
strcpy(string, "npp_handle_event");
break;
case action_npp_url_notify:
strcpy(string, "npp_url_notify");
break;
case action_npp_get_java_class:
strcpy(string, "npp_get_java_class");
break;
case action_npp_get_value:
strcpy(string, "npp_get_value");
break;
case action_npp_set_value:
strcpy(string, "npp_set_value");
break;
default:
strcpy(string, "Unknown action!");
break;
}
return string;
}

View File

@@ -1,87 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __ACTION_H__
#define __ACTION_H__
#include "npapi.h"
typedef enum
{
action_invalid = 0,
action_npn_version,
action_npn_get_url_notify,
action_npn_get_url,
action_npn_post_url_notify,
action_npn_post_url,
action_npn_request_read,
action_npn_new_stream,
action_npn_write,
action_npn_destroy_stream,
action_npn_status,
action_npn_user_agent,
action_npn_mem_alloc,
action_npn_mem_free,
action_npn_mem_flush,
action_npn_reload_plugins,
action_npn_get_java_env,
action_npn_get_java_peer,
action_npn_get_value,
action_npn_set_value,
action_npn_invalidate_rect,
action_npn_invalidate_region,
action_npn_force_redraw,
action_npp_new, // 23
action_npp_destroy,
action_npp_set_window,
action_npp_new_stream,
action_npp_destroy_stream,
action_npp_stream_as_file,
action_npp_write_ready,
action_npp_write,
action_npp_print,
action_npp_handle_event,
action_npp_url_notify,
action_npp_get_java_class,
action_npp_get_value,
action_npp_set_value
} npapiAction;
char * FormatAction(int aAction);
#endif // __ACTION_H__

View File

@@ -1,51 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <windows.h>
#ifndef NTRACE
void __cdecl dbgOut(LPSTR format, ...) {
static char buf[1024];
va_list va;
va_start(va, format);
wvsprintf(buf, format, va);
va_end(va);
lstrcat(buf, "\n");
OutputDebugString(buf);
}
#endif // NDEBUG

View File

@@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __DBG_HPP_
#define __DBG_HPP_
#ifdef NTRACE
#define dbgOut1(x) ((void)0)
#define dbgOut2(x,y) ((void)0)
#define dbgOut3(x,y,z) ((void)0)
#define dbgOut4(x,y,z,t) ((void)0)
#define dbgOut5(x,y,z,t,u) ((void)0)
#define dbgOut6(x,y,z,t,u,v) ((void)0)
#define dbgOut7(x,y,z,t,u,v,a) ((void)0)
#define dbgOut8(x,y,z,t,u,v,a,b) ((void)0)
#else
void __cdecl dbgOut(LPSTR format, ...);
#define dbgOut1(x) dbgOut(x)
#define dbgOut2(x,y) dbgOut(x, y)
#define dbgOut3(x,y,z) dbgOut(x, y, z)
#define dbgOut4(x,y,z,t) dbgOut(x, y, z, t)
#define dbgOut5(x,y,z,t,u) dbgOut(x, y, z, t, u)
#define dbgOut6(x,y,z,t,u,v) dbgOut(x, y, z, t, u, v)
#define dbgOut7(x,y,z,t,u,v, a) dbgOut(x, y, z, t, u, v, a)
#define dbgOut8(x,y,z,t,u,v, a, b) dbgOut(x, y, z, t, u, v, a, b)
#endif
#endif

View File

@@ -1,118 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "npapi.h"
#include "npupp.h"
#include "dbg.h"
NPNetscapeFuncs NPNFuncs;
NPError WINAPI NP_GetEntryPoints(NPPluginFuncs* aPluginFuncs)
{
dbgOut1("wrapper: NP_GetEntryPoints");
if(aPluginFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(aPluginFuncs->size < sizeof(NPPluginFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
aPluginFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
aPluginFuncs->newp = NPP_New;
aPluginFuncs->destroy = NPP_Destroy;
aPluginFuncs->setwindow = NPP_SetWindow;
aPluginFuncs->newstream = NPP_NewStream;
aPluginFuncs->destroystream = NPP_DestroyStream;
aPluginFuncs->asfile = NPP_StreamAsFile;
aPluginFuncs->writeready = NPP_WriteReady;
aPluginFuncs->write = NPP_Write;
aPluginFuncs->print = NPP_Print;
aPluginFuncs->event = NPP_HandleEvent;
aPluginFuncs->urlnotify = NPP_URLNotify;
aPluginFuncs->getvalue = NPP_GetValue;
aPluginFuncs->setvalue = NPP_SetValue;
aPluginFuncs->javaClass = NULL;
return NPERR_NO_ERROR;
}
NPError WINAPI NP_Initialize(NPNetscapeFuncs* aNetscapeFuncs)
{
dbgOut1("wrapper: NP_Initalize");
if(aNetscapeFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(HIBYTE(aNetscapeFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;
if(aNetscapeFuncs->size < sizeof NPNetscapeFuncs)
return NPERR_INVALID_FUNCTABLE_ERROR;
NPNFuncs.size = aNetscapeFuncs->size;
NPNFuncs.version = aNetscapeFuncs->version;
NPNFuncs.geturlnotify = aNetscapeFuncs->geturlnotify;
NPNFuncs.geturl = aNetscapeFuncs->geturl;
NPNFuncs.posturlnotify = aNetscapeFuncs->posturlnotify;
NPNFuncs.posturl = aNetscapeFuncs->posturl;
NPNFuncs.requestread = aNetscapeFuncs->requestread;
NPNFuncs.newstream = aNetscapeFuncs->newstream;
NPNFuncs.write = aNetscapeFuncs->write;
NPNFuncs.destroystream = aNetscapeFuncs->destroystream;
NPNFuncs.status = aNetscapeFuncs->status;
NPNFuncs.uagent = aNetscapeFuncs->uagent;
NPNFuncs.memalloc = aNetscapeFuncs->memalloc;
NPNFuncs.memfree = aNetscapeFuncs->memfree;
NPNFuncs.memflush = aNetscapeFuncs->memflush;
NPNFuncs.reloadplugins = aNetscapeFuncs->reloadplugins;
NPNFuncs.getJavaEnv = aNetscapeFuncs->getJavaEnv;
NPNFuncs.getJavaPeer = aNetscapeFuncs->getJavaPeer;
NPNFuncs.getvalue = aNetscapeFuncs->getvalue;
NPNFuncs.setvalue = aNetscapeFuncs->setvalue;
NPNFuncs.invalidaterect = aNetscapeFuncs->invalidaterect;
NPNFuncs.invalidateregion = aNetscapeFuncs->invalidateregion;
NPNFuncs.forceredraw = aNetscapeFuncs->forceredraw;
return NPERR_NO_ERROR;
}
NPError WINAPI NP_Shutdown()
{
dbgOut1("wrapper:NP_Shutdown");
return NPERR_NO_ERROR;
}

View File

@@ -1,260 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "npapi.h"
#include "npupp.h"
#include "dbg.h"
extern NPNetscapeFuncs NPNFuncs;
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
{
dbgOut1("wrapper: NPN_Version");
*plugin_major = NP_VERSION_MAJOR;
*plugin_minor = NP_VERSION_MINOR;
*netscape_major = HIBYTE(NPNFuncs.version);
*netscape_minor = LOBYTE(NPNFuncs.version);
}
NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
{
dbgOut1("wrapper: NPN_GetURLNotify");
int navMinorVers = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
NPError NPN_GetURL(NPP instance, const char *url, const char *target)
{
dbgOut1("wrapper: NPN_GetURL");
NPError rv = NPNFuncs.geturl(instance, url, target);
return rv;
}
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
{
dbgOut1("wrapper: NPN_PostURLNotify");
int navMinorVers = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
{
dbgOut1("wrapper: NPN_PostURL");
NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
return rv;
}
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
{
dbgOut1("wrapper: NPN_RequestRead");
NPError rv = NPNFuncs.requestread(stream, rangeList);
return rv;
}
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
{
dbgOut1("wrapper: NPN_NewStream");
int navMinorVersion = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = NPNFuncs.newstream(instance, type, target, stream);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
{
dbgOut1("wrapper: NPN_Write");
int navMinorVersion = NPNFuncs.version & 0xFF;
int32 rv = 0;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = NPNFuncs.write(instance, stream, len, buffer);
else
rv = -1;
return rv;
}
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
dbgOut1("wrapper: NPN_DestroyStream");
int navMinorVersion = NPNFuncs.version & 0xFF;
NPError rv = NPERR_NO_ERROR;
if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
rv = NPNFuncs.destroystream(instance, stream, reason);
else
rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
return rv;
}
void NPN_Status(NPP instance, const char *message)
{
dbgOut1("wrapper: NPN_Status");
NPNFuncs.status(instance, message);
}
const char* NPN_UserAgent(NPP instance)
{
dbgOut1("wrapper: NPN_UserAgent");
const char * rv = NULL;
rv = NPNFuncs.uagent(instance);
return rv;
}
void* NPN_MemAlloc(uint32 size)
{
//bgOut1("wrapper: NPN_MemAlloc");
void * rv = NULL;
rv = NPNFuncs.memalloc(size);
return rv;
}
void NPN_MemFree(void* ptr)
{
//dbgOut1("wrapper: NPN_MemFree");
NPNFuncs.memfree(ptr);
}
uint32 NPN_MemFlush(uint32 size)
{
dbgOut1("wrapper: NPN_MemFlush");
uint32 rv = NPNFuncs.memflush(size);
return rv;
}
void NPN_ReloadPlugins(NPBool reloadPages)
{
dbgOut1("wrapper: NPN_ReloadPlugins");
NPNFuncs.reloadplugins(reloadPages);
}
JRIEnv* NPN_GetJavaEnv(void)
{
dbgOut1("wrapper: NPN_GetJavaEnv");
JRIEnv * rv = NULL;
rv = NPNFuncs.getJavaEnv();
return rv;
}
jref NPN_GetJavaPeer(NPP instance)
{
dbgOut1("wrapper: NPN_GetJavaPeer");
jref rv;
rv = NPNFuncs.getJavaPeer(instance);
return rv;
}
NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
{
dbgOut1("wrapper: NPN_GetValue");
NPError rv = NPERR_NO_ERROR;
rv = NPNFuncs.getvalue(instance, variable, value);
return rv;
}
NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
{
dbgOut1("wrapper: NPN_SetValue");
NPError rv = NPERR_NO_ERROR;
rv = NPNFuncs.setvalue(instance, variable, value);
return rv;
}
void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
{
dbgOut1("wrapper: NPN_InvalidateRect");
NPNFuncs.invalidaterect(instance, invalidRect);
}
void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
{
dbgOut1("wrapper: NPN_InvalidateRegion");
NPNFuncs.invalidateregion(instance, invalidRegion);
}
void NPN_ForceRedraw(NPP instance)
{
dbgOut1("wrapper: ForceRedraw");
NPNFuncs.forceredraw(instance);
}

View File

@@ -1,189 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "windows.h"
#include "npupp.h"
#include "npapi.h"
#include "plugin.h"
#include "dbg.h"
nsPluginThread * thePluginThread = NULL;
jref NPP_GetJavaClass ()
{
dbgOut1("wrapper: NPP_GetJavaClass");
jref rv = (jref)thePluginThread->callNPP(action_npp_get_java_class);
return NULL;
}
NPError NPP_New(NPMIMEType aType,
NPP aInstance,
uint16 aMode,
int16 aArgc,
char* aArgn[],
char* aArgv[],
NPSavedData* aSaved)
{
dbgOut1("wrapper: NPP_New");
NPError rv = NPERR_NO_ERROR;
// lamely assuming there is only one embed tag on the page!
// if it is first time in, we don't have it yet
// initiate a thread with plugin running in it
thePluginThread = new nsPluginThread((DWORD)aType);
if (!thePluginThread)
return NPERR_GENERIC_ERROR;
rv = (NPError)thePluginThread->callNPP(action_npp_new,
(DWORD)aType,
(DWORD)aInstance,
(DWORD)aMode,
(DWORD)aArgc,
(DWORD)aArgn,
(DWORD)aArgv,
(DWORD)aSaved);
return rv;
}
NPError NPP_Destroy (NPP aInstance, NPSavedData** aSave)
{
dbgOut1("wrapper: NPP_Destroy");
if (!thePluginThread)
return NPERR_GENERIC_ERROR;
NPError ret = (NPError)thePluginThread->callNPP(action_npp_destroy, (DWORD)aInstance, (DWORD)aSave);
delete thePluginThread;
thePluginThread = NULL;
return ret;
}
NPError NPP_SetWindow (NPP aInstance, NPWindow* aNPWindow)
{
dbgOut1("wrapper: NPP_SetWindow");
NPError rv = (NPError)thePluginThread->callNPP(action_npp_set_window, (DWORD)aInstance, (DWORD)aNPWindow);
return rv;
}
NPError NPP_NewStream(NPP aInstance,
NPMIMEType aType,
NPStream* aStream,
NPBool aSeekable,
uint16* aStype)
{
dbgOut1("wrapper: NPP_NewStream");
NPError rv = (NPError)thePluginThread->callNPP(action_npp_new_stream, (DWORD)aInstance, (DWORD)aType, (DWORD)aStream, (DWORD)aSeekable, (DWORD)aStype);
return rv;
}
int32 NPP_WriteReady (NPP aInstance, NPStream *aStream)
{
dbgOut1("wrapper: NPP_WriteReady");
int32 rv = (int32)thePluginThread->callNPP(action_npp_write_ready, (DWORD)aInstance, (DWORD)aStream);
return rv;
}
int32 NPP_Write (NPP aInstance, NPStream *aStream, int32 aOffset, int32 len, void *aBuffer)
{
dbgOut1("wrapper: NPP_Write");
int32 rv = (int32)thePluginThread->callNPP(action_npp_write, (DWORD)aInstance, (DWORD)aStream, (DWORD)aOffset, (DWORD)len, (DWORD)aBuffer);
return rv;
}
NPError NPP_DestroyStream (NPP aInstance, NPStream *aStream, NPError aReason)
{
dbgOut1("wrapper: NPP_DestroyStream");
NPError rv = (NPError)thePluginThread->callNPP(action_npp_destroy_stream, (DWORD)aInstance, (DWORD)aStream, (DWORD)aReason);
return rv;
}
void NPP_StreamAsFile (NPP aInstance, NPStream* aStream, const char* aName)
{
dbgOut1("wrapper: NPP_StreamAsFile");
thePluginThread->callNPP(action_npp_stream_as_file, (DWORD)aInstance, (DWORD)aStream, (DWORD)aName);
}
void NPP_Print (NPP aInstance, NPPrint* aPrintInfo)
{
dbgOut1("wrapper: NPP_Print");
thePluginThread->callNPP(action_npp_print, (DWORD)aInstance, (DWORD)aPrintInfo);
}
void NPP_URLNotify(NPP aInstance, const char* aUrl, NPReason aReason, void* aNotifyData)
{
dbgOut1("wrapper: NPP_URLNotify");
thePluginThread->callNPP(action_npp_url_notify, (DWORD)aInstance, (DWORD)aUrl, (DWORD)aReason, (DWORD)aNotifyData);
}
NPError NPP_GetValue(NPP aInstance, NPPVariable aVariable, void *aValue)
{
dbgOut1("wrapper: NPP_GetValue");
NPError rv = (NPError)thePluginThread->callNPP(action_npp_get_value, (DWORD)aInstance, (DWORD)aVariable, (DWORD)aValue);
return rv;
}
NPError NPP_SetValue(NPP aInstance, NPNVariable aVariable, void *aValue)
{
dbgOut1("wrapper: NPP_SetValue");
NPError rv = (NPError)thePluginThread->callNPP(action_npp_set_value, (DWORD)aInstance, (DWORD)aVariable, (DWORD)aValue);
return rv;
}
int16 NPP_HandleEvent(NPP aInstance, void* aEvent)
{
dbgOut1("wrapper: NPP_HandleEvent");
int16 rv = (int16)thePluginThread->callNPP(action_npp_handle_event, (DWORD)aInstance, (DWORD)aEvent);
return rv;
}

View File

@@ -1,6 +0,0 @@
LIBRARY NPTHREAD
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3

View File

@@ -1,162 +0,0 @@
# Microsoft Developer Studio Project File - Name="npthread" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=npthread - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "npthread.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "npthread.mak" CFG="npthread - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "npthread - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "npthread - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "npthread - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPTHREAD_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPTHREAD_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
!ELSEIF "$(CFG)" == "npthread - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "npthread___Win32_Debug"
# PROP BASE Intermediate_Dir "npthread___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPTHREAD_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\..\dist\include\plugin" /I "..\..\..\..\..\dist\include\java" /I "..\..\..\..\..\dist\include\nspr" /D "XP_WIN" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NPTHREAD_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib version.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "npthread - Win32 Release"
# Name "npthread - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\action.cpp
# End Source File
# Begin Source File
SOURCE=.\dbg.cpp
# End Source File
# Begin Source File
SOURCE=.\np_entry.cpp
# End Source File
# Begin Source File
SOURCE=.\npn_gate.cpp
# End Source File
# Begin Source File
SOURCE=.\npp_gate.cpp
# End Source File
# Begin Source File
SOURCE=.\npthread.def
# End Source File
# Begin Source File
SOURCE=.\npthread.rc
# End Source File
# Begin Source File
SOURCE=.\plugin.cpp
# End Source File
# Begin Source File
SOURCE=.\plugload.cpp
# End Source File
# Begin Source File
SOURCE=.\thread.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\action.h
# End Source File
# Begin Source File
SOURCE=.\dbg.h
# End Source File
# Begin Source File
SOURCE=.\plugin.h
# End Source File
# Begin Source File
SOURCE=.\plugload.h
# End Source File
# Begin Source File
SOURCE=.\thread.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "npthread"=.\npthread.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,112 +0,0 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", " \0"
VALUE "FileDescription", "npthread\0"
VALUE "FileExtents", "thr\0"
VALUE "FileOpenName", "npthread\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "npthread\0"
VALUE "LegalCopyright", "Copyright © 2002\0"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "*\0"
VALUE "OriginalFilename", "npthread\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "Thread plugin wrapper\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -1,233 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "windows.h"
#include "npupp.h"
#include "npapi.h"
#include "plugin.h"
#include "plugload.h"
#include "dbg.h"
extern NPNetscapeFuncs NPNFuncs;
NPNetscapeFuncs wrapperNPNFuncs;
NPPluginFuncs pluginNPPFuncs;
typedef NPError (__stdcall * NP_GETENTRYPOINTS)(NPPluginFuncs *);
typedef NPError (__stdcall * NP_INITIALIZE)(NPNetscapeFuncs *);
typedef NPError (__stdcall * NP_SHUTDOWN)(void);
NP_SHUTDOWN plugin_NP_Shutdown = NULL;
HINSTANCE pluginLibrary = NULL;
nsPluginThread::nsPluginThread(DWORD aP1) : CThread(),
mP1(aP1),
mP2(0),
mP3(0),
mP4(0),
mP5(0),
mP6(0),
mP7(0)
{
dbgOut1("nsPluginThread::nsPluginThread");
open(this);
}
nsPluginThread::~nsPluginThread()
{
dbgOut1("nsPluginThread::~nsPluginThread");
close(this);
}
BOOL nsPluginThread::init()
{
dbgOut1("nsPluginThread::init");
// scan plugins dir for available plugins to see if we have anything
// for the given mimetype
pluginLibrary = LoadRealPlugin((NPMIMEType)mP1);
if(!pluginLibrary)
return FALSE;
NP_GETENTRYPOINTS plugin_NP_GetEntryPoints = (NP_GETENTRYPOINTS)GetProcAddress(pluginLibrary, "NP_GetEntryPoints");
if(!plugin_NP_GetEntryPoints)
return FALSE;
NP_INITIALIZE plugin_NP_Initialize = (NP_INITIALIZE)GetProcAddress(pluginLibrary, "NP_Initialize");
if(!plugin_NP_Initialize)
return FALSE;
plugin_NP_Shutdown = (NP_SHUTDOWN)GetProcAddress(pluginLibrary, "NP_Shutdown");
if(!plugin_NP_Shutdown)
return FALSE;
// fill callbacks structs
memset(&pluginNPPFuncs, 0, sizeof(NPPluginFuncs));
pluginNPPFuncs.size = sizeof(NPPluginFuncs);
plugin_NP_GetEntryPoints(&pluginNPPFuncs);
// inform the plugin about our entry point it should call
memset((void *)&wrapperNPNFuncs, 0, sizeof(wrapperNPNFuncs));
wrapperNPNFuncs.size = sizeof(wrapperNPNFuncs);
wrapperNPNFuncs.version = NPNFuncs.version;
wrapperNPNFuncs.geturlnotify = NPN_GetURLNotify;
wrapperNPNFuncs.geturl = NPN_GetURL;
wrapperNPNFuncs.posturlnotify = NPN_PostURLNotify;
wrapperNPNFuncs.posturl = NPN_PostURL;
wrapperNPNFuncs.requestread = NPN_RequestRead;
wrapperNPNFuncs.newstream = NPN_NewStream;
wrapperNPNFuncs.write = NPN_Write;
wrapperNPNFuncs.destroystream = NPN_DestroyStream;
wrapperNPNFuncs.status = NPN_Status;
wrapperNPNFuncs.uagent = NPN_UserAgent;
wrapperNPNFuncs.memalloc = NPN_MemAlloc;
wrapperNPNFuncs.memfree = NPN_MemFree;
wrapperNPNFuncs.memflush = NPN_MemFlush;
wrapperNPNFuncs.reloadplugins = NPN_ReloadPlugins;
wrapperNPNFuncs.getJavaEnv = NPN_GetJavaEnv;
wrapperNPNFuncs.getJavaPeer = NPN_GetJavaPeer;
wrapperNPNFuncs.getvalue = NPN_GetValue;
wrapperNPNFuncs.setvalue = NPN_SetValue;
wrapperNPNFuncs.invalidaterect = NPN_InvalidateRect;
wrapperNPNFuncs.invalidateregion = NPN_InvalidateRegion;
wrapperNPNFuncs.forceredraw = NPN_ForceRedraw;
plugin_NP_Initialize(&wrapperNPNFuncs);
return TRUE;
}
void nsPluginThread::shut()
{
dbgOut1("nsPluginThread::shut");
if (!plugin_NP_Shutdown)
plugin_NP_Shutdown();
if (!pluginLibrary)
UnloadRealPlugin(pluginLibrary);
}
// NPP_ call translator
DWORD nsPluginThread::callNPP(npapiAction aAction, DWORD aP1, DWORD aP2,
DWORD aP3, DWORD aP4, DWORD aP5,
DWORD aP6, DWORD aP7)
{
// don't enter untill thread is ready
while (isBusy()) {
Sleep(0);
}
mP1 = aP1;
mP2 = aP2;
mP3 = aP3;
mP4 = aP4;
mP5 = aP5;
mP6 = aP6;
mP7 = aP7;
doAction(aAction);
// don't return untill thread is ready
while (isBusy()) {
Sleep(0);
}
return NPERR_NO_ERROR;
}
void nsPluginThread::dispatch()
{
dbgOut2("nsPluginThread::dispatch: %s", FormatAction(mAction));
switch (mAction) {
case action_npp_new:
pluginNPPFuncs.newp((NPMIMEType)mP1, (NPP)mP2, (uint16)mP3, (int16)mP4, (char**)mP5, (char**)mP6, (NPSavedData*)mP7);
break;
case action_npp_destroy:
pluginNPPFuncs.destroy((NPP)mP1, (NPSavedData**)mP2);
break;
case action_npp_set_window:
pluginNPPFuncs.setwindow((NPP)mP1, (NPWindow*)mP2);
break;
case action_npp_new_stream:
pluginNPPFuncs.newstream((NPP)mP1, (NPMIMEType)mP2, (NPStream*)mP3, (NPBool)mP4, (uint16*)mP5);
break;
case action_npp_destroy_stream:
{
NPStream * stream = (NPStream *)mP2;
pluginNPPFuncs.destroystream((NPP)mP1, stream, (NPError)mP3);
break;
}
case action_npp_stream_as_file:
{
NPStream * stream = (NPStream *)mP2;
pluginNPPFuncs.asfile((NPP)mP1, stream, (char*)mP3);
break;
}
case action_npp_write_ready:
pluginNPPFuncs.writeready((NPP)mP1, (NPStream *)mP2);
break;
case action_npp_write:
pluginNPPFuncs.write((NPP)mP1, (NPStream *)mP2, (int32)mP3, (int32)mP4, (void *)mP5);
break;
case action_npp_print:
pluginNPPFuncs.print((NPP)mP1, (NPPrint*)mP2);
break;
case action_npp_handle_event:
pluginNPPFuncs.event((NPP)mP1, (void *)mP2);
break;
case action_npp_url_notify:
pluginNPPFuncs.urlnotify((NPP)mP1, (const char*)mP2, (NPReason)mP3, (void*)mP4);
break;
case action_npp_get_java_class:
//pluginNPPFuncs.javaClass;
break;
case action_npp_get_value:
pluginNPPFuncs.getvalue((NPP)mP1, (NPPVariable)mP2, (void *)mP3);
break;
case action_npp_set_value:
pluginNPPFuncs.setvalue((NPP)mP1, (NPNVariable)mP2, (void *)mP3);
break;
default:
dbgOut1("Unexpected action!");
break;
}
}

View File

@@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _PLUGIN_H_
#define _PLUGIN_H_
#include "thread.h"
#include "action.h"
class nsPluginThread : CThread
{
public:
nsPluginThread(DWORD aP1);
~nsPluginThread();
private:
BOOL init();
void shut();
void dispatch();
public:
DWORD callNPP(npapiAction aAction, DWORD aP1=NULL,
DWORD aP2=NULL, DWORD aP3=NULL, DWORD aP4=NULL,
DWORD aP5=NULL, DWORD aP6=NULL, DWORD aP7=NULL);
private:
DWORD mP1;
DWORD mP2;
DWORD mP3;
DWORD mP4;
DWORD mP5;
DWORD mP6;
DWORD mP7;
};
#endif // _PLUGIN_H_

View File

@@ -1,153 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "windows.h"
DWORD GetPluginsDir(char * path, DWORD maxsize)
{
if(!path)
return 0;
path[0] = '\0';
DWORD res = GetModuleFileName(NULL, path, maxsize);
if(res == 0)
return 0;
if(path[strlen(path) - 1] == '\\')
path[lstrlen(path) - 1] = '\0';
char *p = strrchr(path, '\\');
if(p)
*p = '\0';
strcat(path, "\\plugins");
res = strlen(path);
return res;
}
HINSTANCE LoadRealPlugin(char * mimetype)
{
if(!mimetype || !strlen(mimetype))
return NULL;
BOOL bDone = FALSE;
WIN32_FIND_DATA ffdataStruct;
char szPath[_MAX_PATH];
char szFileName[_MAX_PATH];
GetPluginsDir(szPath, _MAX_PATH);
strcpy(szFileName, szPath);
strcat(szFileName, "\\00*");
HANDLE handle = FindFirstFile(szFileName, &ffdataStruct);
if(handle == INVALID_HANDLE_VALUE) {
FindClose(handle);
return NULL;
}
DWORD versize = 0L;
DWORD zero = 0L;
char * verbuf = NULL;
do {
strcpy(szFileName, szPath);
strcat(szFileName, "\\");
strcat(szFileName, ffdataStruct.cFileName);
if(!(ffdataStruct. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
versize = GetFileVersionInfoSize(szFileName, &zero);
if (versize > 0)
verbuf = new char[versize];
else
continue;
if(!verbuf)
continue;
GetFileVersionInfo(szFileName, NULL, versize, verbuf);
char *mimetypes = NULL;
UINT len = 0;
if(!VerQueryValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType", (void **)&mimetypes, &len)
|| !mimetypes || !len) {
delete [] verbuf;
continue;
}
// browse through a string of mimetypes
mimetypes[len] = '\0';
char * type = mimetypes;
BOOL more = TRUE;
while(more) {
char * p = strchr(type, '|');
if(p)
*p = '\0';
else
more = FALSE;
if(0 == stricmp(mimetype, type)) {
// this is it!
delete [] verbuf;
FindClose(handle);
HINSTANCE hLib = LoadLibrary(szFileName);
return hLib;
}
type = p;
type++;
}
delete [] verbuf;
}
} while(FindNextFile(handle, &ffdataStruct));
FindClose(handle);
return NULL;
}
void UnloadRealPlugin(HINSTANCE hLib)
{
if(!hLib)
FreeLibrary(hLib);
}

View File

@@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __PLUGLOAD_H__
#define __PLUGLOAD_H__
DWORD GetPluginsDir(char * path, DWORD maxsize);
HINSTANCE LoadRealPlugin(char * mimetype);
void UnloadRealPlugin(HINSTANCE hLib);
#endif

View File

@@ -1,24 +0,0 @@
03-05-2002
This sample is an attempt to write a wrapper plugin which would run the
real plugin in a separate thread. The current code is just a first prototype
version aimed to determine the very possibility of such thing. It is not
designed to handle more than one instance of one plugin. Another limitations
are: it only relays browser-to-plugin calls in thread event based matter
(calls from the plugin to the browser are just made directly by function
pointer; it does not implement notifications back from the plugin thread
to the calling thread, so it simply waits before each NPP_* call until
the plugin thread is done with the previous NPP_* call.
The wrapper tested with Basic plugin sample from the plugin
SDK, so some common plugin crashes can be modelled. Work is still
required to make it functional with more complicated plugins
like Flash.
Steps to see it in action:
-- place the wrapper plugin (npthread.dll) in the plugins folder
-- remove npnul32.dll from the plugins folder
-- rename the plugin you want to run in a separate thread adding
two zeroes at the beginnig (ren npbasic.dll 00npbasic.dll)
-- run test case for the plugin in question

Some files were not shown because too many files have changed in this diff Show More