home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 April / enter-2004-04.iso / files / httrack-3.30.exe / {app} / src_win / WinHTTrack / WinHTTrack.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-07  |  21.3 KB  |  866 lines

  1. // WinHTTrack.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "WinHTTrack.h"
  6.  
  7. #include "Shell.h"
  8. #include "winsock.h"
  9.  
  10. #include "wid1.h"
  11. #include "maintab.h"
  12.  
  13. #include "MainFrm.h"
  14. #include "splitter.h"
  15. #include "about.h"
  16.  
  17. #include "WinHTTrackDoc.h"
  18. #include "WinHTTrackView.h"
  19.  
  20. #include "inprogress.h"
  21.  
  22. /* HTS - HTTRACK */
  23. extern "C" {
  24.   #include "htsbase.h"
  25.   #include "htsglobal.h"
  26. };
  27.  
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33.  
  34. //
  35. #include "DialogContainer.h"
  36. #include "InfoUrl.h"
  37.  
  38. // PAS de domodal a l'exterieur!!!!!
  39. #include "wizard.h"
  40. #include "wizard2.h"
  41. #include "WizLinks.h"
  42. extern char WIZ_question[1000];
  43. extern char WIZ_reponse[1000];
  44.  
  45.  
  46. extern Wid1* dialog1;
  47. extern CMainTab* maintab;
  48. extern Cinprogress* inprogress;
  49. extern CShellApp* CShellApp_app;
  50. extern int termine;
  51. extern int termine_requested;
  52. extern int soft_term_requested;
  53. extern int shell_terminated;
  54. extern CInfoUrl* _Cinprogress_inst;
  55. extern int LibRasUse;
  56.  
  57. extern "C" {
  58.   char* hts_rootdir(char* file);
  59. };
  60.  
  61.  
  62. // rmdir
  63. #include <direct.h>
  64.  
  65. // linput
  66. extern "C" {
  67.   void linput(FILE* fp,char* s,int max);
  68.   void linput_trim(FILE* fp,char* s,int max);
  69.   void linput_cpp(FILE* fp,char* s,int max);
  70. };
  71.  
  72. /* WinHTTrack refresh Mutex */
  73. HANDLE WhttMutex;
  74.  
  75. /* Location */
  76. char* WhttLocation="";
  77.  
  78.  
  79. // HTTrack main vars
  80. HWND App_Main_HWND;
  81. CSplitterFrame* this_CSplitterFrame=NULL;
  82. HICON httrack_icon;
  83. // Helper
  84. LaunchHelp* HtsHelper=NULL;
  85.  
  86. // dirtreeview
  87. #include "DirTreeView.h"
  88. extern CDirTreeView* this_DirTreeView;
  89.  
  90. // New Project
  91. #include "NewProj.h"
  92. extern CNewProj* dialog0;
  93.  
  94.  
  95. // InfoEnd
  96. #include "infoend.h"
  97. extern Cinfoend* this_Cinfoend;
  98.  
  99. // Pointeur sur nous
  100. CWinHTTrackApp* this_app=NULL;
  101.  
  102. // fexist
  103. extern "C" int fexist(char*);
  104.  
  105. /////////////////////////////////////////////////////////////////////////////
  106. // CWinHTTrackApp
  107.  
  108. BEGIN_MESSAGE_MAP(CWinHTTrackApp, CWinApp)
  109.     //{{AFX_MSG_MAP(CWinHTTrackApp)
  110.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  111.     ON_COMMAND(ID_FILE_SAVE, OnFileSave)
  112.     ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
  113.     ON_COMMAND(ID_FILE_MRU_FILE1, OnFileMruFile1)
  114.     //}}AFX_MSG_MAP
  115.   ON_COMMAND(wm_ViewRestart,OnViewRestart)
  116.   ON_COMMAND(wm_WizRequest1,OnWizRequest1)
  117.   ON_COMMAND(wm_WizRequest2,OnWizRequest2)
  118.   ON_COMMAND(wm_WizRequest3,OnWizRequest3)
  119.     // Standard file based document commands
  120.     //ON_COMMAND(ID_FILE_WIZARD, OnWizard)
  121.     ON_COMMAND(ID_FILE_NEW, OnFileNew)
  122.     ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  123.     ON_COMMAND(ID_FILE_DELETE_PROJ, OnFileDelete)
  124.     ON_COMMAND(ID_FILE_BROWSE_SIT, OnBrowseWebsites)
  125.   ON_COMMAND(IDC_langprefs,Onipabout)
  126.   ON_COMMAND(ID_ABOUT,Onipabout)
  127.   ON_COMMAND(ID_UPDATE,OnUpdate)
  128.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  129.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  130.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  131.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  132.   // Forward to inprogress
  133.   ON_BN_CLICKED(ID_LOAD_OPTIONS,FwOnLoadprofile)
  134.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,FwOnSaveprofile)
  135.     ON_BN_CLICKED(ID_LoadDefaultOptions, FwOnLoaddefault)
  136.     ON_BN_CLICKED(ID_SaveDefaultOptions, FwOnSavedefault)
  137.     ON_BN_CLICKED(ID_ClearDefaultOptions,FwOnResetdefault)
  138.   //
  139.   ON_BN_CLICKED(ID_WINDOW_HIDE,FwOnhide)
  140.   //
  141.     ON_BN_CLICKED(ID_OPTIONS_MODIFY,FwOnModifyOpt)
  142.     ON_BN_CLICKED(ID_FILE_PAUSE,FwOnPause)
  143.     ON_BN_CLICKED(ID_LOG_VIEWLOG,FwOniplogLog)
  144.     ON_BN_CLICKED(ID_LOG_VIEWERRORLOG,FwOniplogErr)
  145.     ON_BN_CLICKED(ID_LOG_VIEWTRANSFERS,FwOnViewTransfers)
  146. END_MESSAGE_MAP()
  147.  
  148. /////////////////////////////////////////////////////////////////////////////
  149. // CWinHTTrackApp construction
  150.  
  151. CWinHTTrackApp::CWinHTTrackApp()
  152. {
  153.   // HTTrack inits
  154.   CreateMutex(NULL, FALSE, "WinHTTrack_RUN");
  155.   HtsHelper = new LaunchHelp();
  156. }
  157.  
  158. CWinHTTrackApp::~CWinHTTrackApp()
  159. {
  160.   DeleteTabs();
  161.   delete HtsHelper;
  162.   HtsHelper=NULL;
  163. }
  164.  
  165. /////////////////////////////////////////////////////////////////////////////
  166. // The one and only CWinHTTrackApp object
  167.  
  168. CWinHTTrackApp theApp;
  169.  
  170. /////////////////////////////////////////////////////////////////////////////
  171. // CWinHTTrackApp initialization
  172.  
  173. void InitCBErrMsg(char* msg, char* file, int line) {
  174.   CString st;
  175.   st.Format("A fatal error has occured\r\n%s"
  176.     "\r\nin file '%s', line %d\r\n"
  177.     "Please report the problem at http://forum.httrack.com\r\n"
  178.     "using the CRASH.TXT file generated in the WinHTTrack directory\r\n"
  179.     "Thank you!", msg, file, line);
  180.   AfxMessageBox(st, MB_OK|MB_APPLMODAL|MB_SYSTEMMODAL|MB_ICONSTOP);
  181. }
  182. void InitCBErr() {
  183.   htsCallbackErr = InitCBErrMsg;
  184. }
  185.  
  186. int Eval_Exception( void );
  187.  
  188. int Eval_Exception ( int n_except )
  189. {
  190.     AfxMessageBox("error");
  191.  
  192.     return 0;
  193. }
  194.  
  195. extern "C" {
  196.   int hts_init(void);
  197.   void hts_uninit(void);
  198. }
  199. BOOL CWinHTTrackApp::InitInstance()
  200. {
  201.   InitCBErr();
  202.   hts_init();
  203.  
  204.   WhttMutex = CreateMutex(NULL,FALSE,NULL);
  205.  
  206.   // Change the registry key under which our settings are stored.
  207.   // TODO: You should modify this string to be something appropriate
  208.   // such as the name of your company or organization.
  209.   SetRegistryKey("WinHTTrack Website Copier");
  210.   LANG_INIT();    // petite init langue
  211.   
  212.   /* INDISPENSABLE pour le drag&drop! */
  213.   if (!AfxOleInit())
  214.   {
  215.       AfxMessageBox(LANG(LANG_F1));
  216.       return FALSE;
  217.   }
  218.   AfxEnableControlContainer();
  219.   
  220.   // Pointeur sur CShellApp
  221.   CShellApp_app=&app;
  222.   this_app=this;
  223.   _Cinprogress_inst=NULL;
  224.   LibRasUse=0;
  225.  
  226.     // Standard initialization
  227.     // If you are not using these features and wish to reduce the size
  228.     //  of your final executable, you should remove from the following
  229.     //  the specific initialization routines you do not need.
  230.  
  231. #ifdef _AFXDLL
  232.     Enable3dControls();            // Call this when using MFC in a shared DLL
  233. #else
  234.     Enable3dControlsStatic();    // Call this when linking to MFC statically
  235. #endif
  236.  
  237.  
  238.   httrack_icon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  239.  
  240.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  241.  
  242.     // Register the application's document templates.  Document templates
  243.     //  serve as the connection between documents, frame windows and views.
  244.  
  245.   // DOC //
  246.     CMultiDocTemplate* pDocTemplate;
  247.     pDocTemplate = new CMultiDocTemplate(
  248.         IDR_MAINFRAME,
  249.         RUNTIME_CLASS(CWinHTTrackDoc),
  250.         RUNTIME_CLASS(CSplitterFrame),       // main SDI frame window
  251.         RUNTIME_CLASS(CView)); 
  252.     AddDocTemplate(pDocTemplate);
  253.  
  254.   /*
  255.     CMDIFrameWnd* pMainFrame = new CMDIFrameWnd;
  256.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  257.         return FALSE;
  258.   */
  259.  
  260.     // create main window
  261.     CMainFrame* pMainFrame = new CMainFrame;
  262.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  263.         return FALSE;
  264.     m_pMainWnd = pMainFrame;
  265.     int nCmdShow = m_nCmdShow;
  266.  
  267.  
  268.   // Also in this example, there is only one menubar shared between
  269.     //  all the views.  The automatic menu enabling support of MFC
  270.     //  will disable the menu items that don't apply based on the
  271.     //  currently active view.  The one MenuBar is used for all
  272.     //  document types, including when there are no open documents.
  273.  
  274.   // enable file manager drag/drop and DDE Execute open
  275.     pMainFrame->DragAcceptFiles();
  276.  
  277.   // Now finally show the main menu
  278.     //pMainFrame->ShowWindow(m_nCmdShow);
  279.     //pMainFrame->UpdateWindow();
  280.     m_pMainWnd = pMainFrame;
  281.  
  282.   // command line arguments are ignored, create a new (empty) document
  283.     //OnFileNew();
  284.   // DOC //
  285.  
  286.     // Parse command line for standard shell commands, DDE, file open
  287.     CCommandLineInfo cmdInfo;
  288.     ParseCommandLine(cmdInfo);
  289.  
  290.   hts_rootdir((char*)AfxGetApp()->m_pszHelpFilePath);
  291.  
  292.   // Restore position
  293.     ((CMainFrame*)m_pMainWnd)->InitialShowWindow(nCmdShow);
  294.     pMainFrame->UpdateWindow();
  295.  
  296.     // Dispatch commands specified on the command line
  297.     if (!ProcessShellCommand(cmdInfo))
  298.         return FALSE;
  299.  
  300.   // Init Winsock
  301.   WSockInit();
  302.  
  303.     // The one and only window has been initialized, so show and update it.
  304.     //m_pMainWnd->ShowWindow(SW_SHOW);
  305.     //m_pMainWnd->UpdateWindow();
  306.  
  307.   /*CWinApp* app=AfxGetApp();
  308.   POSITION pos;
  309.   pos=app->GetFirstDocTemplatePosition();
  310.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  311.   pos=templ->GetFirstDocPosition();
  312.   CDocument* doc  = templ->GetNextDoc(pos);
  313.  
  314.   CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CTest );
  315.   CObject* pObject = pRuntimeClass->CreateObject();
  316.   ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CTest ) ) );
  317.   
  318.   doc->AddView((CView*) pObject);
  319.   */
  320.  
  321.   {
  322.     // enable file manager drag/drop and DDE Execute open
  323.     EnableShellOpen();
  324.     RegisterShellFileTypes();
  325.     // register "New File" handler
  326.     HKEY phkResult;
  327.     DWORD creResult;
  328.     if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  329.       RegCloseKey(phkResult);
  330.       if (RegCreateKeyEx(HKEY_CLASSES_ROOT,".whtt\\ShellNew",0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&phkResult,&creResult)==ERROR_SUCCESS) {
  331.         char voidbuff='\0';
  332.         RegSetValueEx(phkResult,"NullFile",0,REG_SZ,(LPBYTE)&voidbuff,1);
  333.         RegCloseKey(phkResult);
  334.       }
  335.     }   
  336.  
  337.     // Infos la 1ere fois!
  338.     CWinApp* pApp = AfxGetApp();
  339.     if (pApp->GetProfileInt("Interface","FirstRun",0) != 3) {
  340.       pApp->WriteProfileInt("Interface","FirstRun",3);
  341.  
  342.       Cabout about;
  343.       about.DoModal();
  344.       
  345.       // Default proxy?
  346.       if (maintab) {
  347.         maintab->DefineDefaultProxy();
  348.         if (maintab->DoModal()!=IDCANCEL) {
  349.           // Default proxy values
  350.           CString strSection       = "OptionsValues";
  351.           MyWriteProfileString("",strSection, "Proxy",maintab->m_option10.m_proxy);
  352.           MyWriteProfileString("",strSection, "Port",maintab->m_option10.m_port);
  353.         }
  354.         maintab->UnDefineDefaultProxy();
  355.       }
  356.     }
  357.   }
  358.   
  359.  
  360. #ifdef HTTRACK_AFF_WARNING
  361. #ifndef _DEBUG
  362.   AfxMessageBox("--WARNING--\r\n"HTTRACK_AFF_WARNING);
  363. #endif
  364. #endif
  365.  
  366.   return TRUE;
  367. }
  368.  
  369.  
  370. BOOL CWinHTTrackApp::WSockInit() {
  371.   // Initialiser WINSOCK
  372.   WORD   wVersionRequested; /* requested version WinSock API */ 
  373.   WSADATA wsadata;        /* Windows Sockets API data */
  374.   {
  375.     int stat;
  376.     wVersionRequested = 0x0101;
  377.     stat = WSAStartup( wVersionRequested, &wsadata );
  378.     if (stat != 0) {
  379.       //HTS_PANIC_PRINTF("Winsock not found!\n");
  380.     } else if (LOBYTE(wsadata.wVersion) != 1  && HIBYTE(wsadata.wVersion) != 1) {
  381.       //HTS_PANIC_PRINTF("WINSOCK.DLL does not support version 1.1\n");
  382.       WSACleanup();
  383.     }
  384.   }
  385.   // Fin Initialiser WINSOCK
  386.   return TRUE;
  387. }
  388.  
  389. /////////////////////////////////////////////////////////////////////////////
  390. // CAboutDlg dialog used for App About
  391.  
  392. /*
  393. class CAboutDlg : public CDialog
  394. {
  395. public:
  396.     CAboutDlg();
  397.  
  398. // Dialog Data
  399.     //{{AFX_DATA(CAboutDlg)
  400.     enum { IDD = IDD_ABOUTBOX };
  401.     //}}AFX_DATA
  402.  
  403.     // ClassWizard generated virtual function overrides
  404.     //{{AFX_VIRTUAL(CAboutDlg)
  405.     protected:
  406.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  407.     //}}AFX_VIRTUAL
  408.  
  409. // Implementation
  410. protected:
  411.     //{{AFX_MSG(CAboutDlg)
  412.         // No message handlers
  413.     //}}AFX_MSG
  414.     DECLARE_MESSAGE_MAP()
  415. };
  416.  
  417. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  418. {
  419.     //{{AFX_DATA_INIT(CAboutDlg)
  420.     //}}AFX_DATA_INIT
  421. }
  422.  
  423. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  424. {
  425.     CDialog::DoDataExchange(pDX);
  426.     //{{AFX_DATA_MAP(CAboutDlg)
  427.     //}}AFX_DATA_MAP
  428. }
  429.  
  430. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  431.     //{{AFX_MSG_MAP(CAboutDlg)
  432.         // No message handlers
  433.     //}}AFX_MSG_MAP
  434. END_MESSAGE_MAP()
  435. */
  436.  
  437. // App command to run the dialog
  438. void CWinHTTrackApp::OnAppAbout()
  439. {
  440.   Cabout about;
  441.   about.DoModal();
  442. //    CAboutDlg aboutDlg;
  443. //    aboutDlg.DoModal();
  444. }
  445.  
  446.  
  447. /* Request: Set new view in the splitter window (when clicking on finished, for example) */
  448. extern "C" {
  449.   int hts_resetvar(void);
  450. }
  451. void CWinHTTrackApp::OnViewRestart() {
  452.   //CloseAllDocuments(FALSE);
  453.   //OnFileNew();
  454.  
  455.   /* Free library */
  456.   WHTT_LOCK();
  457.   hts_resetvar();
  458.   WHTT_UNLOCK();
  459.  
  460.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  461. }
  462.  
  463. void CWinHTTrackApp::OnWizRequest1() {
  464.   wizard diawiz;
  465.   diawiz.m_question=WIZ_question;
  466.   diawiz.DoModal();
  467.   strcpybuff(WIZ_reponse,diawiz.m_reponse);
  468. }
  469.  
  470. void CWinHTTrackApp::OnWizRequest2() {
  471.   wizard2 diawiz2;
  472.   diawiz2.m_question=WIZ_question;
  473.   if (diawiz2.DoModal()==IDOK)
  474.   strcpybuff(WIZ_reponse,"YES");
  475.   else
  476.     strcpybuff(WIZ_reponse,"NO");
  477. }
  478.  
  479. void CWinHTTrackApp::OnWizRequest3() {
  480.   WizLinks diawiz3;
  481.   diawiz3.m_url=WIZ_question;
  482.   if (diawiz3.DoModal()==IDskipall)
  483.     strcpybuff(WIZ_reponse,"*");
  484.   else
  485.     switch(diawiz3.m_lnk) {
  486.     case 0:
  487.       strcpybuff(WIZ_reponse,"0");
  488.       break;
  489.     case 1:
  490.       strcpybuff(WIZ_reponse,"1");
  491.       break;
  492.     case 2:
  493.       strcpybuff(WIZ_reponse,"2");
  494.       break;
  495.     case 3:
  496.       strcpybuff(WIZ_reponse,"4");
  497.       break;
  498.     case 4:
  499.       strcpybuff(WIZ_reponse,"5");
  500.       break;
  501.     case 5:
  502.       strcpybuff(WIZ_reponse,"6");
  503.       break;
  504.     default:
  505.       strcpybuff(WIZ_reponse,"");
  506.       break;
  507.   }
  508. }
  509.  
  510.  
  511. //
  512.  
  513.  
  514. /////////////////////////////////////////////////////////////////////////////
  515. // CWinHTTrackApp message handlers
  516.  
  517. // Ne fait pas partie de la classe
  518. /*
  519. UINT RunBackEngine( LPVOID pP ) {
  520.   static int running=0;
  521.   if (running)
  522.     return 0;
  523.   running=1;
  524.   {
  525.     CWinApp* app=AfxGetApp();
  526.     POSITION pos;
  527.     pos=app->GetFirstDocTemplatePosition();
  528.     CDocTemplate* templ = app->GetNextDocTemplate(pos);
  529.     pos=templ->GetFirstDocPosition();
  530.     CDocument* doc  = templ->GetNextDoc(pos);
  531.     pos=doc->GetFirstViewPosition();
  532.     CView*     view = doc->GetNextView(pos);
  533.     App_Main_HWND=view->m_hWnd;
  534.   }
  535.   //
  536.   CShellApp app;
  537.   app.InitInstance();
  538.   running=0;
  539.   return 0;
  540. }
  541. */
  542.  
  543. /*
  544. void CWinHTTrackApp::OnWizard() {
  545.   //this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  546. }
  547. */
  548.  
  549. afx_msg void CWinHTTrackApp::OnFileNew( ) {
  550.   OpenDocumentFile("");
  551. }
  552.  
  553. afx_msg void CWinHTTrackApp::OnFileOpen( ) {
  554.   this->CWinApp::OnFileOpen();
  555. }
  556.  
  557. void CWinHTTrackApp::OnFileSave() {
  558. }
  559.  
  560. void CWinHTTrackApp::OnFileSaveAs() 
  561. {
  562.     // TODO: Add your command handler code here
  563.     
  564. }
  565.  
  566. void CWinHTTrackApp::OnFileDelete()
  567. {
  568.   static char szFilter[256];
  569.   strcpybuff(szFilter,"WinHTTrack Website Copier Project (*.whtt)|*.whtt||");
  570.   CFileDialog* dial = new CFileDialog(true,"whtt",NULL,OFN_HIDEREADONLY,szFilter);
  571.   if (dial->DoModal() == IDOK) {
  572.     CString st=dial->GetPathName();
  573.     if (fexist((char*) LPCTSTR(st))) {
  574.       int pos=st.ReverseFind('.');
  575.       CString dir=st.Left(pos)+"\\";
  576.       char msg[1000];
  577.       sprintf(msg,"%s\r\n%s",LANG_DELETECONF,dir);
  578.       if (AfxMessageBox(msg,MB_OKCANCEL)==IDOK) {
  579.         if (remove(st)) {
  580.           AfxMessageBox("Error deleting "+st);
  581.         } else {
  582.           RmDir(dir);
  583.         }
  584.       }
  585.     } else
  586.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  587.   }
  588.   delete dial;
  589. }
  590.  
  591. void CWinHTTrackApp::OnBrowseWebsites()
  592. {
  593.   CString st=dialog0->GetBasePath();
  594.  
  595.   if (st.GetLength()<=1) {
  596.     CString strSection       = "DefaultValues";    
  597.     CWinApp* pApp = AfxGetApp();
  598.     st = pApp->GetProfileString(strSection, "BasePath");
  599.     st += "\\";
  600.   }
  601.  
  602.   st+="index.html";
  603.   ShellExecute(NULL,"open",st,"","",SW_RESTORE);    
  604. }
  605.  
  606. BOOL CWinHTTrackApp::RmDir(CString srcpath) {
  607.   CWaitCursor wait;
  608.  
  609.   if (srcpath.GetLength()==0)
  610.     return FALSE;
  611.   CString path=srcpath;
  612.   WIN32_FIND_DATA find;
  613.   if (path.Right(1)!="\\")
  614.     path+="\\";  
  615.   HANDLE h = FindFirstFile(path+"*.*",&find);
  616.   if (h != INVALID_HANDLE_VALUE) {
  617.     do {
  618.       if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_SYSTEM ))
  619.       if (strcmp(find.cFileName,".."))
  620.       if (strcmp(find.cFileName,"."))
  621.         if (!(find.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY )) {
  622.           if (remove(path+find.cFileName)) {
  623.             AfxMessageBox("Error deleting "+path+find.cFileName);
  624.             return FALSE;
  625.           }
  626.         } else {
  627.           if (!RmDir(path+find.cFileName))
  628.             return FALSE;
  629.         }
  630.     } while(FindNextFile(h,&find));
  631.     FindClose(h);
  632.   }
  633.   if (rmdir(srcpath)) {
  634.     AfxMessageBox("Error deleting "+srcpath);
  635.     return FALSE;
  636.   }
  637.   return TRUE;
  638. }
  639.  
  640.  
  641. void CWinHTTrackApp::OnFileMruFile1() 
  642. {
  643.     // TODO: Add your command handler code here
  644.     
  645. }
  646.  
  647. void CWinHTTrackApp::Onipabout() 
  648. {
  649.   Cabout about;
  650.   about.DoModal();
  651. }
  652.  
  653. void CWinHTTrackApp::OnUpdate() 
  654. {
  655.   CString st;
  656.   st.Format(HTS_UPDATE_WEBSITE,HTS_PLATFORM,LANGUAGE_NAME);
  657.   HtsHelper->Help(st);
  658. }
  659.  
  660. // Appel aide
  661. BOOL CWinHTTrackApp::OnHelpInfo2() {
  662.   return OnHelpInfo(NULL);
  663. }
  664.  
  665. BOOL CWinHTTrackApp::OnHelpInfo(HELPINFO* dummy) 
  666. {
  667.   HtsHelper->Help("step2.html");
  668.   return true;
  669. }
  670.  
  671. // Forwards
  672.  
  673. void CWinHTTrackApp::FwOnhide() {
  674.   if (this_CSplitterFrame)
  675.     this_CSplitterFrame->Onhide();
  676.   else
  677.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  678. }
  679.  
  680. void CWinHTTrackApp::FwOnLoadprofile() {
  681.   if ((dialog1!=NULL) && (maintab!=NULL))
  682.     dialog1->OnLoadprofile();
  683.   else
  684.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  685. }
  686. void CWinHTTrackApp::FwOnSaveprofile() {
  687.   if ((dialog1!=NULL) && (maintab!=NULL))
  688.     dialog1->OnSaveprofile();
  689.   else
  690.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  691. }
  692. void CWinHTTrackApp::FwOnLoaddefault() {
  693.   if ((dialog1!=NULL) && (maintab!=NULL))
  694.     dialog1->OnLoaddefault();
  695.   else
  696.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  697. }
  698. void CWinHTTrackApp::FwOnSavedefault() {
  699.   if ((dialog1!=NULL) && (maintab!=NULL))
  700.     dialog1->OnSavedefault();
  701.   else
  702.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  703. }
  704. void CWinHTTrackApp::FwOnResetdefault() {
  705.   if ((dialog1!=NULL) && (maintab!=NULL))
  706.     dialog1->OnResetdefault();
  707.   else
  708.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  709. }
  710.  
  711. //
  712.  
  713. void CWinHTTrackApp::FwOnModifyOpt() {
  714.   if ((inprogress!=NULL) && (maintab!=NULL))
  715.     inprogress->OnModifyOpt();
  716.   else
  717.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  718. }
  719.  
  720. void CWinHTTrackApp::FwOnPause() {
  721.   if ((inprogress!=NULL) && (maintab!=NULL))
  722.     inprogress->OnPause();
  723.   else
  724.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  725. }
  726.  
  727. void CWinHTTrackApp::FwOniplogLog() {
  728.   if ((inprogress!=NULL) && (maintab!=NULL))
  729.     inprogress->OniplogLog();
  730.   else
  731.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  732. }
  733.  
  734. void CWinHTTrackApp::FwOniplogErr() {
  735.   if ((inprogress!=NULL) && (maintab!=NULL))
  736.     inprogress->OniplogErr();
  737.   else
  738.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  739. }
  740.  
  741. void CWinHTTrackApp::FwOnViewTransfers() {
  742.   if ((inprogress!=NULL) && (maintab!=NULL))
  743.     inprogress->OnViewTransfers();
  744.   else
  745.     AfxMessageBox(LANG_ACTIONNYP,MB_OK);
  746. }
  747.  
  748. CDocument* CWinHTTrackApp::OpenDocumentFile( LPCTSTR lpszFileName)
  749. {
  750.   // Eviter deux fenΩtres (un seul document)
  751.   // Le CMultui..->CSingleDoc.. est trop complexe α changer (α cause du splitter-wnd)
  752.   int count=1;
  753.  
  754.   { /* Check if a document exists, and if exists if empty or not, and if name is different */
  755.     POSITION pos;
  756.     pos=GetFirstDocTemplatePosition();
  757.     if (pos) {
  758.       CDocTemplate* tmpl=GetNextDocTemplate(pos);
  759.       if (tmpl) {
  760.         pos=tmpl->GetFirstDocPosition();
  761.         if (pos) {
  762.           CDocument* doc  = tmpl->GetNextDoc(pos);
  763.           if (doc) {
  764.             if (dialog0->GetName().GetLength()==0) {
  765.               CloseAllDocuments(FALSE);
  766.               count=0;        /* No documents */
  767.             } else {
  768.               if (dialog0->GetPath0()+".whtt" == LPCSTR(lpszFileName))
  769.                 return NULL;
  770.             }
  771.           }
  772.         } else
  773.           count=0;          /* No documents */
  774.       }
  775.     }
  776.   }
  777.  
  778.   // Ouvrir nouvelle instance
  779.   if (count) {
  780.     char cmdl[2048];
  781.     CWinApp* pApp = AfxGetApp();
  782.     CString name = pApp->m_pszHelpFilePath;
  783.     name=name.Left(name.GetLength()-4);
  784.     name += ".EXE";
  785.     strcpybuff(cmdl,"\"");
  786.     strcatbuff(cmdl,lpszFileName);
  787.     strcatbuff(cmdl,"\"");
  788.     ShellExecute(NULL,"open",name,cmdl,"",SW_RESTORE);
  789.     return NULL;
  790.   }
  791.  
  792.   // Ouvrir nouveau?
  793.   //if (count)
  794.   //  return;       // ne rien faire, car limitΘ α 1 document
  795.   //count++;
  796.  
  797.   /* Ouvrir */
  798.   /*
  799.   CWinApp* app=AfxGetApp();
  800.   POSITION pos;
  801.   pos=app->GetFirstDocTemplatePosition();
  802.   CDocTemplate* templ = app->GetNextDocTemplate(pos);
  803.   pos=templ->GetFirstDocPosition();
  804.   if (pos) {
  805.     CDocument* doc  = templ->GetNextDoc(pos);
  806.     if (doc)
  807.       if (!doc->SaveModified())
  808.         return NULL;
  809.   }
  810.   CloseAllDocuments(FALSE);
  811.   */
  812.   if (strlen(lpszFileName))
  813.     return CWinApp::OpenDocumentFile(lpszFileName);
  814.   else
  815.     CWinApp::OnFileNew();
  816.   return NULL;
  817. }
  818.  
  819. void CWinHTTrackApp::NewTabs() {
  820.   DeleteTabs();
  821.   m_tab0 = new CFirstInfo();
  822.   m_tab1 = new CNewProj();
  823.   m_tab2 = new Wid1();
  824.   m_tab3 = new Ctrans();
  825.   m_tabprogress = new Cinprogress();
  826.   m_tabend = new Cinfoend();
  827. }
  828.  
  829. void CWinHTTrackApp::DeleteTabs() {
  830.   if (m_tab0)
  831.   if (m_tab0->GetSafeHwnd())       /* a dΘja ΘtΘ dΘtruit par CWinApp */
  832.     delete m_tab0;
  833.   if (m_tab1)
  834.   if (m_tab1->GetSafeHwnd())
  835.     delete m_tab1;
  836.   if (m_tab2)
  837.   if (m_tab2->GetSafeHwnd())
  838.     delete m_tab2;
  839.   if (m_tab3)
  840.   if (m_tab3->GetSafeHwnd())
  841.     delete m_tab3;
  842.   if (m_tabprogress)
  843.   if (m_tabprogress->GetSafeHwnd())
  844.     delete m_tabprogress;
  845.   if (m_tabend)
  846.   if (m_tabend->GetSafeHwnd())
  847.     delete m_tabend;
  848.  
  849.   m_tab0=NULL;
  850.   m_tab1=NULL;
  851.   m_tab2=NULL;
  852.   m_tab3=NULL;
  853.   m_tabprogress=NULL;
  854.   m_tabend=NULL;
  855. }
  856.  
  857. int CWinHTTrackApp::ExitInstance() 
  858. {
  859.   LANG_DELETE();
  860.  
  861.   /* Uninitialize */
  862.   hts_uninit();
  863.  
  864.   return CWinApp::ExitInstance();
  865. }
  866.