00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #define XP_UNIX 1
00042 #define OJI 1
00043
00044 #include <stdio.h>
00045 #include "nscore.h"
00046 #include "npapi.h"
00047 #include "npupp.h"
00048
00049
00050
00051
00052
00053
00054 #ifdef PLUGIN_TRACE
00055 #include <stdio.h>
00056 #define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
00057 #else
00058 #define PLUGINDEBUGSTR(msg)
00059 #endif
00060
00061
00062
00063
00064
00065
00066
00067
00068 static NPNetscapeFuncs gNetscapeFuncs;
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 void
00082 NPN_Version(int* plugin_major, int* plugin_minor,
00083 int* netscape_major, int* netscape_minor)
00084 {
00085 *plugin_major = NP_VERSION_MAJOR;
00086 *plugin_minor = NP_VERSION_MINOR;
00087
00088
00089 *netscape_major = gNetscapeFuncs.version >> 8;
00090
00091 *netscape_minor = gNetscapeFuncs.version & 0xFF;
00092 }
00093
00094 NPError
00095 NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
00096 {
00097 return CallNPN_GetValueProc(gNetscapeFuncs.getvalue,
00098 instance, variable, r_value);
00099 }
00100
00101 NPError
00102 NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00103 {
00104 return CallNPN_SetValueProc(gNetscapeFuncs.setvalue,
00105 instance, variable, value);
00106 }
00107
00108 NPError
00109 NPN_GetURL(NPP instance, const char* url, const char* window)
00110 {
00111 return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
00112 }
00113
00114 NPError
00115 NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
00116 {
00117 return CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
00118 }
00119
00120 NPError
00121 NPN_PostURL(NPP instance, const char* url, const char* window,
00122 uint32 len, const char* buf, NPBool file)
00123 {
00124 return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance,
00125 url, window, len, buf, file);
00126 }
00127
00128 NPError
00129 NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len,
00130 const char* buf, NPBool file, void* notifyData)
00131 {
00132 return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify,
00133 instance, url, window, len, buf, file, notifyData);
00134 }
00135
00136 NPError
00137 NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00138 {
00139 return CallNPN_RequestReadProc(gNetscapeFuncs.requestread,
00140 stream, rangeList);
00141 }
00142
00143 NPError
00144 NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
00145 NPStream** stream_ptr)
00146 {
00147 return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance,
00148 type, window, stream_ptr);
00149 }
00150
00151 int32
00152 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
00153 {
00154 return CallNPN_WriteProc(gNetscapeFuncs.write, instance,
00155 stream, len, buffer);
00156 }
00157
00158 NPError
00159 NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00160 {
00161 return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream,
00162 instance, stream, reason);
00163 }
00164
00165 void
00166 NPN_Status(NPP instance, const char* message)
00167 {
00168 CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
00169 }
00170
00171 const char*
00172 NPN_UserAgent(NPP instance)
00173 {
00174 return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
00175 }
00176
00177 void*
00178 NPN_MemAlloc(uint32 size)
00179 {
00180 return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
00181 }
00182
00183 void NPN_MemFree(void* ptr)
00184 {
00185 CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
00186 }
00187
00188 uint32 NPN_MemFlush(uint32 size)
00189 {
00190 return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
00191 }
00192
00193 void NPN_ReloadPlugins(NPBool reloadPages)
00194 {
00195 CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
00196 }
00197
00198 JRIEnv* NPN_GetJavaEnv()
00199 {
00200 return CallNPN_GetJavaEnvProc(gNetscapeFuncs.getJavaEnv);
00201 }
00202
00203 jref NPN_GetJavaPeer(NPP instance)
00204 {
00205 return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer,
00206 instance);
00207 }
00208
00209 void
00210 NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
00211 {
00212 CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance,
00213 invalidRect);
00214 }
00215
00216 void
00217 NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
00218 {
00219 CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance,
00220 invalidRegion);
00221 }
00222
00223 void
00224 NPN_ForceRedraw(NPP instance)
00225 {
00226 CallNPN_ForceRedrawProc(gNetscapeFuncs.forceredraw, instance);
00227 }
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 NPError
00243 Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
00244 int16 argc, char* argn[], char* argv[], NPSavedData* saved)
00245 {
00246 NPError ret;
00247 PLUGINDEBUGSTR("New");
00248 ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
00249 return ret;
00250 }
00251
00252 NPError
00253 Private_Destroy(NPP instance, NPSavedData** save)
00254 {
00255 PLUGINDEBUGSTR("Destroy");
00256 return NPP_Destroy(instance, save);
00257 }
00258
00259 NPError
00260 Private_SetWindow(NPP instance, NPWindow* window)
00261 {
00262 NPError err;
00263 PLUGINDEBUGSTR("SetWindow");
00264 err = NPP_SetWindow(instance, window);
00265 return err;
00266 }
00267
00268 NPError
00269 Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
00270 NPBool seekable, uint16* stype)
00271 {
00272 NPError err;
00273 PLUGINDEBUGSTR("NewStream");
00274 err = NPP_NewStream(instance, type, stream, seekable, stype);
00275 return err;
00276 }
00277
00278 int32
00279 Private_WriteReady(NPP instance, NPStream* stream)
00280 {
00281 unsigned int result;
00282 PLUGINDEBUGSTR("WriteReady");
00283 result = NPP_WriteReady(instance, stream);
00284 return result;
00285 }
00286
00287 int32
00288 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
00289 void* buffer)
00290 {
00291 unsigned int result;
00292 PLUGINDEBUGSTR("Write");
00293 result = NPP_Write(instance, stream, offset, len, buffer);
00294 return result;
00295 }
00296
00297 void
00298 Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
00299 {
00300 PLUGINDEBUGSTR("StreamAsFile");
00301 NPP_StreamAsFile(instance, stream, fname);
00302 }
00303
00304
00305 NPError
00306 Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00307 {
00308 NPError err;
00309 PLUGINDEBUGSTR("DestroyStream");
00310 err = NPP_DestroyStream(instance, stream, reason);
00311 return err;
00312 }
00313
00314 void
00315 Private_URLNotify(NPP instance, const char* url,
00316 NPReason reason, void* notifyData)
00317
00318 {
00319 PLUGINDEBUGSTR("URLNotify");
00320 NPP_URLNotify(instance, url, reason, notifyData);
00321 }
00322
00323
00324
00325 void
00326 Private_Print(NPP instance, NPPrint* platformPrint)
00327 {
00328 PLUGINDEBUGSTR("Print");
00329 NPP_Print(instance, platformPrint);
00330 }
00331
00332 NPError
00333 Private_GetValue(NPP instance, NPPVariable variable, void *r_value)
00334 {
00335 PLUGINDEBUGSTR("GetValue");
00336 return NPP_GetValue(instance, variable, r_value);
00337 }
00338
00339 JRIGlobalRef
00340 Private_GetJavaClass(void)
00341 {
00342 jref clazz = NPP_GetJavaClass();
00343 if (clazz) {
00344 JRIEnv* env = NPN_GetJavaEnv();
00345 return JRI_NewGlobalRef(env, clazz);
00346 }
00347 return NULL;
00348 }
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 char *
00363 NP_GetMIMEDescription(void)
00364 {
00365 return NPP_GetMIMEDescription();
00366 }
00367
00368
00369
00370
00371
00372
00373
00374 NPError
00375 NP_GetValue(void *future, NPPVariable variable, void *value)
00376 {
00377 return NPP_GetValue(future, variable, value);
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 NPError
00398 NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
00399 {
00400 NPError err = NPERR_NO_ERROR;
00401
00402 PLUGINDEBUGSTR("NP_Initialize");
00403
00404
00405
00406 if ((nsTable == NULL) || (pluginFuncs == NULL))
00407 err = NPERR_INVALID_FUNCTABLE_ERROR;
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418 if (err == NPERR_NO_ERROR) {
00419 if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
00420 err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00421 if (nsTable->size < sizeof(NPNetscapeFuncs))
00422 err = NPERR_INVALID_FUNCTABLE_ERROR;
00423 if (pluginFuncs->size < sizeof(NPPluginFuncs))
00424 err = NPERR_INVALID_FUNCTABLE_ERROR;
00425 }
00426
00427
00428 if (err == NPERR_NO_ERROR) {
00429
00430
00431
00432
00433
00434
00435
00436 gNetscapeFuncs.version = nsTable->version;
00437 gNetscapeFuncs.size = nsTable->size;
00438 gNetscapeFuncs.posturl = nsTable->posturl;
00439 gNetscapeFuncs.geturl = nsTable->geturl;
00440 gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
00441 gNetscapeFuncs.requestread = nsTable->requestread;
00442 gNetscapeFuncs.newstream = nsTable->newstream;
00443 gNetscapeFuncs.write = nsTable->write;
00444 gNetscapeFuncs.destroystream = nsTable->destroystream;
00445 gNetscapeFuncs.status = nsTable->status;
00446 gNetscapeFuncs.uagent = nsTable->uagent;
00447 gNetscapeFuncs.memalloc = nsTable->memalloc;
00448 gNetscapeFuncs.memfree = nsTable->memfree;
00449 gNetscapeFuncs.memflush = nsTable->memflush;
00450 gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
00451 gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
00452 gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
00453 gNetscapeFuncs.getvalue = nsTable->getvalue;
00454
00455
00456
00457
00458
00459
00460
00461 pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
00462 pluginFuncs->size = sizeof(NPPluginFuncs);
00463 pluginFuncs->newp = NewNPP_NewProc(Private_New);
00464 pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
00465 pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
00466 pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
00467 pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
00468 pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
00469 pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
00470 pluginFuncs->write = NewNPP_WriteProc(Private_Write);
00471 pluginFuncs->print = NewNPP_PrintProc(Private_Print);
00472 pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);
00473 pluginFuncs->event = NULL;
00474 pluginFuncs->javaClass = Private_GetJavaClass();
00475 pluginFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
00476
00477 err = NPP_Initialize();
00478 }
00479
00480 return err;
00481 }
00482
00483
00484
00485
00486
00487
00488
00489
00490 NPError
00491 NP_Shutdown(void)
00492 {
00493 PLUGINDEBUGSTR("NP_Shutdown");
00494 NPP_Shutdown();
00495 return NPERR_NO_ERROR;
00496 }