Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Attributes
CPluginBase Class Reference

#include <plugbase.h>

Inheritance diagram for CPluginBase:
Inheritance graph
[legend]
Collaboration diagram for CPluginBase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CPluginBase (NPP pNPInstance, WORD wMode)
 ~CPluginBase ()
virtual BOOL initEmbed (DWORD dwInitData)=0
virtual void shutEmbed ()=0
virtual BOOL isInitialized ()=0
virtual void getModulePath (LPSTR szPath, int iSize)=0
virtual int messageBox (LPSTR szMessage, LPSTR szTitle, UINT uStyle)=0
virtual BOOL isStandAlone ()=0
virtual BOOL initStandAlone ()=0
virtual void shutStandAlone ()=0
virtual void outputToNativeWindow (LPSTR szString)=0
virtual BOOL initFull (DWORD dwInitData)
virtual void shutFull ()
virtual BOOL init (DWORD dwInitData)
virtual void shut ()
virtual void getLogFileName (LPSTR szLogFileName, int iSize)
virtual void autoStartScriptIfNeeded ()
const NPP getNPInstance ()
const WORD getMode ()
const NPStreamgetNPStream ()
void onNPP_NewStream (NPP pInstance, LPSTR szMIMEType, NPStream *pStream, NPBool bSeekable, uint16 *puType)
void onNPP_StreamAsFile (NPP pInstance, NPStream *pStream, const char *szFileName)
void onNPP_DestroyStream (NPStream *pStream)
virtual DWORD makeNPNCall (NPAPI_Action=action_invalid, DWORD dw1=0L, DWORD dw2=0L, DWORD dw3=0L, DWORD dw4=0L, DWORD dw5=0L, DWORD dw6=0L, DWORD dw7=0L)

Public Attributes

voidm_pNPNAlloced
voidm_pValue
NPAPI_Action m_firstAction

Private Attributes

NPP m_pNPInstance
WORD m_wMode
NPStreamm_pStream
NPStreamm_pScriptStream
char m_szScriptCacheFile [_MAX_PATH]
BOOL m_bWaitingForScriptStream

Detailed Description

Definition at line 56 of file plugbase.h.


Constructor & Destructor Documentation

CPluginBase::CPluginBase ( NPP  pNPInstance,
WORD  wMode 
)

Definition at line 50 of file plugbase.cpp.

                                                    :
  m_pNPInstance(pNPInstance),
  m_wMode(wMode),
  m_pStream(NULL),
  m_pScriptStream(NULL),
  m_bWaitingForScriptStream(FALSE),
  m_pNPNAlloced(NULL),
  m_pValue(NULL)
{
  assert(m_pNPInstance != NULL);
  m_szScriptCacheFile[0] = '\0';

  if(m_wMode == NP_FULL)
  {
    // next should be NPP_NewStream with the script to perform
    // so we set a flag for a special stream treatment
    m_bWaitingForScriptStream = TRUE;
  }
}

Member Function Documentation

Reimplemented in CPlugin.

Definition at line 398 of file plugbase.cpp.

{
}

Here is the caller graph for this function:

void CPluginBase::getLogFileName ( LPSTR  szLogFileName,
int  iSize 
) [virtual]

Reimplemented in CPlugin, and CPlugin.

Definition at line 120 of file plugbase.cpp.

{
  char szFileName[_MAX_PATH];
  getModulePath(szFileName, sizeof(szFileName));
  strcat(szFileName, szINIFile);
  XP_GetPrivateProfileString(SECTION_LOG, KEY_FILE_NAME, "", szLogFileName, (DWORD)iSize, szFileName);
  if(!*szLogFileName)
  {
    strcpy(szLogFileName, m_szScriptCacheFile);

    // last three chars MUST be pts
    int iLength = strlen(szLogFileName);
    szLogFileName[iLength - 3] = 'l';
    szLogFileName[iLength - 2] = 'o';
    szLogFileName[iLength - 1] = 'g';
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 143 of file plugbase.cpp.

{
  return m_wMode;
}

Here is the caller graph for this function:

virtual void CPluginBase::getModulePath ( LPSTR  szPath,
int  iSize 
) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

Definition at line 138 of file plugbase.cpp.

{
  return m_pNPInstance;
}

Here is the caller graph for this function:

Definition at line 148 of file plugbase.cpp.

{
  return m_pStream;
}

Here is the caller graph for this function:

BOOL CPluginBase::init ( DWORD  dwInitData) [virtual]

Definition at line 104 of file plugbase.cpp.

{
  if(m_wMode == NP_EMBED)
    return initEmbed(dwInitData);
  else
    return initFull(dwInitData);
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual BOOL CPluginBase::initEmbed ( DWORD  dwInitData) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

BOOL CPluginBase::initFull ( DWORD  dwInitData) [virtual]

Reimplemented in CPlugin, and CPlugin.

Definition at line 91 of file plugbase.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual BOOL CPluginBase::initStandAlone ( ) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

virtual BOOL CPluginBase::isInitialized ( ) [pure virtual]

Implemented in CPlugin, CPlugin, and CPlugin.

Here is the caller graph for this function:

virtual BOOL CPluginBase::isStandAlone ( ) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

DWORD CPluginBase::makeNPNCall ( NPAPI_Action  action = action_invalid,
DWORD  dw1 = 0L,
DWORD  dw2 = 0L,
DWORD  dw3 = 0L,
DWORD  dw4 = 0L,
DWORD  dw5 = 0L,
DWORD  dw6 = 0L,
DWORD  dw7 = 0L 
) [virtual]

Reimplemented in CPlugin, and CPlugin.

Definition at line 235 of file plugbase.cpp.

{
  DWORD dwRet = 0L;
  DWORD dwTickEnter = XP_GetTickCount();

  switch (action)
  {
    case action_invalid:
      assert(0);
      break;
    case action_npn_version:
    {
      static int iP_maj = 0;
      static int iP_min = 0;
      static int iN_maj = 0;
      static int iN_min = 0;
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)&iP_maj;
      if(dw2 == DEFAULT_DWARG_VALUE)
        dw2 = (DWORD)&iP_min;
      if(dw3 == DEFAULT_DWARG_VALUE)
        dw3 = (DWORD)&iN_maj;
      if(dw4 == DEFAULT_DWARG_VALUE)
        dw4 = (DWORD)&iN_min;
      NPN_Version((int *)dw1, (int *)dw2, (int *)dw3, (int *)dw4);
      break;
    }
    case action_npn_get_url_notify:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_GetURLNotify((NPP)dw1, (char *)dw2, (char *)dw3, (void *)dw4);
      break;
    case action_npn_get_url:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_GetURL((NPP)dw1, (char *)dw2, (char *)dw3);
      break;
    case action_npn_post_url_notify:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_PostURLNotify((NPP)dw1, (char *)dw2, (char *)dw3, (int32)dw4, (char *)dw5, 
                                (BOOL)dw6, (void *)dw7);
      break;
    case action_npn_post_url:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = NPN_PostURL((NPP)dw1, (char *)dw2, (char *)dw3, (int32)dw4, (char *)dw5, (BOOL)dw6);
      break;
    case action_npn_new_stream:
      assert(m_pStream == NULL);
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw4 == DEFAULT_DWARG_VALUE)
        dw4 = (DWORD)&m_pStream;
      dwRet = NPN_NewStream((NPP)dw1, (char *)dw2, (char *)dw3, (NPStream **)dw4);
      break;
    case action_npn_destroy_stream:
      assert(m_pStream != NULL);
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw2 == DEFAULT_DWARG_VALUE)
        dw2 = (DWORD)m_pStream;
      dwRet = NPN_DestroyStream((NPP)dw1, (NPStream *)dw2, (NPError)dw3);
      m_pStream = NULL;
      break;
    case action_npn_request_read:
      break;
    case action_npn_write:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw2 == DEFAULT_DWARG_VALUE)
        dw2 = (DWORD)m_pStream;
      dwRet = NPN_Write((NPP)dw1, (NPStream *)dw2, (int32)dw3, (void *)dw4);
      break;
    case action_npn_status:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_Status((NPP)dw1, (char *)dw2);
      break;
    case action_npn_user_agent:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = (DWORD)NPN_UserAgent((NPP)dw1);
      break;
    case action_npn_mem_alloc:
      assert(m_pNPNAlloced == NULL);
      m_pNPNAlloced = NPN_MemAlloc((int32)dw1);
      dwRet = (DWORD)m_pNPNAlloced;
      if(m_pNPNAlloced != NULL)
      {
        for(int i = 0; i < (int)dw1; i++)
          *(((BYTE *)m_pNPNAlloced) + i) = 255;
      }
      break;
    case action_npn_mem_free:
      assert(m_pNPNAlloced != NULL);
      dw1 = (DWORD)m_pNPNAlloced;
      NPN_MemFree((void *)dw1);
      m_pNPNAlloced = NULL;
      break;
    case action_npn_mem_flush:
      dwRet = (DWORD)NPN_MemFlush((int32)dw1);
      break;
    case action_npn_reload_plugins:
      NPN_ReloadPlugins((NPBool)dw1);
      break;
    case action_npn_get_java_env:
      dwRet = (DWORD)NPN_GetJavaEnv();
      break;
    case action_npn_get_java_peer:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      dwRet = (DWORD)NPN_GetJavaPeer((NPP)dw1);
      break;
    case action_npn_get_value:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw3 == DEFAULT_DWARG_VALUE)
        dw3 = (DWORD)m_pValue;
      dwRet = (DWORD)NPN_GetValue((NPP)dw1, (NPNVariable)dw2, (void *)dw3);
      break;
    case action_npn_set_value:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      if(dw3 == DEFAULT_DWARG_VALUE)
        dw3 = (DWORD)m_pValue;

      // note that Mozilla expects boolean values not as a pointer to BOOL 
      // but rather as simply null and not null, let's convert
      if((dw2 == NPPVpluginWindowBool) ||
         (dw2 == NPPVpluginTransparentBool) ||
         (dw2 == NPPVpluginKeepLibraryInMemory)) {
        dwRet = (DWORD)NPN_SetValue((NPP)dw1, (NPPVariable)dw2, (void *)(*(BOOL *)dw3));
      } else
        dwRet = (DWORD)NPN_SetValue((NPP)dw1, (NPPVariable)dw2, (void *)dw3);
      break;
    case action_npn_invalidate_rect:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_InvalidateRect((NPP)dw1, (NPRect *)dw2);
      break;
    case action_npn_invalidate_region:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_InvalidateRegion((NPP)dw1, (NPRegion)dw2);
      break;
    case action_npn_force_redraw:
      if(dw1 == DEFAULT_DWARG_VALUE)
        dw1 = (DWORD)m_pNPInstance;
      NPN_ForceRedraw((NPP)dw1);
      break;
    default:
      assert(0);
      break;
  }

  DWORD dwTickReturn = XP_GetTickCount();
  pLogger->appendToLog(action, dwTickEnter, dwTickReturn, dwRet, dw1, dw2, dw3, dw4, dw5, dw6, dw7);

  return dwRet;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int CPluginBase::messageBox ( LPSTR  szMessage,
LPSTR  szTitle,
UINT  uStyle 
) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

Definition at line 175 of file plugbase.cpp.

{
  // if this is a stream created by tester, reflect the fact it is destroyed
  if(pStream == m_pStream)
    m_pStream = NULL;

  // if this is a script stream, reflect the fact it is destroyed too, and execute the script
  if(pStream == m_pScriptStream)
  {
    m_pScriptStream = NULL;

    if(!XP_IsFile(m_szScriptCacheFile))
      return;

    CScripter * pScripter = new CScripter();
    pScripter->associate(this);

    if(pScripter->createScriptFromFile(m_szScriptCacheFile))
    {
      char szOutput[128];
      char szExecutingScript[] = "Executing script...";

      strcpy(szOutput, szExecutingScript);
      NPN_Status(m_pNPInstance, szOutput);

      int iRepetitions = pScripter->getCycleRepetitions();
      int iDelay = pScripter->getCycleDelay();
      if(iDelay < 0)
        iDelay = 0;

      assert(pLogger != NULL);
      pLogger->resetStartTime();

      pLogger->setLogToFileFlag(TRUE);
      pLogger->blockDumpToFile(FALSE);

      for(int i = 0; i < iRepetitions; i++)
      {
        wsprintf(szOutput, "%s %i", szExecutingScript, i);
        NPN_Status(m_pNPInstance, szOutput);

        pScripter->executeScript();
        if(iDelay != 0)
          XP_Sleep(iDelay);
      }
    }
    else
      NPN_Status(m_pNPInstance, "Cannot create script...");


    pLogger->setLogToFileFlag(FALSE);

    delete pScripter;

    m_szScriptCacheFile[0] = '\0';

    NPN_Status(m_pNPInstance, "Script execution complete");
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CPluginBase::onNPP_NewStream ( NPP  pInstance,
LPSTR  szMIMEType,
NPStream pStream,
NPBool  bSeekable,
uint16 puType 
)

Definition at line 153 of file plugbase.cpp.

Here is the caller graph for this function:

void CPluginBase::onNPP_StreamAsFile ( NPP  pInstance,
NPStream pStream,
const char *  szFileName 
)

Definition at line 164 of file plugbase.cpp.

{
  if((m_pScriptStream == NULL) || (pStream != m_pScriptStream) || (szFileName == NULL))
    return;

  strcpy(m_szScriptCacheFile, szFileName);
#ifdef DEBUG
  fprintf(stderr,"CPluginBase::onNPP_StreamAsFile(), Script Cache File \"%s\"", m_szScriptCacheFile);
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void CPluginBase::outputToNativeWindow ( LPSTR  szString) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

void CPluginBase::shut ( ) [virtual]

Reimplemented in CPlugin, CPlugin, and CPlugin.

Definition at line 112 of file plugbase.cpp.

{
  if(m_wMode == NP_EMBED)
    shutEmbed();
  else
    shutFull();
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void CPluginBase::shutEmbed ( ) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:

void CPluginBase::shutFull ( ) [virtual]

Reimplemented in CPlugin, and CPlugin.

Definition at line 100 of file plugbase.cpp.

{
}

Here is the caller graph for this function:

virtual void CPluginBase::shutStandAlone ( ) [pure virtual]

Implemented in CPlugin, and CPlugin.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 67 of file plugbase.h.

Definition at line 72 of file plugbase.h.

Reimplemented in CPlugin.

Definition at line 59 of file plugbase.h.

Definition at line 70 of file plugbase.h.

Definition at line 62 of file plugbase.h.

Definition at line 61 of file plugbase.h.

Definition at line 71 of file plugbase.h.

Definition at line 63 of file plugbase.h.

Reimplemented in CPlugin, and CPlugin.

Definition at line 60 of file plugbase.h.


The documentation for this class was generated from the following files: