Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
dlgauto.cpp File Reference
#include <windows.h>
#include <windowsx.h>
#include <assert.h>
#include "resource.h"
#include "guihlp.h"
#include "plugin.h"
#include "scripter.h"
#include "logger.h"
#include "xp.h"

Go to the source code of this file.

Functions

static void onCommand (HWND hWnd, int id, HWND hWndCtl, UINT codeNotify)
static BOOL onInitDialog (HWND hWnd, HWND hWndFocus, LPARAM lParam)
static void onDestroy (HWND hWnd)
BOOL CALLBACK NP_LOADDS AutoDlgProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)

Variables

CLoggerpLogger
static CScripterpScripter = NULL

Function Documentation

BOOL CALLBACK NP_LOADDS AutoDlgProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 226 of file dlgauto.cpp.

{
  switch(msg)
  {
    case WM_INITDIALOG:
      return (BOOL)HANDLE_WM_INITDIALOG(hWnd, wParam, lParam, onInitDialog);
    case WM_COMMAND:
      HANDLE_WM_COMMAND(hWnd, wParam, lParam, onCommand);
      break;
    case WM_DESTROY:
      HANDLE_WM_DESTROY(hWnd, wParam, lParam, onDestroy);
      break;

    default:
      return FALSE;
  }
  return TRUE;
}

Here is the call graph for this function:

static void onCommand ( HWND  hWnd,
int  id,
HWND  hWndCtl,
UINT  codeNotify 
) [static]

Definition at line 53 of file dlgauto.cpp.

{
  CPlugin * pPlugin = (CPlugin *)GetWindowLong(hWnd, DWL_USER);
  if(!pPlugin)
    return;

  switch (id)
  {
    case IDC_EDIT_SCRIPT_FILE_NAME:
    {
      if(codeNotify != EN_CHANGE)
        break;
      char szString[256];
      Edit_GetText(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), szString, sizeof(szString));
      int iLen = strlen(szString);
      EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), (iLen > 0));
      if(iLen <= 0)
        break;

      // synchronize log filename with current script filename
      char szLogFileName[256];
      char * p = strchr(szString, '.');

      if(p != NULL)
        *p = '\0';

      strcpy(szLogFileName, szString);
      strcat(szLogFileName, ".log");
      Edit_SetText(GetDlgItem(GetParent(hWnd), IDC_EDIT_LOG_FILE_NAME), szLogFileName);

      // restore
      if(p)
        *p = '.';

      pPlugin->updatePrefs(gp_scriptfile, FALSE, szString);

      break;
    }
    /*
    case IDC_BUTTON_STOP:
      assert(pScripter != NULL);
      pScripter->setStopAutoExecFlag(TRUE);
      ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), SW_SHOW);
      ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), SW_HIDE);
      break;
    */
    case IDC_BUTTON_GO:
    {
      pLogger->blockDumpToFile(FALSE);

      //ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), SW_HIDE);
      //ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), SW_SHOW);
      //UpdateWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP));
      EnableWindowNow(GetDlgItem(hWnd, IDC_BUTTON_GO), FALSE);

      EnableWindowNow(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), FALSE);
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_EDIT_LOG_FILE_NAME), FALSE);
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_CHECK_SHOW_LOG), FALSE);
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_CHECK_LOG_TO_FRAME), FALSE);
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_CHECK_LOG_TO_FILE), FALSE);
      BOOL bFlashWasEnabled = FALSE;
      if(IsWindowEnabled(GetDlgItem(GetParent(hWnd), IDC_BUTTON_FLUSH)))
      {
        bFlashWasEnabled = TRUE;
        EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_BUTTON_FLUSH), FALSE);
      }
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_BUTTON_CLEAR), FALSE);
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_RADIO_MODE_MANUAL), FALSE);
      EnableWindowNow(GetDlgItem(GetParent(hWnd), IDC_RADIO_MODE_AUTO), FALSE);
    
      if(pScripter != NULL)
        delete pScripter;

      pScripter = new CScripter();
      pScripter->associate(pPlugin);

      char szFileName[_MAX_PATH];
      pPlugin ->getModulePath(szFileName, sizeof(szFileName));

      char szFile[_MAX_PATH];
      Edit_GetText(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), szFile, sizeof(szFile));
      strcat(szFileName, szFile);

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

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

        ShowWindowNow(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LABEL), SW_SHOW);
        char szLeft[256];

        for(int i = 0; i < iRepetitions; i++)
        {
          wsprintf(szLeft, "%i", iRepetitions - i);
          Static_SetText(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LEFT), szLeft);
          pScripter->executeScript();
          /*
          if(pScripter->getStopAutoExecFlag())
          {
            pScripter->setStopAutoExecFlag(FALSE);
            break;
          }
          */
          if(iDelay != 0)
            XP_Sleep(iDelay);
        }
      }
      else
      {
        MessageBox(hWnd, "Script file not found or invalid", "", MB_OK | MB_ICONERROR);
      }

      delete pScripter;
      pScripter = NULL;

      Static_SetText(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LEFT), "");
      ShowWindow(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LABEL), SW_HIDE);

      //ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), SW_SHOW);
      //ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), SW_HIDE);
      EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), TRUE);

      EnableWindow(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_EDIT_LOG_FILE_NAME), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_CHECK_SHOW_LOG), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_CHECK_LOG_TO_FRAME), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_CHECK_LOG_TO_FILE), TRUE);
      if(bFlashWasEnabled)
        EnableWindow(GetDlgItem(GetParent(hWnd), IDC_BUTTON_FLUSH), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_BUTTON_CLEAR), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_RADIO_MODE_MANUAL), TRUE);
      EnableWindow(GetDlgItem(GetParent(hWnd), IDC_RADIO_MODE_AUTO), TRUE);
      break;
    }
    default:
      break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void onDestroy ( HWND  hWnd) [static]

Definition at line 217 of file dlgauto.cpp.

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

Here is the caller graph for this function:

static BOOL onInitDialog ( HWND  hWnd,
HWND  hWndFocus,
LPARAM  lParam 
) [static]

Definition at line 197 of file dlgauto.cpp.

{
  CPlugin * pPlugin = (CPlugin *)lParam;
  SetWindowLong(hWnd, DWL_USER, (long)pPlugin);

  int iTopMargin = 188;
  SetWindowPos(hWnd, NULL, 0,iTopMargin, 0,0, SWP_NOZORDER | SWP_NOSIZE);

  if (pPlugin)
    Edit_SetText(GetDlgItem(hWnd, IDC_EDIT_SCRIPT_FILE_NAME), (LPCSTR)pPlugin->m_Pref_szScriptFile);

  Static_SetText(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LEFT), "");
  ShowWindow(GetDlgItem(hWnd, IDC_STATIC_REPETITIONS_LABEL), SW_HIDE);

  ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_GO), SW_SHOW);
  ShowWindow(GetDlgItem(hWnd, IDC_BUTTON_STOP), SW_HIDE);

  return TRUE;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 47 of file np_entry.cpp.

CScripter* pScripter = NULL [static]

Definition at line 51 of file dlgauto.cpp.