1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
23
* Pierre Phaneuf <pp@ludusdesign.com>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the NPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the NPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
////////////////////////////////////////////////////////////////////////////////
41
// This acts as a adapter layer to allow 5.0 plugins work with the 4.0/3.0
43
////////////////////////////////////////////////////////////////////////////////
45
////////////////////////////////////////////////////////////////////////////////
46
// SECTION 1 - Includes
47
////////////////////////////////////////////////////////////////////////////////
52
#include "nsIPluginManager.h"
53
#include "nsIServiceManager.h"
54
#include "nsIAllocator.h"
55
#include "nsLiveConnect.h"
59
////////////////////////////////////////////////////////////////////////////////
60
// SECTION 3 - Classes
61
////////////////////////////////////////////////////////////////////////////////
63
////////////////////////////////////////////////////////////////////////////////
67
// This is the dummy plugin manager that interacts with the 5.0 plugin.
69
class CPluginManager : public nsIPluginManager, public nsIServiceManager, public nsIAllocator {
71
// Need an operator new for this.
72
void* operator new(size_t size) { return ::NPN_MemAlloc(size); }
73
void operator delete(void* ptr) { ::NPN_MemFree(ptr); }
76
virtual ~CPluginManager(void);
80
////////////////////////////////////////////////////////////////////////////
81
// from nsIPluginManager:
83
// (Corresponds to NPN_GetValue.)
85
GetValue(nsPluginManagerVariable variable, void *value);
87
// (Corresponds to NPN_SetValue.)
89
SetValue(nsPluginManagerVariable variable, void *value);
92
ReloadPlugins(PRBool reloadPages);
94
// (Corresponds to NPN_UserAgent.)
96
UserAgent(const char* *result);
99
GetURL(nsISupports* pluginInst,
101
const char* target = NULL,
102
nsIPluginStreamListener* streamListener = NULL,
103
const char* altHost = NULL,
104
const char* referrer = NULL,
105
PRBool forceJSEnabled = PR_FALSE);
108
PostURL(nsISupports* pluginInst,
110
PRUint32 postDataLen,
111
const char* postData,
112
PRBool isFile = PR_FALSE,
113
const char* target = NULL,
114
nsIPluginStreamListener* streamListener = NULL,
115
const char* altHost = NULL,
116
const char* referrer = NULL,
117
PRBool forceJSEnabled = PR_FALSE,
118
PRUint32 postHeadersLength = 0,
119
const char* postHeaders = NULL);
122
RegisterPlugin(REFNSIID aCID,
123
const char* aPluginName,
124
const char* aDescription,
125
const char** aMimeTypes,
126
const char** aMimeDescriptions,
127
const char** aFileExtensions,
131
UnregisterPlugin(REFNSIID aCID);
135
* RegisterService may be called explicitly to register a service
136
* with the service manager. If a service is not registered explicitly,
137
* the component manager will be used to create an instance according
138
* to the class ID specified.
141
RegisterService(const nsCID& aClass, nsISupports* aService)
143
return NS_ERROR_NOT_IMPLEMENTED;
147
* Requests a service to be shut down, possibly unloading its DLL.
149
* @returns NS_OK - if shutdown was successful and service was unloaded,
150
* @returns NS_ERROR_SERVICE_NOT_FOUND - if shutdown failed because
151
* the service was not currently loaded
152
* @returns NS_ERROR_SERVICE_IN_USE - if shutdown failed because some
153
* user of the service wouldn't voluntarily release it by using
154
* a shutdown listener.
157
UnregisterService(const nsCID& aClass)
159
return NS_ERROR_NOT_IMPLEMENTED;
163
GetService(const nsCID& aClass, const nsIID& aIID,
164
nsISupports* *result,
165
nsIShutdownListener* shutdownListener = NULL);
168
ReleaseService(const nsCID& aClass, nsISupports* service,
169
nsIShutdownListener* shutdownListener = NULL);
172
GetService(const char* aContractID, const nsIID& aIID,
173
nsISupports* *result,
174
nsIShutdownListener* shutdownListener = NULL)
176
return NS_ERROR_NOT_IMPLEMENTED;
180
ReleaseService(const char* aContractID, nsISupports* service,
181
nsIShutdownListener* shutdownListener = NULL)
183
return NS_ERROR_NOT_IMPLEMENTED;
187
* Allocates a block of memory of a particular size.
189
* @param size - the size of the block to allocate
190
* @result the block of memory
193
Alloc(PRUint32 size);
196
* Reallocates a block of memory to a new size.
198
* @param ptr - the block of memory to reallocate
199
* @param size - the new size
200
* @result the rellocated block of memory
203
Realloc(void* ptr, PRUint32 size);
206
* Frees a block of memory.
208
* @param ptr - the block of memory to free
214
* Attempts to shrink the heap.
220
nsILiveconnect* mLiveconnect;
223
////////////////////////////////////////////////////////////////////////////////
225
// CPluginManagerStream
227
// This is the dummy plugin manager stream that interacts with the 5.0 plugin.
229
class CPluginManagerStream : public nsIOutputStream {
233
CPluginManagerStream(NPP npp, NPStream* pstr);
234
virtual ~CPluginManagerStream(void);
238
//////////////////////////////////////////////////////////////////////////
240
// Taken from nsIStream
243
/** Write data into the stream.
244
* @param aBuf the buffer into which the data is read
245
* @param aCount the maximum number of bytes to read
246
* @param errorResult the error code if an error occurs
247
* @return number of bytes read or -1 if error
250
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
256
//////////////////////////////////////////////////////////////////////////
258
// Specific methods to nsIPluginManagerStream.
261
// Corresponds to NPStream's url field.
263
GetURL(const char* *result);
265
// Corresponds to NPStream's end field.
267
GetEnd(PRUint32 *result);
269
// Corresponds to NPStream's lastmodfied field.
271
GetLastModified(PRUint32 *result);
273
// Corresponds to NPStream's notifyData field.
275
GetNotifyData(void* *result);
277
// Corresponds to NPStream's url field.
278
NS_IMETHOD Close(void);
283
// The plugin instance that the manager stream belongs to.
287
// The stream the class is using.
292
////////////////////////////////////////////////////////////////////////////////
294
// CPluginInstancePeer
296
// This is the dummy instance peer that interacts with the 5.0 plugin.
297
// In order to do LiveConnect, the class subclasses nsILiveConnectPluginInstancePeer.
299
class CPluginInstancePeer : public nsIPluginInstancePeer, public nsIPluginTagInfo {
303
// XXX - I add parameters to the constructor because I wasn't sure if
304
// XXX - the 4.0 browser had the npp_instance struct implemented.
305
// XXX - If so, then I can access npp_instance through npp->ndata.
306
CPluginInstancePeer(nsIPluginInstance* pluginInstance, NPP npp, nsMIMEType typeString, nsPluginMode type,
307
PRUint16 attribute_cnt, const char** attribute_list, const char** values_list);
309
virtual ~CPluginInstancePeer(void);
313
// (Corresponds to NPN_GetValue.)
315
GetValue(nsPluginInstancePeerVariable variable, void *value);
317
// (Corresponds to NPN_SetValue.)
319
SetValue(nsPluginInstancePeerVariable variable, void *value);
321
// Corresponds to NPP_New's MIMEType argument.
323
GetMIMEType(nsMIMEType *result);
325
// Corresponds to NPP_New's mode argument.
327
GetMode(nsPluginMode *result);
329
// Get a ptr to the paired list of attribute names and values,
330
// returns the length of the array.
332
// Each name or value is a null-terminated string.
334
GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values);
336
// Get the value for the named attribute. Returns null
337
// if the attribute was not set.
339
GetAttribute(const char* name, const char* *result);
341
// Corresponds to NPN_NewStream.
343
NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result);
345
// Corresponds to NPN_ShowStatus.
347
ShowStatus(const char* message);
350
SetWindowSize(PRUint32 width, PRUint32 height);
352
nsIPluginInstance* GetInstance(void) { return mInstance; }
353
NPP GetNPPInstance(void) { return npp; }
355
void SetWindow(NPWindow* window) { mWindow = window; }
356
NPWindow* GetWindow() { return mWindow; }
361
// XXX - The next five variables may need to be here since I
362
// XXX - don't think np_instance is available in 4.0X.
363
nsIPluginInstance* mInstance;
365
nsMIMEType typeString;
367
PRUint16 attribute_cnt;
368
char** attribute_list;
372
class CPluginStreamInfo : public nsIPluginStreamInfo {
376
CPluginStreamInfo(const char* URL, nsIPluginInputStream* inStr, nsMIMEType type, PRBool seekable)
377
: mURL(URL), mInputStream(inStr), mMimeType(type), mIsSeekable(seekable) {}
379
virtual ~CPluginStreamInfo() {}
382
GetContentType(nsMIMEType* result)
389
IsSeekable(PRBool* result)
391
*result = mIsSeekable;
396
GetLength(PRUint32* result)
398
return mInputStream->GetLength(result);
402
GetLastModified(PRUint32* result)
404
return mInputStream->GetLastModified(result);
408
GetURL(const char** result)
415
RequestRead(nsByteRange* rangeList)
417
return mInputStream->RequestRead(rangeList);
422
nsIPluginInputStream* mInputStream;
423
nsMIMEType mMimeType;
427
class CPluginInputStream : public nsIPluginInputStream {
432
NS_DECL_NSIINPUTSTREAM
434
////////////////////////////////////////////////////////////////////////////
435
// from nsIPluginInputStream:
437
// (Corresponds to NPStream's lastmodified field.)
439
GetLastModified(PRUint32 *result);
442
RequestRead(nsByteRange* rangeList);
444
////////////////////////////////////////////////////////////////////////////
445
// CPluginInputStream specific methods:
447
CPluginInputStream(nsIPluginStreamListener* listener);
448
virtual ~CPluginInputStream(void);
450
void SetStreamInfo(NPP npp, NPStream* stream) {
455
nsIPluginStreamListener* GetListener(void) { return mListener; }
456
nsPluginStreamType GetStreamType(void) { return mStreamType; }
458
nsresult SetReadBuffer(PRUint32 len, const char* buffer) {
459
// XXX this has to be way more sophisticated
460
mBuffer = dup(len, buffer);
466
char* dup(PRUint32 len, const char* buffer) {
467
char* result = new char[len];
468
if (result != NULL) {
469
const char *src = buffer;
477
nsIPluginStreamInfo* CreatePluginStreamInfo(const char* url, nsMIMEType type, PRBool seekable) {
478
if (mStreamInfo == NULL) {
479
mStreamInfo = new CPluginStreamInfo(url, this, type, seekable);
480
mStreamInfo->AddRef();
485
nsIPluginStreamInfo* GetPluginStreamInfo() {
491
nsIPluginStreamListener* mListener;
492
nsPluginStreamType mStreamType;
496
PRUint32 mBufferLength;
497
PRUint32 mAmountRead;
498
nsIPluginStreamInfo* mStreamInfo;
501
//////////////////////////////////////////////////////////////////////////////
504
#define TRACE(foo) trace(foo)
512
#if defined(__cplusplus)
516
////////////////////////////////////////////////////////////////////////////////
517
// SECTION 1 - Includes
518
////////////////////////////////////////////////////////////////////////////////
520
#if defined(XP_UNIX) || defined(XP_MAC)
528
////////////////////////////////////////////////////////////////////////////////
529
// SECTION 2 - Global Variables
530
////////////////////////////////////////////////////////////////////////////////
533
// thePlugin and thePluginManager are used in the life of the plugin.
535
// These two will be created on NPP_Initialize and destroyed on NPP_Shutdown.
537
nsIPluginManager* thePluginManager = NULL;
538
nsIPlugin* thePlugin = NULL;
543
// Interface IDs for nsISupports
545
NS_DEFINE_IID(kPluginCID, NS_PLUGIN_CID);
546
static NS_DEFINE_IID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
547
static NS_DEFINE_IID(kAllocatorCID, NS_ALLOCATOR_CID);
549
// mapping from NPError to nsresult
550
nsresult fromNPError[] = {
551
NS_OK, // NPERR_NO_ERROR,
552
NS_ERROR_FAILURE, // NPERR_GENERIC_ERROR,
553
NS_ERROR_FAILURE, // NPERR_INVALID_INSTANCE_ERROR,
554
NS_ERROR_NOT_INITIALIZED, // NPERR_INVALID_FUNCTABLE_ERROR,
555
NS_ERROR_FACTORY_NOT_LOADED, // NPERR_MODULE_LOAD_FAILED_ERROR,
556
NS_ERROR_OUT_OF_MEMORY, // NPERR_OUT_OF_MEMORY_ERROR,
557
NS_NOINTERFACE, // NPERR_INVALID_PLUGIN_ERROR,
558
NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PLUGIN_DIR_ERROR,
559
NS_NOINTERFACE, // NPERR_INCOMPATIBLE_VERSION_ERROR,
560
NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_PARAM,
561
NS_ERROR_ILLEGAL_VALUE, // NPERR_INVALID_URL,
562
NS_ERROR_ILLEGAL_VALUE, // NPERR_FILE_NOT_FOUND,
563
NS_ERROR_FAILURE, // NPERR_NO_DATA,
564
NS_ERROR_FAILURE // NPERR_STREAM_NOT_SEEKABLE,
567
////////////////////////////////////////////////////////////////////////////////
568
// SECTION 4 - API Shim Plugin Implementations
569
// Glue code to the 5.0x Plugin.
571
// Most of the NPP_* functions that interact with the plug-in will need to get
572
// the instance peer from npp->pdata so it can get the plugin instance from the
573
// peer. Once the plugin instance is available, the appropriate 5.0 plug-in
574
// function can be called:
576
// CPluginInstancePeer* peer = (CPluginInstancePeer* )instance->pdata;
577
// nsIPluginInstance* inst = peer->GetUserInstance();
578
// inst->NewPluginAPIFunction();
580
// Similar steps takes place with streams. The stream peer is stored in NPStream's
581
// pdata. Get the peer, get the stream, call the function.
584
////////////////////////////////////////////////////////////////////////////////
585
// UNIX-only API calls
586
////////////////////////////////////////////////////////////////////////////////
589
char* NPP_GetMIMEDescription(void)
592
//fprintf(stderr, "MIME description\n");
593
if (thePlugin == NULL) {
595
NSGetFactory(thePluginManager, kPluginCID, NULL, NULL, (nsIFactory** )&thePlugin);
597
//fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin);
599
nsresult err = thePlugin->GetMIMEDescription(&ret);
600
if (err) return NULL;
601
//fprintf(stderr, "Get response %s\n", ret);
603
//fprintf(stderr, "Freeing plugin...");
604
thePlugin->Release();
607
//fprintf(stderr, "Done\n");
612
//------------------------------------------------------------------------------
613
// Cross-Platform Plug-in API Calls
614
//------------------------------------------------------------------------------
616
//+++++++++++++++++++++++++++++++++++++++++++++++++
618
//+++++++++++++++++++++++++++++++++++++++++++++++++
621
NPP_SetValue(NPP instance, NPNVariable variable, void *value)
623
return NPERR_GENERIC_ERROR; // nothing to set
626
//+++++++++++++++++++++++++++++++++++++++++++++++++
628
//+++++++++++++++++++++++++++++++++++++++++++++++++
631
NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
633
//fprintf(stderr, "MIME description\n");
634
if (thePlugin == NULL) {
636
if (NSGetFactory(thePluginManager, kPluginCID, NULL, NULL, (nsIFactory** )&thePlugin) != NS_OK)
637
return NPERR_GENERIC_ERROR;
639
//fprintf(stderr, "Allocated Plugin 0x%08x\n", thePlugin);
640
nsresult err = thePlugin->GetValue((nsPluginVariable)variable, value);
641
if (err) return NPERR_GENERIC_ERROR;
642
//fprintf(stderr, "Get response %08x\n", ret);
644
//fprintf(stderr, "Freeing plugin...");
645
thePlugin->Release();
648
//fprintf(stderr, "Done\n");
649
return NPERR_NO_ERROR;
653
//+++++++++++++++++++++++++++++++++++++++++++++++++
655
// Provides global initialization for a plug-in, and returns an error value.
657
// This function is called once when a plug-in is loaded, before the first instance
658
// is created. thePluginManager and thePlugin are both initialized.
659
//+++++++++++++++++++++++++++++++++++++++++++++++++
664
// TRACE("NPP_Initialize\n");
666
// Only call initialize the plugin if it hasn't been created.
667
// This could happen if GetJavaClass() is called before
669
if (thePluginManager == NULL) {
670
// Create the plugin manager and plugin classes.
671
thePluginManager = new CPluginManager();
672
if ( thePluginManager == NULL )
673
return NPERR_OUT_OF_MEMORY_ERROR;
674
thePluginManager->AddRef();
676
nsresult error = NS_OK;
677
// On UNIX the plugin might have been created when calling NPP_GetMIMEType.
678
if (thePlugin == NULL) {
679
// create nsIPlugin factory
680
error = (NPError)NSGetFactory(thePluginManager, kPluginCID, NULL, NULL, (nsIFactory** )&thePlugin);
682
// beard: this will leak reference counts.
683
if (error == NS_OK) {
689
return (NPError) error;
692
//+++++++++++++++++++++++++++++++++++++++++++++++++
694
// New in Netscape Navigator 3.0.
696
// NPP_GetJavaClass is called during initialization to ask your plugin
697
// what its associated Java class is. If you don't have one, just return
698
// NULL. Otherwise, use the javah-generated "use_" function to both
699
// initialize your class and return it. If you can't find your class, an
700
// error will be signalled by "use_" and will cause the Navigator to
701
// complain to the user.
702
//+++++++++++++++++++++++++++++++++++++++++++++++++
705
NPP_GetJavaClass(void)
707
// Only call initialize the plugin if it hasn't been `d.
709
if (thePluginManager == NULL) {
710
// Create the plugin manager and plugin objects.
711
NPError result = CPluginManager::Create();
712
if (result) return NULL;
713
assert( thePluginManager != NULL );
714
thePluginManager->AddRef();
715
NP_CreatePlugin(thePluginManager, (nsIPlugin** )(&thePlugin));
716
assert( thePlugin != NULL );
718
return thePlugin->GetJavaClass();
723
//+++++++++++++++++++++++++++++++++++++++++++++++++
725
// Provides global deinitialization for a plug-in.
727
// This function is called once after the last instance of your plug-in
728
// is destroyed. thePluginManager and thePlugin are delete at this time.
729
//+++++++++++++++++++++++++++++++++++++++++++++++++
734
// TRACE("NPP_Shutdown\n");
738
thePlugin->Shutdown();
739
thePlugin->Release();
743
if (thePluginManager) {
744
thePluginManager->Release();
745
thePluginManager = NULL;
751
//+++++++++++++++++++++++++++++++++++++++++++++++++
753
// Creates a new instance of a plug-in and returns an error value.
755
// A plugin instance peer and instance peer is created. After
756
// a successful instansiation, the peer is stored in the plugin
758
//+++++++++++++++++++++++++++++++++++++++++++++++++
761
NPP_New(NPMIMEType pluginType,
769
// TRACE("NPP_New\n");
771
if (instance == NULL)
772
return NPERR_INVALID_INSTANCE_ERROR;
774
// Create a new plugin instance and start it.
775
nsIPluginInstance* pluginInstance = NULL;
776
thePlugin->CreatePluginInstance(thePluginManager, NS_GET_IID(nsIPluginInstance), pluginType, (void**)&pluginInstance);
777
if (pluginInstance == NULL) {
778
return NPERR_OUT_OF_MEMORY_ERROR;
781
// Create a new plugin instance peer,
782
// XXX - Since np_instance is not implemented in the 4.0x browser, I
783
// XXX - had to save the plugin parameter in the peer class.
784
// XXX - Ask Warren about np_instance.
785
CPluginInstancePeer* peer = new CPluginInstancePeer(pluginInstance, instance, (nsMIMEType)pluginType,
786
(nsPluginMode)mode, (PRUint16)argc, (const char** )argn, (const char** )argv);
787
assert( peer != NULL );
788
if (!peer) return NPERR_OUT_OF_MEMORY_ERROR;
790
pluginInstance->Initialize(peer);
791
pluginInstance->Start();
792
// Set the user instance and store the peer in npp->pdata.
793
instance->pdata = peer;
796
return NPERR_NO_ERROR;
799
//+++++++++++++++++++++++++++++++++++++++++++++++++
801
// Deletes a specific instance of a plug-in and returns an error value.
803
// The plugin instance peer and plugin instance are destroyed.
804
// The instance's pdata is set to NULL.
805
//+++++++++++++++++++++++++++++++++++++++++++++++++
808
NPP_Destroy(NPP instance, NPSavedData** save)
810
// TRACE("NPP_Destroy\n");
812
if (instance == NULL)
813
return NPERR_INVALID_INSTANCE_ERROR;
815
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
816
nsIPluginInstance* pluginInstance = peer->GetInstance();
817
pluginInstance->Stop();
818
pluginInstance->Destroy();
819
pluginInstance->Release();
821
instance->pdata = NULL;
823
return NPERR_NO_ERROR;
826
//+++++++++++++++++++++++++++++++++++++++++++++++++
828
// Sets the window in which a plug-in draws, and returns an error value.
829
//+++++++++++++++++++++++++++++++++++++++++++++++++
832
NPP_SetWindow(NPP instance, NPWindow* window)
834
// TRACE("NPP_SetWindow\n");
836
if (instance == NULL)
837
return NPERR_INVALID_INSTANCE_ERROR;
839
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
841
return NPERR_INVALID_PLUGIN_ERROR;
843
// record the window in the peer, so we can deliver proper events.
844
peer->SetWindow(window);
846
nsIPluginInstance* pluginInstance = peer->GetInstance();
847
if( pluginInstance == 0 )
848
return NPERR_INVALID_PLUGIN_ERROR;
850
return (NPError)pluginInstance->SetWindow((nsPluginWindow* ) window );
853
//+++++++++++++++++++++++++++++++++++++++++++++++++
855
// Notifies an instance of a new data stream and returns an error value.
857
// Create a stream peer and stream. If succesful, save
858
// the stream peer in NPStream's pdata.
859
//+++++++++++++++++++++++++++++++++++++++++++++++++
862
NPP_NewStream(NPP instance,
868
// XXX - How do you set the fields of the peer stream and stream?
869
// XXX - Looks like these field will have to be created since
870
// XXX - We are not using np_stream.
872
// TRACE("NPP_NewStream\n");
874
if (instance == NULL)
875
return NPERR_INVALID_INSTANCE_ERROR;
877
CPluginInputStream* inStr = (CPluginInputStream*)stream->notifyData;
879
return NPERR_GENERIC_ERROR;
881
nsIPluginStreamInfo* info = inStr->CreatePluginStreamInfo(stream->url, type, seekable);
882
nsresult err = inStr->GetListener()->OnStartBinding(info);
885
inStr->SetStreamInfo(instance, stream);
886
stream->pdata = inStr;
887
*stype = inStr->GetStreamType();
889
return NPERR_NO_ERROR;
892
//+++++++++++++++++++++++++++++++++++++++++++++++++
894
// Returns the maximum number of bytes that an instance is prepared to accept
896
//+++++++++++++++++++++++++++++++++++++++++++++++++
899
NPP_WriteReady(NPP instance, NPStream *stream)
901
// TRACE("NPP_WriteReady\n");
903
if (instance == NULL)
906
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
913
//+++++++++++++++++++++++++++++++++++++++++++++++++
915
// Delivers data from a stream and returns the number of bytes written.
916
//+++++++++++++++++++++++++++++++++++++++++++++++++
919
NPP_Write(NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
921
// TRACE("NPP_Write\n");
923
if (instance == NULL)
926
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
929
nsresult err = inStr->SetReadBuffer((PRUint32)len, (const char*)buffer);
930
if (err != NS_OK) return -1;
931
err = inStr->GetListener()->OnDataAvailable(inStr->GetPluginStreamInfo(), inStr, len);
932
if (err != NS_OK) return -1;
936
//+++++++++++++++++++++++++++++++++++++++++++++++++
937
// NPP_DestroyStream:
938
// Indicates the closure and deletion of a stream, and returns an error value.
940
// The stream peer and stream are destroyed. NPStream's
941
// pdata is set to NULL.
942
//+++++++++++++++++++++++++++++++++++++++++++++++++
945
NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
947
// TRACE("NPP_DestroyStream\n");
949
if (instance == NULL)
950
return NPERR_INVALID_INSTANCE_ERROR;
952
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
954
return NPERR_GENERIC_ERROR;
955
inStr->GetListener()->OnStopBinding(inStr->GetPluginStreamInfo(), (nsPluginReason)reason);
957
stream->pdata = NULL;
959
return NPERR_NO_ERROR;
962
//+++++++++++++++++++++++++++++++++++++++++++++++++
964
// Provides a local file name for the data from a stream.
965
//+++++++++++++++++++++++++++++++++++++++++++++++++
968
NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
970
// TRACE("NPP_StreamAsFile\n");
972
if (instance == NULL)
975
CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
978
(void)inStr->GetListener()->OnFileAvailable(inStr->GetPluginStreamInfo(), fname);
981
//+++++++++++++++++++++++++++++++++++++++++++++++++
983
//+++++++++++++++++++++++++++++++++++++++++++++++++
986
NPP_Print(NPP instance, NPPrint* printInfo)
988
// TRACE("NPP_Print\n");
990
if(printInfo == NULL) // trap invalid parm
993
if (instance != NULL)
995
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
996
nsIPluginInstance* pluginInstance = peer->GetInstance();
997
pluginInstance->Print((nsPluginPrint* ) printInfo );
1001
//+++++++++++++++++++++++++++++++++++++++++++++++++
1003
// Notifies the instance of the completion of a URL request.
1004
//+++++++++++++++++++++++++++++++++++++++++++++++++
1007
NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
1009
// TRACE("NPP_URLNotify\n");
1011
if (instance != NULL) {
1012
CPluginInputStream* inStr = (CPluginInputStream*)notifyData;
1013
(void)inStr->GetListener()->OnStopBinding(inStr->GetPluginStreamInfo(), (nsPluginReason)reason);
1018
//+++++++++++++++++++++++++++++++++++++++++++++++++
1020
// Mac-only, but stub must be present for Windows
1021
// Delivers a platform-specific event to the instance.
1022
//+++++++++++++++++++++++++++++++++++++++++++++++++
1026
NPP_HandleEvent(NPP instance, void* event)
1028
// TRACE("NPP_HandleEvent\n");
1029
int16 eventHandled = FALSE;
1030
if (instance == NULL)
1031
return eventHandled;
1033
NPEvent* npEvent = (NPEvent*) event;
1034
nsPluginEvent pluginEvent = {
1038
npEvent->event, npEvent->wParam, npEvent->lParam
1042
CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
1043
nsIPluginInstance* pluginInstance = peer->GetInstance();
1044
if (pluginInstance) {
1046
nsresult err = pluginInstance->HandleEvent(&pluginEvent, &handled);
1047
if (err) return FALSE;
1048
eventHandled = (handled == PR_TRUE);
1051
return eventHandled;
1053
#endif // ndef XP_UNIX
1055
//////////////////////////////////////////////////////////////////////////////
1056
// SECTION 5 - API Browser Implementations
1058
// Glue code to the 4.0x Browser.
1059
//////////////////////////////////////////////////////////////////////////////
1061
//////////////////////////////////////////////////////////////////////////////
1066
//******************************************************************************
1068
// Once we moved to the new APIs, we need to implement fJVMMgr.
1070
//******************************************************************************
1072
CPluginManager::CPluginManager(void)
1074
mLiveconnect = NULL;
1077
CPluginManager::~CPluginManager(void)
1079
NS_IF_RELEASE(mLiveconnect);
1082
//+++++++++++++++++++++++++++++++++++++++++++++++++
1084
//+++++++++++++++++++++++++++++++++++++++++++++++++
1087
CPluginManager::ReloadPlugins(PRBool reloadPages)
1089
NPN_ReloadPlugins(reloadPages);
1094
CPluginManager::GetURL(nsISupports* pluginInst,
1097
nsIPluginStreamListener* streamListener,
1098
const char* altHost,
1099
const char* referrer,
1100
PRBool forceJSEnabled)
1102
if (altHost != NULL || referrer != NULL || forceJSEnabled != PR_FALSE) {
1103
return NPERR_INVALID_PARAM;
1106
nsIPluginInstance* inst = NULL;
1107
nsresult rslt = pluginInst->QueryInterface(NS_GET_IID(nsIPluginInstance), (void**)&inst);
1108
if (rslt != NS_OK) return rslt;
1109
CPluginInstancePeer* instancePeer = NULL;
1110
rslt = inst->GetPeer((nsIPluginInstancePeer**)&instancePeer);
1111
if (rslt != NS_OK) {
1115
NPP npp = instancePeer->GetNPPInstance();
1118
if (streamListener) {
1119
CPluginInputStream* inStr = new CPluginInputStream(streamListener);
1120
if (inStr == NULL) {
1121
instancePeer->Release();
1123
return NS_ERROR_OUT_OF_MEMORY;
1127
err = NPN_GetURLNotify(npp, url, target, inStr);
1130
err = NPN_GetURL(npp, url, target);
1132
instancePeer->Release();
1134
return fromNPError[err];
1138
CPluginManager::PostURL(nsISupports* pluginInst,
1140
PRUint32 postDataLen,
1141
const char* postData,
1144
nsIPluginStreamListener* streamListener,
1145
const char* altHost,
1146
const char* referrer,
1147
PRBool forceJSEnabled,
1148
PRUint32 postHeadersLength,
1149
const char* postHeaders)
1151
if (altHost != NULL || referrer != NULL || forceJSEnabled != PR_FALSE
1152
|| postHeadersLength != 0 || postHeaders != NULL) {
1153
return NPERR_INVALID_PARAM;
1156
nsIPluginInstance* inst = NULL;
1157
nsresult rslt = pluginInst->QueryInterface(NS_GET_IID(nsIPluginInstance), (void**)&inst);
1158
if (rslt != NS_OK) return rslt;
1159
CPluginInstancePeer* instancePeer = NULL;
1160
rslt = inst->GetPeer((nsIPluginInstancePeer**)&instancePeer);
1161
if (rslt != NS_OK) {
1165
NPP npp = instancePeer->GetNPPInstance();
1168
if (streamListener) {
1169
CPluginInputStream* inStr = new CPluginInputStream(streamListener);
1170
if (inStr == NULL) {
1171
instancePeer->Release();
1173
return NS_ERROR_OUT_OF_MEMORY;
1177
err = NPN_PostURLNotify(npp, url, target, postDataLen, postData, isFile, inStr);
1180
err = NPN_PostURL(npp, url, target, postDataLen, postData, isFile);
1182
instancePeer->Release();
1184
return fromNPError[err];
1189
CPluginManager::RegisterPlugin(REFNSIID aCID,
1190
const char* aPluginName,
1191
const char* aDescription,
1192
const char** aMimeTypes,
1193
const char** aMimeDescriptions,
1194
const char** aFileExtensions,
1197
// XXXwaterson I don't think we need to do anything here.
1203
CPluginManager::UnregisterPlugin(REFNSIID aCID)
1205
// XXXwaterson I don't think we need to do anything here.
1210
CPluginManager::GetService(const nsCID& aClass, const nsIID& aIID,
1211
nsISupports* *result,
1212
nsIShutdownListener* shutdownListener)
1214
// the only service we support currently is nsIAllocator.
1215
if (aClass.Equals(kPluginManagerCID) || aClass.Equals(kAllocatorCID)) {
1216
return QueryInterface(aIID, (void**) result);
1218
if (aClass.Equals(nsILiveconnect::GetCID())) {
1219
if (mLiveconnect == NULL) {
1220
mLiveconnect = new nsLiveconnect;
1221
NS_IF_ADDREF(mLiveconnect);
1223
return mLiveconnect->QueryInterface(aIID, result);
1225
return NS_ERROR_SERVICE_NOT_FOUND;
1229
CPluginManager::ReleaseService(const nsCID& aClass, nsISupports* service,
1230
nsIShutdownListener* shutdownListener)
1232
NS_RELEASE(service);
1237
CPluginManager::Alloc(PRUint32 size)
1239
return ::NPN_MemAlloc(size);
1243
CPluginManager::Realloc(void* ptr, PRUint32 size)
1246
void* new_ptr = Alloc(size);
1247
if (new_ptr != NULL) {
1248
::memcpy(new_ptr, ptr, size);
1257
CPluginManager::Free(void* ptr)
1263
return NS_ERROR_NULL_POINTER;
1267
CPluginManager::HeapMinimize()
1270
::NPN_MemFlush(1024);
1275
//+++++++++++++++++++++++++++++++++++++++++++++++++
1277
//+++++++++++++++++++++++++++++++++++++++++++++++++
1280
CPluginManager::UserAgent(const char* *result)
1282
*result = NPN_UserAgent(NULL);
1288
(int)NPNVxDisplay, // nsPluginManagerVariable_XDisplay = 1,
1289
(int)NPNVxtAppContext, // nsPluginManagerVariable_XtAppContext,
1290
(int)NPNVnetscapeWindow, // nsPluginManagerVariable_NetscapeWindow,
1291
(int)NPPVpluginWindowBool, // nsPluginInstancePeerVariable_WindowBool,
1292
(int)NPPVpluginTransparentBool, // nsPluginInstancePeerVariable_TransparentBool,
1293
(int)NPPVjavaClass, // nsPluginInstancePeerVariable_JavaClass,
1294
(int)NPPVpluginWindowSize, // nsPluginInstancePeerVariable_WindowSize,
1295
(int)NPPVpluginTimerInterval, // nsPluginInstancePeerVariable_TimerInterval
1298
//+++++++++++++++++++++++++++++++++++++++++++++++++
1300
//+++++++++++++++++++++++++++++++++++++++++++++++++
1303
CPluginManager::GetValue(nsPluginManagerVariable variable, void *value)
1306
return fromNPError[NPN_GetValue(NULL, (NPNVariable)varMap[(int)variable], value)];
1308
return fromNPError[NPERR_GENERIC_ERROR];
1312
//+++++++++++++++++++++++++++++++++++++++++++++++++
1314
//+++++++++++++++++++++++++++++++++++++++++++++++++
1317
CPluginManager::SetValue(nsPluginManagerVariable variable, void *value)
1320
return fromNPError[NPN_SetValue(NULL, (NPPVariable)varMap[(int)variable], value)];
1322
return fromNPError[NPERR_GENERIC_ERROR];
1326
//+++++++++++++++++++++++++++++++++++++++++++++++++
1327
// nsISupports functions
1328
//+++++++++++++++++++++++++++++++++++++++++++++++++
1330
NS_IMPL_ADDREF(CPluginManager)
1331
NS_IMPL_RELEASE(CPluginManager)
1334
CPluginManager::QueryInterface(const nsIID& iid, void** ptr)
1337
return NS_ERROR_NULL_POINTER;
1340
if (iid.Equals(NS_GET_IID(nsIServiceManager))) {
1341
*ptr = (void*) (nsIServiceManager*)this;
1345
if (iid.Equals(NS_GET_IID(nsIAllocator))) {
1346
*ptr = (void*) (nsIAllocator*)this;
1350
if (iid.Equals(NS_GET_IID(nsIPluginManager)) || iid.Equals(NS_GET_IID(nsISupports))) {
1351
*ptr = (void*) ((nsIPluginManager*)this);
1355
return NS_NOINTERFACE;
1358
//////////////////////////////////////////////////////////////////////////////
1360
// CPluginInstancePeer
1363
CPluginInstancePeer::CPluginInstancePeer(nsIPluginInstance* pluginInstance,
1365
nsMIMEType typeString,
1368
const char** attr_list,
1369
const char** val_list)
1370
: mInstance(pluginInstance), mWindow(NULL),
1371
npp(npp), typeString(typeString), type(type), attribute_cnt(attr_cnt),
1372
attribute_list(NULL), values_list(NULL)
1374
NS_IF_ADDREF(mInstance);
1376
attribute_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
1377
values_list = (char**) NPN_MemAlloc(attr_cnt * sizeof(const char*));
1379
if (attribute_list != NULL && values_list != NULL) {
1380
for (int i = 0; i < attribute_cnt; i++) {
1381
attribute_list[i] = (char*) NPN_MemAlloc(strlen(attr_list[i]) + 1);
1382
if (attribute_list[i] != NULL)
1383
strcpy(attribute_list[i], attr_list[i]);
1385
values_list[i] = (char*) NPN_MemAlloc(strlen(val_list[i]) + 1);
1386
if (values_list[i] != NULL)
1387
strcpy(values_list[i], val_list[i]);
1392
CPluginInstancePeer::~CPluginInstancePeer(void)
1394
if (attribute_list != NULL && values_list != NULL) {
1395
for (int i = 0; i < attribute_cnt; i++) {
1396
NPN_MemFree(attribute_list[i]);
1397
NPN_MemFree(values_list[i]);
1400
NPN_MemFree(attribute_list);
1401
NPN_MemFree(values_list);
1404
NS_IF_RELEASE(mInstance);
1408
//+++++++++++++++++++++++++++++++++++++++++++++++++
1410
//+++++++++++++++++++++++++++++++++++++++++++++++++
1413
CPluginInstancePeer::GetValue(nsPluginInstancePeerVariable variable, void *value)
1416
return fromNPError[NPN_GetValue(NULL, (NPNVariable)varMap[(int)variable], value)];
1418
return fromNPError[NPERR_GENERIC_ERROR];
1422
//+++++++++++++++++++++++++++++++++++++++++++++++++
1424
//+++++++++++++++++++++++++++++++++++++++++++++++++
1427
CPluginInstancePeer::SetValue(nsPluginInstancePeerVariable variable, void *value)
1430
return fromNPError[NPN_SetValue(NULL, (NPPVariable)varMap[(int)variable], value)];
1432
return fromNPError[NPERR_GENERIC_ERROR];
1436
//+++++++++++++++++++++++++++++++++++++++++++++++++
1438
// Corresponds to NPP_New's MIMEType argument.
1439
//+++++++++++++++++++++++++++++++++++++++++++++++++
1442
CPluginInstancePeer::GetMIMEType(nsMIMEType *result)
1444
*result = typeString;
1448
//+++++++++++++++++++++++++++++++++++++++++++++++++
1450
// Corresponds to NPP_New's mode argument.
1451
//+++++++++++++++++++++++++++++++++++++++++++++++++
1454
CPluginInstancePeer::GetMode(nsPluginMode *result)
1461
// Get a ptr to the paired list of attribute names and values,
1462
// returns the length of the array.
1464
// Each name or value is a null-terminated string.
1466
CPluginInstancePeer::GetAttributes(PRUint16& n, const char* const*& names, const char* const*& values)
1469
names = attribute_list;
1470
values = values_list;
1477
inline unsigned char toupper(unsigned char c)
1479
return (c >= 'a' && c <= 'z') ? (c - ('a' - 'A')) : c;
1482
static int strcasecmp(const char * str1, const char * str2)
1486
const unsigned char * p1 = (unsigned char *) str1 - 1;
1487
const unsigned char * p2 = (unsigned char *) str2 - 1;
1488
unsigned long c1, c2;
1490
while (toupper(c1 = *++p1) == toupper(c2 = *++p2))
1496
const unsigned char * p1 = (unsigned char *) str1;
1497
const unsigned char * p2 = (unsigned char *) str2;
1498
unsigned char c1, c2;
1500
while (toupper(c1 = *p1++) == toupper(c2 = *p2++))
1506
return(toupper(c1) - toupper(c2));
1511
// Get the value for the named attribute. Returns null
1512
// if the attribute was not set.
1514
CPluginInstancePeer::GetAttribute(const char* name, const char* *result)
1516
for (int i=0; i < attribute_cnt; i++) {
1517
#if defined(XP_UNIX) || defined(XP_MAC)
1518
if (strcasecmp(name, attribute_list[i]) == 0)
1520
if (stricmp(name, attribute_list[i]) == 0)
1523
*result = values_list[i];
1528
return NS_ERROR_FAILURE;
1531
//+++++++++++++++++++++++++++++++++++++++++++++++++
1533
//+++++++++++++++++++++++++++++++++++++++++++++++++
1535
CPluginInstancePeer::NewStream(nsMIMEType type, const char* target,
1536
nsIOutputStream* *result)
1538
assert( npp != NULL );
1540
// Create a new NPStream.
1541
NPStream* stream = NULL;
1542
NPError error = NPN_NewStream(npp, (NPMIMEType)type, target, &stream);
1543
if (error != NPERR_NO_ERROR)
1544
return fromNPError[error];
1546
// Create a new Plugin Manager Stream.
1547
// XXX - Do we have to Release() the manager stream before doing this?
1548
// XXX - See the BAM doc for more info.
1549
CPluginManagerStream* mstream = new CPluginManagerStream(npp, stream);
1550
if (mstream == NULL)
1551
return NS_ERROR_OUT_OF_MEMORY;
1553
*result = (nsIOutputStream* )mstream;
1558
//+++++++++++++++++++++++++++++++++++++++++++++++++
1560
//+++++++++++++++++++++++++++++++++++++++++++++++++
1563
CPluginInstancePeer::ShowStatus(const char* message)
1565
assert( message != NULL );
1567
NPN_Status(npp, message);
1572
CPluginInstancePeer::SetWindowSize(PRUint32 width, PRUint32 height)
1577
size.height = height;
1578
err = NPN_SetValue(npp, NPPVpluginWindowSize, &size);
1579
return fromNPError[err];
1582
//+++++++++++++++++++++++++++++++++++++++++++++++++
1583
// nsISupports functions
1584
//+++++++++++++++++++++++++++++++++++++++++++++++++
1586
NS_IMPL_ADDREF(CPluginInstancePeer)
1587
NS_IMPL_RELEASE(CPluginInstancePeer)
1590
CPluginInstancePeer::QueryInterface(const nsIID& iid, void** ptr)
1593
return NS_ERROR_NULL_POINTER;
1596
if (iid.Equals(NS_GET_IID(nsIPluginInstancePeer))) {
1597
*ptr = (void*) this;
1601
if (iid.Equals(NS_GET_IID(nsIPluginTagInfo)) || iid.Equals(NS_GET_IID(nsISupports))) {
1602
*ptr = (void*) ((nsIPluginTagInfo*)this);
1606
return NS_NOINTERFACE;
1609
//////////////////////////////////////////////////////////////////////////////
1611
// CPluginManagerStream
1614
CPluginManagerStream::CPluginManagerStream(NPP npp, NPStream* pstr)
1615
: npp(npp), pstream(pstr)
1619
CPluginManagerStream::~CPluginManagerStream(void)
1622
NPN_DestroyStream(npp, pstream, NPRES_DONE);
1626
//+++++++++++++++++++++++++++++++++++++++++++++++++
1628
//+++++++++++++++++++++++++++++++++++++++++++++++++
1631
CPluginManagerStream::Write(const char* buffer, PRUint32 len, PRUint32 *aWriteCount)
1633
assert( npp != NULL );
1634
assert( pstream != NULL );
1636
*aWriteCount = NPN_Write(npp, pstream, len, (void* )buffer);
1637
return *aWriteCount >= 0 ? NS_OK : NS_ERROR_FAILURE;
1640
//+++++++++++++++++++++++++++++++++++++++++++++++++
1642
//+++++++++++++++++++++++++++++++++++++++++++++++++
1645
CPluginManagerStream::GetURL(const char* *result)
1647
assert( pstream != NULL );
1649
*result = pstream->url;
1653
//+++++++++++++++++++++++++++++++++++++++++++++++++
1655
//+++++++++++++++++++++++++++++++++++++++++++++++++
1658
CPluginManagerStream::GetEnd(PRUint32 *result)
1660
assert( pstream != NULL );
1662
*result = pstream->end;
1666
//+++++++++++++++++++++++++++++++++++++++++++++++++
1668
//+++++++++++++++++++++++++++++++++++++++++++++++++
1671
CPluginManagerStream::GetLastModified(PRUint32 *result)
1673
assert( pstream != NULL );
1675
*result = pstream->lastmodified;
1679
//+++++++++++++++++++++++++++++++++++++++++++++++++
1681
//+++++++++++++++++++++++++++++++++++++++++++++++++
1684
CPluginManagerStream::GetNotifyData(void* *result)
1686
assert( pstream != NULL );
1688
*result = pstream->notifyData;
1692
//+++++++++++++++++++++++++++++++++++++++++++++++++
1694
//+++++++++++++++++++++++++++++++++++++++++++++++++
1697
CPluginManagerStream::Close(void)
1699
assert( pstream != NULL );
1705
//+++++++++++++++++++++++++++++++++++++++++++++++++
1706
// nsISupports functions
1707
//+++++++++++++++++++++++++++++++++++++++++++++++++
1709
NS_IMPL_ISUPPORTS1(CPluginManagerStream, nsIOutputStream)
1711
//////////////////////////////////////////////////////////////////////////////
1713
NS_IMPL_ISUPPORTS1(CPluginStreamInfo, nsIPluginStreamInfo)
1715
CPluginInputStream::CPluginInputStream(nsIPluginStreamListener* listener)
1716
: mListener(listener), mStreamType(nsPluginStreamType_Normal),
1717
mNPP(NULL), mStream(NULL),
1718
mBuffer(NULL), mBufferLength(0), mAmountRead(0),
1721
if (mListener != NULL) {
1722
mListener->AddRef();
1723
mListener->GetStreamType(&mStreamType);
1727
CPluginInputStream::~CPluginInputStream(void)
1729
NS_IF_RELEASE(mListener);
1733
NS_IF_RELEASE(mStreamInfo);
1736
NS_IMPL_ISUPPORTS1(CPluginInputStream, nsIPluginInputStream)
1739
CPluginInputStream::Close(void)
1741
if (mNPP == NULL || mStream == NULL)
1742
return NS_ERROR_FAILURE;
1743
NPError err = NPN_DestroyStream(mNPP, mStream, NPRES_USER_BREAK);
1744
return fromNPError[err];
1748
CPluginInputStream::GetLength(PRUint32 *aLength)
1750
*aLength = mStream->end;
1755
CPluginInputStream::Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount)
1757
PRUint32 cnt = PR_MIN(aCount, mBufferLength);
1758
memcpy(aBuf, mBuffer + mAmountRead, cnt);
1761
mBufferLength -= cnt;
1766
CPluginInputStream::GetLastModified(PRUint32 *result)
1768
*result = mStream->lastmodified;
1773
CPluginInputStream::RequestRead(nsByteRange* rangeList)
1775
NPError err = NPN_RequestRead(mStream, (NPByteRange*)rangeList);
1776
return fromNPError[err];
1780
//////////////////////////////////////////////////////////////////////////////
1782
#if defined(__cplusplus)