]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/nplugin/src/npwin.cpp
added test for HitTest(m_dragPoint) bug to the sample
[wxWidgets.git] / utils / nplugin / src / npwin.cpp
... / ...
CommitLineData
1/* npwin.cpp */
2#include "windows.h"
3
4#include "npapi.h"
5#include "npupp.h"
6
7#ifdef __WIN32__
8 #define NP_EXPORT
9#else
10 #define NP_EXPORT _export
11#endif
12
13static NPNetscapeFuncs* g_pNavigatorFuncs = NULL;
14
15
16/* PLUGIN DLL entry points */
17/* These are the Windows specific DLL entry points, not the "normal" plugin
18 entry points. The "normal" ones are in NPSHELL.CPP
19*/
20
21/* fills in the func table used by Navigator to call entry points in
22 plugin DLL. Note that these entry points ensure that DS is loaded
23 by using the NP_LOADDS macro, when compiling for Win16
24*/
25NPError WINAPI NP_EXPORT NP_GetEntryPoints(NPPluginFuncs* pFuncs)
26{
27 /* trap a NULL ptr */
28 if(pFuncs == NULL)
29 return NPERR_INVALID_FUNCTABLE_ERROR;
30
31 /* if the plugin's function table is smaller than the plugin expects,
32 then they are incompatible, and should return an error */
33 if(pFuncs->size < sizeof NPPluginFuncs)
34 return NPERR_INVALID_FUNCTABLE_ERROR;
35
36 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
37 pFuncs->newp = NPP_New;
38 pFuncs->destroy = NPP_Destroy;
39 pFuncs->setwindow = NPP_SetWindow;
40 pFuncs->newstream = NPP_NewStream;
41 pFuncs->destroystream = NPP_DestroyStream;
42 pFuncs->asfile = NPP_StreamAsFile;
43 pFuncs->writeready = NPP_WriteReady;
44 pFuncs->write = NPP_Write;
45 pFuncs->print = NPP_Print;
46 pFuncs->event = NULL; /* reserved */
47
48 return NPERR_NO_ERROR;
49}
50
51/* called immediately after the plugin DLL is loaded
52*/
53NPError WINAPI NP_EXPORT NP_Initialize(NPNetscapeFuncs* pFuncs)
54{
55 /* trap a NULL ptr */
56 if(pFuncs == NULL)
57 return NPERR_INVALID_FUNCTABLE_ERROR;
58
59 g_pNavigatorFuncs = pFuncs; /* save it for future reference */
60
61 /* if the plugin's major ver level is lower than the Navigator's,
62 then they are incompatible, and should return an error */
63 if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
64 return NPERR_INCOMPATIBLE_VERSION_ERROR;
65
66 /* if the Navigator's function table is smaller than the plugin expects,
67 then they are incompatible, and should return an error */
68 if(pFuncs->size < sizeof NPNetscapeFuncs)
69 return NPERR_INVALID_FUNCTABLE_ERROR;
70
71 return NPP_Initialize();
72}
73
74/* called immediately before the plugin DLL is unloaded
75*/
76NPError WINAPI NP_EXPORT NP_Shutdown()
77{
78 NPP_Shutdown();
79
80 g_pNavigatorFuncs = NULL;
81
82 return NPERR_NO_ERROR;
83}
84
85
86/* NAVIGATOR Entry points */
87
88/* These entry points expect to be called from within the plugin. The
89 noteworthy assumption is that DS has already been set to point to the
90 plugin's DLL data segment. Don't call these functions from outside
91 the plugin without ensuring DS is set to the DLLs data segment first,
92 typically using the NP_LOADDS macro
93*/
94
95/* returns the major/minor version numbers of the Plugin API for the plugin
96 and the Navigator
97*/
98void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
99{
100 *plugin_major = NP_VERSION_MAJOR;
101 *plugin_minor = NP_VERSION_MINOR;
102 *netscape_major = HIBYTE(g_pNavigatorFuncs->version);
103 *netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
104}
105
106/* causes the specified URL to be fetched and streamed in
107*/
108NPError NPN_GetURL(NPP instance, const char *url, const char *window)
109{
110 return g_pNavigatorFuncs->geturl(instance, url, window);
111}
112
113NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
114{
115 return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
116}
117
118/* Requests that a number of bytes be provided on a stream. Typically
119 this would be used if a stream was in "pull" mode. An optional
120 position can be provided for streams which are seekable.
121*/
122NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
123{
124 return g_pNavigatorFuncs->requestread(stream, rangeList);
125}
126
127/* Creates a new stream of data from the plug-in to be interpreted
128 by Netscape in the current window.
129*/
130NPError NPN_NewStream(NPP instance, NPMIMEType type, NPStream *stream)
131{
132 return g_pNavigatorFuncs->newstream(instance, type, stream);
133}
134
135/* Provides len bytes of data.
136*/
137int32 NPN_Write(NPP instance, NPStream *stream,
138 int32 len, void *buffer)
139{
140 return g_pNavigatorFuncs->write(instance, stream, len, buffer);
141}
142
143/* Closes a stream object.
144reason indicates why the stream was closed.
145*/
146NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
147{
148 return g_pNavigatorFuncs->destroystream(instance, stream, reason);
149}
150
151/* Provides a text status message in the Netscape client user interface
152*/
153void NPN_Status(NPP instance, const char *message)
154{
155 g_pNavigatorFuncs->status(instance, message);
156}
157
158/* returns the user agent string of Navigator, which contains version info
159*/
160const char* NPN_UserAgent(NPP instance)
161{
162 return g_pNavigatorFuncs->uagent(instance);
163}
164
165/* allocates memory from the Navigator's memory space. Necessary so that
166 saved instance data may be freed by Navigator when exiting.
167*/
168void* NPN_MemAlloc(uint32 size)
169{
170 return g_pNavigatorFuncs->memalloc(size);
171}
172
173/* reciprocal of MemAlloc() above
174*/
175void NPN_MemFree(void* ptr)
176{
177 g_pNavigatorFuncs->memfree(ptr);
178}
179
180/* private function to Netscape. do not use!
181*/
182void NPN_ReloadPlugins(NPBool reloadPages)
183{
184 g_pNavigatorFuncs->reloadplugins(reloadPages);
185}
186