22 #include "cpincommandhandler.h" |
22 #include "cpincommandhandler.h" |
23 #include "cusdcommandhandler.h" |
23 #include "cusdcommandhandler.h" |
24 #include "cnumcommandhandler.h" |
24 #include "cnumcommandhandler.h" |
25 #include "cfuncommandhandler.h" |
25 #include "cfuncommandhandler.h" |
26 #include "cbccommandhandler.h" |
26 #include "cbccommandhandler.h" |
27 #include "hvercommandhandler.h" |
|
28 #include "cgsncommandhandler.h" |
|
29 #include "cgmrcommandhandler.h" |
|
30 #include "cgmicommandhandler.h" |
|
31 #include "cmgwcommandhandler.h" |
|
32 #include "cmgdcommandhandler.h" |
|
33 #include "telephonywrapper.h" |
|
34 #include "cgmmcommandhandler.h" |
|
35 #include "scpbrcommandhandler.h" |
|
36 #include "scpbwcommandhandler.h" |
|
37 |
27 |
38 #include "atmisccmdpluginconsts.h" |
28 #include "atmisccmdpluginconsts.h" |
39 #include "cmserror.h" |
|
40 #include "debug.h" |
29 #include "debug.h" |
41 |
30 |
42 #include <exterror.h> // Additional RMobilePhone error code |
31 #include <EXTERROR.H> // Additional RMobilePhone error code |
43 #include <etelmmerr.h> // ETelMM error code |
|
44 #include <gsmerror.h> // GSM error code |
|
45 |
32 |
46 // +CME error code |
33 // +CME error code |
47 _LIT8(KCMEMemoryFailure, "+CME ERROR: 23\r\n"); // Memory failure.\r\n |
|
48 _LIT8(KCMEIncorrectPassword, "+CME ERROR: 16\r\n"); // Incorrect password.\r\n |
34 _LIT8(KCMEIncorrectPassword, "+CME ERROR: 16\r\n"); // Incorrect password.\r\n |
49 _LIT8(KCMEPUKRequired, "+CME ERROR: 12\r\n"); // PUK required.\r\n |
35 _LIT8(KCMEPUKRequired, "+CME ERROR: 12\r\n"); // PUK required.\r\n |
50 _LIT8(KCMENotAllowed, "+CME ERROR: 3\r\n"); // Operation not allowed.\r\n |
36 _LIT8(KCMENotAllowed, "+CME ERROR: 3\r\n"); // Operation not allowed.\r\n |
51 _LIT8(KCMEPhoneError, "+CME ERROR: 0\r\n"); // Phone failure.\r\n |
37 _LIT8(KCMEPhoneError, "+CME ERROR: 0\r\n"); // Phone failure.\r\n |
52 _LIT8(KCMEPhoneUnknown, "+CME ERROR: 100\r\n"); // unknown error |
38 _LIT8(KCMEPhoneUnknown, "+CME ERROR: 100\r\n"); // unknown error |
53 _LIT8(KCMESimNotInserted, "+CME ERROR: 10\r\n"); // SIM not inserted |
|
54 _LIT8(KCMEMemoryFull, "+CME ERROR: 20\r\n"); // Memory full |
|
55 _LIT8(KCMEInvalidIndex, "+CME ERROR: 21\r\n"); // Invalid index |
|
56 _LIT8(KCMENotFound, "+CME ERROR: 22\r\n"); // Not found |
|
57 _LIT8(KCMEDialStringTooLong, "+CME ERROR: 26\r\n"); // Dial string too long |
|
58 _LIT8(KCMETextStringTooLong, "+CME ERROR: 24\r\n"); // Text string too long |
|
59 _LIT8(KCMEInvalidCharacters, "+CME ERROR: 27\r\n"); // Invalid characters in dial string |
|
60 |
|
61 |
|
62 |
39 |
63 const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF |
40 const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF |
64 const TInt KEditorReplyLength = 4; // CR+LF+'>'+' ' |
|
65 |
41 |
66 CATMiscCmdPlugin* CATMiscCmdPlugin::NewL() |
42 CATMiscCmdPlugin* CATMiscCmdPlugin::NewL() |
67 { |
43 { |
68 CATMiscCmdPlugin* self = new (ELeave) CATMiscCmdPlugin(); |
44 CATMiscCmdPlugin* self = new (ELeave) CATMiscCmdPlugin(); |
69 CleanupStack::PushL(self); |
45 CleanupStack::PushL(self); |
112 iCUSDHandler = CCUSDCommandHandler::NewL(this, iCommandParser, iPhone); |
79 iCUSDHandler = CCUSDCommandHandler::NewL(this, iCommandParser, iPhone); |
113 iCPINHandler = CCPINCommandHandler::NewL(this, iCommandParser, iPhone); |
80 iCPINHandler = CCPINCommandHandler::NewL(this, iCommandParser, iPhone); |
114 iCNUMHandler = CCNUMCommandHandler::NewL(this, iCommandParser, iPhone, iTelServer); |
81 iCNUMHandler = CCNUMCommandHandler::NewL(this, iCommandParser, iPhone, iTelServer); |
115 iCFUNHandler = CCFUNCommandHandler::NewL(this, iCommandParser, iPhone); |
82 iCFUNHandler = CCFUNCommandHandler::NewL(this, iCommandParser, iPhone); |
116 iCBCHandler = CCBCCommandHandler::NewL(this, iCommandParser, iPhone); |
83 iCBCHandler = CCBCCommandHandler::NewL(this, iCommandParser, iPhone); |
117 iHVERHandler = CHVERCommandHandler::NewL(this, iCommandParser, iPhone); |
|
118 iCGSNHandler = CCGSNCommandHandler::NewL(this, iCommandParser, iPhone); |
|
119 iCGMRHandler = CCGMRCommandHandler::NewL(this, iCommandParser, iPhone); |
|
120 iCGMIHandler = CCGMICommandHandler::NewL(this, iCommandParser, iPhone); |
|
121 iCMGWHandler = CCMGWCommandHandler::NewL(this, iCommandParser, iPhone); |
|
122 iCMGDHandler = CCMGDCommandHandler::NewL(this, iCommandParser, iPhone); |
|
123 iCGMMHandler = CCGMMCommandHandler::NewL(this, iCommandParser, iPhone); |
|
124 iSCPBRHandler = CSCPBRCommandHandler::NewL(this, iCommandParser, iPhone); |
|
125 iSCPBWHandler = CSCPBWCommandHandler::NewL(this, iCommandParser, iPhone); |
|
126 |
|
127 |
|
128 // Get telephony information - Model, IMEI, Manufacturer |
|
129 CTelephonyWrapper* telephonyWrapper = CTelephonyWrapper::NewL(); |
|
130 TInt result = telephonyWrapper->SynchronousGetPhoneId(); |
|
131 |
|
132 if (KErrNone == result) |
|
133 { |
|
134 static_cast<CHVERCommandHandler*>(iHVERHandler)->SetHWVersion(telephonyWrapper->GetPhoneModel()); |
|
135 static_cast<CCGSNCommandHandler*>(iCGSNHandler)->SetSerialNum(telephonyWrapper->GetPhoneSerialNum()); |
|
136 static_cast<CCGMICommandHandler*>(iCGMIHandler)->SetManufacturer(telephonyWrapper->GetPhoneManufacturer()); |
|
137 static_cast<CCGMMCommandHandler*>(iCGMMHandler)->SetManufacturer(telephonyWrapper->GetPhoneManufacturer()); |
|
138 static_cast<CCGMMCommandHandler*>(iCGMMHandler)->SetModelID(telephonyWrapper->GetPhoneModel()); |
|
139 } |
|
140 else // The result is used to determine whether to display CME error or not |
|
141 { |
|
142 static_cast<CHVERCommandHandler*>(iHVERHandler)->SetTelephonyError(result); |
|
143 static_cast<CCGSNCommandHandler*>(iCGSNHandler)->SetTelephonyError(result); |
|
144 static_cast<CCGMICommandHandler*>(iCGMIHandler)->SetTelephonyError(result); |
|
145 static_cast<CCGMMCommandHandler*>(iCGMMHandler)->SetTelephonyError(result); |
|
146 } |
|
147 delete telephonyWrapper; |
|
148 |
|
149 TRACE_FUNC_EXIT |
84 TRACE_FUNC_EXIT |
150 } |
85 } |
151 |
86 |
152 /** |
87 /** |
153 * @see CATExtPluginBase::ReportConnectionName |
88 * @see CATExtPluginBase::ReportConnectionName |
213 iCurrentHandler = iCBCHandler; |
148 iCurrentHandler = iCBCHandler; |
214 break; |
149 break; |
215 } |
150 } |
216 case (TAtCommandParser::ECmdAtCmee): |
151 case (TAtCommandParser::ECmdAtCmee): |
217 { |
152 { |
218 iCurrentHandler = NULL; |
|
219 break; |
|
220 } |
|
221 case (TAtCommandParser::ECmdAtHver): |
|
222 { |
|
223 iCurrentHandler = iHVERHandler; |
|
224 break; |
|
225 } |
|
226 case (TAtCommandParser::ECmdAtCgsn): // intentional fall through |
|
227 case (TAtCommandParser::ECmdAtGsn): |
|
228 case (TAtCommandParser::ECmdAtI1): |
|
229 { |
|
230 iCurrentHandler = iCGSNHandler; |
|
231 break; |
|
232 } |
|
233 case (TAtCommandParser::ECmdAtCgmr): // intentional fall through |
|
234 case (TAtCommandParser::ECmdAtGmr): |
|
235 case (TAtCommandParser::ECmdAtI2): |
|
236 case (TAtCommandParser::ECmdAtI4): |
|
237 { |
|
238 iCurrentHandler = iCGMRHandler; |
|
239 break; |
|
240 } |
|
241 case (TAtCommandParser::ECmdAtCgmi): // intentional fall through |
|
242 case (TAtCommandParser::ECmdAtGmi): |
|
243 case (TAtCommandParser::ECmdAtI): |
|
244 case (TAtCommandParser::ECmdAtI0): |
|
245 { |
|
246 iCurrentHandler = iCGMIHandler; |
|
247 break; |
|
248 } |
|
249 case (TAtCommandParser::ECmdAtCmgw): |
|
250 { |
|
251 iCurrentHandler = iCMGWHandler; |
|
252 break; |
|
253 } |
|
254 case (TAtCommandParser::ECmdAtCmgd): |
|
255 { |
|
256 iCurrentHandler = iCMGDHandler; |
|
257 break; |
|
258 } |
|
259 case (TAtCommandParser::ECmdAtCmgf): |
|
260 { |
|
261 iCurrentHandler = NULL; |
153 iCurrentHandler = NULL; |
262 break; |
|
263 } |
|
264 case (TAtCommandParser::ECmdAtCgmm): // intentional fall through |
|
265 case (TAtCommandParser::ECmdAtGmm): |
|
266 case (TAtCommandParser::ECmdAtI3): |
|
267 { |
|
268 iCurrentHandler = iCGMMHandler; |
|
269 break; |
|
270 } |
|
271 case (TAtCommandParser::ECmdAtScpbr): |
|
272 { |
|
273 iCurrentHandler = iSCPBRHandler; |
|
274 break; |
|
275 } |
|
276 case (TAtCommandParser::ECmdAtScpbw): |
|
277 { |
|
278 iCurrentHandler = iSCPBWHandler; |
|
279 break; |
154 break; |
280 } |
155 } |
281 case (TAtCommandParser::EUnknown): |
156 case (TAtCommandParser::EUnknown): |
282 default: |
157 default: |
283 { |
158 { |
406 */ |
276 */ |
407 TInt CATMiscCmdPlugin::CreatePartOfReply( RBuf8& aBuffer ) |
277 TInt CATMiscCmdPlugin::CreatePartOfReply( RBuf8& aBuffer ) |
408 { |
278 { |
409 TRACE_FUNC_ENTRY |
279 TRACE_FUNC_ENTRY |
410 TInt ret = KErrNone; |
280 TInt ret = KErrNone; |
|
281 TInt partLength; |
411 if ( iReplyBuffer.Length() <= 0 ) |
282 if ( iReplyBuffer.Length() <= 0 ) |
412 { |
283 { |
413 ret = KErrGeneral; |
284 ret = KErrGeneral; |
414 } |
285 } |
415 else |
286 else |
416 { |
287 { |
417 TInt partLength = NextReplyPartLength(); |
288 partLength = NextReplyPartLength(); |
418 if ( iReplyBuffer.Length() < partLength ) |
289 if ( iReplyBuffer.Length() < partLength ) |
419 { |
290 { |
420 ret = KErrNotFound; |
291 ret = KErrNotFound; |
421 } |
292 } |
422 else if (ret == KErrNone) |
293 } |
423 { |
|
424 aBuffer.Create( iReplyBuffer, partLength ); |
|
425 iReplyBuffer.Delete( 0, partLength ); |
|
426 if ( iReplyBuffer.Length() == 0 ) |
|
427 { |
|
428 iReplyBuffer.Close(); |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 Trace(KDebugPrintD, "ret: ", ret); |
294 Trace(KDebugPrintD, "ret: ", ret); |
|
295 if (ret == KErrNone) |
|
296 { |
|
297 aBuffer.Create( iReplyBuffer, partLength ); |
|
298 iReplyBuffer.Delete( 0, partLength ); |
|
299 if ( iReplyBuffer.Length() == 0 ) |
|
300 { |
|
301 iReplyBuffer.Close(); |
|
302 } |
|
303 } |
|
304 |
434 TRACE_FUNC_EXIT |
305 TRACE_FUNC_EXIT |
435 return ret; |
306 return ret; |
436 } |
307 } |
437 |
308 |
438 /** |
309 /** |
475 Trace(KDebugPrintD, "aReplyType: ", aReplyType); |
346 Trace(KDebugPrintD, "aReplyType: ", aReplyType); |
476 switch ( aReplyType ) |
347 switch ( aReplyType ) |
477 { |
348 { |
478 case EReplyTypeOther: |
349 case EReplyTypeOther: |
479 break; |
350 break; |
480 case EReplyTypeEditor: |
|
481 CreateEditModeBuffer( iReplyBuffer ); |
|
482 break; |
|
483 case EReplyTypeOk: |
351 case EReplyTypeOk: |
484 CreateOkOrErrorReply( iReplyBuffer, ETrue ); |
352 CreateOkOrErrorReply( iReplyBuffer, ETrue ); |
485 break; |
353 break; |
486 case EReplyTypeError: |
354 case EReplyTypeError: |
487 CreateOkOrErrorReply( iReplyBuffer, EFalse ); |
355 CreateOkOrErrorReply( iReplyBuffer, EFalse ); |
541 } |
406 } |
542 replyBuffer.Append( iCarriageReturn ); |
407 replyBuffer.Append( iCarriageReturn ); |
543 } |
408 } |
544 |
409 |
545 aReplyBuffer.ReAlloc(aReplyBuffer.Length() + replyBuffer.Length()); |
410 aReplyBuffer.ReAlloc(aReplyBuffer.Length() + replyBuffer.Length()); |
546 aReplyBuffer.Append( replyBuffer ); |
|
547 TRACE_FUNC_EXIT |
|
548 return KErrNone; |
|
549 } |
|
550 |
|
551 /** |
|
552 * @see MATMiscCmdPlugin::CreateEditModeBuffer |
|
553 */ |
|
554 TInt CATMiscCmdPlugin::CreateEditModeBuffer( RBuf8& aReplyBuffer ) |
|
555 { |
|
556 TRACE_FUNC_ENTRY |
|
557 _LIT8( KReplyPromptAndSpace, "> " ); |
|
558 TBuf8<KEditorReplyLength> replyBuffer; |
|
559 replyBuffer.Append( iCarriageReturn ); |
|
560 replyBuffer.Append( iLineFeed ); |
|
561 replyBuffer.Append( KReplyPromptAndSpace ); |
|
562 |
|
563 TInt err = aReplyBuffer.ReAlloc( aReplyBuffer.Length() + replyBuffer.Length() ); |
|
564 if (KErrNone != err) |
|
565 { |
|
566 return err; |
|
567 } |
|
568 aReplyBuffer.Append( replyBuffer ); |
411 aReplyBuffer.Append( replyBuffer ); |
569 TRACE_FUNC_EXIT |
412 TRACE_FUNC_EXIT |
570 return KErrNone; |
413 return KErrNone; |
571 } |
414 } |
572 |
415 |
656 { |
499 { |
657 // not allowed with this sim |
500 // not allowed with this sim |
658 response.Append(KCMENotAllowed); |
501 response.Append(KCMENotAllowed); |
659 break; |
502 break; |
660 } |
503 } |
661 case KErrGsmMMImeiNotAccepted: |
|
662 { |
|
663 // Memory failure |
|
664 response.Append(KCMEMemoryFailure); |
|
665 break; |
|
666 } |
|
667 case KErrUnknown: |
504 case KErrUnknown: |
668 case KErrGsmSimServAnrFull: |
|
669 { |
505 { |
670 // unknown error |
506 // unknown error |
671 response.Append(KCMEPhoneUnknown); |
507 response.Append(KCMEPhoneUnknown); |
672 break; |
|
673 } |
|
674 case KErrNotFound: |
|
675 { |
|
676 response.Append(KCMENotFound); |
|
677 break; |
|
678 } |
|
679 case KErrInUse: |
|
680 case KErrGsmMMServiceOptionTemporaryOutOfOrder: |
|
681 { |
|
682 // SIM not inserted |
|
683 response.Append(KCMESimNotInserted); |
|
684 break; |
|
685 } |
|
686 case KErrArgument: |
|
687 case KErrGsm0707InvalidIndex: |
|
688 case KErrGsm0707NotFound: |
|
689 { |
|
690 // Invalid index |
|
691 response.Append(KCMEInvalidIndex); |
|
692 break; |
|
693 } |
|
694 case KErrGsm0707TextStringTooLong: |
|
695 { |
|
696 // Text string too long |
|
697 response.Append(KCMETextStringTooLong); |
|
698 break; |
|
699 } |
|
700 case KErrGsm0707DialStringTooLong: |
|
701 { |
|
702 // Dial string too long |
|
703 response.Append(KCMEDialStringTooLong); |
|
704 break; |
|
705 } |
|
706 case KErrGsmCCUnassignedNumber: |
|
707 case KErrGsm0707InvalidCharsInDialString: |
|
708 { |
|
709 // Invalid characters in dial string |
|
710 response.Append(KCMEInvalidCharacters); |
|
711 break; |
|
712 } |
|
713 case KErrMMEtelMaxReached: |
|
714 { |
|
715 // Memory full |
|
716 response.Append(KCMEMemoryFull); |
|
717 break; |
508 break; |
718 } |
509 } |
719 default: |
510 default: |
720 { |
511 { |
721 response.Append(KCMEPhoneError); |
512 response.Append(KCMEPhoneError); |
728 else |
519 else |
729 { |
520 { |
730 CreateReplyAndComplete( EReplyTypeError); |
521 CreateReplyAndComplete( EReplyTypeError); |
731 } |
522 } |
732 |
523 |
733 TRACE_FUNC_EXIT |
|
734 } |
|
735 |
|
736 void CATMiscCmdPlugin::CreateCMSReplyAndComplete(TInt aError) |
|
737 { |
|
738 TRACE_FUNC_ENTRY |
|
739 |
|
740 if(iQuietMode) |
|
741 { |
|
742 CreateReplyAndComplete(EReplyTypeError); |
|
743 } |
|
744 else |
|
745 { |
|
746 // return error code to AT client |
|
747 RBuf8 response; |
|
748 if (KErrNone != response.Create(KDefaultCmdBufLength)) |
|
749 { |
|
750 CreateReplyAndComplete(EReplyTypeError); |
|
751 return; |
|
752 } |
|
753 |
|
754 // return error code to AT client |
|
755 response.Append(KCRLF); |
|
756 response.Append(KCMSErr); |
|
757 |
|
758 switch(aError) |
|
759 { |
|
760 case KErrGsmSMSReserved: |
|
761 { |
|
762 // Other application cause SMS interface being reserved |
|
763 response.AppendNum(EATCMSErr301); |
|
764 break; |
|
765 } |
|
766 case KErrGsmSMSInvalidPDUModeParameter: |
|
767 { |
|
768 // Under the mode of PDU, PDU parameter error |
|
769 response.AppendNum(EATCMSErr304); |
|
770 break; |
|
771 } |
|
772 case KErrGsm0707SimFailure: |
|
773 case KErrGsmMMServiceOptionTemporaryOutOfOrder: |
|
774 { |
|
775 // SIM card not inserted |
|
776 response.AppendNum(EATCMSErr310); |
|
777 break; |
|
778 } |
|
779 case KErrGsmSMSSimPin1Required: |
|
780 { |
|
781 // PIN request by SIM card |
|
782 response.AppendNum(EATCMSErr311); |
|
783 break; |
|
784 } |
|
785 case KErrGsmSMSPhoneToSimLockRequired: |
|
786 { |
|
787 // PH-(U) SIM PIN request by SIM card |
|
788 response.AppendNum(EATCMSErr312); |
|
789 break; |
|
790 } |
|
791 case KErrGsmSMSSimPuk1Required: |
|
792 { |
|
793 // PUK request by SIM card |
|
794 response.AppendNum(EATCMSErr316); |
|
795 break; |
|
796 } |
|
797 case KErrGsmSMSMemoryFailure: |
|
798 { |
|
799 // Memory error |
|
800 response.AppendNum(EATCMSErr320); |
|
801 break; |
|
802 } |
|
803 case KErrPathNotFound: |
|
804 case KErrGsmSMSInvalidMemoryIndex: |
|
805 { |
|
806 // Invalid Memory index number |
|
807 response.AppendNum(EATCMSErr321); |
|
808 break; |
|
809 } |
|
810 case KErrOverflow: |
|
811 case KErrGsmSMSMemoryFull: |
|
812 { |
|
813 // Memory is full |
|
814 response.AppendNum(EATCMSErr322); |
|
815 break; |
|
816 } |
|
817 default: |
|
818 { |
|
819 response.AppendNum(EATCmsErrGeneral); |
|
820 break; |
|
821 } |
|
822 } |
|
823 CreateReplyAndComplete( EReplyTypeError, response ); |
|
824 response.Close(); |
|
825 } |
|
826 |
|
827 TRACE_FUNC_EXIT |
524 TRACE_FUNC_EXIT |
828 } |
525 } |
829 |
526 |
830 TInt CATMiscCmdPlugin::HandleUnsolicitedRequest(const TDesC8& aAT ) |
527 TInt CATMiscCmdPlugin::HandleUnsolicitedRequest(const TDesC8& aAT ) |
831 { |
528 { |