Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
npp_gate.cpp File Reference
#include "xp.h"
#include "epmanager.h"
#include "plugload.h"
#include "logger.h"

Go to the source code of this file.

Functions

jref NPP_GetJavaClass (void)
NPError NPP_New (NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
NPError NPP_Destroy (NPP instance, NPSavedData **save)
NPError NPP_SetWindow (NPP instance, NPWindow *pNPWindow)
NPError NPP_NewStream (NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *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, NPError 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)
NPError NPP_GetValue (NPP instance, NPPVariable variable, void *value)
NPError NPP_SetValue (NPP instance, NPNVariable variable, void *value)
int16 NPP_HandleEvent (NPP instance, void *event)

Variables

NPNetscapeFuncs NPNFuncs
Loggerlogger
NPNetscapeFuncs fakeNPNFuncs
NPPEntryPointManagerepManager

Function Documentation

NPError NPP_Destroy ( NPP  instance,
NPSavedData **  save 
)

Definition at line 158 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  BOOL last = FALSE;

  if(logger)
    logger->logCall(action_npp_destroy, (DWORD)instance, (DWORD)save);

  NPError rv = epManager->callNPP_Destroy(instance, save, &last);

  if(logger)
    logger->logReturn();

  if(last && logger->bSPALID)
  {
    // this will log it
    epManager->callNP_Shutdown(instance);

    XP_HLIB hLib = NULL;

    epManager->removeEntryPointsForPlugin(instance, &hLib);
  
    UnloadRealPlugin(hLib);
  }
  return rv;
}

Here is the call graph for this function:

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

Definition at line 270 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_destroy_stream, (DWORD)instance, (DWORD)stream, (DWORD)reason);

  NPError rv = epManager->callNPP_DestroyStream(instance, stream, reason);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

Definition at line 51 of file npp_gate.cpp.

Here is the call graph for this function:

NPError NPP_GetValue ( NPP  instance,
NPPVariable  variable,
void value 
)

Definition at line 328 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_get_value, (DWORD)instance, (DWORD)variable, (DWORD)value);

  NPError rv = epManager->callNPP_GetValue(instance, variable, value);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

int16 NPP_HandleEvent ( NPP  instance,
void event 
)

Definition at line 366 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return 0;

  if(instance == NULL)
    return 0;

  if(logger)
    logger->logCall(action_npp_handle_event, (DWORD)instance, (DWORD)event);

  int16 rv = epManager->callNPP_HandleEvent(instance, event);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

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

Definition at line 61 of file npp_gate.cpp.

{   
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;
  
  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_new, (DWORD)pluginType, (DWORD)instance, (DWORD)mode, (DWORD)argc, (DWORD)argn, (DWORD)argv, (DWORD)saved);

/* now action begins */

  if(NULL == epManager->findEntryPointsForPlugin(pluginType))
  {
    // if it is first time in, we don't have it yet
    // scan plugins dir for available plugins to see if we have anything 
    // for the given mimetype
    XP_HLIB hLib = LoadRealPlugin(pluginType);
    if(!hLib)
    {
      // what do we do if we don't?
      return NPERR_GENERIC_ERROR;
    }

    NP_GETENTRYPOINTS real_NP_GetEntryPoints = (NP_GETENTRYPOINTS)XP_GetSymbol(hLib, "NP_GetEntryPoints");
    if(!real_NP_GetEntryPoints)
      return NPERR_GENERIC_ERROR;

    NP_INITIALIZE real_NP_Initialize = (NP_INITIALIZE)XP_GetSymbol(hLib, "NP_Initialize");
    if(!real_NP_Initialize)
      return NPERR_GENERIC_ERROR;

    NP_SHUTDOWN real_NP_Shutdown = (NP_SHUTDOWN)XP_GetSymbol(hLib, "NP_Shutdown");
    if(!real_NP_Shutdown)
      return NPERR_GENERIC_ERROR;

    // fill callbacks structs
    NPPluginFuncs realNPPFuncs;
    memset(&realNPPFuncs, 0, sizeof(NPPluginFuncs));
    realNPPFuncs.size = sizeof(NPPluginFuncs);

    real_NP_GetEntryPoints(&realNPPFuncs);

    if(logger)
      logger->logSPY_NP_GetEntryPoints(&realNPPFuncs);

    // store the table with the entry point manager
    epManager->createEntryPointsForPlugin(pluginType, &realNPPFuncs, real_NP_Shutdown, hLib);
    
    // inform the plugin about our entry point it should call
    memset((void *)&fakeNPNFuncs, 0, sizeof(fakeNPNFuncs));

    fakeNPNFuncs.size             = sizeof(fakeNPNFuncs);
    fakeNPNFuncs.version          = NPNFuncs.version;
    fakeNPNFuncs.geturlnotify     = NPN_GetURLNotify;
    fakeNPNFuncs.geturl           = NPN_GetURL;
    fakeNPNFuncs.posturlnotify    = NPN_PostURLNotify;
    fakeNPNFuncs.posturl          = NPN_PostURL;
    fakeNPNFuncs.requestread      = NPN_RequestRead;
    fakeNPNFuncs.newstream        = NPN_NewStream;
    fakeNPNFuncs.write            = NPN_Write;
    fakeNPNFuncs.destroystream    = NPN_DestroyStream;
    fakeNPNFuncs.status           = NPN_Status;
    fakeNPNFuncs.uagent           = NPN_UserAgent;
    fakeNPNFuncs.memalloc         = NPN_MemAlloc;
    fakeNPNFuncs.memfree          = NPN_MemFree;
    fakeNPNFuncs.memflush         = NPN_MemFlush;
    fakeNPNFuncs.reloadplugins    = NPN_ReloadPlugins;
    fakeNPNFuncs.getJavaEnv       = NPN_GetJavaEnv;
    fakeNPNFuncs.getJavaPeer      = NPN_GetJavaPeer;
    fakeNPNFuncs.getvalue         = NPN_GetValue;
    fakeNPNFuncs.setvalue         = NPN_SetValue;
    fakeNPNFuncs.invalidaterect   = NPN_InvalidateRect;
    fakeNPNFuncs.invalidateregion = NPN_InvalidateRegion;
    fakeNPNFuncs.forceredraw      = NPN_ForceRedraw;

    if(logger)
      logger->logSPY_NP_Initialize();

    real_NP_Initialize(&fakeNPNFuncs);
  }
  
  NPError rv = epManager->callNPP_New(pluginType, instance, mode, argc, argn, argv, saved);
  
  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

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

Definition at line 209 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_new_stream, (DWORD)instance, (DWORD)type, (DWORD)stream, (DWORD)seekable, (DWORD)stype);

  NPError rv = epManager->callNPP_NewStream(instance, type, stream, seekable, stype);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

void NPP_Print ( NPP  instance,
NPPrint printInfo 
)

Definition at line 303 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return;

  if(logger)
    logger->logCall(action_npp_print, (DWORD)instance, (DWORD)printInfo);

  epManager->callNPP_Print(instance, printInfo);
}

Here is the call graph for this function:

NPError NPP_SetValue ( NPP  instance,
NPNVariable  variable,
void value 
)

Definition at line 347 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_set_value, (DWORD)instance, (DWORD)variable, (DWORD)value);

  NPError rv = epManager->callNPP_SetValue(instance, variable, value);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

NPError NPP_SetWindow ( NPP  instance,
NPWindow pNPWindow 
)

Definition at line 190 of file npp_gate.cpp.

{    
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_set_window, (DWORD)instance, (DWORD)pNPWindow);

  NPError rv = epManager->callNPP_SetWindow(instance, pNPWindow);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

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

Definition at line 289 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return;

  if(instance == NULL)
    return;

  if(logger)
    logger->logCall(action_npp_stream_as_file, (DWORD)instance, (DWORD)stream, (DWORD)fname);

  epManager->callNPP_StreamAsFile(instance, stream, fname);
}

Here is the call graph for this function:

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

Definition at line 314 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return;

  if(instance == NULL)
    return;

  if(logger)
    logger->logCall(action_npp_url_notify, (DWORD)instance, (DWORD)url, (DWORD)reason, (DWORD)notifyData);

  epManager->callNPP_URLNotify(instance, url, reason, notifyData);
}

Here is the call graph for this function:

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

Definition at line 251 of file npp_gate.cpp.

{   
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_write, (DWORD)instance, (DWORD)stream, (DWORD)offset, (DWORD)len, (DWORD)buffer);

  int32 rv = epManager->callNPP_Write(instance, stream, offset, len, buffer);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:

int32 NPP_WriteReady ( NPP  instance,
NPStream stream 
)

Definition at line 232 of file npp_gate.cpp.

{
  if(epManager == NULL)
    return NPERR_GENERIC_ERROR;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(logger)
    logger->logCall(action_npp_write_ready, (DWORD)instance, (DWORD)stream);

  int32 rv = epManager->callNPP_WriteReady(instance, stream);

  if(logger)
    logger->logReturn();

  return rv;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 48 of file np_entry.cpp.

Definition at line 47 of file npp_gate.cpp.

Definition at line 50 of file np_entry.cpp.

Definition at line 45 of file np_entry.cpp.