Diff for /mozptch/datamodul.pas between versions 1.4 and 1.5

version 1.4, 2004/04/16 16:52:52 version 1.5, 2004/05/13 15:20:51
Line 9 Line 9
 # ========  # ========
 #  #
 # $Log$  # $Log$
# Revision 1.4  2004/04/16 16:52:52  oertel# Revision 1.5  2004/05/13 15:20:51  oertel
# src: terminated with multi language interface: (nearly)all messeges now in mozptch.msg# - now (beta) support for firefox and thunderbird
# www: spelling correction, multilanguage interface# - mimetype.tmpl will be created if not present
# bin: new binary with message file#
## Revision 1.4  2004/04/16 16:52:52  oertel
# Revision 1.3  2004/04/07 18:34:55  oertel# src: terminated with multi language interface: (nearly)all messeges now in mozptch.msg
# src: continued with multi language interface# www: spelling correction, multilanguage interface
## bin: new binary with message file
# Revision 1.2  2004/03/28 17:08:58  oertel#
# src: started with multi language interface# Revision 1.3  2004/04/07 18:34:55  oertel
# messages in the new file mozptch.msg# src: continued with multi language interface
# new command line option -l <lang>#
## Revision 1.2  2004/03/28 17:08:58  oertel
# Revision 1.1  2004/03/14 12:49:07  oertel# src: started with multi language interface
# Initial commit version 9.29# messages in the new file mozptch.msg
 # new command line option -l <lang>
 #
 # Revision 1.1  2004/03/14 12:49:07  oertel
 # Initial commit version 9.29
 #  #
 *)  *)
   
Line 32  unit datamodul;  Line 36  unit datamodul; 
 interface  interface
   
 uses  uses
  SysUtils, Classes, ExtCtrls,   SysUtils, Classes,
  shell_func, VersionInfo,  ProcessViewer,   {$IFDEF MSWINDOWS}
  forms,ShlObj, ActiveX, Windows, Dialogs, preffile, IniFiles,   ExtCtrls, shell_func, VersionInfo,  ProcessViewer,
   ShlObj, Windows,  activeX,
   {$ENDIF}
   forms, Dialogs, preffile, IniFiles,
   UnitFunc, Controls, stdctrls, Graphics,DateUtils,strutils,    UnitFunc, Controls, stdctrls, Graphics,DateUtils,strutils,
   IdMessageClient, IdSMTP, IdBaseComponent, IdComponent, IdTCPConnection,    IdMessageClient, IdSMTP, IdBaseComponent, IdComponent, IdTCPConnection,
   IdTCPClient, Sockets, IdUDPBase, IdUDPClient, IdDNSResolver,xmlpatch;    IdTCPClient, Sockets, IdUDPBase, IdUDPClient, IdDNSResolver,xmlpatch;
Line 89  var  Line 96  var 
   sHelpVar1,sHelpVar2,sHelpVar3,sHelpVar4,sHelpVar5,    sHelpVar1,sHelpVar2,sHelpVar3,sHelpVar4,sHelpVar5,
   sHelpVar6,sHelpVar7,sHelpVar8,sHelpVar9,sHelpVar10 : string;    sHelpVar6,sHelpVar7,sHelpVar8,sHelpVar9,sHelpVar10 : string;
   mozmaildir, mozmailsubdir, mozmailsltdir, mozprogdir :string;    mozmaildir, mozmailsubdir, mozmailsltdir, mozprogdir :string;
  mozprofparentdir : string;   mozprofparentdir, mozprogname, mozaplication : string;
   mozaplication_internal : string;
   hostresolved, telearbeitsplatz : boolean;    hostresolved, telearbeitsplatz : boolean;
   logfeil : TextFile;    logfeil : TextFile;
   intFehler : integer;    intFehler : integer;
Line 174  begin  Line 182  begin 
   GetMem(MyLang, Size);    GetMem(MyLang, Size);
   Ident:=GetSystemDefaultLangID;    Ident:=GetSystemDefaultLangID;
   VerLanguageName(Ident, MyLang, Size);    VerLanguageName(Ident, MyLang, Size);
     writelog('Long system language: '+StrPas(MyLang));
   getSystemLanguage:=copy(StrPas(MyLang),1,2);    getSystemLanguage:=copy(StrPas(MyLang),1,2);
   FreeMem(MyLang);    FreeMem(MyLang);
 end;  end;
Line 191  var  Line 200  var 
  tmpLangStr : string;   tmpLangStr : string;
 begin  begin
  tmpLangStr := AnsiLowerCase(getSystemLanguage);   tmpLangStr := AnsiLowerCase(getSystemLanguage);
    writelog('Short system language: '+tmpLangStr);
  if CompareStr(mozptchmsg.ReadString('messages'   if CompareStr(mozptchmsg.ReadString('messages'
                                  ,tmpLangStr                                   ,tmpLangStr
                                  ,'Message not found')                                   ,'Message not found')
                                  ,'Message not found') = 0 then                                   ,'Message not found') = 0 then
  syslang := 'en'  begin
   syslang := 'en';
   writelog('language: '+tmpLangStr+' not found - fall back to english');
  end
  else   else
   syslang := tmpLangStr;    syslang := tmpLangStr;
 end;  end;
Line 309  begin  Line 322  begin 
   end;    end;
   writelog(Format(getMsg('target_dir_exists'),[mozprofparentdir]));    writelog(Format(getMsg('target_dir_exists'),[mozprofparentdir]));
   hostresolved := false;    hostresolved := false;
  DataModule1.TcpSocke.Host := sHost;   if sHost <> 'empty' then
  DataModule1.TcpSocke.ReadTimeOut := 3000; // 3 Sekunden Timeout  
  DataModule1.TcpSocke.Port := 25; //smtp  
  try  
   DataModule1.TcpClient1.LookupHostAddr(sHost);  
   hostresolved := true;  
  except  
   hostresolved := false;  
  end;  
  if not hostresolved then  
   begin    begin
   writelog(Format(getMsg('host_not_resolved'),[sHost]));    DataModule1.TcpSocke.Host := sHost;
   showMessage(Format(getMsg('host_not_resolved'),[sHost]));    DataModule1.TcpSocke.ReadTimeOut := 3000; // 3 Sekunden Timeout
   checkInputData := false;    DataModule1.TcpSocke.Port := 25; //smtp
   exit;    try
  end;     DataModule1.TcpClient1.LookupHostAddr(sHost);
  writelog(Format(getMsg('host_resolved'),[sHost]));     hostresolved := true;
  writelog('Server '+sHost+' konnte resolved werden');    except
  try     hostresolved := false;
   DataModule1.TcpSocke.connect;    end;
  except    if not hostresolved then
   writelog(Format(getMsg('host_not_reached_at_port25'),[sHost]));    begin
   ShowMessage(Format(getMsg('host_not_reached_at_port25'),[sHost]));     writelog(Format(getMsg('host_not_resolved'),[sHost]));
   checkInputData := false;     showMessage(Format(getMsg('host_not_resolved'),[sHost]));
   exit;     checkInputData := false;
     exit;
    end;
    writelog(Format(getMsg('host_resolved'),[sHost]));
    writelog('Server '+sHost+' konnte resolved werden');
    try
     DataModule1.TcpSocke.connect;
    except
     writelog(Format(getMsg('host_not_reached_at_port25'),[sHost]));
     ShowMessage(Format(getMsg('host_not_reached_at_port25'),[sHost]));
     checkInputData := false;
     exit;
    end;
    DataModule1.TcpSocke.Disconnect;
    writelog(Format(getMsg('host_connected_at_port25'),[sHost]));
   end;    end;
  DataModule1.TcpSocke.Disconnect;  
  writelog(Format(getMsg('host_connected_at_port25'),[sHost]));  
 
   if verify_user_at_sendmail then    if verify_user_at_sendmail then
   begin    begin
    try     try
Line 426  end;  Line 442  end; 
  procedure killmozilla;   procedure killmozilla;
  begin   begin
   writelog('killing mozilla.....');    writelog('killing mozilla.....');
  Start(ExtractFilePath(Application.ExeName)+'\kill.exe mozilla.exe');   Start(ExtractFilePath(Application.ExeName)+'\kill.exe '+mozprogname);
  end;   end;
   
   {$IFDEF MSWINDOWS}
  function startmozilla(param : string) : boolean;   function startmozilla(param : string) : boolean;
  var   var
   commandline, option, report : String;    commandline, option, report : String;
  begin   begin
  commandline := MOZPROGDIR+'\mozilla.exe';   commandline := MOZPROGDIR+'\'+mozprogname;
  if not FileExists(MOZPROGDIR+'\mozilla.exe') then   if not FileExists(MOZPROGDIR+'\'+mozprogname) then
   begin    begin
   writelog(Format(getMsg('no_mozilla_exe_found'),[MOZPROGDIR]));    writelog(Format(getMsg('no_mozilla_exe_found'),[mozprogname,MOZPROGDIR]));
   ShowMessage(Format(getMsg('no_mozilla_exe_found_msg'),[MOZPROGDIR]));    ShowMessage(Format(getMsg('no_mozilla_exe_found_msg'),[mozprogname,MOZPROGDIR]));
    application.Terminate;     application.Terminate;
    exit;     exit;
   end    end
   else    else
   begin    begin
   if not Start (commandline+' '+param)    if not Start ('"'+commandline+'" '+param)
    then     then
    Begin     Begin
    writelog('Error starting mozilla');     writelog('Error starting '+mozprogname);
     result := false;      result := false;
    End     End
    else     else
    begin     begin
    writelog('Mozilla started with '+param);     writelog(mozprogname+' started with '+param);
      result := true;       result := true;
    end;     end;
   end;    end;
  end;   end;
   {$ELSE}
    {$IFDEF LINUX}
   function startmozilla(param : string) : boolean;
   begin
    // has to be written....
   end;
    {$ENDIF}
   {$ENDIF}
   
   
 function getMozSltDir(mozhome:string) : string;  function getMozSltDir(mozhome:string) : string;
Line 714  end;  Line 739  end; 
   
 function resolve_variables(tempstr : string; makepref: boolean) : string;  function resolve_variables(tempstr : string; makepref: boolean) : string;
 begin  begin
    tempstr := replaceStr(tempstr,'%mozaplication%',mozaplication);
  tempstr := replaceStr(tempstr,'%sHost%',sHost);   tempstr := replaceStr(tempstr,'%sHost%',sHost);
  tempstr := replaceStr(tempstr,'%sUname%',sUname);   tempstr := replaceStr(tempstr,'%sUname%',sUname);
  tempstr := replaceStr(tempstr,'%replyToAdress%',sReplyToAdress);   tempstr := replaceStr(tempstr,'%replyToAdress%',sReplyToAdress);
Line 728  begin  Line 754  begin 
  tempstr := replaceStr(tempstr,'%HelpVar8%',sHelpVar8);   tempstr := replaceStr(tempstr,'%HelpVar8%',sHelpVar8);
  tempstr := replaceStr(tempstr,'%HelpVar9%',sHelpVar9);   tempstr := replaceStr(tempstr,'%HelpVar9%',sHelpVar9);
  tempstr := replaceStr(tempstr,'%HelpVar10%',sHelpVar10);   tempstr := replaceStr(tempstr,'%HelpVar10%',sHelpVar10);
    tempstr := replaceStr(tempstr,'%mozprogname%',mozprogname);
  if makepref then   if makepref then
  begin   begin
   tempstr := replaceStr(tempstr,'%localMozAppdataDir%',MakePrefPath(localMozAppdataDir));    tempstr := replaceStr(tempstr,'%localMozAppdataDir%',MakePrefPath(localMozAppdataDir));
Line 1022  begin  Line 1049  begin 
  mozptchini.ReadSectionValues('mimetype_helper', tempStrings);   mozptchini.ReadSectionValues('mimetype_helper', tempStrings);
  for i:= 0 to tempStrings.Count-1 do   for i:= 0 to tempStrings.Count-1 do
  begin   begin
  if not ((tempStrings[i] = '') or (pos('//',tempstrings[i])=1)) then   if not ((tempStrings[i] = '') or ((pos('/',tempstrings[i])=1)
                              and (pos('/',tempstrings[i])=2))) then
   begin    begin
    if mozptchini.SectionExists('install-'+tempStrings.Names[i]) then     if mozptchini.SectionExists('install-'+tempStrings.Names[i]) then
    begin     begin
Line 1205  var  Line 1233  var 
   Fehler : string;    Fehler : string;
   problem : string;    problem : string;
   AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word;    AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond: Word;
     rdffile : text;
 begin  begin
  killmozilla;   killmozilla;
  writelog(getMsg('start_procedure_doConfig'));   writelog(getMsg('start_procedure_doConfig'));
Line 1218  begin  Line 1247  begin 
  begin   begin
   // find old profile or create new....    // find old profile or create new....
   //writelog('imap soll eingerichtet werden.....');    //writelog('imap soll eingerichtet werden.....');
  localMozAppdataDir := getAppdataDir+'\mozilla';   localMozAppdataDir := getAppdataDir+'\'+mozaplication_internal;
   writelog('localMozAppdataDir is '+localMozAppdataDir);    writelog('localMozAppdataDir is '+localMozAppdataDir);
   completeMozDir := findOrCreateMozProf;    completeMozDir := findOrCreateMozProf;
   writelog('completeMozDir is '+completeMozDir);    writelog('completeMozDir is '+completeMozDir);
Line 1246  begin  Line 1275  begin 
   if not FileExists(completeMozDir+'\mimetypes.rdf') then    if not FileExists(completeMozDir+'\mimetypes.rdf') then
   begin    begin
    writelog(getMsg('no_mimetypes_rdf_try_template'));     writelog(getMsg('no_mimetypes_rdf_try_template'));
      if not fileExists(completeMozDir+'\mimetypes.tmpl') then
      begin
       AssignFile(rdffile,completeMozDir+'\mimetypes.tmpl');
       rewrite(rdffile);
       writeln(rdffile,'<?xml version="1.0"?>');
       writeln(rdffile,'<RDF:RDF xmlns:NC="http://home.netscape.com/NC-rdf#"');
       writeln(rdffile,'         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">');
       writeln(rdffile,'  <RDF:Description about="urn:mimetypes">');
       writeln(rdffile,'    <NC:MIME-types resource="urn:mimetypes:root"/>');
       writeln(rdffile,'  </RDF:Description>');
       writeln(rdffile,'  <RDF:Seq about="urn:mimetypes:root">');
       writeln(rdffile,'  </RDF:Seq>');
       writeln(rdffile,'</RDF:RDF>');
       CloseFile(rdffile);
      end;
    if not FileCopy(completeMozDir+'\mimetypes.tmpl',     if not FileCopy(completeMozDir+'\mimetypes.tmpl',
                    completeMozDir+'\mimetypes.rdf',                     completeMozDir+'\mimetypes.rdf',
                    true,true,problem) then                     true,true,problem) then
Line 1482  begin  Line 1526  begin 
      if patchPrefs then       if patchPrefs then
      begin       begin
       if Messagebox(0, PChar(Format(getMsg('ask_for_confirmation_with_patch'),        if Messagebox(0, PChar(Format(getMsg('ask_for_confirmation_with_patch'),
                            [completemozdir])),                             [mozaplication,completemozdir])),
              ' Warnung', MB_TASKMODAL + MB_YESNO + MB_DEFBUTTON1) = IDNO then               ' Warnung', MB_TASKMODAL + MB_YESNO + MB_DEFBUTTON1) = IDNO then
       begin        begin
        writelog(getMsg('user_informed_about_existing_prefjs'));         writelog(getMsg('user_informed_about_existing_prefjs'));
Line 1503  begin  Line 1547  begin 
      else       else
      begin       begin
       if Messagebox(0, PChar(Format(getMsg('ask_for_confirmation_without_patch'),        if Messagebox(0, PChar(Format(getMsg('ask_for_confirmation_without_patch'),
                            [completemozdir])),                             [mozaplication,completemozdir])),
                  ' Warnung', MB_TASKMODAL + MB_YESNO + MB_DEFBUTTON1) = IDNO then                   ' Warnung', MB_TASKMODAL + MB_YESNO + MB_DEFBUTTON1) = IDNO then
       begin        begin
        writelog(getMsg('user_informed_about_existing_prefjs'));         writelog(getMsg('user_informed_about_existing_prefjs'));
Line 1565  begin  Line 1609  begin 
   for i := 1 to paramcount do    for i := 1 to paramcount do
   begin    begin
    if (paramstr(i) = '-f') then     if (paramstr(i) = '-f') then
    if paramcount <= i+1 then     if paramcount > i then
     begin      begin
      mozptchiniFileName := paramstr(i+1);       mozptchiniFileName := paramstr(i+1);
     end;      end;
Line 1573  begin  Line 1617  begin 
    if (paramstr(i) = '-s') then interactive := false;     if (paramstr(i) = '-s') then interactive := false;
    // -l parameter for manual language selection     // -l parameter for manual language selection
    if (paramstr(i) = '-l') then     if (paramstr(i) = '-l') then
    if paramcount <= i+1 then     if paramcount > i then
     begin      begin
      syslang := paramstr(i+1);       syslang := paramstr(i+1);
        writelog('Language set by -l Argument to :'+syslang);
     end;      end;
   end;    end;
  end;   end;
Line 1630  begin  Line 1675  begin 
   sHost := ValueOfEnvVar('HOST');    sHost := ValueOfEnvVar('HOST');
   *)    *)
   sTmp := ValueOfEnvVar ('TEMP');    sTmp := ValueOfEnvVar ('TEMP');
     mozaplication := getVariableValue('%mozaplication%');
     mozaplication_internal := getVariableValue('%mozaplication_internal%');
   sHelpVar1 := getVariableValue('%HelpVar1%');    sHelpVar1 := getVariableValue('%HelpVar1%');
   sHelpVar2 := getVariableValue('%HelpVar2%');    sHelpVar2 := getVariableValue('%HelpVar2%');
   sUname := getVariableValue('%sUname%');    sUname := getVariableValue('%sUname%');
Line 1641  begin  Line 1688  begin 
   sHome := getVariableValue('%sHome%');    sHome := getVariableValue('%sHome%');
   sHelpVar7 := getVariableValue('%HelpVar7%');    sHelpVar7 := getVariableValue('%HelpVar7%');
   sHelpVar8 := getVariableValue('%HelpVar8%');    sHelpVar8 := getVariableValue('%HelpVar8%');
  localMozAppdataDir := getAppdataDir+'\mozilla';   localMozAppdataDir := getAppdataDir+'\'+mozaplication_internal;
   writelog('localMozAppdataDir is '+localMozAppdataDir);    writelog('localMozAppdataDir is '+localMozAppdataDir);
   sHelpVar9 := getVariableValue('%HelpVar9%');    sHelpVar9 := getVariableValue('%HelpVar9%');
   sHelpVar10 := getVariableValue('%HelpVar10%');    sHelpVar10 := getVariableValue('%HelpVar10%');
   //sreplyToAdress := getVariableValue('%replyToAdress%');    //sreplyToAdress := getVariableValue('%replyToAdress%');
   // where to find mozilla.exe    // where to find mozilla.exe
   mozprogdir := getVariableValue('%mozprogdir%');    mozprogdir := getVariableValue('%mozprogdir%');
     // name of 'mozilla.exe'
     mozprogname := getVariableValue('%mozprogname%');
   //a mozilla profile path is    //a mozilla profile path is
   // eg. n:/home/user1/mozmail/default/einstell.slt/prefs.js    // eg. n:/home/user1/mozmail/default/einstell.slt/prefs.js
   //where n:/home/user1 is    //where n:/home/user1 is
Line 1700  begin  Line 1749  begin 
    begin     begin
      if InstallNewMail = false then Application.Terminate;       if InstallNewMail = false then Application.Terminate;
      FUser := TFUser.Create(Application);       FUser := TFUser.Create(Application);
     FUser.Caption := getMsg('title_info_about_configuration');      FUser.Caption := Format(getMsg('title_info_about_configuration'),[mozaplication]);
      FUser.CheckBoxPatchPrefs.Caption := getMsg('CheckBoxPatchPrefs_caption');       FUser.CheckBoxPatchPrefs.Caption := getMsg('CheckBoxPatchPrefs_caption');
      FUser.TextViewer1.text := Format(getMsg('main_user_info_about_configuration')       FUser.TextViewer1.text := Format(getMsg('main_user_info_about_configuration')
                                      ,[sUname,sHome,mozprofparentdir]);                                       ,[mozaplication,sUname,sHome,mozprofparentdir,
                                         mozaplication,mozaplication,mozaplication]);
      if FUser.ShowModal = mrCancel then       if FUser.ShowModal = mrCancel then
      begin       begin
       writelog('Programm terminated by user after Info');        writelog('Programm terminated by user after Info');
         FUser.Release;
       Application.Terminate;        Application.Terminate;
       exit;        exit;
      end;       end;
Line 1723  begin  Line 1774  begin 
    end;     end;
    startConfiguration;     startConfiguration;
    if interactive then     if interactive then
     MessageDlg(getMsg('process_finished'), mtInformation, [mbOK], 0);      MessageDlg(Format(getMsg('process_finished'),[mozaplication]), mtInformation, [mbOK], 0);
   end    end
   else    else
   begin    begin

Removed from v.1.4  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>