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.

54 lines
1007 B
C++
Raw Normal View History

2016-10-15 12:37:59 -04:00
#ifndef NNTPCHAN_NNTP_HANDLER_HPP
#define NNTPCHAN_NNTP_HANDLER_HPP
#include <deque>
#include <string>
#include "line.hpp"
2016-10-15 13:53:35 -04:00
#include "nntp_auth.hpp"
2016-10-15 12:37:59 -04:00
#include "storage.hpp"
namespace nntpchan
{
class NNTPServerHandler : public LineReader
{
public:
NNTPServerHandler(const std::string & storage);
2016-10-15 13:53:35 -04:00
~NNTPServerHandler();
2016-10-15 12:37:59 -04:00
bool Done();
2016-10-15 13:53:35 -04:00
void SetAuth(NNTPCredentialDB * creds);
void Greet();
2016-10-15 12:37:59 -04:00
protected:
void HandleLine(const std::string & line);
void HandleCommand(const std::deque<std::string> & command);
private:
enum State {
eStateReadCommand,
eStateStoreArticle,
eStateQuit
};
private:
// 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 13:53:35 -04:00
bool PostingAllowed();
2016-10-15 12:37:59 -04:00
private:
2016-10-15 13:53:35 -04:00
NNTPCredentialDB * m_auth;
2016-10-15 12:37:59 -04:00
ArticleStorage m_store;
std::string m_mode;
bool m_authed;
State m_state;
};
}
#endif