|
1 /** |
|
2 * Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Author: Philippe Gabriel |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file FTPUI.H |
|
24 @internalComponent |
|
25 */ |
|
26 |
|
27 #include <e32cons.h> |
|
28 #include <e32base.h> |
|
29 #include <f32file.h> |
|
30 #include "FTPSESS.H" |
|
31 #include "CONSOLE.H" |
|
32 |
|
33 class CFtpUI : public CBase, public MCmdConsoleReport,public MFtpSessionNotifier |
|
34 /** |
|
35 a simple FTPui |
|
36 @internalComponent |
|
37 */ |
|
38 { |
|
39 public: |
|
40 /** Console callback Minterface */ |
|
41 void CmdReady(void); |
|
42 void Escape(void); |
|
43 /** FTP Session callback Minterface notifier */ |
|
44 void Complete(void); |
|
45 /** Operation completed, more data to follow */ |
|
46 void MoreData(void); |
|
47 /** Transfer Progress report */ |
|
48 void TransferProgress(TUint aProgress); |
|
49 /** User canceled ongoing operation */ |
|
50 void Cancel(void); |
|
51 /** Peer reset the connection */ |
|
52 void ConnReset(void); |
|
53 /** Connection error */ |
|
54 void ConnectionError(TOpComp aTConnectionError); |
|
55 /** FTP server does not implement the operation requested */ |
|
56 void OperationNotSupported(void); |
|
57 /** Local File system error */ |
|
58 void LocalFileSystemError(TOpComp aTLocalFileSystemError); |
|
59 /** Remote File system error */ |
|
60 void RemoteFileSystemError(TOpComp aTRemoteFileSystemError); |
|
61 /** Not specified yet */ |
|
62 void EUnknownError(); |
|
63 /** Message reported by server */ |
|
64 void ServerMessage(const TDesC8&); |
|
65 /** FTP User interface specific methods */ |
|
66 CFtpUI(void); |
|
67 ~CFtpUI(void); |
|
68 /** Execute a previously parsed command */ |
|
69 TBool Execute(void); |
|
70 void SetConsole(CConsoleBase*); |
|
71 void SetCmdConsole(CmdConsole*); |
|
72 void SetFTPSession(CFTPSession*); |
|
73 void Help(void); |
|
74 |
|
75 enum TParseResult{ |
|
76 EError,EContinue,ESuccess |
|
77 }; |
|
78 /** Parse a command */ |
|
79 TParseResult Parse(TDesC&); |
|
80 private: |
|
81 enum ftpCmds{ |
|
82 /** Syntax error |
|
83 */ |
|
84 EInvalid, |
|
85 /** Connection cmds |
|
86 */ |
|
87 EConnectDNS,EConnectIP,EClose,EActive,Epasv, |
|
88 /** Xfer cmds |
|
89 */ |
|
90 EPut,EGet,EBin,EAsc,ERest,EOver,EExpand, |
|
91 /** File cmds |
|
92 */ |
|
93 EDel,ERen, |
|
94 /** Dir cmds |
|
95 */ |
|
96 EMkdir,ERmdir,ECd,EPwd,EList,ELcd, |
|
97 /** Help |
|
98 */ |
|
99 EHelp, |
|
100 /** Exit |
|
101 */ |
|
102 EQuit, |
|
103 /** Version |
|
104 */ |
|
105 EVer, |
|
106 /** Cancel |
|
107 */ |
|
108 ECancel |
|
109 }; |
|
110 enum TState{ |
|
111 EInputCmd,EInputLogin,EInputPass |
|
112 }; |
|
113 /** A Buffer to fill in with command */ |
|
114 TBuf<256> iCmdBuffer; |
|
115 /** A Buffer to fill in with param */ |
|
116 TBuf<256> iUParam; |
|
117 /** A dir path in the local file system */ |
|
118 TBuf<256> iDirPath; |
|
119 /** A Buffer to fill in with param */ |
|
120 TBuf8<256> iParamBuffer1; |
|
121 /** A Buffer to fill in with param */ |
|
122 TBuf8<256> iParamBuffer2; |
|
123 /** A Buffer to fill in with param */ |
|
124 TBuf8<256> iParamBuffer3; |
|
125 /** A Buffer to fill with data comming from the DTP Channel */ |
|
126 TBuf8<2000> iFileBuffer; |
|
127 /** A Buffer to fill with data comming from the DTP Channel */ |
|
128 TBuf<2000> iUBuffer; |
|
129 /** The amount transfered so far in bytes */ |
|
130 TUint iTransferProgress; |
|
131 /** The last moment when the amount transferred was displayed */ |
|
132 TTime iLastTime; |
|
133 TInt iProgressIdx; |
|
134 TBool iProgress; |
|
135 ftpCmds iCurCmd; |
|
136 TState iState; |
|
137 CConsoleBase* iConsole; |
|
138 CmdConsole* iCmdConsole; |
|
139 /** A pointer to an FtpSess object */ |
|
140 CFTPSession* iFTPSession; |
|
141 /** Default params */ |
|
142 CFTPSession::TConnectionMode iConnMode; |
|
143 CFTPSession::TOpenMode iOpenMode; |
|
144 CFTPSession::RepresentationType iType; |
|
145 RFs iFs; |
|
146 virtual TText getProgressChar(); |
|
147 }; |