67 lines
966 B
C++
67 lines
966 B
C++
#ifndef PROTOCOL_H
|
|
#define PROTOCOL_H
|
|
|
|
#include "Util/Util.h"
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
|
|
namespace Protocol {
|
|
|
|
class Protocol
|
|
{
|
|
public:
|
|
class State
|
|
{
|
|
public:
|
|
enum type
|
|
{
|
|
Connected,
|
|
Disconnected
|
|
};
|
|
};
|
|
|
|
typedef std::pair<State::type, std::string> Result;
|
|
|
|
public:
|
|
explicit Protocol(const Util::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_boundary,
|
|
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 Util::Context& m_context;
|
|
};
|
|
|
|
} // namespace Protocol
|
|
|
|
#endif // PROTOCOL_H
|