From 97d06f3e79bbdf4941b4d7144d06c6051811a5bf Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 5 Apr 2019 14:16:12 +0200 Subject: geht nun auch mit imap --- emails.lpi | 20 +++--- emails.lpr | 2 +- emails.lps | 231 +++++++++++++++++++++++++++++++++++-------------------------- emails.res | Bin 138932 -> 139052 bytes unit1.lfm | 10 +-- unit1.pas | 163 +++++++++++++++++++++++++++---------------- 6 files changed, 255 insertions(+), 171 deletions(-) diff --git a/emails.lpi b/emails.lpi index 9d3caa8..11ea4cc 100644 --- a/emails.lpi +++ b/emails.lpi @@ -1,7 +1,7 @@ - + @@ -13,9 +13,6 @@ - - - @@ -23,16 +20,17 @@ - - - + + + + - + @@ -46,9 +44,13 @@ - + + + + + diff --git a/emails.lpr b/emails.lpr index b139b94..e4eb2b7 100644 --- a/emails.lpr +++ b/emails.lpr @@ -5,7 +5,7 @@ program emails; uses cthreads, Interfaces, // this includes the LCL widgetset - Forms, Unit1, popunit + Forms, Unit1, popimapunit, deencrypt { you can add units after this }; {$R *.res} diff --git a/emails.lps b/emails.lps index d0b9298..aeced4f 100644 --- a/emails.lps +++ b/emails.lps @@ -1,15 +1,16 @@ - + - + - - - + + + + @@ -18,191 +19,225 @@ - - - - + + + - + - - - - + + + + + - + - - + + + - + - - - + + + + + + + + + - + + - + - - + + - + - + - - + + - - - + + + - - - + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + diff --git a/emails.res b/emails.res index 877868c..f6e8499 100644 Binary files a/emails.res and b/emails.res differ diff --git a/unit1.lfm b/unit1.lfm index a8fbd46..a8f9e56 100644 --- a/unit1.lfm +++ b/unit1.lfm @@ -11,7 +11,7 @@ object Form1: TForm1 OnDestroy = FormDestroy OnResize = FormResize OnShow = FormShow - LCLVersion = '1.8.4.0' + LCLVersion = '2.0.0.4' object Memo1: TMemo Left = 0 Height = 584 @@ -73,18 +73,18 @@ object Form1: TForm1 end object CheckBox1: TCheckBox Left = 272 - Height = 21 + Height = 23 Top = 596 - Width = 93 + Width = 96 Caption = 'aufploppen' OnClick = CheckBox1Click TabOrder = 2 end object CheckBox2: TCheckBox Left = 416 - Height = 21 + Height = 23 Top = 596 - Width = 86 + Width = 91 Caption = 'Ton geben' Checked = True OnClick = CheckBox1Click diff --git a/unit1.pas b/unit1.pas index 12bddaf..fe3236a 100644 --- a/unit1.pas +++ b/unit1.pas @@ -6,7 +6,7 @@ interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, - ExtCtrls, popunit, gitUpdateUnit; + ExtCtrls, popimapunit, gitUpdateUnit; type @@ -36,7 +36,7 @@ type lb: tMouseButton; public { public declarations } - pc: tPopClient; + pc: tPopImapClient; procedure neueNachrichten(sender: tObject); end; @@ -53,68 +53,99 @@ uses myStringListUnit, lowLevelUnit, process; procedure TForm1.FormCreate(Sender: TObject); var - sl: tMyStringList; - s,ga: string; + sl: tMyStringList; + s,ga: string; + found: boolean; begin __ausgabenMaske:=1; - ga:='.*@eckner\.net' +'|'+ - '(ee|intern|vorstand)@wurzel\.org' +'|'+ - 'erich\.eckner@uni-jena\.de' +'|'+ - 'erich\.eckner@gmx\.de' +'|'+ - '(ioq_(nlo|staff)|alle_mitarbeiter|fsr-physik-newsletter)@listserv\.uni-jena\.de' +'|'+ - '(sox-users|logwatch-devel)@lists\.sourceforge\.net' +'|'+ - 'gmp-discuss@gmplib\.org' +'|'+ - 'hashcash@freelists\.org' +'|'+ - 'crux(-commits)?@lists\.crux\.nu' +'|'+ - 'radvd-devel-l@lists\.litech\.org' +'|'+ - 'arch-general-request@archlinux\.org'; - if fileexists(extractfilepath(application.exename)+'optionen.konf') then begin - sl:=tMyStringList.create; - sl.loadFromFile(extractfilepath(application.exename)+'optionen.konf'); - - s:=sl.grepFirst('^aufploppen\s*='); - erstesArgument(s,'='); - if uppercase(s)='JA' then - checkBox1.checked:=true - else if uppercase(s)='NEIN' then - checkBox1.checked:=false - else if s<>'' then - raise exception.create(''''+s+''' ist kein gültiger Wert für ''aufploppen'' (ja|nein)!'); - - s:=sl.grepFirst('^Ton\s+geben\s*='); - erstesArgument(s,'='); - if uppercase(s)='JA' then - checkBox2.checked:=true - else if uppercase(s)='NEIN' then - checkBox2.checked:=false - else if s<>'' then - raise exception.create(''''+s+''' ist kein gültiger Wert für ''Ton geben'' (ja|nein)!'); - - sl.grep('^gültiger\s+Adressat\s*='); - if sl.count>0 then begin - ga:=''; - sl.rewind; - while sl.readln(s) do begin - erstesArgument(s,'='); - ga:=ga+'|'+s; - end; - delete(ga,1,1); - end; - sl.free; - end; + if not fileexists(extractfilepath(application.exename)+'optionen.konf') then + raise exception.create('Kann Optionendatei ''' + extractfilepath(application.exename) + 'optionen.konf' + ''' nicht finden!'); - writeln(ga); - - pc:=tPopClient.create; - pc.timeout:=10; + sl:=tMyStringList.create; + sl.loadFromFile(extractfilepath(application.exename)+'optionen.konf'); + + s:=sl.grepFirst('^aufploppen\s*='); + erstesArgument(s,'='); + if uppercase(s)='JA' then + checkBox1.checked:=true + else if uppercase(s)='NEIN' then + checkBox1.checked:=false + else if s<>'' then + raise exception.create(''''+s+''' ist kein gültiger Wert für ''aufploppen'' (ja|nein)!'); + + s:=sl.grepFirst('^Ton\s+geben\s*='); + erstesArgument(s,'='); + if uppercase(s)='JA' then + checkBox2.checked:=true + else if uppercase(s)='NEIN' then + checkBox2.checked:=false + else if s<>'' then + raise exception.create(''''+s+''' ist kein gültiger Wert für ''Ton geben'' (ja|nein)!'); + + pc:=tPopImapClient.create; + s:=sl.grepFirst('^Timeout\s*='); + if erstesArgument(s,'=')<>'' then + pc.timeout:=strToFloat(s); pc.neueNachrichten:=@neueNachrichten; -// pc.sshUser:='erich'; - pc.host:='eckner.net'; - pc.user:='notify@eckner.net'; - pc.pass:='C7sd7k8*'; + s:=sl.grepFirst('^ssh-User\s*='); + if erstesArgument(s,'=')<>'' then + pc.sshUser:=s; + s:=sl.grepFirst('^Host\s*='); + if erstesArgument(s,'=')<>'' then + pc.host:=s + else + raise exception.create('Kein Host in '''+extractfilepath(application.exename)+'optionen.konf'' angegeben!'); + s:=sl.grepFirst('^User\s*='); + if erstesArgument(s,'=')<>'' then + pc.user:=s + else + raise exception.create('Kein User in '''+extractfilepath(application.exename)+'optionen.konf'' angegeben!'); + s:=sl.grepFirst('^Pass\s*='); + if erstesArgument(s,'=')<>'' then + pc.pass:=s + else + raise exception.create('Kein Pass in '''+extractfilepath(application.exename)+'optionen.konf'' angegeben!'); + found:=false; + s:=sl.grepFirst('^Port\s*='); + if erstesArgument(s,'=')<>'' then begin + pc.port:=strToInt(s); + found:=true; + end; + s:=sl.grepFirst('^Protocol\s*='); + erstesArgument(s,'='); + if s='pop' then begin + pc.mailProtocol:=mpPop; + if not found then + pc.port:=995; + end + else if s='imap' then begin + pc.mailProtocol:=mpImap; + if not found then + pc.port:=993; + end + else begin + if not found then + raise exception.create('Kein Port und kein Protocol in '''+extractfilepath(application.exename)+'optionen.konf'' angegeben!'); + if pc.port=993 then + pc.mailProtocol:=mpImap + else if pc.port=995 then + pc.mailProtocol:=mpPop + else + raise exception.create('Ungültiges/unbekanntes Mail-Protokoll '''+s+'''!'); + end; + + sl.grep('^gültiger\s+Adressat\s*='); + if sl.count>0 then begin + ga:=''; + sl.rewind; + while sl.readln(s) do begin + erstesArgument(s,'='); + ga:=ga+'|'+s; + end; + delete(ga,1,1); + end; pc.gueltigerAdressat:='('+ga+')'; - pc.port:=995; end; procedure TForm1.FormDestroy(Sender: TObject); @@ -148,6 +179,22 @@ begin sl.addWithLineBreaks('gültiger Adressat = '+umbrechen(copy(pc.gueltigerAdressat,2,length(pc.gueltigerAdressat)-2),'|',true,'gültiger Adressat = ')); + sl.add('Timeout = ' + floatToStr(pc.timeOut)); + if pc.sshUser<>'' then + sl.add('ssh-User = ' + pc.sshUser); + sl.add('Host = ' + pc.host); + sl.add('User = ' + pc.user); + sl.add('Pass = ' + pc.pass); + sl.add('Port = ' + intToStr(pc.port)); + case pc.mailProtocol of + mpPop: + sl.add('Protocol = pop'); + mpImap: + sl.add('Protocol = pop'); + else + raise exception.create('unbekanntes Mail-Protokoll!'); + end{of Case}; + sl.saveToFile(extractfilepath(application.exename)+'optionen.konf'); sl.free; end; -- cgit v1.2.3-54-g00ecf