spsmtp.hpp
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* Copyright 2009 Stephen Liu
* For license terms, see the file COPYING along with this library.
*/
#ifndef __spsmtp_hpp__
#define __spsmtp_hpp__
#include "sphandler.hpp"
class SP_Buffer;
class SP_ArrayList;
class SP_SmtpHandler {
public:
virtual ~SP_SmtpHandler();
virtual void error();
virtual void timeout();
enum {
eAccept = 0, // command accepted
eReject = -1, // command rejected
eClose = -2 // force to close the connection
};
virtual int welcome( const char * clientIP, const char * serverIP, SP_Buffer * reply );
virtual int help( const char * args, SP_Buffer * reply );
virtual int helo( const char * args, SP_Buffer * reply );
virtual int ehlo( const char * args, SP_Buffer * reply );
/**
* Called after the AUTH LOGIN during a SMTP exchange.
*
* @param user is the encoded username
* @param pass is the encoded password
*/
virtual int auth( const char * user, const char * pass, SP_Buffer * reply );
virtual int noop( const char * args, SP_Buffer * reply );
/**
* Called first, after the MAIL FROM during a SMTP exchange.
*
* @param args is the args of the MAIL FROM
*/
virtual int from( const char * args, SP_Buffer * reply ) = 0;
/**
* Called once for every RCPT TO during a SMTP exchange.
* This will occur after a from() call.
*
* @param args is the args of the RCPT TO
*/
virtual int rcpt( const char * args, SP_Buffer * reply ) = 0;
/**
* Called when the DATA part of the SMTP exchange begins. Will
* only be called if at least one recipient was accepted.
*
* @param data will be the smtp data stream, stripped of any extra '.' chars
*/
virtual int data( const char * data, SP_Buffer * reply ) = 0;
/**
* This method is called whenever a RSET command is sent. It should
* be used to clean up any pending deliveries.
*/
virtual int rset( SP_Buffer * reply ) = 0;
};
class SP_SmtpHandlerList {
public:
SP_SmtpHandlerList();
~SP_SmtpHandlerList();
int getCount();
void append( SP_SmtpHandler * handler );
SP_SmtpHandler * getItem( int index );
private:
SP_ArrayList * mList;
};
class SP_SmtpHandlerFactory {
public:
virtual ~SP_SmtpHandlerFactory();
virtual SP_SmtpHandler * create() const = 0;
};
class SP_SmtpHandlerAdapterFactory : public SP_HandlerFactory {
public:
SP_SmtpHandlerAdapterFactory( SP_SmtpHandlerFactory * factory );
virtual ~SP_SmtpHandlerAdapterFactory();
virtual SP_Handler * create() const;
private:
SP_SmtpHandlerFactory * mFactory;
};
#endif