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/include/nntpchan/nntp_handler.hpp
2017-10-17 10:29:56 -04:00

62 lines
1.1 KiB
C++

#ifndef NNTPCHAN_NNTP_HANDLER_HPP
#define NNTPCHAN_NNTP_HANDLER_HPP
#include "line.hpp"
#include "nntp_auth.hpp"
#include "storage.hpp"
#include <deque>
#include <string>
namespace nntpchan
{
class NNTPServerHandler : public LineReader, public IConnHandler
{
public:
NNTPServerHandler(const fs::path &storage);
~NNTPServerHandler();
virtual bool ShouldClose();
void SetAuth(CredDB_ptr creds);
virtual void OnData(const char *, ssize_t);
void Greet();
protected:
void HandleLine(const std::string &line);
void HandleCommand(const std::deque<std::string> &command);
private:
enum State
{
eStateReadCommand,
eStateStoreArticle,
eStateQuit
};
private:
void EnterState(State st);
void ArticleObtained();
// handle quit command, this queues a reply
void Quit();
// switch nntp modes, this queues a reply
void SwitchMode(const std::string &mode);
bool PostingAllowed();
private:
std::string m_articleName;
FileHandle_ptr m_article;
CredDB_ptr m_auth;
ArticleStorage_ptr m_store;
std::string m_mode;
bool m_authed;
State m_state;
};
}
#endif