Initial commit
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
#ifndef PROTOCOL_H
|
||||
#define PROTOCOL_H
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "util.h"
|
||||
|
||||
|
||||
class protocol
|
||||
{
|
||||
public:
|
||||
class state
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
connected,
|
||||
disconnected
|
||||
};
|
||||
};
|
||||
|
||||
typedef std::pair<state::type, std::string> result;
|
||||
|
||||
public:
|
||||
explicit protocol(const context& context);
|
||||
|
||||
result openConnection(const std::string& address);
|
||||
result processMessage(const std::string& message);
|
||||
|
||||
private:
|
||||
class internalState
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
none,
|
||||
connect,
|
||||
helo,
|
||||
auth_login_user,
|
||||
auth_login_pass,
|
||||
mail_from,
|
||||
rcpt_to,
|
||||
data,
|
||||
mime_oundary,
|
||||
image_data,
|
||||
disconnect
|
||||
};
|
||||
};
|
||||
|
||||
private:
|
||||
result answer(state::type state, std::string answer) const;
|
||||
void appendMessage(const std::string& message);
|
||||
|
||||
private:
|
||||
internalState::type m_internalState;
|
||||
std::string m_address;
|
||||
std::string m_message;
|
||||
|
||||
const context& m_context;
|
||||
};
|
||||
|
||||
#endif // PROTOCOL_H
|
||||
|
||||
Reference in New Issue
Block a user