|
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_CDUNUPSTREAM_H |
|
20 #define C_CDUNUPSTREAM_H |
|
21 |
|
22 #include "DunTransUtils.h" |
|
23 #include "DunStream.h" |
|
24 #include "DunAtCmdHandler.h" |
|
25 #include "DunAtCmdEchoer.h" |
|
26 #include "DunDataPusher.h" |
|
27 |
|
28 class MDunCmdModeMonitor; |
|
29 |
|
30 /** |
|
31 * Class used for storing data related to activity monitoring |
|
32 * |
|
33 * @lib dunutils.lib |
|
34 * @since S60 v3.2 |
|
35 */ |
|
36 NONSHARABLE_CLASS( TDunActivityData ) |
|
37 { |
|
38 |
|
39 public: |
|
40 |
|
41 /** |
|
42 * Callback to call when notification via MDunActivityManager to be made |
|
43 * Not own. |
|
44 */ |
|
45 MDunActivityManager* iActivityCallback; |
|
46 |
|
47 /** |
|
48 * Flag for data read activity's MDunActivityManager callback |
|
49 * This flag is needed to prevent multiple notifications of same activity |
|
50 */ |
|
51 TBool iDataRead; |
|
52 |
|
53 /** |
|
54 * Used as a flag for the first notification of read activity |
|
55 * This flag is needed to keep MDunActivityManager notifications in sync |
|
56 * (inactivity notification done only if activity notification done first) |
|
57 */ |
|
58 TBool iNotified; |
|
59 |
|
60 }; |
|
61 |
|
62 /** |
|
63 * Class used for storing data related to AT command parsing |
|
64 * |
|
65 * @lib dunutils.lib |
|
66 * @since S60 v3.2 |
|
67 */ |
|
68 NONSHARABLE_CLASS( TDunParseData ) |
|
69 { |
|
70 |
|
71 public: |
|
72 |
|
73 /** |
|
74 * Flag for command mode notifier's MDunCmdModeMonitor callback |
|
75 * This flag is needed to mark command mode start/end for parse start/end |
|
76 */ |
|
77 TBool iDataMode; |
|
78 |
|
79 /** |
|
80 * AT Command handler. |
|
81 */ |
|
82 CDunAtCmdHandler* iAtCmdHandler; |
|
83 |
|
84 }; |
|
85 |
|
86 /** |
|
87 * Accessor class for AT command handling related functionality |
|
88 * |
|
89 * @lib dunutils.lib |
|
90 * @since S60 v3.2 |
|
91 */ |
|
92 NONSHARABLE_CLASS( MDunAtCmdHandler ) |
|
93 { |
|
94 |
|
95 public: |
|
96 |
|
97 /** |
|
98 * Starts URC message handling |
|
99 * This is an accessor for CDunDownstream's StartStream() |
|
100 * |
|
101 * @since S60 5.0 |
|
102 * @return Symbian error code on error, KErrNone otherwise |
|
103 */ |
|
104 virtual TInt StartUrc() = 0; |
|
105 |
|
106 /** |
|
107 * Stops AT command handling downstream related activity (also URC) |
|
108 * This is an accessor for CDunDownstream's Stop() |
|
109 * |
|
110 * @since S60 3.2 |
|
111 * @return None |
|
112 */ |
|
113 virtual TInt StopAtCmdHandling() = 0; |
|
114 |
|
115 }; |
|
116 |
|
117 /** |
|
118 * Class for data transmission of one "stream" from local media to network |
|
119 * |
|
120 * @lib dunutils.lib |
|
121 * @since S60 v3.2 |
|
122 */ |
|
123 NONSHARABLE_CLASS( CDunUpstream ) : public CDunStream, |
|
124 public MDunAtCmdHandler, |
|
125 public MDunCmdModeMonitor, |
|
126 public MDunAtCmdStatusReporter, |
|
127 public MDunAtCmdEchoer |
|
128 { |
|
129 |
|
130 public: |
|
131 |
|
132 /** |
|
133 * Two-phased constructor. |
|
134 * @param aUtility Pointer to common utility class |
|
135 * @return Instance of self |
|
136 */ |
|
137 static CDunUpstream* NewL( MDunTransporterUtilityAux* aUtility ); |
|
138 |
|
139 /** |
|
140 * Destructor. |
|
141 */ |
|
142 virtual ~CDunUpstream(); |
|
143 |
|
144 /** |
|
145 * Resets data to initial values |
|
146 * |
|
147 * @since S60 3.2 |
|
148 * @return None |
|
149 */ |
|
150 void ResetData(); |
|
151 |
|
152 /** |
|
153 * Sets activity callback for this stream |
|
154 * |
|
155 * @since S60 3.2 |
|
156 * @param aActivityCallback Pointer to activity callback |
|
157 * @return KErrGeneral if callback null, KErrNone otherwise |
|
158 */ |
|
159 TInt SetActivityCallback( MDunActivityManager* aActivityCallback ); |
|
160 |
|
161 /** |
|
162 * Initializes this stream for AT command notifications |
|
163 * |
|
164 * @since S60 5.0 |
|
165 * @param aStreamCallback Pointer to stream callback |
|
166 * @param aConnectionName Connection identifier name |
|
167 * @param aCallbackUp Upstream callback to call when command mode starts or |
|
168 * ends |
|
169 * @param aCallbackDown Downstream callback to call when command mode starts |
|
170 * or ends |
|
171 * @return Symbian error code on error, KErrNone otherwise |
|
172 */ |
|
173 TInt InitializeForAtParsing( MDunStreamManipulator* aStreamCallback, |
|
174 const TDesC8* aConnectionName, |
|
175 MDunCmdModeMonitor* aCallbackUp, |
|
176 MDunCmdModeMonitor* aCallbackDown ); |
|
177 |
|
178 /** |
|
179 * Starts upstream by issuing read request |
|
180 * |
|
181 * @since S60 3.2 |
|
182 * @return Symbian error code on error, KErrNone otherwise |
|
183 */ |
|
184 TInt StartStream(); |
|
185 |
|
186 /** |
|
187 * Stops transfer for read & write endpoints |
|
188 * |
|
189 * @since S60 3.2 |
|
190 * @return Symbian error code on error, KErrNone otherwise |
|
191 */ |
|
192 TInt Stop(); |
|
193 |
|
194 /** |
|
195 * Data transmission state (if read completed) |
|
196 * |
|
197 * @since S60 3.2 |
|
198 * @return ETrue if data successfully read, EFalse otherwise |
|
199 */ |
|
200 TBool DataReadStatus(); |
|
201 |
|
202 private: |
|
203 |
|
204 CDunUpstream( MDunTransporterUtilityAux* aUtility ); |
|
205 |
|
206 void ConstructL(); |
|
207 |
|
208 /** |
|
209 * Initializes this class |
|
210 * |
|
211 * @since S60 3.2 |
|
212 * @return None |
|
213 */ |
|
214 void Initialize(); |
|
215 |
|
216 /** |
|
217 * Issues transfer request for this stream |
|
218 * |
|
219 * @since S60 3.2 |
|
220 * @return Symbian error code on error, KErrNone otherwise |
|
221 */ |
|
222 TInt IssueRequest(); |
|
223 |
|
224 /** |
|
225 * Processes data that was read |
|
226 * |
|
227 * @since S60 5.0 |
|
228 * @return ETrue if request to be reissued, EFalse otherwise |
|
229 */ |
|
230 TBool ProcessReadData(); |
|
231 |
|
232 /** |
|
233 * Manages activity in a channel |
|
234 * |
|
235 * @since S60 3.2 |
|
236 * @return Symbian error code on error, KErrNone otherwise |
|
237 */ |
|
238 TInt ManageChannelActivity(); |
|
239 |
|
240 // from base class CActive |
|
241 |
|
242 /** |
|
243 * From CActive. |
|
244 * Gets called when endpoint data read/write complete |
|
245 * |
|
246 * @since S60 3.2 |
|
247 * @return None |
|
248 */ |
|
249 void RunL(); |
|
250 |
|
251 /** |
|
252 * From CActive. |
|
253 * Gets called on cancel |
|
254 * |
|
255 * @since S60 3.2 |
|
256 * @return None |
|
257 */ |
|
258 void DoCancel(); |
|
259 |
|
260 // from base class MDunAtCmdStatusReporter |
|
261 |
|
262 /** |
|
263 * Notifies about parser's need to get more data |
|
264 * |
|
265 * @since TB9.2 |
|
266 * @return None |
|
267 */ |
|
268 void NotifyParserNeedsMoreData(); |
|
269 |
|
270 /** |
|
271 * Notifies about editor mode reply |
|
272 * |
|
273 * @since TB9.2 |
|
274 * @param aStart ETrue if start of editor mode, EFalse otherwise |
|
275 * @return Symbian error code on error, KErrNone otherwise |
|
276 */ |
|
277 void NotifyEditorModeReply( TBool aStart ); |
|
278 |
|
279 // from base class MDunAtCmdHandler |
|
280 |
|
281 /** |
|
282 * Starts URC message handling |
|
283 * This is an accessor for CDunDownstream's StartStream() |
|
284 * |
|
285 * @since S60 5.0 |
|
286 * @return Symbian error code on error, KErrNone otherwise |
|
287 */ |
|
288 TInt StartUrc(); |
|
289 |
|
290 /** |
|
291 * Stops AT command handling downstream related activity (also URC) |
|
292 * This is an accessor for CDunDownstream's Stop() |
|
293 * |
|
294 * @since S60 3.2 |
|
295 * @return Symbian error code on error, KErrNone otherwise |
|
296 */ |
|
297 TInt StopAtCmdHandling(); |
|
298 |
|
299 // from base class MDunCmdModeMonitor |
|
300 |
|
301 /** |
|
302 * Notifies about command mode start |
|
303 * |
|
304 * @since S60 5.0 |
|
305 * @return None |
|
306 */ |
|
307 void NotifyCommandModeStart(); |
|
308 |
|
309 /** |
|
310 * Notifies about command mode end |
|
311 * |
|
312 * @since S60 5.0 |
|
313 * @return None |
|
314 */ |
|
315 void NotifyCommandModeEnd(); |
|
316 |
|
317 // from base class MDunAtCmdEchoer |
|
318 |
|
319 /** |
|
320 * Notifies about completed echo in text mode |
|
321 * |
|
322 * @since TB9.2 |
|
323 * @return None |
|
324 */ |
|
325 void NotifyEchoComplete(); |
|
326 |
|
327 private: // data |
|
328 |
|
329 /** |
|
330 * Pointer to common utility class |
|
331 * Not own. |
|
332 */ |
|
333 MDunTransporterUtilityAux* iUtility; |
|
334 |
|
335 /** |
|
336 * Data related to activity monitoring |
|
337 */ |
|
338 TDunActivityData iActivityData; |
|
339 |
|
340 /** |
|
341 * Data related to AT command parsing |
|
342 */ |
|
343 TDunParseData iParseData; |
|
344 |
|
345 }; |
|
346 |
|
347 #endif // C_CDUNUPSTREAM_H |