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