Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions | Variables
BackwardAdapter.cpp File Reference
#include "npapi.h"
#include "nsIPluginManager2.h"
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsLiveConnect.h"
#include "nsIEventHandler.h"
#include "nsplugin.h"
#include "nsDebug.h"
#include "nsIJRILiveConnectPlugin.h"
#include "nsIJRILiveConnectPIPeer.h"
#include "nsIPluginInputStream.h"
#include "nsObsoleteModuleLoading.h"
#include <windows.h>

Go to the source code of this file.

Classes

class  CPluginManager
struct  CPluginManager::RegisteredWindow
class  CPluginManagerStream
class  CPluginInstancePeer
class  CPluginStreamInfo
class  CPluginInputStream

Functions

static NS_DEFINE_CID (kPluginCID, NS_PLUGIN_CID)
static NS_DEFINE_CID (kPluginManagerCID, NS_PLUGINMANAGER_CID)
static NS_DEFINE_CID (kMemoryCID, NS_MEMORY_CID)
NPError NPP_Initialize (void)
jref NPP_GetJavaClass (void)
void NPP_Shutdown (void)
NPError NPP_New (NPMIMEType pluginType, NPP instance, PRUint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
NPError NPP_Destroy (NPP instance, NPSavedData **save)
NPError NPP_SetWindow (NPP instance, NPWindow *window)
NPError NPP_NewStream (NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, PRUint16 *stype)
int32 NPP_WriteReady (NPP instance, NPStream *stream)
int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPReason reason)
void NPP_StreamAsFile (NPP instance, NPStream *stream, const char *fname)
void NPP_Print (NPP instance, NPPrint *printInfo)
void NPP_URLNotify (NPP instance, const char *url, NPReason reason, void *notifyData)
int16 NPP_HandleEvent (NPP instance, void *event)

Variables

nsIPluginManagerthePluginManager = NULL
nsIPluginthePlugin = NULL
nsresult fromNPError []
int varMap []

Function Documentation

NPError NPP_Destroy ( NPP  instance,
NPSavedData **  save 
)

Definition at line 1226 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_Destroy\n");
    
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;
    
    CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
    nsIPluginInstance* pluginInstance = peer->GetInstance();
    pluginInstance->Stop();
    pluginInstance->Destroy();
    pluginInstance->Release();
       // peer->Release();
    instance->pdata = NULL;
    
    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

NPError NPP_DestroyStream ( NPP  instance,
NPStream stream,
NPReason  reason 
)

Definition at line 1363 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_DestroyStream\n");

    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;
              
    CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
    if (inStr == NULL)
        return NPERR_GENERIC_ERROR;
    inStr->GetListener()->OnStopBinding(inStr->GetPluginStreamInfo(), (nsPluginReason)reason);
    // inStr->Release();
    stream->pdata = NULL;
       
    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

Definition at line 1126 of file BackwardAdapter.cpp.

{
       jref pluginClass = NULL;
       if (thePlugin != NULL) {
              nsIJRILiveConnectPlugin* jriPlugin = NULL;
              if (thePlugin->QueryInterface(NS_GET_IID(nsIJRILiveConnectPlugin), (void**)&jriPlugin) == NS_OK) {
                     jriPlugin->GetJavaClass(NPN_GetJavaEnv(), &pluginClass);
                     NS_RELEASE(jriPlugin);
              }
       }
       return pluginClass;
}

Here is the call graph for this function:

int16 NPP_HandleEvent ( NPP  instance,
void event 
)

Definition at line 1444 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_HandleEvent\n");
    int16 eventHandled = FALSE;
    if (instance == NULL)
        return eventHandled;
       
    NPEvent* npEvent = (NPEvent*) event;
    nsPluginEvent pluginEvent = {
#ifdef XP_MAC
        npEvent, NULL
#else
        npEvent->event, npEvent->wParam, npEvent->lParam
#endif
    };
       
    CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
    nsIPluginInstance* pluginInstance = peer->GetInstance();
    if (pluginInstance) {
        PRBool handled;
        nsresult err = pluginInstance->HandleEvent(&pluginEvent, &handled);
        if (err) return FALSE;
        eventHandled = (handled == PR_TRUE);
    }
       
    return eventHandled;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1086 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_Initialize\n");

    // Only call initialize the plugin if it hasn't been created.
    // This could happen if GetJavaClass() is called before
    // NPP Initialize.  
    if (thePluginManager == NULL) {
        // Create the plugin manager and plugin classes.
        thePluginManager = new CPluginManager(); 
        if ( thePluginManager == NULL ) 
            return NPERR_OUT_OF_MEMORY_ERROR;  
        thePluginManager->AddRef();
    }
    NPError error = NPERR_INVALID_PLUGIN_ERROR;  
    // On UNIX the plugin might have been created when calling NPP_GetMIMEType.
    if (thePlugin == NULL) {
        // create nsIPlugin factory
        nsresult result = NSGetFactory(thePluginManager, kPluginCID, NULL, NULL, (nsIFactory**)&thePlugin);
        if (result == NS_OK && thePlugin->Initialize() == NS_OK)
              error = NPERR_NO_ERROR;
      
       }
       
    return error;
}

Here is the call graph for this function:

NPError NPP_New ( NPMIMEType  pluginType,
NPP  instance,
PRUint16  mode,
int16  argc,
char *  argn[],
char *  argv[],
NPSavedData saved 
)

Definition at line 1177 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_New\n");
    
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    // Create a new plugin instance and start it.
    nsIPluginInstance* pluginInstance = NULL;
    thePlugin->CreatePluginInstance(thePluginManager, NS_GET_IID(nsIPluginInstance), pluginType, (void**)&pluginInstance);
    if (pluginInstance == NULL) {
        return NPERR_OUT_OF_MEMORY_ERROR;
    }
    
    // Create a new plugin instance peer,
    // XXX - Since np_instance is not implemented in the 4.0x browser, I
    // XXX - had to save the plugin parameter in the peer class.
    // XXX - Ask Warren about np_instance.
    CPluginInstancePeer* peer = new CPluginInstancePeer(pluginInstance, instance,
                                                                                           (nsMIMEType)pluginType, 
                                                                          (nsPluginMode)mode, (PRUint16)argc,
                                                                          (const char** )argn, (const char** )argv);
    assert( peer != NULL );
    if (!peer) return NPERR_OUT_OF_MEMORY_ERROR;
    peer->AddRef();
    pluginInstance->Initialize(peer);
    pluginInstance->Start();
    // Set the user instance and store the peer in npp->pdata.
    instance->pdata = peer;
    peer->Release();

    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

NPError NPP_NewStream ( NPP  instance,
NPMIMEType  type,
NPStream stream,
NPBool  seekable,
PRUint16 stype 
)

Definition at line 1280 of file BackwardAdapter.cpp.

{
    // XXX - How do you set the fields of the peer stream and stream?
    // XXX - Looks like these field will have to be created since
    // XXX - We are not using np_stream.
   
//    TRACE("NPP_NewStream\n");

    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;
                            
    CPluginInputStream* inStr = (CPluginInputStream*)stream->notifyData;
    if (inStr == NULL)
        return NPERR_GENERIC_ERROR;
    
    nsIPluginStreamInfo* info = inStr->CreatePluginStreamInfo(stream->url, type, seekable);
    nsresult err = inStr->GetListener()->OnStartBinding(info);
    if (err) return err;

    inStr->SetStreamInfo(instance, stream);
    stream->pdata = inStr;
    *stype = inStr->GetStreamType();

    return NPERR_NO_ERROR;
}

Here is the call graph for this function:

void NPP_Print ( NPP  instance,
NPPrint printInfo 
)

Definition at line 1404 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_Print\n");

    if(printInfo == NULL)   // trap invalid parm
        return;

    if (instance != NULL)
    {
        CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
        nsIPluginInstance* pluginInstance = peer->GetInstance();
        pluginInstance->Print((nsPluginPrint* ) printInfo );
    }
}

Here is the call graph for this function:

NPError NPP_SetWindow ( NPP  instance,
NPWindow window 
)

Definition at line 1250 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_SetWindow\n");
    
    if (instance == NULL)
        return NPERR_INVALID_INSTANCE_ERROR;

    CPluginInstancePeer* peer = (CPluginInstancePeer*) instance->pdata;
    if ( peer == NULL)
        return NPERR_INVALID_PLUGIN_ERROR;

       // record the window in the peer, so we can deliver proper events.
       peer->SetWindow(window);

    nsIPluginInstance* pluginInstance = peer->GetInstance();
    if( pluginInstance == 0 )
        return NPERR_INVALID_PLUGIN_ERROR;

    return (NPError)pluginInstance->SetWindow((nsPluginWindow* ) window );
}

Here is the call graph for this function:

Definition at line 1148 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_Shutdown\n");

    if (thePlugin)
    {
        thePlugin->Shutdown();
        thePlugin->Release();
        thePlugin = NULL;
    }

    if (thePluginManager)  {
        thePluginManager->Release();
        thePluginManager = NULL;
    }
    
    return;
}

Here is the call graph for this function:

void NPP_StreamAsFile ( NPP  instance,
NPStream stream,
const char *  fname 
)

Definition at line 1386 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_StreamAsFile\n");

    if (instance == NULL)
        return;
              
    CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
    if (inStr == NULL)
        return;
    (void)inStr->GetListener()->OnFileAvailable(inStr->GetPluginStreamInfo(), fname);
}

Here is the call graph for this function:

void NPP_URLNotify ( NPP  instance,
const char *  url,
NPReason  reason,
void notifyData 
)

Definition at line 1425 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_URLNotify\n");

    if (instance != NULL) {
        CPluginInputStream* inStr = (CPluginInputStream*)notifyData;
        (void)inStr->GetListener()->OnStopBinding(inStr->GetPluginStreamInfo(), (nsPluginReason)reason);
        inStr->Release();
    }
}

Here is the call graph for this function:

int32 NPP_Write ( NPP  instance,
NPStream stream,
int32  offset,
int32  len,
void buffer 
)

Definition at line 1337 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_Write\n");

    if (instance == NULL)
        return -1;
       
    CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
    if (inStr == NULL)
        return -1;
    nsresult err = inStr->SetReadBuffer((PRUint32)len, (const char*)buffer);
    if (err != NS_OK) return -1;
    err = inStr->GetListener()->OnDataAvailable(inStr->GetPluginStreamInfo(), inStr, len);
    if (err != NS_OK) return -1;
    return len;
}

Here is the call graph for this function:

int32 NPP_WriteReady ( NPP  instance,
NPStream stream 
)

Definition at line 1317 of file BackwardAdapter.cpp.

{
//    TRACE("NPP_WriteReady\n");

    if (instance == NULL)
        return -1;

    CPluginInputStream* inStr = (CPluginInputStream*)stream->pdata;
    if (inStr == NULL)
        return -1;
    return NP_MAXREADY;
}

Here is the call graph for this function:

static NS_DEFINE_CID ( kPluginCID  ,
NS_PLUGIN_CID   
) [static]
static NS_DEFINE_CID ( kPluginManagerCID  ,
NS_PLUGINMANAGER_CID   
) [static]
static NS_DEFINE_CID ( kMemoryCID  ,
NS_MEMORY_CID   
) [static]

Variable Documentation

Definition at line 961 of file BackwardAdapter.cpp.

Definition at line 960 of file BackwardAdapter.cpp.