|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TTelnet.cpp |
|
15 // Tiny Telnet - A simple telnet client to test CTelnetSession API |
|
16 // |
|
17 // |
|
18 |
|
19 #include <e32cons.h> |
|
20 #include <in_sock.h> |
|
21 #include <es_sock.h> |
|
22 #include <nifman.h> |
|
23 #include <e32test.h> |
|
24 #include <TELSESS.H> |
|
25 #include "TUIEDIT.H" |
|
26 //#include <debug.h> |
|
27 |
|
28 // ActiveConsole Declaration |
|
29 |
|
30 class CActiveConsole : public CActive |
|
31 /** |
|
32 @internalComponent |
|
33 */ |
|
34 { |
|
35 public: |
|
36 ~CActiveConsole(); |
|
37 void RequestCharacter(); |
|
38 void RunL(); |
|
39 virtual void ProcessKeyPress(TChar aChar) = 0; |
|
40 void DoCancel(); |
|
41 |
|
42 protected: |
|
43 void ConstructL(CConsoleBase* aConsole); |
|
44 inline CActiveConsole(TInt aPriority) : CActive(aPriority){}; |
|
45 |
|
46 protected: |
|
47 CConsoleBase* iConsole; |
|
48 }; |
|
49 |
|
50 class CTinyTelnet : public CActiveConsole, public MTelnetNotification |
|
51 /** |
|
52 @internalComponent |
|
53 */ |
|
54 { |
|
55 enum TState |
|
56 { |
|
57 EConnecting,EConnected, EDisconnecting,EDisconnected,EComplete |
|
58 }; |
|
59 |
|
60 public: |
|
61 CTinyTelnet(); |
|
62 ~CTinyTelnet(); |
|
63 |
|
64 static CTinyTelnet* NewLC(CConsoleBase* aConsole); |
|
65 void ConstructL(CConsoleBase* aConsole); |
|
66 |
|
67 void DisplayOptionStates(); |
|
68 |
|
69 void Error(TInt aError); |
|
70 void ReadComplete(const TDesC8& aBuffer); |
|
71 void WriteComplete(); |
|
72 void ConnectionClosed(); |
|
73 void OptionsChanged(); |
|
74 void Connected(); |
|
75 |
|
76 void ProcessKeyPress(TChar aChar); |
|
77 void DoCancel(); |
|
78 |
|
79 |
|
80 TBool DoCommand(); |
|
81 void Read(); |
|
82 TInt Write(TChar aChar); |
|
83 |
|
84 private: |
|
85 void Open(TDesC& aCommandArg); |
|
86 void OpenIP(TDesC& aCommandArg); |
|
87 void Close(TDesC& aCommandArg); |
|
88 void Help(TDesC& aCommandArg); |
|
89 void LocalEcho(TDesC& aCommandArg); |
|
90 void Binary(TDesC& aCommandArg); |
|
91 void Logout(TDesC& aCommandArg); |
|
92 |
|
93 private: |
|
94 TTelnetConfig iConfig; |
|
95 CTelnetSession* iTelnetSession; |
|
96 TInetAddr iAddress; |
|
97 TBuf<30> iBuffer; |
|
98 CLineEdit* iCommandLine; //[remove] |
|
99 TBuf<80> iCommand; |
|
100 TBuf<80> iCommandArg; |
|
101 TState iState; |
|
102 TBool iLocalEcho; |
|
103 TBool iBinaryOnOff; |
|
104 }; |
|
105 |
|
106 |
|
107 |