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 #include "config.h"
00039
00040 #ifdef HAVE_MOZILLA_CONFIG_H
00041 # include <mozilla-config.h>
00042 #endif
00043
00044 #include "nscore.h"
00045 #include "npapi.h"
00046 #include "npupp.h"
00047
00048
00049 #define NP_EXPORT
00050
00051
00052 NPNetscapeFuncs* g_pNavigatorFuncs = 0;
00053 JRIGlobalRef Private_GetJavaClass(void);
00054
00055
00057
00058
00059
00060
00061
00062 JRIGlobalRef
00063 Private_GetJavaClass(void)
00064 {
00065 jref clazz = NPP_GetJavaClass();
00066 if (clazz) {
00067 JRIEnv* env = NPN_GetJavaEnv();
00068 return JRI_NewGlobalRef(env, clazz);
00069 }
00070 return NULL;
00071 }
00072
00073
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 static NPPluginFuncs* g_pluginFuncs;
00085
00086
00088
00089
00090
00091
00092
00093
00094 #ifdef __MINGW32__
00095 extern "C" __declspec(dllexport) NPError WINAPI
00096 #else
00097 NPError WINAPI NP_EXPORT
00098 #endif
00099 NP_GetEntryPoints(NPPluginFuncs* pFuncs)
00100 {
00101
00102 if(pFuncs == NULL)
00103 return NPERR_INVALID_FUNCTABLE_ERROR;
00104
00105
00106
00107
00108 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
00109 pFuncs->newp = NPP_New;
00110 pFuncs->destroy = NPP_Destroy;
00111 pFuncs->setwindow = NPP_SetWindow;
00112 pFuncs->newstream = NPP_NewStream;
00113 pFuncs->destroystream = NPP_DestroyStream;
00114 pFuncs->asfile = NPP_StreamAsFile;
00115 pFuncs->writeready = NPP_WriteReady;
00116 pFuncs->write = NPP_Write;
00117 pFuncs->print = NPP_Print;
00118 pFuncs->getvalue = NPP_GetValue;
00119 pFuncs->event = 0;
00120
00121 g_pluginFuncs = pFuncs;
00122
00123 return NPERR_NO_ERROR;
00124 }
00125
00126
00128
00129
00130
00131
00132 #ifdef __MINGW32__
00133 extern "C" __declspec(dllexport) NPError WINAPI
00134 #else
00135 NPError WINAPI NP_EXPORT
00136 #endif
00137 NP_Initialize(NPNetscapeFuncs* pFuncs)
00138 {
00139
00140 if(pFuncs == NULL)
00141 return NPERR_INVALID_FUNCTABLE_ERROR;
00142
00143 g_pNavigatorFuncs = pFuncs;
00144
00145
00146
00147 if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
00148 return NPERR_INCOMPATIBLE_VERSION_ERROR;
00149
00150
00151 int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
00152
00153 if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
00154 g_pluginFuncs->urlnotify = NPP_URLNotify;
00155 }
00156
00157 if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) {
00158 g_pluginFuncs->javaClass = Private_GetJavaClass();
00159 }
00160
00161
00162 return NPP_Initialize();
00163 }
00164
00165
00167
00168
00169
00170
00171
00172
00173 #ifdef __MINGW32__
00174 extern "C" __declspec(dllexport) NPError WINAPI
00175 #else
00176 NPError WINAPI NP_EXPORT
00177 #endif
00178 NP_Shutdown()
00179 {
00180 NPP_Shutdown();
00181 g_pNavigatorFuncs = NULL;
00182 return NPERR_NO_ERROR;
00183 }
00184
00185
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
00202 {
00203 *plugin_major = NP_VERSION_MAJOR;
00204 *plugin_minor = NP_VERSION_MINOR;
00205 *netscape_major = HIBYTE(g_pNavigatorFuncs->version);
00206 *netscape_minor = LOBYTE(g_pNavigatorFuncs->version);
00207 }
00208
00209 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *result)
00210 {
00211 return g_pNavigatorFuncs->getvalue(instance, variable, result);
00212 }
00213
00214
00215
00216
00217 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
00218
00219 {
00220 int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
00221 NPError err;
00222 if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
00223 err = g_pNavigatorFuncs->geturlnotify(instance, url, target, notifyData);
00224 }
00225 else {
00226 err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00227 }
00228 return err;
00229 }
00230
00231
00232 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
00233 {
00234 return g_pNavigatorFuncs->geturl(instance, url, target);
00235 }
00236
00237 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
00238 {
00239 int navMinorVers = g_pNavigatorFuncs->version & 0xFF;
00240 NPError err;
00241 if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) {
00242 err = g_pNavigatorFuncs->posturlnotify(instance, url, window, len, buf, file, notifyData);
00243 }
00244 else {
00245 err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00246 }
00247 return err;
00248 }
00249
00250
00251 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
00252 {
00253 return g_pNavigatorFuncs->posturl(instance, url, window, len, buf, file);
00254 }
00255
00256
00257
00258
00259
00260 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00261 {
00262 return g_pNavigatorFuncs->requestread(stream, rangeList);
00263 }
00264
00265
00266
00267
00268 NPError NPN_NewStream(NPP instance, NPMIMEType type,
00269 const char* target, NPStream** stream)
00270 {
00271 int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
00272 NPError err;
00273
00274 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
00275 err = g_pNavigatorFuncs->newstream(instance, type, target, stream);
00276 }
00277 else {
00278 err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00279 }
00280 return err;
00281 }
00282
00283
00284
00285 int32 NPN_Write(NPP instance, NPStream *stream,
00286 int32 len, void *buffer)
00287 {
00288 int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
00289 int32 result;
00290
00291 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
00292 result = g_pNavigatorFuncs->write(instance, stream, len, buffer);
00293 }
00294 else {
00295 result = -1;
00296 }
00297 return result;
00298 }
00299
00300
00301
00302
00303 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00304 {
00305 int navMinorVersion = g_pNavigatorFuncs->version & 0xFF;
00306 NPError err;
00307
00308 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT ) {
00309 err = g_pNavigatorFuncs->destroystream(instance, stream, reason);
00310 }
00311 else {
00312 err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00313 }
00314 return err;
00315 }
00316
00317
00318
00319 void NPN_Status(NPP instance, const char *message)
00320 {
00321 g_pNavigatorFuncs->status(instance, message);
00322 }
00323
00324
00325
00326 const char* NPN_UserAgent(NPP instance)
00327 {
00328 return g_pNavigatorFuncs->uagent(instance);
00329 }
00330
00331
00332
00333
00334
00335
00336 void* NPN_MemAlloc(uint32 size)
00337 {
00338 return g_pNavigatorFuncs->memalloc(size);
00339 }
00340
00341
00342
00343 void NPN_MemFree(void* ptr)
00344 {
00345 g_pNavigatorFuncs->memfree(ptr);
00346 }
00347
00348
00349
00350 void NPN_ReloadPlugins(NPBool reloadPages)
00351 {
00352 g_pNavigatorFuncs->reloadplugins(reloadPages);
00353 }
00354
00355 JRIEnv* NPN_GetJavaEnv(void)
00356 {
00357 return g_pNavigatorFuncs->getJavaEnv();
00358 }
00359
00360 jref NPN_GetJavaPeer(NPP instance)
00361 {
00362 return g_pNavigatorFuncs->getJavaPeer(instance);
00363 }
00364