Store username in Session.
[dftpd.git] / Session.hpp
blobeeb6331c1b63a79c9d72548c1ada5f1a18d9fa99
1 #ifndef __DFTPD__SESSION_HPP__
2 #define __DFTPD__SESSION_HPP__
4 #include "SessionPtr.hpp"
5 #include "SessionControllerPtr.hpp"
6 #include "String.hpp"
7 #include "Telnet.hpp"
8 #include "Auth.hpp"
10 typedef std::vector<std::string> Command;
12 class Session
14 enum State
16 S_GREETING,
17 S_LOGIN,
18 S_PASSWORD,
19 S_READY
22 enum PassState
24 PS_NONE,
25 PS_LOGGEDIN,
26 PS_BADPASS
29 public:
30 static SessionPtr Create( int controlSock, const SessionControllerPtr& sessionController, const AuthPtr& auth );
31 ~Session();
33 void Tick();
35 private:
36 Session( int controlSock, const SessionControllerPtr& sessionController, const AuthPtr& auth );
38 void Remove();
40 void SendGreeting();
41 void SendSyntaxError();
42 void SendNotLoggedIn();
43 bool AwaitLogin();
44 PassState AwaitPassword();
45 void AwaitReady();
47 void HandleMode( const Command& cmd );
48 void HandleType( const Command& cmd );
49 void HandleStru( const Command& cmd );
51 Command GetCommand() { return ParseCommand( m_control->GetBuf() ); }
54 TelnetPtr m_control;
55 int m_controlSock;
57 int m_id;
58 static int m_counter;
60 State m_state;
62 SessionControllerWPtr m_sessionController;
63 SessionWPtr m_this;
64 AuthPtr m_auth;
66 std::string m_user;
69 #endif