|
1 /* |
|
2 * Copyright (c) 2007-2010 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: Definitions needed for one "stream" of CDunTransporter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CDUNDOWNSTREAM_H |
|
20 #define C_CDUNDOWNSTREAM_H |
|
21 |
|
22 #include "DunTransUtils.h" |
|
23 #include "DunStream.h" |
|
24 #include "DunAtCmdHandler.h" |
|
25 #include "DunDataPusher.h" |
|
26 |
|
27 class MDunCompletionReporter; |
|
28 class MDunAtCmdHandler; |
|
29 |
|
30 /** |
|
31 * Class used for storing data related to data pushing |
|
32 * |
|
33 * @lib dunutils.lib |
|
34 * @since S60 v3.2 |
|
35 */ |
|
36 NONSHARABLE_CLASS( TDunPushData ) |
|
37 { |
|
38 |
|
39 public: |
|
40 |
|
41 /** |
|
42 * Flag for command mode notifier's MDunCmdModeMonitor callback |
|
43 * This flag is needed to mark command mode start/end |
|
44 */ |
|
45 TBool iDataMode; |
|
46 |
|
47 /** |
|
48 * Data pusher for stream manipulation |
|
49 */ |
|
50 CDunDataPusher* iDataPusher; |
|
51 |
|
52 /** |
|
53 * AT command handling related functionality for CDunDownstream |
|
54 * Not own. |
|
55 */ |
|
56 MDunAtCmdHandler* iAtCmdHandler; |
|
57 |
|
58 }; |
|
59 |
|
60 /** |
|
61 * Class for manipulating existing stream's contents from outside |
|
62 * (outside of class CDunDownstream) |
|
63 * |
|
64 * @lib dunutils.lib |
|
65 * @since S60 v3.2 |
|
66 */ |
|
67 NONSHARABLE_CLASS( MDunStreamManipulator ) |
|
68 { |
|
69 |
|
70 public: |
|
71 |
|
72 /** |
|
73 * Gets called when outside party wants to push data to the existing stream |
|
74 * |
|
75 * @since S60 5.0 |
|
76 * @param aPushedData Data to push to the stream (not copied) |
|
77 * @param aCallback Callback to call when data is processed by the stream |
|
78 * @return Symbian error code on error, KErrNone otherwise |
|
79 */ |
|
80 virtual TInt NotifyDataPushRequest( |
|
81 const TDesC8 *aPushedData, |
|
82 MDunCompletionReporter* aCallback ) = 0; |
|
83 |
|
84 }; |
|
85 |
|
86 /** |
|
87 * Class for data transmission of one "stream" from network to local media |
|
88 * |
|
89 * @lib dunutils.lib |
|
90 * @since S60 v3.2 |
|
91 */ |
|
92 NONSHARABLE_CLASS( CDunDownstream ) : public CDunStream, |
|
93 public MDunStreamManipulator, |
|
94 public MDunCompletionReporter, |
|
95 public MDunCmdModeMonitor |
|
96 { |
|
97 |
|
98 friend class CDunDataPusher; |
|
99 |
|
100 public: |
|
101 |
|
102 /** |
|
103 * Two-phased constructor. |
|
104 * @param aUtility Pointer to common utility class |
|
105 * @return Instance of self |
|
106 */ |
|
107 static CDunDownstream* NewL( MDunTransporterUtilityAux* aUtility ); |
|
108 |
|
109 /** |
|
110 * Destructor. |
|
111 */ |
|
112 virtual ~CDunDownstream(); |
|
113 |
|
114 /** |
|
115 * Resets data to initial values |
|
116 * |
|
117 * @since S60 3.2 |
|
118 * @return None |
|
119 */ |
|
120 void ResetData(); |
|
121 |
|
122 /** |
|
123 * Starts downstream by issuing read request |
|
124 * |
|
125 * @since S60 3.2 |
|
126 * @return Symbian error code on error, KErrNone otherwise |
|
127 */ |
|
128 TInt StartStream(); |
|
129 |
|
130 /** |
|
131 * Stops transfer for read or write endpoints |
|
132 * |
|
133 * @since S60 3.2 |
|
134 * @param aStopMplex ETrue if multiplexer stop, EFalse otherwise |
|
135 * @return Symbian error code on error, KErrNone otherwise |
|
136 */ |
|
137 TInt Stop( TBool aStopMplex=ETrue ); |
|
138 |
|
139 /** |
|
140 * Initializes this stream for data pushing |
|
141 * |
|
142 * @since S60 3.2 |
|
143 * @param aAtCmdHandler AT command handling related functionality |
|
144 * @return Symbian error code on error, KErrNone otherwise |
|
145 */ |
|
146 TInt InitializeForDataPushing( MDunAtCmdHandler* aAtCmdHandler ); |
|
147 |
|
148 /** |
|
149 * Adds data to event queue and starts sending if needed |
|
150 * |
|
151 * @since S60 5.0 |
|
152 * @param aPushedData Data to push to the stream (not copied) |
|
153 * @param aCallback Callback to call when data is processed by the stream |
|
154 * @return Symbian error code on error, KErrNone otherwise |
|
155 */ |
|
156 TInt AddToQueueAndSend( const TDesC8 *aPushedData, |
|
157 MDunCompletionReporter* aCallback ); |
|
158 |
|
159 private: |
|
160 |
|
161 CDunDownstream( MDunTransporterUtilityAux* aUtility ); |
|
162 |
|
163 void ConstructL(); |
|
164 |
|
165 /** |
|
166 * Initializes this class |
|
167 * |
|
168 * @since S60 3.2 |
|
169 * @return None |
|
170 */ |
|
171 void Initialize(); |
|
172 |
|
173 /** |
|
174 * Issues transfer request for this stream |
|
175 * |
|
176 * @since S60 3.2 |
|
177 * @return Symbian error code on error, KErrNone otherwise |
|
178 */ |
|
179 TInt IssueRequest(); |
|
180 |
|
181 // from base class CActive |
|
182 |
|
183 /** |
|
184 * From CActive. |
|
185 * Gets called when endpoint data read complete |
|
186 * |
|
187 * @since S60 3.2 |
|
188 * @return None |
|
189 */ |
|
190 void RunL(); |
|
191 |
|
192 /** |
|
193 * From CActive. |
|
194 * Gets called on cancel |
|
195 * |
|
196 * @since S60 3.2 |
|
197 * @return None |
|
198 */ |
|
199 void DoCancel(); |
|
200 |
|
201 // from base class MDunStreamManipulator |
|
202 |
|
203 /** |
|
204 * Gets called when outside party wants to push data to the existing stream |
|
205 * |
|
206 * @since S60 3.2 |
|
207 * @param aPushedData Data to push to the stream (not copied) |
|
208 * @param aCallback Callback to call when data is processed by the stream |
|
209 * @return Symbian error code on error, KErrNone otherwise |
|
210 */ |
|
211 TInt NotifyDataPushRequest( const TDesC8 *aPushedData, |
|
212 MDunCompletionReporter* aCallback ); |
|
213 |
|
214 // from base class MDunCompletionReporter |
|
215 |
|
216 /** |
|
217 * Gets called when data push is complete |
|
218 * |
|
219 * @since S60 5.0 |
|
220 * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise |
|
221 * @return None |
|
222 */ |
|
223 void NotifyDataPushComplete( TBool aAllPushed ); |
|
224 |
|
225 // from base class MDunCmdModeMonitor |
|
226 |
|
227 /** |
|
228 * Notifies about command mode start |
|
229 * |
|
230 * @since S60 5.0 |
|
231 * @return None |
|
232 */ |
|
233 void NotifyCommandModeStart(); |
|
234 |
|
235 /** |
|
236 * Notifies about command mode end |
|
237 * |
|
238 * @since S60 5.0 |
|
239 * @return None |
|
240 */ |
|
241 void NotifyCommandModeEnd(); |
|
242 |
|
243 private: // data |
|
244 |
|
245 /** |
|
246 * Pointer to common utility class |
|
247 * Not own. |
|
248 */ |
|
249 MDunTransporterUtilityAux* iUtility; |
|
250 |
|
251 /** |
|
252 * Data related to data pushing |
|
253 */ |
|
254 TDunPushData iPushData; |
|
255 |
|
256 }; |
|
257 |
|
258 #endif // C_CDUNDOWNSTREAM_H |