cellular/SSSettings/src/RSSSettings.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:  Class for getting information about the Clir, Cug, Als and 
       
    15 *                Als blocking status in the phone. 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    <bldvariant.hrh> // for feature definitions
       
    23 #include    <e32base.h>
       
    24 #include    <rmmcustomapi.h>
       
    25 #include    <mmtsy_names.h>
       
    26 #include    <PSVariables.h> 
       
    27 #include    <startupdomainpskeys.h>
       
    28 #include    <centralrepository.h> // central repository 
       
    29 #include    <sssettingsprivatecrkeys.h> // settings central repository keys. 
       
    30 #include    <telservicesinternalcrkeys.h>
       
    31 #include    <telservicesvariant.hrh>
       
    32 
       
    33 #include    "rsssettings.h" 
       
    34 #include    "msssettingsobserver.h" 
       
    35 #include    "csssettingsnotifier.h" 
       
    36 #include    "csssettingsalsnotifier.h" 
       
    37 #include    "sssettingslogger.h" 
       
    38 
       
    39 // CONSTANTS
       
    40 _LIT( KPanicCat, "SSSettings" );
       
    41 #define KSSSettingsTSYName KMmTsyModuleName
       
    42 const TInt KSSSettingsTSYNameMaxLength( 80 );
       
    43 const TInt KSSSettingsLastSetting(ESSSettingsDefaultCug);
       
    44 const TInt KSSSettingsMaxETelRetryCount(7);
       
    45 const TInt KSSSettingsETelRetryCountTimeout(100000); 
       
    46 
       
    47 // ================= LOCAL FUNCTIONS =======================
       
    48 TInt SSSettingsDoOpenEtelConnection( RTelServer& aEtel, RPhone& aPhone )
       
    49     {
       
    50     TInt phones(0);
       
    51     if ( aEtel.EnumeratePhones( phones) == KErrNone )
       
    52         {
       
    53         for ( TInt p = 0 ; p < phones ; p++ )
       
    54             {
       
    55             TBuf<KSSSettingsTSYNameMaxLength> tsyName;
       
    56             if ( aEtel.GetTsyName( p,tsyName ) == KErrNone )
       
    57                 {
       
    58                 if ( tsyName.CompareF( KSSSettingsTSYName ) == 0 )
       
    59                     {
       
    60                     RTelServer::TPhoneInfo info;
       
    61                     if ( aEtel.GetPhoneInfo( p,info ) == KErrNone )
       
    62                         {
       
    63                         if ( aPhone.Open( aEtel, info.iName ) == KErrNone )
       
    64                             {
       
    65                             return KErrNone;
       
    66                             }
       
    67                         }
       
    68                     }
       
    69                 }
       
    70             }
       
    71         }
       
    72     return KErrGeneral;
       
    73     }
       
    74 
       
    75 
       
    76 // ================= MEMBER FUNCTIONS =======================
       
    77 
       
    78 // C++ default constructor can NOT contain any code, that
       
    79 // might leave.
       
    80 //
       
    81 EXPORT_C RSSSettings::RSSSettings()
       
    82     {
       
    83     iData = NULL;
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 // RSSSettings::Close
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 EXPORT_C void RSSSettings::Close()
       
    92    {
       
    93    __SSSLOGSTRING("[SSS]--> RSSSettings::Close");
       
    94    DeleteSettingsData();
       
    95    __SSSLOGSTRING("[SSS] <--RSSSettings::Close");
       
    96    }
       
    97 
       
    98 // ---------------------------------------------------------
       
    99 // RSSSettings::Open#1
       
   100 // ---------------------------------------------------------
       
   101 //
       
   102 EXPORT_C TInt RSSSettings::Open()
       
   103     {
       
   104     __SSSLOGSTRING("[SSS]--> RSSSettings::Open");
       
   105     TInt ret(KErrNone);
       
   106     ret = Open( NULL );
       
   107     __SSSLOGSTRING("[SSS] <--RSSSettings::Open");
       
   108     return ret;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // RSSSettings::Open#3
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 EXPORT_C TInt RSSSettings::Open( RTelServer* aTelServer )
       
   116     {
       
   117     __SSSLOGSTRING("[SSS]--> RSSSettings::Open3");
       
   118     TRAPD( error, OpenL( aTelServer ) );
       
   119     if ( error != KErrNone )
       
   120         {
       
   121         DeleteSettingsData();
       
   122         }
       
   123     __SSSLOGSTRING("[SSS] <--RSSSettings::Open3");
       
   124     return error;
       
   125 
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // RSSSettings::OpenL
       
   130 // ---------------------------------------------------------
       
   131 //
       
   132 void RSSSettings::OpenL( RTelServer* aTelServer )
       
   133     {
       
   134     __SSSLOGSTRING("[SSS]--> RSSSettings::OpenL");
       
   135     if ( iData )
       
   136         {
       
   137         DeleteSettingsData();
       
   138         }
       
   139 
       
   140     iData = new ( ELeave ) TSSSettingsData;
       
   141 
       
   142     iData->iOwnTelServer = ETrue;
       
   143     iData->iTelServer = NULL;
       
   144     iData->iCallBack = NULL;
       
   145     iData->iCallBackSetting = KErrBadDescriptor;
       
   146     iData->iCallBackValue = KErrBadDescriptor;
       
   147     iData->iNotifier = NULL;
       
   148     iData->iCustomPhone = NULL;
       
   149     iData->iCUGDefault = NULL;
       
   150     iData->iRepository = NULL;
       
   151 
       
   152     // Create Notifier
       
   153     // ConstructL is called later when the sessions are opened.
       
   154     iData->iNotifier = new ( ELeave ) CSSSettingsNotifier( *this );
       
   155 
       
   156     // Crate call back  for async inform
       
   157     TCallBack callBack( InformCallBack, this );
       
   158     iData->iCallBack = new ( ELeave ) 
       
   159         CAsyncCallBack( callBack, CActive::EPriorityStandard );
       
   160 
       
   161     // Check central repository connection.
       
   162     iData->iRepository = CRepository::NewL(
       
   163         KCRUidSupplementaryServiceSettings );
       
   164 
       
   165     // Check ETel connecion
       
   166     if ( aTelServer )
       
   167         {
       
   168         iData->iOwnTelServer = EFalse;
       
   169         iData->iTelServer = aTelServer;
       
   170         // Given ETel connection must be open.
       
   171         if ( iData->iTelServer->Handle() == 0 )
       
   172             {
       
   173             User::Leave( KErrBadHandle );
       
   174             }
       
   175         }
       
   176     else
       
   177         {
       
   178         iData->iOwnTelServer = ETrue;
       
   179         iData->iTelServer = new ( ELeave ) RTelServer();
       
   180 
       
   181         // Retry ETel connection:
       
   182         TInt err(KErrNone);
       
   183         for ( TInt i = 0 ; i < KSSSettingsMaxETelRetryCount ; i++ )
       
   184             {
       
   185             err = iData->iTelServer->Connect();
       
   186             if ( err == KErrNone )
       
   187                 {
       
   188                 break;
       
   189                 }
       
   190             User::After( KSSSettingsETelRetryCountTimeout );
       
   191             }
       
   192 
       
   193         User::LeaveIfError( err );
       
   194         }
       
   195 
       
   196     // Open phones
       
   197     TInt error = iData->iTelServer->LoadPhoneModule( KSSSettingsTSYName );
       
   198     if (( error != KErrNone ) && ( error != KErrAlreadyExists ))
       
   199         {
       
   200         User::Leave( error );
       
   201         }
       
   202 
       
   203     User::LeaveIfError( SSSettingsDoOpenEtelConnection( 
       
   204         *iData->iTelServer, iData->iMobilePhone ) );
       
   205 
       
   206     iData->iCustomPhone = new ( ELeave ) RMmCustomAPI;
       
   207     iData->iCustomPhone->Open( iData->iMobilePhone );
       
   208 
       
   209 
       
   210     // Finish off the notifier construct.
       
   211     iData->iNotifier->ConstructL();
       
   212 
       
   213     // Create arrays:
       
   214     for ( TInt i = 0 ; i <= KSSSettingsLastSetting ; i++ )
       
   215         {
       
   216         RSSSettingsObserverArray newArray;
       
   217         User::LeaveIfError( iData->iObservers.Append( newArray ) );
       
   218         }
       
   219 
       
   220     //Get default CUG
       
   221     error = GetDefaultCugL( iData->iCUGDefault );
       
   222     if ( error != KErrNone )
       
   223         {
       
   224         //Support legacy, if error occurs
       
   225         iData->iCUGDefault = ESSSettingsCugDefault; 
       
   226         }
       
   227     __SSSLOGSTRING("[SSS] <--RSSSettings::OpenL");
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------
       
   231 // RSSSettings::DeleteSettingsData
       
   232 // ---------------------------------------------------------
       
   233 //
       
   234 void RSSSettings::DeleteSettingsData()
       
   235     {
       
   236     __SSSLOGSTRING("[SSS]--> RSSSettings::DeleteSettingsData");
       
   237     if ( iData == NULL )
       
   238         {
       
   239         return;
       
   240         }
       
   241 
       
   242     // if some event is waiting for the observer calls..
       
   243     if (( iData->iCallBackSetting != KErrBadDescriptor ||
       
   244           iData->iCallBackValue != KErrBadDescriptor ) &&
       
   245           iData->iCallBack )
       
   246         {
       
   247         iData->iCallBack->Cancel();
       
   248         InformCallBack( this );
       
   249         }
       
   250 
       
   251     // close array
       
   252     MSSSettingsObserver* observer = FindOneObserver();
       
   253     while ( observer )
       
   254         {
       
   255         CancelAll( *observer );
       
   256         observer = FindOneObserver();
       
   257         }
       
   258 
       
   259     iData->iObservers.Reset();
       
   260 
       
   261     // delete callback
       
   262     if ( iData->iCallBack )
       
   263         {
       
   264         iData->iCallBack->Cancel();
       
   265         delete iData->iCallBack;
       
   266         iData->iCallBack = NULL;
       
   267         }
       
   268 
       
   269     // Delete notifier
       
   270     delete iData->iNotifier;
       
   271     iData->iNotifier = NULL;
       
   272 
       
   273     delete iData->iRepository;
       
   274     iData->iRepository = NULL;
       
   275     
       
   276     // close phones
       
   277     if ( iData->iCustomPhone )
       
   278         {
       
   279         iData->iCustomPhone->Close();
       
   280         delete iData->iCustomPhone;
       
   281         iData->iCustomPhone = NULL;
       
   282         }
       
   283 
       
   284     iData->iMobilePhone.Close();
       
   285 
       
   286     // close ETel session
       
   287     if (( iData->iTelServer ) && ( iData->iOwnTelServer ))
       
   288         {
       
   289         if ( iData->iTelServer->Handle() )
       
   290             {
       
   291             iData->iTelServer->Close();
       
   292             }
       
   293         delete iData->iTelServer;
       
   294         iData->iTelServer = NULL;
       
   295         }
       
   296 
       
   297     // delete data object
       
   298     delete iData;
       
   299     iData = NULL;
       
   300     __SSSLOGSTRING("[SSS] <--RSSSettings::DeleteSettingsData");
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------
       
   304 // RSSSettings::InformCallBack
       
   305 // KErrBadDescriptor is used as not defined.
       
   306 // ---------------------------------------------------------
       
   307 //
       
   308 TInt RSSSettings::InformCallBack( TAny* aPtr )
       
   309     {
       
   310     __SSSLOGSTRING("[SSS]--> RSSSettings::InformCallBack");
       
   311     RSSSettings* settings = static_cast <RSSSettings*> ( aPtr );
       
   312 
       
   313     if ( !settings->iData )
       
   314         {
       
   315         return KErrNone;
       
   316         }
       
   317 
       
   318     // We need to have both setting and value to make observer call.
       
   319     if ( settings->iData->iCallBackSetting == KErrBadDescriptor ||
       
   320          settings->iData->iCallBackValue == KErrBadDescriptor )
       
   321         {
       
   322         settings->iData->iCallBackSetting = KErrBadDescriptor;
       
   323         settings->iData->iCallBackValue = KErrBadDescriptor;
       
   324         return KErrNone;
       
   325         }
       
   326 
       
   327     settings->InformChange(
       
   328         (TSSSettingsSetting)settings->iData->iCallBackSetting , 
       
   329         settings->iData->iCallBackValue );
       
   330 
       
   331     settings->iData->iCallBackSetting = KErrBadDescriptor;
       
   332     settings->iData->iCallBackValue = KErrBadDescriptor;
       
   333     
       
   334     __SSSLOGSTRING("[SSS] <--RSSSettings::InformCallBack");
       
   335     return KErrNone;
       
   336     }
       
   337 
       
   338 // ---------------------------------------------------------
       
   339 // RSSSettings::InformChange
       
   340 // ---------------------------------------------------------
       
   341 //
       
   342 void RSSSettings::InformChange( TSSSettingsSetting aSetting, TInt aNewValue )
       
   343     {
       
   344     __SSSLOGSTRING("[SSS]--> RSSSettings::InformChange");
       
   345     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
   346 
       
   347     RSSSettingsObserverArray& array = iData->iObservers[aSetting];
       
   348     for ( TInt i = 0 ; i < array.Count() ; i++ )
       
   349         {
       
   350         array[i]->PhoneSettingChanged( aSetting, aNewValue );
       
   351         }
       
   352 
       
   353     __SSSLOGSTRING("[SSS] <--RSSSettings::InformChange");
       
   354     }
       
   355 
       
   356 // ---------------------------------------------------------
       
   357 // RSSSettings::RegisterAll
       
   358 // ---------------------------------------------------------
       
   359 //
       
   360 EXPORT_C TInt RSSSettings::RegisterAll( MSSSettingsObserver& aObserver )
       
   361     {
       
   362     __SSSLOGSTRING("[SSS]--> RSSSettings::RegisterAll");
       
   363     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
   364     if ( !iData )
       
   365         {
       
   366         return KErrBadHandle;
       
   367         }
       
   368 
       
   369     TInt error(KErrNone);
       
   370     for ( TInt i = 0 ; i <= KSSSettingsLastSetting ; i++ )
       
   371         {
       
   372         error = Register( static_cast <TSSSettingsSetting >( i ), aObserver );
       
   373         // KErrAlreadyExists: it's already registered.
       
   374         // KErrNotSupported: ALS and ALS blocking may return this.
       
   375         if (( error != KErrNone ) && 
       
   376             ( error != KErrAlreadyExists ) && 
       
   377             ( error != KErrNotSupported ))
       
   378             {
       
   379             CancelAll( aObserver );
       
   380             break;
       
   381             }
       
   382         error = KErrNone;
       
   383         }
       
   384     __SSSLOGSTRING("[SSS] <--RSSSettings::RegisterAll");
       
   385     return error;
       
   386     }
       
   387 
       
   388 // ---------------------------------------------------------
       
   389 // RSSSettings::Register
       
   390 // ---------------------------------------------------------
       
   391 //
       
   392 EXPORT_C TInt RSSSettings::Register( 
       
   393     TSSSettingsSetting aSetting, 
       
   394     MSSSettingsObserver& aObserver )
       
   395     {
       
   396     __SSSLOGSTRING("[SSS]--> RSSSettings::Register");
       
   397     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
   398     if ( !iData )
       
   399         {
       
   400         return KErrBadHandle;
       
   401         }
       
   402     __ASSERT_DEBUG( aSetting <= KSSSettingsLastSetting, 
       
   403                     Panic( SSSettingsPanicInvalidRequest ) );
       
   404 
       
   405     if ( ExistsObserver( aSetting, aObserver ) )
       
   406         {
       
   407         return KErrAlreadyExists;
       
   408         }
       
   409 
       
   410     RSSSettingsObserverArray& array = iData->iObservers[aSetting];
       
   411 
       
   412     // When the first observer is set, the notifier is activated.
       
   413     TInt error(KErrNone);
       
   414     if ( array.Count() == 0 )
       
   415         {
       
   416         error = iData->iNotifier->AddNotifier( aSetting );
       
   417         // if BT Sim Access Profile(SAP) is turned on then ETEL returns KErrNotReady.
       
   418         if ( error != KErrNone )
       
   419             {
       
   420             __SSSLOGSTRING1("[SSS]--> RSSSettings::Register -> Error code: %d", error );
       
   421             return error;
       
   422             }
       
   423         }
       
   424     error = array.Append( &aObserver );
       
   425 
       
   426     __SSSLOGSTRING("[SSS] <--RSSSettings::Register");
       
   427     return error;
       
   428     }
       
   429 
       
   430 // ---------------------------------------------------------
       
   431 // RSSSettings::CancelAll
       
   432 // ---------------------------------------------------------
       
   433 //
       
   434 EXPORT_C void RSSSettings::CancelAll( 
       
   435     MSSSettingsObserver& aObserver )
       
   436     {
       
   437     __SSSLOGSTRING("[SSS]--> RSSSettings::CancelAll");
       
   438     if ( !iData )
       
   439         {
       
   440         return;
       
   441         }
       
   442 
       
   443     for ( TInt i = 0 ; i <= KSSSettingsLastSetting ; i++ )
       
   444         {
       
   445         Cancel( static_cast <TSSSettingsSetting> ( i ), aObserver );
       
   446         }
       
   447     __SSSLOGSTRING("[SSS] <--RSSSettings::CancelAll");
       
   448     }
       
   449 
       
   450 // ---------------------------------------------------------
       
   451 // RSSSettings::Cancel
       
   452 // ---------------------------------------------------------
       
   453 //
       
   454 EXPORT_C void RSSSettings::Cancel( 
       
   455     TSSSettingsSetting aSetting,
       
   456     MSSSettingsObserver& aObserver )
       
   457     {
       
   458     __SSSLOGSTRING("[SSS]--> RSSSettings::Cancel");
       
   459     if ( !iData )
       
   460         {
       
   461         return;
       
   462         }
       
   463     __ASSERT_ALWAYS( aSetting <= KSSSettingsLastSetting, 
       
   464                      Panic( SSSettingsPanicInvalidRequest ) );
       
   465 
       
   466     RSSSettingsObserverArray& array = iData->iObservers[aSetting];
       
   467 
       
   468     TInt index = array.Find( &aObserver );
       
   469     if ( index == KErrNotFound )
       
   470         {
       
   471         return;
       
   472         }
       
   473 
       
   474     array.Remove( index );
       
   475     array.Compress();
       
   476 
       
   477     // When the last observer is removed the notifier is cancelled.
       
   478     if ( array.Count() == 0 )
       
   479         {
       
   480         iData->iNotifier->RemoveNotifier( aSetting );
       
   481         }
       
   482     __SSSLOGSTRING("[SSS] <--RSSSettings::Cancel");
       
   483     }
       
   484 
       
   485 // ---------------------------------------------------------
       
   486 // RSSSettings::Get
       
   487 // ---------------------------------------------------------
       
   488 //
       
   489 EXPORT_C TInt RSSSettings::Get( TSSSettingsSetting aSetting, TInt& aValue )
       
   490     {
       
   491     __SSSLOGSTRING("[SSS]--> RSSSettings::Get");
       
   492     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
   493     if ( !iData )
       
   494         {
       
   495         return KErrBadHandle;
       
   496         }
       
   497 
       
   498     __ASSERT_DEBUG( aSetting <= KSSSettingsLastSetting, 
       
   499                     Panic( SSSettingsPanicInvalidRequest ) );
       
   500 
       
   501     TInt error(KErrNone);
       
   502     TInt value(0);
       
   503     if ( error != KErrNone )
       
   504         {
       
   505         return error;
       
   506         }
       
   507 
       
   508     // If Get fails, we try to save the default data.
       
   509     switch ( aSetting )
       
   510         {
       
   511         case ESSSettingsCug:
       
   512             error = GetCug( value );
       
   513             if (( error != KErrNone ) && ( error != KErrNotFound ))
       
   514                 {
       
   515                 break;
       
   516                 }
       
   517             if ( error == KErrNotFound )
       
   518                 {
       
   519                 error = iData->iRepository->Set(
       
   520                     KSettingsCUG,
       
   521                     iData->iCUGDefault );
       
   522                     
       
   523                 if ( error != KErrNone )
       
   524                     {
       
   525                     break;
       
   526                     }
       
   527                 value = iData->iCUGDefault;
       
   528                 }
       
   529             //If value outside of 0-32767 and not 65535, value is not accepted.
       
   530             if ( iData->iCUGDefault == ESSSettingsAltCugDefault )
       
   531                 {
       
   532                 if ((( value < ESSSettingsCugSuppress ) || 
       
   533                      ( value > ESSSettingsCugMax )) &&
       
   534                      ( value != ESSSettingsAltCugDefault ))
       
   535                     {
       
   536                     error = KErrCorrupt;
       
   537                     break;
       
   538                     }
       
   539                 }
       
   540             //If value outside of 1-32767, it is not accepted.
       
   541             else
       
   542                 {
       
   543                 if (( value < ESSSettingsCugSuppress ) || 
       
   544                     ( value > ESSSettingsCugMax ))
       
   545                     {
       
   546                     error = KErrCorrupt;
       
   547                     break;
       
   548                     }
       
   549                 }
       
   550             aValue = value;
       
   551             break;
       
   552         case ESSSettingsClir:
       
   553             error = iData->iRepository->Get(
       
   554                 KSettingsCLIR,
       
   555                 value );
       
   556             if ( ( error != KErrNone ) && ( error != KErrNotFound ) )
       
   557                 {
       
   558                 break;
       
   559                 }
       
   560             if ( error == KErrNotFound )
       
   561                 {
       
   562                 error = iData->iRepository->Set( 
       
   563                     KSettingsCLIR,
       
   564                     ESSSettingsClirNetworkDefault );
       
   565                 if ( error != KErrNone )
       
   566                     {
       
   567                     break;
       
   568                     }
       
   569                 value = ESSSettingsClirNetworkDefault;
       
   570                 }
       
   571 
       
   572             if (( value < ESSSettingsClirNetworkDefault ) || 
       
   573                 ( value > ESSSettingsClirExplicitSuppress ))
       
   574                 {
       
   575                 error = KErrCorrupt;
       
   576                 break;
       
   577                 }
       
   578             aValue = value;
       
   579             break;
       
   580             
       
   581         case ESSSettingsAls:
       
   582             {
       
   583             TInt simState(0);
       
   584             error = RProperty::Get( KPSUidStartup, KPSSimStatus, simState );
       
   585             
       
   586             __SSSLOGSTRING2("[SSS] ESSSettingsAls: SIM State: %d Error: %d", simState, error );
       
   587            if ( error == KErrNone )
       
   588                 {
       
   589                 error = GetALSSettingValue( value, simState );
       
   590                 aValue = value;
       
   591                 __SSSLOGSTRING1("[SSS]     RSSSettings::Get: ALS Value: %d", aValue );
       
   592                 }
       
   593             break;
       
   594             }
       
   595         case ESSSettingsAlsBlocking:
       
   596             {
       
   597             RMmCustomAPI::TGetAlsBlockStatus alsBlockStatus = 
       
   598                 RMmCustomAPI::EBlockStatusUnknown;
       
   599             error = iData->iCustomPhone->GetAlsBlocked( alsBlockStatus );
       
   600 
       
   601             if ( error != KErrNone )
       
   602                 {
       
   603                 aValue = ESSSettingsAlsBlockingNotSupported;
       
   604                 return KErrNone;
       
   605                 }
       
   606             switch ( alsBlockStatus )
       
   607                 {
       
   608                 case RMmCustomAPI::EBlockStatusNotSupported: 
       
   609                     aValue = ESSSettingsAlsBlockingNotSupported;
       
   610                     break;
       
   611                 case RMmCustomAPI::EBlockStatusActive: 
       
   612                     aValue = ESSSettingsAlsBlockingOn;
       
   613                     break;
       
   614                 case RMmCustomAPI::EBlockStatusInactive: 
       
   615                     aValue = ESSSettingsAlsBlockingOff;
       
   616                     break;
       
   617                 case RMmCustomAPI::EBlockStatusUnknown: 
       
   618                     error = KErrNotSupported;
       
   619                     break;
       
   620                 default:
       
   621                     error = KErrNotSupported;
       
   622                     break;
       
   623                 }
       
   624             break;
       
   625             }
       
   626         case ESSSettingsDefaultCug:
       
   627             aValue = iData->iCUGDefault;
       
   628             break;
       
   629         default:
       
   630             error = KErrNotSupported;
       
   631             break;
       
   632         }
       
   633 
       
   634     __SSSLOGSTRING("[SSS] <--RSSSettings::Get");
       
   635     __SSSLOGSTRING1("[SSS] <--RSSSettings::Get Error code: %d", error );
       
   636     return error;
       
   637     }
       
   638 
       
   639 // ---------------------------------------------------------
       
   640 // RSSSettings::GetALSSettingValue
       
   641 // ---------------------------------------------------------
       
   642 //
       
   643 TInt RSSSettings::GetALSSettingValue( TInt& aValue, const TInt aSimState )
       
   644     {
       
   645     __SSSLOGSTRING1("[SSS]--> RSSSettings::GetALSSettingValue SIMSTATE: %d", aSimState );
       
   646     TInt value(0);
       
   647     TBool simAlsValue(EFalse);
       
   648     TBool ppAlsValue(EFalse);
       
   649     TBool alsCSPSupport(EFalse);
       
   650     TInt error(KErrNone);
       
   651     /* aValue is set to ESSSettingsAlsNotSupported value because if SimState isnt 
       
   652     ESimUsable or ALS handler doesnt exist then value should always be Not Supported.*/ 
       
   653     aValue = ESSSettingsAlsNotSupported;
       
   654     
       
   655     // als is NULL when ALS is not supported by PP als, SIM als and SIM csp als bits.
       
   656     CSSSettingsAlsNotifier* als = iData->iNotifier->GetAlsHandler();
       
   657     __SSSLOGSTRING1("[SSS] AlsHandler value: %d", als );
       
   658     
       
   659      // Make sure that SIM state is OK otherwise parameters coming from SIM are mess.
       
   660     if ( ( aSimState == ESimUsable ) && als )    
       
   661         {
       
   662         error = als->GetAlsValue( (TSSSettingsAlsValue&) value );
       
   663         if ( error == KErrNone )
       
   664             {
       
   665             if (( value < ESSSettingsAlsNotSupported ) || 
       
   666                 ( value > ESSSettingsAlsAlternate ))
       
   667                 {
       
   668                 error = KErrCorrupt;
       
   669                 return error;
       
   670                 }
       
   671             
       
   672             TInt alsCSPError(KErrNone);
       
   673             als->GetAlsSupport( ppAlsValue, simAlsValue, alsCSPSupport, alsCSPError );
       
   674             if ( alsCSPError == KErrNotReady || alsCSPError == KErrServerBusy )
       
   675                 {
       
   676                 __SSSLOGSTRING1("[SSS] ALS - CSP specific Error code: %d", alsCSPError );
       
   677                 return alsCSPError;                             
       
   678                 }
       
   679                                         
       
   680             // Decides if ALS is wanted to be shown.
       
   681             if ( KErrNotSupported == IsALSSupported( ppAlsValue, simAlsValue, alsCSPSupport, error ) )
       
   682                 {
       
   683                 value = ESSSettingsAlsNotSupported;
       
   684                 }
       
   685             aValue = value;
       
   686             }
       
   687         }
       
   688     __SSSLOGSTRING1("[SSS]<-- RSSSettings::GetALSSettingValue Error: %d", error );
       
   689     return error;
       
   690     }
       
   691 
       
   692 // ---------------------------------------------------------------------------
       
   693 // RSSSettings::IsALSSupported
       
   694 // List all cases when als is shown. If there is some special SIM that doesn't
       
   695 // support ALS then add case below and give error code KErrNotSupported.
       
   696 // ---------------------------------------------------------------------------
       
   697 // 
       
   698 TInt RSSSettings::IsALSSupported( TInt aPpAlsValue, TInt aSimAlsValue, 
       
   699     TBool aAlsCspSupport, TInt aAlsCspError ) const
       
   700     {
       
   701     TInt error(KErrNotSupported);
       
   702     
       
   703     __SSSLOGSTRING1("[SSS]    RSSSettings::IsALSSupported ppAlsValue value: %d", aPpAlsValue );
       
   704     __SSSLOGSTRING1("[SSS]    RSSSettings::IsALSSupported simAlsValue value:  %d", aSimAlsValue );
       
   705     __SSSLOGSTRING1("[SSS]    RSSSettings::IsALSSupported alsCSPSupport value: %d", aAlsCspSupport );
       
   706     __SSSLOGSTRING1("[SSS]    RSSSettings::IsALSSupported alsCSPError value: %d", aAlsCspError );
       
   707     
       
   708     // When PP ALS is on and used SIM card suppports CSP ALS then alsCSPSupport returns EFALSE and alsCSPError KErrNotSupported but ALS functionality
       
   709     // needs to be shown therefore KErrNone is returned.
       
   710     if ( aPpAlsValue && !aSimAlsValue && aAlsCspSupport == FALSE && aAlsCspError == KErrNotSupported  )
       
   711         {
       
   712         error = KErrNone;
       
   713         }          
       
   714     else if ( aPpAlsValue && aSimAlsValue && aAlsCspSupport == FALSE )
       
   715         {
       
   716         error = KErrNone;
       
   717         }
       
   718     else if ( aPpAlsValue && aSimAlsValue && aAlsCspSupport == TRUE  )
       
   719         {
       
   720         error = KErrNone;
       
   721         }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
       
   722     else if ( aPpAlsValue && !aSimAlsValue && aAlsCspSupport == FALSE  )
       
   723         {
       
   724         error = KErrNone;
       
   725         }
       
   726     else if ( aPpAlsValue && !aSimAlsValue && aAlsCspSupport == TRUE  )
       
   727         {
       
   728         error = KErrNone;
       
   729         }
       
   730     else if ( !aPpAlsValue && aSimAlsValue && aAlsCspSupport == TRUE  )
       
   731         {
       
   732         error = KErrNone;
       
   733         }
       
   734     else if ( !aPpAlsValue && aSimAlsValue && aAlsCspSupport == FALSE  )
       
   735         {
       
   736         error = KErrNotSupported;
       
   737         }
       
   738     else if ( !aPpAlsValue && !aSimAlsValue && aAlsCspSupport == TRUE  )
       
   739         {
       
   740         error = KErrNone;
       
   741         }
       
   742                             
       
   743     return error;   
       
   744     }
       
   745     
       
   746 // ---------------------------------------------------------
       
   747 // RSSSettings::Set
       
   748 // ---------------------------------------------------------
       
   749 //
       
   750 EXPORT_C TInt RSSSettings::Set( TSSSettingsSetting aSetting, TInt aValue )
       
   751     {
       
   752     __SSSLOGSTRING("[SSS]--> RSSSettings::Set");
       
   753     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
   754     if ( !iData )
       
   755         {
       
   756         return KErrBadHandle;
       
   757         }
       
   758 
       
   759     __ASSERT_DEBUG( aSetting <= KSSSettingsLastSetting, 
       
   760                     Panic( SSSettingsPanicInvalidRequest ) );
       
   761 
       
   762     TInt error(KErrNone);
       
   763     if ( error != KErrNone )
       
   764         {
       
   765         return error;
       
   766         }
       
   767 
       
   768     switch ( aSetting )
       
   769         {
       
   770         case ESSSettingsCug:
       
   771             {
       
   772             if ( iData->iCUGDefault == ESSSettingsAltCugDefault )
       
   773                 {
       
   774                 if ((( aValue < ESSSettingsCugSuppress ) || 
       
   775                     ( aValue > ESSSettingsCugMax )) &&
       
   776                     ( aValue != iData->iCUGDefault ))
       
   777                     {
       
   778                     error = KErrArgument;
       
   779                     break;
       
   780                     }
       
   781                 }
       
   782             else
       
   783                 {
       
   784                 if (( aValue < ESSSettingsCugSuppress ) || 
       
   785                     ( aValue > ESSSettingsCugMax ))
       
   786                     {
       
   787                     error = KErrArgument;
       
   788                     break;
       
   789                     }
       
   790                 }
       
   791             if ( error == KErrNone )
       
   792                 {
       
   793                 error = SetCug( aValue, iData->iCUGDefault );
       
   794                 }
       
   795             }
       
   796             break;
       
   797         case ESSSettingsClir:
       
   798             if (( aValue < ESSSettingsClirNetworkDefault ) || 
       
   799                 ( aValue > ESSSettingsClirExplicitSuppress ))
       
   800                 {
       
   801                 error = KErrArgument;
       
   802                 break;
       
   803                 }
       
   804             error = iData->iRepository->Set(
       
   805                 KSettingsCLIR,
       
   806                 aValue );
       
   807             break;
       
   808         case ESSSettingsAls:
       
   809             {
       
   810             // ESSSettingsAlsBlockingNotSupported is not allowed to write
       
   811             if (( aValue < ESSSettingsAlsBlockingOff ) || 
       
   812                 ( aValue > ESSSettingsAlsAlternate ))
       
   813                 {
       
   814                 error = KErrArgument;
       
   815                 break;
       
   816                 }
       
   817 
       
   818             CSSSettingsAlsNotifier* als = iData->iNotifier->GetAlsHandler();
       
   819             if ( als )
       
   820                 {
       
   821                 error = als->SetAlsValue( (TSSSettingsAlsValue)aValue );   
       
   822                 }
       
   823             else
       
   824                 {
       
   825                 error = KErrNotSupported;
       
   826                 }
       
   827             break;
       
   828             }
       
   829         case ESSSettingsAlsBlocking:
       
   830             switch ( aValue )
       
   831                 {
       
   832                 case ESSSettingsAlsBlockingOn:
       
   833                     error = iData->iCustomPhone->SetAlsBlocked( 
       
   834                         RMmCustomAPI::EActivateBlock );
       
   835                     break;
       
   836                 case ESSSettingsAlsBlockingOff:
       
   837                     error = iData->iCustomPhone->SetAlsBlocked( 
       
   838                         RMmCustomAPI::EDeactivateBlock );
       
   839                     break;
       
   840                 default:
       
   841                     error = KErrArgument;
       
   842                     break;
       
   843                 }
       
   844             break;
       
   845         case ESSSettingsDefaultCug:
       
   846             return KErrNotSupported;
       
   847         default:
       
   848             error = KErrArgument;
       
   849             break;
       
   850         }
       
   851 
       
   852     if ( error == KErrNone )
       
   853         {
       
   854         // If old request is still waiting, force it to end.
       
   855         if (( iData->iCallBackSetting != KErrBadDescriptor ) ||
       
   856             ( iData->iCallBackValue != KErrBadDescriptor ))
       
   857             {
       
   858             iData->iCallBack->Cancel();
       
   859             InformCallBack( this );
       
   860             }
       
   861 
       
   862         // activate call back
       
   863         iData->iCallBackSetting = aSetting;
       
   864         iData->iCallBackValue = aValue;
       
   865         iData->iCallBack->CallBack();
       
   866         }
       
   867     __SSSLOGSTRING("[SSS] <--RSSSettings::Set");
       
   868     return error;
       
   869     }
       
   870 
       
   871 // ---------------------------------------------------------
       
   872 // RSSSettings::HandleSIMChanged
       
   873 // ---------------------------------------------------------
       
   874 //
       
   875 EXPORT_C TInt RSSSettings::HandleSIMChanged()
       
   876     {
       
   877     __SSSLOGSTRING("[SSS]--> RSSSettings::HandleSIMChanged");
       
   878     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
   879     if ( !iData )
       
   880         {
       
   881         return KErrBadHandle;
       
   882         }
       
   883     TInt error = Set( ESSSettingsCug, iData->iCUGDefault );
       
   884     if ( error != KErrNone )
       
   885         {
       
   886         return error;
       
   887         }
       
   888     else
       
   889         {
       
   890         // Reset also the previous Cug value.
       
   891         error = ResetPreviousCugValue();
       
   892         if ( error != KErrNone )
       
   893             {
       
   894             return error;
       
   895             }
       
   896         }
       
   897 
       
   898     error = Set( ESSSettingsClir, ESSSettingsClirNetworkDefault );
       
   899     if ( error != KErrNone )
       
   900         {
       
   901         return error;
       
   902         }
       
   903 
       
   904     // Set als to primary only if it's stored in Shared Data.
       
   905     CSSSettingsAlsNotifier* als = iData->iNotifier->GetAlsHandler();
       
   906     if ( als )
       
   907         {
       
   908         TBool simAls(EFalse);
       
   909         TBool ppAls(EFalse);
       
   910         TBool cspAls(EFalse);
       
   911         TInt cspError(KErrNone);
       
   912         als->GetAlsSupport( ppAls, simAls, cspAls, cspError );
       
   913         __SSSLOGSTRING2("[SSS]     RSSSettings::HandleSIMChanged: ppAls: %d, simAls: %d", ppAls, simAls );
       
   914         if ( !simAls )
       
   915             {
       
   916             error = Set( ESSSettingsAls, ESSSettingsAlsPrimary );
       
   917             }
       
   918         }
       
   919     __SSSLOGSTRING("[SSS] <--RSSSettings::HandleSIMChanged");
       
   920     return error;
       
   921     }
       
   922 
       
   923 // ---------------------------------------------------------
       
   924 // RSSSettings::ExistsObserver
       
   925 // ---------------------------------------------------------
       
   926 //
       
   927 TBool RSSSettings::ExistsObserver( TSSSettingsSetting aSetting, 
       
   928                     MSSSettingsObserver& aObserver )
       
   929     {
       
   930     __SSSLOGSTRING("[SSS]--> RSSSettings::ExistsObserver");
       
   931     if ( !iData )
       
   932         {
       
   933         return EFalse;
       
   934         }
       
   935 
       
   936     __ASSERT_ALWAYS( aSetting <= KSSSettingsLastSetting, 
       
   937                     Panic( SSSettingsPanicInvalidRequest ) );
       
   938 
       
   939     TInt index = iData->iObservers[aSetting].Find( &aObserver );
       
   940     if ( index == KErrNotFound )
       
   941         {
       
   942         return EFalse;
       
   943         }
       
   944 
       
   945     __SSSLOGSTRING("[SSS] <--RSSSettings::ExistsObserver");
       
   946     return ETrue;
       
   947     }
       
   948 
       
   949 // ---------------------------------------------------------
       
   950 // RSSSettings::FindOneObserver
       
   951 // ---------------------------------------------------------
       
   952 //
       
   953 MSSSettingsObserver* RSSSettings::FindOneObserver() const
       
   954     {
       
   955     __SSSLOGSTRING("[SSS]--> RSSSettings::FindOneObserver");
       
   956     if ( iData == NULL )
       
   957         {
       
   958         return NULL;
       
   959         }
       
   960 
       
   961     for ( TInt settingIndex = 0 ; 
       
   962           settingIndex < iData->iObservers.Count() ; 
       
   963           settingIndex++ )
       
   964         {
       
   965         RSSSettingsObserverArray& array = iData->iObservers[settingIndex];
       
   966         if ( array.Count() )
       
   967             {
       
   968             return array[0];
       
   969             }
       
   970         }
       
   971 
       
   972     __SSSLOGSTRING("[SSS] <--RSSSettings::FindOneObserver");
       
   973     return NULL;
       
   974     }
       
   975 
       
   976 // ---------------------------------------------------------
       
   977 // RSSSettings::GetCug
       
   978 // ---------------------------------------------------------
       
   979 //
       
   980 TInt RSSSettings::GetCug( TInt& aValue ) const
       
   981     {
       
   982     __SSSLOGSTRING("[SSS]--> RSSSettings::GetCug");
       
   983     TInt value(KErrNone);
       
   984     TInt error(KErrNone);
       
   985     error = iData->iRepository->Get(
       
   986         KSettingsCUG,
       
   987         value );
       
   988 
       
   989     if ( error == KErrNone )
       
   990         {
       
   991         aValue = value;
       
   992         }
       
   993 
       
   994     __SSSLOGSTRING1("[SSS]     RSSSettings::GetCug: value: %d", value );
       
   995     __SSSLOGSTRING("[SSS] <--RSSSettings::GetCug");
       
   996     return error;
       
   997     }
       
   998 
       
   999 // ---------------------------------------------------------
       
  1000 // RSSSettings::GetDefaultCugL
       
  1001 // ---------------------------------------------------------
       
  1002 //
       
  1003 TInt RSSSettings::GetDefaultCugL( TInt& aValue ) const
       
  1004     {
       
  1005     __SSSLOGSTRING("[SSS]--> RSSSettings::GetDefaultCugL");
       
  1006     TInt value(0);
       
  1007     TBool useDefault(EFalse);
       
  1008     TInt error(KErrNone);
       
  1009     CRepository* repository = CRepository::NewL( KCRUidTelSrvVariation );
       
  1010     error = repository->Get(
       
  1011             KTelSrvVariationFlags,
       
  1012             value );
       
  1013     delete repository;
       
  1014     repository = NULL;
       
  1015     __SSSLOGSTRING1("[SSS]--> RSSSettings::GetDefaultCugL: value: %d", value);
       
  1016     
       
  1017     if ( error == KErrNotFound )
       
  1018         {
       
  1019         useDefault = ETrue;
       
  1020         }
       
  1021     else if ( error != KErrNone )
       
  1022         {
       
  1023         return error;
       
  1024         }
       
  1025 
       
  1026     if (( useDefault ) || 
       
  1027        !( value & KTelephonyLVFlagStandardCugIndexing ))
       
  1028         {
       
  1029         value = ESSSettingsCugDefault;
       
  1030         }
       
  1031     else
       
  1032         {
       
  1033         value = ESSSettingsAltCugDefault;
       
  1034         }
       
  1035     //Return directly (i.e. no shifting).
       
  1036     aValue = value;
       
  1037 
       
  1038     __SSSLOGSTRING1("[SSS]--> RSSSettings::GetDefaultCugL: value: %d", value);
       
  1039     __SSSLOGSTRING("[SSS] <--RSSSettings::GetDefaultCugL");
       
  1040     return error;
       
  1041     }
       
  1042 
       
  1043 // ---------------------------------------------------------
       
  1044 // RSSSettings::SetCug
       
  1045 // Reads existing CUG value from shared data. If new CUG
       
  1046 // value is between 1 and 32767 (or between 0 and 32767), 
       
  1047 // value is to shared data.
       
  1048 // Change also the previous cug to be the old current one.
       
  1049 // ---------------------------------------------------------
       
  1050 //
       
  1051 TInt RSSSettings::SetCug( const TInt aValue, const TInt aCugDefault ) const
       
  1052     {
       
  1053     __SSSLOGSTRING("[SSS]--> RSSSettings::SetCug");
       
  1054     TInt value(KErrNone);
       
  1055     TInt error(KErrNone);
       
  1056     error = iData->iRepository->Get( KSettingsCUG, value );
       
  1057     __SSSLOGSTRING1("[SSS]--> RSSSettings::SetCug: value: %d", value);
       
  1058     if ( error == KErrNone )
       
  1059         {
       
  1060         TInt previousCug(value);
       
  1061 
       
  1062         // CUG default must be saved as shared data default, to support
       
  1063         // different platform versions. Do not write default Cug again to 
       
  1064         // Central Repository, if already exists.
       
  1065         if ( ( aValue != aCugDefault ) ||
       
  1066              ( ( aValue == aCugDefault ) && ( previousCug != aCugDefault ) ) )
       
  1067             {
       
  1068             // Write the current cug value to Central Repository.
       
  1069             error = iData->iRepository->Set( KSettingsCUG, aValue );
       
  1070             __SSSLOGSTRING1("[SSS]--> RSSSettings::SetCug: aValue: %d", aValue);
       
  1071             if ( error == KErrNone )
       
  1072                 {
       
  1073                 if ( ( previousCug != ESSSettingsCugSuppress ) &&
       
  1074                      ( previousCug != aCugDefault ) )
       
  1075                     {
       
  1076                     // Write previous cug value to Central Repository.
       
  1077                     // Default or Suppress value can not be previousCug.
       
  1078                     error = iData->iRepository->Set( 
       
  1079                         KSettingsPreviousCUGIndex,
       
  1080                         previousCug );
       
  1081                     __SSSLOGSTRING1("[SSS]--> RSSSettings::SetCug: previousCug: %d", previousCug);
       
  1082                     }
       
  1083                 }
       
  1084             }
       
  1085         }
       
  1086     __SSSLOGSTRING("[SSS] <--RSSSettings::SetCug");
       
  1087     return error;
       
  1088     }
       
  1089 
       
  1090 // ---------------------------------------------------------
       
  1091 // RSSSettings::PreviousCugValue
       
  1092 // ---------------------------------------------------------
       
  1093 //
       
  1094 EXPORT_C TInt RSSSettings::PreviousCugValue( TInt& aPreviousValue )
       
  1095     {
       
  1096     __SSSLOGSTRING("[SSS]--> RSSSettings::PreviousCugValue");
       
  1097     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
  1098     if ( !iData )
       
  1099         {
       
  1100         return KErrBadHandle;
       
  1101         }
       
  1102     TInt value(KErrNone);
       
  1103     TInt error = iData->iRepository->Get( 
       
  1104         KSettingsPreviousCUGIndex,
       
  1105         value );
       
  1106 
       
  1107     if ( error == KErrNone )
       
  1108         {
       
  1109         aPreviousValue = value;
       
  1110         }
       
  1111 
       
  1112     __SSSLOGSTRING1("[SSS]--> RSSSettings::PreviousCugValue: value: %d", value);
       
  1113     __SSSLOGSTRING("[SSS] <--RSSSettings::PreviousCugValue");
       
  1114     return error;
       
  1115     }
       
  1116 
       
  1117 // ---------------------------------------------------------
       
  1118 // RSSSettings::ResetPreviousCugValue
       
  1119 // Reset PreviousCugValue
       
  1120 // ---------------------------------------------------------
       
  1121 //
       
  1122 EXPORT_C TInt RSSSettings::ResetPreviousCugValue()
       
  1123     {
       
  1124     __SSSLOGSTRING("[SSS]--> RSSSettings::ResetPreviousCugValue");
       
  1125     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
  1126     if ( !iData )
       
  1127         {
       
  1128         return KErrBadHandle;
       
  1129         }
       
  1130 
       
  1131     TInt value(KErrNone);
       
  1132     TInt error(KErrNone);
       
  1133     error = iData->iRepository->Get(
       
  1134         KSettingsPreviousCUGIndex,
       
  1135         value );
       
  1136     __SSSLOGSTRING1("[SSS]--> RSSSettings::PreviousCugValue; before setting: value: %d", value);
       
  1137     if ( error == KErrNone )
       
  1138         {
       
  1139         // Set cug to default one.
       
  1140         value = iData->iCUGDefault;
       
  1141         error = iData->iRepository->Set(
       
  1142             KSettingsPreviousCUGIndex,
       
  1143             value );
       
  1144         __SSSLOGSTRING1("[SSS]--> RSSSettings::PreviousCugValue; after setting: value: %d", value);
       
  1145         }
       
  1146     __SSSLOGSTRING("[SSS] <--RSSSettings::ResetPreviousCugValue");
       
  1147     return error;
       
  1148     }
       
  1149 
       
  1150 // ---------------------------------------------------------
       
  1151 // RSSSettings::HandleRefresh
       
  1152 // ---------------------------------------------------------
       
  1153 //
       
  1154 EXPORT_C TInt RSSSettings::HandleRefresh()
       
  1155     {
       
  1156     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
  1157     if ( !iData )
       
  1158         {
       
  1159         return KErrBadHandle;
       
  1160         }
       
  1161 
       
  1162     return iData->iNotifier->HandleRefresh();
       
  1163     }
       
  1164 
       
  1165 // ---------------------------------------------------------
       
  1166 // RSSSettings::IsValueValidCugIndex
       
  1167 // ---------------------------------------------------------
       
  1168 //
       
  1169 EXPORT_C TBool RSSSettings::IsValueValidCugIndex( const TInt& aValue ) const
       
  1170     {
       
  1171     __ASSERT_DEBUG( iData, Panic( SSSettingsPanicOpenNotDone ) );
       
  1172     if ( !iData )
       
  1173         {
       
  1174         return KErrBadHandle;
       
  1175         }
       
  1176 
       
  1177     TBool validCugIndex = !(( aValue > ESSSettingsCugMax ) ||
       
  1178                             ( aValue < ESSSettingsCugMin ));
       
  1179 
       
  1180     if ( iData->iCUGDefault != ESSSettingsCugDefault )
       
  1181         {
       
  1182         validCugIndex = validCugIndex || 
       
  1183                         aValue == ESSSettingsAltCugMin;
       
  1184         }
       
  1185     return validCugIndex;
       
  1186     }
       
  1187 
       
  1188 // ================= OTHER EXPORTED FUNCTIONS ==============
       
  1189 // Panic
       
  1190 GLREF_C void Panic( TSSSettingsPanic aPanic )
       
  1191     {
       
  1192     User::Panic( KPanicCat, aPanic );
       
  1193     }
       
  1194     
       
  1195 //  End of File