1 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
5 // This file defines a "shell" plugin that plugin developers can use
6 // as the basis for a real plugin. This shell just provides empty
7 // implementations of all functions that the plugin can implement
8 // that will be called by Netscape (the NPP_xxx methods defined in
11 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
24 // Instance state information about the plugin.
26 // *Developers*: Use this struct to hold per-instance
27 // information that you'll need in the
28 // various functions in this file.
30 typedef struct _PluginInstance
39 //------------------------------------------------------------------------------------
41 //------------------------------------------------------------------------------------
42 NPError
NPP_Initialize(void)
44 // MessageBox(NULL, "NPP_Initialize", "NPTest", MB_OK);
46 wxPluginApp *app = wxGetPluginApp();
48 return app->NPP_Initialize();
50 return NPERR_NO_ERROR;
52 wxEntry((WXHINSTANCE
) GetModuleHandle(NULL
));
54 return NPERR_NO_ERROR
;
58 //------------------------------------------------------------------------------------
60 //------------------------------------------------------------------------------------
61 void NPP_Shutdown(void)
63 // MessageBox(NULL, "NPP_Shutdown", "wxPlugin", MB_OK);
65 wxPluginApp
*app
= wxGetPluginApp();
71 //------------------------------------------------------------------------------------
73 //------------------------------------------------------------------------------------
75 NPP_New(NPMIMEType pluginType
,
83 // MessageBox(NULL, "NPP_New", "NPTest", MB_OK);
86 return NPERR_INVALID_INSTANCE_ERROR
;
88 wxPluginApp
*app
= wxGetPluginApp();
90 return app
->NPP_New(pluginType
, instance
, mode
, argc
, argn
, argv
, saved
);
92 return NPERR_NO_ERROR
;
95 //------------------------------------------------------------------------------------
97 //------------------------------------------------------------------------------------
99 NPP_Destroy(NPP instance
, NPSavedData
** save
)
101 // MessageBox(NULL, "NPP_Destroy", "NPTest", MB_OK);
103 if (instance
== NULL
)
104 return NPERR_INVALID_INSTANCE_ERROR
;
106 wxPluginApp
*app
= wxGetPluginApp();
108 return app
->NPP_Destroy(instance
, save
);
110 return NPERR_NO_ERROR
;
114 //------------------------------------------------------------------------------------
116 //------------------------------------------------------------------------------------
118 NPP_SetWindow(NPP instance
, NPWindow
* window
)
120 // MessageBox(NULL, "NPP_SetWindow", "NPTest", MB_OK);
122 if (instance
== NULL
)
123 return NPERR_INVALID_INSTANCE_ERROR
;
125 wxPluginApp
*app
= wxGetPluginApp();
127 return app
->NPP_SetWindow(instance
, window
);
129 return NPERR_NO_ERROR
;
133 //------------------------------------------------------------------------------------
135 //------------------------------------------------------------------------------------
137 NPP_NewStream(NPP instance
,
143 // MessageBox(NULL, "NPP_NewStream", "NPTest", MB_OK);
145 if (instance
== NULL
)
146 return NPERR_INVALID_INSTANCE_ERROR
;
148 wxPluginApp
*app
= wxGetPluginApp();
150 return app
->NPP_NewStream(instance
, type
, stream
, seekable
, stype
);
152 return NPERR_NO_ERROR
;
159 // These next 2 functions are directly relevant in a plug-in which handles the
160 // data in a streaming manner. If you want zero bytes because no buffer space
161 // is YET available, return 0. As long as the stream has not been written
162 // to the plugin, Navigator will continue trying to send bytes. If the plugin
163 // doesn't want them, just return some large number from NPP_WriteReady(), and
164 // ignore them in NPP_Write(). For a NP_ASFILE stream, they are still called
165 // but can safely be ignored using this strategy.
168 static int32 STREAMBUFSIZE
= 0X0FFFFFFF; // If we are reading from a file in NPAsFile
169 // mode so we can take any size stream in our
170 // write call (since we ignore it)
172 //------------------------------------------------------------------------------------
174 //------------------------------------------------------------------------------------
176 NPP_WriteReady(NPP instance
, NPStream
*stream
)
178 wxPluginApp
*app
= wxGetPluginApp();
180 return app
->NPP_WriteReady(instance
, stream
);
182 return STREAMBUFSIZE
;
184 return STREAMBUFSIZE
; // Number of bytes ready to accept in NPP_Write()
189 //------------------------------------------------------------------------------------
191 //------------------------------------------------------------------------------------
193 NPP_Write(NPP instance
, NPStream
*stream
, int32 offset
, int32 len
, void *buffer
)
195 wxPluginApp
*app
= wxGetPluginApp();
197 return app
->NPP_Write(instance
, stream
, offset
, len
, buffer
);
199 return len
; // The number of bytes accepted
204 //------------------------------------------------------------------------------------
205 // NPP_DestroyStream:
206 //------------------------------------------------------------------------------------
208 NPP_DestroyStream(NPP instance
, NPStream
*stream
, NPError reason
)
210 if (instance
== NULL
)
211 return NPERR_INVALID_INSTANCE_ERROR
;
213 wxPluginApp
*app
= wxGetPluginApp();
215 return app
->NPP_DestroyStream(instance
, stream
, reason
);
217 return NPERR_NO_ERROR
;
221 //------------------------------------------------------------------------------------
223 //------------------------------------------------------------------------------------
225 NPP_StreamAsFile(NPP instance
, NPStream
*stream
, const char* fname
)
227 wxPluginApp
*app
= wxGetPluginApp();
229 app
->NPP_StreamAsFile(instance
, stream
, fname
);
234 //------------------------------------------------------------------------------------
236 //------------------------------------------------------------------------------------
238 NPP_Print(NPP instance
, NPPrint
* printInfo
)
240 if (printInfo
== NULL
) // trap invalid parm
242 if ( instance
== NULL
)
245 wxPluginApp
*app
= wxGetPluginApp();
247 app
->NPP_Print(instance
, printInfo
);
251 //------------------------------------------------------------------------------------
254 //------------------------------------------------------------------------------------
255 int16
NPP_HandleEvent(NPP instance
, void* event
)
257 NPBool eventHandled
= FALSE
;
258 if (instance
== NULL
)
261 PluginInstance
* This
= (PluginInstance
*) instance
->pdata
;
264 // *Developers*: The "event" passed in is a Macintosh
265 // EventRecord*. The event.what field can be any of the
266 // normal Mac event types, or one of the following additional
267 // types defined in npapi.h: getFocusEvent, loseFocusEvent,
268 // adjustCursorEvent. The focus events inform your plugin
269 // that it will become, or is no longer, the recepient of
270 // key events. If your plugin doesn't want to receive key
271 // events, return false when passed at getFocusEvent. The
272 // adjustCursorEvent is passed repeatedly when the mouse is
273 // over your plugin; if your plugin doesn't want to set the
274 // cursor, return false. Handle the standard Mac events as
275 // normal. The return value for all standard events is currently
276 // ignored except for the key event: for key events, only return
277 // true if your plugin has handled that particular key event.