telutils/phoneparser/src/CPhoneParserFeatures.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     1 /*
       
     2 * Copyright (c) 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:  Encapsulation of external dependencies of Phone Parser.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CPhoneParserFeatures.h"
       
    21 #include    <featmgr.h>
       
    22 #include    <centralrepository.h>
       
    23 #include    <telservicesvariant.hrh>
       
    24 #include    <telservicesinternalcrkeys.h>
       
    25 #include    <CPhCltEmergencyCall.h>
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // CPhoneParserFeatures::CPhoneParserFeatures
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CPhoneParserFeatures::CPhoneParserFeatures()
       
    38     {
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CPhoneParserFeatures::ConstructL
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CPhoneParserFeatures::ConstructL()
       
    46     {
       
    47     // Read local variation settings.
       
    48     FeatureManager::InitializeLibL();
       
    49     iEmergencyCall = CPhCltEmergencyCall::NewL( this );
       
    50     iRepository = CRepository::NewL( KCRUidTelSrvVariation );
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CPhoneParserFeatures::InstanceL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CPhoneParserFeatures* CPhoneParserFeatures::InstanceL()
       
    58     {
       
    59     CPhoneParserFeatures* self =
       
    60         static_cast<CPhoneParserFeatures*>( Dll::Tls() );
       
    61 
       
    62     if( !self )
       
    63         {
       
    64         self = new (ELeave) CPhoneParserFeatures;
       
    65         CleanupStack::PushL( self );
       
    66         self->ConstructL();
       
    67         CleanupStack::Pop( self );
       
    68         Dll::SetTls( self );
       
    69         }
       
    70 
       
    71     return self;
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CPhoneParserFeatures::Instance
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CPhoneParserFeatures* CPhoneParserFeatures::Instance()
       
    79     {
       
    80     CPhoneParserFeatures* self( NULL );
       
    81     TRAPD( err, self = InstanceL() );
       
    82     return err ? NULL : self;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CPhoneParserFeatures::Free
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CPhoneParserFeatures::Free()
       
    90     {
       
    91     CPhoneParserFeatures* self =
       
    92         static_cast<CPhoneParserFeatures*>( Dll::Tls() );
       
    93 
       
    94     if( self )
       
    95         {
       
    96         delete self;
       
    97         self = NULL;
       
    98         Dll::SetTls( NULL );
       
    99         }
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CPhoneParserFeatures::SetInstance
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 #ifdef __WINS__
       
   107 void CPhoneParserFeatures::SetInstance( 
       
   108     CPhoneParserFeatures* aStub )
       
   109     {
       
   110     Dll::SetTls( aStub );
       
   111     }
       
   112 #endif // __WINS__
       
   113 // -----------------------------------------------------------------------------
       
   114 // CPhoneParserFeatures::~CPhoneParserFeatures
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 CPhoneParserFeatures::~CPhoneParserFeatures()
       
   118     {
       
   119     delete iEmergencyCall;
       
   120     delete iRepository;
       
   121     FeatureManager::UnInitializeLib();
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CPhoneParserFeatures::HandleEmergencyDialL
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CPhoneParserFeatures::HandleEmergencyDialL( const TInt /*aStatus*/ )
       
   129     {
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CPhoneParserFeatures::LifeTimerEnabled
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TBool CPhoneParserFeatures::LifeTimerEnabled()
       
   137     {
       
   138     return Instance() ? 
       
   139         Instance()->GetTelephoneVariant() & KTelSrvLVFlagLifeTimer : EFalse;
       
   140     }
       
   141 
       
   142 // -----------------------------------------------------------------------------
       
   143 // CPhoneParserFeatures::TwoDigitCallingEnabled
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 TBool CPhoneParserFeatures::TwoDigitCallingEnabled()
       
   147     {
       
   148     return Instance() ? 
       
   149         Instance()->GetTelephoneVariant() & KTelSrvLVFlagTwoDigitDial : 
       
   150         EFalse;
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CPhoneParserFeatures::IsZeroDialEnabled
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 TBool CPhoneParserFeatures::IsZeroDialEnabled()
       
   158     {
       
   159     return Instance() ? 
       
   160         Instance()->GetTelephoneVariant() & KTelSrvLVFlagZeroDial : EFalse;
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CPhoneParserFeatures::IsEmergencyNumber
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 TBool CPhoneParserFeatures::IsEmergencyNumber( 
       
   168     const TDesC& aNumber, 
       
   169     TDes& aEmergencyNumber )
       
   170     {
       
   171     return Instance() ? 
       
   172         Instance()->IsEmergencyPhoneNumber( aNumber, aEmergencyNumber ) : EFalse; 
       
   173     }    
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CPhoneParserFeatures::IsItEmergencyNumber
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 TBool CPhoneParserFeatures::IsEmergencyPhoneNumber( 
       
   180     const TDesC& aNumber, 
       
   181     TDes& aEmergencyNumber )
       
   182     {
       
   183     TBool isEmergency;
       
   184 
       
   185     TInt error = iEmergencyCall->IsEmergencyPhoneNumber( 
       
   186         aNumber, 
       
   187         aEmergencyNumber, 
       
   188         isEmergency );
       
   189             
       
   190     return error ? EFalse : isEmergency;
       
   191     }    
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CPhoneParserFeatures::GetTelephoneVariant
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 TInt CPhoneParserFeatures::GetTelephoneVariant()
       
   198     {
       
   199     TInt telephoneVariant;
       
   200     TInt err = iRepository->Get( KTelSrvVariationFlags, telephoneVariant );
       
   201     return err == KErrNone ? telephoneVariant : 0;
       
   202     }
       
   203 
       
   204 // -----------------------------------------------------------------------------
       
   205 // CPhoneParserFeatures::FeatureSupported
       
   206 // -----------------------------------------------------------------------------
       
   207 // 
       
   208 TBool CPhoneParserFeatures::FeatureSupported( TInt aFeature )
       
   209     {
       
   210     return Instance() ? Instance()->IsFeatureSupported( aFeature ) : EFalse;
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CPhoneParserFeatures::IsFeatureSupported
       
   215 // -----------------------------------------------------------------------------
       
   216 // 
       
   217 TBool CPhoneParserFeatures::IsFeatureSupported( TInt aFeature )
       
   218     {
       
   219     return FeatureManager::FeatureSupported( aFeature );
       
   220     }
       
   221 
       
   222 //  End of File