home *** CD-ROM | disk | FTP | other *** search
/ .net 2002 March / DotNetMagazine-Issue107-Coverdisc-NET107-02-03-PCMac.bin / pc / PC Software / picks / HTTrack / httrack-3.22-3.exe / {app} / src_win / WinHTTrack / Wid1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-30  |  25.0 KB  |  861 lines

  1. // Wid1.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <afxole.h>
  6. #include "oledlg.h"
  7. #include "afxodlgs.h"
  8.  
  9.  
  10. #include "Shell.h"
  11. #include "Wid1.h"
  12. //#include "filter.h"
  13.  
  14. #include "NewProj.h"
  15. #include "XSHBrowseForFolder.h"
  16.  
  17. #define HTS_WIN 1
  18. extern "C" {
  19.   #include "htsbase.h"
  20.   #include "htslib.h"
  21. }
  22.  
  23. #include "about.h"
  24. //#include "ProxyId.h"
  25. #include "InsertUrl.h"
  26.  
  27. #ifdef _DEBUG
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32.  
  33. extern CNewProj* dialog0;
  34.  
  35. extern int binput(char* buff,char* s,int max);
  36.  
  37. extern int check_continue(char* path_log);
  38. //extern HICON httrack_icon;
  39. extern int linput(FILE* fp,char* s,int max);
  40. extern int linput_trim(FILE* fp,char* s,int max);
  41. extern int linput_cpp(FILE* fp,char* s,int max);
  42. extern char* fconcat(char* a,char* b);
  43. extern int cmdl_opt(char* s);
  44. extern void Write_profile(CString path,int load_path);
  45. extern void Read_profile(CString path,int load_path);
  46. //extern int suivant4(void);
  47. extern CShellApp* CShellApp_app;
  48.  
  49. // Helper
  50. extern LaunchHelp* HtsHelper;
  51.  
  52. // reference sur objet
  53. extern Wid1* dialog1;
  54.  
  55. /* Main WizTab frame */
  56. #include "WizTab.h"
  57. extern CWizTab* this_CWizTab;
  58.  
  59. /* Main splitter frame */
  60. #include "DialogContainer.h"
  61. #include "splitter.h"
  62. extern CSplitterFrame* this_CSplitterFrame;
  63.  
  64. /* Back to FirstInfo */
  65. //#include "FirstInfo.h"
  66.  
  67. // pour lire ini qu'une fois
  68. int first_time=1;
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // Wid1 dialog
  72.  
  73.  
  74. /*class FileSelPath : public CFileDialog {
  75. public:
  76.   BOOL OnFileNameOK( ) { return 0; }
  77.   FileSelPath(BOOL a):CFileDialog(a) { };
  78. };*/
  79.  
  80. IMPLEMENT_DYNCREATE(Wid1, CPropertyPage)
  81.  
  82. //Cfilter filter;
  83. CString change(CString,char);
  84.  
  85. Wid1::Wid1()
  86.     : CPropertyPage(Wid1::IDD)
  87. {
  88.   dialog1=this;    /* NOTER REFERENCE */
  89.   cancel=0;
  90.     //{{AFX_DATA_INIT(Wid1)
  91.     m_C1 = -1;
  92.     m_urls = _T("");
  93.   m_todo = 0;
  94.     m_infomain = _T("");
  95.     m_filelist = _T("");
  96.     //}}AFX_DATA_INIT
  97. }
  98.  
  99. Wid1::~Wid1() {
  100.   dialog1=NULL;
  101. }
  102.  
  103. void Wid1::DoDataExchange(CDataExchange* pDX)
  104. {
  105.     CPropertyPage::DoDataExchange(pDX);
  106.     //{{AFX_DATA_MAP(Wid1)
  107.     DDX_Control(pDX, IDC_todo, m_ctl_todo);
  108.     DDX_Text(pDX, IDC_URL, m_urls);
  109.     DDX_CBIndex(pDX, IDC_todo, m_todo);
  110.     DDX_Text(pDX, IDC_INFOMAIN, m_infomain);
  111.     DDX_Text(pDX, IDC_filelist, m_filelist);
  112.     //}}AFX_DATA_MAP
  113. }
  114.  
  115. //IMPLEMENT_DYNAMIC(Wid1, CPropertyPage)
  116.  
  117. #define wm_CEasyDropTargetCallback (WM_USER + 1)
  118. BEGIN_MESSAGE_MAP(Wid1, CPropertyPage)
  119.     //{{AFX_MSG_MAP(Wid1)
  120.     ON_EN_CHANGE(IDC_URL, OnChangeUrl)
  121.     ON_CBN_SELCHANGE(IDC_todo, OnSelchangetodo)
  122.     ON_WM_CREATE()
  123.     ON_WM_HELPINFO()
  124.     ON_BN_CLICKED(ID_setopt, Onsetopt)
  125.     ON_BN_CLICKED(IDC_login2, Onlogin2)
  126.     ON_BN_CLICKED(IDC_br, Onbr)
  127.   ON_WM_DROPFILES()
  128.     ON_WM_DRAWITEM()
  129.     ON_WM_SHOWWINDOW()
  130.     ON_EN_CHANGE(IDC_filelist, OnChangefilelist)
  131.     //}}AFX_MSG_MAP
  132.     ON_COMMAND(ID_HELP_FINDER,OnHelpInfo2)
  133.     ON_COMMAND(ID_HELP,OnHelpInfo2)
  134.     //ON_COMMAND(ID_CONTEXT_HELP,OnContextHelp)
  135.     ON_COMMAND(ID_DEFAULT_HELP,OnHelpInfo2)
  136.   //
  137.   ON_BN_CLICKED(ID_LOAD_OPTIONS,OnLoadprofile)
  138.   ON_BN_CLICKED(ID_FILE_SAVE_OPTIONS_AS,OnSaveprofile)
  139.     ON_BN_CLICKED(ID_LoadDefaultOptions, OnLoaddefault)
  140.     ON_BN_CLICKED(ID_SaveDefaultOptions, OnSavedefault)
  141.     ON_BN_CLICKED(ID_ClearDefaultOptions,OnResetdefault)
  142.     //ON_BN_CLICKED(ID_NewProjectImport, OnNewProject)
  143.     ON_BN_CLICKED(ID_SaveProject, OnSaveProject)
  144.   ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  145.   //
  146.   ON_MESSAGE( wm_CEasyDropTargetCallback, DragDropText)
  147. END_MESSAGE_MAP()
  148.  
  149. /////////////////////////////////////////////////////////////////////////////
  150. // Wid1 message handlers
  151.  
  152. BOOL Wid1::OnInitDialog( ) {
  153.   CPropertyPage::OnInitDialog();
  154.   EnableToolTips(true);     // TOOL TIPS
  155.  
  156.   // inits aprËs affichage
  157.   url_status=-1;
  158.   filelist_status=-1;
  159.   //prox_status=-1;
  160.   log_flip=-1;
  161.   mir_status=-1;
  162.   proj_status=-1;
  163.   continue_status=-1;
  164.   OnChangeUrl();
  165.   OnChangefilelist();
  166.   //OnChangeprox();  // update disabled/normal
  167.   //OnSelchangedepth();  // update disabled/normal
  168.   OnSelchangetodo();
  169.  
  170.   // Patcher l'interface pour les FranÁais ;-)
  171.   if (LANG_T(-1)) {    // Patcher en franÁais
  172.     //SetDlgItemText(,"");
  173.     SetWindowText( LANG(LANG_G30)); // "Bienvenue dans WinHTTrack!");
  174.     SetDlgItemText(IDC_STATIC_action,LANG(LANG_G31)); // "Action:");
  175.     //SetDlgItemText(IDC_STATIC_filters,LANG(LANG_G33)); // "Filtres (refuser/accepter liens) :");
  176.     SetDlgItemText(IDC_STATIC_filters2,LANG(LANG_G41)); // "Options & prefs :");
  177.     SetDlgItemText(IDC_STATIC_paths,LANG(LANG_G34)); // "Chemins");
  178.     //SetDlgItemText(IDC_regdef,LANG(LANG_G37)); // "Sauver prÈfs");
  179.     //SetDlgItemText(IDOK,LANG(LANG_NEXT )); // "SUIVANT ->");
  180.     //SetDlgItemText(IDC_avant,LANG(LANG_BACK));
  181.     //SetDlgItemText(IDCANCEL,LANG(LANG_QUIT));  // exit 
  182.     //SetDlgItemText(IDfilter,LANG(LANG_G39)); // "DÈfinir..");
  183.     SetDlgItemText(ID_setopt,LANG(LANG_G40)); // "DÈfinir les options..");
  184.     //SetDlgItemText(IDC_mirtitle2,LANG(LANG_G42)); // "Nom du projet");
  185.     SetDlgItemText(IDC_login2,LANG_G43);
  186.     //SetDlgItemText(IDC_urls,LANG_G44);
  187.     SetDlgItemText(IDC_STATIC_webaddr,LANG_G44);
  188.     SetCombo(this,IDC_todo,LISTDEF_10);
  189.   }
  190.  
  191.   // inits
  192.   LAST_ACTION = m_ctl_todo.GetCount()-1;  // dernier item (update)
  193.  
  194.   // fichier ini
  195.   // lire default
  196.   if (first_time) {
  197.     first_time=0;
  198.  
  199.     //SetDlgItemText(IDC_INFOMAIN,"Please select an action, and fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below");
  200.  
  201.     /*
  202.     CString strSection       = "DefaultValues";    
  203.     CWinApp* pApp = AfxGetApp();
  204.     CString st;
  205.     int n;
  206.     */
  207.  
  208.     /*
  209.     if ((n = pApp->GetProfileInt(strSection, "Action",CB_ERR)) != CB_ERR)
  210.       m_ctl_todo.SetCurSel(n);
  211.  
  212.     if ((st = pApp->GetProfileString(strSection, "Depth")))
  213.       SetDlgItemText(IDC_depth,st);    
  214.     */
  215.  
  216.     /*
  217.     if ((st = pApp->GetProfileString(strSection, "MirrorPath","default")) != (CString) "default")
  218.       SetDlgItemText(IDC_pthmir,st);
  219.     if ((st = pApp->GetProfileString(strSection, "LogPath","default")) != (CString) "default")
  220.       SetDlgItemText(IDC_pathlog,st);
  221.     */
  222.  
  223.     // Infos la 1ere fois!
  224.     /*if (!pApp->GetProfileInt("Interface","FirstRun",0)) {
  225.       pApp->WriteProfileInt("Interface","FirstRun",1);
  226.       Onipabout();
  227.     }*/
  228.  
  229.   } else {
  230.     log_flip=0;
  231.   }
  232.   // fichier ini  
  233.  
  234.   //OnChangepathlog();  // update rÈpertoire log
  235.   //OnChangepthmir();  // update rÈpertoire miroir
  236.  
  237.   return TRUE;
  238. }
  239.  
  240. void Wid1::AfterInitDialog( ) {
  241.   WHTT_LOCATION("Wid1");
  242.   if (load_after_changes) {
  243.     AfterChangepathlog();
  244.     OnSelchangetodo();
  245.     load_after_changes=0;
  246.   }
  247.   OnChangeUrl();
  248.   OnChangefilelist();
  249. }
  250.  
  251. /*
  252. void Wid1::Onurls() {
  253.   CleanUrls();
  254. }
  255. */
  256.  
  257. // nettoyer les URLs
  258. void Wid1::CleanUrls() 
  259. {
  260.   CWaitCursor wait;
  261.   char* tempo, *ch,*str;
  262.   CString    st="";
  263.   // TODO: Add your control notification handler code here
  264.   
  265.   GetDlgItemText(IDC_URL,st);
  266.   tempo=(char*) malloc(st.GetLength()+1);
  267.   ch=(char*) malloc(st.GetLength()+1);
  268.   str=(char*) malloc(st.GetLength()*2+8192);
  269.   tempo[0]=ch[0]=str[0]='\0';
  270.   if ( (tempo) && (ch) && (str) ) {
  271.     strcpybuff(tempo,st);
  272.     int i;
  273.     for(i=0;i < (int) strlen(tempo);i++)  {
  274.       if(tempo[i]==10) tempo[i]=' ';
  275.       else if(tempo[i]==13) tempo[i]=' ';
  276.     }
  277.     
  278.     strcpybuff(ch,"");
  279.     int j=0;
  280.     for(i=0;i <= (int) strlen(tempo);i++) {
  281.       if ((tempo[i]==' ') || (tempo[i]==0)) {
  282.         ch[j++]='\0';
  283.         if ((strlen(ch)>0) && ((int) strlen(ch)<HTS_URLMAXSIZE) ) {
  284.           // vÈrifier URL
  285.           /*
  286.           char adr[HTS_URLMAXSIZE*2],fil[HTS_URLMAXSIZE*2];
  287.           adr[0]=fil[0]='\0';
  288.           if (ident_url_absolute(ch,adr,fil)==-1) {
  289.             htsblk r;
  290.             char loc[HTS_URLMAXSIZE*2]; loc[0]='\0';    // Èventuelle nouvelle position
  291.             r=http_test(ch,fil,loc);
  292.             if ((r.statuscode==301) 
  293.               || (r.statuscode==302) 
  294.               || (r.statuscode==303) 
  295.               || (r.statuscode==307) 
  296.               || (r.statuscode==200)
  297.               ) {
  298.               strcpybuff(ch,loc);
  299.             }
  300.           }
  301.           */
  302.           // recopier adresse
  303.           if (strstr(ch,":/")==NULL) {
  304.             strcatbuff(str,"http://");
  305.           }
  306.           strcatbuff(str,ch);
  307.           strcatbuff(str,"\x0d\x0a");
  308.         }
  309.         j=0;
  310.       } else ch[j++]=tempo[i];
  311.     }
  312.     SetDlgItemText(IDC_URL,str);
  313.     free(tempo);
  314.     free(ch);
  315.     free(str);
  316.   } else
  317.     AfxMessageBox(LANG(LANG_DIAL10));
  318.   //m_urls=str;
  319. }
  320.  
  321. void Wid1::OnChangeUrl()
  322. {
  323.   CString st="";
  324.   //char tempo[8192];
  325.   char* tempo;
  326.     // TODO: If this is a RICHEDIT control, the control will not
  327.     // send this notification unless you override the CPropertyPage::OnInitDialog()
  328.     // function to send the EM_SETEVENTMASK message to the control
  329.   // with the ENM_CHANGE flag ORed into the lParam mask.
  330.   
  331.   // TODO: Add your control notification handler code here
  332.   GetDlgItemText(IDC_URL,st);
  333.   tempo=(char*) malloc(st.GetLength()+1);
  334.   if (tempo) {
  335.     strcpybuff(tempo,st);
  336.     int ex=0;
  337.     do {
  338.       if (strlen(tempo)>0) {
  339.         switch (tempo[strlen(tempo)-1]) {
  340.         case 10: case 13: case 32: tempo[strlen(tempo)-1]='\0';
  341.           break;
  342.         default: ex=1;
  343.           break;
  344.         }
  345.       } else ex=1;
  346.     } while(!ex);
  347.     
  348.     if ( ((strlen(tempo)>0) ) != url_status) { // || (m_ctl_todo.GetCurSel()==4)
  349.       url_status=!url_status;
  350.       
  351.       if (url_status) {
  352.         //m_ctl_next.ModifyStyle(WS_DISABLED,0);
  353.       }
  354.       else {
  355.         //m_ctl_next.ModifyStyle(0,WS_DISABLED);
  356.       }
  357.       //m_ctl_next.RedrawWindow();
  358.     }
  359.     free(tempo); tempo=NULL;
  360.   } else
  361.     AfxMessageBox(LANG(LANG_DIAL10));
  362. }
  363.  
  364. void Wid1::Refresh() {
  365.   OnChangeUrl();
  366.   //OnChangeprox();  // update disabled/normal
  367.   //OnSelchangedepth();  // update disabled/normal
  368. }
  369.  
  370. void Wid1::OnSelchangetodo() 
  371. {
  372.   int r;
  373.   r = m_ctl_todo.GetCurSel();
  374.   if (r!=CB_ERR) {
  375.     switch(r) {
  376.     case 0:
  377.       SetDlgItemText(IDC_INFOMAIN,
  378.       LANG(LANG_G2 /*"Mirror mode, fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  379.       "Mode miroir, remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvÈ ‡ l'emplacement indiquÈ plus bas"*/)
  380.       );
  381.       break;
  382.     case 1:
  383.       SetDlgItemText(IDC_INFOMAIN,
  384.       LANG(LANG_G3 /* "Mirror mode with wizard (asks questions), fill the addresse(s) in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  385.       "Mode miroir semi automatique (pose des questions), remplissez les addresse(s) dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvÈ ‡ l'emplacement indiquÈ plus bas"*/)
  386.       );
  387.       break;
  388.     case 2:
  389.       SetDlgItemText(IDC_INFOMAIN,
  390.       LANG(LANG_G4 /* "Get files mode, fill the addresse(s) of the files in the URL box.\x0d\x0aThe mirror will be saved in the location indicated below",
  391.       "Mode tÈlÈchargement de fichier, remplissez les addresse(s) des fichiers dans la liste d'URLs.\x0d\x0aLe mirroir sera sauvÈ ‡ l'emplacement indiquÈ plus bas"*/)
  392.       );
  393.       SetDlgItemText(IDC_depth,"");
  394.       break;
  395.     case 3:
  396.       SetDlgItemText(IDC_INFOMAIN,
  397.         LANG(LANG_G1B)
  398.         );
  399.       SetDlgItemText(IDC_depth,"");
  400.       break;
  401.     case 4:
  402.       SetDlgItemText(IDC_INFOMAIN,
  403.       LANG(LANG_G5 /* "Test links mode, fill the addresse(s) of the pages containing links to test in the URL box.\x0d\x0aThe log report will be saved in the location indicated below",
  404.       "Mode test de liens, remplissez les adresse(s) des pages contenant les liens ‡ tester dans la liste d'URLs.\x0d\x0aLes fichiers d'audit seront sauvÈs ‡ l'emplacement indiquÈ plus bas"*/)
  405.       );
  406.       SetDlgItemText(IDC_depth,"");
  407.       break;
  408.     default:
  409.       if (r == LAST_ACTION )
  410.         SetDlgItemText(IDC_INFOMAIN,
  411.         LANG(LANG_G6 /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  412.         "Mode mise ‡ jour/continuer un miroir, vÈrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vÈrifiez les paramËtres.\x0d\x0aLe mirroir sera sauvÈ ‡ l'emplacement indiquÈ plus bas"*/)
  413.         );
  414.       else if (r == LAST_ACTION-1 )
  415.         SetDlgItemText(IDC_INFOMAIN,
  416.         LANG(LANG_G6b /* "Update/Continue a mirror mode, check addresse(s) in the URL box, then click to the 'NEXT' button and check parameters.\x0d\x0aThe mirror will be saved in the location indicated below",
  417.         "Mode mise ‡ jour/continuer un miroir, vÈrifiez les adresse(s) dans la liste d'URLs, puis cliquez sur le bouton 'NEXT' et vÈrifiez les paramËtres.\x0d\x0aLe mirroir sera sauvÈ ‡ l'emplacement indiquÈ plus bas"*/)
  418.         );
  419.       break;
  420.     }
  421.     
  422.     if ( ((r==LAST_ACTION)||(r==LAST_ACTION-1)) != continue_status) {
  423.       continue_status=((r==LAST_ACTION)||(r==LAST_ACTION-1));
  424.       OnChangeUrl();
  425.     }
  426.   }
  427.   
  428. }
  429.  
  430.  
  431. void Wid1::OnChangepathlog() {
  432.   load_after_changes=1;
  433. }
  434.  
  435. void Wid1::AfterChangepathlog() 
  436. {
  437.   CString st="";
  438.   char tempo[8192];
  439.   BOOL modify;
  440.  
  441.   strcpybuff(tempo,dialog0->GetPath());
  442.   {
  443.     if (fexist(fconcat(tempo,"hts-cache/winprofile.ini"))) {    // un cache est prÈsent
  444.       if (fsize(fconcat(tempo,"hts-cache/winprofile.ini"))>0) {   // taille log contrÙle>0
  445.         int i;
  446.         for(i=0;i<(int) strlen(tempo);i++)
  447.           if (tempo[i]=='/')
  448.             tempo[i]='\\';
  449.           Read_profile(fconcat(tempo,"hts-cache\\winprofile.ini"),0);
  450.  
  451.           // peut on modifier?
  452.           int pos=m_ctl_todo.GetCurSel();
  453.           if ((pos==LAST_ACTION) || (pos==LAST_ACTION-1) || (pos==0))
  454.             modify=true;
  455.           else
  456.             modify=false;
  457.           
  458.           // existe: update
  459.           if ((fexist(fconcat(tempo,"hts-cache/new.dat"))) && (fexist(fconcat(tempo,"hts-cache/new.ndx")))) {  // il existe dÈja un cache prÈcÈdent.. renommer
  460.             if (modify) {
  461.               if (
  462.                 (!fexist(fconcat(tempo,"hts-in_progress.lock")))
  463.                 &&
  464.                 (!fexist(fconcat(tempo,"hts-cache/interrupted.lock")))
  465.                 )
  466.                 m_ctl_todo.SetCurSel(LAST_ACTION);
  467.               else
  468.                 m_ctl_todo.SetCurSel(LAST_ACTION-1);
  469.             }
  470.             log_flip=1;
  471.           } else if (log_flip) {
  472.             if (modify)
  473.               m_ctl_todo.SetCurSel(0);
  474.             log_flip = 0;
  475.           }
  476.           OnSelchangetodo();
  477.       }
  478.     } else if (log_flip) {
  479.       m_ctl_todo.SetCurSel(0);
  480.       log_flip = 0;
  481.     }
  482.   }
  483. }
  484. /*
  485. void Wid1::OnClose() 
  486. {
  487.   // TODO: Add your message handler code here and/or call default
  488.   //Onfin();
  489.   //::OnClose();
  490.   if (AfxMessageBox(
  491.   LANG(LANG_J1)
  492.   ,MB_OKCANCEL)==IDOK) {
  493.     if (Save_current_profile(1)!=IDCANCEL) {
  494.       cancel=1;
  495.       CPropertyPage::OnCancel();
  496.     }
  497.   }
  498. }
  499. */
  500.  
  501.  
  502.  
  503. // ------------------------------------------------------------
  504. // TOOL TIPS
  505. //
  506. // ajouter dans le .cpp:
  507. // remplacer les deux Wid1:: par le nom de la classe::
  508. // dans la message map, ajouter
  509. // ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify )
  510. // dans initdialog ajouter
  511. // EnableToolTips(true);     // TOOL TIPS
  512. //
  513. // ajouter dans le .h:
  514. // char* GetTip(int id);
  515. // et en generated message map
  516. // afx_msg BOOL OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult );
  517. BOOL Wid1::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
  518. {
  519.   TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
  520.   UINT nID =pNMHDR->idFrom;
  521.   if (pTTT->uFlags & TTF_IDISHWND)
  522.   {
  523.     // idFrom is actually the HWND of the tool
  524.     nID = ::GetDlgCtrlID((HWND)nID);
  525.     if(nID)
  526.     {
  527.       char* st=GetTip(nID);
  528.       if (st != "") {
  529.         pTTT->lpszText = st;
  530.         pTTT->hinst = AfxGetResourceHandle();
  531.         return(TRUE);
  532.       }
  533.     }
  534.   }
  535.   return(FALSE);
  536. }
  537. char* Wid1::GetTip(int ID)
  538. {
  539.   switch(ID) {
  540.     case IDC_todo:  return LANG(LANG_G9); break; // "Choose an action","Choisissez une action"); break; 
  541.     case IDC_depth: return LANG(LANG_G10); break; // "Maximum link depth to scan","Profondeur maximale"); break;
  542.     case IDC_URL:   return LANG(LANG_G11); break; // "Enter addresses here","Entrez les adresses ici"); break;
  543.     //case IDC_urls:  return LANG(LANG_G12); break; // "Check spelling","VÈrifier syntaxe"); break;
  544.     //case IDfilter:  return LANG(LANG_G13); break; // "Define additional filters","DÈfinir les filtres supplÈmentaires"); break;
  545.     //case IDC_pathlog:  return LANG(LANG_G16); break; // "Path","Chemin"); break;
  546.     //case IDC_br2:      return LANG(LANG_G17); break; // "Select path","Choix du chemin"); break;
  547.     //case IDC_pthmir:   return LANG(LANG_G18); break; // "Path","Chemin"); break;
  548.     //case IDC_br1:      return LANG(LANG_G19); break; // "Select path","Choix du chemin"); break;
  549.     case IDCANCEL:     return LANG(LANG_G20); break; // "Quit WinHTTrack","Quittter WinHTTrack"); break;
  550.     case IDC_ipabout:  return LANG(LANG_G21); break; // "About WinHTTrack","A propos de WinHTTrack"); break;
  551.     case IDC_regdef:   return LANG(LANG_G22); break; // "Save preferences as default values","Sauver les rÈglages par dÈfaut"); break;
  552.     case IDOK:         return LANG(LANG_G23); break; // "Click to continue","Clic pour continuer"); break;
  553.     case IDC_avant:     return LANG_TIPPREV; break;
  554.     case ID_setopt:    return LANG(LANG_G24); break; // "Click to define option","Clic pour dÈfinir les options"); break;
  555.     case IDC_login2:   return LANG_G24b; break;
  556.     case IDC_filelist: return LANG_G24c; break;
  557.     //case : return ""; break;
  558.   }
  559.   return "";
  560. }
  561. // TOOL TIPS
  562. // ------------------------------------------------------------
  563.  
  564.  
  565. /*
  566. void Wid1::OnDropFiles(HDROP hDropInfo) 
  567. {
  568.   int nf;
  569.   int i;
  570.   nf=DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);    // nbre de fichiers
  571.  
  572.   for(i=0;i<nf;i++) {
  573.     char* buff;
  574.     int size;
  575.     size=DragQueryFile(hDropInfo,i,NULL,0);    // taille buffer nÈcessaire
  576.     if (size>0) {
  577.       size+=16;    // marge de sÈcuritÈ
  578.       buff=(char*) calloc(size,1);
  579.       if (buff) {
  580.         if (DragQueryFile(hDropInfo,i,buff,size)>0) {    // ok copiÈ
  581.           AfxMessageBox(buff,MB_OKCANCEL+MB_ICONQUESTION);
  582.         }
  583.         free(buff);
  584.       }
  585.     }
  586.   }
  587.  
  588.   CPropertyPage::OnDropFiles(hDropInfo);
  589. }
  590. */
  591.  
  592. int Wid1::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  593. {
  594.     if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
  595.         return -1;
  596.  
  597.   // Drag&Drop
  598.   drag=new CEasyDropTarget(this);
  599.   if (drag->IsRegistered()) {
  600.     drag->SetTextCallback(wm_CEasyDropTargetCallback);
  601.   }
  602.     
  603.     return 0;
  604. }
  605.  
  606.  
  607. CString Wid1::TextToUrl(CString st,CLIPFORMAT cfFormat) {
  608.   // yop
  609.   // on va convertir les chaines ‡ la suite
  610.   if (cfFormat==CF_TEXT) {
  611.     char *buff;
  612.     buff=(char*) malloc(st.GetLength()+2);
  613.     if (buff) {
  614.       char s[HTS_URLMAXSIZE*2];
  615.       CString res="";
  616.       strcpybuff(buff,st);
  617.       //
  618.       int ptr=0;
  619.       do {
  620.         ptr+=binput(buff+ptr,s,1000);
  621.         if (!strstr(s,"://")) {
  622.           char tempo[HTS_URLMAXSIZE*2]="http://";
  623.           strcatbuff(tempo,s);
  624.           strcpybuff(s,tempo);
  625.         }
  626.         escape_check_url(s);
  627.         if (res.GetLength())
  628.           res+="\r\n";
  629.         res+=s;
  630.       } while(ptr<(int) strlen(buff));
  631.       st=res;
  632.       free(buff);
  633.     }
  634.   }
  635.   else if (cfFormat==CF_HDROP) {
  636.     if (st.GetLength()<256) {
  637.       char s[256];
  638.       strcpybuff(s,st);
  639.       escape_check_url(s);     // coder %
  640.       st="file://";
  641.       st+=s;
  642.     } else
  643.       st="";
  644.   }
  645.   else
  646.     st="";
  647.   return st;
  648. }
  649.  
  650. // Message from CEasyDropTarget
  651. LRESULT Wid1::DragDropText(WPARAM wParam,LPARAM lParam) {
  652.   if (lParam) {
  653.     CString st=*((CString*) lParam);
  654.     CLIPFORMAT cfFormat=wParam;
  655.     st=Wid1::TextToUrl(st,cfFormat);
  656.     if (st=="")
  657.       AfxMessageBox(LANG(LANG_DIAL11),MB_SYSTEMMODAL);
  658.     else
  659.       AddText(st);
  660.   }
  661.   return 0;
  662. }
  663.  
  664. // ajout d'URLs
  665. void Wid1::AddText(CString add_st) {
  666.   CString st;
  667.   GetDlgItemText(IDC_URL,st);
  668.   SetDlgItemText(IDC_URL,st+"\r\n"+add_st);
  669.   CleanUrls();
  670.   OnChangeUrl();
  671. }
  672.  
  673. // Appel aide
  674. BOOL Wid1::OnHelpInfo2() {
  675.   return OnHelpInfo(NULL);
  676. }
  677.  
  678. BOOL Wid1::OnHelpInfo(HELPINFO* dummy) 
  679. {
  680.   //return CPropertyPage::OnHelpInfo(pHelpInfo);
  681.   //AfxGetApp()->WinHelp(0,HELP_FINDER);    // Index du fichier Hlp
  682.   //LaunchHelp(pHelpInfo);
  683.   HtsHelper->Help("step2.html");
  684.   //HtsHelper->Help();
  685.   return true;
  686. }
  687.  
  688. void Wid1::OnLoadprofile() {
  689.   static char BASED_CODE szFilter[256];
  690.   strcpybuff(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RÈglages de WinHTTrack (*.opt)|*.opt||"*/));
  691.   CFileDialog* dial = new CFileDialog(true,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  692.   if (dial->DoModal() == IDOK) {
  693.     CString st=dial->GetPathName();
  694.     char s[256];
  695.     strcpybuff(s,st);
  696.     if (fexist(s))
  697.       Read_profile(st,1);
  698.     else
  699.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  700.   }
  701.   delete dial;
  702. }
  703.  
  704. void Wid1::OnSaveprofile() {
  705.   static char BASED_CODE szFilter[256];
  706.   strcpybuff(szFilter,LANG(LANG_G25 /*"WinHTTrack preferences (*.opt)|*.opt||","RÈglages de WinHTTrack (*.opt)|*.opt||"*/));
  707.   CFileDialog* dial = new CFileDialog(false,"opt",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter);
  708.   if (dial->DoModal() == IDOK) {
  709.     CString st=dial->GetPathName();
  710.     Write_profile(st,1);
  711.   }
  712.   delete dial;
  713. }
  714.  
  715. void Wid1::OnLoaddefault() {
  716.   if (AfxMessageBox(LANG(LANG_G27),MB_OKCANCEL)==IDOK) {
  717.     Read_profile("",0);
  718.   }
  719. }
  720.  
  721. void Wid1::OnSavedefault() {
  722.   if (AfxMessageBox(LANG(LANG_G28),MB_OKCANCEL)==IDOK) {
  723.     Write_profile("",0);
  724.   }
  725. }
  726.  
  727. void Wid1::OnResetdefault() {
  728.   if (AfxMessageBox(LANG(LANG_G29),MB_OKCANCEL)==IDOK) {
  729.     Read_profile("<null>",0);    // charger default
  730.     Write_profile("",0);         // et sauver
  731.   }
  732. }
  733.  
  734. /*
  735. void Wid1::OnNewProject() {
  736.   if (AfxMessageBox(LANG(LANG_G1C),MB_OKCANCEL)==IDOK) {
  737.     CWinApp* pApp = AfxGetApp();
  738.     CString name = pApp->m_pszHelpFilePath;
  739.     name=name.Left(name.GetLength()-4);
  740.     name += ".EXE";
  741.     ShellExecute(NULL,"open",name,"","",SW_RESTORE);
  742.     cancel=1;
  743.     EndDialog(1);
  744.   }
  745. }
  746. */
  747.  
  748. void Wid1::OnSaveProject() {
  749.   Save_current_profile(0);
  750. }
  751.  
  752. void Wid1::Onsetopt() 
  753. {
  754.   CShellApp_app->OptPannel();
  755. }
  756.  
  757. /*
  758. HCURSOR Wid1::OnQueryDragIcon() 
  759. {
  760.     // TODO: Add your message handler code here and/or call default
  761.     
  762.     return CPropertyPage::OnQueryDragIcon();
  763. }
  764. */
  765.  
  766. void Wid1::Onlogin2() 
  767. {
  768.   CInsertUrl url;
  769.   url.dest_path=dialog0->GetPath();
  770.   if (url.DoModal() == IDOK) {
  771.     if (url.m_urladr.Left(7)=="http://")
  772.       url.m_urladr=url.m_urladr.Mid(7);
  773.     CString st;
  774.     GetDlgItemText(IDC_URL,st);
  775.     if (url.m_urllogin.GetLength()==0) {
  776.       SetDlgItemText(IDC_URL,st+"\r\n"+url.m_urladr);
  777.     } else {
  778.       char *a,*b;
  779.       escape_in_url(a=copychar(LPCTSTR(url.m_urllogin)));
  780.       escape_in_url(b=copychar(LPCTSTR(url.m_urlpass)));
  781.       SetDlgItemText(IDC_URL,st+"\r\n"+(CString)(a)+":"+(CString)(b)+"@"+url.m_urladr);
  782.     }
  783.     CleanUrls();
  784.     OnChangeUrl();
  785.   }
  786. }
  787.  
  788. LRESULT Wid1::OnWizardNext() {
  789.   CString st;
  790.   UpdateData(TRUE);         // DoDataExchange
  791.   m_urls.TrimLeft(); m_urls.TrimRight();
  792.   m_filelist.TrimLeft(); m_filelist.TrimRight();
  793.   if ((m_urls.GetLength()>0) || (m_filelist.GetLength()>0)) {
  794.     if ((m_todo==LAST_ACTION)||(m_todo==LAST_ACTION-1)) {
  795.       char path[HTS_URLMAXSIZE*2];
  796.       CString st;
  797.       st=dialog0->GetPath();
  798.       strcpybuff(path,st);
  799.       if (check_continue(path))
  800.         return 0;
  801.       else {
  802.         GetDlgItem(IDC_URL)->SetFocus();
  803.         return -1;        // impossible de continuer
  804.       }
  805.     }
  806.   } else {
  807.     GetDlgItem(IDC_URL)->SetFocus();
  808.     return -1;
  809.   }
  810.   return 0;
  811. }
  812.  
  813. BOOL Wid1::OnSetActive( ) {
  814.   //OnInitDialog();
  815.   AfterInitDialog();
  816.   this_CWizTab->SetWizardButtons(PSWIZB_BACK|PSWIZB_NEXT);
  817.   return 1;
  818. }
  819.  
  820. BOOL Wid1::OnQueryCancel( ) {
  821.   this_CSplitterFrame->SetNewView(0,1,RUNTIME_CLASS(CDialogContainer));
  822.   return 0;
  823. }
  824.  
  825. BOOL Wid1::OnKillActive( ) {
  826.   UpdateData(TRUE);         // DoDataExchange
  827.   return 1;
  828. }
  829.  
  830. void Wid1::Onbr() 
  831. {
  832.   static char BASED_CODE szFilter[256];
  833.   strcpybuff(szFilter,LANG(LANG_G25b));
  834.   CFileDialog* dial = new CFileDialog(true,"txt",NULL,OFN_HIDEREADONLY,szFilter);
  835.   if (dial->DoModal() == IDOK) {
  836.     if (fexist((char*)LPCSTR(dial->GetPathName()))) {
  837.       SetDlgItemText(IDC_filelist,dial->GetPathName());
  838.     } else {
  839.       AfxMessageBox(LANG(LANG_G26 /*"File not found!","Fichier introuvable!"*/));
  840.       SetDlgItemText(IDC_filelist,"");
  841.     }
  842.   }
  843.   delete dial;
  844.   OnChangefilelist();
  845. }
  846.  
  847. void Wid1::OnChangefilelist() 
  848. {
  849.   CString st;
  850.   GetDlgItemText(IDC_filelist,st);
  851.   if ((st.GetLength()>0) != filelist_status) {
  852.     filelist_status=(st.GetLength()>0);
  853.     if (filelist_status) {
  854.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(WS_DISABLED,0);
  855.     } else {
  856.       GetDlgItem(IDC_STATIC_filelist)->ModifyStyle(0,WS_DISABLED);
  857.     }
  858.     GetDlgItem(IDC_STATIC_filelist)->RedrawWindow();
  859.   }
  860. }
  861.