1 #ifndef _nntpconnection_
\r
2 #define _nntpconnection_
\r
4 #include "../socketdefines.h"
\r
5 #include "../ilogger.h"
\r
6 #include "../message.h"
\r
10 //#include <zthread/Runnable.h>
\r
11 #include "../pthreadwrapper/runnable.h"
\r
16 #include <sys/socket.h>
\r
17 #include <sys/select.h>
\r
18 #include <sys/types.h>
\r
20 #include <netinet/in.h>
\r
21 #include <arpa/inet.h>
\r
24 class NNTPConnection:public PThread::Runnable,public ILogger
\r
27 NNTPConnection(SOCKET sock);
\r
31 const bool Disconnected() { return m_socket==INVALID_SOCKET; }
\r
37 typedef enum ClientMode
\r
44 std::string m_command;
\r
45 std::vector<std::string> m_arguments;
\r
56 void SendBuffered(const std::string &data);
\r
57 void SendBufferedLine(const std::string &data) { SendBuffered(data+"\r\n"); }
\r
58 void SocketSend(); // immediately send buffered data - will block if send if no ready
\r
59 void SocketReceive(); // immediately recv data on socket - will block if no data is waiting
\r
60 void HandleReceivedData();
\r
61 std::vector<char>::iterator Find(std::vector<char> &buffer, const std::string &val);
\r
62 const bool HandleCommand(const NNTPCommand &command);
\r
63 void HandlePostedMessage(const std::string &message);
\r
65 void SendArticleParts(const NNTPCommand &command);
\r
66 void SendArticleOverInfo(Message &message);
\r
68 // various NNTP commands to handle
\r
69 const bool HandleQuitCommand(const NNTPCommand &command);
\r
70 const bool HandleModeCommand(const NNTPCommand &command);
\r
71 const bool HandleCapabilitiesCommand(const NNTPCommand &command);
\r
72 const bool HandleHelpCommand(const NNTPCommand &command);
\r
73 const bool HandleDateCommand(const NNTPCommand &command);
\r
74 const bool HandleListCommand(const NNTPCommand &command);
\r
75 const bool HandleGroupCommand(const NNTPCommand &command);
\r
76 const bool HandleListGroupCommand(const NNTPCommand &command);
\r
77 const bool HandleNextCommand(const NNTPCommand &command);
\r
78 const bool HandleLastCommand(const NNTPCommand &command);
\r
79 const bool HandleArticleCommand(const NNTPCommand &command);
\r
80 const bool HandleHeadCommand(const NNTPCommand &command);
\r
81 const bool HandleBodyCommand(const NNTPCommand &command);
\r
82 const bool HandleStatCommand(const NNTPCommand &command);
\r
83 const bool HandleNewGroupsCommand(const NNTPCommand &command);
\r
84 const bool HandlePostCommand(const NNTPCommand &command);
\r
85 const bool HandleOverCommand(const NNTPCommand &command);
\r
88 ClientStatus m_status;
\r
89 std::vector<char> m_sendbuffer;
\r
90 std::vector<char> m_receivebuffer;
\r
91 std::vector<char> m_tempbuffer;
\r
95 #endif // _nntpconnection_
\r