Difference between revisions of "Unit POP3"
From Ultibo.org
Line 248: | Line 248: | ||
---- | ---- | ||
− | '' | + | |
+ | '''POP3 buffer''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TPOP3Buffer = class(TObject)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>constructor Create(ASize:LongWord);</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FLock:TCriticalSectionHandle;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FData:Pointer;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FSize:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FStart:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function AcquireLock:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function ReleaseLock:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function GetCount:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property Count:LongWord read GetCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function ReadData:Char;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function WriteData(AChar:Char):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function WriteLock(var ASize:LongWord):Pointer;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function WriteUnlock(ACount:LongWord):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''POP3 client''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TPOP3Client = class(TWinsock2TCPClient)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>constructor Create;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FOnRequest:TPOP3ClientNotifyEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnReply:TPOP3ClientNotifyEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FOnRequestStart:TNotifyEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnRequestEnd:TNotifyEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FBuffer:TPOP3Buffer;</code> | ||
+ | | Buffer for received data | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div> | ||
+ | |- | ||
+ | | <code>function GetReply(var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendRequest(const ARequest:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property OnRequest:TPOP3ClientNotifyEvent read FOnRequest write FOnRequest;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnReply:TPOP3ClientNotifyEvent read FOnReply write FOnReply;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property OnRequestStart:TNotifyEvent read FOnRequestStart write FOnRequestStart;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnRequestEnd:TNotifyEvent read FOnRequestEnd write FOnRequestEnd;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property Buffer:TPOP3Buffer read FBuffer;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function DoConn(const AHost,APort:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoStat(var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoList(const AMessage:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoRetr(const AMessage:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoDele(const AMessage:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoNoop(var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoRset(var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoQuit(var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function DoTop(const AMessage,ACount:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoUidl(const AMessage:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoUser(const AUsername:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoPass(const APassword:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoApop(const AUsername,ADigest:String; var AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''POP3 connection''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TPOP3Connection = class(TListObject)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>constructor Create;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | | <code>destructor Destroy; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FLock:TCriticalSectionHandle;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FHandle:LongWord;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FRxByteCount:Int64;</code> | ||
+ | | Bytes Recv Count from Connection | ||
+ | |- | ||
+ | | <code>FTxByteCount:Int64;</code> | ||
+ | | Bytes Sent Count to Connection | ||
+ | |- | ||
+ | | <code>FRequestCount:Int64;</code> | ||
+ | | Requests Recv Count from Connection | ||
+ | |- | ||
+ | | <code>FReplyCount:Int64;</code> | ||
+ | | Replies Sent Count to Connection | ||
+ | |- | ||
+ | | <code>FRequestTime:TDateTime;</code> | ||
+ | | Last Request Time | ||
+ | |- | ||
+ | | <code>FReplyTime:TDateTime;</code> | ||
+ | | Last Reply Time | ||
+ | |- | ||
+ | | <code>FRemoteAddress:String;</code> | ||
+ | | Address of Remote Client | ||
+ | |- | ||
+ | | <code>FStatus:LongWord;</code> | ||
+ | | None,Conn,User,Data etc | ||
+ | |- | ||
+ | | <code>FUsername:String;</code> | ||
+ | | Current Username | ||
+ | |- | ||
+ | | <code>FPassword:String;</code> | ||
+ | | Current Password | ||
+ | |- | ||
+ | | <code>FTimestamp:String;</code> | ||
+ | | Timestamp for APOP authentication | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FThread:TThread;</code> | ||
+ | | TWinsock2TCPServerThread | ||
+ | |- | ||
+ | | <code>FBuffer:TPOP3Buffer;</code> | ||
+ | | Buffer for received data | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function AcquireLock:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function ReleaseLock:Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>procedure SetHandle(AHandle:LongWord);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetRxByteCount:Int64;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetRxByteCount(const ARxByteCount:Int64);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetTxByteCount:Int64;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetTxByteCount(const ATxByteCount:Int64);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetRequestCount:Int64;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetRequestCount(const ARequestCount:Int64);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetReplyCount:Int64;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetReplyCount(const AReplyCount:Int64);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetRequestTime:TDateTime;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetRequestTime(const ARequestTime:TDateTime);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetReplyTime:TDateTime;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetReplyTime(const AReplyTime:TDateTime);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetRemoteAddress:String;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetRemoteAddress(const ARemoteAddress:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetStatus(AStatus:LongWord);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetUsername:String;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetUsername(const AUsername:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetPassword:String;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetPassword(const APassword:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function GetTimestamp:String;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure SetTimestamp(const ATimestamp:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>procedure SetThread(AThread:TThread);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property Handle:LongWord read FHandle write SetHandle;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property RxByteCount:Int64 read GetRxByteCount write SetRxByteCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property TxByteCount:Int64 read GetTxByteCount write SetTxByteCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property RequestCount:Int64 read GetRequestCount write SetRequestCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property ReplyCount:Int64 read GetReplyCount write SetReplyCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property RequestTime:TDateTime read GetRequestTime write SetRequestTime;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property ReplyTime:TDateTime read GetReplyTime write SetReplyTime;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property RemoteAddress:String read GetRemoteAddress write SetRemoteAddress;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property Status:LongWord read FStatus write SetStatus;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property Username:String read GetUsername write SetUsername;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property Password:String read GetPassword write SetPassword;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property Timestamp:String read GetTimestamp write SetTimestamp;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property Thread:TThread read FThread write SetThread;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property Buffer:TPOP3Buffer read FBuffer;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>procedure IncrementRxByteCount(const ARxByteCount:Int64);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure IncrementTxByteCount(const ATxByteCount:Int64);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure IncrementRequestCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure IncrementReplyCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | |||
+ | '''POP3 listener''' | ||
+ | |||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;"> | ||
+ | |||
+ | <code>TPOP3Listener = class(TWinsock2TCPListener)</code> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>constructor Create;</code> | ||
+ | | style="width: 50%;"| | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div> | ||
+ | |- | ||
+ | | <code>FOnConnected:TPOP3ConnectionEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnDisconnected:TPOP3ConnectionEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FOnCheckHost:TPOP3HostEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnCheckCount:TPOP3CountEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FOnRequest:TPOP3NotifyEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnReply:TPOP3NotifyEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FOnConn:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnStat:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnList:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnRetr:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnDele:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnNoop:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnRset:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnQuit:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>FOnTop:TPOP3RequestExEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnUidl:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnUser:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnPass:TPOP3RequestEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>FOnApop:TPOP3RequestExEvent;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div> | ||
+ | |- | ||
+ | | <code>procedure DoConnect(AThread:TWinsock2TCPServerThread); override;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoDisconnect(AThread:TWinsock2TCPServerThread); override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function DoCheckHost(AThread:TWinsock2TCPServerThread):Boolean; virtual;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function DoCheckCount(AThread:TWinsock2TCPServerThread):Boolean; virtual;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function DoExecute(AThread:TWinsock2TCPServerThread):Boolean; override;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>procedure DoConn(AThread:TWinsock2TCPServerThread);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoStat(AThread:TWinsock2TCPServerThread);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoList(AThread:TWinsock2TCPServerThread; const AMessage:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoRetr(AThread:TWinsock2TCPServerThread; const AMessage:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoDele(AThread:TWinsock2TCPServerThread; const AMessage:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoNoop(AThread:TWinsock2TCPServerThread);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoRset(AThread:TWinsock2TCPServerThread);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoQuit(AThread:TWinsock2TCPServerThread);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>procedure DoTop(AThread:TWinsock2TCPServerThread; const AMessage,ACount:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoUidl(AThread:TWinsock2TCPServerThread; const AMessage:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoUser(AThread:TWinsock2TCPServerThread; const AUsername:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoPass(AThread:TWinsock2TCPServerThread; const APassword:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>procedure DoApop(AThread:TWinsock2TCPServerThread; const AUsername,ADigest:String);</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>function GetRequest(AThread:TWinsock2TCPServerThread; var ARequest:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>function SendReply(AThread:TWinsock2TCPServerThread; const AReply:String):Boolean;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div> | ||
+ | |- | ||
+ | | <code>property OnConnected:TPOP3ConnectionEvent read FOnConnected write FOnConnected;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnDisconnected:TPOP3ConnectionEvent read FOnDisconnected write FOnDisconnected;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property OnCheckHost:TPOP3HostEvent read FOnCheckHost write FOnCheckHost;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnCheckCount:TPOP3CountEvent read FOnCheckCount write FOnCheckCount;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property OnRequest:TPOP3NotifyEvent read FOnRequest write FOnRequest;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnReply:TPOP3NotifyEvent read FOnReply write FOnReply;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property OnConn:TPOP3RequestEvent read FOnConn write FOnConn;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnStat:TPOP3RequestEvent read FOnStat write FOnStat;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnList:TPOP3RequestEvent read FOnList write FOnList;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnRetr:TPOP3RequestEvent read FOnRetr write FOnRetr;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnDele:TPOP3RequestEvent read FOnDele write FOnDele;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnNoop:TPOP3RequestEvent read FOnNoop write FOnNoop;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnRset:TPOP3RequestEvent read FOnRset write FOnRset;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnQuit:TPOP3RequestEvent read FOnQuit write FOnQuit;</code> | ||
+ | | | ||
+ | |- | ||
+ | |colspan="2"| | ||
+ | |- | ||
+ | | <code>property OnTop:TPOP3RequestExEvent read FOnTop write FOnTop;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnUidl:TPOP3RequestEvent read FOnUidl write FOnUidl;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnUser:TPOP3RequestEvent read FOnUser write FOnUser;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnPass:TPOP3RequestEvent read FOnPass write FOnPass;</code> | ||
+ | | | ||
+ | |- | ||
+ | | <code>property OnApop:TPOP3RequestExEvent read FOnApop write FOnApop;</code> | ||
+ | | | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
=== Public variables === | === Public variables === |
Revision as of 04:42, 17 March 2017
Return to Unit Reference
Contents
Description
Ultibo POP3 interface unit
To be documented
Constants
POP3 specific constants
POP3_*
POP3_LINE_END = Chr(13) + Chr(10);
|
CR LF |
POP3_BUFFER_SIZE = SIZE_4K;
|
POP3 status constants
POP3_STATUS_*
POP3_STATUS_NONE = 0;
|
|
POP3_STATUS_CONN = 1;
|
|
POP3_STATUS_USER = 2;
|
|
POP3_STATUS_PASS = 3;
|
|
POP3_STATUS_APOP = 4;
|
|
POP3_STATUS_DATA = 5;
|
|
POP3_STATUS_QUIT = 6;
|
|
POP3_MAX_STATUS = 6;
|
POP3 command constants
POP3_COMMAND_*
POP3_COMMAND_STAT = 'STAT';
|
|
POP3_COMMAND_LIST = 'LIST';
|
|
POP3_COMMAND_RETR = 'RETR';
|
|
POP3_COMMAND_DELE = 'DELE';
|
|
POP3_COMMAND_NOOP = 'NOOP';
|
|
POP3_COMMAND_RSET = 'RSET';
|
|
POP3_COMMAND_QUIT = 'QUIT';
|
|
POP3_COMMAND_TOP = 'TOP';
|
|
POP3_COMMAND_UIDL = 'UIDL';
|
|
POP3_COMMAND_USER = 'USER';
|
|
POP3_COMMAND_PASS = 'PASS';
|
|
POP3_COMMAND_APOP = 'APOP';
|
POP3 string constants
POP3_STRING_*
POP3_STRING_SUCCESS = '+OK ';
|
|
POP3_STRING_FAILURE = '-ERR ';
|
|
POP3_STRING_COMPLETE = '.';
|
|
POP3_STRING_SIGNON = 'Ultibo POP3 server (version ' + ULTIBO_RELEASE_VERSION + ')';
|
|
POP3_STRING_SIGNOFF = 'Ultibo POP3 server closing connection';
|
|
POP3_STRING_EMPTY_STAT = '0 0';
|
|
POP3_STRING_EMPTY_LIST = '0 messages (0 octets)';
|
|
POP3_STRING_BAD_COMMAND = 'Bad command';
|
|
POP3_STRING_BAD_MESSAGE = 'No such message';
|
|
POP3_STRING_BAD_USERNAME = 'Invalid username or password';
|
|
POP3_STRING_BAD_PASSWORD = 'Invalid username or password';
|
|
POP3_STRING_NO_PERMISSION = 'Permission denied';
|
POP3 logging constants
POP3_LOG_*
POP3_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;
|
POP3 debugging messages |
POP3_LOG_LEVEL_INFO = LOG_LEVEL_INFO;
|
POP3 informational messages |
POP3_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;
|
POP3 error messages |
POP3_LOG_LEVEL_NONE = LOG_LEVEL_NONE;
|
No POP3 messages |
Type definitions
POP3 client notify event
TPOP3ClientNotifyEvent = procedure(const ARequest:String) of Object;
|
POP3 host event
TPOP3HostEvent = function(AConnection:TPOP3Connection):Boolean of Object;
|
POP3 count event
TPOP3CountEvent = function(AConnection:TPOP3Connection):Boolean of Object;
|
POP3 notify event
TPOP3NotifyEvent = procedure(AConnection:TPOP3Connection; const ARequest:String) of Object;
|
POP3 request event
TPOP3RequestEvent = function(AConnection:TPOP3Connection; const ARequest:String; var AReply:String):Boolean of Object;
|
POP3 request extended event
TPOP3RequestExEvent = function(AConnection:TPOP3Connection; const ARequest,AData:String; var AReply:String):Boolean of Object;
|
POP3 connection event
TPOP3ConnectionEvent = procedure(AConnection:TPOP3Connection) of Object;
|
Class definitions
POP3 buffer
TPOP3Buffer = class(TObject)
public
| |
constructor Create(ASize:LongWord);
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TCriticalSectionHandle;
|
|
FData:Pointer;
|
|
FSize:LongWord;
|
|
FCount:LongWord;
|
|
FStart:LongWord;
|
|
function AcquireLock:Boolean;
|
|
function ReleaseLock:Boolean;
|
|
function GetCount:LongWord;
|
|
public
| |
property Count:LongWord read GetCount;
|
|
function ReadData:Char;
|
|
function WriteData(AChar:Char):Boolean;
|
|
function WriteLock(var ASize:LongWord):Pointer;
|
|
function WriteUnlock(ACount:LongWord):Boolean;
|
POP3 client
TPOP3Client = class(TWinsock2TCPClient)
public
| |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FOnRequest:TPOP3ClientNotifyEvent;
|
|
FOnReply:TPOP3ClientNotifyEvent;
|
|
FOnRequestStart:TNotifyEvent;
|
|
FOnRequestEnd:TNotifyEvent;
|
|
FBuffer:TPOP3Buffer;
|
Buffer for received data |
protected
| |
function GetReply(var AReply:String):Boolean;
|
|
function SendRequest(const ARequest:String):Boolean;
|
|
public
| |
property OnRequest:TPOP3ClientNotifyEvent read FOnRequest write FOnRequest;
|
|
property OnReply:TPOP3ClientNotifyEvent read FOnReply write FOnReply;
|
|
property OnRequestStart:TNotifyEvent read FOnRequestStart write FOnRequestStart;
|
|
property OnRequestEnd:TNotifyEvent read FOnRequestEnd write FOnRequestEnd;
|
|
property Buffer:TPOP3Buffer read FBuffer;
|
|
function DoConn(const AHost,APort:String; var AReply:String):Boolean;
|
|
function DoStat(var AReply:String):Boolean;
|
|
function DoList(const AMessage:String; var AReply:String):Boolean;
|
|
function DoRetr(const AMessage:String; var AReply:String):Boolean;
|
|
function DoDele(const AMessage:String; var AReply:String):Boolean;
|
|
function DoNoop(var AReply:String):Boolean;
|
|
function DoRset(var AReply:String):Boolean;
|
|
function DoQuit(var AReply:String):Boolean;
|
|
function DoTop(const AMessage,ACount:String; var AReply:String):Boolean;
|
|
function DoUidl(const AMessage:String; var AReply:String):Boolean;
|
|
function DoUser(const AUsername:String; var AReply:String):Boolean;
|
|
function DoPass(const APassword:String; var AReply:String):Boolean;
|
|
function DoApop(const AUsername,ADigest:String; var AReply:String):Boolean;
|
POP3 connection
TPOP3Connection = class(TListObject)
public
| |
constructor Create;
|
|
destructor Destroy; override;
|
|
private
| |
FLock:TCriticalSectionHandle;
|
|
FHandle:LongWord;
|
|
FRxByteCount:Int64;
|
Bytes Recv Count from Connection |
FTxByteCount:Int64;
|
Bytes Sent Count to Connection |
FRequestCount:Int64;
|
Requests Recv Count from Connection |
FReplyCount:Int64;
|
Replies Sent Count to Connection |
FRequestTime:TDateTime;
|
Last Request Time |
FReplyTime:TDateTime;
|
Last Reply Time |
FRemoteAddress:String;
|
Address of Remote Client |
FStatus:LongWord;
|
None,Conn,User,Data etc |
FUsername:String;
|
Current Username |
FPassword:String;
|
Current Password |
FTimestamp:String;
|
Timestamp for APOP authentication |
FThread:TThread;
|
TWinsock2TCPServerThread |
FBuffer:TPOP3Buffer;
|
Buffer for received data |
function AcquireLock:Boolean;
|
|
function ReleaseLock:Boolean;
|
|
procedure SetHandle(AHandle:LongWord);
|
|
function GetRxByteCount:Int64;
|
|
procedure SetRxByteCount(const ARxByteCount:Int64);
|
|
function GetTxByteCount:Int64;
|
|
procedure SetTxByteCount(const ATxByteCount:Int64);
|
|
function GetRequestCount:Int64;
|
|
procedure SetRequestCount(const ARequestCount:Int64);
|
|
function GetReplyCount:Int64;
|
|
procedure SetReplyCount(const AReplyCount:Int64);
|
|
function GetRequestTime:TDateTime;
|
|
procedure SetRequestTime(const ARequestTime:TDateTime);
|
|
function GetReplyTime:TDateTime;
|
|
procedure SetReplyTime(const AReplyTime:TDateTime);
|
|
function GetRemoteAddress:String;
|
|
procedure SetRemoteAddress(const ARemoteAddress:String);
|
|
procedure SetStatus(AStatus:LongWord);
|
|
function GetUsername:String;
|
|
procedure SetUsername(const AUsername:String);
|
|
function GetPassword:String;
|
|
procedure SetPassword(const APassword:String);
|
|
function GetTimestamp:String;
|
|
procedure SetTimestamp(const ATimestamp:String);
|
|
procedure SetThread(AThread:TThread);
|
|
public
| |
property Handle:LongWord read FHandle write SetHandle;
|
|
property RxByteCount:Int64 read GetRxByteCount write SetRxByteCount;
|
|
property TxByteCount:Int64 read GetTxByteCount write SetTxByteCount;
|
|
property RequestCount:Int64 read GetRequestCount write SetRequestCount;
|
|
property ReplyCount:Int64 read GetReplyCount write SetReplyCount;
|
|
property RequestTime:TDateTime read GetRequestTime write SetRequestTime;
|
|
property ReplyTime:TDateTime read GetReplyTime write SetReplyTime;
|
|
property RemoteAddress:String read GetRemoteAddress write SetRemoteAddress;
|
|
property Status:LongWord read FStatus write SetStatus;
|
|
property Username:String read GetUsername write SetUsername;
|
|
property Password:String read GetPassword write SetPassword;
|
|
property Timestamp:String read GetTimestamp write SetTimestamp;
|
|
property Thread:TThread read FThread write SetThread;
|
|
property Buffer:TPOP3Buffer read FBuffer;
|
|
procedure IncrementRxByteCount(const ARxByteCount:Int64);
|
|
procedure IncrementTxByteCount(const ATxByteCount:Int64);
|
|
procedure IncrementRequestCount;
|
|
procedure IncrementReplyCount;
|
POP3 listener
TPOP3Listener = class(TWinsock2TCPListener)
public
| |
constructor Create;
|
|
private
| |
FOnConnected:TPOP3ConnectionEvent;
|
|
FOnDisconnected:TPOP3ConnectionEvent;
|
|
FOnCheckHost:TPOP3HostEvent;
|
|
FOnCheckCount:TPOP3CountEvent;
|
|
FOnRequest:TPOP3NotifyEvent;
|
|
FOnReply:TPOP3NotifyEvent;
|
|
FOnConn:TPOP3RequestEvent;
|
|
FOnStat:TPOP3RequestEvent;
|
|
FOnList:TPOP3RequestEvent;
|
|
FOnRetr:TPOP3RequestEvent;
|
|
FOnDele:TPOP3RequestEvent;
|
|
FOnNoop:TPOP3RequestEvent;
|
|
FOnRset:TPOP3RequestEvent;
|
|
FOnQuit:TPOP3RequestEvent;
|
|
FOnTop:TPOP3RequestExEvent;
|
|
FOnUidl:TPOP3RequestEvent;
|
|
FOnUser:TPOP3RequestEvent;
|
|
FOnPass:TPOP3RequestEvent;
|
|
FOnApop:TPOP3RequestExEvent;
|
|
protected
| |
procedure DoConnect(AThread:TWinsock2TCPServerThread); override;
|
|
procedure DoDisconnect(AThread:TWinsock2TCPServerThread); override;
|
|
function DoCheckHost(AThread:TWinsock2TCPServerThread):Boolean; virtual;
|
|
function DoCheckCount(AThread:TWinsock2TCPServerThread):Boolean; virtual;
|
|
function DoExecute(AThread:TWinsock2TCPServerThread):Boolean; override;
|
|
procedure DoConn(AThread:TWinsock2TCPServerThread);
|
|
procedure DoStat(AThread:TWinsock2TCPServerThread);
|
|
procedure DoList(AThread:TWinsock2TCPServerThread; const AMessage:String);
|
|
procedure DoRetr(AThread:TWinsock2TCPServerThread; const AMessage:String);
|
|
procedure DoDele(AThread:TWinsock2TCPServerThread; const AMessage:String);
|
|
procedure DoNoop(AThread:TWinsock2TCPServerThread);
|
|
procedure DoRset(AThread:TWinsock2TCPServerThread);
|
|
procedure DoQuit(AThread:TWinsock2TCPServerThread);
|
|
procedure DoTop(AThread:TWinsock2TCPServerThread; const AMessage,ACount:String);
|
|
procedure DoUidl(AThread:TWinsock2TCPServerThread; const AMessage:String);
|
|
procedure DoUser(AThread:TWinsock2TCPServerThread; const AUsername:String);
|
|
procedure DoPass(AThread:TWinsock2TCPServerThread; const APassword:String);
|
|
procedure DoApop(AThread:TWinsock2TCPServerThread; const AUsername,ADigest:String);
|
|
function GetRequest(AThread:TWinsock2TCPServerThread; var ARequest:String):Boolean;
|
|
function SendReply(AThread:TWinsock2TCPServerThread; const AReply:String):Boolean;
|
|
public
| |
property OnConnected:TPOP3ConnectionEvent read FOnConnected write FOnConnected;
|
|
property OnDisconnected:TPOP3ConnectionEvent read FOnDisconnected write FOnDisconnected;
|
|
property OnCheckHost:TPOP3HostEvent read FOnCheckHost write FOnCheckHost;
|
|
property OnCheckCount:TPOP3CountEvent read FOnCheckCount write FOnCheckCount;
|
|
property OnRequest:TPOP3NotifyEvent read FOnRequest write FOnRequest;
|
|
property OnReply:TPOP3NotifyEvent read FOnReply write FOnReply;
|
|
property OnConn:TPOP3RequestEvent read FOnConn write FOnConn;
|
|
property OnStat:TPOP3RequestEvent read FOnStat write FOnStat;
|
|
property OnList:TPOP3RequestEvent read FOnList write FOnList;
|
|
property OnRetr:TPOP3RequestEvent read FOnRetr write FOnRetr;
|
|
property OnDele:TPOP3RequestEvent read FOnDele write FOnDele;
|
|
property OnNoop:TPOP3RequestEvent read FOnNoop write FOnNoop;
|
|
property OnRset:TPOP3RequestEvent read FOnRset write FOnRset;
|
|
property OnQuit:TPOP3RequestEvent read FOnQuit write FOnQuit;
|
|
property OnTop:TPOP3RequestExEvent read FOnTop write FOnTop;
|
|
property OnUidl:TPOP3RequestEvent read FOnUidl write FOnUidl;
|
|
property OnUser:TPOP3RequestEvent read FOnUser write FOnUser;
|
|
property OnPass:TPOP3RequestEvent read FOnPass write FOnPass;
|
|
property OnApop:TPOP3RequestExEvent read FOnApop write FOnApop;
|
Public variables
POP3 logging
POP3_DEFAULT_LOG_LEVEL:LongWord = POP3_LOG_LEVEL_DEBUG;
|
Minimum level for POP3 messages. Only messages with level greater than or equal to this will be printed. |
POP3_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
procedure POP3Init;
Description: To be documented
Note | None documented |
---|
POP3 helper functions
procedure POP3Log(Level:LongWord; const AText:String);
Description: To be documented
Note | None documented |
---|
procedure POP3LogInfo(const AText:String);
Description: To be documented
Note | None documented |
---|
procedure POP3LogError(const AText:String);
Description: To be documented
Note | None documented |
---|
procedure POP3LogDebug(const AText:String);
Description: To be documented
Note | None documented |
---|
Return to Unit Reference