提交 2c161e587a2500b771a532ea03ce0885f23ca795

作者 LJH 李佳桓
1 个父辈 13424f74

add

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