Back to index

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

Go to the source code of this file.

Functions

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)
jref NPP_GetJavaClass (void)

Variables

CLoggerpLogger
static char szINIFile [] = NPAPI_INI_FILE_NAME
static char szTarget [] = LOGGER_DEFAULT_TARGET

Function Documentation

NPError NPP_Destroy ( NPP  instance,
NPSavedData **  save 
)

Definition at line 103 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  NPError ret = NPERR_NO_ERROR;
  CPluginBase * pPlugin = NULL;

  if(!instance) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;
  if(pPlugin) {
    if (pPlugin->isStandAlone())
      pPlugin->shutStandAlone();

    pPlugin->shut();
    DestroyPlugin(pPlugin);
    goto Return;
  }

Return:
  pLogger->blockDumpToFrame(TRUE);
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_destroy, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)instance, (DWORD)save);
  pLogger->blockDumpToFrame(FALSE);

  // mark logger stale as the dll can remain in memory with no NP_Shutdown called
  // and then come back with NPP_New where we should recreate the logger
  pLogger->markStale();
  return ret;
}

Here is the call graph for this function:

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

Definition at line 276 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  NPError ret = NPERR_NO_ERROR;

  if(!instance) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;

  pPlugin->onNPP_DestroyStream(stream);
  if(pLogger->onNPP_DestroyStream(stream))
    return ret;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_destroy_stream, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)instance, (DWORD)stream, (DWORD)reason);
  return ret;
}

Here is the call graph for this function:

Definition at line 421 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  DWORD dwTickReturn = XP_GetTickCount();
  if(pLogger)
    pLogger->appendToLog(action_npp_get_java_class, dwTickEnter, dwTickReturn, 0L);
  return NULL;
}

Here is the call graph for this function:

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

Definition at line 350 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  NPError ret = NPERR_NO_ERROR;

  if(!instance) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;

#ifdef XP_UNIX
  switch (variable) {
    case NPPVpluginNameString:   
      *((char **)value) = "API Tester plugin";
      break;
    case NPPVpluginDescriptionString:
      *((char **)value) = "This plugins reads and executes test scripts.";
      break;
    default:
      ret = NPERR_GENERIC_ERROR;
  }
#endif // XP_UNIX (displays name and description)

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_get_value, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)instance, (DWORD)variable, (DWORD)value);
  return ret;
}

Here is the call graph for this function:

int16 NPP_HandleEvent ( NPP  instance,
void event 
)

Definition at line 403 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  int16 ret = (int16)TRUE;

  if(!instance)
    goto Return;

  pPlugin = (CPluginBase *)instance->pdata;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_handle_event, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)instance, (DWORD)event);
  return ret;
}

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 53 of file npp_gate.cpp.

{   
  DWORD dwTickEnter = XP_GetTickCount();
  NPError ret = NPERR_NO_ERROR;
  CPluginBase * pPlugin = NULL;

  if(!instance) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)CreatePlugin(instance, mode);

  if(!pPlugin) {
    ret = NPERR_OUT_OF_MEMORY_ERROR;
    goto Return;
  }

  instance->pdata = (void *)pPlugin;

  // recreate logger if needed
  if (!pLogger)
    pLogger = new CLogger(szTarget);
  else if (pLogger->isStale()) {
    delete pLogger;
    pLogger = new CLogger(szTarget);
  }

  char szFileName[_MAX_PATH];
  pPlugin->getModulePath(szFileName, sizeof(szFileName));
  strcat(szFileName, szINIFile);
  pLogger->restorePreferences(szFileName);
  
  pLogger->associate(pPlugin);

  if (pPlugin->isStandAlone())
    pPlugin->initStandAlone();

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_new, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)pluginType, (DWORD)instance, 
                       (DWORD)mode, (DWORD)argc, (DWORD)argn, (DWORD)argv, (DWORD)saved);

  pPlugin->autoStartScriptIfNeeded();

  return ret;
}

Here is the call graph for this function:

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

Definition at line 206 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  NPError ret = NPERR_NO_ERROR;

  if(!instance) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;
  pPlugin->onNPP_NewStream(instance, (LPSTR)type, stream, seekable, stype);

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_new_stream, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)instance, 
                       (DWORD)type, (DWORD)stream, (DWORD)seekable, (DWORD)stype);
  if (pPlugin->m_firstAction == action_npn_request_read && seekable) {
    *stype = NP_SEEK;
  }
  return ret;
}

Here is the call graph for this function:

void NPP_Print ( NPP  instance,
NPPrint printInfo 
)

Definition at line 318 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;

  if(!instance)
    goto Return;

  pPlugin = (CPluginBase *)instance->pdata;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_print, dwTickEnter, dwTickReturn, 0L, 
                       (DWORD)instance, (DWORD)printInfo);
}

Here is the call graph for this function:

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

Definition at line 383 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  NPError ret = NPERR_NO_ERROR;

  if(!instance) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_set_value, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)instance, (DWORD)variable, (DWORD)value);
  return ret;
}

Here is the call graph for this function:

NPError NPP_SetWindow ( NPP  instance,
NPWindow pNPWindow 
)

Definition at line 139 of file npp_gate.cpp.

{    
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  NPError ret = NPERR_NO_ERROR;

  if(!instance ) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  if(!pNPWindow) {
    ret = NPERR_INVALID_INSTANCE_ERROR;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;

  if(!pPlugin) {
    ret = NPERR_GENERIC_ERROR;
    goto Return;
  }

  if (!pPlugin->isStandAlone())
  {
    // window just created
    if(!pPlugin->isInitialized() && pNPWindow->window) { 
      if(!pPlugin->init((DWORD)pNPWindow->window)) {
        delete pPlugin;
        pPlugin = NULL;
        ret = NPERR_MODULE_LOAD_FAILED_ERROR;
        goto Return;
      }

      if(pLogger->getShowImmediatelyFlag()) {
        pLogger->dumpLogToTarget();
        pLogger->clearLog();
      }
      goto Return;
    }

    // window goes away
    if(!pNPWindow->window && pPlugin->isInitialized()) {
      pPlugin->shut();
      ret = NPERR_NO_ERROR;
      goto Return;
    }

    // window resized?
    if(pPlugin->isInitialized() && pNPWindow->window) {
      ret = NPERR_NO_ERROR;
      goto Return;
    }

    // this should not happen, nothing to do
    if(!pNPWindow->window && !pPlugin->isInitialized()) {
      ret = NPERR_NO_ERROR;
      goto Return;
    }
  }

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_set_window, dwTickEnter, dwTickReturn, (DWORD)ret, (DWORD)instance, (DWORD)pNPWindow);
  return ret;
}

Here is the call graph for this function:

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

Definition at line 300 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;

  if(!instance)
    goto Return;

  pPlugin = (CPluginBase *)instance->pdata;

  pPlugin->onNPP_StreamAsFile(instance, stream, fname);

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_stream_as_file, dwTickEnter, dwTickReturn, 0L, 
                       (DWORD)instance, (DWORD)stream, (DWORD)fname);
}

Here is the call graph for this function:

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

Definition at line 334 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;

  if(!instance)
    goto Return;

  pPlugin = (CPluginBase *)instance->pdata;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_url_notify, dwTickEnter, dwTickReturn, 0L, 
                       (DWORD)instance, (DWORD)url, (DWORD)reason, (DWORD)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 250 of file npp_gate.cpp.

{   
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  int32 ret = len;

  if(!instance)
    goto Return;
  
  pPlugin = (CPluginBase *)instance->pdata;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_write, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)instance, (DWORD)stream, 
                       (DWORD)offset, (DWORD)len, (DWORD)buffer);
  if (pPlugin->m_firstAction == action_npn_request_read) {
    if (stream->notifyData) {
      NPByteRange* rangeList =     (NPByteRange*) stream->notifyData;
      NPN_RequestRead(stream, rangeList);
      stream->notifyData = 0;
    }
  }
  return ret;
}

Here is the call graph for this function:

int32 NPP_WriteReady ( NPP  instance,
NPStream stream 
)

Definition at line 230 of file npp_gate.cpp.

{
  DWORD dwTickEnter = XP_GetTickCount();
  CPluginBase * pPlugin = NULL;
  int32 ret = 0x0FFFFFFF;

  if(!instance) {
    ret = 0L;
    goto Return;
  }

  pPlugin = (CPluginBase *)instance->pdata;

Return:
  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action_npp_write_ready, dwTickEnter, dwTickReturn, (DWORD)ret, 
                       (DWORD)instance, (DWORD)stream);
  return ret;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 47 of file np_entry.cpp.

char szINIFile[] = NPAPI_INI_FILE_NAME [static]

Definition at line 47 of file npp_gate.cpp.

char szTarget[] = LOGGER_DEFAULT_TARGET [static]

Definition at line 48 of file npp_gate.cpp.