convergedcallengine/csplugin/src/cspsssettingshandler.cpp
branchRCL_3
changeset 20 987c9837762f
parent 0 ff3b6d0fd310
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  implementation of CSPSsSettingsHandler class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "cspsssettingshandler.h"
       
    21 #include "csplogger.h"
       
    22 #include "csppanic.pan"
       
    23 
       
    24 #include <etelmm.h>
       
    25 #include <mccpssobserver.h>
       
    26 
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CSPSsSettingsHandler::CSPSsSettingsHandler
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CSPSsSettingsHandler::CSPSsSettingsHandler( const MCCPSsObserver& aObs ) : 
       
    35         iObserver( const_cast<MCCPSsObserver&>(aObs) )
       
    36     {
       
    37     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::CSPSsSettingsHandler" );
       
    38     } 
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CSPSsSettingsHandler::ConstructL
       
    42 // Symbian 2nd phase constructor can leave.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CSPSsSettingsHandler::ConstructL()
       
    46     {
       
    47     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::ConstructL <" );
       
    48     User::LeaveIfError( iSSSettings.Open() );
       
    49     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::ConstructL Reg " );
       
    50     TInt errorCode = iSSSettings.Register( ESSSettingsAls, *this );
       
    51     CSPLOGSTRING2( CSPINT, 
       
    52             "CSPSsSettingsHandler::ConstructL > iSSSettings.Register, errorCode: %d",
       
    53             errorCode );
       
    54     if ( errorCode == KErrNotSupported )
       
    55         {
       
    56         CSPLOGSTRING( CSPINT, "CSPSsSettingsHandler::ConstructL, ALS not supported" );
       
    57         }
       
    58     else if ( errorCode == KErrNotReady )
       
    59         {
       
    60         // Try again after idle
       
    61         iRegisterAlsNofify = CIdle::NewL( CActive::EPriorityHigh );
       
    62         RegisterAfterIdle();
       
    63         }    
       
    64       
       
    65     RMobilePhone::TMobilePhoneALSLine alsLine;
       
    66     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::ConstructL GetALS" );
       
    67     GetALSLineL( alsLine );
       
    68     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::ConstructL Notify " );
       
    69     iObserver.NotifyCurrentActiveALSLine( (TInt) alsLine );
       
    70        
       
    71     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::ConstructL >" );
       
    72     } 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CSPSsSettingsHandler::NewL
       
    76 // Two-phased constructor.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 CSPSsSettingsHandler* CSPSsSettingsHandler::NewL( const MCCPSsObserver& aObs )
       
    80     {
       
    81     CSPSsSettingsHandler* self = new ( ELeave ) CSPSsSettingsHandler( aObs );
       
    82     CleanupStack::PushL( self );
       
    83     self->ConstructL( );
       
    84     CleanupStack::Pop( self );
       
    85     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::NewL" );
       
    86     return self;
       
    87     } 
       
    88 
       
    89 // Destructor
       
    90 CSPSsSettingsHandler::~CSPSsSettingsHandler()
       
    91     {
       
    92     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::~CSPSsSettingsHandler <" );
       
    93     iSSSettings.Close();
       
    94     CSPLOGSTRING( CSPOBJECT, "CSPSsSettingsHandler::~CSPSsSettingsHandler >" );
       
    95     if ( iRegisterAlsNofify )
       
    96         {
       
    97         delete iRegisterAlsNofify;
       
    98         }
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CSPSsSettingsHandler::GetALSLineL
       
   103 // Sends synchronous request to get the ALS line and returns handle to access 
       
   104 // the status.
       
   105 // (other items were commented in a header).
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CSPSsSettingsHandler::GetALSLineL(
       
   109         RMobilePhone::TMobilePhoneALSLine& aALSLine )
       
   110     {
       
   111     TInt value;
       
   112     User::LeaveIfError( iSSSettings.Get( ESSSettingsAls, value ) );
       
   113 
       
   114     TSSSettingsAlsValue alsValue = 
       
   115         static_cast< TSSSettingsAlsValue > ( value );
       
   116 
       
   117     switch( alsValue )
       
   118         {
       
   119         case ESSSettingsAlsNotSupported:
       
   120             aALSLine = RMobilePhone::EAlternateLineNotAvailable;
       
   121             break;
       
   122         case ESSSettingsAlsPrimary: 
       
   123             aALSLine = RMobilePhone::EAlternateLinePrimary;       
       
   124             break;
       
   125         case ESSSettingsAlsAlternate:
       
   126             aALSLine = RMobilePhone::EAlternateLineAuxiliary;
       
   127             break;
       
   128         default:
       
   129             break;
       
   130         }
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CSPSsSettingsHandler::SetALSLineL
       
   135 // Sends synchronous request to set the ALS line and returns handle to access 
       
   136 // the status.
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CSPSsSettingsHandler::SetALSLineL(
       
   140         RMobilePhone::TMobilePhoneALSLine& aALSLine )
       
   141     {
       
   142     TSSSettingsAlsValue alsValue = 
       
   143         static_cast<TSSSettingsAlsValue> ( aALSLine );
       
   144         
       
   145     switch( aALSLine )
       
   146         {
       
   147         case RMobilePhone::EAlternateLineUnknown:
       
   148         case RMobilePhone::EAlternateLineNotAvailable:
       
   149             alsValue = ESSSettingsAlsNotSupported;
       
   150             break;
       
   151         case RMobilePhone::EAlternateLinePrimary: 
       
   152             alsValue = ESSSettingsAlsPrimary;       
       
   153             break;
       
   154         case RMobilePhone::EAlternateLineAuxiliary:
       
   155             alsValue = ESSSettingsAlsAlternate;
       
   156             break;
       
   157         default:
       
   158             CSPLOGSTRING( CSPINT,
       
   159                 "CSPSsSettingsHandler::SetALSLineL: Not valid value" );
       
   160             __ASSERT_DEBUG( EFalse, Panic( ECSPPanicInvalidRequest ) );
       
   161             break;
       
   162         }
       
   163     User::LeaveIfError( iSSSettings.Set( ESSSettingsAls, alsValue ) );
       
   164     } 
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CSPSsSettingsHandler::GetClirL
       
   168 // Sends synchronous request to get the CLIR value and returns handle to access 
       
   169 // the status.
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 void CSPSsSettingsHandler::GetClirL(
       
   173         RMobileCall::TMobileCallIdRestriction& aClir )
       
   174     {
       
   175     TInt value;
       
   176     User::LeaveIfError( iSSSettings.Get( ESSSettingsClir, value ) );
       
   177 
       
   178     TSSSettingsClirValue clir = 
       
   179         static_cast<TSSSettingsClirValue> ( value );
       
   180     CSPLOGSTRING2( CSPERROR,
       
   181         "CSPSsSettingsHandler::GetClirL, clir: %d", clir );
       
   182         
       
   183     switch( clir )
       
   184         {
       
   185         case ESSSettingsClirNetworkDefault:
       
   186             aClir = RMobileCall::EIdRestrictDefault;
       
   187             break;
       
   188         case ESSSettingsClirExplicitInvoke: 
       
   189             aClir = RMobileCall::EDontSendMyId;
       
   190             break;
       
   191         case ESSSettingsClirExplicitSuppress:
       
   192             aClir = RMobileCall::ESendMyId; 
       
   193             break;
       
   194         default:
       
   195             CSPLOGSTRING2( CSPERROR,
       
   196                 "CSPSsSettingsHandler::GetClirL, NOT VALID aClir: %d", aClir );
       
   197             __ASSERT_DEBUG( EFalse, Panic( ECSPPanicInvalidRequest ) );
       
   198             break;
       
   199         }
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CSPSsSettingsHandler::GetCugL
       
   204 // Sends synchronous request to get the CUG index and returns handle to access 
       
   205 // the status.
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 void CSPSsSettingsHandler::GetCugL( TInt& aCugIndex )
       
   209     {
       
   210     CSPLOGSTRING2( CSPINT,
       
   211         "CSPSsSettingsHandler::GetCugL, aCugIndex: %d", aCugIndex );
       
   212     User::LeaveIfError( iSSSettings.Get( ESSSettingsCug, aCugIndex ) );
       
   213     }
       
   214     
       
   215 // -----------------------------------------------------------------------------
       
   216 // CSPSsSettingsHandler::GetDefaultCugL
       
   217 // Sends synchronous request to get the default CUG index 
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 void CSPSsSettingsHandler::GetDefaultCugL( TInt& aDefCug )
       
   221     {
       
   222     User::LeaveIfError( iSSSettings.Get( ESSSettingsDefaultCug, aDefCug ) );
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CSPSsSettingsHandler::IsValueValidCugIndex
       
   227 // Sends synchronous request to check the CUG index 
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 TBool CSPSsSettingsHandler::IsValueValidCugIndex( const TInt& aValue ) const
       
   231     {
       
   232     return iSSSettings.IsValueValidCugIndex( aValue );
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // CSPSsSettingsHandler::PhoneSettingChanged
       
   237 // ---------------------------------------------------------
       
   238 //
       
   239 void CSPSsSettingsHandler::PhoneSettingChanged( 
       
   240         TSSSettingsSetting aSetting, 
       
   241         TInt aNewValue )
       
   242     {
       
   243     CSPLOGSTRING2( CSPINT,
       
   244         "CSPSsSettingsHandler::PhoneSettingChanged, aNewValue : %d",
       
   245         aNewValue );
       
   246     if ( aSetting == ESSSettingsAls )
       
   247         {
       
   248         TSSSettingsAlsValue alsValue = 
       
   249             static_cast< TSSSettingsAlsValue > ( aNewValue );
       
   250     
       
   251         RMobilePhone::TMobilePhoneALSLine 
       
   252             alsLine( RMobilePhone::EAlternateLineUnknown );
       
   253 
       
   254         switch( alsValue )
       
   255             {
       
   256             case ESSSettingsAlsNotSupported:
       
   257                 alsLine = RMobilePhone::EAlternateLineNotAvailable;
       
   258                 break;
       
   259             case ESSSettingsAlsPrimary: 
       
   260                 alsLine = RMobilePhone::EAlternateLinePrimary;       
       
   261                 break;
       
   262             case ESSSettingsAlsAlternate:
       
   263                 alsLine = RMobilePhone::EAlternateLineAuxiliary;
       
   264                 break;
       
   265             default:
       
   266                 break;
       
   267             }
       
   268         
       
   269         iObserver.NotifyCurrentActiveALSLine( (TInt) alsLine );
       
   270         }
       
   271     }
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CSPSsSettingsHandler::RegisterAfterIdle
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 void CSPSsSettingsHandler::RegisterAfterIdle()
       
   278     {
       
   279     CSPLOGSTRING( CSPINT, "CSPSsSettingsHandler::RegisterAfterIdle" );
       
   280     if ( !iRegisterAlsNofify->IsActive() )
       
   281         {
       
   282         CSPLOGSTRING( CSPINT, "CSPSsSettingsHandler::RegisterAfterIdle > iRegisterAlsNofify->Star" );
       
   283         iRegisterAlsNofify->Start( 
       
   284             TCallBack( CIdleCallBack, this ) );
       
   285         }
       
   286     }
       
   287     
       
   288 // -----------------------------------------------------------------------------
       
   289 // CSProvider::CIdleCallBack
       
   290 // -----------------------------------------------------------------------------
       
   291 //
       
   292 TInt CSPSsSettingsHandler::CIdleCallBack( TAny* aAny )
       
   293     {
       
   294     CSPLOGSTRING( CSPINT, "CSPSsSettingsHandler::CIdleCallBack" );
       
   295     static_cast< CSPSsSettingsHandler* >( aAny )->Register();
       
   296 
       
   297     return KErrNone;    
       
   298     }   
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CSProvider::Register
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 void CSPSsSettingsHandler::Register()
       
   305     {
       
   306     CSPLOGSTRING( CSPINT, "CSPSsSettingsHandler::Register" );
       
   307     TInt errorCode( KErrNotReady );
       
   308     
       
   309     errorCode = iSSSettings.Register( ESSSettingsAls, *this );
       
   310     CSPLOGSTRING2( CSPINT, 
       
   311         "CSPSsSettingsHandler::Register > iSSSettings.Register, errorCode: %d",
       
   312         errorCode );
       
   313 
       
   314     if ( errorCode == KErrNotReady )
       
   315         {
       
   316         // Try again
       
   317         RegisterAfterIdle();
       
   318         }
       
   319     }  
       
   320 
       
   321 //  End of file