blob: 5bbb648c3383c906889de3518f1bb929384c0c5e [file] [log] [blame]
Grace Klobafbe47c02009-05-14 17:31:45 -07001/*
2 * Copyright 2008, The Android Open Source Project
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <stdlib.h>
27#include <string.h>
28#include <stdio.h>
29#include "main.h"
30#include "PluginObject.h"
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040031#include "AnimationPlugin.h"
Derek Sollenbergerf42e2f42009-06-26 11:42:46 -040032#include "AudioPlugin.h"
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -040033#include "BackgroundPlugin.h"
Derek Sollenbergerdb398a72009-06-29 13:53:04 -040034#include "FormPlugin.h"
Derek Sollenberger4fb83e62009-07-27 16:40:13 -040035#include "PaintPlugin.h"
Derek Sollenbergerb8947ee2009-10-05 14:40:18 -040036#include "VideoPlugin.h"
Grace Klobafbe47c02009-05-14 17:31:45 -070037
38NPNetscapeFuncs* browser;
Derek Sollenbergerb8947ee2009-10-05 14:40:18 -040039JavaVM* gVM;
40
Grace Klobafbe47c02009-05-14 17:31:45 -070041#define EXPORT __attribute__((visibility("default")))
42
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040043NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
Grace Klobafbe47c02009-05-14 17:31:45 -070044 char* argn[], char* argv[], NPSavedData* saved);
45NPError NPP_Destroy(NPP instance, NPSavedData** save);
46NPError NPP_SetWindow(NPP instance, NPWindow* window);
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040047NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
Grace Klobafbe47c02009-05-14 17:31:45 -070048 NPBool seekable, uint16* stype);
49NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
50int32 NPP_WriteReady(NPP instance, NPStream* stream);
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040051int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
Grace Klobafbe47c02009-05-14 17:31:45 -070052 void* buffer);
53void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
54void NPP_Print(NPP instance, NPPrint* platformPrint);
55int16 NPP_HandleEvent(NPP instance, void* event);
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040056void NPP_URLNotify(NPP instance, const char* URL, NPReason reason,
Grace Klobafbe47c02009-05-14 17:31:45 -070057 void* notifyData);
58NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value);
59NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value);
60
61extern "C" {
62EXPORT NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env, void *application_context);
63EXPORT NPError NP_GetValue(NPP instance, NPPVariable variable, void *value);
64EXPORT const char* NP_GetMIMEDescription(void);
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040065EXPORT void NP_Shutdown(void);
Grace Klobafbe47c02009-05-14 17:31:45 -070066};
67
68ANPAudioTrackInterfaceV0 gSoundI;
Mike Reed224adad2009-06-10 10:24:01 -040069ANPBitmapInterfaceV0 gBitmapI;
Grace Klobafbe47c02009-05-14 17:31:45 -070070ANPCanvasInterfaceV0 gCanvasI;
71ANPLogInterfaceV0 gLogI;
72ANPPaintInterfaceV0 gPaintI;
73ANPPathInterfaceV0 gPathI;
Derek Sollenbergerc0f26572009-07-16 11:38:02 -040074ANPSurfaceInterfaceV0 gSurfaceI;
Grace Kloba9ffe5ac2009-08-04 17:51:06 -070075ANPSystemInterfaceV0 gSystemI;
Grace Klobafbe47c02009-05-14 17:31:45 -070076ANPTypefaceInterfaceV0 gTypefaceI;
Derek Sollenberger5b011e32009-06-22 11:39:40 -040077ANPWindowInterfaceV0 gWindowI;
Grace Klobafbe47c02009-05-14 17:31:45 -070078
79#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
Derek Sollenberger5b011e32009-06-22 11:39:40 -040080#define DEBUG_PLUGIN_EVENTS 0
Grace Klobafbe47c02009-05-14 17:31:45 -070081
82NPError NP_Initialize(NPNetscapeFuncs* browserFuncs, NPPluginFuncs* pluginFuncs, void *java_env, void *application_context)
83{
84 // Make sure we have a function table equal or larger than we are built against.
85 if (browserFuncs->size < sizeof(NPNetscapeFuncs)) {
86 return NPERR_GENERIC_ERROR;
87 }
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040088
Grace Klobafbe47c02009-05-14 17:31:45 -070089 // Copy the function table (structure)
90 browser = (NPNetscapeFuncs*) malloc(sizeof(NPNetscapeFuncs));
91 memcpy(browser, browserFuncs, sizeof(NPNetscapeFuncs));
Derek Sollenberger9119e7d2009-06-08 10:53:09 -040092
Grace Klobafbe47c02009-05-14 17:31:45 -070093 // Build the plugin function table
94 pluginFuncs->version = 11;
95 pluginFuncs->size = sizeof(pluginFuncs);
96 pluginFuncs->newp = NPP_New;
97 pluginFuncs->destroy = NPP_Destroy;
98 pluginFuncs->setwindow = NPP_SetWindow;
99 pluginFuncs->newstream = NPP_NewStream;
100 pluginFuncs->destroystream = NPP_DestroyStream;
101 pluginFuncs->asfile = NPP_StreamAsFile;
102 pluginFuncs->writeready = NPP_WriteReady;
103 pluginFuncs->write = (NPP_WriteProcPtr)NPP_Write;
104 pluginFuncs->print = NPP_Print;
105 pluginFuncs->event = NPP_HandleEvent;
106 pluginFuncs->urlnotify = NPP_URLNotify;
107 pluginFuncs->getvalue = NPP_GetValue;
108 pluginFuncs->setvalue = NPP_SetValue;
109
110 static const struct {
111 NPNVariable v;
112 uint32_t size;
113 ANPInterface* i;
114 } gPairs[] = {
Derek Sollenbergerc0f26572009-07-16 11:38:02 -0400115 { kAudioTrackInterfaceV0_ANPGetValue, sizeof(gSoundI), &gSoundI },
Mike Reed224adad2009-06-10 10:24:01 -0400116 { kBitmapInterfaceV0_ANPGetValue, sizeof(gBitmapI), &gBitmapI },
Grace Klobafbe47c02009-05-14 17:31:45 -0700117 { kCanvasInterfaceV0_ANPGetValue, sizeof(gCanvasI), &gCanvasI },
Mike Reed224adad2009-06-10 10:24:01 -0400118 { kLogInterfaceV0_ANPGetValue, sizeof(gLogI), &gLogI },
Grace Klobafbe47c02009-05-14 17:31:45 -0700119 { kPaintInterfaceV0_ANPGetValue, sizeof(gPaintI), &gPaintI },
120 { kPathInterfaceV0_ANPGetValue, sizeof(gPathI), &gPathI },
Derek Sollenbergerc0f26572009-07-16 11:38:02 -0400121 { kSurfaceInterfaceV0_ANPGetValue, sizeof(gSurfaceI), &gSurfaceI },
Grace Kloba9ffe5ac2009-08-04 17:51:06 -0700122 { kSystemInterfaceV0_ANPGetValue, sizeof(gSystemI), &gSystemI },
123 { kTypefaceInterfaceV0_ANPGetValue, sizeof(gTypefaceI), &gTypefaceI },
Derek Sollenbergerc0f26572009-07-16 11:38:02 -0400124 { kWindowInterfaceV0_ANPGetValue, sizeof(gWindowI), &gWindowI },
Grace Klobafbe47c02009-05-14 17:31:45 -0700125 };
126 for (size_t i = 0; i < ARRAY_COUNT(gPairs); i++) {
127 gPairs[i].i->inSize = gPairs[i].size;
128 NPError err = browser->getvalue(NULL, gPairs[i].v, gPairs[i].i);
129 if (err) {
130 return err;
131 }
132 }
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400133
Derek Sollenbergerb8947ee2009-10-05 14:40:18 -0400134 // store the JavaVM for the plugin
135 JNIEnv* env = (JNIEnv*)java_env;
136 env->GetJavaVM(&gVM);
137
Grace Klobafbe47c02009-05-14 17:31:45 -0700138 return NPERR_NO_ERROR;
139}
140
141void NP_Shutdown(void)
142{
143
144}
145
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400146const char *NP_GetMIMEDescription(void)
Grace Klobafbe47c02009-05-14 17:31:45 -0700147{
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400148 return "application/x-testbrowserplugin:tst:Test plugin mimetype is application/x-testbrowserplugin";
Grace Klobafbe47c02009-05-14 17:31:45 -0700149}
150
151NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
152 char* argn[], char* argv[], NPSavedData* saved)
153{
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400154
155 /* BEGIN: STANDARD PLUGIN FRAMEWORK */
Grace Klobafbe47c02009-05-14 17:31:45 -0700156 PluginObject *obj = NULL;
157
158 // Scripting functions appeared in NPAPI version 14
159 if (browser->version >= 14) {
Derek Sollenbergerb4a23912009-11-09 15:38:58 -0500160 instance->pdata = browser->createobject (instance, getPluginClass());
161 obj = static_cast<PluginObject*>(instance->pdata);
Grace Klobafbe47c02009-05-14 17:31:45 -0700162 }
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400163 /* END: STANDARD PLUGIN FRAMEWORK */
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400164
Derek Sollenberger4fb83e62009-07-27 16:40:13 -0400165 // select the drawing model based on user input
166 ANPDrawingModel model = kBitmap_ANPDrawingModel;
167
168 for (int i = 0; i < argc; i++) {
169 if (!strcmp(argn[i], "DrawingModel")) {
170 if (!strcmp(argv[i], "Bitmap")) {
171 model = kBitmap_ANPDrawingModel;
172 }
173 else if (!strcmp(argv[i], "Surface")) {
174 model = kSurface_ANPDrawingModel;
175 }
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500176 gLogI.log(kDebug_ANPLogType, "------ %p DrawingModel is %d", instance, model);
Derek Sollenberger4fb83e62009-07-27 16:40:13 -0400177 break;
178 }
179 }
180
181 // notify the plugin API of the drawing model we wish to use. This must be
182 // done prior to creating certain subPlugin objects (e.g. surfaceViews)
183 NPError err = browser->setvalue(instance, kRequestDrawingModel_ANPSetValue,
184 reinterpret_cast<void*>(model));
185 if (err) {
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500186 gLogI.log(kError_ANPLogType, "request model %d err %d", model, err);
Derek Sollenberger4fb83e62009-07-27 16:40:13 -0400187 return err;
188 }
189
Grace Kloba9ffe5ac2009-08-04 17:51:06 -0700190 const char* path = gSystemI.getApplicationDataDirectory();
191 if (path) {
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500192 gLogI.log(kDebug_ANPLogType, "Application data dir is %s", path);
Grace Kloba9ffe5ac2009-08-04 17:51:06 -0700193 } else {
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500194 gLogI.log(kError_ANPLogType, "Can't find Application data dir");
Grace Kloba9ffe5ac2009-08-04 17:51:06 -0700195 }
196
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400197 // select the pluginType
198 for (int i = 0; i < argc; i++) {
199 if (!strcmp(argn[i], "PluginType")) {
200 if (!strcmp(argv[i], "Animation")) {
201 obj->pluginType = kAnimation_PluginType;
202 obj->activePlugin = new BallAnimation(instance);
203 }
204 else if (!strcmp(argv[i], "Audio")) {
205 obj->pluginType = kAudio_PluginType;
Derek Sollenbergerf42e2f42009-06-26 11:42:46 -0400206 obj->activePlugin = new AudioPlugin(instance);
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400207 }
208 else if (!strcmp(argv[i], "Background")) {
209 obj->pluginType = kBackground_PluginType;
210 obj->activePlugin = new BackgroundPlugin(instance);
211 }
Derek Sollenbergerdb398a72009-06-29 13:53:04 -0400212 else if (!strcmp(argv[i], "Form")) {
213 obj->pluginType = kForm_PluginType;
214 obj->activePlugin = new FormPlugin(instance);
215 }
Derek Sollenberger4fb83e62009-07-27 16:40:13 -0400216 else if (!strcmp(argv[i], "Paint")) {
217 obj->pluginType = kPaint_PluginType;
218 obj->activePlugin = new PaintPlugin(instance);
219 }
Derek Sollenbergerb8947ee2009-10-05 14:40:18 -0400220 else if (!strcmp(argv[i], "Video")) {
221 obj->pluginType = kVideo_PluginType;
222 obj->activePlugin = new VideoPlugin(instance);
223 }
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500224 gLogI.log(kDebug_ANPLogType, "------ %p PluginType is %d", instance, obj->pluginType);
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400225 break;
226 }
227 }
228
229 // if no pluginType is specified then default to Animation
230 if (!obj->pluginType) {
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500231 gLogI.log(kError_ANPLogType, "------ %p No PluginType attribute was found", instance);
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400232 obj->pluginType = kAnimation_PluginType;
233 obj->activePlugin = new BallAnimation(instance);
234 }
235
Derek Sollenberger21f39912009-07-09 09:19:39 -0400236 // check to ensure the pluginType supports the model
237 if (!obj->activePlugin->supportsDrawingModel(model)) {
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500238 gLogI.log(kError_ANPLogType, "------ %p Unsupported DrawingModel (%d)", instance, model);
Derek Sollenberger21f39912009-07-09 09:19:39 -0400239 return NPERR_GENERIC_ERROR;
240 }
241
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400242 return NPERR_NO_ERROR;
Grace Klobafbe47c02009-05-14 17:31:45 -0700243}
244
245NPError NPP_Destroy(NPP instance, NPSavedData** save)
246{
247 PluginObject *obj = (PluginObject*) instance->pdata;
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400248 delete obj->activePlugin;
Grace Klobafbe47c02009-05-14 17:31:45 -0700249
250 return NPERR_NO_ERROR;
251}
252
Grace Klobafbe47c02009-05-14 17:31:45 -0700253NPError NPP_SetWindow(NPP instance, NPWindow* window)
254{
255 PluginObject *obj = (PluginObject*) instance->pdata;
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400256
Grace Klobafbe47c02009-05-14 17:31:45 -0700257 // Do nothing if browser didn't support NPN_CreateObject which would have created the PluginObject.
258 if (obj != NULL) {
259 obj->window = window;
260 }
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400261
Grace Klobafbe47c02009-05-14 17:31:45 -0700262 browser->invalidaterect(instance, NULL);
263
264 return NPERR_NO_ERROR;
265}
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400266
Grace Klobafbe47c02009-05-14 17:31:45 -0700267NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
268{
269 *stype = NP_ASFILEONLY;
270 return NPERR_NO_ERROR;
271}
272
273NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
274{
275 return NPERR_NO_ERROR;
276}
277
278int32 NPP_WriteReady(NPP instance, NPStream* stream)
279{
280 return 0;
281}
282
283int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
284{
285 return 0;
286}
287
288void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
289{
290}
291
292void NPP_Print(NPP instance, NPPrint* platformPrint)
293{
Grace Klobafbe47c02009-05-14 17:31:45 -0700294}
295
Grace Klobafbe47c02009-05-14 17:31:45 -0700296int16 NPP_HandleEvent(NPP instance, void* event)
297{
298 PluginObject *obj = reinterpret_cast<PluginObject*>(instance->pdata);
299 const ANPEvent* evt = reinterpret_cast<const ANPEvent*>(event);
300
Derek Sollenberger5b011e32009-06-22 11:39:40 -0400301#if DEBUG_PLUGIN_EVENTS
Grace Klobafbe47c02009-05-14 17:31:45 -0700302 switch (evt->eventType) {
303 case kDraw_ANPEventType:
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400304
305 if (evt->data.draw.model == kBitmap_ANPDrawingModel) {
306
307 static ANPBitmapFormat currentFormat = -1;
308 if (evt->data.draw.data.bitmap.format != currentFormat) {
309 currentFormat = evt->data.draw.data.bitmap.format;
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500310 gLogI.log(kDebug_ANPLogType, "---- %p Draw (bitmap)"
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400311 " clip=%d,%d,%d,%d format=%d", instance,
312 evt->data.draw.clip.left,
313 evt->data.draw.clip.top,
314 evt->data.draw.clip.right,
315 evt->data.draw.clip.bottom,
316 evt->data.draw.data.bitmap.format);
317 }
Grace Klobafbe47c02009-05-14 17:31:45 -0700318 }
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400319 break;
Grace Klobafbe47c02009-05-14 17:31:45 -0700320
321 case kKey_ANPEventType:
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500322 gLogI.log(kDebug_ANPLogType, "---- %p Key action=%d"
Grace Klobafbe47c02009-05-14 17:31:45 -0700323 " code=%d vcode=%d unichar=%d repeat=%d mods=%x", instance,
324 evt->data.key.action,
325 evt->data.key.nativeCode,
326 evt->data.key.virtualCode,
327 evt->data.key.unichar,
328 evt->data.key.repeatCount,
329 evt->data.key.modifiers);
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400330 break;
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400331
332 case kLifecycle_ANPEventType:
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500333 gLogI.log(kDebug_ANPLogType, "---- %p Lifecycle action=%d",
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400334 instance, evt->data.lifecycle.action);
Mike Reed1e7c3312009-05-26 16:37:45 -0400335 break;
Grace Klobafbe47c02009-05-14 17:31:45 -0700336
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400337 case kTouch_ANPEventType:
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500338 gLogI.log(kDebug_ANPLogType, "---- %p Touch action=%d [%d %d]",
Grace Klobafbe47c02009-05-14 17:31:45 -0700339 instance, evt->data.touch.action, evt->data.touch.x,
340 evt->data.touch.y);
Derek Sollenberger5b011e32009-06-22 11:39:40 -0400341 break;
342
Derek Sollenbergerdb398a72009-06-29 13:53:04 -0400343 case kMouse_ANPEventType:
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500344 gLogI.log(kDebug_ANPLogType, "---- %p Mouse action=%d [%d %d]",
Derek Sollenbergerdb398a72009-06-29 13:53:04 -0400345 instance, evt->data.mouse.action, evt->data.mouse.x,
346 evt->data.mouse.y);
347 break;
348
Derek Sollenberger5b011e32009-06-22 11:39:40 -0400349 case kVisibleRect_ANPEventType:
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500350 gLogI.log(kDebug_ANPLogType, "---- %p VisibleRect [%d %d %d %d]",
Derek Sollenbergerf42e2f42009-06-26 11:42:46 -0400351 instance, evt->data.visibleRect.rect.left, evt->data.visibleRect.rect.top,
352 evt->data.visibleRect.rect.right, evt->data.visibleRect.rect.bottom);
Derek Sollenberger5b011e32009-06-22 11:39:40 -0400353 break;
Grace Klobafbe47c02009-05-14 17:31:45 -0700354
355 default:
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500356 gLogI.log(kError_ANPLogType, "---- %p Unknown Event [%d]",
Derek Sollenberger5b011e32009-06-22 11:39:40 -0400357 instance, evt->eventType);
Grace Klobafbe47c02009-05-14 17:31:45 -0700358 break;
359 }
Derek Sollenberger5b011e32009-06-22 11:39:40 -0400360#endif
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400361
362 if(!obj->activePlugin) {
Derek Sollenbergere62ce172009-11-30 11:52:06 -0500363 gLogI.log(kError_ANPLogType, "the active plugin is null.");
Derek Sollenbergerd7ebf272009-06-18 11:19:41 -0400364 return 0; // unknown or unhandled event
365 }
366 else {
367 return obj->activePlugin->handleEvent(evt);
368 }
Grace Klobafbe47c02009-05-14 17:31:45 -0700369}
370
371void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
372{
373
374}
375
376EXPORT NPError NP_GetValue(NPP instance, NPPVariable variable, void *value) {
377
378 if (variable == NPPVpluginNameString) {
379 const char **str = (const char **)value;
380 *str = "Test Plugin";
381 return NPERR_NO_ERROR;
382 }
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400383
Grace Klobafbe47c02009-05-14 17:31:45 -0700384 if (variable == NPPVpluginDescriptionString) {
385 const char **str = (const char **)value;
386 *str = "Description of Test Plugin";
387 return NPERR_NO_ERROR;
388 }
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400389
Grace Klobafbe47c02009-05-14 17:31:45 -0700390 return NPERR_GENERIC_ERROR;
391}
392
393NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
394{
395 if (variable == NPPVpluginScriptableNPObject) {
396 void **v = (void **)value;
397 PluginObject *obj = (PluginObject*) instance->pdata;
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400398
Grace Klobafbe47c02009-05-14 17:31:45 -0700399 if (obj)
Derek Sollenbergerb4a23912009-11-09 15:38:58 -0500400 browser->retainobject(&obj->header);
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400401
Derek Sollenbergerb4a23912009-11-09 15:38:58 -0500402 *v = &(obj->header);
Grace Klobafbe47c02009-05-14 17:31:45 -0700403 return NPERR_NO_ERROR;
404 }
Derek Sollenberger9119e7d2009-06-08 10:53:09 -0400405
Grace Klobafbe47c02009-05-14 17:31:45 -0700406 return NPERR_GENERIC_ERROR;
407}
408
409NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
410{
411 return NPERR_GENERIC_ERROR;
412}
413