now MSW stuff is complete

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1998-05-20 14:21:00 +00:00
parent 2bda0e1738
commit bbf1f0e5cf
118 changed files with 9265 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
Notes about plugins
I have users that want to visit my pages with tclets, but they do not
have the plugin. What can I do?
Add a pluginspage=http://www.sunlabs.com/tcl/plugin/ name=value
pair to the embed statement. This will cause Navigator to find
the plugin for your user and suggest they install it. The user
is then prompted to download and install the plugin, and then she
has to restart the browser and revisit your page. Very inconvenient
and only slightly better than giving your users the broken image
icon. Netscape says they are working on a more automatic solution.
14. Your demos work just fine, but when I visit my own pages with tclets in
them, at http://www.myserver.com/~mypages/mypage.html, I still get the
broken image icon. Why doesn't it work for me?
This is likely because your web server -- the program that sends
the pages to your browser when you click on a URL -- is not
sending the right mime-type when it sends the '.tcl' file. You
can work around this by adding a type=application/x-tcl name=value
pair to the embed statement, which will cause Navigator to infer
that it should use the Tcl plugin anyways. A better solution is
to ask your system administrator to configure the web server to
send the mime type application/x-tcl when it sends files with a
'.tcl' extension. Nearly all web servers in the world nowadays
are already configured to do this, the only ones we are aware of
that do not are some older versions of Apache.

1
utils/nplugin/lib/dummy Normal file
View File

@@ -0,0 +1 @@
I'm just here to force the creation of a LIB directory.

View File

@@ -0,0 +1,186 @@
/*
* File: simple.cpp
* Purpose: Minimal wxWindows plugin
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
/* static const char sccsid[] = "%W% %G%"; */
#ifdef __GNUG__
#pragma implementation
#pragma interface
#endif
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <fstream.h>
#include "NPApp.h"
#include "NPFrame.h"
#define ID_HELLO 10
// Define a new application type
class MyApp: public wxPluginApp
{ public:
virtual wxFrame *OnInit(void);
virtual wxPluginFrame* OnNewInstance(const wxPluginData& data);
};
// Define a new frame type
class MyFrame: public wxPluginFrame
{ public:
MyFrame(const wxPluginData& data);
public:
// Let's paint directly onto the 'frame'; we don't need a subwindow
void OnPaint(wxPaintEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnHello(wxCommandEvent& event);
// Called when the file has been downloaded
virtual void OnNPNewFile(NPStream *stream, const wxString& fname);
void CentreStrings(wxDC& dc);
DECLARE_EVENT_TABLE()
protected:
wxStringList m_strings;
float m_xpos;
float m_ypos;
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE(MyFrame::OnSize)
EVT_PAINT(MyFrame::OnPaint)
EVT_MOUSE_EVENTS(MyFrame::OnMouseEvent)
EVT_BUTTON(ID_HELLO, MyFrame::OnHello)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
// No app initialisation necessary, and for a plugin there is no
// top frame.
wxFrame *MyApp::OnInit(void)
{
return NULL;
}
// Called whenever a new plugin instance is called. We could check
// various things here in 'data' but we won't bother.
wxPluginFrame* MyApp::OnNewInstance(const wxPluginData& data)
{
// Implicitly added to list of plugin frames
return new MyFrame(data);
}
// My frame constructor
MyFrame::MyFrame(const wxPluginData& data):
wxPluginFrame(data)
{
m_xpos = -1;
m_ypos = -1;
wxMenuBar *menuBar = new wxMenuBar;
wxMenu *menu = new wxMenu;
menu->Append(1, "E&xit");
menuBar->Append(menu, "&File");
SetMenuBar(menuBar);
new wxTextCtrl(this, -1, "", wxPoint(10, 30), wxSize(200, 25), wxSUNKEN_BORDER);
new wxButton(this, ID_HELLO, "Hello", wxPoint(10, 70));
}
void MyFrame::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
int w, h;
GetClientSize(&w, &h);
dc.DrawRectangle(0, 0, w, h);
wxFont swissFont(10, wxSWISS, wxNORMAL, wxNORMAL);
dc.SetFont(swissFont);
dc.SetBackgroundMode(wxTRANSPARENT);
CentreStrings(dc);
}
// Called when the file has been downloaded
void MyFrame::OnNPNewFile(NPStream *stream, const wxString& fname)
{
ifstream str(fname);
char buf[201];
while ( !str.eof() )
{
buf[0] = 0;
str.getline(buf, 200);
if ( buf[0] != 0 )
m_strings.Add(buf);
}
Refresh();
}
void MyFrame::CentreStrings(wxDC& dc)
{
int y = 5;
int cw, ch;
GetClientSize(&cw, &ch);
wxNode *node = m_strings.First();
while ( node )
{
char *s = (char *)node->Data();
float w, h;
dc.GetTextExtent(s, &w, &h);
int x = wxMax(0, (cw - w)/2);
dc.DrawText(s, x, y);
y += h + (h/2);
node = node->Next();
}
}
// This implements a tiny doodling program. Drag the mouse using
// the left button.
void MyFrame::OnMouseEvent(wxMouseEvent& event)
{
float x, y;
event.Position(&x, &y);
wxClientDC dc(this);
if (m_xpos > -1 && m_ypos > -1 && event.Dragging() && event.LeftIsDown())
{
dc.SetPen(wxBLACK_PEN);
dc.SetBrush(wxTRANSPARENT_BRUSH);
dc.DrawLine(m_xpos, m_ypos, x, y);
}
m_xpos = x;
m_ypos = y;
}
void MyFrame::OnHello(wxCommandEvent& event)
{
wxMessageBox("Hello!");
}

View File

@@ -0,0 +1,59 @@
/*
* File: gui.h
* Purpose: wxWindows plugin with a few GUI elements
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
#ifndef __GUIH__
#define __GUIH__
// Define a new application type
class MyApp: public wxPluginApp
{ public:
virtual wxFrame *OnInit(void);
virtual wxPluginFrame* OnNewInstance(const wxPluginData& data);
};
class MyApp;
class MyFrame;
class MyCanvas;
class MyFrame: public wxPluginFrame
{
public:
MyFrame(const wxPluginData& data);
virtual ~MyFrame();
void OldOnMenuCommand(int id);
private:
wxMenu* fileMenu;
wxMenuBar* menuBar;
MyCanvas* leftCanvas;
MyCanvas* rightCanvas;
wxSplitterWindow* splitter;
};
class MyCanvas: public wxScrolledWindow
{
public:
MyCanvas(wxWindow* parent, int x, int y, int w, int h);
virtual ~MyCanvas();
void OnPaint(wxPaintEvent& event);
DECLARE_EVENT_TABLE()
};
// ID for the menu quit command
#define SPLIT_QUIT 1
#define SPLIT_HORIZONTAL 2
#define SPLIT_VERTICAL 3
#define SPLIT_UNSPLIT 4
#endif

View File

@@ -0,0 +1,70 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1997
# Updated:
# Copyright: (c) 1997, Julian Smart
#
# "%W% %G%"
#
# Makefile : Builds gui plugin example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
# Application is a DLL
DLL=1
EXTRAINC=/I$(WXDIR)\utils\nplugin\src
!include $(WXDIR)\src\ntwxwin.mak
THISDIR = $(WXDIR)\utils\nplugin\examples\gui
PROGRAM=npgui32
PLUGINLIB=$(WXDIR)\utils\nplugin\lib\nplugin.lib
OBJECTS = gui.obj
all: $(PROGRAM).dll
$(PROGRAM): $(PROGRAM).exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.nt dllnp FINAL=$(FINAL)
cd $(THISDIR)
# Update the dynamic link library
$(PROGRAM).dll: $(DUMMYOBJ) $(OBJECTS) $(WXDIR)\lib\wx.lib $(PLUGINLIB) $(PROGRAM).res $(PROGRAM).def
$(link) $(LINKFLAGS) \
-out:$(PROGRAM).dll \
-def:$(PROGRAM).def \
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res $(WXDIR)\lib\wx.lib $(PLUGINLIB) \
$(guilibsdll) msvcrt.lib shell32.lib comctl32.lib ctl3d32.lib
gui.obj: gui.$(SRCSUFF) gui.h $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
copy:
copy npgui32.dll "c:\program files\Netscape\Navigator\program\plugins"
copy npgui32.dll "c:\program files\Internet Explorer\plugins"
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb
-erase *.dll
-erase *.exp
-erase *.lib
-erase *.ilk

View File

@@ -0,0 +1,9 @@
LIBRARY NPGUI32
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3

View File

@@ -0,0 +1,44 @@
#include "wx/msw/wx.rc"
/////////////////////////////////////////////////////////////////////////////
//
// 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 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "Julian Smart\0"
VALUE "FileDescription", "wxWindows GUI example plugin file\0"
VALUE "FileVersion", "0.0.0.1\0"
VALUE "InternalName", "wxWindows GUI Plugin\0"
VALUE "LegalCopyright", "Copyright Julian Smart 1997\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename","npgui32.dll\0"
VALUE "ProductName", "wxWindows GUI Plugin Sample\0"
VALUE "ProductVersion", "0.0.0.1\0"
VALUE "MIMEType", "wxgui/mime-type\0"
VALUE "FileExtents", "gui\0"
VALUE "FileOpenName", "wxWindows GUI (*.gui)\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

View File

@@ -0,0 +1,70 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1997
# Updated:
# Copyright: (c) 1997, Julian Smart
#
# "%W% %G%"
#
# Makefile : Builds simple plugin example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
# Application is a DLL
DLL=1
EXTRAINC=/I$(WXDIR)\utils\nplugin\src
!include $(WXDIR)\src\ntwxwin.mak
THISDIR = $(WXDIR)\utils\nplugin\smples\simple
PROGRAM=npsimple32
PLUGINLIB=$(WXDIR)\utils\nplugin\lib\nplugin.lib
OBJECTS = simple.obj
all: $(PROGRAM).dll
$(PROGRAM): $(PROGRAM).exe
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.nt dllnp FINAL=$(FINAL)
cd $(THISDIR)
# Update the dynamic link library
$(PROGRAM).dll: $(DUMMYOBJ) $(OBJECTS) $(WXDIR)\lib\wx.lib $(PLUGINLIB) $(PROGRAM).res $(PROGRAM).def
$(link) $(LINKFLAGS) \
-out:$(PROGRAM).dll \
-def:$(PROGRAM).def \
$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res $(WXDIR)\lib\wx.lib $(PLUGINLIB) \
$(guilibsdll) msvcrt.lib shell32.lib comctl32.lib ctl3d32.lib
simple.obj: simple.$(SRCSUFF) $(DUMMYOBJ)
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
copy:
copy npsimple32.dll "c:\program files\Netscape\Navigator\program\plugins"
copy npsimple32.dll "c:\program files\Internet Explorer\plugins"
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb
-erase *.dll
-erase *.exp
-erase *.lib
-erase *.ilk

View File

@@ -0,0 +1,9 @@
LIBRARY NPSIMPLE32
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD SINGLE
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3

View File

@@ -0,0 +1,44 @@
#include "wx/msw/wx.rc"
/////////////////////////////////////////////////////////////////////////////
//
// 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 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "Julian Smart\0"
VALUE "FileDescription", "wxWindows simple example plugin file\0"
VALUE "FileVersion", "0.0.0.1\0"
VALUE "InternalName", "wxWindows Simple Plugin\0"
VALUE "LegalCopyright", "Copyright Julian Smart 1997\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename","npsimple32.dll\0"
VALUE "ProductName", "wxWindows Simple Plugin Sample\0"
VALUE "ProductVersion", "0.0.0.1\0"
VALUE "MIMEType", "wxsimple/mime-type\0"
VALUE "FileExtents", "smp\0"
VALUE "FileOpenName", "wxWindows Simple (*.smp)\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

View File

@@ -0,0 +1,174 @@
/*
* File: simple.cpp
* Purpose: Minimal wxWindows plugin
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
/* static const char sccsid[] = "%W% %G%"; */
#ifdef __GNUG__
#pragma implementation
#pragma interface
#endif
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include <fstream.h>
#include "NPApp.h"
#include "NPFrame.h"
// Define a new application type
class MyApp: public wxPluginApp
{ public:
virtual wxFrame *OnInit(void);
virtual wxPluginFrame* OnNewInstance(const wxPluginData& data);
};
// Define a new frame type
class MyFrame: public wxPluginFrame
{ public:
MyFrame(const wxPluginData& data);
public:
// Let's paint directly onto the 'frame'; we don't need a subwindow
void OnPaint(wxPaintEvent& event);
void OnDraw(wxDC& dc);
void OnMouseEvent(wxMouseEvent& event);
// Called when the file has been downloaded
virtual void OnNPNewFile(NPStream *stream, const wxString& fname);
void CentreStrings(wxDC& dc);
DECLARE_EVENT_TABLE()
protected:
wxStringList m_strings;
long m_xpos;
long m_ypos;
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_SIZE(MyFrame::OnSize)
EVT_PAINT(MyFrame::OnPaint)
EVT_MOUSE_EVENTS(MyFrame::OnMouseEvent)
END_EVENT_TABLE()
IMPLEMENT_APP(MyApp)
// No app initialisation necessary, and for a plugin there is no
// top frame.
wxFrame *MyApp::OnInit(void)
{
return NULL;
}
// Called whenever a new plugin instance is called. We could check
// various things here in 'data' but we won't bother.
wxPluginFrame* MyApp::OnNewInstance(const wxPluginData& data)
{
// Implicitly added to list of plugin frames
return new MyFrame(data);
}
// My frame constructor
MyFrame::MyFrame(const wxPluginData& data):
wxPluginFrame(data)
{
m_xpos = -1;
m_ypos = -1;
}
void MyFrame::OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
OnDraw(dc);
}
void MyFrame::OnDraw(wxDC& dc)
{
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
int w, h;
GetClientSize(&w, &h);
dc.DrawRectangle(0, 0, w, h);
wxFont swissFont(10, wxSWISS, wxNORMAL, wxNORMAL);
dc.SetFont(swissFont);
dc.SetBackgroundMode(wxTRANSPARENT);
CentreStrings(dc);
}
// Called when the file has been downloaded
void MyFrame::OnNPNewFile(NPStream *stream, const wxString& fname)
{
ifstream str(fname);
char buf[201];
while ( !str.eof() )
{
buf[0] = 0;
str.getline(buf, 200);
if ( buf[0] != 0 )
m_strings.Add(buf);
}
Refresh();
}
void MyFrame::CentreStrings(wxDC& dc)
{
int y = 5;
int cw, ch;
GetClientSize(&cw, &ch);
wxNode *node = m_strings.First();
while ( node )
{
char *s = (char *)node->Data();
long w, h;
dc.GetTextExtent(s, &w, &h);
int x = wxMax(0, (cw - w)/2);
dc.DrawText(s, x, y);
y += h + (h/2);
node = node->Next();
}
}
// This implements a tiny doodling program. Drag the mouse using
// the left button.
void MyFrame::OnMouseEvent(wxMouseEvent& event)
{
long x, y;
event.Position(&x, &y);
wxClientDC dc(this);
if (m_xpos > -1 && m_ypos > -1 && event.Dragging() && event.LeftIsDown())
{
dc.SetPen(wxBLACK_PEN);
dc.SetBrush(wxTRANSPARENT_BRUSH);
dc.DrawLine(m_xpos, m_ypos, x, y);
}
m_xpos = x;
m_ypos = y;
}

View File

@@ -0,0 +1,78 @@
#
# File: makefile.nt
# Author: Julian Smart
# Created: 1993
# Updated:
# Copyright: (c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds controls example (MS VC++).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info
# Set WXDIR for your system
WXDIR = $(WXWIN)
# Application is a DLL
DLL=1
!include $(WXDIR)\src\ntwxwin.mak
PLUGINDIR = $(WXDIR)\utils\nplugin
THISDIR = $(PLUGINDIR)\src
LIBTARGET=$(PLUGINDIR)\lib\nplugin.lib
OBJECTS = npwin.obj npshell.obj NPFrame.obj NPApp.obj
all: $(LIBTARGET)
wx:
cd $(WXDIR)\src\msw
nmake -f makefile.nt FINAL=$(FINAL)
cd $(THISDIR)
wxclean:
cd $(WXDIR)\src\msw
nmake -f makefile.nt clean
cd $(THISDIR)
$(LIBTARGET): $(OBJECTS)
-erase $(LIBTARGET)
$(implib) @<<
-out:$(LIBTARGET)
-machine:$(CPU)
$(OBJECTS)
<<
npwin.obj: npwin.cpp npapi.h npupp.h
$(cc) @<<
$(CPPFLAGS2) /c /Tp $*.$(SRCSUFF)
<<
npshell.obj: npshell.cpp npapi.h NPApp.h NPFrame.h
$(cc) @<<
$(CPPFLAGS2) /c /Tp $*.$(SRCSUFF)
<<
NPFrame.obj: NPFrame.cpp NPFrame.h NPApp.h npapi.h
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
NPApp.obj: NPApp.cpp NPApp.h NPFrame.h npapi.h
$(cc) @<<
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
<<
clean:
-erase *.obj
-erase *.exe
-erase *.res
-erase *.map
-erase *.sbr
-erase *.pdb
-erase *.dll
-erase *.exp
-erase *.ilk
-erase $(LIBTARGET)

258
utils/nplugin/src/npapi.h Normal file
View File

@@ -0,0 +1,258 @@
/*
* npapi.h $Revision$
* Netscape client plug-in API spec
*/
#ifndef _NPAPI_H_
#define _NPAPI_H_
/* XXX this needs to get out of here */
#if defined(__MWERKS__)
#ifndef XP_MAC
#define XP_MAC
#endif
#endif
/*
* Version constants
*/
#define NP_VERSION_MAJOR 0
#define NP_VERSION_MINOR 6
/*
* Basic types
*/
#ifndef _UINT16
typedef unsigned short uint16;
#endif
#ifndef _UINT32
typedef unsigned long uint32;
#endif
#ifndef _INT16
typedef short int16;
#endif
#ifndef _INT32
typedef long int32;
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef NULL
#define NULL (0L)
#endif
typedef unsigned char NPBool;
typedef void* NPEvent;
typedef int16 NPError;
typedef char* NPMIMEType;
/*
* NPP is a plug-in's opaque instance handle
*/
typedef struct _NPP
{
void* pdata; /* plug-in private data */
void* ndata; /* netscape private data */
} NPP_t;
typedef NPP_t* NPP;
typedef struct _NPStream
{
void* pdata; /* plug-in private data */
void* ndata; /* netscape private data */
const char* url;
uint32 end;
uint32 lastmodified;
} NPStream;
typedef struct _NPByteRange
{
int32 offset; /* negative offset means from the end */
uint32 length;
struct _NPByteRange* next;
} NPByteRange;
typedef struct _NPSavedData
{
int32 len;
void* buf;
} NPSavedData;
typedef struct _NPRect
{
uint16 top;
uint16 left;
uint16 bottom;
uint16 right;
} NPRect;
typedef struct _NPWindow
{
void* window; /* platform specific window handle */
uint32 x; /* position of top left corner relative to a netscape page */
uint32 y;
uint32 width; /* maximum window size */
uint32 height;
NPRect clipRect; /* clipping rectangle in port coordinates */
} NPWindow;
typedef struct _NPFullPrint
{
NPBool pluginPrinted; /* Set TRUE if plugin handled fullscreen printing */
NPBool printOne; /* TRUE if plugin should print one copy to default printer */
void* platformPrint; /* Platform-specific printing info */
} NPFullPrint;
typedef struct _NPEmbedPrint
{
NPWindow window;
void* platformPrint; /* Platform-specific printing info */
} NPEmbedPrint;
typedef struct _NPPrint
{
uint16 mode; /* NP_FULL or NP_EMBED */
union
{
NPFullPrint fullPrint; /* if mode is NP_FULL */
NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
} print;
} NPPrint;
#ifdef XP_MAC
/*
* Mac-specific structures and definitions.
*/
#include <Quickdraw.h>
#include <Events.h>
typedef struct NP_Port
{
CGrafPtr port; /* Grafport */
int32 portx; /* position inside the topmost window */
int32 porty;
} NP_Port;
/*
* Non-standard event types that can be passed to HandleEvent
*/
#define getFocusEvent (osEvt + 16)
#define loseFocusEvent (osEvt + 17)
#define adjustCursorEvent (osEvt + 18)
#endif /* XP_MAC */
#define NP_EMBED 1
#define NP_FULL 2
#define NP_BACKGROUND 3
#define NP_NORMAL 1
#define NP_SEEK 2
#define NP_ASFILE 3
#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
/*
* Error and reason code definitions.
*/
#define NP_NOERR 0
#define NP_EINVAL 1
#define NP_EABORT 2
#define NPERR_BASE 0
#define NPERR_NO_ERROR (NPERR_BASE + 0)
#define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
#define NPRES_BASE 0
#define NPRES_NETWORK_ERR (NPRES_BASE + 0)
#define NPRES_USER_BREAK (NPRES_BASE + 1)
#define NPRES_DONE (NPRES_BASE + 3)
/*
* Function prototypes.
* Functions beginning with 'NPP' are functions provided by the plugin that Netscape will call.
* Functions beginning with 'NPN' are functions provided by Netscape that the plugin will call.
*/
#if defined(_WINDOWS) && !defined(__WIN32__)
#define NP_LOADDS _loadds
#else
#define NP_LOADDS
#endif
#ifdef __cplusplus
extern "C" {
#endif
NPError NPP_Initialize(void);
void NPP_Shutdown(void);
NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream, NPError reason);
int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
int16 NPP_HandleEvent(NPP instance, void* event);
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor);
NPError NPN_GetURL(NPP instance, const char* url, const char* window);
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
NPError NPN_NewStream(NPP instance, NPMIMEType type, NPStream* stream);
int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason);
void NPN_Status(NPP instance, const char* message);
const char* NPN_UserAgent(NPP instance);
void* NPN_MemAlloc(uint32 size);
void NPN_MemFree(void* ptr);
uint32 NPN_MemFlush(uint32 size);
void NPN_ReloadPlugins(NPBool reloadPages);
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* _NPAPI_H_ */

277
utils/nplugin/src/npapp.cpp Normal file
View File

@@ -0,0 +1,277 @@
/*
* File: NPApp.cc
* Purpose: wxPluginApp implementation
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "NPApp.h"
#include "NPFrame.h"
#include <windows.h>
IMPLEMENT_ABSTRACT_CLASS(wxPluginApp, wxApp)
wxPluginApp *wxGetPluginApp(void)
{
if ( wxTheApp && wxTheApp->IsKindOf(CLASSINFO(wxPluginApp)))
return (wxPluginApp *)wxTheApp;
else
return NULL;
}
wxPluginApp::wxPluginApp(void)
{
m_data.m_argc = NULL;
m_data.m_argn = NULL;
m_data.m_argv = NULL;
m_data.m_type = 0;
m_data.m_instance = 0;
m_data.m_mode = 0;
m_data.m_window = 0;
}
wxPluginApp::~wxPluginApp(void)
{
if ( m_data.m_argn )
delete[] m_data.m_argn;
if ( m_data.m_argv )
delete[] m_data.m_argv;
}
// Add a frame
void wxPluginApp::AddFrame(wxPluginFrame *frame)
{
m_frames.Append(frame);
}
// Remove a frame
void wxPluginApp::RemoveFrame(wxPluginFrame *frame)
{
m_frames.DeleteObject(frame);
}
// Find a frame given a NP instance
wxPluginFrame *wxPluginApp::FindFrame(NPP instance)
{
wxNode *node = m_frames.First();
while ( node )
{
wxPluginFrame *frame = (wxPluginFrame *)node->Data();
if ( frame->GetInstance() == instance )
{
return frame;
}
node = node->Next();
}
return NULL;
}
void wxPluginApp::SetAttributeValues(const int n, char *argn[], char *argv[])
{
if ( m_data.m_argn )
delete[] m_data.m_argn;
if ( m_data.m_argv )
delete[] m_data.m_argv;
m_data.m_argc = n;
m_data.m_argn = new wxString[n];
m_data.m_argv = new wxString[n];
int i;
for ( i = 0; i < n ; i ++)
{
m_data.m_argn[i] = argn[i];
m_data.m_argv[i] = argv[i];
}
}
///////////////////////////////////////////////////////////////
// Netscape Plugin API calls routed via wxPluginApp
NPError wxPluginApp::NPP_Destroy(NPP instance, NPSavedData** save)
{
wxPluginFrame *frame = FindFrame(instance);
if ( frame )
{
frame->OnClose();
delete frame;
}
return NPERR_NO_ERROR;
}
NPError wxPluginApp::NPP_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
return NPERR_NO_ERROR;
}
/*
jref wxPluginApp::NPP_GetJavaClass(void)
{
return 0;
}
*/
NPError wxPluginApp::NPP_Initialize(void)
{
static int init = FALSE;
if ( init == TRUE )
MessageBox(NULL, "wxPluginApp::NPP_Initialize:\nabout to call wxEntry for 2nd time!!!", "wxPlugin", MB_OK);
wxEntry((WXHINSTANCE) GetModuleHandle(NULL));
init = TRUE;
// MessageBox(NULL, "wxPluginApp::NPP_Initialize: have called wxEntry", "wxPlugin", MB_OK);
return NPERR_NO_ERROR;
}
NPError wxPluginApp::NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
// MessageBox(NULL, "wxPluginApp::NPP_New", "wxPlugin", MB_OK);
// Save values so frame can be created in first NPP_SetWindow
if ( m_data.m_instance != 0 )
{
MessageBox(NULL, "wxPluginApp::NPP_New: whoops, 2 NPP_New calls in succession without NPP_SetWindow.\n Need to modify my code!", "wxPlugin", MB_OK);
return NPERR_NO_ERROR;
}
m_data.m_instance = instance;
m_data.m_type = pluginType;
m_data.m_mode = mode;
SetAttributeValues(argc, argn, argv);
// Unfortunately, we may get a stream event before we've got a valid window
// handle, so we just have to go ahead and create a new instance.
wxPluginFrame *frame = OnNewInstance(m_data);
m_data.m_instance = NULL;
m_data.m_window = NULL;
delete[] m_data.m_argv;
delete[] m_data.m_argn;
m_data.m_argv = NULL;
m_data.m_argn = NULL;
return NPERR_NO_ERROR;
}
NPError wxPluginApp::NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream,
NPBool seekable, uint16* stype)
{
// By default, we want to receive a file instead of a stream.
wxPluginFrame *frame = FindFrame(instance);
if ( frame )
{
return frame->OnNPNewStream(type, stream, seekable, stype);
}
return NPERR_NO_ERROR;
}
void wxPluginApp::NPP_Print(NPP instance, NPPrint* printInfo)
{
if (instance == NULL)
return;
wxPluginFrame *frame = FindFrame(instance);
if ( frame )
{
frame->OnNPPrint(printInfo);
}
}
NPError wxPluginApp::NPP_SetWindow(NPP instance, NPWindow* window)
{
// MessageBox(NULL, "wxPluginApp::NPP_SetWindow", "wxPlugin", MB_OK);
if ( window )
wxDebugMsg("%d\n", (int) window->window);
wxPluginFrame *frame = FindFrame(instance);
if ( frame )
{
frame->SetNPWindow(window);
}
else
{
#if 0
// No such frame: must make it.
if ( m_data.m_instance == NULL )
{
MessageBox(NULL, "wxPluginApp::NPP_SetWindow: whoops, no data to create window. SetWindow called in funny order?", "wxPlugin", MB_OK);
return NPERR_NO_ERROR;
}
if ( window->window == NULL )
{
// We're receiving a NULL window before we've even received
// a valid window. Ignore this silly thing.
return NPERR_NO_ERROR;
}
m_data.m_window = window;
m_data.m_instance = instance;
// wxPluginFrame *frame = OnNewInstance(m_data);
m_data.m_instance = NULL;
m_data.m_window = NULL;
delete[] m_data.m_argv;
delete[] m_data.m_argn;
m_data.m_argv = NULL;
m_data.m_argn = NULL;
#endif
}
return NPERR_NO_ERROR;
}
void wxPluginApp::NPP_Shutdown(void)
{
// Clean up wxWindows
CleanUp();
}
void wxPluginApp::NPP_StreamAsFile(NPP instance, NPStream* stream, const char *fname)
{
wxPluginFrame *frame = FindFrame(instance);
if ( frame )
{
wxString str(fname);
frame->OnNPNewFile(stream, str);
}
}
/*
void wxPluginApp::NPP_URLNotify(NPP instance, const char* url, NPReason reason,
void* notifyData)
{
}
*/
int32 wxPluginApp::NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
void* buf)
{
return len; // The number of bytes accepted
}
static int32 STREAMBUFSIZE = 0X0FFFFFFF; // If we are reading from a file in NPAsFile
// mode so we can take any size stream in our
// write call (since we ignore it)
int32 wxPluginApp::NPP_WriteReady(NPP instance, NPStream* stream)
{
return STREAMBUFSIZE; // Number of bytes ready to accept in NPP_Write()
}

91
utils/nplugin/src/npapp.h Normal file
View File

@@ -0,0 +1,91 @@
/*
* File: NPApp.h
* Purpose: wxPluginApp declaration
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
#ifndef __PLUGINAPP__
#define __PLUGINAPP__
#include "wx/wx.h"
#include "npapi.h"
class wxPluginFrame;
// Data passed to OnNewInstance
class wxPluginData
{
public:
NPP m_instance;
NPMIMEType m_type;
NPWindow* m_window;
int m_mode;
int m_argc;
wxString* m_argn;
wxString* m_argv;
};
class WXDLLEXPORT wxPluginApp: public wxApp
{
DECLARE_ABSTRACT_CLASS(wxPluginApp)
public:
wxPluginApp(void);
~wxPluginApp(void);
// Find a frame given a NP instance
wxPluginFrame *FindFrame(NPP instance);
// Add a frame
void AddFrame(wxPluginFrame *frame);
// Remove a frame
void RemoveFrame(wxPluginFrame *frame);
// Set attribute/values for the last instance
void SetAttributeValues(const int n, char *argn[], char *argv[]);
///////////////////////////////////////////////////////////////
// Higher-level API than NP API
virtual wxPluginFrame *OnNewInstance(const wxPluginData& data) = 0;
///////////////////////////////////////////////////////////////
// Netscape Plugin API calls routed via wxPluginApp
virtual NPError NPP_Destroy(NPP instance, NPSavedData** save);
virtual NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPError reason);
// virtual jref NPP_GetJavaClass(void);
virtual NPError NPP_Initialize(void);
virtual NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode,
int16 argc, char* argn[], char* argv[], NPSavedData* saved);
virtual NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream,
NPBool seekable, uint16* stype);
virtual void NPP_Print(NPP instance, NPPrint* platformPrint);
virtual NPError NPP_SetWindow(NPP instance, NPWindow* window);
virtual void NPP_Shutdown(void);
virtual void NPP_StreamAsFile(NPP instance, NPStream* stream, const char *fname);
/*
virtual void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
void* notifyData);
*/
virtual int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
void* buf);
virtual int32 NPP_WriteReady(NPP instance, NPStream* stream);
protected:
// List of plugin frames
wxList m_frames;
// Temporary NPP_New arguments so we can wait until NPP_SetWindow is called
// before creating a frame
wxPluginData m_data;
};
wxPluginApp *wxGetPluginApp(void);
#endif

View File

@@ -0,0 +1,293 @@
/*
* File: NPFrame.cc
* Purpose: wxPluginFrame implementation
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/frame.h"
#endif
#include "wx/dcprint.h"
#include "NPFrame.h"
#include "NPApp.h"
#include <windows.h>
extern wxList wxModelessWindows;
extern char wxFrameClassName[];
IMPLEMENT_DYNAMIC_CLASS(wxPluginFrame, wxFrame)
wxPluginFrame::wxPluginFrame(void)
{
m_npWindow = NULL;
m_npInstance = NULL;
m_nAttributes = 0;
m_names = NULL;
m_values = NULL;
}
bool wxPluginFrame::Create(const wxPluginData& data)
{
SetName("pluginFrame");
m_npWindow = NULL;
m_npInstance = NULL;
m_nAttributes = 0;
m_names = NULL;
m_values = NULL;
m_npWindow = data.m_window;
m_npInstance = data.m_instance;
SetAttributeValues(data.m_argc, data.m_argn, data.m_argv);
SetNPWindow(data.m_window);
wxModelessWindows.Append(this);
if (wxTheApp->IsKindOf(CLASSINFO(wxPluginApp)))
{
((wxPluginApp *)wxTheApp)->AddFrame(this);
}
return TRUE;
}
wxPluginFrame::~wxPluginFrame(void)
{
if (wxTheApp->IsKindOf(CLASSINFO(wxPluginApp)))
{
((wxPluginApp *)wxTheApp)->RemoveFrame(this);
}
if ( GetHWND() )
UnsubclassWin();
m_hWnd = 0;
if ( m_names )
delete[] m_names;
if ( m_values )
delete[] m_values;
}
// Get size *available for subwindows* i.e. excluding menu bar etc.
// For XView, this is the same as GetSize
void wxPluginFrame::GetClientSize(int *x, int *y) const
{
if ( !m_hWnd )
{
*x = 0; *y = 0;
return;
}
wxFrame::GetClientSize(x, y);
}
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxPluginFrame::SetClientSize(const int width, const int height)
{
if ( !m_hWnd )
return ;
wxFrame::SetClientSize(width, height);
}
void wxPluginFrame::GetSize(int *width, int *height) const
{
if ( !m_hWnd )
{
*width = 0; *height = 0;
return;
}
wxFrame::GetSize(width, height);
}
void wxPluginFrame::GetPosition(int *x, int *y) const
{
if ( !m_hWnd )
{
*x = 0; *y = 0;
return;
}
wxFrame::GetPosition(x, y);
}
void wxPluginFrame::SetAttributeValues(const int n, const char *argn[], const char *argv[])
{
if ( m_names )
delete[] m_names;
if ( m_values )
delete[] m_values;
m_nAttributes = n;
m_names = new wxString[n];
m_values = new wxString[n];
int i;
for ( i = 0; i < n ; i ++)
{
m_names[i] = argn[i];
m_values[i] = argv[i];
}
}
void wxPluginFrame::SetAttributeValues(const int n, const wxString* argn, const wxString* argv)
{
if ( m_names )
delete[] m_names;
if ( m_values )
delete[] m_values;
m_nAttributes = n;
m_names = new wxString[n];
m_values = new wxString[n];
int i;
for ( i = 0; i < n ; i ++)
{
m_names[i] = argn[i];
m_values[i] = argv[i];
}
}
void wxPluginFrame::SetSize(const int x, const int y, const int width, const int height, const int sizeFlags)
{
// Can't allow app to set the size.
return;
}
// Sets and subclasses the platform-specific window handle
bool wxPluginFrame::SetNPWindow(NPWindow *window)
{
if ( !window || !window->window)
{
if ( m_hWnd )
{
wxMessageBox("Unsubclassing window prematurely");
UnsubclassWin();
m_hWnd = 0;
}
m_npWindow = NULL;
}
else
{
if ( m_hWnd )
{
if ( m_hWnd == (WXHWND) window->window )
{
// Does this mean a resize?
return TRUE;
}
}
m_npWindow = window;
m_hWnd = (WXHWND) window->window;
SubclassWin(m_hWnd);
m_windowId = ::GetWindowLong((HWND) m_hWnd, GWL_ID);
}
return TRUE;
}
NPError wxPluginFrame::OnNPNewStream(NPMIMEType type, NPStream *stream, bool seekable, uint16* stype)
{
*stype = NP_ASFILE;
return NPERR_NO_ERROR;
}
void wxPluginFrame::OnNPNewFile(NPStream *stream, const wxString& fname)
{
}
void wxPluginFrame::OnNPPrint(NPPrint* printInfo)
{
if (printInfo->mode == NP_FULL)
{
//
// *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.
//
void* platformPrint = printInfo->print.fullPrint.platformPrint;
NPBool printOne = printInfo->print.fullPrint.printOne;
printInfo->print.fullPrint.pluginPrinted = FALSE; // Do the default
}
else // If not fullscreen, we must be embedded
{
//
// *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.
//
NPWindow* printWindow = &(printInfo->print.embedPrint.window);
void* platformPrint = printInfo->print.embedPrint.platformPrint;
HDC hDC = (HDC) platformPrint;
wxRectangle rect;
rect.x = printWindow->x;
rect.y = printWindow->y;
rect.width = printWindow->width;
rect.height = printWindow->height;
int saveIt = ::SaveDC(hDC);
wxPrinterDC *printerDC = new wxPrinterDC((WXHDC) hDC);
OnPrint(*printerDC, rect);
printerDC->SetHDC(0);
delete printerDC;
::RestoreDC(hDC, saveIt);
}
}
void wxPluginFrame::OnPrint(wxPrinterDC& dc, wxRectangle& rect)
{
// We must do some transformations here
RECT winRect;
/*
winRect.left = rect.x;
winRect.top = rect.y;
winRect.right = rect.x + rect.right;
winRect.bottom = rect.y + rect.height;
*/
POINT winPoint[2];
winPoint[0].x = rect.x;
winPoint[0].y = rect.y;
winPoint[1].x = rect.x + rect.width;
winPoint[1].y = rect.y + rect.height;
if (!LPtoDP((HDC) dc.GetHDC(), winPoint, 2))
wxMessageBox("LPtoDP failed.");
OnDraw(dc);
}
void wxPluginFrame::OnDraw(wxDC& dc)
{
}

View File

@@ -0,0 +1,81 @@
/*
* File: NPFrame.h
* Purpose: wxPluginFrame declaration
* Author: Julian Smart
* Created: 1997
* Updated:
* Copyright: (c) Julian Smart
*/
#ifndef __PLUGINFRAME__
#define __PLUGINFRAME__
#include "wx/frame.h"
#include "NPApp.h"
#include "npapi.h"
WXDLLEXPORT extern const char *wxFrameNameStr;
class wxPrinterDC;
class WXDLLEXPORT wxPluginFrame: public wxFrame
{
DECLARE_DYNAMIC_CLASS(wxPluginFrame)
public:
wxPluginFrame(void);
inline wxPluginFrame(const wxPluginData& data)
{
m_npWindow = NULL;
m_npInstance = NULL;
m_nAttributes = 0;
m_names = NULL;
m_values = NULL;
Create(data);
}
~wxPluginFrame(void);
bool Create(const wxPluginData& data);
// Sets and subclasses the platform-specific window handle
virtual bool SetNPWindow(NPWindow *window);
inline NPWindow *GetNPWindow(void) { return m_npWindow; }
void SetClientSize(const int width, const int height);
void GetClientSize(int *width, int *height) const;
void GetSize(int *width, int *height) const ;
void GetPosition(int *x, int *y) const ;
void SetSize(const int x, const int y, const int width, const int height, const int sizeFlags = wxSIZE_AUTO);
// Accessors
inline int GetAttributeCount(void) const { return m_nAttributes; }
inline wxString GetAttributeName(const int n) { return m_names[n]; }
inline wxString GetAttributeValue(const int n) { return m_values[n]; }
void SetAttributeValues(const int n, const char* argn[], const char *argv[]);
void SetAttributeValues(const int n, const wxString* argn, const wxString* argv);
inline void SetInstance(const NPP instance) { m_npInstance = instance; };
inline NPP GetInstance(void) { return m_npInstance; }
// Overridables: low-level
virtual NPError OnNPNewStream(NPMIMEType type, NPStream *stream, bool seekable, uint16* stype);
virtual void OnNPNewFile(NPStream *stream, const wxString& fname);
virtual void OnNPPrint(NPPrint* printInfo);
// Overridables: high-level
virtual void OnPrint(wxPrinterDC& dc, wxRectangle& rect);
virtual void OnDraw(wxDC& dc);
protected:
wxString* m_names;
wxString* m_values;
int m_nAttributes;
NPP m_npInstance;
NPWindow* m_npWindow;
};
#endif

View File

@@ -0,0 +1,278 @@
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// npshell.cpp
//
// 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).
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#ifndef _NPAPI_H_
#include "npapi.h"
#endif
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include "NPApp.h"
//
// Instance state information about the plugin.
//
// *Developers*: Use this struct to hold per-instance
// information that you'll need in the
// various functions in this file.
//
typedef struct _PluginInstance
{
NPWindow* fWindow;
uint16 fMode;
} PluginInstance;
//------------------------------------------------------------------------------------
// NPP_Initialize:
//------------------------------------------------------------------------------------
NPError NPP_Initialize(void)
{
// MessageBox(NULL, "NPP_Initialize", "NPTest", MB_OK);
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_Initialize();
else
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_Shutdown:
//------------------------------------------------------------------------------------
void NPP_Shutdown(void)
{
// MessageBox(NULL, "NPP_Shutdown", "wxPlugin", MB_OK);
wxPluginApp *app = wxGetPluginApp();
if ( app )
app->NPP_Shutdown();
}
//------------------------------------------------------------------------------------
// NPP_New:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_New(NPMIMEType pluginType,
NPP instance,
uint16 mode,
int16 argc,
char* argn[],
char* argv[],
NPSavedData* saved)
{
// MessageBox(NULL, "NPP_New", "NPTest", MB_OK);
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
else
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_Destroy:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_Destroy(NPP instance, NPSavedData** save)
{
// MessageBox(NULL, "NPP_Destroy", "NPTest", MB_OK);
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_Destroy(instance, save);
else
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_SetWindow:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_SetWindow(NPP instance, NPWindow* window)
{
// MessageBox(NULL, "NPP_SetWindow", "NPTest", MB_OK);
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_SetWindow(instance, window);
else
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_NewStream:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_NewStream(NPP instance,
NPMIMEType type,
NPStream *stream,
NPBool seekable,
uint16 *stype)
{
// MessageBox(NULL, "NPP_NewStream", "NPTest", MB_OK);
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_NewStream(instance, type, stream, seekable, stype);
else
return NPERR_NO_ERROR;
}
//
// *Developers*:
// These next 2 functions are directly relevant in a plug-in which handles the
// data in a streaming manner. If you want zero bytes because no buffer space
// is YET available, return 0. As long as the stream has not been written
// to the plugin, Navigator will continue trying to send bytes. If the plugin
// doesn't want them, just return some large number from NPP_WriteReady(), and
// ignore them in NPP_Write(). For a NP_ASFILE stream, they are still called
// but can safely be ignored using this strategy.
//
static int32 STREAMBUFSIZE = 0X0FFFFFFF; // If we are reading from a file in NPAsFile
// mode so we can take any size stream in our
// write call (since we ignore it)
//------------------------------------------------------------------------------------
// NPP_WriteReady:
//------------------------------------------------------------------------------------
int32 NP_LOADDS
NPP_WriteReady(NPP instance, NPStream *stream)
{
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_WriteReady(instance, stream);
else
return STREAMBUFSIZE;
return STREAMBUFSIZE; // Number of bytes ready to accept in NPP_Write()
}
//------------------------------------------------------------------------------------
// NPP_Write:
//------------------------------------------------------------------------------------
int32 NP_LOADDS
NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
{
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_Write(instance, stream, offset, len, buffer);
else
return len; // The number of bytes accepted
}
//------------------------------------------------------------------------------------
// NPP_DestroyStream:
//------------------------------------------------------------------------------------
NPError NP_LOADDS
NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason)
{
if (instance == NULL)
return NPERR_INVALID_INSTANCE_ERROR;
wxPluginApp *app = wxGetPluginApp();
if ( app )
return app->NPP_DestroyStream(instance, stream, reason);
else
return NPERR_NO_ERROR;
}
//------------------------------------------------------------------------------------
// NPP_StreamAsFile:
//------------------------------------------------------------------------------------
void NP_LOADDS
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
{
wxPluginApp *app = wxGetPluginApp();
if ( app )
app->NPP_StreamAsFile(instance, stream, fname);
}
//------------------------------------------------------------------------------------
// NPP_Print:
//------------------------------------------------------------------------------------
void NP_LOADDS
NPP_Print(NPP instance, NPPrint* printInfo)
{
if (printInfo == NULL) // trap invalid parm
return;
if ( instance == NULL )
return;
wxPluginApp *app = wxGetPluginApp();
if ( app )
app->NPP_Print(instance, printInfo);
}
//------------------------------------------------------------------------------------
// NPP_HandleEvent:
// Mac-only.
//------------------------------------------------------------------------------------
int16 NPP_HandleEvent(NPP instance, void* event)
{
NPBool eventHandled = FALSE;
if (instance == NULL)
return eventHandled;
PluginInstance* This = (PluginInstance*) instance->pdata;
//
// *Developers*: The "event" passed in is a Macintosh
// EventRecord*. The event.what field can be any of the
// normal Mac event types, or one of the following additional
// types defined in npapi.h: getFocusEvent, loseFocusEvent,
// adjustCursorEvent. The focus events inform your plugin
// that it will become, or is no longer, the recepient of
// key events. If your plugin doesn't want to receive key
// events, return false when passed at getFocusEvent. The
// adjustCursorEvent is passed repeatedly when the mouse is
// over your plugin; if your plugin doesn't want to set the
// cursor, return false. Handle the standard Mac events as
// normal. The return value for all standard events is currently
// ignored except for the key event: for key events, only return
// true if your plugin has handled that particular key event.
//
return eventHandled;
}

799
utils/nplugin/src/npupp.h Normal file
View File

@@ -0,0 +1,799 @@
/*
* npupp.h $Revision$
* function call mecahnics needed by platform specific glue code.
*/
#ifndef _NPUPP_H_
#define _NPUPP_H_
#ifndef GENERATINGCFM
#define GENERATINGCFM 0
#endif
#ifndef _NPAPI_H_
#include "npapi.h"
#endif
/******************************************************************************************
plug-in function table macros
for each function in and out of the plugin API we define
typedef NPP_FooUPP
#define NewNPP_FooProc
#define CallNPP_FooProc
for mac, define the UPP magic for PPC/68K calling
*******************************************************************************************/
/* NPP_Initialize */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_InitializeUPP;
enum {
uppNPP_InitializeProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(0))
| RESULT_SIZE(SIZE_CODE(0))
};
#define NewNPP_InitializeProc(FUNC) \
(NPP_InitializeUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_InitializeProcInfo, GetCurrentArchitecture())
#define CallNPP_InitializeProc(FUNC) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_InitializeProcInfo)
#else
typedef void (*NPP_InitializeUPP)(void);
#define NewNPP_InitializeProc(FUNC) \
((NPP_InitializeUPP) (FUNC))
#define CallNPP_InitializeProc(FUNC) \
(*(FUNC))()
#endif
/* NPP_Shutdown */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_ShutdownUPP;
enum {
uppNPP_ShutdownProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(0))
| RESULT_SIZE(SIZE_CODE(0))
};
#define NewNPP_ShutdownProc(FUNC) \
(NPP_ShutdownUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_ShutdownProcInfo, GetCurrentArchitecture())
#define CallNPP_ShutdownProc(FUNC) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_ShutdownProcInfo)
#else
typedef void (*NPP_ShutdownUPP)(void);
#define NewNPP_ShutdownProc(FUNC) \
((NPP_ShutdownUPP) (FUNC))
#define CallNPP_ShutdownProc(FUNC) \
(*(FUNC))()
#endif
/* NPP_New */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_NewUPP;
enum {
uppNPP_NewProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPMIMEType)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(uint16)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(int16)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(char **)))
| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(char **)))
| STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(NPSavedData *)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPP_NewProc(FUNC) \
(NPP_NewUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_NewProcInfo, GetCurrentArchitecture())
#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_NewProcInfo, \
(ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
#else
typedef NPError (*NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
#define NewNPP_NewProc(FUNC) \
((NPP_NewUPP) (FUNC))
#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
#endif
/* NPP_Destroy */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_DestroyUPP;
enum {
uppNPP_DestroyProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPSavedData **)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPP_DestroyProc(FUNC) \
(NPP_DestroyUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_DestroyProcInfo, GetCurrentArchitecture())
#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_DestroyProcInfo, (ARG1), (ARG2))
#else
typedef NPError (*NPP_DestroyUPP)(NPP instance, NPSavedData** save);
#define NewNPP_DestroyProc(FUNC) \
((NPP_DestroyUPP) (FUNC))
#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
#endif
/* NPP_SetWindow */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_SetWindowUPP;
enum {
uppNPP_SetWindowProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPWindow *)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPP_SetWindowProc(FUNC) \
(NPP_SetWindowUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_SetWindowProcInfo, GetCurrentArchitecture())
#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_SetWindowProcInfo, (ARG1), (ARG2))
#else
typedef NPError (*NPP_SetWindowUPP)(NPP instance, NPWindow* window);
#define NewNPP_SetWindowProc(FUNC) \
((NPP_SetWindowUPP) (FUNC))
#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
#endif
/* NPP_NewStream */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_NewStreamUPP;
enum {
uppNPP_NewStreamProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPMIMEType)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(NPBool)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(uint16 *)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPP_NewStreamProc(FUNC) \
(NPP_NewStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_NewStreamProcInfo, GetCurrentArchitecture())
#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_NewStreamProcInfo, (ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
#else
typedef NPError (*NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
#define NewNPP_NewStreamProc(FUNC) \
((NPP_NewStreamUPP) (FUNC))
#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
#endif
/* NPP_DestroyStream */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_DestroyStreamUPP;
enum {
uppNPP_DestroyStreamProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPError)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPP_DestroyStreamProc(FUNC) \
(NPP_DestroyStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_DestroyStreamProcInfo, GetCurrentArchitecture())
#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPErrorArg) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_DestroyStreamProcInfo, (NPParg), (NPStreamPtr), (NPErrorArg))
#else
typedef NPError (*NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPError reason);
#define NewNPP_DestroyStreamProc(FUNC) \
((NPP_DestroyStreamUPP) (FUNC))
#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPErrorArg) \
(*(FUNC))((NPParg), (NPStreamPtr), (NPErrorArg))
#endif
/* NPP_WriteReady */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_WriteReadyUPP;
enum {
uppNPP_WriteReadyProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
| RESULT_SIZE(SIZE_CODE(sizeof(int32)))
};
#define NewNPP_WriteReadyProc(FUNC) \
(NPP_WriteReadyUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_WriteReadyProcInfo, GetCurrentArchitecture())
#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
(int32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_WriteReadyProcInfo, (NPParg), (NPStreamPtr))
#else
typedef int32 (*NPP_WriteReadyUPP)(NPP instance, NPStream* stream);
#define NewNPP_WriteReadyProc(FUNC) \
((NPP_WriteReadyUPP) (FUNC))
#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
(*(FUNC))((NPParg), (NPStreamPtr))
#endif
/* NPP_Write */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_WriteUPP;
enum {
uppNPP_WriteProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(int32)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(int32)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(void*)))
| RESULT_SIZE(SIZE_CODE(sizeof(int32)))
};
#define NewNPP_WriteProc(FUNC) \
(NPP_WriteUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_WriteProcInfo, GetCurrentArchitecture())
#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
(int32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_WriteProcInfo, (NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
#else
typedef int32 (*NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
#define NewNPP_WriteProc(FUNC) \
((NPP_WriteUPP) (FUNC))
#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
(*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
#endif
/* NPP_StreamAsFile */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_StreamAsFileUPP;
enum {
uppNPP_StreamAsFileProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(const char *)))
| RESULT_SIZE(SIZE_CODE(0))
};
#define NewNPP_StreamAsFileProc(FUNC) \
(NPP_StreamAsFileUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_StreamAsFileProcInfo, GetCurrentArchitecture())
#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_StreamAsFileProcInfo, (ARG1), (ARG2), (ARG3))
#else
typedef void (*NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname);
#define NewNPP_StreamAsFileProc(FUNC) \
((NPP_StreamAsFileUPP) (FUNC))
#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
#endif
/* NPP_Print */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_PrintUPP;
enum {
uppNPP_PrintProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPPrint *)))
| RESULT_SIZE(SIZE_CODE(0))
};
#define NewNPP_PrintProc(FUNC) \
(NPP_PrintUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_PrintProcInfo, GetCurrentArchitecture())
#define CallNPP_PrintProc(FUNC, NPParg, voidPtr) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_PrintProcInfo, (NPParg), (voidPtr))
#else
typedef void (*NPP_PrintUPP)(NPP instance, NPPrint* platformPrint);
#define NewNPP_PrintProc(FUNC) \
((NPP_PrintUPP) (FUNC))
#define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \
(*(FUNC))((NPParg), (NPPrintArg))
#endif
/* NPP_HandleEvent */
#if GENERATINGCFM
typedef UniversalProcPtr NPP_HandleEventUPP;
enum {
uppNPP_HandleEventProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(void *)))
| RESULT_SIZE(SIZE_CODE(sizeof(int16)))
};
#define NewNPP_HandleEventProc(FUNC) \
(NPP_HandleEventUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_HandleEventProcInfo, GetCurrentArchitecture())
#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
(int16)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPP_HandleEventProcInfo, (NPParg), (voidPtr))
#else
typedef int16 (*NPP_HandleEventUPP)(NPP instance, void* event);
#define NewNPP_HandleEventProc(FUNC) \
((NPP_HandleEventUPP) (FUNC))
#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
(*(FUNC))((NPParg), (voidPtr))
#endif
/*
* Netscape entry points
*/
/* NPN_GetUrl */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_GetURLUPP;
enum {
uppNPN_GetURLProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(const char*)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(const char*)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPN_GetURLProc(FUNC) \
(NPN_GetURLUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_GetURLProcInfo, GetCurrentArchitecture())
#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_GetURLProcInfo, (ARG1), (ARG2), (ARG3))
#else
typedef NPError (*NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
#define NewNPN_GetURLProc(FUNC) \
((NPN_GetURLUPP) (FUNC))
#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
#endif
/* NPN_PostUrl */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_PostURLUPP;
enum {
uppNPN_PostURLProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(const char*)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(const char*)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(uint32)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(const char*)))
| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(NPBool)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPN_PostURLProc(FUNC) \
(NPN_PostURLUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_PostURLProcInfo, GetCurrentArchitecture())
#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_PostURLProcInfo, (ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
#else
typedef NPError (*NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
#define NewNPN_PostURLProc(FUNC) \
((NPN_PostURLUPP) (FUNC))
#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
#endif
/* NPN_RequestRead */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_RequestReadUPP;
enum {
uppNPN_RequestReadProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPByteRange *)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPN_RequestReadProc(FUNC) \
(NPN_RequestReadUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_RequestReadProcInfo, GetCurrentArchitecture())
#define CallNPN_RequestReadProc(FUNC, stream, range) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_RequestReadProcInfo, (stream), (range))
#else
typedef NPError (*NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
#define NewNPN_RequestReadProc(FUNC) \
((NPN_RequestReadUPP) (FUNC))
#define CallNPN_RequestReadProc(FUNC, stream, range) \
(*(FUNC))((stream), (range))
#endif
/* NPN_NewStream */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_NewStreamUPP;
enum {
uppNPN_NewStreamProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP )))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPMIMEType)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(NPBool)))
| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(uint16*)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPN_NewStreamProc(FUNC) \
(NPN_NewStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_NewStreamProcInfo, GetCurrentArchitecture())
#define CallNPN_NewStreamProc(FUNC, npp, type, stream) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_NewStreamProcInfo, (npp), (type), (stream))
#else
typedef NPError (*NPN_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream);
#define NewNPN_NewStreamProc(FUNC) \
((NPN_NewStreamUPP) (FUNC))
#define CallNPN_NewStreamProc(FUNC, npp, type, stream) \
(*(FUNC))((npp), (type), (stream))
#endif
/* NPN_Write */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_WriteUPP;
enum {
uppNPN_WriteProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP )))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(int32)))
| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(void*)))
| RESULT_SIZE(SIZE_CODE(sizeof(int32)))
};
#define NewNPN_WriteProc(FUNC) \
(NPN_WriteUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_WriteProcInfo, GetCurrentArchitecture())
#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
(int32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_WriteProcInfo, (npp), (stream), (len), (buffer))
#else
typedef int32 (*NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer);
#define NewNPN_WriteProc(FUNC) \
((NPN_WriteUPP) (FUNC))
#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
(*(FUNC))((npp), (stream), (len), (buffer))
#endif
/* NPN_DestroyStream */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_DestroyStreamUPP;
enum {
uppNPN_DestroyStreamProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP )))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPStream *)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPError)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPN_DestroyStreamProc(FUNC) \
(NPN_DestroyStreamUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_DestroyStreamProcInfo, GetCurrentArchitecture())
#define CallNPN_DestroyStreamProc(FUNC, npp, stream, err) \
(NPError)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_DestroyStreamProcInfo, (npp), (stream), (err))
#else
typedef NPError (*NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPError reason);
#define NewNPN_DestroyStreamProc(FUNC) \
((NPN_DestroyStreamUPP) (FUNC))
#define CallNPN_DestroyStreamProc(FUNC, npp, stream, err) \
(*(FUNC))((npp), (stream), (err))
#endif
/* NPN_Status */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_StatusUPP;
enum {
uppNPN_StatusProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(char *)))
};
#define NewNPN_StatusProc(FUNC) \
(NPN_StatusUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_StatusProcInfo, GetCurrentArchitecture())
#define CallNPN_StatusProc(FUNC, npp, msg) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_StatusProcInfo, (npp), (msg))
#else
typedef void (*NPN_StatusUPP)(NPP instance, const char* message);
#define NewNPN_StatusProc(FUNC) \
((NPN_StatusUPP) (FUNC))
#define CallNPN_StatusProc(FUNC, npp, msg) \
(*(FUNC))((npp), (msg))
#endif
/* NPN_UserAgent */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_UserAgentUPP;
enum {
uppNPN_UserAgentProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPP)))
| RESULT_SIZE(SIZE_CODE(sizeof(const char *)))
};
#define NewNPN_UserAgentProc(FUNC) \
(NPN_UserAgentUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_UserAgentProcInfo, GetCurrentArchitecture())
#define CallNPN_UserAgentProc(FUNC, ARG1) \
(const char*)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_UserAgentProcInfo, (ARG1))
#else
typedef const char* (*NPN_UserAgentUPP)(NPP instance);
#define NewNPN_UserAgentProc(FUNC) \
((NPN_UserAgentUPP) (FUNC))
#define CallNPN_UserAgentProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
#endif
/* NPN_MemAlloc */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_MemAllocUPP;
enum {
uppNPN_MemAllocProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(uint32)))
| RESULT_SIZE(SIZE_CODE(sizeof(void *)))
};
#define NewNPN_MemAllocProc(FUNC) \
(NPN_MemAllocUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_MemAllocProcInfo, GetCurrentArchitecture())
#define CallNPN_MemAllocProc(FUNC, ARG1) \
(void*)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_MemAllocProcInfo, (ARG1))
#else
typedef void* (*NPN_MemAllocUPP)(uint32 size);
#define NewNPN_MemAllocProc(FUNC) \
((NPN_MemAllocUPP) (FUNC))
#define CallNPN_MemAllocProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
#endif
/* NPN__MemFree */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_MemFreeUPP;
enum {
uppNPN_MemFreeProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(void *)))
};
#define NewNPN_MemFreeProc(FUNC) \
(NPN_MemFreeUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_MemFreeProcInfo, GetCurrentArchitecture())
#define CallNPN_MemFreeProc(FUNC, ARG1) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_MemFreeProcInfo, (ARG1))
#else
typedef void (*NPN_MemFreeUPP)(void* ptr);
#define NewNPN_MemFreeProc(FUNC) \
((NPN_MemFreeUPP) (FUNC))
#define CallNPN_MemFreeProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
#endif
/* NPN_MemFlush */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_MemFlushUPP;
enum {
uppNPN_MemFlushProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(uint32)))
| RESULT_SIZE(SIZE_CODE(sizeof(uint32)))
};
#define NewNPN_MemFlushProc(FUNC) \
(NPN_MemFlushUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_MemFlushProcInfo, GetCurrentArchitecture())
#define CallNPN_MemFlushProc(FUNC, ARG1) \
(uint32)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_MemFlushProcInfo, (ARG1))
#else
typedef uint32 (*NPN_MemFlushUPP)(uint32 size);
#define NewNPN_MemFlushProc(FUNC) \
((NPN_MemFlushUPP) (FUNC))
#define CallNPN_MemFlushProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
#endif
/* NPN_ReloadPlugins */
#if GENERATINGCFM
typedef UniversalProcPtr NPN_ReloadPluginsUPP;
enum {
uppNPN_ReloadPluginsProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPBool)))
| RESULT_SIZE(SIZE_CODE(0))
};
#define NewNPN_ReloadPluginsProc(FUNC) \
(NPN_ReloadPluginsUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPN_ReloadPluginsProcInfo, GetCurrentArchitecture())
#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
(void)CallUniversalProc((UniversalProcPtr)(FUNC), uppNPN_ReloadPluginsProcInfo, (ARG1))
#else
typedef void (*NPN_ReloadPluginsUPP)(NPBool reloadPages);
#define NewNPN_ReloadPluginsProc(FUNC) \
((NPN_ReloadPluginsUPP) (FUNC))
#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
#endif
/******************************************************************************************
* The actual plugin function table definitions
*******************************************************************************************/
typedef struct _NPPluginFuncs {
uint16 size;
uint16 version;
NPP_NewUPP newp;
NPP_DestroyUPP destroy;
NPP_SetWindowUPP setwindow;
NPP_NewStreamUPP newstream;
NPP_DestroyStreamUPP destroystream;
NPP_StreamAsFileUPP asfile;
NPP_WriteReadyUPP writeready;
NPP_WriteUPP write;
NPP_PrintUPP print;
NPP_HandleEventUPP event;
} NPPluginFuncs;
typedef struct _NPNetscapeFuncs {
uint16 size;
uint16 version;
NPN_GetURLUPP geturl;
NPN_PostURLUPP posturl;
NPN_RequestReadUPP requestread;
NPN_NewStreamUPP newstream;
NPN_WriteUPP write;
NPN_DestroyStreamUPP destroystream;
NPN_StatusUPP status;
NPN_UserAgentUPP uagent;
NPN_MemAllocUPP memalloc;
NPN_MemFreeUPP memfree;
NPN_MemFlushUPP memflush;
NPN_ReloadPluginsUPP reloadplugins;
} NPNetscapeFuncs;
#ifdef XP_MAC
/******************************************************************************************
* Mac platform-specific plugin glue stuff
*******************************************************************************************/
/*
* Main entry point of the plugin.
* This routine will be called when the plugin is loaded. The function
* tables are passed in and the plugin fills in the NPPluginFuncs table
* and NPPShutdownUPP for Netscape's use.
*/
#if GENERATINGCFM
typedef UniversalProcPtr NPP_MainEntryUPP;
enum {
uppNPP_MainEntryProcInfo = kThinkCStackBased
| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(NPNetscapeFuncs*)))
| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(NPPluginFuncs*)))
| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(NPP_ShutdownUPP*)))
| RESULT_SIZE(SIZE_CODE(sizeof(NPError)))
};
#define NewNPP_MainEntryProc(FUNC) \
(NPP_MainEntryUPP) NewRoutineDescriptor((ProcPtr)(FUNC), uppNPP_MainEntryProcInfo, GetCurrentArchitecture())
#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
CallUniversalProc((UniversalProcPtr)(FUNC), (ProcInfoType)uppNPP_MainEntryProcInfo, (netscapeFunc), (pluginFunc), (shutdownUPP))
#else
typedef NPError (*NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*);
#define NewNPP_MainEntryProc(FUNC) \
((NPP_MainEntryUPP) (FUNC))
#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
(*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
#endif
#endif /* MAC */
#ifdef _WINDOWS
#ifdef __cplusplus
extern "C" {
#endif
/* plugin meta member functions */
NPError WINAPI NP_GetEntryPoints(NPPluginFuncs* pFuncs);
NPError WINAPI NP_Initialize(NPNetscapeFuncs* pFuncs);
NPError WINAPI NP_Shutdown();
#ifdef __cplusplus
}
#endif
#endif /* _WINDOWS */
#endif /* _NPUPP_H_ */

186
utils/nplugin/src/npwin.cpp Normal file
View File

@@ -0,0 +1,186 @@
/* npwin.cpp */
#include "windows.h"
#include "npapi.h"
#include "npupp.h"
#ifdef __WIN32__
#define NP_EXPORT
#else
#define NP_EXPORT _export
#endif
static NPNetscapeFuncs* g_pNavigatorFuncs = NULL;
/* PLUGIN DLL entry points */
/* These are the Windows specific DLL entry points, not the "normal" plugin
entry points. The "normal" ones are in NPSHELL.CPP
*/
/* 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 */
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 = NULL; /* reserved */
return NPERR_NO_ERROR;
}
/* 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;
/* if the Navigator's function table is smaller than the plugin expects,
then they are incompatible, and should return an error */
if(pFuncs->size < sizeof NPNetscapeFuncs)
return NPERR_INVALID_FUNCTABLE_ERROR;
return NPP_Initialize();
}
/* called immediately before the plugin DLL is unloaded
*/
NPError WINAPI NP_EXPORT NP_Shutdown()
{
NPP_Shutdown();
g_pNavigatorFuncs = NULL;
return NPERR_NO_ERROR;
}
/* 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);
}
/* causes the specified URL to be fetched and streamed in
*/
NPError NPN_GetURL(NPP instance, const char *url, const char *window)
{
return g_pNavigatorFuncs->geturl(instance, url, window);
}
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, NPStream *stream)
{
return g_pNavigatorFuncs->newstream(instance, type, stream);
}
/* Provides len bytes of data.
*/
int32 NPN_Write(NPP instance, NPStream *stream,
int32 len, void *buffer)
{
return g_pNavigatorFuncs->write(instance, stream, len, buffer);
}
/* Closes a stream object.
reason indicates why the stream was closed.
*/
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
return g_pNavigatorFuncs->destroystream(instance, stream, reason);
}
/* 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);
}
/* private function to Netscape. do not use!
*/
void NPN_ReloadPlugins(NPBool reloadPages)
{
g_pNavigatorFuncs->reloadplugins(reloadPages);
}