Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
npshell.cpp File Reference
#include <os2.h>
#include <string.h>
#include <assert.h>
#include "npnulos2.h"
#include "plugin.h"
#include "utils.h"
#include "dbg.h"

Go to the source code of this file.

Functions

NPError NPP_Initialize (void)
void NPP_Shutdown (void)
NPError NP_LOADDS NPP_New (NPMIMEType pluginType, NPP pInstance, uint16 mode, int16 argc, char *argn[], char *argv[], NPSavedData *saved)
NPError NP_LOADDS NPP_Destroy (NPP pInstance, NPSavedData **save)
NPError NP_LOADDS NPP_SetWindow (NPP pInstance, NPWindow *pNPWindow)
NPError NP_LOADDS NPP_NewStream (NPP pInstance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
int32 NP_LOADDS NPP_WriteReady (NPP pInstance, NPStream *stream)
int32 NP_LOADDS NPP_Write (NPP pInstance, NPStream *stream, int32 offset, int32 len, void *buffer)
NPError NP_LOADDS NPP_DestroyStream (NPP pInstance, NPStream *stream, NPError reason)
void NP_LOADDS NPP_StreamAsFile (NPP instance, NPStream *stream, const char *fname)
void NP_LOADDS NPP_Print (NPP pInstance, NPPrint *printInfo)
void NP_LOADDS NPP_URLNotify (NPP pInstance, const char *url, NPReason reason, void *notifyData)

Variables

char szAppName [] = "NPNULL"

Function Documentation

NPError NP_LOADDS NPP_Destroy ( NPP  pInstance,
NPSavedData **  save 
)

Definition at line 142 of file npshell.cpp.

{
  dbgOut1("NPP_Destroy");
  if(pInstance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  if(pPlugin != NULL)
  {
    pPlugin->shut();
    delete pPlugin;
  }

  return NPERR_NO_ERROR;
}

Here is the call graph for this function:

NPError NP_LOADDS NPP_DestroyStream ( NPP  pInstance,
NPStream stream,
NPError  reason 
)

Definition at line 285 of file npshell.cpp.

{
  dbgOut1("NPP_DestroyStream");
  if(pInstance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  if (!pPlugin)
    return NPERR_GENERIC_ERROR;

  return pPlugin->destroyStream(stream, reason);
}

Here is the call graph for this function:

Definition at line 53 of file npshell.cpp.

Here is the call graph for this function:

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

Definition at line 70 of file npshell.cpp.

{
  if(pInstance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  // See if the content provider specified from where to fetch the plugin
  char * szPageURL = NULL;
  char * szFileURL = NULL;
  char * szFileExtension = NULL;
  char * buf = NULL;
  BOOL bHidden = FALSE;

  for(int i = 0; i < argc; i++)
  {
    if(stricmp(argn[i],"pluginspage") == 0 && argv[i] != NULL)
      szPageURL = (char *)argv[i];
    else if(stricmp(argn[i],"codebase") == 0 && argv[i] != NULL)
      szPageURL = (char *)argv[i];
    else if(stricmp(argn[i],"pluginurl") == 0 && argv[i] != NULL)
      szFileURL = (char *)argv[i];
    else if(stricmp(argn[i],"classid") == 0 && argv[i] != NULL)
      szFileURL = (char *)argv[i];
    else if(stricmp(argn[i],"SRC") == 0 && argv[i] != NULL)
      buf = (char *)argv[i];
    else if(stricmp(argn[i],"HIDDEN") == 0 && argv[i] != NULL)
      bHidden = (strcmp((char *)argv[i], "TRUE") == 0);
  }

  /* some post-processing on the filename to attempt to extract the extension:  */
  if(buf != NULL)
  {
    buf = strrchr(buf, '.');
    if(buf)
      szFileExtension = ++buf;
  }

  CPlugin * pPlugin = new CPlugin(hInst, 
                                  pInstance, 
                                  mode, 
                                  pluginType, 
                                  szPageURL, 
                                  szFileURL, 
                                  szFileExtension,
                                  bHidden);
  if(pPlugin == NULL)
    return NPERR_OUT_OF_MEMORY_ERROR;

  if(bHidden)
  {
    if(!pPlugin->init(NULL))
    {
      delete pPlugin;
      pPlugin = NULL;
      return NPERR_MODULE_LOAD_FAILED_ERROR;
    }
  }

  pInstance->pdata = (void *)pPlugin;

  return NPERR_NO_ERROR;
}

Here is the call graph for this function:

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

Definition at line 224 of file npshell.cpp.

{
  dbgOut1("NPP_NewStream");
  if(pInstance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  if (!pPlugin)
    return NPERR_GENERIC_ERROR;

  return pPlugin->newStream(type, stream, seekable, stype);
}

Here is the call graph for this function:

void NP_LOADDS NPP_Print ( NPP  pInstance,
NPPrint printInfo 
)

Definition at line 312 of file npshell.cpp.

{
  dbgOut2("NPP_Print, printInfo = %#08x", printInfo);

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  pPlugin->print(printInfo);
}

Here is the call graph for this function:

NPError NP_LOADDS NPP_SetWindow ( NPP  pInstance,
NPWindow pNPWindow 
)

Definition at line 161 of file npshell.cpp.

{
  if(pInstance == NULL)
  {
    dbgOut1("NPP_SetWindow returns NPERR_INVALID_INSTANCE_ERROR");
    return NPERR_INVALID_INSTANCE_ERROR;
  }

  if(pNPWindow == NULL)
  {
    dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
    return NPERR_GENERIC_ERROR;
  }

  HWND hWnd = (HWND)pNPWindow->window;

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  if(pPlugin == NULL) 
  {
    dbgOut1("NPP_SetWindow returns NPERR_GENERIC_ERROR");
    return NPERR_GENERIC_ERROR;
  }

  if((hWnd == NULL) && (pPlugin->getWindow() == NULL)) // spurious entry
  {
    dbgOut1("NPP_SetWindow just returns with NPERR_NO_ERROR");
    return NPERR_NO_ERROR;
  }

  if((hWnd == NULL) && (pPlugin->getWindow() != NULL))
  { // window went away
    dbgOut1("NPP_SetWindow, going away...");
    pPlugin->shut();
    return NPERR_NO_ERROR;
  }

  if((pPlugin->getWindow() == NULL) && (hWnd != NULL))
  { // First time in -- no window created by plugin yet
    dbgOut1("NPP_SetWindow, first time");

    if(!pPlugin->init(hWnd))
    {
      delete pPlugin;
      pPlugin = NULL;
      return NPERR_MODULE_LOAD_FAILED_ERROR;
    }
  }

  if((pPlugin->getWindow() != NULL) && (hWnd != NULL))
  { // Netscape window has been resized
    dbgOut1("NPP_SetWindow, resizing");
    pPlugin->resize();
  }

  return NPERR_NO_ERROR;
}

Definition at line 62 of file npshell.cpp.

Here is the call graph for this function:

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

Definition at line 304 of file npshell.cpp.

{
  dbgOut1("NPP_StreamAsFile");
}
void NP_LOADDS NPP_URLNotify ( NPP  pInstance,
const char *  url,
NPReason  reason,
void notifyData 
)

Definition at line 322 of file npshell.cpp.

{
  dbgOut2("NPP_URLNotify, URL '%s'", url);

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  pPlugin->URLNotify(url);
}

Here is the call graph for this function:

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

Definition at line 266 of file npshell.cpp.

{
  //dbgOut1("NPP_Write");
  if(pInstance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  // We don't want any data, kill the stream
  NPN_DestroyStream(pInstance, stream, NPRES_DONE);

  return -1;   // tell the browser to abort the stream, don't need it
}

Here is the call graph for this function:

int32 NP_LOADDS NPP_WriteReady ( NPP  pInstance,
NPStream stream 
)

Definition at line 247 of file npshell.cpp.

{
  dbgOut1("NPP_WriteReady");
  if(pInstance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  CPlugin * pPlugin = (CPlugin *)pInstance->pdata;
  assert(pPlugin != NULL);

  // We don't want any data, kill the stream
  NPN_DestroyStream(pInstance, stream, NPRES_DONE);

  return -1L;   // dont accept any bytes in NPP_Write()
}

Here is the call graph for this function:


Variable Documentation

char szAppName[] = "NPNULL"

Definition at line 48 of file npshell.cpp.