From 76df851d4a53f694f0901d8a4af8c113757e70d3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 30 May 2019 16:17:02 +0200 Subject: popimapunit.pas: evaluate X-Spam-Level header --- popimapunit.pas | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/popimapunit.pas b/popimapunit.pas index 8d841b1..595eef6 100644 --- a/popimapunit.pas +++ b/popimapunit.pas @@ -12,14 +12,18 @@ type tMarkenValiditaet = (mvKeine,mvGueltig,mvUngueltig); tBefehlAusfuehrenErgebnis = (baeOk,baeError,baeTimeOut); tMailProtocol = (mpPop, mpImap); + tSpamLevel = (slSpam,slHam,slUnbekannt); tPopImapClient = class; tNachricht = class(tMyStringList) private _marke: tMarkenValiditaet; + _spam: tSpamLevel; procedure pruefeMarke; + procedure pruefeSpam; function rMarke: tMarkenValiditaet; + function rSpam: tSpamLevel; public id,groesze: longint; sdbName,gueltigerAdressat: string; @@ -29,6 +33,8 @@ type function istGleich(n: tNachricht): boolean; property marke: tMarkenValiditaet read rMarke; + property spam: tSpamLevel + read rSpam; end; tPopImapThread = class(tThread) @@ -76,6 +82,7 @@ type function von(n: longint): string; function zeit(n: longint): string; function marke(n: longint): tMarkenValiditaet; + function spam(n: longint): tSpamLevel; procedure threadAnhalten; procedure aufThreadWarten; procedure loesche(n: longint); @@ -295,12 +302,37 @@ begin closeFile(f); end; +procedure tNachricht.pruefeSpam; +var + s: string; +begin + s:=grepFirst('^[Xx]-Spam-Status:\s'); + if s='' then begin + _spam:=slUnbekannt; + exit; + end; + + if _spam<>slUnbekannt then + exit; + erstesArgument(s,':'); + if erstesArgument(s,',')='No' then + _spam:=slHam + else + _spam:=slSpam; +end; + function tNachricht.rMarke: tMarkenValiditaet; begin pruefeMarke; result:=_marke; end; +function tNachricht.rSpam: tSpamLevel; +begin + pruefeSpam; + result:=_spam; +end; + procedure tNachricht.kopiereVon(n: tNachricht); begin text:=n.text; @@ -796,6 +828,11 @@ begin result:=_nachrichten[n].marke; end; +function tPopImapClient.spam(n: longint): tSpamLevel; +begin + result:=_nachrichten[n].spam; +end; + procedure tPopImapClient.threadAnhalten; begin _thread.beenden:=true; -- cgit v1.2.3-70-g09d2