Back to index

lightning-sunbird  0.9+nobinonly
ScannerWnd.cpp
Go to the documentation of this file.
00001 // ScannerWnd.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "iepatcher.h"
00006 #include "ScannerWnd.h"
00007 #include "IEPatcherDlg.h"
00008 
00009 #ifdef _DEBUG
00010 #define new DEBUG_NEW
00011 #undef THIS_FILE
00012 static char THIS_FILE[] = __FILE__;
00013 #endif
00014 
00016 // CScannerWnd
00017 
00018 CScannerWnd::CScannerWnd()
00019 {
00020 }
00021 
00022 CScannerWnd::~CScannerWnd()
00023 {
00024 }
00025 
00026 
00027 BEGIN_MESSAGE_MAP(CScannerWnd, CWnd)
00028        //{{AFX_MSG_MAP(CScannerWnd)
00029        ON_WM_TIMER()
00030        ON_WM_CREATE()
00031        //}}AFX_MSG_MAP
00032 END_MESSAGE_MAP()
00033 
00034 
00036 // CScannerWnd message handlers
00037 
00038 
00039 int CScannerWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
00040 {
00041        if (CWnd::OnCreate(lpCreateStruct) == -1)
00042               return -1;
00043 
00044        SetTimer(1, 500, NULL);
00045        
00046        return 0;
00047 }
00048 
00049 
00050 void CScannerWnd::OnTimer(UINT nIDEvent) 
00051 {
00052        CIEPatcherDlg * pDlg = ((CIEPatcherApp *) AfxGetApp())->m_pIEPatcherDlg;
00053        if (pDlg)
00054        {
00055               CString sFileToProcess;
00056               if (pDlg->GetPendingFileToScan(sFileToProcess))
00057               {
00058                      PatchStatus ps = CIEPatcherDlg::ScanFile(sFileToProcess);
00059                      AfxGetMainWnd()->SendMessage(WM_UPDATEFILESTATUS, (WPARAM) ps, (LPARAM) (const TCHAR *) sFileToProcess);
00060               }
00061               else if (pDlg->GetPendingFileToPatch(sFileToProcess))
00062               {
00063                      TCHAR szDrive[_MAX_DRIVE];
00064                      TCHAR szDir[_MAX_DIR];
00065                      TCHAR szFile[_MAX_FNAME];
00066                      TCHAR szExt[_MAX_EXT];
00067 
00068                      _tsplitpath(sFileToProcess, szDrive, szDir, szFile, szExt);
00069 
00070                      CString sFileOut;
00071                      TCHAR szPath[_MAX_PATH];
00072                      sFileOut.Format(_T("moz_%s"), szFile);
00073                      _tmakepath(szPath, szDrive, szDir, sFileOut, szExt);
00074                      
00075                      PatchStatus ps;
00076                      CIEPatcherDlg::PatchFile(sFileToProcess, szPath, &ps);
00077                      AfxGetMainWnd()->SendMessage(WM_UPDATEFILESTATUS, (WPARAM) ps, (LPARAM) (const TCHAR *) sFileToProcess);
00078               }
00079        }
00080        
00081        CWnd::OnTimer(nIDEvent);
00082 }