Back to index

lightning-sunbird  0.9+nobinonly
npmac.cpp
Go to the documentation of this file.
00001 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00002 //
00003 // npmac.cpp
00004 //
00005 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00006 
00007 #include <string.h>
00008 
00009 #include <Carbon/Carbon.h>
00010 
00011 #include "npapi.h"
00012 #include "npupp.h"
00013 
00014 //
00015 // Define PLUGIN_TRACE to 1 to have the wrapper functions emit
00016 // DebugStr messages whenever they are called.
00017 //
00018 //#define PLUGIN_TRACE 1
00019 
00020 #if PLUGIN_TRACE
00021 #define PLUGINDEBUGSTR(msg)        ::DebugStr(msg)
00022 #else
00023 #define PLUGINDEBUGSTR(msg)    ((void) 0)
00024 #endif
00025 
00026 
00027 #ifdef __ppc__
00028 
00029 // glue for mapping outgoing Macho function pointers to TVectors
00030 struct TFPtoTVGlue{
00031     void* glue[2];
00032 };
00033 
00034 struct pluginFuncsGlueTable {
00035     TFPtoTVGlue     newp;
00036     TFPtoTVGlue     destroy;
00037     TFPtoTVGlue     setwindow;
00038     TFPtoTVGlue     newstream;
00039     TFPtoTVGlue     destroystream;
00040     TFPtoTVGlue     asfile;
00041     TFPtoTVGlue     writeready;
00042     TFPtoTVGlue     write;
00043     TFPtoTVGlue     print;
00044     TFPtoTVGlue     event;
00045     TFPtoTVGlue     urlnotify;
00046     TFPtoTVGlue     getvalue;
00047     TFPtoTVGlue     setvalue;
00048 
00049     TFPtoTVGlue     shutdown;
00050 } gPluginFuncsGlueTable;
00051 
00052 static inline void* SetupFPtoTVGlue(TFPtoTVGlue* functionGlue, void* fp)
00053 {
00054     functionGlue->glue[0] = fp;
00055     functionGlue->glue[1] = 0;
00056     return functionGlue;
00057 }
00058 
00059 #define PLUGIN_TO_HOST_GLUE(name, fp) (SetupFPtoTVGlue(&gPluginFuncsGlueTable.name, (void*)fp))
00060 
00061 // glue for mapping netscape TVectors to Macho function pointers
00062 struct TTVtoFPGlue {
00063     uint32 glue[6];
00064 };
00065 
00066 struct netscapeFuncsGlueTable {
00067     TTVtoFPGlue             geturl;
00068     TTVtoFPGlue             posturl;
00069     TTVtoFPGlue             requestread;
00070     TTVtoFPGlue             newstream;
00071     TTVtoFPGlue             write;
00072     TTVtoFPGlue             destroystream;
00073     TTVtoFPGlue             status;
00074     TTVtoFPGlue             uagent;
00075     TTVtoFPGlue             memalloc;
00076     TTVtoFPGlue             memfree;
00077     TTVtoFPGlue             memflush;
00078     TTVtoFPGlue             reloadplugins;
00079     TTVtoFPGlue             getJavaEnv;
00080     TTVtoFPGlue             getJavaPeer;
00081     TTVtoFPGlue             geturlnotify;
00082     TTVtoFPGlue             posturlnotify;
00083     TTVtoFPGlue             getvalue;
00084     TTVtoFPGlue             setvalue;
00085     TTVtoFPGlue             invalidaterect;
00086     TTVtoFPGlue             invalidateregion;
00087     TTVtoFPGlue             forceredraw;
00088     TTVtoFPGlue             pushpopupsenabledstate;
00089     TTVtoFPGlue             poppopupsenabledstate;
00090 } gNetscapeFuncsGlueTable;
00091 
00092 static void* SetupTVtoFPGlue(TTVtoFPGlue* functionGlue, void* tvp)
00093 {
00094     static const TTVtoFPGlue glueTemplate = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 };
00095 
00096     memcpy(functionGlue, &glueTemplate, sizeof(TTVtoFPGlue));
00097     functionGlue->glue[0] |= ((UInt32)tvp >> 16);
00098     functionGlue->glue[1] |= ((UInt32)tvp & 0xFFFF);
00099     ::MakeDataExecutable(functionGlue, sizeof(TTVtoFPGlue));
00100     return functionGlue;
00101 }
00102 
00103 #define HOST_TO_PLUGIN_GLUE(name, fp) (SetupTVtoFPGlue(&gNetscapeFuncsGlueTable.name, (void*)fp))
00104 
00105 #else
00106 
00107 #define PLUGIN_TO_HOST_GLUE(name, fp) (fp)
00108 #define HOST_TO_PLUGIN_GLUE(name, fp) (fp)
00109 
00110 #endif /* __ppc__ */
00111 
00112 
00113 #pragma mark -
00114 
00115 
00116 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00117 //
00118 // Globals
00119 //
00120 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00121 
00122 short                gResFile;                   // Refnum of the pluginÕs resource file
00123 NPNetscapeFuncs      gNetscapeFuncs;             // Function table for procs in Netscape called by plugin
00124 
00125 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00126 //
00127 // Wrapper functions for all calls from the plugin to Netscape.
00128 // These functions let the plugin developer just call the APIs
00129 // as documented and defined in npapi.h, without needing to know
00130 // about the function table and call macros in npupp.h.
00131 //
00132 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00133 
00134 
00135 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
00136 {
00137        *plugin_major = NP_VERSION_MAJOR;
00138        *plugin_minor = NP_VERSION_MINOR;
00139        *netscape_major = gNetscapeFuncs.version >> 8;          // Major version is in high byte
00140        *netscape_minor = gNetscapeFuncs.version & 0xFF; // Minor version is in low byte
00141 }
00142 
00143 NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
00144 {
00145        int navMinorVers = gNetscapeFuncs.version & 0xFF;
00146        NPError err;
00147        
00148        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00149        {
00150               err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
00151        }
00152        else
00153        {
00154               err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00155        }
00156        return err;
00157 }
00158 
00159 NPError NPN_GetURL(NPP instance, const char* url, const char* window)
00160 {
00161        return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
00162 }
00163 
00164 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
00165 {
00166        int navMinorVers = gNetscapeFuncs.version & 0xFF;
00167        NPError err;
00168        
00169        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00170        {
00171               err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url, 
00172                                                                                                   window, len, buf, file, notifyData);
00173        }
00174        else
00175        {
00176               err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00177        }
00178        return err;
00179 }
00180 
00181 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
00182 {
00183        return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance, url, window, len, buf, file);
00184 }
00185 
00186 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00187 {
00188        return CallNPN_RequestReadProc(gNetscapeFuncs.requestread, stream, rangeList);
00189 }
00190 
00191 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStream** stream)
00192 {
00193        int navMinorVers = gNetscapeFuncs.version & 0xFF;
00194        NPError err;
00195        
00196        if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
00197        {
00198               err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream);
00199        }
00200        else
00201        {
00202               err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00203        }
00204        return err;
00205 }
00206 
00207 int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
00208 {
00209        int navMinorVers = gNetscapeFuncs.version & 0xFF;
00210        NPError err;
00211        
00212        if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
00213        {
00214               err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);
00215        }
00216        else
00217        {
00218               err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00219        }
00220        return err;
00221 }
00222 
00223 NPError       NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00224 {
00225        int navMinorVers = gNetscapeFuncs.version & 0xFF;
00226        NPError err;
00227        
00228        if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
00229        {
00230               err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);
00231        }
00232        else
00233        {
00234               err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00235        }
00236        return err;
00237 }
00238 
00239 void NPN_Status(NPP instance, const char* message)
00240 {
00241        CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
00242 }
00243 
00244 const char* NPN_UserAgent(NPP instance)
00245 {
00246        return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
00247 }
00248 
00249 void* NPN_MemAlloc(uint32 size)
00250 {
00251        return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
00252 }
00253 
00254 void NPN_MemFree(void* ptr)
00255 {
00256        CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
00257 }
00258 
00259 uint32 NPN_MemFlush(uint32 size)
00260 {
00261        return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
00262 }
00263 
00264 void NPN_ReloadPlugins(NPBool reloadPages)
00265 {
00266        CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
00267 }
00268 
00269 #ifdef OJI
00270 JRIEnv* NPN_GetJavaEnv(void)
00271 {
00272        return CallNPN_GetJavaEnvProc( gNetscapeFuncs.getJavaEnv );
00273 }
00274 
00275 jobject  NPN_GetJavaPeer(NPP instance)
00276 {
00277        return CallNPN_GetJavaPeerProc( gNetscapeFuncs.getJavaPeer, instance );
00278 }
00279 #endif
00280 
00281 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
00282 {
00283        return CallNPN_GetValueProc( gNetscapeFuncs.getvalue, instance, variable, value);
00284 }
00285 
00286 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00287 {
00288        return CallNPN_SetValueProc( gNetscapeFuncs.setvalue, instance, variable, value);
00289 }
00290 
00291 void NPN_InvalidateRect(NPP instance, NPRect *rect)
00292 {
00293        CallNPN_InvalidateRectProc( gNetscapeFuncs.invalidaterect, instance, rect);
00294 }
00295 
00296 void NPN_InvalidateRegion(NPP instance, NPRegion region)
00297 {
00298        CallNPN_InvalidateRegionProc( gNetscapeFuncs.invalidateregion, instance, region);
00299 }
00300 
00301 void NPN_ForceRedraw(NPP instance)
00302 {
00303        CallNPN_ForceRedrawProc( gNetscapeFuncs.forceredraw, instance);
00304 }
00305 
00306 void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
00307 {
00308        CallNPN_PushPopupsEnabledStateProc( gNetscapeFuncs.pushpopupsenabledstate, instance, enabled);
00309 }
00310 
00311 void NPN_PopPopupsEnabledState(NPP instance)
00312 {
00313        CallNPN_PopPopupsEnabledStateProc( gNetscapeFuncs.poppopupsenabledstate, instance);
00314 }
00315 
00316 #pragma mark -
00317 
00318 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00319 //
00320 // Wrapper functions for all calls from Netscape to the plugin.
00321 // These functions let the plugin developer just create the APIs
00322 // as documented and defined in npapi.h, without needing to 
00323 // install those functions in the function table or worry about
00324 // setting up globals for 68K plugins.
00325 //
00326 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00327 
00328 NPError       Private_Initialize(void);
00329 void          Private_Shutdown(void);
00330 NPError              Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
00331 NPError       Private_Destroy(NPP instance, NPSavedData** save);
00332 NPError              Private_SetWindow(NPP instance, NPWindow* window);
00333 NPError              Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
00334 NPError              Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
00335 int32         Private_WriteReady(NPP instance, NPStream* stream);
00336 int32         Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
00337 void          Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
00338 void          Private_Print(NPP instance, NPPrint* platformPrint);
00339 int16         Private_HandleEvent(NPP instance, void* event);
00340 void        Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
00341 jobject              Private_GetJavaClass(void);
00342 
00343 
00344 NPError Private_Initialize(void)
00345 {
00346        PLUGINDEBUGSTR("\pInitialize;g;");
00347        return NPP_Initialize();
00348 }
00349 
00350 void Private_Shutdown(void)
00351 {
00352        PLUGINDEBUGSTR("\pShutdown;g;");
00353        NPP_Shutdown();
00354 }
00355 
00356 
00357 NPError       Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
00358 {
00359        PLUGINDEBUGSTR("\pNew;g;");
00360        return NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
00361 }
00362 
00363 NPError Private_Destroy(NPP instance, NPSavedData** save)
00364 {
00365        PLUGINDEBUGSTR("\pDestroy;g;");
00366        return NPP_Destroy(instance, save);
00367 }
00368 
00369 NPError Private_SetWindow(NPP instance, NPWindow* window)
00370 {
00371        PLUGINDEBUGSTR("\pSetWindow;g;");
00372        return NPP_SetWindow(instance, window);
00373 }
00374 
00375 NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
00376 {
00377        PLUGINDEBUGSTR("\pNewStream;g;");
00378        return NPP_NewStream(instance, type, stream, seekable, stype);
00379 }
00380 
00381 int32 Private_WriteReady(NPP instance, NPStream* stream)
00382 {
00383        PLUGINDEBUGSTR("\pWriteReady;g;");
00384        return NPP_WriteReady(instance, stream);
00385 }
00386 
00387 int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
00388 {
00389        PLUGINDEBUGSTR("\pWrite;g;");
00390        return NPP_Write(instance, stream, offset, len, buffer);
00391 }
00392 
00393 void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
00394 {
00395        PLUGINDEBUGSTR("\pStreamAsFile;g;");
00396        NPP_StreamAsFile(instance, stream, fname);
00397 }
00398 
00399 
00400 NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00401 {
00402        PLUGINDEBUGSTR("\pDestroyStream;g;");
00403        return NPP_DestroyStream(instance, stream, reason);
00404 }
00405 
00406 int16 Private_HandleEvent(NPP instance, void* event)
00407 {
00408        PLUGINDEBUGSTR("\pHandleEvent;g;");
00409        return NPP_HandleEvent(instance, event);
00410 }
00411 
00412 void Private_Print(NPP instance, NPPrint* platformPrint)
00413 {
00414        PLUGINDEBUGSTR("\pPrint;g;");
00415        NPP_Print(instance, platformPrint);
00416 }
00417 
00418 void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
00419 {
00420        PLUGINDEBUGSTR("\pURLNotify;g;");
00421        NPP_URLNotify(instance, url, reason, notifyData);
00422 }
00423 
00424 #ifdef OJI
00425 jobject Private_GetJavaClass(void)
00426 {
00427        PLUGINDEBUGSTR("\pGetJavaClass;g;");
00428 
00429     jobject clazz = NPP_GetJavaClass();
00430     if (clazz)
00431     {
00432               JRIEnv* env = NPN_GetJavaEnv();
00433               return (jobject)JRI_NewGlobalRef(env, clazz);
00434     }
00435     return NULL;
00436 }
00437 #endif
00438 
00439 void SetUpQD(void);
00440 void SetUpQD(void)
00441 {
00442        //
00443        // Memorize the pluginÕs resource file 
00444        // refnum for later use.
00445        //
00446        gResFile = CurResFile();
00447 }
00448 
00449 
00450 int main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
00451 
00452 DEFINE_API_C(int) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp)
00453 {
00454        PLUGINDEBUGSTR("\pmain");
00455 
00456        NPError err = NPERR_NO_ERROR;
00457        
00458        //
00459        // Ensure that everything Netscape passed us is valid!
00460        //
00461        if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL))
00462               err = NPERR_INVALID_FUNCTABLE_ERROR;
00463        
00464        //
00465        // Check the ŌmajorĶ version passed in NetscapeÕs function table.
00466        // We wonÕt load if the major version is newer than what we expect.
00467        // Also check that the function tables passed in are big enough for
00468        // all the functions we need (they could be bigger, if Netscape added
00469        // new APIs, but thatÕs OK with us -- weÕll just ignore them).
00470        //
00471        if (err == NPERR_NO_ERROR)
00472        {
00473               if ((nsTable->version >> 8) > NP_VERSION_MAJOR)         // Major version is in high byte
00474                      err = NPERR_INCOMPATIBLE_VERSION_ERROR;
00475        }
00476               
00477        
00478        if (err == NPERR_NO_ERROR)
00479        {
00480               //
00481               // Copy all the fields of NetscapeÕs function table into our
00482               // copy so we can call back into Netscape later.  Note that
00483               // we need to copy the fields one by one, rather than assigning
00484               // the whole structure, because the Netscape function table
00485               // could actually be bigger than what we expect.
00486               //
00487               
00488               int navMinorVers = nsTable->version & 0xFF;
00489 
00490               gNetscapeFuncs.version          = nsTable->version;
00491               gNetscapeFuncs.size             = nsTable->size;
00492               gNetscapeFuncs.posturl          = (NPN_PostURLUPP)HOST_TO_PLUGIN_GLUE(posturl, nsTable->posturl);
00493               gNetscapeFuncs.geturl           = (NPN_GetURLUPP)HOST_TO_PLUGIN_GLUE(geturl, nsTable->geturl);
00494               gNetscapeFuncs.requestread      = (NPN_RequestReadUPP)HOST_TO_PLUGIN_GLUE(requestread, nsTable->requestread);
00495               gNetscapeFuncs.newstream        = (NPN_NewStreamUPP)HOST_TO_PLUGIN_GLUE(newstream, nsTable->newstream);
00496               gNetscapeFuncs.write            = (NPN_WriteUPP)HOST_TO_PLUGIN_GLUE(write, nsTable->write);
00497               gNetscapeFuncs.destroystream    = (NPN_DestroyStreamUPP)HOST_TO_PLUGIN_GLUE(destroystream, nsTable->destroystream);
00498               gNetscapeFuncs.status           = (NPN_StatusUPP)HOST_TO_PLUGIN_GLUE(status, nsTable->status);
00499               gNetscapeFuncs.uagent           = (NPN_UserAgentUPP)HOST_TO_PLUGIN_GLUE(uagent, nsTable->uagent);
00500               gNetscapeFuncs.memalloc         = (NPN_MemAllocUPP)HOST_TO_PLUGIN_GLUE(memalloc, nsTable->memalloc);
00501               gNetscapeFuncs.memfree          = (NPN_MemFreeUPP)HOST_TO_PLUGIN_GLUE(memfree, nsTable->memfree);
00502               gNetscapeFuncs.memflush         = (NPN_MemFlushUPP)HOST_TO_PLUGIN_GLUE(memflush, nsTable->memflush);
00503               gNetscapeFuncs.reloadplugins    = (NPN_ReloadPluginsUPP)HOST_TO_PLUGIN_GLUE(reloadplugins, nsTable->reloadplugins);
00504               if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
00505               {
00506                      gNetscapeFuncs.getJavaEnv   = (NPN_GetJavaEnvUPP)HOST_TO_PLUGIN_GLUE(getJavaEnv, nsTable->getJavaEnv);
00507                      gNetscapeFuncs.getJavaPeer  = (NPN_GetJavaPeerUPP)HOST_TO_PLUGIN_GLUE(getJavaPeer, nsTable->getJavaPeer);
00508               }
00509               if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00510               {      
00511                      gNetscapeFuncs.geturlnotify        = (NPN_GetURLNotifyUPP)HOST_TO_PLUGIN_GLUE(geturlnotify, nsTable->geturlnotify);
00512                      gNetscapeFuncs.posturlnotify       = (NPN_PostURLNotifyUPP)HOST_TO_PLUGIN_GLUE(posturlnotify, nsTable->posturlnotify);
00513               }
00514               gNetscapeFuncs.getvalue         = (NPN_GetValueUPP)HOST_TO_PLUGIN_GLUE(getvalue, nsTable->getvalue);
00515               gNetscapeFuncs.setvalue         = (NPN_SetValueUPP)HOST_TO_PLUGIN_GLUE(setvalue, nsTable->setvalue);
00516               gNetscapeFuncs.invalidaterect   = (NPN_InvalidateRectUPP)HOST_TO_PLUGIN_GLUE(invalidaterect, nsTable->invalidaterect);
00517               gNetscapeFuncs.invalidateregion = (NPN_InvalidateRegionUPP)HOST_TO_PLUGIN_GLUE(invalidateregion, nsTable->invalidateregion);
00518               gNetscapeFuncs.forceredraw      = (NPN_ForceRedrawUPP)HOST_TO_PLUGIN_GLUE(forceredraw, nsTable->forceredraw);
00519               gNetscapeFuncs.pushpopupsenabledstate = (NPN_PushPopupsEnabledStateUPP)HOST_TO_PLUGIN_GLUE(pushpopupsenabledstate, nsTable->pushpopupsenabledstate);
00520               gNetscapeFuncs.poppopupsenabledstate  = (NPN_PopPopupsEnabledStateUPP)HOST_TO_PLUGIN_GLUE(poppopupsenabledstate, nsTable->poppopupsenabledstate);
00521               
00522               //
00523               // Set up the plugin function table that Netscape will use to
00524               // call us.  Netscape needs to know about our version and size
00525               // and have a UniversalProcPointer for every function we implement.
00526               //
00527               pluginFuncs->version        = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
00528               pluginFuncs->size           = sizeof(NPPluginFuncs);
00529               pluginFuncs->newp           = NewNPP_NewProc(PLUGIN_TO_HOST_GLUE(newp, Private_New));
00530               pluginFuncs->destroy        = NewNPP_DestroyProc(PLUGIN_TO_HOST_GLUE(destroy, Private_Destroy));
00531               pluginFuncs->setwindow      = NewNPP_SetWindowProc(PLUGIN_TO_HOST_GLUE(setwindow, Private_SetWindow));
00532               pluginFuncs->newstream      = NewNPP_NewStreamProc(PLUGIN_TO_HOST_GLUE(newstream, Private_NewStream));
00533               pluginFuncs->destroystream  = NewNPP_DestroyStreamProc(PLUGIN_TO_HOST_GLUE(destroystream, Private_DestroyStream));
00534               pluginFuncs->asfile         = NewNPP_StreamAsFileProc(PLUGIN_TO_HOST_GLUE(asfile, Private_StreamAsFile));
00535               pluginFuncs->writeready     = NewNPP_WriteReadyProc(PLUGIN_TO_HOST_GLUE(writeready, Private_WriteReady));
00536               pluginFuncs->write          = NewNPP_WriteProc(PLUGIN_TO_HOST_GLUE(write, Private_Write));
00537               pluginFuncs->print          = NewNPP_PrintProc(PLUGIN_TO_HOST_GLUE(print, Private_Print));
00538               pluginFuncs->event          = NewNPP_HandleEventProc(PLUGIN_TO_HOST_GLUE(event, Private_HandleEvent));   
00539               if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00540               {      
00541                      pluginFuncs->urlnotify = NewNPP_URLNotifyProc(PLUGIN_TO_HOST_GLUE(urlnotify, Private_URLNotify));               
00542               }
00543 #ifdef OJI
00544               if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
00545               {
00546                      pluginFuncs->javaClass      = (JRIGlobalRef) Private_GetJavaClass();
00547               }
00548 #else
00549                 pluginFuncs->javaClass = NULL;
00550 #endif
00551               *unloadUpp = NewNPP_ShutdownProc(PLUGIN_TO_HOST_GLUE(shutdown, Private_Shutdown));
00552 
00553               SetUpQD();
00554               err = Private_Initialize();
00555        }
00556        
00557        return err;
00558 }