Difference between revisions of "Unit POP3"

From Ultibo.org
Jump to: navigation, search
Line 248: Line 248:
 
----
 
----
  
''To be documented''
+
 
 +
'''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%;"|&nbsp;
 +
|-
 +
| <code>destructor Destroy; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FLock:TCriticalSectionHandle;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FData:Pointer;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FSize:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FStart:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function AcquireLock:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function ReleaseLock:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetCount:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property Count:LongWord read GetCount;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function ReadData:Char;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function WriteData(AChar:Char):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function WriteLock(var ASize:LongWord):Pointer;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function WriteUnlock(ACount:LongWord):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</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%;"|&nbsp;
 +
|-
 +
| <code>destructor Destroy; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FOnRequest:TPOP3ClientNotifyEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnReply:TPOP3ClientNotifyEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FOnRequestStart:TNotifyEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnRequestEnd:TNotifyEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <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>
 +
| &nbsp;
 +
|-
 +
| <code>function SendRequest(const ARequest:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property OnRequest:TPOP3ClientNotifyEvent read FOnRequest write FOnRequest;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnReply:TPOP3ClientNotifyEvent read FOnReply write FOnReply;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property OnRequestStart:TNotifyEvent read FOnRequestStart write FOnRequestStart;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnRequestEnd:TNotifyEvent read FOnRequestEnd write FOnRequestEnd;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property Buffer:TPOP3Buffer read FBuffer;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function DoConn(const AHost,APort:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoStat(var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoList(const AMessage:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoRetr(const AMessage:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoDele(const AMessage:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoNoop(var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoRset(var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoQuit(var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function DoTop(const AMessage,ACount:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoUidl(const AMessage:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoUser(const AUsername:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoPass(const APassword:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoApop(const AUsername,ADigest:String; var AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</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%;"|&nbsp;
 +
|-
 +
| <code>destructor Destroy; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FLock:TCriticalSectionHandle;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FHandle:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
| <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"|&nbsp;
 +
|-
 +
| <code>FThread:TThread;</code>
 +
| TWinsock2TCPServerThread
 +
|-
 +
| <code>FBuffer:TPOP3Buffer;</code>
 +
| Buffer for received data
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function AcquireLock:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function ReleaseLock:Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetHandle(AHandle:LongWord);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetRxByteCount:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetRxByteCount(const ARxByteCount:Int64);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetTxByteCount:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetTxByteCount(const ATxByteCount:Int64);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetRequestCount:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetRequestCount(const ARequestCount:Int64);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetReplyCount:Int64;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetReplyCount(const AReplyCount:Int64);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetRequestTime:TDateTime;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetRequestTime(const ARequestTime:TDateTime);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetReplyTime:TDateTime;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetReplyTime(const AReplyTime:TDateTime);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetRemoteAddress:String;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetRemoteAddress(const ARemoteAddress:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetStatus(AStatus:LongWord);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetUsername:String;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetUsername(const AUsername:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetPassword:String;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetPassword(const APassword:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>function GetTimestamp:String;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure SetTimestamp(const ATimestamp:String);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure SetThread(AThread:TThread);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property Handle:LongWord read FHandle write SetHandle;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property RxByteCount:Int64 read GetRxByteCount write SetRxByteCount;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property TxByteCount:Int64 read GetTxByteCount write SetTxByteCount;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property RequestCount:Int64 read GetRequestCount write SetRequestCount;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property ReplyCount:Int64 read GetReplyCount write SetReplyCount;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property RequestTime:TDateTime read GetRequestTime write SetRequestTime;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property ReplyTime:TDateTime read GetReplyTime write SetReplyTime;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property RemoteAddress:String read GetRemoteAddress write SetRemoteAddress;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Status:LongWord read FStatus write SetStatus;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Username:String read GetUsername write SetUsername;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Password:String read GetPassword write SetPassword;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Timestamp:String read GetTimestamp write SetTimestamp;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property Thread:TThread read FThread  write SetThread;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property Buffer:TPOP3Buffer read FBuffer;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure IncrementRxByteCount(const ARxByteCount:Int64);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure IncrementTxByteCount(const ATxByteCount:Int64);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure IncrementRequestCount;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure IncrementReplyCount;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</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%;"|&nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''private'''</div>
 +
|-
 +
| <code>FOnConnected:TPOP3ConnectionEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnDisconnected:TPOP3ConnectionEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FOnCheckHost:TPOP3HostEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnCheckCount:TPOP3CountEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FOnRequest:TPOP3NotifyEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnReply:TPOP3NotifyEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FOnConn:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnStat:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnList:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnRetr:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnDele:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnNoop:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnRset:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnQuit:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>FOnTop:TPOP3RequestExEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnUidl:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnUser:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnPass:TPOP3RequestEvent;</code>
 +
| &nbsp;
 +
|-
 +
| <code>FOnApop:TPOP3RequestExEvent;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''protected'''</div>
 +
|-
 +
| <code>procedure DoConnect(AThread:TWinsock2TCPServerThread); override;</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoDisconnect(AThread:TWinsock2TCPServerThread); override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function DoCheckHost(AThread:TWinsock2TCPServerThread):Boolean; virtual;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function DoCheckCount(AThread:TWinsock2TCPServerThread):Boolean; virtual;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function DoExecute(AThread:TWinsock2TCPServerThread):Boolean; override;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure DoConn(AThread:TWinsock2TCPServerThread);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoStat(AThread:TWinsock2TCPServerThread);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoList(AThread:TWinsock2TCPServerThread; const AMessage:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoRetr(AThread:TWinsock2TCPServerThread; const AMessage:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoDele(AThread:TWinsock2TCPServerThread; const AMessage:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoNoop(AThread:TWinsock2TCPServerThread);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoRset(AThread:TWinsock2TCPServerThread);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoQuit(AThread:TWinsock2TCPServerThread);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>procedure DoTop(AThread:TWinsock2TCPServerThread; const AMessage,ACount:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoUidl(AThread:TWinsock2TCPServerThread; const AMessage:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoUser(AThread:TWinsock2TCPServerThread; const AUsername:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoPass(AThread:TWinsock2TCPServerThread; const APassword:String);</code>
 +
| &nbsp;
 +
|-
 +
| <code>procedure DoApop(AThread:TWinsock2TCPServerThread; const AUsername,ADigest:String);</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>function GetRequest(AThread:TWinsock2TCPServerThread; var ARequest:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
| <code>function SendReply(AThread:TWinsock2TCPServerThread; const AReply:String):Boolean;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|<div style="font-family: monospace,courier;">'''public'''</div>
 +
|-
 +
| <code>property OnConnected:TPOP3ConnectionEvent read FOnConnected write FOnConnected;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnDisconnected:TPOP3ConnectionEvent read FOnDisconnected write FOnDisconnected;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property OnCheckHost:TPOP3HostEvent read FOnCheckHost write FOnCheckHost;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnCheckCount:TPOP3CountEvent read FOnCheckCount write FOnCheckCount;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property OnRequest:TPOP3NotifyEvent read FOnRequest write FOnRequest;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnReply:TPOP3NotifyEvent read FOnReply write FOnReply;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property OnConn:TPOP3RequestEvent read FOnConn write FOnConn;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnStat:TPOP3RequestEvent read FOnStat write FOnStat;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnList:TPOP3RequestEvent read FOnList write FOnList;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnRetr:TPOP3RequestEvent read FOnRetr write FOnRetr;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnDele:TPOP3RequestEvent read FOnDele write FOnDele;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnNoop:TPOP3RequestEvent read FOnNoop write FOnNoop;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnRset:TPOP3RequestEvent read FOnRset write FOnRset;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnQuit:TPOP3RequestEvent read FOnQuit write FOnQuit;</code>
 +
| &nbsp;
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>property OnTop:TPOP3RequestExEvent read FOnTop write FOnTop;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnUidl:TPOP3RequestEvent read FOnUidl write FOnUidl;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnUser:TPOP3RequestEvent read FOnUser write FOnUser;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnPass:TPOP3RequestEvent read FOnPass write FOnPass;</code>
 +
| &nbsp;
 +
|-
 +
| <code>property OnApop:TPOP3RequestExEvent read FOnApop write FOnApop;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div> 
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===

Revision as of 04:42, 17 March 2017

Return to Unit Reference


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