Back to index

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

#include <loggerw.h>

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

List of all members.

Public Member Functions

 LoggerWin ()
 ~LoggerWin ()
BOOL platformInit ()
void platformShut ()
void dumpStringToMainWindow (char *string)
void onDestroyWindow ()
void onClear ()
BOOL init ()
void shut ()
void setOnTop (BOOL ontop)
void setToFile (BOOL tofile, char *filename)
BOOLgetMutedCalls ()
void setMutedCalls (BOOL *mutedcalls)
BOOL isMuted (NPAPI_Action action)
void logNS_NP_GetEntryPoints ()
void logNS_NP_Initialize ()
void logNS_NP_Shutdown ()
void logSPY_NP_GetEntryPoints (NPPluginFuncs *pNPPFuncs)
void logSPY_NP_Initialize ()
void logSPY_NP_Shutdown (char *mimetype)
void logCall (NPAPI_Action action, DWORD dw1=0L, DWORD dw2=0L, DWORD dw3=0L, DWORD dw4=0L, DWORD dw5=0L, DWORD dw6=0L, DWORD dw7=0L)
void logReturn (DWORD dwRet=0L)

Public Attributes

HWND hWnd
int width
int height
int x
int y
BOOL bSaveSettings
BOOL bMutedAll
BOOL bToWindow
BOOL bToConsole
BOOL bToFile
BOOL bOnTop
BOOL bSPALID
CLogFile filer
char szFile [_MAX_PATH]
BOOL bMutedCalls [TOTAL_NUMBER_OF_API_CALLS]

Detailed Description

Definition at line 43 of file loggerw.h.


Constructor & Destructor Documentation

Definition at line 52 of file loggerw.cpp.

                     : Logger(),
  hWnd(NULL),
  width(0),
  height(0),
  x(0),
  y(0),
  bSaveSettings(FALSE)
{
}

Definition at line 62 of file loggerw.cpp.

{
}

Member Function Documentation

void LoggerWin::dumpStringToMainWindow ( char *  string) [virtual]

Implements Logger.

Definition at line 153 of file loggerw.cpp.

{
  // listboxes don't want <CR> and <LF> so cut them off if any. The order is important.
  char * p = strrchr(string, '\n');
  if(p)
    *p = '\0';

  p = strrchr(string, '\r');
  if(p)
    *p = '\0';

  HWND hWndOutput = GetDlgItem(hWnd, IDC_MAIN_OUTPUT);
  ListBox_AddString(hWndOutput, string);
  int count = ListBox_GetCount(hWndOutput);
  if(count == 32767)
    ListBox_ResetContent(hWndOutput);
  ListBox_SetCaretIndex(hWndOutput, count - 1);
  UpdateWindow(hWndOutput);
}
BOOL * Logger::getMutedCalls ( ) [inherited]

Definition at line 386 of file logger.cpp.

{
  return &bMutedCalls[0];
}

Here is the caller graph for this function:

BOOL Logger::init ( ) [inherited]

Definition at line 72 of file logger.cpp.

{
  if(bToFile)
    filer.create(szFile, TRUE);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL Logger::isMuted ( NPAPI_Action  action) [inherited]

Definition at line 372 of file logger.cpp.

{
  if(bMutedAll)
    return TRUE;

  if(action >= TOTAL_NUMBER_OF_API_CALLS)
  {
    assert(0);
    return FALSE;
  }

  return bMutedCalls[action];
}

Here is the caller graph for this function:

void Logger::logCall ( NPAPI_Action  action,
DWORD  dw1 = 0L,
DWORD  dw2 = 0L,
DWORD  dw3 = 0L,
DWORD  dw4 = 0L,
DWORD  dw5 = 0L,
DWORD  dw6 = 0L,
DWORD  dw7 = 0L 
) [inherited]

Definition at line 302 of file logger.cpp.

{
  if(isMuted(action))
    return;

  static char szLog[512];

  LogItemStruct * lis = makeLogItemStruct(action, dw1, dw2, dw3, dw4, dw5, dw6, dw7);
  int iLength = formatLogItem(lis, szLog, TRUE);
  freeLogItemStruct(lis);

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 87 of file logger.cpp.

{
  char szLog[] = "NP_GetEntryPoints by Netscape\r\n";

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file logger.cpp.

{
  char szLog[] = "NP_Initialize by Netscape\r\n";

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 115 of file logger.cpp.

{
  char szLog[] = "NP_Shutdown by Netscape\r\n";

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);
}

Here is the call graph for this function:

void Logger::logReturn ( DWORD  dwRet = 0L) [inherited]

Definition at line 323 of file logger.cpp.

{
}

Here is the caller graph for this function:

void Logger::logSPY_NP_GetEntryPoints ( NPPluginFuncs pNPPFuncs) [inherited]

Definition at line 129 of file logger.cpp.

{
  char szLog[80] = "NP_GetEntryPoints by NPSpy\r\n";

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);

  if(!pNPPFuncs)
    return;

  char szLog1[80],szLog2[80],szLog3[80],szLog4[80],szLog5[80],szLog6[80],szLog7[80],
       szLog8[80],szLog9[80],szLog10[80],szLog11[80],szLog12[80],szLog13[80],szLog14[80],
       szLog15[80],szLog16[80],szLog17[80],szLog18[80],szLog19[80],szLog20[80];

  sprintf(szLog1, "\r\n");
  sprintf(szLog2, "     Plugin entry point table\r\n");
  sprintf(szLog3, "     ========================\r\n");

  if(pNPPFuncs->size)
    sprintf(szLog4, "    size          = %i\r\n", pNPPFuncs->size);
  else
    sprintf(szLog4, "    size          = not set!\r\n");

  if(pNPPFuncs->version)
    sprintf(szLog5, "    version       = %i\r\n", pNPPFuncs->version);
  else
    sprintf(szLog5, "    version       = not set!\r\n");
  
  if(pNPPFuncs->newp)
    sprintf(szLog6, "    newp          = %#08lx\r\n", pNPPFuncs->newp);
  else
    sprintf(szLog6, "    newp          = not set!\r\n");
  
  if(pNPPFuncs->destroy)
    sprintf(szLog7, "    destroy       = %#08lx\r\n", pNPPFuncs->destroy);
  else
    sprintf(szLog7, "    destroy       = not set!\r\n");
  
  if(pNPPFuncs->setwindow)
    sprintf(szLog8, "    setwindow     = %#08lx\r\n", pNPPFuncs->setwindow);
  else
    sprintf(szLog8, "    setwindow     = not set!\r\n");
  
  if(pNPPFuncs->newstream)
    sprintf(szLog9, "    newstream     = %#08lx\r\n", pNPPFuncs->newstream);
  else
    sprintf(szLog9, "    newstream     = not set!\r\n");
  
  if(pNPPFuncs->destroystream)
    sprintf(szLog10, "    destroystream = %#08lx\r\n", pNPPFuncs->destroystream);
  else
    sprintf(szLog10, "    destroystream = not set!\r\n");
  
  if(pNPPFuncs->asfile)
    sprintf(szLog11, "    asfile        = %#08lx\r\n", pNPPFuncs->asfile);
  else
    sprintf(szLog11, "    asfile        = not set!\r\n");
  
  if(pNPPFuncs->writeready)
    sprintf(szLog12, "    writeready    = %#08lx\r\n", pNPPFuncs->writeready);
  else
    sprintf(szLog12, "    writeready    = not set!\r\n");
  
  if(pNPPFuncs->write)
    sprintf(szLog13, "    write         = %#08lx\r\n", pNPPFuncs->write);
  else
    sprintf(szLog13, "    write         = not set!\r\n");
  
  if(pNPPFuncs->print)
    sprintf(szLog14, "    print         = %#08lx\r\n", pNPPFuncs->print);
  else
    sprintf(szLog14, "    print         = not set!\r\n");
  
  if(pNPPFuncs->event)
    sprintf(szLog15, "    event         = %#08lx\r\n", pNPPFuncs->event);
  else
    sprintf(szLog15, "    event         = not set!\r\n");
  
  if(pNPPFuncs->urlnotify)
    sprintf(szLog16, "    urlnotify     = %#08lx\r\n", pNPPFuncs->urlnotify);
  else
    sprintf(szLog16, "    urlnotify     = not set!\r\n");
  
  if(pNPPFuncs->javaClass)
    sprintf(szLog17, "    javaClass     = %#08lx\r\n", pNPPFuncs->javaClass);
  else
    sprintf(szLog17, "    javaClass     = not set!\r\n");
  
  if(pNPPFuncs->getvalue)
    sprintf(szLog18, "    getvalue      = %#08lx\r\n", pNPPFuncs->getvalue);
  else
    sprintf(szLog18, "    getvalue      = not set!\r\n");
  
  if(pNPPFuncs->setvalue)
    sprintf(szLog19, "    setvalue      = %#08lx\r\n", pNPPFuncs->setvalue);
  else
    sprintf(szLog19, "    setvalue      = not set!\r\n");

  sprintf(szLog20, "\r\n");

  if(bToConsole)
  {
    printf("%s", szLog1); printf("%s", szLog2); printf("%s", szLog3); printf("%s", szLog4);
    printf("%s", szLog5); printf("%s", szLog6); printf("%s", szLog7); printf("%s", szLog8);
    printf("%s", szLog9); printf("%s", szLog10); printf("%s", szLog11); printf("%s", szLog12);
    printf("%s", szLog13); printf("%s", szLog14); printf("%s", szLog15); printf("%s", szLog16);
    printf("%s", szLog17); printf("%s", szLog18); printf("%s", szLog19); printf("%s", szLog20);
  }
  
  if(bToFile)
  {
    filer.write(szLog1); filer.write(szLog2); filer.write(szLog3); filer.write(szLog4);
    filer.write(szLog5); filer.write(szLog6); filer.write(szLog7); filer.write(szLog8);
    filer.write(szLog9); filer.write(szLog10); filer.write(szLog11); filer.write(szLog12);
    filer.write(szLog13); filer.write(szLog14); filer.write(szLog15); filer.write(szLog16);
    filer.write(szLog17); filer.write(szLog18); filer.write(szLog19); filer.write(szLog20);
  }
  
  if(bToWindow)
  {
    dumpStringToMainWindow(szLog1); dumpStringToMainWindow(szLog2);
    dumpStringToMainWindow(szLog3); dumpStringToMainWindow(szLog4);
    dumpStringToMainWindow(szLog5); dumpStringToMainWindow(szLog6);
    dumpStringToMainWindow(szLog7); dumpStringToMainWindow(szLog8);
    dumpStringToMainWindow(szLog9); dumpStringToMainWindow(szLog10);
    dumpStringToMainWindow(szLog11); dumpStringToMainWindow(szLog12);
    dumpStringToMainWindow(szLog13); dumpStringToMainWindow(szLog14);
    dumpStringToMainWindow(szLog15); dumpStringToMainWindow(szLog16);
    dumpStringToMainWindow(szLog17); dumpStringToMainWindow(szLog18);
    dumpStringToMainWindow(szLog19); dumpStringToMainWindow(szLog20);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 268 of file logger.cpp.

{
  char szLog[] = "NP_Initialize by NPSpy\r\n";

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Logger::logSPY_NP_Shutdown ( char *  mimetype) [inherited]

Definition at line 282 of file logger.cpp.

{
  char szLog[512] = "NP_Shutdown by NPSpy\r\n";
  if(mimetype)
  {
    strcat(szLog, " for \"");
    strcat(szLog, mimetype);
    strcat(szLog, "\"");
  }

  if(bToConsole)
    printf("%s", szLog);
  
  if(bToFile)
    filer.write(szLog);

  if(bToWindow)
    dumpStringToMainWindow(szLog);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 173 of file loggerw.cpp.

{
  HWND hWndOutput = GetDlgItem(hWnd, IDC_MAIN_OUTPUT);
  ListBox_ResetContent(hWndOutput);
  UpdateWindow(hWndOutput);
}

Here is the caller graph for this function:

Definition at line 148 of file loggerw.cpp.

{
  hWnd = NULL;
}

Here is the caller graph for this function:

Implements Logger.

Definition at line 66 of file loggerw.cpp.

{
  WNDCLASS wc;
  wc.style         = 0; 
  wc.lpfnWndProc   = DefDlgProc; 
  wc.cbClsExtra    = 0; 
  wc.cbWndExtra    = DLGWINDOWEXTRA; 
  wc.hInstance     = hInst; 
  wc.hIcon         = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON_APP)); 
  wc.hCursor       = LoadCursor(0, IDC_ARROW); 
  wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
  wc.lpszMenuName  = NULL; 
  wc.lpszClassName = szClassName;

  if(!RegisterClass(&wc))
    return FALSE;

  // restore prefs
  ProfileWin profile;

  profile.getBool(NPSPY_REG_KEY_ONTOP, &bOnTop);
  profile.getBool(NPSPY_REG_KEY_LOGTOWINDOW, &bToWindow);
  profile.getBool(NPSPY_REG_KEY_LOGTOCONSOLE, &bToConsole);
  profile.getBool(NPSPY_REG_KEY_LOGTOFILE, &bToFile);
  profile.getBool(NPSPY_REG_KEY_SPALID, &bSPALID);
  profile.getString(NPSPY_REG_KEY_LOGFILENAME, szFile, strlen(szFile));

  for(int i = 1; i < TOTAL_NUMBER_OF_API_CALLS; i++)
  {
    BOOL selected = TRUE;
    if(profile.getBool(ActionName[i], &selected))
      bMutedCalls[i] = !selected;
  }
  
  if(!profile.getSizeAndPosition(&width, &height, &x, &y))
  {
    width = 0;
    height = 0;
    x = 0;
    y = 0;
  }

  hWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG_MAIN), GetDesktopWindow(), (DLGPROC)MainDlgProc, (LPARAM)this);
  if(hWnd == NULL)
  {
    UnregisterClass(szClassName, hInst);
    return FALSE;
  }

  if(bOnTop)
    SetWindowPos(hWnd, bOnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE);

  return TRUE;
}

Here is the call graph for this function:

Implements Logger.

Definition at line 121 of file loggerw.cpp.

{
  if(hWnd != NULL)
  {
    char szLog[] = "--- GOING AWAY... PRESS SPACE BAR TO CONTINUE ---";
    HWND hWndOutput = GetDlgItem(hWnd, IDC_MAIN_OUTPUT);
    ListBox_AddString(hWndOutput, "");
    ListBox_AddString(hWndOutput, szLog);
    int count = ListBox_GetCount(hWndOutput);
    ListBox_SetCaretIndex(hWndOutput, count - 1);
    UpdateWindow(hWndOutput);

    DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG_PAUSE), hWnd, (DLGPROC)PauseDlgProc);

    ProfileWin profile;

    RECT rc;
    if(GetWindowRect(hWnd, &rc))
      profile.setSizeAndPosition(rc.right - rc.left, rc.bottom - rc.top, rc.left, rc.top);

    DestroyWindow(hWnd);
    hWnd = NULL;
  }

  UnregisterClass(szClassName, hInst);
}

Here is the call graph for this function:

void Logger::setMutedCalls ( BOOL mutedcalls) [inherited]

Definition at line 391 of file logger.cpp.

{
  for(int i = 0; i < sizeof(bMutedCalls)/sizeof(BOOL); i++)
    bMutedCalls[i] = mutedcalls[i];
}

Here is the caller graph for this function:

void Logger::setOnTop ( BOOL  ontop) [inherited]

Definition at line 327 of file logger.cpp.

{
  bOnTop = ontop;
}
void Logger::setToFile ( BOOL  tofile,
char *  filename 
) [inherited]

Definition at line 332 of file logger.cpp.

{
  if(!filename || !*filename || (strlen(filename) > _MAX_PATH))
  {
    bToFile = FALSE;
    return;
  }

  //don't screw up the file on false call
  BOOL samefile = (stricmp(szFile, filename) == 0);
  BOOL sameaction = (bToFile == tofile);
  
  if(sameaction)
  {
    if(samefile)
      return;

    strcpy(szFile, filename);

    if(bToFile)
    {
      filer.close();
      filer.create(szFile, TRUE);
    }
  }

  if(!sameaction)
  {
    bToFile = tofile;

    if(!samefile)
      strcpy(szFile, filename);

    if(bToFile)
      filer.create(szFile, TRUE);
    else
      filer.close();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void Logger::shut ( ) [inherited]

Definition at line 80 of file logger.cpp.

{
  filer.close();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

BOOL Logger::bMutedAll [inherited]

Definition at line 51 of file logger.h.

Definition at line 65 of file logger.h.

BOOL Logger::bOnTop [inherited]

Definition at line 55 of file logger.h.

Reimplemented from Logger.

Definition at line 51 of file loggerw.h.

BOOL Logger::bSPALID [inherited]

Definition at line 56 of file logger.h.

BOOL Logger::bToConsole [inherited]

Definition at line 53 of file logger.h.

BOOL Logger::bToFile [inherited]

Definition at line 54 of file logger.h.

BOOL Logger::bToWindow [inherited]

Definition at line 52 of file logger.h.

CLogFile Logger::filer [inherited]

Definition at line 58 of file logger.h.

Definition at line 48 of file loggerw.h.

Definition at line 46 of file loggerw.h.

char Logger::szFile[_MAX_PATH] [inherited]

Definition at line 61 of file logger.h.

Definition at line 47 of file loggerw.h.

Definition at line 49 of file loggerw.h.

Definition at line 50 of file loggerw.h.


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