1 // daemon/Anyterm.hh
2 // This file is part of Anyterm; see http://anyterm.org/
3 // (C) 2005-2007 Philip Endecott
4 
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 
20 
21 
22 #ifndef Anyterm_hh
23 #define Anyterm_hh
24 
25 #include <map>
26 #include <string>
27 
28 #include <boost/shared_ptr.hpp>
29 
30 #include "Locked.hh"
31 
32 #include "Session.hh"
33 #include "config.hh"
34 #include "HttpRequest.hh"
35 
36 
37 class Anyterm {
38 
39 private:
40   const std::string def_charset;
41   const bool diff;
42   const int max_sessions;
43   typedef boost::shared_ptr<Session> session_ptr_t;
44   typedef std::map<SessionId, session_ptr_t> sessions_t;
45   typedef pbe::Locked<sessions_t> locked_sessions_t;
46   locked_sessions_t sessions;
47   Session::activityfactory_t activityfactory;
48   bool reaper_running;
49 
50 public:
51 
52   Anyterm(std::string command, std::string device, std::string charset, bool diff,
53           int max_sessions_);
54 
55   struct response_t {
56     std::string type;
57     std::string body;
response_tAnyterm::response_t58     response_t(std::string t, std::string b): type(t), body(b) {};
59   };
60 
61   response_t process_request(const pbe::HttpRequest& request);
62 
63   void reap_timed_out_sessions(void);
64   void run_reaper_thread(void);
65 
66 };
67 
68 
69 
70 
71 #endif
72