telutils/phoneparser/src/CPhoneParserFeatures.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     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::TwoDigitCallingEnabled
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TBool CPhoneParserFeatures::TwoDigitCallingEnabled()
       
   137     {
       
   138     return Instance() ? 
       
   139         Instance()->GetTelephoneVariant() & KTelSrvLVFlagTwoDigitDial : 
       
   140         EFalse;
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CPhoneParserFeatures::IsZeroDialEnabled
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 TBool CPhoneParserFeatures::IsZeroDialEnabled()
       
   148     {
       
   149     return Instance() ? 
       
   150         Instance()->GetTelephoneVariant() & KTelSrvLVFlagZeroDial : EFalse;
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // CPhoneParserFeatures::IsEmergencyNumber
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 TBool CPhoneParserFeatures::IsEmergencyNumber( 
       
   158     const TDesC& aNumber, 
       
   159     TDes& aEmergencyNumber )
       
   160     {
       
   161     return Instance() ? 
       
   162         Instance()->IsEmergencyPhoneNumber( aNumber, aEmergencyNumber ) : EFalse; 
       
   163     }    
       
   164 
       
   165 // -----------------------------------------------------------------------------
       
   166 // CPhoneParserFeatures::IsItEmergencyNumber
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 TBool CPhoneParserFeatures::IsEmergencyPhoneNumber( 
       
   170     const TDesC& aNumber, 
       
   171     TDes& aEmergencyNumber )
       
   172     {
       
   173     TBool isEmergency;
       
   174 
       
   175     TInt error = iEmergencyCall->IsEmergencyPhoneNumber( 
       
   176         aNumber, 
       
   177         aEmergencyNumber, 
       
   178         isEmergency );
       
   179             
       
   180     return error ? EFalse : isEmergency;
       
   181     }    
       
   182 
       
   183 // -----------------------------------------------------------------------------
       
   184 // CPhoneParserFeatures::GetTelephoneVariant
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 TInt CPhoneParserFeatures::GetTelephoneVariant()
       
   188     {
       
   189     TInt telephoneVariant;
       
   190     TInt err = iRepository->Get( KTelSrvVariationFlags, telephoneVariant );
       
   191     return err == KErrNone ? telephoneVariant : 0;
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CPhoneParserFeatures::FeatureSupported
       
   196 // -----------------------------------------------------------------------------
       
   197 // 
       
   198 TBool CPhoneParserFeatures::FeatureSupported( TInt aFeature )
       
   199     {
       
   200     return Instance() ? Instance()->IsFeatureSupported( aFeature ) : EFalse;
       
   201     }
       
   202 
       
   203 // -----------------------------------------------------------------------------
       
   204 // CPhoneParserFeatures::IsFeatureSupported
       
   205 // -----------------------------------------------------------------------------
       
   206 // 
       
   207 TBool CPhoneParserFeatures::IsFeatureSupported( TInt aFeature )
       
   208     {
       
   209     return FeatureManager::FeatureSupported( aFeature );
       
   210     }
       
   211 
       
   212 //  End of File