|
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 * FTP protocol engine |
|
16 * Author: Philippe Gabriel |
|
17 * Implements objet controling the DTP channel of the FTP protocol |
|
18 * Model the DTP Channel as an FSM |
|
19 * |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 |
|
25 /** |
|
26 @file DTPCHNL.H |
|
27 @internalComponent |
|
28 */ |
|
29 |
|
30 #if !defined(__DTPCHNL_H__) |
|
31 #define __DTPCHNL_H__ |
|
32 #include "DEBUG.H" |
|
33 #include "FTPDEF.H" |
|
34 #include "SETERROR.H" |
|
35 #include <e32base.h> |
|
36 #include <in_sock.h> |
|
37 |
|
38 ////////////////////////////////////////////////////////////// |
|
39 // Definitions |
|
40 ////////////////////////////////////////////////////////////// |
|
41 |
|
42 class CFtpProtocol; |
|
43 class MDTPChannelNotifier |
|
44 /** |
|
45 @internalComponent |
|
46 */ |
|
47 { |
|
48 public: |
|
49 /** |
|
50 Operation completion return codes. |
|
51 */ |
|
52 enum TDtpOperationCompletion |
|
53 { |
|
54 EDtpConnectComplete=0, |
|
55 EDtpAcceptComplete, |
|
56 EDtpDisconnectComplete, |
|
57 EDtpSendComplete, |
|
58 EDtpSendEOFComplete, |
|
59 EDtpRcvMoreData, |
|
60 EDtpRcvComplete, |
|
61 EDtpOpCancelComplete |
|
62 }; |
|
63 /** |
|
64 Error status |
|
65 */ |
|
66 enum TDtpOperationError |
|
67 { |
|
68 EDtpConnectFailed=0, |
|
69 EDtpSendAborted, |
|
70 EDtpRecvAborted |
|
71 }; |
|
72 public: |
|
73 /** Notify of normal completion of an operation */ |
|
74 virtual void DTPChannelOperationCompletion(const TDtpOperationCompletion)=0; |
|
75 /** Notify of error performing an operation */ |
|
76 virtual void DTPChannelOperationError(const TDtpOperationError)=0; |
|
77 /** Notify of reception */ |
|
78 virtual void DTPChannelXferNotification(const TDtpOperationCompletion)=0; |
|
79 }; |
|
80 |
|
81 NONSHARABLE_CLASS(CDTPChannel) : public CActive |
|
82 /** |
|
83 DTP Channel |
|
84 @internalComponent |
|
85 */ |
|
86 { |
|
87 public: |
|
88 |
|
89 CDTPChannel(MDTPChannelNotifier*,CFTPSetError*); |
|
90 ~CDTPChannel(); |
|
91 static CDTPChannel* NewL(MDTPChannelNotifier*,CFTPSetError*,RSocketServ&); |
|
92 /** Command interface .Connect DTP socket*/ |
|
93 TBool Connect(TSockAddr&); |
|
94 /** Open the DTP channel and wait for connection */ |
|
95 void Accept(void); |
|
96 /** returns the port the socket listens on */ |
|
97 TUint ListeningPort(void); |
|
98 void Disconnect(void); |
|
99 /** Send the content of aBuffer down the DTP Channel */ |
|
100 void Send(TDesC8&); |
|
101 /** Shutdown the DTP connection to notify an end of send */ |
|
102 void SendEOF(void); |
|
103 /** Rcv from DTP Channel and store in aBuffer */ |
|
104 void Recv(TDes8&); |
|
105 /** returns state of DTP Channel */ |
|
106 TBool Closed(void); |
|
107 /** returns state of DTP Channel */ |
|
108 TBool Connected(void); |
|
109 protected: |
|
110 void RunL(); |
|
111 void DoCancel(void); |
|
112 private: |
|
113 enum TState |
|
114 { |
|
115 EDTPChannelIdle,EDTPChannelConnecting,EDTPChannelListening,EDTPChannelConnected, |
|
116 EDTPChannelShutingDown,EDTPChannelSending,EDTPChannelReceiving |
|
117 }; |
|
118 enum TPanic |
|
119 { |
|
120 EDTPPanicChannelNotConnected = -1, |
|
121 EDTPPanicChannelOutOfState = -2 |
|
122 }; |
|
123 void ConstructL(RSocketServ&); |
|
124 /** The state of the FSM */ |
|
125 TState iDTPChannelState; |
|
126 /** A socket server to be used for all socket operations */ |
|
127 RSocketServ iSockServ; |
|
128 |
|
129 RSocket iDTPTransferSocket; |
|
130 RSocket iDTPListenSocket; |
|
131 MDTPChannelNotifier* iNotifier; |
|
132 // CFtpProtocol* iFtpProtocol; |
|
133 /** A pointer to a CFTPSetError object */ |
|
134 CFTPSetError* iCFTPSetError; |
|
135 TInetAddr iLocalAddress; |
|
136 TSockXfrLength iRcvLen; |
|
137 }; |
|
138 #endif // __DTPCHNL_H__ |