telutils/phoneparser/src/PhoneGsmParser.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002 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:  Utility functions for clients.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "phonegsmparser.h" 
       
    21 #include    "cphonegsmparser.h" 
       
    22 #include    "cphonegsmparserbase.h" 
       
    23 #include    "cphonegsmparserresult.h" 
       
    24 #include    "cphonegsmoptioncontainer.h" 
       
    25 
       
    26 #include    "cphonegsmparsercontainer.h" 
       
    27 #include    "cphonegsmssparser.h" 
       
    28 #include    "cphonegsmsimcontrolparser.h" 
       
    29 #include    "cphonegsmphonenumberparser.h" 
       
    30 #include    "cphonegsmsscallparser.h" 
       
    31 #include    "cphonegsmmanufacturerparser.h" 
       
    32 #include    "cphonegsmpcnprocedureparser.h" 
       
    33 #include    "cphonegsmmanufacturerhandler.h" 
       
    34 #include    "cphonegsmemergencynumberparser.h" 
       
    35 #include    "cphoneparserfeatures.h" 
       
    36 #include    "cphonevoipnumberparser.h" 
       
    37 
       
    38 // CONSTANTS
       
    39 const TInt KPhoneParserResultParameterReserver = 10;
       
    40 _LIT( KPhoneParserPanic, "PhoneParser" );
       
    41 
       
    42 // Software version display code
       
    43 _LIT( KPhoneCodeBadPinChange, "**04*" );
       
    44 _LIT( KPhoneCodeBadPin2Change, "**042*" );
       
    45 _LIT( KPhoneCodeBadPinUnblock, "**05*" );
       
    46 _LIT( KPhoneCodeBadPin2Unblock, "**052*" );
       
    47 _LIT( KPhoneCodeActivateRfsNormal, "*#7780#" );
       
    48 _LIT( KPhoneCodeActivateRfsDeep, "*#7370#" );
       
    49 _LIT( KPhoneCodeBtAddress, "*#2820#" );
       
    50 _LIT( KPhoneCodeRFLoopback, "*#9990#" );
       
    51 _LIT( KPhoneCodeWLANMAC, "*#62209526#" );
       
    52 _LIT( KPhoneCodeBtDebugMode, "*#2873#" );
       
    53                   
       
    54 // ============================= LOCAL FUNCTIONS ===============================
       
    55 
       
    56 // ============================ MEMBER FUNCTIONS ===============================
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // PhoneGsmParser::CreateParserL
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CPhoneGsmParserBase* PhoneGsmParser::CreateParserL()
       
    63     {
       
    64     // 1. SS CONTAINER TO STACK
       
    65     CPhoneGsmParserContainer* ssContainer =
       
    66         CPhoneGsmParserContainer::NewLC();
       
    67 
       
    68     CPhoneGsmParserBase* ssProcedure = 
       
    69         CPhoneGsmSsParser::NewLC();
       
    70     ssContainer->AddL( *ssProcedure );
       
    71     CleanupStack::Pop( ssProcedure );
       
    72 
       
    73     CPhoneGsmParserBase* ssCallProcedure =
       
    74         CPhoneGsmSsCallParser::NewLC();
       
    75     ssContainer->AddL( *ssCallProcedure );
       
    76     CleanupStack::Pop( ssCallProcedure );
       
    77     
       
    78     // 2. SIM CONTROL PROCEDURE TO STACK
       
    79     CPhoneGsmParserBase* simControlProcedure = 
       
    80         CPhoneGsmSimControlParser::NewLC();
       
    81    
       
    82     // 3. PHONE NUMBER TO STACK
       
    83     CPhoneGsmParserBase* phoneNumber =
       
    84         CPhoneGsmPhoneNumberParser::NewLC();
       
    85 
       
    86     // 4. MANUFACTURER SPECIFIC TO STACK
       
    87     CPhoneGsmParserBase* manufacturerSpecific = 
       
    88         CreateManufacturerProcedureParserLC();
       
    89         
       
    90     // 5. EMERGENCY NUMBER PARSER TO STACK
       
    91     CPhoneGsmParserBase* emergencyNumberParser =
       
    92         CPhoneGsmEmergencyNumberParser::NewLC();
       
    93         
       
    94     // 6. VOIP NUMBER PARSER TO STACK
       
    95     CPhoneGsmParserBase* voipNumberParser =
       
    96         CPhoneVoipNumberParser::NewLC();
       
    97     
       
    98     CPhoneGsmParser* parser = 
       
    99         CPhoneGsmParser::NewL(
       
   100             ssContainer, 
       
   101             simControlProcedure,
       
   102             phoneNumber,
       
   103             manufacturerSpecific,
       
   104             emergencyNumberParser,
       
   105             voipNumberParser);
       
   106 
       
   107     CleanupStack::Pop( 6, ssContainer );
       
   108 
       
   109     return parser;
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // PhoneGsmParser::UseFeatureStub
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 #ifdef __WINS__
       
   117 EXPORT_C void PhoneGsmParser::UseFeatureStub( CPhoneParserFeatures* aStub )
       
   118     {
       
   119     CPhoneParserFeatures::SetInstance( aStub );
       
   120     }
       
   121 #endif // __WINS__
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // PhoneGsmParser::CreateResultsL
       
   125 //
       
   126 // Create parser so that AddParameterL shouldn't leave.
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 EXPORT_C CPhoneGsmParserResult* PhoneGsmParser::CreateResultL()
       
   130     {
       
   131     CPhoneGsmParserResult* result = CPhoneGsmParserResult::NewL();
       
   132     
       
   133     CleanupStack::PushL( result );
       
   134     result->ReserveParametersL( KPhoneParserResultParameterReserver );
       
   135     CleanupStack::Pop( result );
       
   136 
       
   137     result->ClearL();
       
   138     return result;
       
   139     }
       
   140 
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // PhoneGsmParser::CreateOptionContainerL
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C CPhoneGsmOptionContainerBase* PhoneGsmParser::CreateOptionContainerL()
       
   147     {
       
   148     CPhoneGsmOptionContainer* options =
       
   149         CPhoneGsmOptionContainer::NewL();
       
   150     
       
   151     CleanupStack::PushL( options );
       
   152 
       
   153     DefineOptionsL( *options );
       
   154     InitialiseOptionsToDefaultValues( *options );
       
   155 
       
   156     CleanupStack::Pop( options );
       
   157     return options;
       
   158     }
       
   159 
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // PhoneGsmParser::InitialiseOptionsToDefaultValues
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void PhoneGsmParser::InitialiseOptionsToDefaultValues( 
       
   166         CPhoneGsmOptionContainerBase& aOptions )
       
   167     {
       
   168     aOptions.SetOptionStatus( KPhoneOptionSend, EFalse );
       
   169     aOptions.SetOptionStatus( KPhoneOptionInCall, EFalse );
       
   170     aOptions.SetOptionStatus( KPhoneOptionVoipCall, EFalse );
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // PhoneGsmParser::DetermineContentType
       
   175 //
       
   176 // It is helper method to categorize processed strings.
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C PhoneGsmParser::TContentType 
       
   180     PhoneGsmParser::DetermineContentType( 
       
   181         const CPhoneGsmParserResult& aResult )
       
   182     {
       
   183     TContentType type = EContentUnknown;
       
   184     TUint uid = aResult.Uid();
       
   185     TUint main = PHONE_EXTRACT_MAIN( aResult.Uid() );
       
   186 
       
   187     switch ( main )
       
   188         {
       
   189         case KPhoneGsmUidInvalid:
       
   190             type = EContentInvalid;
       
   191             break;
       
   192 
       
   193         case KPhoneGsmUidMisc:
       
   194             if ( uid == KPhoneUidUnstructuredService )
       
   195                 {
       
   196                 type = EContentUnstructuredService;
       
   197                 }
       
   198             break;
       
   199 
       
   200         case KPhoneGsmUidSupplementaryService:
       
   201         case KPhoneGsmUidSupplementaryServiceDuringCall:
       
   202             type = EContentSupplementaryService;
       
   203             break;
       
   204 
       
   205         case KPhoneGsmUidDialPhoneNumber:
       
   206             type = EContentPhoneNumber;
       
   207             break;
       
   208 
       
   209         default:
       
   210             break;
       
   211         }
       
   212 
       
   213     return type;
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // PhoneGsmParser::IsAllowedForArriving
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C TBool PhoneGsmParser::IsAllowedForArriving(
       
   221         const CPhoneGsmParserResult& aResult )
       
   222     {  
       
   223     TUint32 uid = aResult.Uid();
       
   224     
       
   225     // Allowed:
       
   226     //      0 SEND
       
   227     //      All manufacturer codes
       
   228     //      All sim control procedures
       
   229     //      All pcn procedures
       
   230     
       
   231     return ( uid == KPhoneUidCommand0 ||
       
   232              uid == KPhoneUidManufacturerDebugCode ||
       
   233              uid == KPhoneUidManufacturerCode || 
       
   234              PHONE_EXTRACT_MAIN( uid ) == KPhoneGsmUidSimControlProcedure ||
       
   235              PHONE_EXTRACT_MAIN( uid ) == KPhoneGsmUidPcnProcedures );
       
   236     }
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // PhoneGsmParser::IsAllowedForBadSim
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 EXPORT_C TBool PhoneGsmParser::IsAllowedForBadSim(
       
   243         const CPhoneGsmParserResult& aResult )
       
   244     {
       
   245     TUint32 uid = aResult.Uid();
       
   246     TUint aux = aResult.AuxInformation();
       
   247 
       
   248     // Allowed:
       
   249     //      DialEmergency
       
   250     //      Some manufacturer codes
       
   251     //      All sim control procedures
       
   252     //      All pcn procedures
       
   253     
       
   254     return ( uid == KPhoneUidEmergencyNumber ||
       
   255              uid == KPhoneUidManufacturerDebugCode ||
       
   256              ( uid == KPhoneUidManufacturerCode && 
       
   257                ( aux == CPhoneGsmManufacturerHandler::EBadPinChange ||
       
   258                  aux == CPhoneGsmManufacturerHandler::EBadPin2Change ||
       
   259                  aux == CPhoneGsmManufacturerHandler::EBadPinUnblock ||
       
   260                  aux == CPhoneGsmManufacturerHandler::EBadPin2Unblock ) ) ||
       
   261 
       
   262              PHONE_EXTRACT_MAIN( uid ) == KPhoneGsmUidSimControlProcedure ||
       
   263              PHONE_EXTRACT_MAIN( uid ) == KPhoneGsmUidPcnProcedures );
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // PhoneGsmParser::Panic
       
   268 //
       
   269 // Panic for phone parser.
       
   270 // -----------------------------------------------------------------------------
       
   271 //
       
   272 void PhoneGsmParser::Panic( 
       
   273         TPanicReason aReason )
       
   274     {
       
   275     User::Panic( KPhoneParserPanic, aReason );
       
   276     }
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // PhoneGsmParser::DefineOptionsL
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 void PhoneGsmParser::DefineOptionsL( 
       
   283         CPhoneGsmOptionContainerBase& aOptions )
       
   284     {
       
   285     CPhoneGsmOptionContainer& options =
       
   286             static_cast<CPhoneGsmOptionContainer&>( aOptions );
       
   287     
       
   288     options.DefineOptionL( KPhoneOptionSend, EFalse );
       
   289     options.DefineOptionL( KPhoneOptionInCall, EFalse );
       
   290     options.DefineOptionL( KPhoneOptionVoipCall, EFalse );
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // PhoneGsmParser::CreateManufacturerProcedureParserLC
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 CPhoneGsmParserBase* 
       
   298     PhoneGsmParser::CreateManufacturerProcedureParserLC()
       
   299     {
       
   300     // CONTAINER TO STACK.
       
   301     CPhoneGsmParserContainer* manufacturer =
       
   302         CPhoneGsmParserContainer::NewLC();
       
   303 
       
   304     CPhoneGsmPcnProcedureParser* gsmPcnCodes =
       
   305         CPhoneGsmPcnProcedureParser::NewLC();
       
   306     manufacturer->AddL( *gsmPcnCodes );
       
   307     CleanupStack::Pop( gsmPcnCodes );
       
   308 
       
   309     CPhoneGsmManufacturerParser* manuCodes =
       
   310         CPhoneGsmManufacturerParser::NewLC();
       
   311     manufacturer->AddL( *manuCodes );
       
   312     CleanupStack::Pop( manuCodes );
       
   313 
       
   314     manuCodes->AddStringL( 
       
   315         KPhoneCodeBadPinChange,
       
   316         CPhoneGsmManufacturerParser::EFlagCode + 
       
   317         CPhoneGsmManufacturerParser::EFlagPrefix,
       
   318         CPhoneGsmManufacturerHandler::EBadPinChange );
       
   319 
       
   320     manuCodes->AddStringL( 
       
   321         KPhoneCodeBadPin2Change,
       
   322         CPhoneGsmManufacturerParser::EFlagCode + 
       
   323         CPhoneGsmManufacturerParser::EFlagPrefix,
       
   324         CPhoneGsmManufacturerHandler::EBadPin2Change );
       
   325 
       
   326     manuCodes->AddStringL( 
       
   327         KPhoneCodeBadPinUnblock,
       
   328         CPhoneGsmManufacturerParser::EFlagCode + 
       
   329         CPhoneGsmManufacturerParser::EFlagPrefix,
       
   330         CPhoneGsmManufacturerHandler::EBadPinUnblock );
       
   331 
       
   332     manuCodes->AddStringL( 
       
   333         KPhoneCodeBadPin2Unblock,
       
   334         CPhoneGsmManufacturerParser::EFlagCode + 
       
   335         CPhoneGsmManufacturerParser::EFlagPrefix,
       
   336         CPhoneGsmManufacturerHandler::EBadPin2Unblock );
       
   337 
       
   338     manuCodes->AddStringL(
       
   339         KPhoneCodeActivateRfsNormal,
       
   340         CPhoneGsmManufacturerParser::EFlagCode,
       
   341         CPhoneGsmManufacturerHandler::EActivateRfsNormal );
       
   342 
       
   343     manuCodes->AddStringL(
       
   344         KPhoneCodeActivateRfsDeep,
       
   345         CPhoneGsmManufacturerParser::EFlagCode,
       
   346         CPhoneGsmManufacturerHandler::EActivateRfsDeep );
       
   347 
       
   348     manuCodes->AddStringL(
       
   349         KPhoneCodeBtAddress,
       
   350         CPhoneGsmManufacturerParser::EFlagCode,
       
   351         CPhoneGsmManufacturerHandler::EShowBtAddress,
       
   352         KFeatureIdBt );
       
   353 
       
   354     manuCodes->AddStringL(
       
   355         KPhoneCodeWLANMAC, 
       
   356         CPhoneGsmManufacturerParser::EFlagCode,
       
   357         CPhoneGsmManufacturerHandler::EShowWlanMac,
       
   358         KFeatureIdProtocolWlan );       
       
   359 
       
   360     manuCodes->AddStringL( 
       
   361         KPhoneCodeRFLoopback,
       
   362         CPhoneGsmManufacturerParser::EFlagCode,
       
   363         CPhoneGsmManufacturerHandler::EBTLoopback,
       
   364         KFeatureIdBtTestMode );
       
   365 
       
   366     manuCodes->AddStringL( 
       
   367         KPhoneCodeBtDebugMode,
       
   368         CPhoneGsmManufacturerParser::EFlagCode,
       
   369         CPhoneGsmManufacturerHandler::EBTDebugMode,
       
   370         KFeatureIdBt );
       
   371 
       
   372     return manufacturer;
       
   373     }
       
   374 
       
   375 //  End of File