telutils/phoneparser/src/CPhoneGsmSsParser.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:  Principal parser for supplementary service procedures.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    <bldvariant.hrh>
       
    21 #include    <featmgr.h>
       
    22 #include    <nwdefs.h>
       
    23 
       
    24 #include    "cphonegsmssparser.h" 
       
    25 #include    "cphonegsmparserresult.h" 
       
    26 #include    "phonegsmparser.h" 
       
    27 #include    "cphonegsmoptioncontainer.h" 
       
    28 #include    "cphoneparserfeatures.h" 
       
    29 
       
    30 // CONSTANTS
       
    31 
       
    32 // Granularity of service array
       
    33 const TInt KPhoneServiceArrayGranularity = 20;
       
    34 
       
    35 // Activation starts with *. See also registration.
       
    36 _LIT( KPhoneSsActivation, "*" );
       
    37 
       
    38 // Deactivation starts with #.
       
    39 _LIT( KPhoneSsDeactivation, "#" );
       
    40 
       
    41 // Interrogation starts with *#.
       
    42 _LIT( KPhoneSsInterrogation, "*#" );
       
    43 
       
    44 // Registration starts with ** OR *. Case * is handled in the code.
       
    45 _LIT( KPhoneSsRegistration, "**" );
       
    46 
       
    47 // Erasure starts with ##.
       
    48 _LIT( KPhoneSsErasure, "##" );
       
    49 
       
    50 // It defines characters that can be used in these prefixes (see above).
       
    51 _LIT( KPhoneSsActionCharacters, "*#" );
       
    52 
       
    53 // It defines string that ends all ss requests.
       
    54 _LIT( KPhoneSsEnd, "#" );
       
    55 
       
    56 // It defines characters that are considered to be digits.
       
    57 _LIT( KPhoneSsDigits, "1234567890" );
       
    58 
       
    59 // Asterisk.
       
    60 const TInt KPhoneSsAsterisk = '*';
       
    61 
       
    62 // Hash.
       
    63 const TInt KPhoneSsHash = '#';
       
    64 
       
    65 // Plus.
       
    66 const TInt KPhoneSsPlus = '+';
       
    67 
       
    68 // Remainder: single character
       
    69 const TInt KPhoneSsRemainderSingle = 1;
       
    70 
       
    71 // Remainder: still a parameter, but ok ss
       
    72 const TInt KPhoneSsRemainderMinLength = 2; // something + #
       
    73 
       
    74 const TInt KPhoneSsPasswordLength = 4; 
       
    75 
       
    76 // Remainder: passwordk, ok ss
       
    77 const TInt KPhoneSsRemainderPasswordMinLength = 5; // four digits + #
       
    78 
       
    79 // Maximum length of directory number.
       
    80 const TInt KPhoneSsDirectoryNumberMaxLength = 38;
       
    81 // Maximum length of basic service code.
       
    82 const TInt KPhoneSsBasicCodeMaxLength = 2;
       
    83 // Maximum length of group code.
       
    84 const TInt KPhoneSsGroupCodeMaxLength = 4;
       
    85 // Maximum length of timer.
       
    86 const TInt KPhoneSsTimerMaxLength = 2;
       
    87 
       
    88 // The only acceptable group code (change of barring password)
       
    89 const TUint KPhoneSsOnlyAllowedGroupCode = 330;
       
    90 
       
    91 // Pack: shift
       
    92 const TInt KPhoneGsmPackShift = 8;
       
    93 
       
    94 // Pack: mask
       
    95 const TInt KPhoneGsmPackMask = 255;
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // Syntax:
       
    99 //    
       
   100 //      SC      Service code
       
   101 //      A       Activation
       
   102 //      D       Deactivation
       
   103 //      I       Interrogation
       
   104 //      R       Registration
       
   105 //      E       Erasure
       
   106 //
       
   107 //     Text string must contain each of these in the following order
       
   108 //     "SC A D I R E" (separated by space). Following values correspond
       
   109 //      
       
   110 //
       
   111 //     0 - ENotAllowed       
       
   112 //     1 - ENoParameters
       
   113 //     2 - EEmptyOrBasicCode
       
   114 //     3 - ENumberOptBasicCodeOptTimer
       
   115 //     4 - ENumberOptBasicCode     
       
   116 //     5 - EPasswordOptBasicCode
       
   117 //     6 - EOptGroupCodePasswordNewPasswordNewPassword    
       
   118 //     7 - EEmptyOrBasicCode2         
       
   119 // -----------------------------------------------------------------------------
       
   120 _LIT( KPhoneUidForwardingAllCode,                                   "002 2 2 0 3 2" );
       
   121 _LIT( KPhoneUidForwardingAllConditionalCode,                        "004 2 2 0 3 2" );
       
   122 _LIT( KPhoneUidForwardingUnconditionalCode,                         "21  2 2 2 4 2" );
       
   123 _LIT( KPhoneUidForwardingNoReplyCode,                               "61  2 2 2 3 2" );
       
   124 _LIT( KPhoneUidForwardingNotReachableCode,                          "62  2 2 2 4 2" );
       
   125 _LIT( KPhoneUidForwardingBusyCode,                                  "67  2 2 2 4 2" );
       
   126 _LIT( KPhoneUidBarringAllOutgoingCallsCode,                         "33  5 5 1 0 0" );
       
   127 _LIT( KPhoneUidBarringAllIncomingCallsCode,                         "35  5 5 1 0 0" );
       
   128 _LIT( KPhoneUidBarringAllServicesCode,                              "330 0 5 0 0 0" );
       
   129 _LIT( KPhoneUidBarringAllOutgoingInternationalCallsCode,            "331 5 5 1 0 0" );
       
   130 _LIT( KPhoneUidBarringAllOutgoingInternationalCallsExceptHomeCode,  "332 5 5 1 0 0" );
       
   131 _LIT( KPhoneUidBarringAllOutgoingServicesCode,                      "333 0 5 0 0 0" );
       
   132 _LIT( KPhoneUidBarringAllIncomingCallsWhenRoamingCode,              "351 5 5 1 0 0" );
       
   133 _LIT( KPhoneUidBarringAllIncomingServicesCode,                      "353 0 5 0 0 0" );
       
   134 _LIT( KPhoneUidWaitingCode,                                         "43  7 7 7 0 0" );
       
   135 _LIT( KPhoneUidCallingLineIdentificationPresentationCode,           "30  0 0 1 0 0" );
       
   136 _LIT( KPhoneUidCallingLineIdentificationRestrictionCode,            "31  0 0 1 0 0" );
       
   137 _LIT( KPhoneUidConnectedLinePresentationCode,                       "76  0 0 1 0 0" );
       
   138 _LIT( KPhoneUidConnectedLinePresentationRestrictionCode,            "77  0 0 1 0 0" ); 
       
   139 _LIT( KPhoneUidPasswordCode,                                        "03  6 0 0 6 0" );
       
   140 _LIT( KPhoneUidCallingNamePresentationCode,                         "300 0 0 1 0 0" );
       
   141 
       
   142 // ============================ MEMBER FUNCTIONS ===============================
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CPhoneGsmSsParser::CPhoneGsmSsParser
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 CPhoneGsmSsParser::CPhoneGsmSsParser()
       
   149     {
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CPhoneGsmSsParser::ConstructL
       
   154 // -----------------------------------------------------------------------------
       
   155 //
       
   156 void CPhoneGsmSsParser::ConstructL()
       
   157     {
       
   158     iArray = 
       
   159         new ( ELeave ) CServiceArray( 
       
   160             KPhoneServiceArrayGranularity );
       
   161 
       
   162     // Check AddL method for details what these really mean.
       
   163     
       
   164     // Forwarding
       
   165     AddL( KPhoneUidForwardingAllCode, 
       
   166         KPhoneUidForwardingAll );
       
   167     AddL( KPhoneUidForwardingAllConditionalCode, 
       
   168         KPhoneUidForwardingAllConditional );
       
   169     AddL( KPhoneUidForwardingUnconditionalCode, 
       
   170         KPhoneUidForwardingUnconditional );
       
   171     AddL( KPhoneUidForwardingNoReplyCode, 
       
   172         KPhoneUidForwardingNoReply );
       
   173     AddL( KPhoneUidForwardingNotReachableCode, 
       
   174         KPhoneUidForwardingNotReachable );
       
   175     AddL( KPhoneUidForwardingBusyCode, 
       
   176         KPhoneUidForwardingBusy );
       
   177 
       
   178     // Barring
       
   179     AddL( KPhoneUidBarringAllOutgoingCallsCode, 
       
   180         KPhoneUidBarringAllOutgoingCalls );
       
   181     AddL( KPhoneUidBarringAllIncomingCallsCode, 
       
   182         KPhoneUidBarringAllIncomingCalls );
       
   183     AddL( KPhoneUidBarringAllServicesCode, 
       
   184         KPhoneUidBarringAllServices );
       
   185     AddL( KPhoneUidBarringAllOutgoingInternationalCallsCode, 
       
   186         KPhoneUidBarringAllOutgoingInternationalCalls );
       
   187     AddL( KPhoneUidBarringAllOutgoingInternationalCallsExceptHomeCode, 
       
   188         KPhoneUidBarringAllOutgoingInternationalCallsExceptHome );
       
   189     AddL( KPhoneUidBarringAllOutgoingServicesCode, 
       
   190         KPhoneUidBarringAllOutgoingServices );
       
   191     AddL( KPhoneUidBarringAllIncomingCallsWhenRoamingCode, 
       
   192         KPhoneUidBarringAllIncomingCallsWhenRoaming );
       
   193     AddL( KPhoneUidBarringAllIncomingServicesCode, 
       
   194         KPhoneUidBarringAllIncomingServices );
       
   195     
       
   196     // Waiting
       
   197     AddL( KPhoneUidWaitingCode, 
       
   198         KPhoneUidWaiting );
       
   199 
       
   200     // Calling line identification presentation
       
   201     AddL( KPhoneUidCallingLineIdentificationPresentationCode, 
       
   202         KPhoneUidCallingLineIdentificationPresentation );
       
   203 
       
   204     // Calling line identification restriction
       
   205     AddL( KPhoneUidCallingLineIdentificationRestrictionCode, 
       
   206         KPhoneUidCallingLineIdentificationRestriction );
       
   207 
       
   208     // Connected line presentation
       
   209     AddL( KPhoneUidConnectedLinePresentationCode, 
       
   210         KPhoneUidConnectedLinePresentation );
       
   211 
       
   212     // Connected line presentation restriction.
       
   213     AddL( KPhoneUidConnectedLinePresentationRestrictionCode, 
       
   214         KPhoneUidConnectedLinePresentationRestriction );
       
   215 
       
   216     // CNAP.  
       
   217     if ( CPhoneParserFeatures::FeatureSupported( KFeatureIdPhoneCnap ) )
       
   218         {
       
   219         AddL( KPhoneUidCallingNamePresentationCode, 
       
   220             KPhoneUidCallingNamePresentation );
       
   221         }
       
   222 
       
   223     // Password
       
   224     AddL( KPhoneUidPasswordCode, 
       
   225         KPhoneUidPassword );
       
   226 
       
   227     }
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 // CPhoneGsmSsParser::NewLC
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 CPhoneGsmSsParser* CPhoneGsmSsParser::NewLC()
       
   234     {
       
   235     CPhoneGsmSsParser* self = new ( ELeave ) CPhoneGsmSsParser;
       
   236     
       
   237     CleanupStack::PushL( self );
       
   238     self->ConstructL();
       
   239     
       
   240     return self;
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CPhoneGsmSsParser::~CPhoneGsmSsParser
       
   245 // -----------------------------------------------------------------------------
       
   246 //
       
   247 CPhoneGsmSsParser::~CPhoneGsmSsParser()
       
   248     {
       
   249     delete iArray;
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // CPhoneGsmSsParser::ParseL
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 TBool CPhoneGsmSsParser::ParseL( 
       
   257         const TDesC& aString, 
       
   258         CPhoneGsmParserResult& aResult,
       
   259         CPhoneGsmOptionContainerBase& aOptions )
       
   260     {
       
   261     TBool result = EFalse;
       
   262     aResult.ClearL();      
       
   263 // All operations require SEND.
       
   264 // If VoIP call no action needed here.
       
   265     if ( !aOptions.FindOptionStatus( KPhoneOptionSend ) ||
       
   266          aOptions.FindOptionStatus( KPhoneOptionVoipCall ) )
       
   267         {
       
   268         return EFalse;
       
   269         }
       
   270 
       
   271     TLex input( aString );
       
   272     TPtrC action( 
       
   273         FindString( 
       
   274             input, 
       
   275             KPhoneSsActionCharacters() ) );
       
   276 
       
   277     // Check if action is proper for service requests.
       
   278     TServiceType type = EServiceActivation;
       
   279     
       
   280     // This variable will indicate if action was ok.
       
   281     TBool ok = ETrue;
       
   282 
       
   283     // Fill type.
       
   284     if ( action == KPhoneSsActivation )
       
   285         {
       
   286         type = EServiceActivation;
       
   287         }
       
   288     else if ( action == KPhoneSsDeactivation )
       
   289         {
       
   290         type = EServiceDeactivation;
       
   291         }
       
   292     else if ( action == KPhoneSsInterrogation )
       
   293         {
       
   294         type = EServiceInterrogation;
       
   295         }
       
   296     else if ( action == KPhoneSsRegistration )
       
   297         {
       
   298         type = EServiceRegistration;
       
   299         }
       
   300     else if ( action == KPhoneSsErasure )
       
   301         {
       
   302         type = EServiceErasure;
       
   303         }
       
   304     else 
       
   305         {
       
   306         // Not ok.
       
   307         ok = EFalse;
       
   308         }
       
   309 
       
   310     // Prefix must be one of the service types.
       
   311     if ( ok )
       
   312         {
       
   313         TPtrC serviceCode( FindString( input, KPhoneSsDigits() ) );
       
   314         
       
   315         // Check that service code is not too long.
       
   316         if ( serviceCode.Length() > KPhoneGsmSsServiceCodeMaxLength )
       
   317             {
       
   318             return EFalse;
       
   319             }
       
   320 
       
   321         TKeyArrayFix key( _FOFF( TServiceInfo, iCode ), ECmpNormal );
       
   322         TServiceInfo info;
       
   323         TInt position;       
       
   324         info.iCode = serviceCode;
       
   325 
       
   326         // Check if the string can be a service request.
       
   327         if ( !iArray->FindIsq( info, key, position ) )
       
   328             {
       
   329             info = iArray->At( position );
       
   330             }
       
   331         else
       
   332             {
       
   333             // Not found.
       
   334             return EFalse;
       
   335             }
       
   336 
       
   337         TServiceSyntax syntax = ESyntaxNotAllowed;
       
   338 
       
   339         // Take syntax from info record.
       
   340         switch ( type )
       
   341             {
       
   342             case EServiceActivation:
       
   343                 syntax = info.iActivation;
       
   344                 break;
       
   345 
       
   346             case EServiceDeactivation:
       
   347                 syntax = info.iDeactivation;
       
   348                 break;
       
   349 
       
   350             case EServiceInterrogation:
       
   351                 syntax = info.iInterrogation;
       
   352                 break;
       
   353 
       
   354             case EServiceRegistration:
       
   355                 syntax = info.iRegistration;
       
   356                 break;
       
   357 
       
   358             case EServiceErasure:
       
   359                 syntax = info.iErasure;
       
   360                 break;
       
   361 
       
   362             default:
       
   363                 PhoneGsmParser::Panic( PhoneGsmParser::EShouldNeverHappen );
       
   364                 break;
       
   365             }
       
   366 
       
   367         TUint data;
       
   368         PackData( data, type, syntax );
       
   369 
       
   370         aResult.SetUid( info.iUid );
       
   371         aResult.SetAuxInformation( data );
       
   372         
       
   373         // We may have to backtrack in case HandleParametersL fails.
       
   374         TLexMark mark;
       
   375         input.Mark( mark );
       
   376 
       
   377         // First attempt
       
   378         result = HandleParametersL( input, aResult, syntax );
       
   379 
       
   380         // If action was activation and result was failure, then try registration.
       
   381         if ( !result && type == EServiceActivation )
       
   382             {
       
   383             // Backtrack.
       
   384             input.UnGetToMark( mark );
       
   385 
       
   386             // Clear previous results & fill information again.
       
   387 
       
   388             type = EServiceRegistration;
       
   389             syntax = info.iRegistration;
       
   390             PackData( data, type, syntax );
       
   391 
       
   392             aResult.ClearL();
       
   393             aResult.SetUid( info.iUid );
       
   394             aResult.SetAuxInformation( data );
       
   395 
       
   396             // Try again. If this fails, then it is really failure.
       
   397             result = HandleParametersL( input, aResult, syntax );
       
   398             }
       
   399         }
       
   400 
       
   401     return result;
       
   402     }
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // CPhoneGsmSsParser::PackData
       
   406 //
       
   407 // Combine data to integer.
       
   408 // -----------------------------------------------------------------------------
       
   409 //
       
   410 void CPhoneGsmSsParser::PackData(
       
   411         TUint& aResult,
       
   412         TServiceType aType,
       
   413         TServiceSyntax aSyntax )
       
   414     {
       
   415     aResult = 
       
   416         ( ( ( TUint )aType ) << KPhoneGsmPackShift ) + ( ( TUint )aSyntax );
       
   417     }
       
   418 
       
   419 // -----------------------------------------------------------------------------
       
   420 // CPhoneGsmSsParser::UnpackData
       
   421 // 
       
   422 // Take data from integer.
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 void CPhoneGsmSsParser::UnpackData(
       
   426         TUint aData,
       
   427         TServiceType& aResultType,
       
   428         TServiceSyntax& aResultSyntax )
       
   429     {
       
   430     aResultSyntax = 
       
   431         CPhoneGsmSsParser::TServiceSyntax( aData & KPhoneGsmPackMask );
       
   432     aResultType = 
       
   433         CPhoneGsmSsParser::TServiceType( 
       
   434             ( aData >> KPhoneGsmPackShift ) & 
       
   435             KPhoneGsmPackMask );
       
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // CPhoneGsmSsParser::HandleParametersL
       
   440 //
       
   441 // Selects correct function by syntax information.
       
   442 // -----------------------------------------------------------------------------
       
   443 //
       
   444 TBool CPhoneGsmSsParser::HandleParametersL( 
       
   445         TLex& aInput, 
       
   446         CPhoneGsmParserResult& aResult,
       
   447         TServiceSyntax aSyntax )
       
   448     {
       
   449     TBool result = EFalse;
       
   450 
       
   451     switch ( aSyntax )
       
   452         {
       
   453         case ESyntaxNotAllowed:
       
   454             result = 
       
   455                 HandleNotAllowedL( aInput, aResult );
       
   456             break;
       
   457 
       
   458         case ESyntaxNoParameters:
       
   459             result = 
       
   460                 HandleNoParametersL( aInput, aResult );
       
   461             break;
       
   462 
       
   463         case ESyntaxEmptyOrBasicCode:
       
   464             result = 
       
   465                 HandleEmptyOrBasicCodeL( aInput, aResult );
       
   466             break;
       
   467             
       
   468         case ESyntaxNumberOptBasicCodeOptTimer:
       
   469             result = 
       
   470                 HandleNumberOptBasicCodeOptTimerL( 
       
   471                     aInput, 
       
   472                     aResult );
       
   473             break;
       
   474 
       
   475         case ESyntaxNumberOptBasicCode:
       
   476             result = 
       
   477                 HandleNumberOptBasicCodeL( 
       
   478                     aInput, 
       
   479                     aResult );
       
   480             break;
       
   481 
       
   482         case ESyntaxPasswordOptBasicCode:
       
   483             result = 
       
   484                 HandlePasswordOptBasicCodeL( 
       
   485                     aInput, 
       
   486                     aResult );
       
   487             break;
       
   488             
       
   489         case ESyntaxOptGroupCodePasswordNewPasswordNewPassword:
       
   490             result = 
       
   491                 HandleOptGroupCodePasswordNewPasswordNewPasswordL( 
       
   492                     aInput, 
       
   493                     aResult );
       
   494             break;
       
   495 
       
   496         case ESyntaxEmptyOrBasicCode2:
       
   497             result = 
       
   498                 HandleEmptyOrBasicCode2L( 
       
   499                     aInput, 
       
   500                     aResult );
       
   501             break;
       
   502 
       
   503         default:
       
   504             break;
       
   505         }          
       
   506 
       
   507     return result;
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CPhoneGsmSsParser::HandleNotAllowedL
       
   512 //
       
   513 // Just clear the result and return that parsing failed.
       
   514 // -----------------------------------------------------------------------------
       
   515 //
       
   516 TBool CPhoneGsmSsParser::HandleNotAllowedL( 
       
   517         TLex& /*aInput*/, 
       
   518         CPhoneGsmParserResult& aResult )
       
   519     {
       
   520     aResult.ClearL();
       
   521     
       
   522     return EFalse;
       
   523     }
       
   524 
       
   525 // -----------------------------------------------------------------------------
       
   526 // CPhoneGsmSsParser::HandleNoParametersL
       
   527 //
       
   528 // Handle no more parameters, only hash 
       
   529 // as the last character.
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 TBool CPhoneGsmSsParser::HandleNoParametersL( 
       
   533         TLex& aInput, 
       
   534         CPhoneGsmParserResult& /*aResult*/ )
       
   535     {
       
   536     // Next character is last character and it is hash character.
       
   537     TBool result = EFalse;
       
   538     TPtrC ptr = aInput.Remainder();
       
   539 
       
   540     if ( ptr.Length() == KPhoneSsRemainderSingle )
       
   541         {
       
   542         result = ( ptr[0] == KPhoneSsHash );
       
   543         }
       
   544 
       
   545     return result;
       
   546     }
       
   547 
       
   548 // -----------------------------------------------------------------------------
       
   549 // CPhoneGsmSsParser::HandleEmptyOrBasicCodeL
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 TBool CPhoneGsmSsParser::HandleEmptyOrBasicCodeL( 
       
   553         TLex& aInput,
       
   554         CPhoneGsmParserResult& aResult )
       
   555     {
       
   556     TBool result = EFalse;
       
   557 
       
   558     if ( HandleNoParametersL( aInput, aResult ) )
       
   559         {
       
   560         aResult.AddParameterL( KNullDesC );
       
   561         aResult.AddParameterL( KNullDesC );
       
   562         result = ETrue;
       
   563         }
       
   564     else
       
   565         {
       
   566         result = HandleEmptyParameterL( aInput, aResult );
       
   567 
       
   568         if ( result )
       
   569             {
       
   570             result = HandleBasicCodeL( aInput, aResult );
       
   571             result = result && HandleNoParametersL( aInput, aResult );
       
   572             }
       
   573         }
       
   574 
       
   575     return result;
       
   576     }
       
   577 
       
   578 // -----------------------------------------------------------------------------
       
   579 // CPhoneGsmSsParser::HandleNumberOptBasicCodeOptTimerL
       
   580 // -----------------------------------------------------------------------------
       
   581 //
       
   582 TBool CPhoneGsmSsParser::HandleNumberOptBasicCodeOptTimerL(
       
   583         TLex& aInput,
       
   584         CPhoneGsmParserResult& aResult )
       
   585     {
       
   586     TBool result = EFalse;
       
   587     
       
   588     if ( HandleNumberL( aInput, aResult ) )
       
   589         {
       
   590         if ( HandleNoParametersL( aInput, aResult ) )
       
   591             {
       
   592             // Add basic code and timer.
       
   593             aResult.AddParameterL( KNullDesC ); 
       
   594             aResult.AddParameterL( KNullDesC ); 
       
   595             result = ETrue;
       
   596             }
       
   597         else 
       
   598             {
       
   599             if ( HandleBasicCodeL( aInput, aResult ) )
       
   600                 {
       
   601                 if ( HandleTimerL( aInput, aResult ) )
       
   602                     {
       
   603                     result = HandleNoParametersL( aInput, aResult );
       
   604                     }
       
   605                 else
       
   606                     {
       
   607                     result = HandleNoParametersL( aInput, aResult );
       
   608                     aResult.AddParameterL( KNullDesC );
       
   609                     }
       
   610                 }
       
   611             else if ( HandleEmptyParameterL( aInput, aResult ) )
       
   612                 {
       
   613                 result = HandleTimerL( aInput, aResult );
       
   614                 result = result && 
       
   615                          HandleNoParametersL( aInput, aResult );
       
   616                 }
       
   617             }
       
   618         }
       
   619 
       
   620     return result;
       
   621     }
       
   622 
       
   623 // -----------------------------------------------------------------------------
       
   624 // CPhoneGsmSsParser::HandleNumberOptBasicCodeL
       
   625 // -----------------------------------------------------------------------------
       
   626 //
       
   627 TBool CPhoneGsmSsParser::HandleNumberOptBasicCodeL(
       
   628         TLex& aInput,
       
   629         CPhoneGsmParserResult& aResult )
       
   630     {
       
   631     TBool result = EFalse;
       
   632     
       
   633     if ( HandleNumberL( aInput, aResult ) )
       
   634         {
       
   635         if ( HandleNoParametersL( aInput, aResult ) )
       
   636             {
       
   637             aResult.AddParameterL( KNullDesC );
       
   638             result = ETrue;
       
   639             }
       
   640         else
       
   641             {
       
   642             result = HandleBasicCodeL( aInput, aResult );
       
   643             result = result && HandleNoParametersL( aInput, aResult );
       
   644             }
       
   645         }
       
   646 
       
   647     return result;
       
   648     }
       
   649 
       
   650 // -----------------------------------------------------------------------------
       
   651 // CPhoneGsmSsParser::HandlePasswordOptBasicCodeL
       
   652 // -----------------------------------------------------------------------------
       
   653 //
       
   654 TBool CPhoneGsmSsParser::HandlePasswordOptBasicCodeL(
       
   655         TLex& aInput,
       
   656         CPhoneGsmParserResult& aResult )
       
   657     {
       
   658     TBool result = EFalse;
       
   659 
       
   660     if ( HandlePasswordL( aInput, aResult ) )
       
   661         {
       
   662         if ( HandleNoParametersL( aInput, aResult ) )
       
   663             {
       
   664             aResult.AddParameterL( KNullDesC );
       
   665             result = ETrue;
       
   666             }
       
   667         else
       
   668             {
       
   669             result = HandleBasicCodeL( aInput, aResult );
       
   670             result = result && HandleNoParametersL( aInput, aResult );
       
   671             }
       
   672         }
       
   673 
       
   674     return result;
       
   675     }
       
   676 
       
   677 // -----------------------------------------------------------------------------
       
   678 // CPhoneGsmSsParser::
       
   679 // HandleOptGroupCodePasswordNewPasswordNewPasswordL
       
   680 // -----------------------------------------------------------------------------
       
   681 //
       
   682 TBool CPhoneGsmSsParser::
       
   683     HandleOptGroupCodePasswordNewPasswordNewPasswordL(
       
   684         TLex& aInput,
       
   685         CPhoneGsmParserResult& aResult )
       
   686     {
       
   687     TBool result = HandleGroupCodeL( aInput, aResult );
       
   688 
       
   689     if ( !result )
       
   690         {
       
   691         result = HandleEmptyParameterL( aInput, aResult );
       
   692         }
       
   693 
       
   694     result = result && HandlePasswordL( aInput, aResult );
       
   695     result = result && HandlePasswordL( aInput, aResult );
       
   696     result = result && HandlePasswordL( aInput, aResult );
       
   697     result = result && HandleNoParametersL( aInput, aResult );
       
   698 
       
   699     return result;
       
   700     }
       
   701 
       
   702 // -----------------------------------------------------------------------------
       
   703 // CPhoneGsmSsParser::HandleEmptyOrBasicCode2L
       
   704 // -----------------------------------------------------------------------------
       
   705 //
       
   706 TBool CPhoneGsmSsParser::HandleEmptyOrBasicCode2L(
       
   707         TLex& aInput,
       
   708         CPhoneGsmParserResult& aResult )
       
   709     {
       
   710     TBool result = HandleNoParametersL( aInput, aResult );
       
   711 
       
   712     if ( result )
       
   713         {
       
   714         aResult.AddParameterL( KNullDesC );
       
   715         }
       
   716     else
       
   717         {
       
   718         result = HandleBasicCodeL( aInput, aResult );
       
   719         result = result && HandleNoParametersL( aInput, aResult );
       
   720         }
       
   721     
       
   722     return result;
       
   723     }
       
   724 
       
   725 // -----------------------------------------------------------------------------
       
   726 // CPhoneGsmSsParser::HandleEmptyParameterL
       
   727 //
       
   728 // Handle empty parameter, two consecutive asterisks.
       
   729 // -----------------------------------------------------------------------------
       
   730 //
       
   731 TBool CPhoneGsmSsParser::HandleEmptyParameterL( 
       
   732         TLex& aInput,
       
   733         CPhoneGsmParserResult& aResult )
       
   734     {
       
   735     TBool result = EFalse;
       
   736     aInput.Mark();
       
   737 
       
   738     if ( aInput.Peek() == KPhoneSsAsterisk )
       
   739         {
       
   740         aInput.Inc();
       
   741 
       
   742         result = ( aInput.Peek() == KPhoneSsAsterisk );
       
   743         
       
   744         if ( result )
       
   745             {
       
   746             aResult.AddParameterL( KNullDesC );
       
   747             }
       
   748         }
       
   749 
       
   750     if ( !result )
       
   751         {
       
   752         aInput.UnGetToMark();
       
   753         }
       
   754 
       
   755     return result;
       
   756     }
       
   757 
       
   758 // -----------------------------------------------------------------------------
       
   759 // CPhoneGsmSsParser::HandleBasicCodeL
       
   760 //
       
   761 // Basically, basic service code is a two digit string.
       
   762 // In this method, only explicit
       
   763 // values are handled (parameter might be empty).
       
   764 //
       
   765 // The method checks that the first character is * and then
       
   766 // it is followed by two digits. And there must not be more
       
   767 // than two digits.
       
   768 // -----------------------------------------------------------------------------
       
   769 //
       
   770 TBool CPhoneGsmSsParser::HandleBasicCodeL( 
       
   771         TLex& aInput,
       
   772         CPhoneGsmParserResult& aResult )
       
   773     {   
       
   774     TBool result = EFalse;
       
   775     TLexMark start;
       
   776 
       
   777     aInput.Mark( start );
       
   778 
       
   779     if ( aInput.Peek() == KPhoneSsAsterisk )
       
   780         {
       
   781         aInput.Inc();
       
   782     
       
   783         TLexMark mark;
       
   784         aInput.Mark( mark );
       
   785         
       
   786         if ( aInput.Peek().IsDigit() )
       
   787             {
       
   788             aInput.Inc();
       
   789 
       
   790             if ( aInput.Peek().IsDigit() )
       
   791                 {
       
   792                 aInput.Inc();
       
   793 
       
   794                 if ( !aInput.Peek().IsDigit() )
       
   795                     {
       
   796                     TPtrC code = aInput.MarkedToken( mark );
       
   797 
       
   798                     result = CheckBasicCode( code );
       
   799 
       
   800                     if ( result )
       
   801                         {
       
   802                         aResult.AddParameterL( code );
       
   803                         }
       
   804                     }
       
   805                 }
       
   806             }
       
   807 
       
   808         // Check empty parameters.
       
   809         if ( !result )
       
   810             {
       
   811             aInput.UnGetToMark( mark );
       
   812             
       
   813             if ( aInput.Remainder() == KPhoneSsEnd )
       
   814                 {
       
   815                 aResult.AddParameterL( KNullDesC );
       
   816                 result = ETrue;
       
   817                 }
       
   818             }
       
   819         }
       
   820 
       
   821     if ( !result )
       
   822         {
       
   823         aInput.UnGetToMark( start );
       
   824         }
       
   825 
       
   826     return result;
       
   827     }
       
   828 
       
   829 // -----------------------------------------------------------------------------
       
   830 // CPhoneGsmSsParser::HandleNumberL
       
   831 //
       
   832 // Directory number as a parameter must be present. It can
       
   833 // contain at most 38 digits. Digits and '+' characters
       
   834 // are allowed, but '+' character is allowed to be only in the 
       
   835 // beginning of the string.
       
   836 // -----------------------------------------------------------------------------
       
   837 //
       
   838 TBool CPhoneGsmSsParser::HandleNumberL( 
       
   839         TLex& aInput,
       
   840         CPhoneGsmParserResult& aResult )
       
   841     {
       
   842     if ( aInput.Remainder().Length() < KPhoneSsRemainderMinLength )
       
   843         {
       
   844         return EFalse;
       
   845         }
       
   846 
       
   847     TInt maxLength = KPhoneSsDirectoryNumberMaxLength;
       
   848     TBool result = EFalse;
       
   849     TLexMark start;
       
   850 
       
   851     aInput.Mark( start );
       
   852 
       
   853     if ( aInput.Peek() == KPhoneSsAsterisk )
       
   854         {
       
   855         aInput.Inc();
       
   856        
       
   857         TLexMark mark;
       
   858         aInput.Mark( mark );
       
   859 
       
   860         if ( aInput.Peek() == KPhoneSsPlus )
       
   861             {
       
   862             aInput.Inc();
       
   863             maxLength++;
       
   864             }
       
   865 
       
   866         while ( aInput.Peek().IsDigit() )
       
   867             {
       
   868             aInput.Inc();
       
   869             }
       
   870 
       
   871         TPtrC number = aInput.MarkedToken( mark );
       
   872         if ( number.Length() <= maxLength )
       
   873             {  
       
   874             aResult.AddParameterL( number );
       
   875             result = ETrue;
       
   876             }
       
   877         }
       
   878 
       
   879     if ( !result )
       
   880         {
       
   881         aInput.UnGetToMark( start );
       
   882         }
       
   883 
       
   884     return result;
       
   885     }
       
   886 
       
   887 // -----------------------------------------------------------------------------
       
   888 // CPhoneGsmSsParser::HandleTimerL
       
   889 //
       
   890 // The method checks if the next part is 'no reply timer'.
       
   891 // It is at most two digits. Value is expected to be present.
       
   892 // Value is checked in CheckTimer method.
       
   893 //
       
   894 // (if value is not present, then it is handled in calling
       
   895 //  method)
       
   896 // -----------------------------------------------------------------------------
       
   897 //
       
   898 TBool CPhoneGsmSsParser::HandleTimerL( 
       
   899         TLex& aInput,
       
   900         CPhoneGsmParserResult& aResult )
       
   901     {
       
   902     TBool result = EFalse;
       
   903     TLexMark start;
       
   904     aInput.Mark( start );
       
   905 
       
   906     if ( aInput.Peek() == KPhoneSsAsterisk )
       
   907         {
       
   908         aInput.Inc();
       
   909 
       
   910         TLexMark mark;
       
   911         aInput.Mark( mark );
       
   912         
       
   913         while ( aInput.Peek().IsDigit() )
       
   914             {
       
   915             aInput.Inc();
       
   916             }
       
   917         
       
   918         TPtrC timer( aInput.MarkedToken( mark ) );
       
   919         
       
   920         if ( CheckTimer( timer ) )
       
   921             {
       
   922             aResult.AddParameterL( timer );
       
   923             result = ETrue;
       
   924             }
       
   925 
       
   926         // Check empty parameters.
       
   927         if ( !result )
       
   928             {
       
   929             aInput.UnGetToMark( mark );
       
   930             
       
   931             if ( aInput.Remainder() == KPhoneSsEnd )
       
   932                 {
       
   933                 aResult.AddParameterL( KNullDesC );
       
   934                 result = ETrue;
       
   935                 }
       
   936             }
       
   937         }
       
   938 
       
   939     if ( !result )
       
   940         {
       
   941         aInput.UnGetToMark( start );
       
   942         }
       
   943 
       
   944     return result;
       
   945     }
       
   946 
       
   947 // -----------------------------------------------------------------------------
       
   948 // CPhoneGsmSsParser::HandlePasswordL
       
   949 //
       
   950 // Password is four digit string.
       
   951 // -----------------------------------------------------------------------------
       
   952 //
       
   953 TBool CPhoneGsmSsParser::HandlePasswordL( 
       
   954         TLex& aInput,
       
   955         CPhoneGsmParserResult& aResult )
       
   956     {
       
   957     if ( aInput.Remainder().Length() <
       
   958          KPhoneSsRemainderPasswordMinLength )
       
   959         {
       
   960         return EFalse;
       
   961         }
       
   962 
       
   963     TBool result = EFalse;
       
   964     TLexMark start;
       
   965     aInput.Mark( start );
       
   966 
       
   967     if ( aInput.Peek() == KPhoneSsAsterisk )
       
   968         {
       
   969         aInput.Inc();
       
   970 
       
   971         TLexMark mark;
       
   972         aInput.Mark( mark );
       
   973 
       
   974         while( aInput.Peek().IsDigit() )
       
   975             {
       
   976             aInput.Inc();
       
   977             }
       
   978 
       
   979         TPtrC password( aInput.MarkedToken( mark ) );
       
   980         
       
   981         if ( password.Length() == KPhoneSsPasswordLength )
       
   982             {
       
   983             aResult.AddParameterL( password );
       
   984             result = ETrue;
       
   985             }
       
   986         }
       
   987 
       
   988     if ( !result )
       
   989         {
       
   990         aInput.UnGetToMark( start );
       
   991         }
       
   992 
       
   993     return result;
       
   994     }
       
   995 
       
   996 // -----------------------------------------------------------------------------
       
   997 // CPhoneGsmSsParser::HandleGroupCodeL
       
   998 //
       
   999 // The method handles password group codes. However, code 
       
  1000 // must be one to four digits. 
       
  1001 //
       
  1002 // (if group code is null, then it is handled in calling
       
  1003 //  method)
       
  1004 // -----------------------------------------------------------------------------
       
  1005 //
       
  1006 TBool CPhoneGsmSsParser::HandleGroupCodeL( 
       
  1007         TLex& aInput,
       
  1008         CPhoneGsmParserResult& aResult )
       
  1009     {
       
  1010     if ( aInput.Remainder().Length() <= KPhoneSsRemainderMinLength )
       
  1011         {
       
  1012         return EFalse;
       
  1013         }
       
  1014 
       
  1015     TBool result = EFalse; 
       
  1016     TLexMark start;
       
  1017 
       
  1018     aInput.Mark( start );
       
  1019 
       
  1020     if ( aInput.Peek() == KPhoneSsAsterisk )
       
  1021         {
       
  1022         aInput.Inc();
       
  1023         
       
  1024         TLexMark mark;
       
  1025         aInput.Mark( mark );
       
  1026 
       
  1027         while ( aInput.Peek().IsDigit() )
       
  1028             {
       
  1029             aInput.Inc();
       
  1030             }
       
  1031 
       
  1032         TPtrC groupCode( aInput.MarkedToken( mark ) );
       
  1033 
       
  1034         if ( CheckGroupCode( groupCode ) )
       
  1035             {
       
  1036             aResult.AddParameterL( groupCode );
       
  1037             result = ETrue;
       
  1038             }
       
  1039         }
       
  1040 
       
  1041     if ( !result )
       
  1042         {
       
  1043         aInput.UnGetToMark( start );
       
  1044         }
       
  1045 
       
  1046     return result;
       
  1047     }
       
  1048 
       
  1049 // -----------------------------------------------------------------------------
       
  1050 // CPhoneGsmSsParser::CheckBasicCode
       
  1051 //
       
  1052 // Check that basic code is appropriate
       
  1053 // -----------------------------------------------------------------------------
       
  1054 //
       
  1055 TBool CPhoneGsmSsParser::CheckBasicCode( const TDesC& aCode )
       
  1056     {
       
  1057     TLex lex( aCode );
       
  1058     TUint value;
       
  1059     
       
  1060     if ( aCode.Length() <= KPhoneSsBasicCodeMaxLength )
       
  1061         {
       
  1062         if ( lex.Val( value, EDecimal ) != KErrNone )
       
  1063             {
       
  1064             return EFalse;
       
  1065             }
       
  1066         }
       
  1067     else
       
  1068         {
       
  1069         return EFalse;
       
  1070         }
       
  1071 
       
  1072     TBool result = EFalse;
       
  1073   
       
  1074     switch ( value )
       
  1075         {
       
  1076         // TELESERVICES
       
  1077         case EAllTele:          // GSM: All tele and bearer services
       
  1078         case ETelephony:        // GSM: Teleservices
       
  1079         case EAllDataTele:      // GSM: All data teleservices
       
  1080         case EFax:              // GSM: Facsimile services
       
  1081         case ESms:              // GSM: Short message services
       
  1082         case EAllTeleExcSms:    // GSM: All teleservices except SMS
       
  1083         case EAltTele:          // PCN: Alternate line service
       
  1084 
       
  1085         // BEARER SERVICES
       
  1086         case EAllBearer:        // GSM: All bearer services
       
  1087         case EAllAsync:         // GSM: All async services
       
  1088         case EAllSync:          // GSM: All sync services
       
  1089         case ESyncData:         // GSM: All data circuit sync
       
  1090         case EAsyncData:        // GSM: All data circuit async
       
  1091         case EPacketData:       // GSM: All dedicated packet access
       
  1092         case EPadAccess:        // GSM: All dedicated PAD access
       
  1093 
       
  1094             result = ETrue;
       
  1095             break;
       
  1096 
       
  1097         // PLMN specific teleservices and bearer services
       
  1098         default:
       
  1099             
       
  1100             // GSM: PLMN specific teleservices
       
  1101             if ( value >= EAllPlmnTele && value <= EPlmnTeleF )
       
  1102                 {
       
  1103                 result = ETrue;
       
  1104                 }
       
  1105             // GSM: PLMN specific bearer services
       
  1106             else if ( value >= EAllPlmnBearer && value <= EPlmnBearerServF )
       
  1107                 {
       
  1108                 result = ETrue;
       
  1109                 }
       
  1110 
       
  1111             // Otherwise, result == EFalse and it's OK.
       
  1112             break;
       
  1113         }
       
  1114     
       
  1115     return result;
       
  1116     }
       
  1117 
       
  1118 // -----------------------------------------------------------------------------
       
  1119 // CPhoneGsmSsParser::CheckTimer
       
  1120 //
       
  1121 // Check if timer value is ok.
       
  1122 // -----------------------------------------------------------------------------
       
  1123 //
       
  1124 TBool CPhoneGsmSsParser::CheckTimer( const TDesC& aCode )
       
  1125     {
       
  1126     TLex lex( aCode );
       
  1127     TUint value;
       
  1128     
       
  1129     if ( aCode.Length() <= KPhoneSsTimerMaxLength )
       
  1130         {
       
  1131         if ( lex.Val( value, EDecimal ) != KErrNone )
       
  1132             {
       
  1133             return EFalse;
       
  1134             }
       
  1135         }
       
  1136     else 
       
  1137         {
       
  1138         return EFalse;
       
  1139         }
       
  1140 
       
  1141     TBool result = EFalse;
       
  1142 
       
  1143     switch ( value )
       
  1144         {
       
  1145         case 5:
       
  1146         case 10:
       
  1147         case 15:
       
  1148         case 20:
       
  1149         case 25:
       
  1150         case 30:
       
  1151             result = ETrue;
       
  1152             break;
       
  1153 
       
  1154         default:
       
  1155             break;
       
  1156         }
       
  1157 
       
  1158     return result;
       
  1159     }
       
  1160 
       
  1161 // -----------------------------------------------------------------------------
       
  1162 // CPhoneGsmSsParser::CheckGroupCode
       
  1163 //
       
  1164 // Check if group code is ok.
       
  1165 // -----------------------------------------------------------------------------
       
  1166 //
       
  1167 TBool CPhoneGsmSsParser::CheckGroupCode( const TDesC& aCode )
       
  1168     {
       
  1169     TLex lex( aCode );
       
  1170     TUint value;
       
  1171     TBool result = EFalse;
       
  1172 
       
  1173     if ( aCode.Length() <= KPhoneSsGroupCodeMaxLength )
       
  1174         {
       
  1175         if ( lex.Val( value, EDecimal ) == KErrNone )
       
  1176             {
       
  1177             result = ( value == KPhoneSsOnlyAllowedGroupCode );
       
  1178             }
       
  1179         }
       
  1180 
       
  1181     return result;
       
  1182     }
       
  1183 
       
  1184 // -----------------------------------------------------------------------------
       
  1185 // CPhoneGsmSsParser::FindString
       
  1186 // -----------------------------------------------------------------------------
       
  1187 //
       
  1188 TPtrC CPhoneGsmSsParser::FindString( 
       
  1189         TLex& aInput,
       
  1190         const TDesC& aAllowedCharacters )
       
  1191     {
       
  1192     TLexMark mark;
       
  1193     aInput.Mark( mark );
       
  1194 
       
  1195     // Return string containing characters that appear in 
       
  1196     // aAllowedCharacters.
       
  1197     while ( aAllowedCharacters.Locate( aInput.Peek() ) != 
       
  1198             KErrNotFound )
       
  1199         {
       
  1200         aInput.Inc();
       
  1201         }
       
  1202     
       
  1203     return aInput.MarkedToken( mark );
       
  1204     }
       
  1205 
       
  1206 // -----------------------------------------------------------------------------
       
  1207 // CPhoneGsmSsParser::AddL
       
  1208 //
       
  1209 // Parse service description and add it.
       
  1210 //
       
  1211 // -----------------------------------------------------------------------------
       
  1212 //
       
  1213 void CPhoneGsmSsParser::AddL( 
       
  1214         const TDesC& aService, 
       
  1215         TUint aUid )
       
  1216     {
       
  1217     // There must be six positive integers in aService.   
       
  1218     TLex input( aService );
       
  1219 
       
  1220     // First number is service code.
       
  1221     TPtrC serviceCode( NextNumber( input ) );
       
  1222 
       
  1223     // And then next five are syntax descriptions.
       
  1224     TServiceSyntax activation = 
       
  1225         ConvertToServiceSyntax( NextNumberAsValue( input ) );
       
  1226     TServiceSyntax deactivation = 
       
  1227         ConvertToServiceSyntax( NextNumberAsValue( input ) );
       
  1228     TServiceSyntax interrogation = 
       
  1229         ConvertToServiceSyntax( NextNumberAsValue( input ) );
       
  1230     TServiceSyntax registration = 
       
  1231         ConvertToServiceSyntax( NextNumberAsValue( input ) );
       
  1232     TServiceSyntax erasure = 
       
  1233         ConvertToServiceSyntax( NextNumberAsValue( input ) );
       
  1234    
       
  1235     // Add to array.
       
  1236     AddServiceL( 
       
  1237         serviceCode,
       
  1238         activation,
       
  1239         deactivation,
       
  1240         interrogation,
       
  1241         registration,
       
  1242         erasure,
       
  1243         aUid );
       
  1244     }
       
  1245 
       
  1246 // -----------------------------------------------------------------------------
       
  1247 // CPhoneGsmSsParser::AddServiceL
       
  1248 // -----------------------------------------------------------------------------
       
  1249 //
       
  1250 void CPhoneGsmSsParser::AddServiceL( 
       
  1251         const TDesC& aServiceCode,
       
  1252         TServiceSyntax aActivation,
       
  1253         TServiceSyntax aDeactivation,
       
  1254         TServiceSyntax aInterrogation,
       
  1255         TServiceSyntax aRegistration,
       
  1256         TServiceSyntax aErasure,
       
  1257         TUint aUid )
       
  1258     {   
       
  1259     TServiceInfo info;
       
  1260 
       
  1261     // Fill information to info structure.
       
  1262     info.iCode = aServiceCode;
       
  1263     info.iActivation = aActivation;
       
  1264     info.iDeactivation = aDeactivation;
       
  1265     info.iInterrogation = aInterrogation;
       
  1266     info.iRegistration = aRegistration;
       
  1267     info.iErasure = aErasure;
       
  1268     info.iUid = aUid;
       
  1269 
       
  1270     TKeyArrayFix key( _FOFF( TServiceInfo, iCode ), ECmpNormal );
       
  1271 
       
  1272     // Add it to the array.
       
  1273     TRAPD( err, iArray->InsertIsqL( info, key ) ); 
       
  1274 
       
  1275     if ( err != KErrNone && err != KErrNoMemory )
       
  1276         {
       
  1277         PhoneGsmParser::Panic( 
       
  1278             PhoneGsmParser::EIncorrectServiceDescription );
       
  1279         }
       
  1280 
       
  1281     // Just leave if no memory.
       
  1282     if ( err == KErrNoMemory )
       
  1283         {
       
  1284         User::Leave( err );
       
  1285         }
       
  1286     }
       
  1287 
       
  1288 // -----------------------------------------------------------------------------
       
  1289 // CPhoneGsmSsParser::NextNumber
       
  1290 //
       
  1291 // Skip spaces and then get next number.
       
  1292 // -----------------------------------------------------------------------------
       
  1293 //
       
  1294 TPtrC CPhoneGsmSsParser::NextNumber( 
       
  1295         TLex& aLex )
       
  1296     {
       
  1297     // Skip whites.
       
  1298     aLex.SkipSpace();
       
  1299 
       
  1300     // Go over digits.
       
  1301     aLex.Mark();
       
  1302     while ( aLex.Peek().IsDigit() )
       
  1303         {
       
  1304         aLex.Inc();
       
  1305         }
       
  1306 
       
  1307     // Check if we got proper number.
       
  1308     if ( !aLex.TokenLength() )
       
  1309         {
       
  1310         PhoneGsmParser::Panic( 
       
  1311             PhoneGsmParser::EIncorrectServiceDescription );
       
  1312         }
       
  1313     
       
  1314     return aLex.MarkedToken();       
       
  1315     }
       
  1316 
       
  1317 // -----------------------------------------------------------------------------
       
  1318 // CPhoneGsmSsParser::NextNumberAsValue
       
  1319 //
       
  1320 // Get number and convert it to value.
       
  1321 // -----------------------------------------------------------------------------
       
  1322 //
       
  1323 TUint CPhoneGsmSsParser::NextNumberAsValue( 
       
  1324         TLex& aLex )
       
  1325     {
       
  1326     // Get number.
       
  1327     TPtrC number( NextNumber( aLex ) );
       
  1328     TLex input( number );
       
  1329     TUint value;
       
  1330 
       
  1331     // Parse number.
       
  1332     if ( input.Val( value, EDecimal ) != KErrNone )
       
  1333         {
       
  1334         PhoneGsmParser::Panic( 
       
  1335             PhoneGsmParser::EIncorrectServiceDescription );
       
  1336         }
       
  1337 
       
  1338     return value;
       
  1339     }
       
  1340 
       
  1341 // -----------------------------------------------------------------------------
       
  1342 // CPhoneGsmSsParser::ConvertToServiceSyntax
       
  1343 //
       
  1344 // Convert value to a service syntax enumeration.
       
  1345 // -----------------------------------------------------------------------------
       
  1346 //
       
  1347 CPhoneGsmSsParser::TServiceSyntax 
       
  1348     CPhoneGsmSsParser::ConvertToServiceSyntax( 
       
  1349         TUint aService )
       
  1350     {
       
  1351     TServiceSyntax service = ESyntaxNotAllowed;
       
  1352 
       
  1353     switch ( aService )
       
  1354         {
       
  1355         case 0:
       
  1356             service = ESyntaxNotAllowed;        
       
  1357             break;
       
  1358         case 1:
       
  1359             service = ESyntaxNoParameters;
       
  1360             break;
       
  1361         case 2:
       
  1362             service = ESyntaxEmptyOrBasicCode;
       
  1363             break;
       
  1364         case 3:
       
  1365             service = ESyntaxNumberOptBasicCodeOptTimer;
       
  1366             break;
       
  1367         case 4:
       
  1368             service = ESyntaxNumberOptBasicCode;
       
  1369             break;
       
  1370         case 5:
       
  1371             service = ESyntaxPasswordOptBasicCode;
       
  1372             break;
       
  1373         case 6:
       
  1374             service = ESyntaxOptGroupCodePasswordNewPasswordNewPassword;
       
  1375             break;
       
  1376         case 7:
       
  1377             service = ESyntaxEmptyOrBasicCode2;
       
  1378             break;
       
  1379         default:
       
  1380             PhoneGsmParser::Panic( 
       
  1381                 PhoneGsmParser::EIncorrectServiceDescription );       
       
  1382         }
       
  1383 
       
  1384     return service;
       
  1385     }
       
  1386 
       
  1387 //  End of File