|
1 // xmodem.h |
|
2 // |
|
3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #ifndef __XMODEM_H__ |
|
14 #define __XMODEM_H__ |
|
15 |
|
16 #include <fshell/ioutils.h> |
|
17 |
|
18 using namespace IoUtils; |
|
19 |
|
20 |
|
21 class CCmdXmodem : public CCommandBase |
|
22 { |
|
23 public: |
|
24 enum TSyncResult |
|
25 { |
|
26 ENormal, |
|
27 EEot |
|
28 }; |
|
29 public: |
|
30 static CCommandBase* NewLC(); |
|
31 ~CCmdXmodem(); |
|
32 protected: |
|
33 CCmdXmodem(); |
|
34 void ConstructL(); |
|
35 void SendStdinL(); |
|
36 void SendFileL(const TDesC& aFileName); |
|
37 void ReceiveToStdoutL(); |
|
38 void ReceiveToFileL(const TDesC& aFileName); |
|
39 void ReceiveToNullL(); |
|
40 void SendBlockL(const TDesC& aBlock); |
|
41 TPtrC ReceiveBlockL(TBool aIsFirstBlock, TBool& aIsFinalBlock); |
|
42 void DoReceiveBlockL(); |
|
43 void SendTerminateL(); |
|
44 void WaitForSyncL(); |
|
45 TSyncResult SendSyncL(); |
|
46 TUint8 ReceiveByteL(TInt aTimeout, TBool* aTimeoutOccurred = NULL); |
|
47 TUint16 ReceiveShortL(TInt aTimeout, TBool* aTimeoutOccurred = NULL); |
|
48 void ReceiveWithTimeoutL(TDes& aBuf, TInt aTimeout, TBool* aTimeoutOccurred = NULL); |
|
49 void DoReceiveWithTimeoutL(TDes& aBuf, TInt aTimeout, TBool* aTimeoutOccurred = NULL); |
|
50 void PurgeInputL(); |
|
51 void SendL(const TDesC& aData); |
|
52 TInt CheckSize() const; |
|
53 TInt ProtocolOverhead() const; |
|
54 TBool CheckBlock() const; |
|
55 void Progress(TRefByValue<const TDesC> aFmt, ...) const; |
|
56 void Dump(const TDesC& aData); |
|
57 void Abort(); |
|
58 void HandleTelnetCommandL(); |
|
59 void Unget(TChar aChar); |
|
60 void PrepareConsoleToTransferL(); |
|
61 void CleanupClonsoleAfterTransferL(); |
|
62 private: // From CCommandBase. |
|
63 virtual const TDesC& Name() const; |
|
64 virtual void DoRunL(); |
|
65 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
66 virtual void HandleLeave(TInt aError); |
|
67 protected: |
|
68 virtual void OptionsL(RCommandOptionList& aOptions); |
|
69 private: |
|
70 enum TTelnetMode |
|
71 { |
|
72 ESendBinary = 0x00000001, |
|
73 ERecvBinary = 0x00000002 |
|
74 }; |
|
75 protected: |
|
76 enum |
|
77 { |
|
78 ESend, EReceive |
|
79 } iMode; |
|
80 TFileName2 iFileName; |
|
81 TInt iBlockSize; |
|
82 TUint8 iPacketNumber; |
|
83 TBool iOverwrite; |
|
84 private: |
|
85 TBool iVerbose; |
|
86 TBool iCrc; |
|
87 TBool iStarted; |
|
88 TUint iTelnetMode; |
|
89 HBufC* iBuf; |
|
90 TBuf<2> iUngetBuf; |
|
91 RTimer iTimer; |
|
92 }; |
|
93 |
|
94 #endif // __XMODEM_H__ |