cellular/telephonysettings/src/PsetCallBarring.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Call barring class. Sets and gets call barring setting.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  Include Files
       
    21 #include <etelmm.h>
       
    22 #include <rsssettings.h> 
       
    23 #include "mpsetrequestobs.h" 
       
    24 #include "psetcallbarring.h" 
       
    25 #include "psettelephony.h" 
       
    26 #include "psetpanic.h" 
       
    27 #include "psetconstants.h" 
       
    28 #include "psetutility.h" 
       
    29 #include "phonesettingslogger.h" 
       
    30 
       
    31 // CONSTANTS    
       
    32 _LIT( KPSNameOfClass, "CPsetCallBarring" );
       
    33 
       
    34 //  MEMBER FUNCTIONS
       
    35 //=============================================================================
       
    36 // ---------------------------------------------------------------------------
       
    37 // 
       
    38 // 1st phase constructor.
       
    39 // 
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CPsetCallBarring* CPsetCallBarring::NewL( MPsetBarringObserver& aObserver, 
       
    43                   RMobilePhone& aPhone ) 
       
    44     {
       
    45     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::NewL");
       
    46     CPsetCallBarring* self = new( ELeave ) CPsetCallBarring( aPhone );
       
    47 
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL( aObserver );
       
    50     CleanupStack::Pop();
       
    51 
       
    52     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::NewL");
       
    53     return self;
       
    54     }
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // 
       
    58 // 2nd phase constructor.
       
    59 // 
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void CPsetCallBarring::ConstructL( MPsetBarringObserver& aObserver )
       
    63     {
       
    64     /*****************************************************
       
    65     *    Series 60 Customer / ETel
       
    66     *    Series 60  ETel API
       
    67     *****************************************************/
       
    68     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::ConstructL");
       
    69     iLine = new ( ELeave ) RMobileLine;
       
    70     this->SetObserver( aObserver );
       
    71     CActiveScheduler::Add( this );
       
    72     
       
    73     //Check which line is used, or if ALS is not active.
       
    74     TInt usedLine = ESSSettingsAlsNotSupported;
       
    75 
       
    76     iSsSettings = new (ELeave) RSSSettings;
       
    77     User::LeaveIfError( iSsSettings->Open() );
       
    78     TRAPD( err, iSsSettings->Register( ESSSettingsAls, *this ) );
       
    79     if ( err == KErrNone )
       
    80         {
       
    81         iSsSettings->Get( ESSSettingsAls, usedLine );
       
    82         }
       
    83 
       
    84     iAls = static_cast <TSSSettingsAlsValue> ( usedLine );
       
    85     
       
    86     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::ConstructL");
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Destructor.
       
    91 // Closes line subsession.
       
    92 // 
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C CPsetCallBarring::~CPsetCallBarring()
       
    96     {
       
    97     Cancel();
       
    98     if ( iLine )
       
    99         {
       
   100         iLine->Close();    
       
   101         }
       
   102     delete iLine;
       
   103     
       
   104     if ( iSsSettings )
       
   105         {
       
   106         iSsSettings->Cancel( ESSSettingsAls, *this ); 
       
   107         iSsSettings->Close();
       
   108         }
       
   109     delete iSsSettings;
       
   110     
       
   111     iReqObserver = NULL;
       
   112         
       
   113     delete iCbStatusInterrogator;
       
   114     iCbStatusInterrogator = NULL;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // 
       
   119 // If SsSettings notifies of settings change, copy new value to member variable.
       
   120 // 
       
   121 // ---------------------------------------------------------------------------
       
   122 void CPsetCallBarring::PhoneSettingChanged( 
       
   123     TSSSettingsSetting aSetting, TInt aNewValue )
       
   124     {
       
   125     if ( aSetting == ESSSettingsAls )
       
   126         {
       
   127         iAls = static_cast <TSSSettingsAlsValue> (aNewValue);
       
   128         }
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------------------------
       
   132 // 
       
   133 // Validates used bsc, if EUnknown, updates to real value
       
   134 // 
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CPsetCallBarring::ValidateBsc( TBasicServiceGroups& aBsc )
       
   138     {
       
   139     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::ValidateBsc" );
       
   140     if ( aBsc == EUnknown )
       
   141     // if bsc is unknown, update it
       
   142         {
       
   143         if ( iAls == ESSSettingsAlsAlternate )
       
   144             {
       
   145             aBsc = EAltTele;
       
   146             }
       
   147         else
       
   148             {
       
   149             aBsc = ETelephony;
       
   150             }
       
   151         }    
       
   152     else
       
   153     // If no specific line is indicated
       
   154         {
       
   155         if ( aBsc == EAllTeleAndBearer || aBsc == EAllTele )
       
   156             {
       
   157             // if ALS is used, use 89 bsc
       
   158             if ( iAls == ESSSettingsAlsAlternate )
       
   159                 {
       
   160                 aBsc = EAltTele;
       
   161                 }
       
   162             }
       
   163         }
       
   164     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::ValidateBsc" );
       
   165     }
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // 
       
   169 // Sets barring setting on network.
       
   170 // 
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 EXPORT_C void CPsetCallBarring::SetBarringL( 
       
   174     const TCallBarringSetting& aBarring, TBasicServiceGroups aBsc )
       
   175     {
       
   176     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::SetBarringL");
       
   177     if ( IsActive() )
       
   178         {
       
   179         User::Leave( KErrInUse );
       
   180         }
       
   181 
       
   182     __PHSLOGSTRING1("[PHS]    SetBarringL: Barring Group: %d", aBarring.iServiceGroup);
       
   183     //Opens the correct basic service group->contradicting custom tsy.
       
   184     CPsetTelephony::CheckLineModeL( aBarring.iServiceGroup, &iPhone, iLine );
       
   185 
       
   186     // Copy received information to member and local variables.
       
   187     // Note if alternate line selected then iServiceGroup changes in iBarringParameters 
       
   188     // and iChangeSetting iSericeGroup has old information.
       
   189     iChangeSetting = aBarring;
       
   190 
       
   191     __PHSLOGSTRING1("[PHS]    SetBarringL: Password: %S", &aBarring.iPassword);
       
   192     __PHSLOGSTRING1("[PHS]    SetBarringL: Settings: %d", aBarring.iSetting);
       
   193 
       
   194     ValidateBsc( aBsc );
       
   195     
       
   196     if ( aBsc == EAltTele )
       
   197         {
       
   198         iBarringParameters.iServiceGroup = PSetUtility::VerifyAltLineUseL();
       
   199         }
       
   200                 
       
   201     iBarringParameters.iPassword = aBarring.iPassword;
       
   202     iBarringParameters.iAction = SetBarringAction( aBarring.iSetting );
       
   203     iBarringParameters.iServiceGroup = PSetUtility::ChangeToEtelInternal( aBsc );
       
   204         
       
   205     __PHSLOGSTRING1("[PHS]    SetBarringL: Program: %d", aBarring.iType);
       
   206 
       
   207     // Start to request barring change.
       
   208     iPhone.SetCallBarringStatus( 
       
   209         iStatus, 
       
   210         SetBarringProgram( aBarring.iType ), 
       
   211         iBarringParameters );
       
   212 
       
   213     StartRequestingL( EPSetRequestChangeBarring );
       
   214     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::SetBarringL");
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // 
       
   219 // Gets barring status from network. 
       
   220 // 
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C void CPsetCallBarring::GetBarringStatusL( const TServiceGroup aGroup, 
       
   224     const TBarringProgram aMode )
       
   225     {
       
   226     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::GetBarringStatusL");
       
   227     if ( IsActive() )
       
   228         {
       
   229         User::Leave( KErrInUse );
       
   230         }
       
   231 
       
   232     __PHSLOGSTRING1("[PHS]    GetBarringStatusL: Barring Group: %d", aGroup);
       
   233     __PHSLOGSTRING1("[PHS]    GetBarringStatusL: Program: %d", aMode);
       
   234 
       
   235     CPsetTelephony::CheckLineModeL( aGroup, &iPhone, iLine );
       
   236 
       
   237     // Start to request for barring status.
       
   238     iCbStatusInterrogator = CRetrieveMobilePhoneCBList::NewL( iPhone );
       
   239     iCbStatusInterrogator->Start( iStatus, SetBarringProgram( aMode ) );
       
   240 
       
   241     StartRequestingL( EPSetRequestGetStatus );
       
   242     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::GetBarringStatusL");
       
   243     }
       
   244 
       
   245 // ---------------------------------------------------------------------------
       
   246 // 
       
   247 // Cancels current request pending on requester. Return Values: TInt error code 
       
   248 // 
       
   249 // ---------------------------------------------------------------------------
       
   250 //
       
   251 EXPORT_C TInt CPsetCallBarring::CancelCurrentRequest()
       
   252     {
       
   253     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::CancelCurrentRequest");
       
   254     // Set PSUI so that correct observer is used and hide requesting note.
       
   255     // When interrupting a note, does *not leave*.
       
   256     // This needs to be done first, since notes must be cleared from screen
       
   257     // even though request is not active.
       
   258     iObserver->SetEngineContact( this );
       
   259     // Does not leave
       
   260     TRAPD( err, iObserver->HandleCBRequestingL( EFalse, ETrue ) );
       
   261         
       
   262     if ( !IsActive() || err != KErrNone )
       
   263         {
       
   264         return KErrGeneral;
       
   265         }
       
   266     
       
   267     // Request has been already sent to network before this cancel method 
       
   268     // will be called. Calling DoCancel in this phase causes that e.g. "Barring 
       
   269     // activated" note is not shown to user even barring has been set active. 
       
   270     // Cancel can be done only to EPSetRequestGetStatus. It does not cause
       
   271     // any harm if status is not shown to user when quit is pressed. 
       
   272     if ( iCurrentReq == EPSetRequestGetStatus )
       
   273         {
       
   274         Cancel();
       
   275         }
       
   276     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::CancelCurrentRequest");
       
   277 
       
   278     return KErrNone;
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // 
       
   283 // C++ constructor.
       
   284 // 
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 CPsetCallBarring::CPsetCallBarring
       
   288                 ( RMobilePhone& aPhone ) : CActive( EPriorityStandard ),
       
   289                                            iPhone ( aPhone )
       
   290     {
       
   291     }
       
   292 
       
   293 // ---------------------------------------------------------------------------
       
   294 // 
       
   295 // Returns correct type of barring program.
       
   296 // 
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 RMobilePhone::TMobilePhoneCBCondition CPsetCallBarring::SetBarringProgram( 
       
   300     TBarringProgram aMode )
       
   301     {
       
   302     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::SetBarringProgram");
       
   303     __PHSLOGSTRING1("[PHS]    SetBarringProgram: Program: %d", aMode);
       
   304     /*****************************************************
       
   305     *    Series 60 Customer / ETel
       
   306     *    Series 60  ETel API
       
   307     *****************************************************/
       
   308     RMobilePhone::TMobilePhoneCBCondition barringType = 
       
   309         RMobilePhone::EBarUnspecified;
       
   310     switch ( aMode )
       
   311         {
       
   312         case EBarringTypeAllOutgoingServices:
       
   313             barringType = RMobilePhone::EBarAllOutgoingServices;
       
   314             break;
       
   315         case EBarringTypeAllIncomingServices:
       
   316             barringType = RMobilePhone::EBarAllIncomingServices;
       
   317             break;           
       
   318         case EBarringTypeAllServices:
       
   319         case EBarringTypeAllBarrings:
       
   320             barringType = RMobilePhone::EBarAllCases;
       
   321             break;
       
   322         case EBarringTypeAllOutgoing:
       
   323             barringType = RMobilePhone::EBarAllOutgoing;
       
   324             break;
       
   325         case EBarringTypeOutgoingInternational:
       
   326             barringType = RMobilePhone::EBarOutgoingInternational;
       
   327             break;
       
   328         case EBarringTypeOutgoingInternationalExceptToHomeCountry:
       
   329             barringType = RMobilePhone::EBarOutgoingInternationalExHC;
       
   330             break;
       
   331         case EBarringTypeAllIncoming:
       
   332             barringType = RMobilePhone::EBarAllIncoming;
       
   333             break;
       
   334         case EBarringTypeIncomingWhenRoaming:
       
   335             barringType = RMobilePhone::EBarIncomingRoaming;
       
   336             break;
       
   337         default:
       
   338             Panic( KPSNameOfClass, ECBUnknownBarringSetting );
       
   339             break;
       
   340         }
       
   341 
       
   342     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::SetBarringProgram");
       
   343     return barringType;
       
   344     }
       
   345 
       
   346 // ---------------------------------------------------------------------------
       
   347 // 
       
   348 // Changes both barring and common passwords.
       
   349 // 
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 EXPORT_C void CPsetCallBarring::ChangePasswordL( 
       
   353     RMobilePhone::TMobilePhonePasswordChangeV2& aPwds, TBool aIsBarringPw )
       
   354     {
       
   355     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::ChangePasswordL");
       
   356     if ( IsActive() )
       
   357         {
       
   358         User::Leave( KErrInUse );
       
   359         }
       
   360     
       
   361     RMobilePhone::TMobilePhonePasswordChangeV2Pckg pwdPckg ( aPwds );
       
   362 
       
   363     if ( aIsBarringPw )
       
   364         {
       
   365         iPhone.SetSSPassword( iStatus, pwdPckg, KPsetBarringService );
       
   366         SetRequestStatus( EPSetRequestChangeBarringPwd );
       
   367         }
       
   368     else
       
   369         {
       
   370         iPhone.SetSSPassword( iStatus, pwdPckg, KPsetAllSSServices );
       
   371         SetRequestStatus( EPSetRequestChangeCommonPwd );
       
   372         }
       
   373 
       
   374     StartRequestingL( KPsetRequestAlreadySet );
       
   375     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::ChangePasswordL");
       
   376     }
       
   377 // ---------------------------------------------------------------------------
       
   378 // 
       
   379 // Verify and change barring password.
       
   380 // DEPRECATED - calls the correct API
       
   381 // ---------------------------------------------------------------------------
       
   382 //
       
   383 EXPORT_C void CPsetCallBarring::ChangePasswordL( 
       
   384     RMobilePhone::TMobilePhonePasswordChangeV2& aPwds )
       
   385     {
       
   386     ChangePasswordL( aPwds, ETrue );
       
   387     }
       
   388 
       
   389 // ---------------------------------------------------------------------------
       
   390 // Sets request observer.
       
   391 // ---------------------------------------------------------------------------
       
   392 //
       
   393 EXPORT_C void CPsetCallBarring::SetRequestObserver( MPsetRequestObserver* aObs )
       
   394     {
       
   395     iReqObserver = aObs;
       
   396     }
       
   397 
       
   398 // ---------------------------------------------------------------------------
       
   399 // 
       
   400 // Sets observer member variable.
       
   401 // 
       
   402 // ---------------------------------------------------------------------------
       
   403 //
       
   404 void CPsetCallBarring::SetObserver( MPsetBarringObserver& aObserver )
       
   405     {
       
   406     iObserver = &aObserver;    
       
   407     }
       
   408 
       
   409 // ---------------------------------------------------------------------------
       
   410 // 
       
   411 // Starts requesting
       
   412 // 
       
   413 // ---------------------------------------------------------------------------
       
   414 //
       
   415 void CPsetCallBarring::StartRequestingL( const TInt& aRequest )
       
   416     {
       
   417     if ( aRequest != KPsetRequestAlreadySet )
       
   418         {
       
   419         SetRequestStatus( static_cast <TPSetBarringRequest> ( aRequest ) );
       
   420         }
       
   421 
       
   422     SetActive();
       
   423 
       
   424     iObserver->SetEngineContact( this );
       
   425 
       
   426     CleanupLeavePushL();    
       
   427     iObserver->HandleCBRequestingL( ETrue, EFalse );
       
   428     CleanupStack::Pop(); // CleanupCancelPushL
       
   429     }
       
   430 
       
   431 // ---------------------------------------------------------------------------
       
   432 // 
       
   433 // Returns ETrue, if plural notes hould be shown.
       
   434 // 
       
   435 // ---------------------------------------------------------------------------
       
   436 //
       
   437 TBool CPsetCallBarring::GetPlurality()
       
   438     {
       
   439     if ( iChangeSetting.iSetting == ECancelBarring && 
       
   440         ( iChangeSetting.iType == EBarringTypeAllBarrings || 
       
   441           iChangeSetting.iType == EBarringTypeAllIncomingServices || 
       
   442           iChangeSetting.iType == EBarringTypeAllOutgoingServices ||
       
   443           iChangeSetting.iType == EBarringTypeAllServices ) )
       
   444         {
       
   445         return ETrue;
       
   446         }
       
   447 
       
   448     else
       
   449         {
       
   450         return EFalse;
       
   451         }
       
   452     }
       
   453 
       
   454 // ---------------------------------------------------------------------------
       
   455 // 
       
   456 // Push object into cleanupstack to catch leaving.
       
   457 // 
       
   458 // ---------------------------------------------------------------------------
       
   459 //
       
   460 void CPsetCallBarring::CleanupLeavePushL()
       
   461       {
       
   462       CleanupStack::PushL( TCleanupItem( DoHandleLeave, this ) );
       
   463       }
       
   464 
       
   465 // ---------------------------------------------------------------------------
       
   466 // 
       
   467 // Object has caused a leave.
       
   468 // 
       
   469 // ---------------------------------------------------------------------------
       
   470 //
       
   471 void CPsetCallBarring::DoHandleLeave( TAny* aAny )
       
   472       {
       
   473       REINTERPRET_CAST( CPsetCallBarring*, aAny )->HandleLeave();
       
   474       }
       
   475 
       
   476 // ---------------------------------------------------------------------------
       
   477 // 
       
   478 // Things to do when leave occurs.
       
   479 // 
       
   480 // ---------------------------------------------------------------------------
       
   481 //
       
   482 void CPsetCallBarring::HandleLeave()
       
   483     {
       
   484     CancelCurrentRequest();
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------------------------
       
   488 // Inform the request observer that request has been completed.
       
   489 // ---------------------------------------------------------------------------
       
   490 //
       
   491 void CPsetCallBarring::RequestCompleted( const TInt& aError )
       
   492     {
       
   493     if ( aError != KErrNone )
       
   494         {
       
   495         SetRequestStatus( static_cast <TPSetBarringRequest> (aError) );
       
   496         }    
       
   497     ClearParams();
       
   498 
       
   499     if ( iReqObserver )
       
   500         {
       
   501         iReqObserver->RequestComplete(); 
       
   502         }
       
   503     }
       
   504 
       
   505 // ---------------------------------------------------------------------------
       
   506 // Empties member variables.
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 void CPsetCallBarring::ClearParams()
       
   510     {
       
   511     SetRequestStatus( EPSetRequestNone );
       
   512     iBarringParameters.iServiceGroup = RMobilePhone::EServiceUnspecified;
       
   513     iBarringParameters.iAction = RMobilePhone::EServiceActionUnspecified;
       
   514     iBarringParameters.iPassword = KNullDesC;
       
   515     }
       
   516 
       
   517 // ---------------------------------------------------------------------------
       
   518 // Return barring action.
       
   519 // ---------------------------------------------------------------------------
       
   520 //
       
   521 RMobilePhone::TMobilePhoneServiceAction CPsetCallBarring::SetBarringAction( 
       
   522     const TBarringSetting& aSetting )
       
   523     {
       
   524     if ( aSetting == ECancelBarring )
       
   525         {
       
   526     /*****************************************************
       
   527     *    Series 60 Customer / ETel
       
   528     *    Series 60  ETel API
       
   529     *****************************************************/
       
   530         return RMobilePhone::EServiceActionDeactivate;
       
   531         }
       
   532     else
       
   533         {
       
   534         return RMobilePhone::EServiceActionActivate;
       
   535         }
       
   536     }
       
   537 
       
   538 // ---------------------------------------------------------------------------
       
   539 // Handles inquiry results.
       
   540 // ---------------------------------------------------------------------------
       
   541 //
       
   542 void CPsetCallBarring::HandleInquiryResultL()
       
   543     {
       
   544     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::HandleInquiryResultL");
       
   545     TUint8 arrayOfBsc[KPSetNumberOfBsc];
       
   546     arrayOfBsc[0] = KPSetUnusedValue;
       
   547 
       
   548     CMobilePhoneCBList* cbStatusList = iCbStatusInterrogator->RetrieveListL();
       
   549     CleanupStack::PushL( cbStatusList );
       
   550     TBarringStatus status = EBarringStatusInactive;
       
   551     /*****************************************************
       
   552     *    Series 60 Customer / ETel
       
   553     *    Series 60  ETel API
       
   554     *****************************************************/
       
   555     RMobilePhone::TMobilePhoneCBInfoEntryV1 cbInfo;
       
   556     TInt entries = cbStatusList->Enumerate();
       
   557     __PHSLOGSTRING1("[PHS]    HandleInquiryResultL: Entry count: %d", entries);
       
   558     TInt i(0); 
       
   559     TInt cbArray(0);
       
   560     // If alternate line in use then only als line service information is shown.
       
   561     if ( iAls == ESSSettingsAlsAlternate )
       
   562         {
       
   563         while ( entries > i )
       
   564             {
       
   565             cbInfo = cbStatusList->GetEntryL( i );
       
   566 
       
   567             if ( cbInfo.iStatus == RMobilePhone::ECallBarringStatusActive && cbInfo.iServiceGroup == RMobilePhone::EAuxVoiceService )
       
   568                 {
       
   569                  __PHSLOGSTRING1("[PHS]    ALS: iServiceGroup: %d", cbInfo.iServiceGroup);
       
   570                 status = EBarringStatusActive;
       
   571                 arrayOfBsc[cbArray] = static_cast <TUint8> 
       
   572                     ( PSetUtility::ChangeToGSM( cbInfo.iServiceGroup ) );
       
   573                 cbArray++;
       
   574                 }
       
   575             i++;                                                                
       
   576             }   
       
   577         }
       
   578     else    // All other services than alternate line service is allowed to show when primary line is active.
       
   579         {
       
   580         while ( entries > i )
       
   581             {
       
   582             cbInfo = cbStatusList->GetEntryL( i );
       
   583 
       
   584             if ( cbInfo.iStatus == RMobilePhone::ECallBarringStatusActive && cbInfo.iServiceGroup != RMobilePhone::EAuxVoiceService )
       
   585                 {
       
   586                 __PHSLOGSTRING1("[PHS]  iServiceGroup: %d", cbInfo.iServiceGroup);
       
   587                 status = EBarringStatusActive;             
       
   588                 arrayOfBsc[cbArray] = static_cast <TUint8> 
       
   589                     ( PSetUtility::ChangeToGSM( cbInfo.iServiceGroup ) );
       
   590                 cbArray++; 
       
   591                 }
       
   592             i++;                       
       
   593             }
       
   594         }
       
   595         
       
   596     arrayOfBsc[cbArray] = KPSetUnusedValue;
       
   597     CleanupStack::PopAndDestroy( cbStatusList );
       
   598     iObserver->HandleBarringModeStatusL( arrayOfBsc, status );    
       
   599     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::HandleInquiryResultL");
       
   600     }
       
   601 
       
   602 // ---------------------------------------------------------------------------
       
   603 // Update the request status - both internally and to observers.
       
   604 // ---------------------------------------------------------------------------
       
   605 //
       
   606 void CPsetCallBarring::SetRequestStatus( TPSetBarringRequest aStatus )
       
   607     {
       
   608     iCurrentReq = aStatus;
       
   609     if ( iReqObserver )
       
   610         {
       
   611         iReqObserver->RequestStatusChanged( aStatus );
       
   612         }
       
   613     }
       
   614 
       
   615 // ---------------------------------------------------------------------------
       
   616 // 
       
   617 // Cancels pending request.
       
   618 // 
       
   619 // ---------------------------------------------------------------------------
       
   620 //
       
   621 void CPsetCallBarring::DoCancel()
       
   622     {    
       
   623     switch ( iCurrentReq )
       
   624         {
       
   625         case EPSetRequestChangeBarring:
       
   626             iPhone.CancelAsyncRequest( 
       
   627                 EMobilePhoneSetCallBarringStatus );
       
   628             break;
       
   629         case EPSetRequestGetStatus:
       
   630             iCbStatusInterrogator->Cancel();
       
   631             delete iCbStatusInterrogator;
       
   632             iCbStatusInterrogator = NULL;
       
   633             break;
       
   634         case EPSetRequestChangeBarringPwd:
       
   635         case EPSetRequestChangeCommonPwd:
       
   636             iPhone.CancelAsyncRequest( EMobilePhoneSetSSPassword );
       
   637             break;
       
   638         default:
       
   639             break;
       
   640         }
       
   641     ClearParams();    
       
   642     }
       
   643 
       
   644 
       
   645 // ---------------------------------------------------------------------------
       
   646 // 
       
   647 // Handles completed request. If error occured, calls error handling
       
   648 //    function of the observer, otherwise does nothing.
       
   649 // 
       
   650 // ---------------------------------------------------------------------------
       
   651 //
       
   652 void CPsetCallBarring::RunL()
       
   653     {
       
   654     __PHSLOGSTRING("[PHS]--> CPsetCallBarring::RunL");
       
   655     __ASSERT_ALWAYS( iObserver != NULL, 
       
   656         Panic( KPSNameOfClass, ECBNoObserver ) );
       
   657 
       
   658     //Hide requesting note - does not leave when deleting a note.
       
   659     iObserver->SetEngineContact( this );
       
   660     iObserver->HandleCBRequestingL( EFalse, EFalse );
       
   661 
       
   662     //Error situations
       
   663     if ( iStatus != KErrNone )
       
   664         {
       
   665         iObserver->HandleBarringErrorL( iStatus.Int() );
       
   666         RequestCompleted( iStatus.Int() );      
       
   667         return;
       
   668         }
       
   669   
       
   670     switch ( iCurrentReq )
       
   671         {
       
   672         case EPSetRequestChangeBarring:
       
   673             {
       
   674             __PHSLOGSTRING("[PHS]     EPSetRequestChangeBarring");
       
   675             TBarringStatus status = ( TBarringStatus ) iChangeSetting.iSetting;
       
   676             TBool plural = GetPlurality();
       
   677             __PHSLOGSTRING1("[PHS]    Barring status: %d", status );
       
   678             __PHSLOGSTRING1("[PHS]    Plurality: %d", plural );
       
   679             iObserver->HandleBarringModeChangedL( iChangeSetting.iType, 
       
   680                                                   status, plural );
       
   681             break;
       
   682             }            
       
   683         case EPSetRequestGetStatus:
       
   684             {
       
   685             __PHSLOGSTRING("[PHS]     EPSetRequestGetStatus");
       
   686             HandleInquiryResultL();
       
   687             break;
       
   688             }
       
   689         case EPSetRequestChangeBarringPwd:
       
   690         case EPSetRequestChangeCommonPwd:
       
   691             __PHSLOGSTRING("[PHS]     EPSetRequestChange");
       
   692             iObserver->CbPasswordChangedL( ETrue );
       
   693             break;
       
   694         default:
       
   695             Panic ( KPSNameOfClass, ECBUnknownRequest );
       
   696             break;
       
   697         }
       
   698     RequestCompleted( KErrNone );
       
   699     __PHSLOGSTRING("[PHS] <--CPsetCallBarring::RunL");
       
   700     }
       
   701 
       
   702 // End of File