epoc32/include/telsess.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- a/epoc32/include/telsess.h	Tue Mar 16 16:12:26 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,314 +0,0 @@
     1.4 -/**
     1.5 -* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 -* All rights reserved.
     1.7 -* This component and the accompanying materials are made available
     1.8 -* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     1.9 -* which accompanies this distribution, and is available
    1.10 -* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 -*
    1.12 -* Initial Contributors:
    1.13 -* Nokia Corporation - initial contribution.
    1.14 -*
    1.15 -* Contributors:
    1.16 -*
    1.17 -* Description:
    1.18 -* Telnet Session API
    1.19 -* 
    1.20 -*
    1.21 -*/
    1.22 -
    1.23 -
    1.24 -
    1.25 -
    1.26 -
    1.27 -/**
    1.28 - @file TELSESS.H
    1.29 -*/
    1.30 -
    1.31 -#ifndef _TELSESS_H_
    1.32 -#define _TELSESS_H_
    1.33 -
    1.34 -#include <in_sock.h>
    1.35 -#include <e32std.h>
    1.36 -#include <e32cons.h>
    1.37 -#include <f32file.h>
    1.38 -
    1.39 -#define __TELNETSESSDEBUG__ // Put in Debug mode
    1.40 -
    1.41 -class CTelnetControl;
    1.42 -
    1.43 -// Used by client to retrieve RFC option state
    1.44 -// Flags for Telnet negotiated options
    1.45 -// 1 = Enabled 0 = Disabled
    1.46 -
    1.47 -/**
    1.48 -Defines the supported, RFC-defined, option status.
    1.49 -
    1.50 -@publishedAll
    1.51 -@released 
    1.52 -*/
    1.53 -typedef struct
    1.54 -    {
    1.55 -	/** If ETrue, the server is sending in binary (RFC 856). */
    1.56 -    TBool    iServerBinary; ///< RFC 856  (Server Sending in Binary)
    1.57 -	/** If ETrue, the client is sending in binary (RFC 856). */
    1.58 -    TBool    iClientBinary; ///< RFC 856  (Client Sending in Binary)
    1.59 -	/** If ETrue, the server is echoing data back to the client (RFC 857). */
    1.60 -    TBool    iEcho;         ///< RFC 857  (Server Echoing Data from Client)
    1.61 -	/** If ETrue, the client will negotiate about window size (RFC 1073). */
    1.62 -    TBool    iNAWS;         ///< RFC 1073 (Client Providing Window Size Information)
    1.63 -	/** If ETrue, the terminal speed option is enabled (RFC 1079). */
    1.64 -    TBool    iTerminalSpeed;///< RFC 1079 (Client Providing Terminal Speed Information)
    1.65 -	/** If ETrue, the client is providing terminal type information (RFC 1091). */
    1.66 -    TBool    iTerminalType; ///< RFC 1091 (Client Providing Terminal Type Information)
    1.67 -	/** If ETrue, if the server is providing status information (RFC 859). */
    1.68 -    TBool    iServerStatus; ///< RFC 859  (Server Providing Status Information)
    1.69 -	/** If ETrue, if the client is providing status information (RFC 859). */
    1.70 -    TBool    iClientStatus; ///< RFC 859  (Client Providing Status Information)
    1.71 -    }TOptionStatus;
    1.72 -
    1.73 -// Used by client to configure the Symbian Telnet
    1.74 -class TTelnetConfig
    1.75 -/**
    1.76 -* Specifies telnet session configuration information.
    1.77 -* 
    1.78 -* The client must provide a reference to an instance of this class as a parameter 
    1.79 -* to the CTelnetSession::NewL() function. 
    1.80 -* 
    1.81 -* Configuration options can be modified, when the session is in progress, using 
    1.82 -* the CTelnetSession::DoModifyConfig() function. 
    1.83 -* 
    1.84 -* Configuration option state can be obtained using the CTelnetSession::OptionStatus() 
    1.85 -* function.
    1.86 -* @publishedAll
    1.87 -* @released 
    1.88 -*/
    1.89 -    {
    1.90 - public:
    1.91 -
    1.92 -	/** Constructor. */
    1.93 -	 TTelnetConfig() {
    1.94 -		              iAllowLogout = TRUE;        // RFC 727  - Default TRUE = Server Can Logout Client
    1.95 -					  iWindowSize.x = (TInt16)80; // RFC 1073 - Default 80 x 24
    1.96 -					  iWindowSize.y = (TInt16)24;
    1.97 -					  iTermSpeed = _L8("38400");  // RFC 1079 - Default to 38400 Baud Terminal
    1.98 -					  iTermType  = _L8("dumb");   // RFC 1091 - Default to base NVT Terminal
    1.99 -					}
   1.100 -	/** Destructor. */
   1.101 -	 ~TTelnetConfig(){}
   1.102 -
   1.103 -	typedef struct
   1.104 -		/** 
   1.105 -		* Specifies the client's window size.
   1.106 -		* 
   1.107 -		* The default is 80 columns by 24 rows which constructs to x=80, y=24. 
   1.108 -		*/
   1.109 -		{
   1.110 -		/** The client window's width (number of columns). */
   1.111 -		TInt16 x;
   1.112 -		/** The client window's height (number of rows). */
   1.113 -		TInt16 y;
   1.114 -		}TWindowSize;
   1.115 -
   1.116 -	/** 
   1.117 -	* Specifies the client's window size.
   1.118 -	* 
   1.119 -	* The default is 80 columns by 24 rows. 
   1.120 -	* 
   1.121 -	* (RFC 1073 -- Set to Configure Window Size) 
   1.122 -	*/
   1.123 -	TWindowSize	iWindowSize; 
   1.124 -	
   1.125 -	/**
   1.126 -	* Specifies the speed of the telnet connection.
   1.127 -	* 
   1.128 -	* The default is "38400" (in ASCII characters). Must be set to a server-supported rate.
   1.129 -	* 
   1.130 -	* (RFC 1079 -- Set to Configure Terminal Speed) 
   1.131 -	*/
   1.132 -	TBuf8<20>	iTermSpeed;  
   1.133 -	
   1.134 -	/**
   1.135 -	* Specifies the terminal type.
   1.136 -	* 
   1.137 -	* The default is "dumb" (in ASCII characters). 
   1.138 -	* 
   1.139 -	* (RFC 1091 -- Set to Configure Terminal Type) 
   1.140 -	*/
   1.141 -	TBuf8<20>	iTermType;
   1.142 -	
   1.143 -	/**
   1.144 -	* Specifies whether the telnet server can logout the client.
   1.145 -	* 
   1.146 -	* The default, ETrue, enables the server to logout the client. If EFalse any 
   1.147 -	* logout request from the telnet server is rejected by the client.
   1.148 -	*
   1.149 -	* (RFC 727 -- Set/Clear to Enable/Disable Server Logout) 
   1.150 -	*/
   1.151 -	TBool		iAllowLogout;
   1.152 -	
   1.153 -	/**
   1.154 -	* Enables or disables telnet server echo to client.
   1.155 -	* 
   1.156 -	* The default, ETrue, enables server echo. Note that although this is normal 
   1.157 -	* telnet server behaviour, it is not a formal telnet requirement. It is therefore 
   1.158 -	* recommended that the client implement an optional local echo. 
   1.159 -	*
   1.160 -	* (RFC 857 -- Set/Clear to Enable/Disable Server Echo to client) 
   1.161 -	*/
   1.162 -	TBool		iServerEcho;
   1.163 -    };
   1.164 -
   1.165 -// Client can pass these in overloaded CTelnetSession::Write(TTelnetUserControl& aControlCode);
   1.166 -
   1.167 -/**
   1.168 -* Specifies the telnet control code to send to the server.
   1.169 -*
   1.170 -* This is done using the overloaded CTelnetSession::Write() function.
   1.171 -* @publishedAll
   1.172 -* @released 
   1.173 -*/
   1.174 -enum TTelnetUserControl 
   1.175 -    {
   1.176 -	/** Control code not supported. */
   1.177 -    ENotSupported = 0,
   1.178 -	
   1.179 -	/**
   1.180 -	* Break (the NVT 129th ASCII break code).
   1.181 -	* The default is 243. This is not a valid control in Binary mode. 
   1.182 -	*/
   1.183 -    EBrk	= 243,
   1.184 -	
   1.185 -	/**
   1.186 -	* Interupt Process.
   1.187 -	* The default is 244.
   1.188 -	*/
   1.189 -    EIp		= 244,
   1.190 -	
   1.191 -	/** 
   1.192 -	* Abort Output.
   1.193 -	* The default is 245. 
   1.194 -	*/
   1.195 -    EAo		= 245,
   1.196 -	
   1.197 -	/**
   1.198 -	Are you there?
   1.199 -	* The default is 246. 
   1.200 -	*/
   1.201 -    EAyt	= 246,
   1.202 -	
   1.203 -	/**
   1.204 -	* Erase Character. 
   1.205 -	* The default is 247. This is not a valid control in Binary mode. 
   1.206 -	*/
   1.207 -    EEc		= 247,
   1.208 -	
   1.209 -	/** 
   1.210 -	* Erase Line.
   1.211 -	* The default is 248. This is not a valid control in Binary mode. 
   1.212 -	*/
   1.213 -    EEl		= 248,
   1.214 -    };
   1.215 -
   1.216 -// Client MUST override this class
   1.217 -// Client MUST provide a pointer to an instance of this class as a parameter to CTelnetSession::NewL()
   1.218 -class MTelnetNotification
   1.219 -/**
   1.220 -* Symbian telnet notification interface.
   1.221 -* 
   1.222 -* Informs the client when an error occurs, when reads and writes have completed, 
   1.223 -* when a connection is made or closed and when configuration options change.
   1.224 -* @publishedAll
   1.225 -* @released 
   1.226 -*/
   1.227 -    {
   1.228 - public:
   1.229 -	/** 
   1.230 -	* Reports errors on the Telnet connection.
   1.231 -	*
   1.232 -	* The error code is supplied by the server. If this function is called, it is 
   1.233 -	* likely that the connection has failed. Therefore it is recommended that the 
   1.234 -	* client disconnects and resets its state.
   1.235 -	* 
   1.236 -	* @param aError	Error code from server. 
   1.237 -	 */
   1.238 -    virtual void Error(TInt aError) = 0; ///< Miscellaneous Error callback
   1.239 -	
   1.240 -	/** 
   1.241 -	* Passes the data that was received from the server to the client.
   1.242 -	* 
   1.243 -	* It is recommended that the client copies the data from this buffer, as it 
   1.244 -	* is owned by the Symbian telnet.
   1.245 -	* 
   1.246 -	* @param aBuffer	Data received from server. 
   1.247 -	*/
   1.248 -    virtual void ReadComplete(const TDesC8& aBuffer) = 0; ///< Last Read to Server completion callback
   1.249 -	
   1.250 -	/** Notifies the client that a write to the server from the client has completed. */
   1.251 -    virtual void WriteComplete() = 0; ///< Last Write to Server completion callback
   1.252 -	
   1.253 -	/** Notifies the client that the connection to the server has been closed. */
   1.254 -    virtual void ConnectionClosed() = 0; ///< Telnet Connection Closed callback
   1.255 -	
   1.256 -	/** Notifies the client that a connection to the server has been made. */
   1.257 -    virtual void Connected() = 0; ///< Telnet Connected callback
   1.258 -	
   1.259 -	/** Notifies the client that telnet configuration options have changed. */
   1.260 -    virtual void OptionsChanged() = 0;                    ///< Telnet RFC Options Changed callback
   1.261 -    };
   1.262 -
   1.263 -class CTelnetControl;
   1.264 -
   1.265 -class CTelnetSession : public CBase
   1.266 -/**
   1.267 -* The main Symbian telnet class.
   1.268 -* 
   1.269 -* Consists of a connection interface and a protocol interface. The connection 
   1.270 -* interface comprises member functions that: connect to, read from, write to 
   1.271 -* and disconnect from a telnet server.
   1.272 -* 
   1.273 -* The protocol interface includes member functions that get and set telnet configuration.
   1.274 -*
   1.275 -* @publishedAll
   1.276 -* @released 
   1.277 -*/
   1.278 -    {
   1.279 -    //public:
   1.280 -    // Data Structures
   1.281 - public:
   1.282 -    ~CTelnetSession();
   1.283 -    // Construction
   1.284 -    // Need to add max buffer size to constructor [check]
   1.285 -    IMPORT_C static CTelnetSession* NewL(const TTelnetConfig& aConfig,const MTelnetNotification* aNotifier);
   1.286 - protected:
   1.287 -    IMPORT_C void ConstructL(const TTelnetConfig& aConfig,const MTelnetNotification* aNotifier);
   1.288 -    //
   1.289 -    // Connection Interface
   1.290 -    //
   1.291 - public:
   1.292 -    IMPORT_C TInt Connect(const TInetAddr& aNetAddr); ///< Connects to aNetAddr on the standard telnet port (port 23)
   1.293 -    IMPORT_C TInt Connect(const TInetAddr& aNetAddr, TUint aPort); ///< Connects to aNetAddr on user specified port
   1.294 -    IMPORT_C TInt Connect(const TDesC& aServerName); ///< Connects to aSeverName on the standard telnet port (port 23)
   1.295 -    IMPORT_C TInt Connect(const TDesC& aServerName, TUint aPort); ///< Connects to aServerName on user specified port
   1.296 -    IMPORT_C TInt Disconnect(); ///< Disconnects current connection 
   1.297 -    IMPORT_C TInt Write(const TDesC8& aBuffer); ///< Writes a byte stream over the open telnet connection.
   1.298 -    IMPORT_C TInt Write(TTelnetUserControl& aControlCode); ///< Writes NVT code to stream. Prepends \<IAC\> code (255)
   1.299 -    IMPORT_C TInt Read(); ///< Read data received over telnet buffer.
   1.300 -    
   1.301 -	//
   1.302 -	// Protocol Interface 
   1.303 -	//
   1.304 -	IMPORT_C TInt DoForceLogout();
   1.305 -	IMPORT_C TInt DoModifyConfig(TTelnetConfig& aConfig);
   1.306 -	IMPORT_C TInt OptionStatus(TOptionStatus& aStatus);
   1.307 - private:
   1.308 -    CTelnetSession();
   1.309 -
   1.310 - private:
   1.311 -    MTelnetNotification* iNotifier;
   1.312 -    CTelnetControl* iTelnetProtocol;
   1.313 -
   1.314 -    };
   1.315 -
   1.316 -
   1.317 -#endif // _TELNETPROTOCOLAPI_H_