Back to index

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

#include <logger.h>

Collaboration diagram for CLogger:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CLogger (LPSTR szTarget=NULL)
 ~CLogger ()
void associate (CPluginBase *pPlugin)
void setShowImmediatelyFlag (BOOL bFlagState)
void setLogToFileFlag (BOOL bFlagState)
void setLogToFrameFlag (BOOL bFlagState)
BOOL getShowImmediatelyFlag ()
BOOL getLogToFileFlag ()
BOOL getLogToFrameFlag ()
int getStringDataWrap ()
void restorePreferences (LPSTR szFileName)
BOOL onNPP_DestroyStream (NPStream *npStream)
BOOL appendToLog (NPAPI_Action action, DWORD dwTickEnter, DWORD dwTickReturn, DWORD dwRet=0L, DWORD dw1=0L, DWORD dw2=0L, DWORD dw3=0L, DWORD dw4=0L, DWORD dw5=0L, DWORD dw6=0L, DWORD dw7=0L)
void dumpLogToTarget ()
void clearLog ()
void clearTarget ()
void resetStartTime ()
void blockDumpToFile (BOOL bBlock)
void blockDumpToFrame (BOOL bBlock)
void closeLogToFile ()
void markStale ()
BOOL isStale ()

Private Attributes

CPluginBasem_pPlugin
NPP m_pPluginInstance
CLogItemListm_pLog
CLogFilem_pLogFile
BOOL m_bShowImmediately
BOOL m_bLogToFile
BOOL m_bLogToFrame
BOOL m_bBlockLogToFile
BOOL m_bBlockLogToFrame
char m_szTarget [256]
NPStreamm_pStream
char m_szStreamType [80]
DWORD m_dwStartTime
char m_szItemSeparator [80]
int m_iStringDataWrap
BOOL m_bStale

Detailed Description

Definition at line 46 of file logger.h.


Constructor & Destructor Documentation

CLogger::CLogger ( LPSTR  szTarget = NULL)

Definition at line 74 of file logger.cpp.

{
  if(m_pLogFile != NULL)
    delete m_pLogFile;

  if(m_pLog != NULL)
    delete m_pLog;
}

Member Function Documentation

BOOL CLogger::appendToLog ( NPAPI_Action  action,
DWORD  dwTickEnter,
DWORD  dwTickReturn,
DWORD  dwRet = 0L,
DWORD  dw1 = 0L,
DWORD  dw2 = 0L,
DWORD  dw3 = 0L,
DWORD  dw4 = 0L,
DWORD  dw5 = 0L,
DWORD  dw6 = 0L,
DWORD  dw7 = 0L 
)

Definition at line 119 of file logger.cpp.

{
  if(m_pLog == NULL)
    return FALSE;

  if(!m_bLogToFrame && !m_bLogToFile)
    return TRUE;

  DWORD dwTimeEnter;
  DWORD dwTimeReturn;
  if(m_dwStartTime == 0xFFFFFFFF)
  {
    m_dwStartTime = dwTickEnter;
    dwTimeEnter = 0L;
  }
  else
    dwTimeEnter = dwTickEnter - m_dwStartTime;

  dwTimeReturn = dwTickReturn - m_dwStartTime;

  LogItemStruct * plis = makeLogItemStruct(action, dwTimeEnter, dwTimeReturn, dwRet, 
                                           dw1, dw2, dw3, dw4, dw5, dw6, dw7);

  static char szOutput[1024];

  // dump to file
  if(m_bLogToFile && !m_bBlockLogToFile)
  {
    if(m_pLogFile == NULL)
    {
      m_pLogFile = new CLogFile();
      if(m_pLogFile == NULL)
        return FALSE;

      char szFile[256];
      m_pPlugin->getLogFileName(szFile, sizeof(szFile));

      if(m_pPlugin->getMode() == NP_EMBED)
      {
        if(!m_pLogFile->create(szFile, FALSE))
        {
          char szMessage[512];
          wsprintf(szMessage, "File '%s'\n probably exists. Overwrite?", szFile);
          if(IDYES == m_pPlugin->messageBox(szMessage, "", MB_ICONQUESTION | MB_YESNO))
          {
            if(!m_pLogFile->create(szFile, TRUE))
            {
              m_pPlugin->messageBox("Cannot create file.", "", MB_ICONERROR | MB_OK);
              delete m_pLogFile;
              m_pLogFile = NULL;
              return FALSE;
            }
          }
          else
          {
            delete m_pLogFile;
            m_pLogFile = NULL;
            goto Frame;
          }
        }
      }
      else // NP_FULL
      {
        if(!m_pLogFile->create(szFile, TRUE))
        {
          delete m_pLogFile;
          m_pLogFile = NULL;
          return FALSE;
        }
      }
    }

    formatLogItem(plis, szOutput, m_szItemSeparator, TRUE);
    m_pLogFile->write(szOutput);
    m_pLogFile->flush();
  }

Frame:

  // dump to frame
  if(m_bLogToFrame && !m_bBlockLogToFrame)
  {
    if(m_bShowImmediately)
    {
      BOOL dosstyle = (m_pPlugin && m_pPlugin->isStandAlone());

      int iLength = formatLogItem(plis, szOutput, "", dosstyle);

      // we should fix the output string if it contains symbols <html
      // If this is the case the browser will display the whole output
      // in HTML format while we still want it to be in plain text.
      // I do not know if this is a bug in the browser or not.
      FixUpOutputString(szOutput);

      if (m_pPlugin && m_pPlugin->isStandAlone())
      {
        m_pPlugin->outputToNativeWindow(szOutput);
      }
      else
      {
        if(m_pStream == NULL)
          NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream);

        NPN_Write(m_pPluginInstance, m_pStream, iLength, (void *)szOutput);
      }
      delete plis;
    }
    else
      m_pLog->add(plis);
  }

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 83 of file logger.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 351 of file logger.cpp.

{
  m_bBlockLogToFile = bBlock;
}

Here is the caller graph for this function:

Definition at line 356 of file logger.cpp.

{
  m_bBlockLogToFrame = bBlock;
}

Here is the caller graph for this function:

Definition at line 271 of file logger.cpp.

{
  if(m_pLog != NULL)
    delete m_pLog;

  m_pLog = new CLogItemList();
}

Here is the caller graph for this function:

Definition at line 279 of file logger.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 342 of file logger.cpp.

{
  if(m_pLogFile != NULL)
  {
    delete m_pLogFile;
    m_pLogFile = NULL;
  }
}

Here is the caller graph for this function:

Definition at line 306 of file logger.cpp.

{
  if(m_pLog == NULL)
    return;

  static char szOutput[1024];

  if (m_pPlugin && m_pPlugin->isStandAlone())
  {
    for(LogItemListElement * plile = m_pLog->m_pFirst; plile != NULL; plile = plile->pNext)
    {
      formatLogItem(plile->plis, szOutput, "", TRUE);
      m_pPlugin->outputToNativeWindow(szOutput);
    }
  }
  else
  {
    BOOL bTemporaryStream = ((m_pStream == NULL) && !getShowImmediatelyFlag());

    if(m_pStream == NULL)
      NPN_NewStream(m_pPluginInstance, m_szStreamType, m_szTarget, &m_pStream);

    for(LogItemListElement * plile = m_pLog->m_pFirst; plile != NULL; plile = plile->pNext)
    {
      int iLength = formatLogItem(plile->plis, szOutput, "");
      NPN_Write(m_pPluginInstance, m_pStream, iLength, (void *)szOutput);
    }

    if(bTemporaryStream)
    {
      NPN_DestroyStream(m_pPluginInstance, m_pStream, NPRES_DONE);
      m_pStream = NULL;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 251 of file logger.cpp.

{
  return m_bLogToFile;
}

Definition at line 261 of file logger.cpp.

{
  return m_bLogToFrame;
}

Definition at line 241 of file logger.cpp.

{
  return m_bShowImmediately;
}

Here is the caller graph for this function:

Definition at line 266 of file logger.cpp.

{
  return m_iStringDataWrap;
}

Here is the caller graph for this function:

Definition at line 366 of file logger.cpp.

{
  return m_bStale;
}

Here is the caller graph for this function:

Definition at line 361 of file logger.cpp.

{
  m_bStale = TRUE;
}

Here is the caller graph for this function:

Definition at line 97 of file logger.cpp.

{
  if(npStream == m_pStream) // Navigator itself destroys it
  {
    m_pStream = NULL;
    return TRUE;
  }
  return FALSE;
}

Here is the caller graph for this function:

Definition at line 301 of file logger.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 89 of file logger.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 246 of file logger.cpp.

{
  m_bLogToFile = bFlagState;
}

Here is the caller graph for this function:

Definition at line 256 of file logger.cpp.

{
  m_bLogToFrame = bFlagState;
}

Here is the caller graph for this function:

Definition at line 236 of file logger.cpp.

{
  m_bShowImmediately = bFlagState;
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 56 of file logger.h.

Definition at line 57 of file logger.h.

Definition at line 54 of file logger.h.

Definition at line 55 of file logger.h.

Definition at line 53 of file logger.h.

Definition at line 64 of file logger.h.

Definition at line 61 of file logger.h.

Definition at line 63 of file logger.h.

Definition at line 51 of file logger.h.

Definition at line 52 of file logger.h.

Definition at line 49 of file logger.h.

Definition at line 50 of file logger.h.

Definition at line 59 of file logger.h.

char CLogger::m_szItemSeparator[80] [private]

Definition at line 62 of file logger.h.

char CLogger::m_szStreamType[80] [private]

Definition at line 60 of file logger.h.

char CLogger::m_szTarget[256] [private]

Definition at line 58 of file logger.h.


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