Difference between revisions of "Unit POP3"
From Ultibo.org
Line 166: | Line 166: | ||
| <code>POP3_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | | <code>POP3_LOG_LEVEL_INFO = LOG_LEVEL_INFO;</code> | ||
| POP3 informational messages | | POP3 informational messages | ||
+ | |- | ||
+ | | <code>POP3_LOG_LEVEL_WARN = LOG_LEVEL_WARN;</code> | ||
+ | | POP3 warning messages | ||
|- | |- | ||
| <code>POP3_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | | <code>POP3_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;</code> | ||
Line 921: | Line 924: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogInfo(const AText:String);</pre> | + | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogInfo(const AText:String); inline;</pre> |
+ | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
+ | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
+ | {| class="wikitable" style="font-size: 14px; background: white;" | ||
+ | |- | ||
+ | ! '''Note''' | ||
+ | | None documented | ||
+ | |- | ||
+ | |} | ||
+ | </div></div> | ||
+ | <br /> | ||
+ | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
+ | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogWarn(const AText:String); inline;</pre> | ||
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
Line 933: | Line 948: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogError(const AText:String);</pre> | + | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogError(const AText:String); inline;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | ||
Line 945: | Line 960: | ||
<br /> | <br /> | ||
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | <div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial; padding-top: 0px; padding-bottom: 15px;"> | ||
− | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogDebug(const AText:String);</pre> | + | <pre style="border: 0; padding-bottom:0px;">procedure POP3LogDebug(const AText:String); inline;</pre> |
<div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | <div style="font-size: 14px; padding-left: 12px;">'''Description:''' To be documented</div> | ||
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> | <div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;"> |
Revision as of 04:40, 26 March 2018
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
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
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
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
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_WARN = LOG_LEVEL_WARN;
|
POP3 warning 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); inline;
Description: To be documented
Note | None documented |
---|
procedure POP3LogWarn(const AText:String); inline;
Description: To be documented
Note | None documented |
---|
procedure POP3LogError(const AText:String); inline;
Description: To be documented
Note | None documented |
---|
procedure POP3LogDebug(const AText:String); inline;
Description: To be documented
Note | None documented |
---|
Return to Unit Reference