1 #ifndef _nntpconnection_
\r
2 #define _nntpconnection_
\r
4 #include "../socketdefines.h"
\r
5 #include "../ilogger.h"
\r
6 #include "../message.h"
\r
7 #include "../localidentity.h"
\r
11 //#include <zthread/Runnable.h>
\r
12 #include "../pthreadwrapper/runnable.h"
\r
17 #include <sys/socket.h>
\r
18 #include <sys/select.h>
\r
19 #include <sys/types.h>
\r
21 #include <netinet/in.h>
\r
22 #include <arpa/inet.h>
\r
25 class NNTPConnection:public PThread::Runnable,public ILogger
\r
28 NNTPConnection(SOCKET sock);
\r
32 const bool Disconnected() { return m_socket==INVALID_SOCKET; }
\r
38 typedef enum ClientMode
\r
45 std::string m_command;
\r
46 std::vector<std::string> m_arguments;
\r
55 LocalIdentity m_authuser; // -1 if user not authenticated, otherwise id of user from tblLocalIdentity
\r
56 bool m_authenticated;
\r
59 void SendBuffered(const std::string &data);
\r
60 void SendBufferedLine(const std::string &data) { SendBuffered(data+"\r\n"); }
\r
61 void SocketSend(); // immediately send buffered data - will block if send if no ready
\r
62 void SocketReceive(); // immediately recv data on socket - will block if no data is waiting
\r
63 void HandleReceivedData();
\r
64 std::vector<char>::iterator Find(std::vector<char> &buffer, const std::string &val);
\r
65 const bool HandleCommand(const NNTPCommand &command);
\r
66 void HandlePostedMessage(const std::string &message);
\r
68 void SendArticleParts(const NNTPCommand &command);
\r
69 void SendArticleOverInfo(Message &message);
\r
71 // various NNTP commands to handle
\r
72 const bool HandleQuitCommand(const NNTPCommand &command);
\r
73 const bool HandleModeCommand(const NNTPCommand &command);
\r
74 const bool HandleCapabilitiesCommand(const NNTPCommand &command);
\r
75 const bool HandleHelpCommand(const NNTPCommand &command);
\r
76 const bool HandleDateCommand(const NNTPCommand &command);
\r
77 const bool HandleListCommand(const NNTPCommand &command);
\r
78 const bool HandleGroupCommand(const NNTPCommand &command);
\r
79 const bool HandleListGroupCommand(const NNTPCommand &command);
\r
80 const bool HandleNextCommand(const NNTPCommand &command);
\r
81 const bool HandleLastCommand(const NNTPCommand &command);
\r
82 const bool HandleArticleCommand(const NNTPCommand &command);
\r
83 const bool HandleHeadCommand(const NNTPCommand &command);
\r
84 const bool HandleBodyCommand(const NNTPCommand &command);
\r
85 const bool HandleStatCommand(const NNTPCommand &command);
\r
86 const bool HandleNewGroupsCommand(const NNTPCommand &command);
\r
87 const bool HandlePostCommand(const NNTPCommand &command);
\r
88 const bool HandleOverCommand(const NNTPCommand &command);
\r
89 const bool HandleAuthInfoCommand(const NNTPCommand &command);
\r
90 const bool HandleGetTrustCommand(const NNTPCommand &command);
\r
91 const bool HandleSetTrustCommand(const NNTPCommand &command);
\r
92 const bool HandleGetTrustListCommand(const NNTPCommand &command);
\r
95 ClientStatus m_status;
\r
96 std::vector<char> m_sendbuffer;
\r
97 std::vector<char> m_receivebuffer;
\r
98 std::vector<char> m_tempbuffer;
\r
102 #endif // _nntpconnection_
\r