Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libnntpchan/nntp_handler.hpp

63 lines
1.2 KiB
C++
Raw Normal View History

2016-10-15 21:37:59 +05:00
#ifndef NNTPCHAN_NNTP_HANDLER_HPP
#define NNTPCHAN_NNTP_HANDLER_HPP
#include <deque>
#include <string>
#include "line.hpp"
2016-10-15 22:53:35 +05:00
#include "nntp_auth.hpp"
2016-10-15 21:37:59 +05:00
#include "storage.hpp"
namespace nntpchan
{
2017-05-03 18:15:06 +05:00
class NNTPServerHandler : public LineReader, public IConnHandler
2016-10-15 21:37:59 +05:00
{
public:
NNTPServerHandler(const std::string & storage);
2016-10-15 22:53:35 +05:00
~NNTPServerHandler();
2017-05-03 18:15:06 +05:00
virtual bool ShouldClose();
void SetAuth(CredDB_ptr creds);
2016-10-15 22:53:35 +05:00
2017-05-03 18:44:42 +05:00
virtual void OnData(const char *, ssize_t);
2016-10-15 22:53:35 +05:00
void Greet();
2017-05-03 18:15:06 +05:00
2016-10-15 21:37:59 +05:00
protected:
void HandleLine(const std::string & line);
void HandleCommand(const std::deque<std::string> & command);
private:
2017-05-03 18:15:06 +05:00
2016-10-15 21:37:59 +05:00
enum State {
eStateReadCommand,
eStateStoreArticle,
eStateQuit
};
private:
2017-05-03 22:33:04 +05:00
void EnterState(State st);
void ArticleObtained();
2016-10-15 21:37:59 +05:00
// handle quit command, this queues a reply
void Quit();
// switch nntp modes, this queues a reply
void SwitchMode(const std::string & mode);
2016-10-15 22:53:35 +05:00
bool PostingAllowed();
2017-05-03 18:15:06 +05:00
2016-10-15 21:37:59 +05:00
private:
2017-05-03 22:33:04 +05:00
std::string m_articleName;
FileHandle_ptr m_article;
CredDB_ptr m_auth;
2016-10-15 21:37:59 +05:00
ArticleStorage m_store;
std::string m_mode;
bool m_authed;
State m_state;
};
}
#endif