~ubuntu-branches/debian/squeeze/djvulibre/squeeze

« back to all changes in this revision

Viewing changes to gui/npsdk/npmac.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barak A. Pearlmutter
  • Date: 2004-11-01 16:49:49 UTC
  • Revision ID: james.westby@ubuntu.com-20041101164949-fm4bl2hmkvkseoqw
Tags: upstream-3.5.14
ImportĀ upstreamĀ versionĀ 3.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
2
//
 
3
// npmac.cpp
 
4
//
 
5
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
6
 
 
7
#include <Processes.h>
 
8
#include <Gestalt.h>
 
9
#include <FragLoad.h>
 
10
#include <Timer.h>
 
11
#include <Resources.h>
 
12
#include <ToolUtils.h>
 
13
 
 
14
#define XP_MAC 1
 
15
 
 
16
//
 
17
// A4Stuff.h contains the definition of EnterCodeResource and 
 
18
// EnterCodeResource, used for setting up the code resource's
 
19
// globals for 68K (analagous to the function SetCurrentA5
 
20
// defined by the toolbox).
 
21
//
 
22
#include <A4Stuff.h>
 
23
 
 
24
 
 
25
#include "npapi.h"
 
26
 
 
27
//
 
28
// The Mixed Mode procInfos defined in npupp.h assume Think C-
 
29
// style calling conventions.  These conventions are used by
 
30
// Metrowerks with the exception of pointer return types, which
 
31
// in Metrowerks 68K are returned in A0, instead of the standard
 
32
// D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
 
33
// Mixed Mode will return the values to a 68K plugin in D0, but 
 
34
// a 68K plugin compiled by Metrowerks will expect the result in
 
35
// A0.  The following pragma forces Metrowerks to use D0 instead.
 
36
//
 
37
#ifdef __MWERKS__
 
38
#ifndef powerc
 
39
#pragma pointers_in_D0
 
40
#endif
 
41
#endif
 
42
 
 
43
#include "npupp.h"
 
44
 
 
45
#ifdef __MWERKS__
 
46
#ifndef powerc
 
47
#pragma pointers_in_A0
 
48
#endif
 
49
#endif
 
50
 
 
51
 
 
52
//
 
53
// Define PLUGIN_TRACE to 1 to have the wrapper functions emit
 
54
// DebugStr messages whenever they are called.
 
55
//
 
56
#define PLUGIN_TRACE 0
 
57
 
 
58
#if PLUGIN_TRACE
 
59
#define PLUGINDEBUGSTR(msg)             ::DebugStr(msg)
 
60
#else
 
61
#define PLUGINDEBUGSTR
 
62
#endif
 
63
 
 
64
 
 
65
 
 
66
 
 
67
 
 
68
 
 
69
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
70
//
 
71
// Globals
 
72
//
 
73
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
74
 
 
75
QDGlobals*              gQDPtr;                         // Pointer to Netscape's QuickDraw globals
 
76
short                   gResFile;                       // Refnum of the plugin's resource file
 
77
NPNetscapeFuncs gNetscapeFuncs;         // Function table for procs in Netscape called by plugin
 
78
 
 
79
 
 
80
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
81
//
 
82
// Wrapper functions for all calls from the plugin to Netscape.
 
83
// These functions let the plugin developer just call the APIs
 
84
// as documented and defined in npapi.h, without needing to know
 
85
// about the function table and call macros in npupp.h.
 
86
//
 
87
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
88
 
 
89
 
 
90
void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
 
91
{
 
92
        *plugin_major = NP_VERSION_MAJOR;
 
93
        *plugin_minor = NP_VERSION_MINOR;
 
94
        *netscape_major = gNetscapeFuncs.version >> 8;          // Major version is in high byte
 
95
        *netscape_minor = gNetscapeFuncs.version & 0xFF;        // Minor version is in low byte
 
96
}
 
97
 
 
98
NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
 
99
{
 
100
        int navMinorVers = gNetscapeFuncs.version & 0xFF;
 
101
        NPError err;
 
102
        
 
103
        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
 
104
        {
 
105
                err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
 
106
        }
 
107
        else
 
108
        {
 
109
                err = NPERR_INCOMPATIBLE_VERSION_ERROR;
 
110
        }
 
111
        return err;
 
112
}
 
113
 
 
114
NPError NPN_GetURL(NPP instance, const char* url, const char* window)
 
115
{
 
116
        return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
 
117
}
 
118
 
 
119
NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
 
120
{
 
121
        int navMinorVers = gNetscapeFuncs.version & 0xFF;
 
122
        NPError err;
 
123
        
 
124
        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
 
125
        {
 
126
                err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url, 
 
127
                                                                                                                window, len, buf, file, notifyData);
 
128
        }
 
129
        else
 
130
        {
 
131
                err = NPERR_INCOMPATIBLE_VERSION_ERROR;
 
132
        }
 
133
        return err;
 
134
}
 
135
 
 
136
NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
 
137
{
 
138
        return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance, url, window, len, buf, file);
 
139
}
 
140
 
 
141
NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
 
142
{
 
143
        return CallNPN_RequestReadProc(gNetscapeFuncs.requestread, stream, rangeList);
 
144
}
 
145
 
 
146
NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStream** stream)
 
147
{
 
148
        int navMinorVers = gNetscapeFuncs.version & 0xFF;
 
149
        NPError err;
 
150
        
 
151
        if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
 
152
        {
 
153
                err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream);
 
154
        }
 
155
        else
 
156
        {
 
157
                err = NPERR_INCOMPATIBLE_VERSION_ERROR;
 
158
        }
 
159
        return err;
 
160
}
 
161
 
 
162
int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
 
163
{
 
164
        int navMinorVers = gNetscapeFuncs.version & 0xFF;
 
165
        NPError err;
 
166
        
 
167
        if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
 
168
        {
 
169
                err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);
 
170
        }
 
171
        else
 
172
        {
 
173
                err = NPERR_INCOMPATIBLE_VERSION_ERROR;
 
174
        }
 
175
        return err;
 
176
}
 
177
 
 
178
NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
 
179
{
 
180
        int navMinorVers = gNetscapeFuncs.version & 0xFF;
 
181
        NPError err;
 
182
        
 
183
        if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
 
184
        {
 
185
                err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);
 
186
        }
 
187
        else
 
188
        {
 
189
                err = NPERR_INCOMPATIBLE_VERSION_ERROR;
 
190
        }
 
191
        return err;
 
192
}
 
193
 
 
194
void NPN_Status(NPP instance, const char* message)
 
195
{
 
196
        CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
 
197
}
 
198
 
 
199
const char* NPN_UserAgent(NPP instance)
 
200
{
 
201
        return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
 
202
}
 
203
 
 
204
void* NPN_MemAlloc(uint32 size)
 
205
{
 
206
        return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
 
207
}
 
208
 
 
209
void NPN_MemFree(void* ptr)
 
210
{
 
211
        CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
 
212
}
 
213
 
 
214
uint32 NPN_MemFlush(uint32 size)
 
215
{
 
216
        return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
 
217
}
 
218
 
 
219
void NPN_ReloadPlugins(NPBool reloadPages)
 
220
{
 
221
        CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
 
222
}
 
223
 
 
224
 
 
225
JRIEnv* NPN_GetJavaEnv(void)
 
226
{
 
227
        return CallNPN_GetJavaEnvProc( gNetscapeFuncs.getJavaEnv );
 
228
}
 
229
 
 
230
jref  NPN_GetJavaPeer(NPP instance)
 
231
{
 
232
        return CallNPN_GetJavaPeerProc( gNetscapeFuncs.getJavaPeer, instance );
 
233
}
 
234
 
 
235
 
 
236
 
 
237
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
238
//
 
239
// Wrapper functions for all calls from Netscape to the plugin.
 
240
// These functions let the plugin developer just create the APIs
 
241
// as documented and defined in npapi.h, without needing to 
 
242
// install those functions in the function table or worry about
 
243
// setting up globals for 68K plugins.
 
244
//
 
245
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
246
 
 
247
NPError         Private_Initialize(void);
 
248
void            Private_Shutdown(void);
 
249
NPError         Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
 
250
NPError         Private_Destroy(NPP instance, NPSavedData** save);
 
251
NPError         Private_SetWindow(NPP instance, NPWindow* window);
 
252
NPError         Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
 
253
NPError         Private_DestroyStream(NPP instance, NPStream* stream, NPError reason);
 
254
int32           Private_WriteReady(NPP instance, NPStream* stream);
 
255
int32           Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
 
256
void            Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
 
257
void            Private_Print(NPP instance, NPPrint* platformPrint);
 
258
int16           Private_HandleEvent(NPP instance, void* event);
 
259
void        Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData);
 
260
jref            Private_GetJavaClass(void);
 
261
 
 
262
 
 
263
NPError Private_Initialize(void)
 
264
{
 
265
        NPError err;
 
266
        EnterCodeResource();
 
267
        PLUGINDEBUGSTR("\pInitialize;g;");
 
268
        err = NPP_Initialize();
 
269
        ExitCodeResource();
 
270
        return err;
 
271
}
 
272
 
 
273
void Private_Shutdown(void)
 
274
{
 
275
        EnterCodeResource();
 
276
        PLUGINDEBUGSTR("\pShutdown;g;");
 
277
        NPP_Shutdown();
 
278
        ExitCodeResource();
 
279
}
 
280
 
 
281
 
 
282
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
 
283
{
 
284
        EnterCodeResource();
 
285
        NPError ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
 
286
        PLUGINDEBUGSTR("\pNew;g;");
 
287
        ExitCodeResource();
 
288
        return ret;     
 
289
}
 
290
 
 
291
NPError Private_Destroy(NPP instance, NPSavedData** save)
 
292
{
 
293
        NPError err;
 
294
        EnterCodeResource();
 
295
        PLUGINDEBUGSTR("\pDestroy;g;");
 
296
        err = NPP_Destroy(instance, save);
 
297
        ExitCodeResource();
 
298
        return err;
 
299
}
 
300
 
 
301
NPError Private_SetWindow(NPP instance, NPWindow* window)
 
302
{
 
303
        NPError err;
 
304
        EnterCodeResource();
 
305
        PLUGINDEBUGSTR("\pSetWindow;g;");
 
306
        err = NPP_SetWindow(instance, window);
 
307
        ExitCodeResource();
 
308
        return err;
 
309
}
 
310
 
 
311
NPError Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype)
 
312
{
 
313
        NPError err;
 
314
        EnterCodeResource();
 
315
        PLUGINDEBUGSTR("\pNewStream;g;");
 
316
        err = NPP_NewStream(instance, type, stream, seekable, stype);
 
317
        ExitCodeResource();
 
318
        return err;
 
319
}
 
320
 
 
321
int32 Private_WriteReady(NPP instance, NPStream* stream)
 
322
{
 
323
        int32 result;
 
324
        EnterCodeResource();
 
325
        PLUGINDEBUGSTR("\pWriteReady;g;");
 
326
        result = NPP_WriteReady(instance, stream);
 
327
        ExitCodeResource();
 
328
        return result;
 
329
}
 
330
 
 
331
int32 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer)
 
332
{
 
333
        int32 result;
 
334
        EnterCodeResource();
 
335
        PLUGINDEBUGSTR("\pWrite;g;");
 
336
        result = NPP_Write(instance, stream, offset, len, buffer);
 
337
        ExitCodeResource();
 
338
        return result;
 
339
}
 
340
 
 
341
void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
 
342
{
 
343
        EnterCodeResource();
 
344
        PLUGINDEBUGSTR("\pStreamAsFile;g;");
 
345
        NPP_StreamAsFile(instance, stream, fname);
 
346
        ExitCodeResource();
 
347
}
 
348
 
 
349
 
 
350
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
 
351
{
 
352
        NPError err;
 
353
        EnterCodeResource();
 
354
        PLUGINDEBUGSTR("\pDestroyStream;g;");
 
355
        err = NPP_DestroyStream(instance, stream, reason);
 
356
        ExitCodeResource();
 
357
        return err;
 
358
}
 
359
 
 
360
int16 Private_HandleEvent(NPP instance, void* event)
 
361
{
 
362
        int16 result;
 
363
        EnterCodeResource();
 
364
        PLUGINDEBUGSTR("\pHandleEvent;g;");
 
365
        result = NPP_HandleEvent(instance, event);
 
366
        ExitCodeResource();
 
367
        return result;
 
368
}
 
369
 
 
370
void Private_Print(NPP instance, NPPrint* platformPrint)
 
371
{
 
372
        EnterCodeResource();
 
373
        PLUGINDEBUGSTR("\pPrint;g;");
 
374
        NPP_Print(instance, platformPrint);
 
375
        ExitCodeResource();
 
376
}
 
377
 
 
378
void Private_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
 
379
{
 
380
        EnterCodeResource();
 
381
        PLUGINDEBUGSTR("\pURLNotify;g;");
 
382
        NPP_URLNotify(instance, url, reason, notifyData);
 
383
        ExitCodeResource();
 
384
}
 
385
 
 
386
 
 
387
jref Private_GetJavaClass(void)
 
388
{
 
389
        EnterCodeResource();
 
390
        PLUGINDEBUGSTR("\pGetJavaClass;g;");
 
391
 
 
392
    jref clazz = NPP_GetJavaClass();
 
393
    ExitCodeResource();
 
394
    if (clazz)
 
395
    {
 
396
                JRIEnv* env = NPN_GetJavaEnv();
 
397
                return JRI_NewGlobalRef(env, clazz);
 
398
    }
 
399
    return NULL;
 
400
}
 
401
 
 
402
 
 
403
void SetUpQD(void);
 
404
void SetUpQD(void)
 
405
{
 
406
        ProcessSerialNumber PSN;
 
407
        FSSpec                          myFSSpec;
 
408
        Str63                           name;
 
409
        ProcessInfoRec          infoRec;
 
410
        OSErr                           result = noErr;
 
411
        ConnectionID            connID;
 
412
        Str255                          errName;
 
413
        
 
414
        //
 
415
        // Memorize the plugin's resource file 
 
416
        // refnum for later use.
 
417
        //
 
418
        gResFile = CurResFile();
 
419
        
 
420
        //
 
421
        // Ask the system if CFM is available.
 
422
        //
 
423
        long response;
 
424
        OSErr err = Gestalt(gestaltCFMAttr, &response);
 
425
        Boolean hasCFM = BitTst(&response, 31-gestaltCFMPresent);
 
426
                        
 
427
        if (hasCFM)
 
428
        {
 
429
                //
 
430
                // GetProcessInformation takes a process serial number and 
 
431
                // will give us back the name and FSSpec of the application.
 
432
                // See the Process Manager in IM.
 
433
                //
 
434
                infoRec.processInfoLength = sizeof(ProcessInfoRec);
 
435
                infoRec.processName = name;
 
436
                infoRec.processAppSpec = &myFSSpec;
 
437
                
 
438
                PSN.highLongOfPSN = 0;
 
439
                PSN.lowLongOfPSN = kCurrentProcess;
 
440
                
 
441
                result = GetProcessInformation(&PSN, &infoRec);
 
442
                if (result != noErr)
 
443
                        PLUGINDEBUGSTR("\pFailed in GetProcessInformation");
 
444
                }
 
445
        else
 
446
                //
 
447
                // If no CFM installed, assume it must be a 68K app.
 
448
                //
 
449
                result = -1;            
 
450
                
 
451
        if (result == noErr)
 
452
        {
 
453
                //
 
454
                // Now that we know the app name and FSSpec, we can call GetDiskFragment
 
455
                // to get a connID to use in a subsequent call to FindSymbol (it will also
 
456
                // return the address of `main' in app, which we ignore).  If GetDiskFragment 
 
457
                // returns an error, we assume the app must be 68K.
 
458
                //
 
459
                Ptr mainAddr;   
 
460
                result =  GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
 
461
                                                                  kLoadLib, &connID, (Ptr*)&mainAddr, errName);
 
462
        }
 
463
 
 
464
        if (result == noErr) 
 
465
        {
 
466
                //
 
467
                // The app is a PPC code fragment, so call FindSymbol
 
468
                // to get the exported `qd' symbol so we can access its
 
469
                // QuickDraw globals.
 
470
                //
 
471
                SymClass symClass;
 
472
                result = FindSymbol(connID, "\pqd", (Ptr*)&gQDPtr, &symClass);
 
473
                if (result != noErr)
 
474
                        PLUGINDEBUGSTR("\pFailed in FindSymbol qd");
 
475
        }
 
476
        else
 
477
        {
 
478
                //
 
479
                // The app is 68K, so use its A5 to compute the address
 
480
                // of its QuickDraw globals.
 
481
                //
 
482
                gQDPtr = (QDGlobals*)(*((long*)SetCurrentA5()) - (sizeof(QDGlobals) - sizeof(GrafPtr)));
 
483
        }
 
484
 
 
485
}
 
486
 
 
487
 
 
488
 
 
489
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp);
 
490
 
 
491
#if GENERATINGCFM
 
492
RoutineDescriptor mainRD = BUILD_ROUTINE_DESCRIPTOR(uppNPP_MainEntryProcInfo, main);
 
493
#endif
 
494
 
 
495
 
 
496
NPError main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, NPP_ShutdownUPP* unloadUpp)
 
497
{
 
498
        EnterCodeResource();
 
499
        PLUGINDEBUGSTR("\pmain");
 
500
 
 
501
        NPError err = NPERR_NO_ERROR;
 
502
        
 
503
        //
 
504
        // Ensure that everything Netscape passed us is valid!
 
505
        //
 
506
        if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL))
 
507
                err = NPERR_INVALID_FUNCTABLE_ERROR;
 
508
        
 
509
        //
 
510
        // Check the `major' version passed in Netscape's function table.
 
511
        // We won't load if the major version is newer than what we expect.
 
512
        // Also check that the function tables passed in are big enough for
 
513
        // all the functions we need (they could be bigger, if Netscape added
 
514
        // new APIs, but that's OK with us -- we'll just ignore them).
 
515
        //
 
516
        if (err == NPERR_NO_ERROR)
 
517
        {
 
518
                if ((nsTable->version >> 8) > NP_VERSION_MAJOR)         // Major version is in high byte
 
519
                        err = NPERR_INCOMPATIBLE_VERSION_ERROR;
 
520
//              if (nsTable->size < sizeof(NPNetscapeFuncs))
 
521
//                      err = NPERR_INVALID_FUNCTABLE_ERROR;
 
522
//              if (pluginFuncs->size < sizeof(NPPluginFuncs))          
 
523
//                      err = NPERR_INVALID_FUNCTABLE_ERROR;
 
524
        }
 
525
                
 
526
        
 
527
        if (err == NPERR_NO_ERROR)
 
528
        {
 
529
                //
 
530
                // Copy all the fields of Netscape's function table into our
 
531
                // copy so we can call back into Netscape later.  Note that
 
532
                // we need to copy the fields one by one, rather than assigning
 
533
                // the whole structure, because the Netscape function table
 
534
                // could actually be bigger than what we expect.
 
535
                //
 
536
                
 
537
                int navMinorVers = nsTable->version & 0xFF;
 
538
 
 
539
                gNetscapeFuncs.version = nsTable->version;
 
540
                gNetscapeFuncs.size = nsTable->size;
 
541
                gNetscapeFuncs.posturl = nsTable->posturl;
 
542
                gNetscapeFuncs.geturl = nsTable->geturl;
 
543
                gNetscapeFuncs.requestread = nsTable->requestread;
 
544
                gNetscapeFuncs.newstream = nsTable->newstream;
 
545
                gNetscapeFuncs.write = nsTable->write;
 
546
                gNetscapeFuncs.destroystream = nsTable->destroystream;
 
547
                gNetscapeFuncs.status = nsTable->status;
 
548
                gNetscapeFuncs.uagent = nsTable->uagent;
 
549
                gNetscapeFuncs.memalloc = nsTable->memalloc;
 
550
                gNetscapeFuncs.memfree = nsTable->memfree;
 
551
                gNetscapeFuncs.memflush = nsTable->memflush;
 
552
                gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
 
553
                if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
 
554
                {
 
555
                        gNetscapeFuncs.getJavaEnv = nsTable->getJavaEnv;
 
556
                        gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
 
557
                }
 
558
                if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
 
559
                {       
 
560
                        gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
 
561
                        gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
 
562
                }
 
563
                
 
564
                //
 
565
                // Set up the plugin function table that Netscape will use to
 
566
                // call us.  Netscape needs to know about our version and size
 
567
                // and have a UniversalProcPointer for every function we implement.
 
568
                //
 
569
                pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
 
570
                pluginFuncs->size = sizeof(NPPluginFuncs);
 
571
                pluginFuncs->newp = NewNPP_NewProc(Private_New);
 
572
                pluginFuncs->destroy = NewNPP_DestroyProc(Private_Destroy);
 
573
                pluginFuncs->setwindow = NewNPP_SetWindowProc(Private_SetWindow);
 
574
                pluginFuncs->newstream = NewNPP_NewStreamProc(Private_NewStream);
 
575
                pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
 
576
                pluginFuncs->asfile = NewNPP_StreamAsFileProc(Private_StreamAsFile);
 
577
                pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
 
578
                pluginFuncs->write = NewNPP_WriteProc(Private_Write);
 
579
                pluginFuncs->print = NewNPP_PrintProc(Private_Print);
 
580
                pluginFuncs->event = NewNPP_HandleEventProc(Private_HandleEvent);       
 
581
                if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
 
582
                {       
 
583
                        pluginFuncs->urlnotify = NewNPP_URLNotifyProc(Private_URLNotify);                       
 
584
                }
 
585
                if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
 
586
                {
 
587
                        pluginFuncs->javaClass  = (JRIGlobalRef) Private_GetJavaClass();
 
588
                }
 
589
                *unloadUpp = NewNPP_ShutdownProc(Private_Shutdown);
 
590
                SetUpQD();
 
591
                err = Private_Initialize();
 
592
        }
 
593
        
 
594
        ExitCodeResource();
 
595
        return err;
 
596
}