26 #include "cbccommandhandler.h" |
26 #include "cbccommandhandler.h" |
27 |
27 |
28 #include "atmisccmdpluginconsts.h" |
28 #include "atmisccmdpluginconsts.h" |
29 #include "debug.h" |
29 #include "debug.h" |
30 |
30 |
31 #include <exterror.h> // Additional RMobilePhone error code |
31 #include <EXTERROR.H> // Additional RMobilePhone error code |
32 |
|
33 |
32 |
34 // +CME error code |
33 // +CME error code |
35 _LIT8(KCMEIncorrectPassword, "+CME: 16\r\n"); // Incorrect password.\r\n |
34 _LIT8(KCMEIncorrectPassword, "+CME ERROR: 16\r\n"); // Incorrect password.\r\n |
36 _LIT8(KCMEPUKRequired, "+CME: 12\r\n"); // PUK required.\r\n |
35 _LIT8(KCMEPUKRequired, "+CME ERROR: 12\r\n"); // PUK required.\r\n |
37 _LIT8(KCMENotAllowed, "+CME: 3\r\n"); // Operation not allowed.\r\n |
36 _LIT8(KCMENotAllowed, "+CME ERROR: 3\r\n"); // Operation not allowed.\r\n |
38 _LIT8(KCMEPhoneError, "+CME: 0\r\n"); // Phone failure.\r\n |
37 _LIT8(KCMEPhoneError, "+CME ERROR: 0\r\n"); // Phone failure.\r\n |
39 _LIT8(KCMEPhoneUnknown, "+CME: 100\r\n"); // unknown error |
38 _LIT8(KCMEPhoneUnknown, "+CME ERROR: 100\r\n"); // unknown error |
40 |
39 |
41 const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF |
40 const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF |
42 |
41 |
43 CATMiscCmdPlugin* CATMiscCmdPlugin::NewL() |
42 CATMiscCmdPlugin* CATMiscCmdPlugin::NewL() |
44 { |
43 { |
454 |
465 |
455 void CATMiscCmdPlugin::CreateCMEReplyAndComplete(TInt aError) |
466 void CATMiscCmdPlugin::CreateCMEReplyAndComplete(TInt aError) |
456 { |
467 { |
457 TRACE_FUNC_ENTRY |
468 TRACE_FUNC_ENTRY |
458 |
469 |
459 // TODO should return CME error according to CME state (and quiet mode?) |
470 // currently only support +CME error level 0 and 1 |
460 RBuf8 response; |
471 ASSERT(iErrorLevel == 0 || iErrorLevel == 1 ); |
461 response.Create(KDefaultCmdBufLength); |
472 |
462 |
473 // Log error code |
463 // log error code |
474 Trace(KDebugPrintD, "complete with error ", aError); |
464 response.AppendNum(aError); |
475 |
465 Trace(KDebugPrintD, "complete with error ", &response); |
476 if(iErrorLevel == 1 && !iQuietMode) |
466 |
477 { |
467 // return error code to AT client |
478 // return error code to AT client |
468 response.Zero(); // reuse RBuf |
479 RBuf8 response; |
469 response.Append(KCRLF); |
480 response.Create(KDefaultCmdBufLength); |
470 switch(aError) |
481 response.Append(KCRLF); |
471 { |
482 switch(aError) |
472 case KErrGsm0707IncorrectPassword: |
483 { |
473 case KErrAccessDenied: |
484 case KErrGsm0707IncorrectPassword: |
474 { |
485 case KErrAccessDenied: |
475 // code was entered erroneously |
486 { |
476 response.Append(KCMEIncorrectPassword); |
487 // code was entered erroneously |
477 break; |
488 response.Append(KCMEIncorrectPassword); |
478 } |
489 break; |
479 case KErrGsmSSPasswordAttemptsViolation: |
490 } |
480 case KErrLocked: |
491 case KErrGsmSSPasswordAttemptsViolation: |
481 { |
492 case KErrLocked: |
482 // Pin blocked |
493 { |
483 response.Append(KCMEPUKRequired); |
494 // Pin blocked |
484 break; |
495 response.Append(KCMEPUKRequired); |
485 } |
496 break; |
486 case KErrGsm0707OperationNotAllowed: |
497 } |
487 { |
498 case KErrGsm0707OperationNotAllowed: |
488 // not allowed with this sim |
499 { |
489 response.Append(KCMENotAllowed); |
500 // not allowed with this sim |
490 break; |
501 response.Append(KCMENotAllowed); |
491 } |
502 break; |
492 case KErrUnknown: |
503 } |
493 { |
504 case KErrUnknown: |
494 // unknown error |
505 { |
495 response.Append(KCMEPhoneUnknown); |
506 // unknown error |
496 break; |
507 response.Append(KCMEPhoneUnknown); |
497 } |
508 break; |
498 default: |
509 } |
499 response.Append(KCMEPhoneError); |
510 default: |
500 } |
511 { |
501 CreateReplyAndComplete( EReplyTypeError, response ); |
512 response.Append(KCMEPhoneError); |
502 response.Close(); |
513 break; |
503 TRACE_FUNC_EXIT |
514 } |
504 } |
515 } |
505 |
516 CreateReplyAndComplete( EReplyTypeError, response ); |
|
517 response.Close(); |
|
518 } |
|
519 else |
|
520 { |
|
521 CreateReplyAndComplete( EReplyTypeError); |
|
522 } |
|
523 |
|
524 TRACE_FUNC_EXIT |
|
525 } |
506 |
526 |
507 TInt CATMiscCmdPlugin::HandleUnsolicitedRequest(const TDesC8& aAT ) |
527 TInt CATMiscCmdPlugin::HandleUnsolicitedRequest(const TDesC8& aAT ) |
508 { |
528 { |
|
529 TRACE_FUNC_ENTRY |
|
530 TRACE_FUNC_EXIT |
509 return SendUnsolicitedResult(aAT); |
531 return SendUnsolicitedResult(aAT); |
|
532 } |
|
533 |
|
534 void CATMiscCmdPlugin::HandleCMEECommand() |
|
535 { |
|
536 TRACE_FUNC_ENTRY |
|
537 TAtCommandParser::TCommandHandlerType cmdHandlerType = iCommandParser.CommandHandlerType(); |
|
538 |
|
539 if (cmdHandlerType == TAtCommandParser::ECmdHandlerTypeSet) |
|
540 { |
|
541 // +CMEE=n |
|
542 TInt errLevel; |
|
543 TInt ret = iCommandParser.NextIntParam(errLevel); |
|
544 TPtrC8 param = iCommandParser.NextParam(); |
|
545 _LIT8(KCMEDbg, "CME : NextIntParam returned %d, NextParam Length is %d, errLevel %d\r\n"); |
|
546 Trace(KCMEDbg, ret, param.Length(), errLevel); |
|
547 if (ret == KErrNone && param.Length() == 0 && |
|
548 (errLevel == 0 || errLevel == 1)) |
|
549 { |
|
550 iErrorLevel = errLevel; |
|
551 _LIT8(KCMEErrorLevel, "CME error level: %d\r\n"); |
|
552 Trace(KCMEErrorLevel, iErrorLevel); |
|
553 } |
|
554 } |
|
555 TRACE_FUNC_EXIT |
510 } |
556 } |
511 |
557 |
512 void CATMiscCmdPlugin::ConnectToEtelL(RTelServer& aTelServer, RMobilePhone& aPhone) |
558 void CATMiscCmdPlugin::ConnectToEtelL(RTelServer& aTelServer, RMobilePhone& aPhone) |
513 { |
559 { |
514 TRACE_FUNC_ENTRY |
560 TRACE_FUNC_ENTRY |