switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Termlib / TelnetTerminal.hh
1 // $Id$
2 //
3 // Copyright (C) 2009
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 //
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at 
9 // http://senf.berlios.de/license.html
10 //
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on, 
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
14 //
15 // Software distributed under the License is distributed on an "AS IS" basis, 
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
17 // for the specific language governing rights and limitations under the License.
18 //
19 // The Original Code is Fraunhofer FOKUS code.
20 //
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
24 //
25 // Contributor(s):
26 //   Stefan Bund <g0dil@berlios.de>
27
28 /** \file
29     \brief TelnetTerminal public header */
30
31 #ifndef HH_SENF_Utils_Termlib_TelnetTerminal_
32 #define HH_SENF_Utils_Termlib_TelnetTerminal_ 1
33
34 // Custom includes
35 #include "Telnet.hh"
36 #include "AbstractTerminal.hh"
37 #include <senf/Utils/Logger.hh>
38
39 //#include "TelnetTerminal.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
41
42 namespace senf {
43 namespace term {
44
45     /** \brief AbstractTerminal interface implementation based on telnet
46
47         This class provides a telnet server implementation implementing the AbstractTerminal
48         interface.
49
50         TelnetTerminal provides one additional callback which needs to be implemented in a derived
51         class: v_setupFailed(). This member will be called, when not all required telnet options are
52         supported by the telnet client. In this case, the communication will be switched back into
53         line-oriented mode and v_setupFailed() is called.
54
55         \ingroup telnet_group
56      */
57     class TelnetTerminal
58         : public telnethandler::TerminalType,
59           public telnethandler::NAWS,
60           public AbstractTerminal
61     {
62         SENF_LOG_CLASS_AREA();
63     public:
64         TelnetTerminal();
65
66         ///\name AbstractTerminal interface implementation
67         //\{
68         virtual void setCallbacks(AbstractTerminal::Callbacks & cb);
69         virtual std::string terminalType();
70         virtual unsigned width() const;
71         virtual unsigned height() const;
72         virtual void write(char ch);
73         //\}
74
75     protected:
76
77 #   ifndef DOXYGEN
78     private:
79 #   endif
80         virtual void v_setupFailed() = 0; ///< Called when the telnet setup has failed
81
82     private:
83         virtual void v_setupComplete();
84         virtual void v_charReceived(char ch);
85         virtual void v_windowSizeChanged();
86
87         AbstractTerminal::Callbacks * callbacks_;
88         bool setupFailed_;
89     };
90
91 }}
92
93 //-/////////////////////////////////////////////////////////////////////////////////////////////////
94 //#include "TelnetTerminal.cci"
95 //#include "TelnetTerminal.ct"
96 //#include "TelnetTerminal.cti"
97 #endif
98
99 \f
100 // Local Variables:
101 // mode: c++
102 // fill-column: 100
103 // comment-column: 40
104 // c-file-style: "senf"
105 // indent-tabs-mode: nil
106 // ispell-local-dictionary: "american"
107 // compile-command: "scons -u test"
108 // End: