|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // AT Command Base Class |
|
15 // |
|
16 // |
|
17 |
|
18 #include "PHONE.H" |
|
19 #include "ATIO.H" |
|
20 #include "mSLOGGER.H" |
|
21 #include "ATINIT.H" |
|
22 #include "ATESCAPE.H" |
|
23 #include "LINE.H" |
|
24 #include "NOTIFY.H" |
|
25 #include "sms_rx_queue.h" // for CReceiveSmsQueue |
|
26 |
|
27 // Specific GSM Error String Response |
|
28 _LIT8(KCmsErrorString,"+CMS ERROR:*"); |
|
29 |
|
30 // |
|
31 // CATParamListEntry |
|
32 // A pointer to a meaningful result in the received buffer from the modem |
|
33 // |
|
34 CATParamListEntry::CATParamListEntry(const TDesC8& aDes) : |
|
35 iResultPtr(aDes) |
|
36 { |
|
37 } |
|
38 |
|
39 CATParamListEntry::~CATParamListEntry() |
|
40 {} |
|
41 |
|
42 void CATParamListEntry::Deque() |
|
43 { |
|
44 iLink.Deque(); |
|
45 } |
|
46 |
|
47 void CATParamListEntry::EntryValL(CATParamListEntry* aEntry,TInt& aValue) |
|
48 { |
|
49 if (aEntry==NULL) |
|
50 User::Leave(KErrGeneral); |
|
51 TLex8 lex(aEntry->iResultPtr); |
|
52 (void)User::LeaveIfError(lex.Val(aValue)); |
|
53 aEntry->Deque(); |
|
54 delete aEntry; |
|
55 } |
|
56 |
|
57 TInt CATParamListEntry::EntryValL(CATParamListEntry* aEntry) |
|
58 { |
|
59 TInt val; |
|
60 EntryValL(aEntry,val); |
|
61 return val; |
|
62 } |
|
63 |
|
64 |
|
65 // |
|
66 // Async One Shot to call RelinquishOwnershipComplete(). |
|
67 // If RelinquishOwnershipComplete() is called synchronously, it destroys the CATIO object |
|
68 // before the latter has finished processing. |
|
69 // |
|
70 CCompleteRelinquish* CCompleteRelinquish::New(CTelObject* aTelObject) |
|
71 // |
|
72 // Create the Relinquish Complete async one shot |
|
73 // |
|
74 { |
|
75 // The below TRAP is used to stop leavescan errors occurring. |
|
76 // This is not the best solution, but I am pressed for time ;-( |
|
77 CCompleteRelinquish* ptr=NULL; |
|
78 TRAP_IGNORE(ptr=new(ELeave)CCompleteRelinquish(aTelObject)); |
|
79 return ptr; |
|
80 } |
|
81 |
|
82 CCompleteRelinquish::CCompleteRelinquish(CTelObject* aTelObject) |
|
83 // |
|
84 // C'tor |
|
85 // |
|
86 :CAsyncOneShot(CActive::EPriorityLow), iTelObject(aTelObject) |
|
87 { |
|
88 __DECLARE_NAME(_S("CCompleteRelinquish")); |
|
89 } |
|
90 |
|
91 |
|
92 CCompleteRelinquish::~CCompleteRelinquish() |
|
93 { |
|
94 Cancel(); |
|
95 } |
|
96 |
|
97 void CCompleteRelinquish::RunL() |
|
98 // |
|
99 // Call RelinquishOwnershipCompleted() or RecoverDataPortAndRelinquishOwnershipCompleted() |
|
100 // after CATIO has finished its processing |
|
101 // |
|
102 { |
|
103 __ASSERT_ALWAYS(iPanicOccurred!=ENoPanicOccurred,Panic(EIllegalPanicOccurredValue)); |
|
104 if (iPanicOccurred == EPanicOccurredWithoutDataPortLoan) |
|
105 { |
|
106 REINTERPRET_CAST(CCallBase*,iTelObject)->RelinquishOwnershipCompleted(KErrNone); |
|
107 } |
|
108 if (iPanicOccurred == EPanicOccurredDuringDataPortLoan) |
|
109 { |
|
110 REINTERPRET_CAST(CCallBase*,iTelObject)->RecoverDataPortAndRelinquishOwnershipCompleted(KErrNone); |
|
111 } |
|
112 delete this; |
|
113 } |
|
114 // |
|
115 // The Command Base Class |
|
116 // |
|
117 CATBase::CATBase(CATIO* aIo, CTelObject* aTelObject,CPhoneGlobals* aPhoneGlobals) |
|
118 : iIo(aIo),iPhoneGlobals(aPhoneGlobals),iComplete(NULL),iTelObject(aTelObject),iCallInfo(NULL) |
|
119 { |
|
120 iRxResults.SetOffset(_FOFF(CATParamListEntry,iLink)); |
|
121 } |
|
122 |
|
123 CATBase::~CATBase() |
|
124 // |
|
125 // Assumes CATIO pointer is still valid |
|
126 // |
|
127 { |
|
128 if(!iRxResults.IsEmpty()) |
|
129 { |
|
130 CATParamListEntry* entry; |
|
131 TDblQueIter<CATParamListEntry> iter(iRxResults); |
|
132 while (entry = iter++,entry!=NULL) |
|
133 { |
|
134 entry->Deque(); |
|
135 delete entry; |
|
136 } |
|
137 } |
|
138 } |
|
139 |
|
140 void CATBase::GenericEventSignal(TEventSource aEventSource, TInt aStatus) |
|
141 // |
|
142 // If an IO error has occurred, complete this ATBase-object with the error. |
|
143 // |
|
144 { |
|
145 if (aStatus!=KErrNone) |
|
146 { |
|
147 LOGTEXT2(_L8("EventSignal received error status %d"),aStatus); |
|
148 CompleteWithIOError(aEventSource,aStatus); |
|
149 } |
|
150 else |
|
151 { |
|
152 EventSignal(aEventSource); |
|
153 } |
|
154 } |
|
155 |
|
156 void CATBase::AddStdExpectStrings() |
|
157 { |
|
158 if (!iOKExpectString) |
|
159 iOKExpectString=iIo->AddExpectString(this,KOkString); |
|
160 if (!iErrorExpectString) |
|
161 iErrorExpectString=iIo->AddExpectString(this,KErrorString); |
|
162 } |
|
163 |
|
164 |
|
165 TInt CATBase::ValidateExpectString() |
|
166 /** |
|
167 * New version ValidateExpectStringL which returns an error code |
|
168 * as opposed to leaving. |
|
169 * Use of this new code should hopefully remove alot of |
|
170 * unesseccary TRAP harness in the TSY. |
|
171 */ |
|
172 { |
|
173 TInt ret(KErrNone); |
|
174 |
|
175 if(iIo->FoundChatString()!=iOKExpectString) |
|
176 { |
|
177 if(iIo->FoundChatString()==iErrorExpectString) |
|
178 { |
|
179 LOGTEXT(_L8("Modem returned ERROR in response to command")); |
|
180 ret=KErrGeneral; |
|
181 } |
|
182 else |
|
183 { |
|
184 LOGTEXT(_L8("Modem returned unexpected response to command")); |
|
185 ret=KErrUnknown; |
|
186 } |
|
187 } |
|
188 |
|
189 return ret; |
|
190 } |
|
191 |
|
192 void CATBase::RemoveStdExpectStrings() |
|
193 { |
|
194 LOGTEXT(_L8("RemoveStdExpectStrings()")); |
|
195 iIo->RemoveExpectString(iOKExpectString); |
|
196 iOKExpectString=NULL; |
|
197 iIo->RemoveExpectString(iErrorExpectString); |
|
198 iErrorExpectString=NULL; |
|
199 } |
|
200 |
|
201 void CATBase::RemoveUnsolicitedStrings() |
|
202 { |
|
203 LOGTEXT(_L8("RemoveUnsolicitedStrings()")); |
|
204 |
|
205 _LIT8(KNetworkRegistration,"+CREG:"); // Network registration |
|
206 _LIT8(KIncomingCallIndication,"RING"); // Normal Ring |
|
207 _LIT8(KIncomingExtCallIndication,"+CRING:"); // Extended format call |
|
208 _LIT8(KIncomingExtNTCallParameter,"REL"); // Non-Transparent parameter |
|
209 _LIT8(KIncomingExtAlternatingCallParameter,"ALT"); // Unsupported Alternating parameter |
|
210 _LIT8(KIncomingExtVoiceRelCallParameter,"VOICE/REL"); // NT Voice parameter |
|
211 |
|
212 if(!iRxResults.IsEmpty()) |
|
213 { |
|
214 TInt aQueueSteps = NULL; |
|
215 CATParamListEntry* entry; |
|
216 TDblQueIter<CATParamListEntry> iter(iRxResults); |
|
217 // Step along the queue looking for an unsolicited strings |
|
218 while (entry = iter++,entry!=NULL) |
|
219 { |
|
220 TPtrC8 aResult(entry->iResultPtr); |
|
221 // If a match is found, we dequeue it and all its expected parameters |
|
222 if (aResult==KIncomingCallIndication) // 0 Params |
|
223 { |
|
224 // Remove the "RING" |
|
225 entry->Deque(); delete entry; |
|
226 LOGTEXT2(_L8("Unsolicited >%S< Removed"),&aResult); |
|
227 } |
|
228 else if (aResult==KIncomingExtCallIndication) // 1/2 Params |
|
229 { |
|
230 // Remove the "+CRING:" |
|
231 entry->Deque(); delete entry; entry = iter++; |
|
232 LOGTEXT2(_L8("Unsolicited >%S< Removed"),&aResult); |
|
233 // We know we should be getting at least one and maybee two parameters |
|
234 TPtrC8 aFirstParameterResult(entry->iResultPtr); |
|
235 if (aFirstParameterResult==KIncomingExtNTCallParameter |
|
236 || aFirstParameterResult==KIncomingExtVoiceRelCallParameter |
|
237 || aFirstParameterResult==KIncomingExtAlternatingCallParameter) |
|
238 { |
|
239 // We have an "ALT" or a "REL" so we have two parameters |
|
240 entry->Deque(); delete entry; entry = iter++; |
|
241 TPtrC8 aSecondParameterResult(entry->iResultPtr); |
|
242 entry->Deque(); delete entry; // If recognised parameter - remove |
|
243 LOGTEXT3(_L8("Unsolicited Parameter >%S %S< Removed"),&aFirstParameterResult,&aSecondParameterResult); aSecondParameterResult==KIncomingCallIndication; // Quick fix to remove unused parameters make warning |
|
244 } |
|
245 else |
|
246 { |
|
247 // We only have one parameter |
|
248 entry->Deque(); delete entry; // If recognised parameter - remove |
|
249 LOGTEXT2(_L8("Unsolicited Parameter >%S< Removed"),&aFirstParameterResult); |
|
250 } |
|
251 } |
|
252 else if (aResult==KNetworkRegistration) // 2 Params |
|
253 { |
|
254 // Remove the "+CREG:" |
|
255 entry->Deque(); delete entry; entry = iter++; |
|
256 LOGTEXT2(_L8("Unsolicited >%S< Removed"),&aResult); |
|
257 // Remove both parameters |
|
258 TPtrC8 aFirstParameterResult(entry->iResultPtr); |
|
259 entry->Deque(); delete entry; entry = iter++; |
|
260 TPtrC8 aSecondParameterResult(entry->iResultPtr); |
|
261 entry->Deque(); delete entry; |
|
262 LOGTEXT3(_L8("Unsolicited Parameters >%S,%S< Removed"),&aFirstParameterResult,&aSecondParameterResult); aFirstParameterResult==KIncomingCallIndication; aSecondParameterResult==KIncomingCallIndication; // Quick fix to remove unused parameters make warning |
|
263 } |
|
264 |
|
265 // Increment the queue step counter |
|
266 else aQueueSteps++; |
|
267 } |
|
268 // Now we have to retrace the list, ignoring dequeued entries |
|
269 for (TInt aLoop=NULL;aLoop<aQueueSteps;aLoop++) |
|
270 iter--; |
|
271 } |
|
272 } |
|
273 |
|
274 void CATBase::CleanupRxResults(TAny *aCATBase) // for TCleanupOperation |
|
275 { |
|
276 CATBase* p= reinterpret_cast<CATBase*>(aCATBase); |
|
277 TDblQueIter<CATParamListEntry> iter(p->iRxResults); |
|
278 CATParamListEntry* entry=iter++; |
|
279 while (entry!=NULL) |
|
280 { |
|
281 entry->Deque(); |
|
282 delete entry; |
|
283 entry=iter++; |
|
284 } |
|
285 } |
|
286 |
|
287 void CATBase::RxResultsPushLC() |
|
288 { |
|
289 TCleanupItem cleanup(CleanupRxResults,this); |
|
290 CleanupStack::PushL(cleanup); |
|
291 } |
|
292 |
|
293 void CATBase::ParseBufferLC(TBool aReportLists, TUint aSeparatorChar) |
|
294 // |
|
295 // Parses buffer. Treats aSeparatorChar like a comma |
|
296 // |
|
297 { |
|
298 LOGTEXT(_L8("Parse the Buffer List")); |
|
299 |
|
300 if (iIo->CurrentLine()==KOkString) |
|
301 iIo->ClearCurrentLine(); // remove trailing "OK" |
|
302 |
|
303 iBuffer.Set(iIo->Buffer()); |
|
304 iIo->ClearBuffer(); |
|
305 |
|
306 ParseLC(aReportLists, aSeparatorChar); |
|
307 } |
|
308 |
|
309 void CATBase::ParseLineLC(TBool aReportLists, TUint aSeparatorChar) |
|
310 // |
|
311 // Parses current line. Treats aSeparatorChar like a comma |
|
312 // |
|
313 { |
|
314 LOGTEXT(_L8("Parse the current line")); |
|
315 |
|
316 iBuffer.Set(iIo->CurrentLine()); |
|
317 iIo->ClearCurrentLine(); |
|
318 ParseLC(aReportLists, aSeparatorChar); |
|
319 } |
|
320 |
|
321 void CATBase::AddParamL(const TDesC8 &aPtr) |
|
322 { |
|
323 CATParamListEntry* aParamListEntry = new (ELeave) CATParamListEntry(aPtr); |
|
324 iRxResults.AddLast(*aParamListEntry); |
|
325 } |
|
326 |
|
327 void CATBase::ParseLC(TBool aReportLists, TUint aSeparatorChar) |
|
328 // |
|
329 // Does the actual parsing of iBuffer, set up from ParseLineLC or ParseBufferLC |
|
330 // |
|
331 { |
|
332 _LIT8(KOpenBracket, "("); |
|
333 _LIT8(KCloseBracket, ")"); |
|
334 |
|
335 #ifdef __LOGDEB__ |
|
336 TPtrC8 buf(iBuffer); |
|
337 if (buf.Length()>180) |
|
338 { |
|
339 buf.Set(buf.Left(180)); |
|
340 LOGTEXT2(_L8("buffer to parse >%S< and so on ..."),&buf); |
|
341 } |
|
342 else |
|
343 LOGTEXT2(_L8("buffer to parse >%S<"),&buf); |
|
344 #endif |
|
345 |
|
346 RxResultsPushLC(); |
|
347 TLex8 yyLex(iBuffer); |
|
348 |
|
349 // Move cursor past any spaces or open brackets |
|
350 yyLex.SkipSpace(); |
|
351 TChar peek=yyLex.Peek(); |
|
352 if (peek=='(' || peek=='[' || peek=='{') |
|
353 yyLex.Inc(); |
|
354 |
|
355 if (aReportLists && peek=='(') |
|
356 { |
|
357 AddParamL(KOpenBracket); |
|
358 LOGTEXT2(_L8("list separator >%S<"),&iRxResults.Last()->iResultPtr); |
|
359 } |
|
360 do |
|
361 { |
|
362 // Skip all space and opening brackets |
|
363 for (;;) |
|
364 { |
|
365 yyLex.SkipSpace(); |
|
366 if (yyLex.Eos()) |
|
367 return; |
|
368 peek = yyLex.Peek(); |
|
369 if (peek!='(') |
|
370 break; |
|
371 if (aReportLists) |
|
372 { |
|
373 AddParamL(KOpenBracket); |
|
374 LOGTEXT2(_L8("list separator >%S<"),&iRxResults.Last()->iResultPtr); |
|
375 } |
|
376 yyLex.Inc(); |
|
377 } |
|
378 |
|
379 if (peek=='"') // start of quoted string |
|
380 { |
|
381 yyLex.Inc(); // step over the quote |
|
382 yyLex.Mark(); |
|
383 while (!yyLex.Eos()) |
|
384 { |
|
385 peek=yyLex.Peek(); |
|
386 if (peek=='"') |
|
387 break; |
|
388 yyLex.Inc(); |
|
389 } |
|
390 |
|
391 AddParamL(yyLex.MarkedToken()); |
|
392 LOGTEXT2(_L8("quoted parameter >%S<"),&iRxResults.Last()->iResultPtr); |
|
393 if (yyLex.Eos()) |
|
394 return; |
|
395 |
|
396 // Skip all space and closing brackets |
|
397 for (;;) |
|
398 { |
|
399 yyLex.Inc(); |
|
400 yyLex.SkipSpace(); |
|
401 if (yyLex.Eos()) |
|
402 return; |
|
403 peek = yyLex.Peek(); |
|
404 if (peek!=')') |
|
405 break; |
|
406 if (aReportLists) |
|
407 { |
|
408 AddParamL(KCloseBracket); |
|
409 LOGTEXT2(_L8("list separator >%S<"),&iRxResults.Last()->iResultPtr); |
|
410 } |
|
411 } |
|
412 |
|
413 // Skip any following separator |
|
414 if (peek==',' || peek==aSeparatorChar) |
|
415 { |
|
416 yyLex.Inc(); |
|
417 yyLex.SkipSpace(); |
|
418 if (yyLex.Eos()) |
|
419 return; |
|
420 peek=yyLex.Peek(); |
|
421 } |
|
422 } |
|
423 else // if (peek!=',' && peek !='(' && peek!='"' && peek!=aSeparatorChar) |
|
424 { |
|
425 yyLex.Mark(); |
|
426 while (peek!=',' && !peek.IsSpace() && peek!=')' && peek!=']' && peek!='}' && peek!=aSeparatorChar) |
|
427 { |
|
428 yyLex.Inc(); |
|
429 if (yyLex.Eos()) |
|
430 break; |
|
431 peek=yyLex.Peek(); |
|
432 if ((peek==':')&&(aSeparatorChar!=':')) |
|
433 { |
|
434 yyLex.Inc(); |
|
435 break; |
|
436 } |
|
437 } |
|
438 |
|
439 AddParamL(yyLex.MarkedToken()); |
|
440 LOGTEXT2(_L8("normal parameter >%S<"),&iRxResults.Last()->iResultPtr); |
|
441 if (yyLex.Eos()) |
|
442 return; |
|
443 // skip any whitespace and closing brackets |
|
444 for (;;) |
|
445 { |
|
446 yyLex.SkipSpace(); |
|
447 if (yyLex.Eos()) |
|
448 return; |
|
449 peek = yyLex.Peek(); |
|
450 if (peek!=')') |
|
451 break; |
|
452 if (aReportLists) |
|
453 { |
|
454 AddParamL(KCloseBracket); |
|
455 LOGTEXT2(_L8("list separator >%S<"),&iRxResults.Last()->iResultPtr); |
|
456 } |
|
457 yyLex.Inc(); |
|
458 } |
|
459 // Skip any following separator |
|
460 if (peek==',' || peek==aSeparatorChar) |
|
461 { |
|
462 yyLex.Inc(); |
|
463 yyLex.SkipSpace(); |
|
464 if (yyLex.Eos()) |
|
465 return; |
|
466 peek=yyLex.Peek(); |
|
467 } |
|
468 } |
|
469 } while (peek!=')'&& peek!=']'&& peek!='}'); |
|
470 if (aReportLists && peek==')') |
|
471 { |
|
472 AddParamL(KCloseBracket); |
|
473 LOGTEXT2(_L8("list separator >%S<"),&iRxResults.Last()->iResultPtr); |
|
474 } |
|
475 |
|
476 } |
|
477 |
|
478 void CATBase::ChangeCallStatus(RMobileCall::TMobileCallStatus aCallStatus) |
|
479 // |
|
480 // This is called from a phone-based command as it is overloaded in CATCallAlterCommands. |
|
481 // |
|
482 { |
|
483 if (iCallInfo->iMobileStatus != aCallStatus) |
|
484 { |
|
485 iCallInfo->iMobileStatus = aCallStatus; |
|
486 if (aCallStatus == RMobileCall::EStatusIdle) |
|
487 { |
|
488 iCallInfo->iHookStatus = RCall::EHookStatusOn; |
|
489 iPhoneGlobals->iNotificationStore->CheckNotification(iTelObject,EBecomeIdle); |
|
490 } |
|
491 else if (aCallStatus != RMobileCall::EStatusUnknown && aCallStatus != RMobileCall::EStatusRinging) |
|
492 { |
|
493 iCallInfo->iHookStatus = RCall::EHookStatusOff; |
|
494 } |
|
495 } |
|
496 } |
|
497 |
|
498 void CATBase::ChangeLineStatus(RCall::TStatus aLineStatus) |
|
499 { |
|
500 iPhoneGlobals->iPhoneStatus.iLineStatus = aLineStatus; |
|
501 } |
|
502 |
|
503 void CATBase::SetToNotInitialised() |
|
504 { |
|
505 iPhoneGlobals->iPhoneStatus.iMode = RPhone::EModeUnknown; |
|
506 iPhoneGlobals->iPhoneStatus.iDataAndFaxFlags = RPhone::KCapsUnknown; |
|
507 iPhoneGlobals->iPhoneStatus.iInitStatus = EPhoneNotInitialised; |
|
508 } |
|
509 |
|
510 void CATBase::StandardWriteCompletionHandler(TEventSource aSource,TInt aTimeOut) |
|
511 { |
|
512 __ASSERT_ALWAYS(aSource==EWriteCompletion,Panic(EATCommand_IllegalCompletionWriteExpected)); |
|
513 iIo->SetTimeOut(this,aTimeOut * KOneSecondPause); |
|
514 AddStdExpectStrings(); |
|
515 } |
|
516 |
|
517 void CATBase::Write(const TDesC8& aCommand,TInt aTimeOut) |
|
518 { |
|
519 iTxBuffer.Format(KStringFormatString,&aCommand); |
|
520 iIo->Write(this,iTxBuffer); |
|
521 iIo->SetTimeOut(this,aTimeOut * KOneSecondPause); |
|
522 } |
|
523 |
|
524 void CATBase::Write(const TDesC8& aCommand,TInt aTimeOut,TInt aValue) |
|
525 { |
|
526 iTxBuffer.Format(KStringAndIntegerFormatString,&aCommand,aValue); |
|
527 iIo->Write(this,iTxBuffer); |
|
528 iIo->SetTimeOut(this,aTimeOut * KOneSecondPause); |
|
529 } |
|
530 |
|
531 void CATBase::Write(const TInt aTimeOut) |
|
532 { |
|
533 iIo->Write(this,iTxBuffer); |
|
534 iIo->SetTimeOut(this,aTimeOut * KOneSecondPause); |
|
535 } |
|
536 |
|
537 void CATBase::WriteExpectingResults(const TDesC8& aCommand,TInt aTimeOut) |
|
538 { |
|
539 iIo->ClearBuffer(); |
|
540 Write(aCommand,aTimeOut); |
|
541 } |
|
542 |
|
543 void CATBase::AppendWildCardChar(TDes8& aString) |
|
544 // |
|
545 // A utility function to append a '*' to aString if there's not one already there |
|
546 // |
|
547 { |
|
548 _LIT8(KAsterisk,"*"); |
|
549 if(aString.Right(1)!=KAsterisk) |
|
550 aString.Append(KAsterisk); |
|
551 } |
|
552 |
|
553 void CATBase::AddCmsErrorExpectString() |
|
554 // |
|
555 // Add the "+CMS ERROR:" expect string |
|
556 // |
|
557 { |
|
558 iCmsExpectString=iIo->AddExpectString(this,KCmsErrorString); |
|
559 LOGTEXT(_L8("Added \"+CMS ERROR:\" string.")); |
|
560 } |
|
561 |
|
562 void CATBase::RemoveCmsErrorExpectString() |
|
563 // |
|
564 // Remove the "+CMS ERROR:" expect string |
|
565 // |
|
566 { |
|
567 iIo->RemoveExpectString(iCmsExpectString); |
|
568 iCmsExpectString=NULL; |
|
569 LOGTEXT(_L8("Removed \"+CMS ERROR:\" string.")); |
|
570 } |
|
571 |
|
572 CTelObject* CATBase::Owner() |
|
573 { |
|
574 return iTelObject; |
|
575 } |
|
576 |
|
577 TCallInfoTSY* CATBase::CallInfo() |
|
578 { |
|
579 return iCallInfo; |
|
580 } |
|
581 |
|
582 // |
|
583 // CATCommands class |
|
584 // |
|
585 CATCommands::CATCommands(CATIO* aIo, CTelObject* aTelObject, CATInit* aInit, CPhoneGlobals* aPhoneGlobals) |
|
586 : CATBase(aIo,aTelObject,aPhoneGlobals), iInit(aInit) |
|
587 {} |
|
588 |
|
589 void CATCommands::ConstructL() |
|
590 { |
|
591 iATSetToOnlineCommandMode=CATSetToOnlineCommandMode::NewL(iIo,iTelObject,iPhoneGlobals); |
|
592 } |
|
593 |
|
594 CATCommands::~CATCommands() |
|
595 { |
|
596 delete iATSetToOnlineCommandMode; |
|
597 } |
|
598 |
|
599 void CATCommands::ExecuteCommand(TTsyReqHandle aTsyReqHandle, TAny* aParams) |
|
600 // |
|
601 // Ensures that phone is initialised and not in on-line data mode |
|
602 // |
|
603 { |
|
604 if (iPhoneGlobals->iPhoneStatus.iInitStatus==EPhoneNotInitialised) |
|
605 { |
|
606 iInit->StartInit(this,aTsyReqHandle,aParams); |
|
607 } |
|
608 else if (iPhoneGlobals->iPhoneStatus.iMode==RPhone::EModeOnlineData) |
|
609 { |
|
610 iATSetToOnlineCommandMode->StartEscapeSequence(this,aTsyReqHandle,aParams); |
|
611 } |
|
612 else |
|
613 { |
|
614 if (iPhoneGlobals->iEventSignalActive) |
|
615 { |
|
616 // Make sure request only completed if we have a valid request handle |
|
617 // Signal that request could not be executed |
|
618 if (aTsyReqHandle) |
|
619 iTelObject->ReqCompleted(aTsyReqHandle, KErrInUse); |
|
620 } |
|
621 else |
|
622 { |
|
623 iPhoneGlobals->iEventSignalActive = ETrue; |
|
624 Start(aTsyReqHandle, aParams); |
|
625 } |
|
626 } |
|
627 } |
|
628 |
|
629 void CATCommands::ExecuteCommand(TTsyReqHandle aTsyReqHandle, TAny* aParams,TCallInfoTSY* aCallInfo) |
|
630 // |
|
631 // Overloaded function for CCallHayes-originated commands, so that the status can be |
|
632 // changed for CCallHayes->iCallInfo |
|
633 // |
|
634 { |
|
635 iCallInfo = aCallInfo; |
|
636 ExecuteCommand(aTsyReqHandle,aParams); |
|
637 } |
|
638 |
|
639 void CATCommands::CancelCommand(TTsyReqHandle aTsyReqHandle) |
|
640 { |
|
641 if(iInit->CheckActiveReqHandle(aTsyReqHandle)) |
|
642 { |
|
643 iInit->StopInit(aTsyReqHandle); |
|
644 } |
|
645 else if (iPhoneGlobals->iPhoneStatus.iMode==RPhone::EModeOnlineData) |
|
646 { |
|
647 iATSetToOnlineCommandMode->StopEscapeSequence(aTsyReqHandle); |
|
648 } |
|
649 else |
|
650 { |
|
651 Stop(aTsyReqHandle); |
|
652 } |
|
653 } |
|
654 |
|
655 void CATCommands::Complete(TInt aError,TEventSource /*aSource*/) |
|
656 // |
|
657 // Should be called by all Complete()'s before ReqCompleted() |
|
658 // |
|
659 { |
|
660 LOGTEXT(_L8("CATCommands::Complete called")); |
|
661 |
|
662 if (aError==KErrTimedOut) |
|
663 { |
|
664 LOGTEXT(_L8("CATCommands::Complete KErrTimedOut error, setting EPhoneNotIntialised")); |
|
665 iPhoneGlobals->iPhoneStatus.iInitStatus = EPhoneNotInitialised; |
|
666 } |
|
667 |
|
668 // Clear the flow control flag to show no AT commands are writing to the |
|
669 // serial port. |
|
670 iPhoneGlobals->iEventSignalActive = EFalse; |
|
671 |
|
672 // Allow the CReceiveSmsQueue object to read PDUs from the phones memory, if needed |
|
673 if(iPhoneGlobals->iReceiveSmsQueuePtr) |
|
674 iPhoneGlobals->iReceiveSmsQueuePtr->ReadPDUFromPhone(); |
|
675 |
|
676 // Check the flow control flag, as the previous lines may have started off a |
|
677 // AT command. |
|
678 // If the flow control is clear then allow the Check ForChangeOfNetwork to have |
|
679 // a go at updating its status and writing to the serial port. |
|
680 if (!(iPhoneGlobals->iEventSignalActive)) |
|
681 iPhoneGlobals->CheckForChangeOfNetwork(); |
|
682 } |