|
1 /* |
|
2 * Copyright (c) 2008-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: AT command pusher for downstream |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef C_CDUNATCMDPUSHER_H |
|
19 #define C_CDUNATCMDPUSHER_H |
|
20 |
|
21 #include <atext.h> |
|
22 #include <e32base.h> |
|
23 #include "DunDataPusher.h" |
|
24 |
|
25 class MDunStreamManipulator; |
|
26 |
|
27 /** |
|
28 * Notification interface class for data pushing status changes |
|
29 * |
|
30 * @lib dunatext.lib |
|
31 * @since S60 v5.0 |
|
32 */ |
|
33 NONSHARABLE_CLASS( MDunAtCmdPusher ) |
|
34 { |
|
35 |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Notifies about end of AT command processing. |
|
40 * This is after all reply data for an AT command is multiplexed to the |
|
41 * downstream. |
|
42 * |
|
43 * @since S60 5.0 |
|
44 * @param aError Error code of command processing completion |
|
45 * @return Symbian error code on error, KErrNone otherwise |
|
46 */ |
|
47 virtual TInt NotifyEndOfProcessing( TInt aError ) = 0; |
|
48 |
|
49 /** |
|
50 * Notifies about request to stop AT command handling for the rest of the |
|
51 * command line data |
|
52 * |
|
53 * @since S60 5.0 |
|
54 * @return Symbian error code on error, KErrNone otherwise |
|
55 */ |
|
56 virtual TInt NotifyEndOfCmdLineProcessing() = 0; |
|
57 |
|
58 /** |
|
59 * Notifies about request to peek for the next command |
|
60 * |
|
61 * @since S60 5.0 |
|
62 * @return ETrue if next command exists, EFalse otherwise |
|
63 */ |
|
64 virtual TBool NotifyNextCommandPeekRequest() = 0; |
|
65 |
|
66 /** |
|
67 * Notifies about editor mode reply |
|
68 * |
|
69 * @since TB9.2 |
|
70 * @return Symbian error code on error, KErrNone otherwise |
|
71 */ |
|
72 virtual TInt NotifyEditorModeReply() = 0; |
|
73 |
|
74 }; |
|
75 |
|
76 /** |
|
77 * Class for AT command URC handler |
|
78 * |
|
79 * @lib dunatext.lib |
|
80 * @since S60 v5.0 |
|
81 */ |
|
82 NONSHARABLE_CLASS( CDunAtCmdPusher ) : public CActive, |
|
83 public MDunCompletionReporter |
|
84 { |
|
85 |
|
86 public: |
|
87 |
|
88 /** |
|
89 * Two-phased constructor. |
|
90 * @param aAtCmdExt Pointer to AT command extension |
|
91 * @param aCallback Callback to AT command handler |
|
92 * @param aDownstream Callback to downstream, |
|
93 * @param aOkBuffer Buffer for ok reply |
|
94 * @return Instance of self |
|
95 */ |
|
96 static CDunAtCmdPusher* NewL( RATExt* aAtCmdExt, |
|
97 MDunAtCmdPusher* aCallback, |
|
98 MDunStreamManipulator* aDownstream, |
|
99 TDesC8* aOkBuffer ); |
|
100 |
|
101 /** |
|
102 * Two-phased constructor. |
|
103 * @param aAtCmdExt Pointer to AT command extension |
|
104 * @param aCallback Callback to AT command handler |
|
105 * @param aDownstream Callback to downstream |
|
106 * @param aOkBuffer Buffer for ok reply |
|
107 * @return Instance of self |
|
108 */ |
|
109 static CDunAtCmdPusher* NewLC( RATExt* aAtCmdExt, |
|
110 MDunAtCmdPusher* aCallback, |
|
111 MDunStreamManipulator* aDownstream, |
|
112 TDesC8* aOkBuffer ); |
|
113 |
|
114 /** |
|
115 * Destructor. |
|
116 */ |
|
117 virtual ~CDunAtCmdPusher(); |
|
118 |
|
119 /** |
|
120 * Resets data to initial values |
|
121 * |
|
122 * @since S60 5.0 |
|
123 * @return None |
|
124 */ |
|
125 void ResetData(); |
|
126 |
|
127 /** |
|
128 * Starts AT command handling |
|
129 * |
|
130 * @since S60 5.0 |
|
131 * @param aCommand AT command or editor mode input to handle |
|
132 * @param aNormalMode ETrue if request issue for normal mode |
|
133 * @return Symbian error code on error, KErrNone otherwise |
|
134 */ |
|
135 TInt IssueRequest( TDesC8& aCommand, TBool aNormalMode=ETrue ); |
|
136 |
|
137 /** |
|
138 * Stops AT command handling |
|
139 * |
|
140 * @since S60 5.0 |
|
141 * @return Symbian error code on error, KErrNone otherwise |
|
142 */ |
|
143 TInt Stop(); |
|
144 |
|
145 /** |
|
146 * Manages request to abort command handling |
|
147 * |
|
148 * @since S60 5.0 |
|
149 * @return Symbian error code on error, KErrNone otherwise |
|
150 */ |
|
151 TInt ManageAbortRequest(); |
|
152 |
|
153 /** |
|
154 * Sets end of command line marker on for the possible series of AT |
|
155 * commands. |
|
156 * |
|
157 * @since S60 5.0 |
|
158 * @param aPushLast ETrue to push last reply, EFalse otherwise |
|
159 * @return None |
|
160 */ |
|
161 void SetEndOfCmdLine(); |
|
162 |
|
163 /** |
|
164 * Gets the editor mode status |
|
165 * |
|
166 * @since TB9.2 |
|
167 * @return ETrue if in editor mode, EFalse otherwise |
|
168 */ |
|
169 TBool EditorMode(); |
|
170 |
|
171 private: |
|
172 |
|
173 CDunAtCmdPusher( RATExt* aAtCmdExt, |
|
174 MDunAtCmdPusher* aCallback, |
|
175 MDunStreamManipulator* aDownstream, |
|
176 TDesC8* aOkBuffer ); |
|
177 |
|
178 void ConstructL(); |
|
179 |
|
180 /** |
|
181 * Initializes this class |
|
182 * |
|
183 * @since S60 5.0 |
|
184 * @return None |
|
185 */ |
|
186 void Initialize(); |
|
187 |
|
188 /** |
|
189 * Sets state to idle and notifies about subcommand handling completion |
|
190 * |
|
191 * @since S60 5.0 |
|
192 * @param aError Error code for completion |
|
193 * @return None |
|
194 */ |
|
195 void SetToIdleAndNotifyEnd( TInt aError ); |
|
196 |
|
197 /** |
|
198 * Checks if "OK" (verbose) or "0" (numeric) string or exists at the end of |
|
199 * buffer and removes it |
|
200 * |
|
201 * @since S60 5.0 |
|
202 * @return Symbian error code on error, KErrNone otherwise |
|
203 */ |
|
204 TInt CheckAndRemoveOkString(); |
|
205 |
|
206 /** |
|
207 * Sends reply data to downstream |
|
208 * |
|
209 * @since S60 5.0 |
|
210 * @param aRecvBuffer ETrue if using receive buffer |
|
211 * EFalse if using "OK" buffer |
|
212 * @return None |
|
213 */ |
|
214 void SendReplyData( TBool aRecvBuffer=ETrue ); |
|
215 |
|
216 /** |
|
217 * Manages change in reply type to EReplyTypeOther |
|
218 * |
|
219 * @since TB9.2 |
|
220 * @return None |
|
221 */ |
|
222 void ManageReplyTypeChangeToOther(); |
|
223 |
|
224 /** |
|
225 * Manages change in reply type to EReplyTypeOk |
|
226 * |
|
227 * @since TB9.2 |
|
228 * @return None |
|
229 */ |
|
230 void ManageReplyTypeChangeToOk(); |
|
231 |
|
232 /** |
|
233 * Manages change in reply type to EReplyTypeError |
|
234 * |
|
235 * @since TB9.2 |
|
236 * @return None |
|
237 */ |
|
238 void ManageReplyTypeChangeToError(); |
|
239 |
|
240 /** |
|
241 * Manages change in reply type to EReplyTypeEditor |
|
242 * |
|
243 * @since TB9.2 |
|
244 * @return None |
|
245 */ |
|
246 void ManageReplyTypeChangeToEditor(); |
|
247 |
|
248 /** |
|
249 * Manages change in reply type |
|
250 * |
|
251 * @since S60 5.0 |
|
252 * @return None |
|
253 */ |
|
254 void ManageReplyTypeChange(); |
|
255 |
|
256 // from base class CActive |
|
257 |
|
258 /** |
|
259 * From CActive. |
|
260 * Gets called when AT command handled |
|
261 * |
|
262 * @since S60 5.0 |
|
263 * @return None |
|
264 */ |
|
265 void RunL(); |
|
266 |
|
267 /** |
|
268 * From CActive. |
|
269 * Gets called on cancel |
|
270 * |
|
271 * @since S60 5.0 |
|
272 * @return None |
|
273 */ |
|
274 void DoCancel(); |
|
275 |
|
276 // from base class MDunCompletionReporter |
|
277 |
|
278 /** |
|
279 * From MDunCompletionReporter. |
|
280 * Gets called when data push is complete |
|
281 * |
|
282 * @since S60 5.0 |
|
283 * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise |
|
284 * @return None |
|
285 */ |
|
286 void NotifyDataPushComplete( TBool aAllPushed ); |
|
287 |
|
288 private: // data |
|
289 |
|
290 /** |
|
291 * AT command extension |
|
292 * Not own. |
|
293 */ |
|
294 RATExt* iAtCmdExt; |
|
295 |
|
296 /** |
|
297 * Notification interface class for data pushing status changes |
|
298 * Not own. |
|
299 */ |
|
300 MDunAtCmdPusher* iCallback; |
|
301 |
|
302 /** |
|
303 * Callback to call when data to push |
|
304 * Not own. |
|
305 */ |
|
306 MDunStreamManipulator* iDownstream; |
|
307 |
|
308 /** |
|
309 * Buffer for ok reply |
|
310 * Not own. |
|
311 */ |
|
312 TDesC8* iOkBuffer; |
|
313 |
|
314 /** |
|
315 * Current state of AT command handling: active or inactive |
|
316 */ |
|
317 TDunState iAtPushState; |
|
318 |
|
319 /** |
|
320 * Buffer for receiving |
|
321 */ |
|
322 TBuf8<KDefaultCmdBufLength> iRecvBuffer; |
|
323 |
|
324 /** |
|
325 * Indicates how many bytes of reply left |
|
326 */ |
|
327 TInt iReplyBytesLeft; |
|
328 |
|
329 /** |
|
330 * Package for reply bytes left |
|
331 */ |
|
332 TPckg<TInt> iReplyLeftPckg; |
|
333 |
|
334 /** |
|
335 * Reply type for the handled AT command |
|
336 */ |
|
337 TATExtensionReplyType iReplyType; |
|
338 |
|
339 /** |
|
340 * Package for reply type for the handled AT command |
|
341 */ |
|
342 TPckg<TATExtensionReplyType> iReplyTypePckg; |
|
343 |
|
344 /** |
|
345 * Flag indicating if other than "ERROR" reply already received in the |
|
346 * command line |
|
347 */ |
|
348 TBool iNoErrorReceived; |
|
349 |
|
350 /** |
|
351 * Flag indicating if the last "OK" reply push is started |
|
352 */ |
|
353 TBool iLastOkPush; |
|
354 |
|
355 /** |
|
356 * Flag indicating if abort already tried for one command |
|
357 */ |
|
358 TBool iCmdAbort; |
|
359 |
|
360 /** |
|
361 * Flag indicating if stop needed after the next reply |
|
362 */ |
|
363 TBool iStop; |
|
364 |
|
365 /** |
|
366 * Flag indicating if in editor mode |
|
367 */ |
|
368 TBool iEditorMode; |
|
369 |
|
370 }; |
|
371 |
|
372 #endif // C_CDUNATCMDPUSHER_H |