phoneclientserver/phoneserver/Src/Standard/CPhSrvEmergencyNumberManager.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Emergency Number Manager.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cphsrvemergencynumbermanager.h" 
       
    22 #include "mphsrvphoneinterface.h" 
       
    23 #include "phsrvdebuginfo.h" 
       
    24 #include <cemergencynumberpolicy.h> 
       
    25 
       
    26 // CONSTANTS
       
    27 _LIT(KPhSrvDosEnPolicyLibName, "dosenpolicy.dll");  // DOS emergency number policy
       
    28 _LIT(KPhSrvSosEnPolicyLibName, "sosenpolicy.dll");  // SOS emergency number policy
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CPhSrvEmergencyNumberManager::CPhSrvEmergencyNumberManager()
       
    34 // 
       
    35 // C++ constructor
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CPhSrvEmergencyNumberManager::CPhSrvEmergencyNumberManager(
       
    39     MPhSrvPhoneInterface& aPhone ) : iPhone( aPhone )
       
    40     {
       
    41     }
       
    42 
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CPhSrvEmergencyNumberManager::~CPhSrvEmergencyNumberManager()
       
    46 // 
       
    47 // C++ destructor
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CPhSrvEmergencyNumberManager::~CPhSrvEmergencyNumberManager()
       
    51     {
       
    52     delete iEmergencyNumberPolicy;    
       
    53     iEnPolicyLib.Close();
       
    54     }
       
    55 
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CPhSrvEmergencyNumberManager::ConstructL()
       
    59 // 
       
    60 // Symbian OS 2nd phase constructor
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CPhSrvEmergencyNumberManager::ConstructL( TBool aIsDosEnPolicy )
       
    64     {
       
    65     if ( aIsDosEnPolicy )
       
    66         {
       
    67         // Dynamically load Dos emergency DLL.
       
    68         User::LeaveIfError( iEnPolicyLib.Load( KPhSrvDosEnPolicyLibName ) );
       
    69         }
       
    70     else
       
    71         {
       
    72         // Dynamically load Sos emergency DLL.
       
    73         User::LeaveIfError( iEnPolicyLib.Load( KPhSrvSosEnPolicyLibName ) );
       
    74         }
       
    75 
       
    76     if ( iEnPolicyLib.Type()[1] != KEnPolicyUid )
       
    77         {
       
    78         iEnPolicyLib.Close();
       
    79         User::Leave( KErrNotFound );
       
    80         }
       
    81 
       
    82     TLibraryFunction entry=iEnPolicyLib.Lookup(1);
       
    83     CEmergencyNumberPolicy* enPolicy = ( CEmergencyNumberPolicy* ) entry();    
       
    84     CleanupStack::PushL( enPolicy );
       
    85     enPolicy->ConstructL( iPhone.PhSrvETelServer() );
       
    86     CleanupStack::Pop();
       
    87 
       
    88     iEmergencyNumberPolicy = enPolicy;
       
    89 
       
    90     }
       
    91 
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CPhSrvEmergencyNumberManager::EmergencyNumberManagerIsEmergencyNumberL()
       
    95 // 
       
    96 // Enquire as to whether the specified number would result
       
    97 // in an emergency call being placed.
       
    98 //
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 /*****************************************************
       
   102 *   Series 60 Customer / ETel
       
   103 *   Series 60  ETel API
       
   104 *****************************************************/
       
   105 /*****************************************************
       
   106 *   Series 60 Customer / DOS
       
   107 *   Needs customer DOS implementation
       
   108 *****************************************************/
       
   109 TBool CPhSrvEmergencyNumberManager::EmergencyNumberManagerIsEmergencyNumberL(
       
   110     TDes& aNumber, 
       
   111     TPhCltEmergencyNumberQueryMode aMode 
       
   112     )
       
   113     {
       
   114     _DPRINT( 4, "PSrv.EN.IsEmergency.begin" );   // debug print
       
   115 
       
   116     // check length of number, it must be between 1..6
       
   117     if ( aNumber.Length() < 1 )
       
   118         {
       
   119         // Empty. No further checking needed.
       
   120         return EFalse;
       
   121         }
       
   122     
       
   123     TBool isEmergencyNumber = EFalse;
       
   124     TInt err = 
       
   125         iEmergencyNumberPolicy->IsEmergencyNumber ( 
       
   126                             static_cast< TPhCltTelephoneNumber& >(aNumber),
       
   127                             aMode, 
       
   128                             isEmergencyNumber );
       
   129 
       
   130     if ( err != KErrNone )
       
   131         {
       
   132         // error in checking
       
   133         isEmergencyNumber = EFalse;
       
   134         }
       
   135 
       
   136     return isEmergencyNumber;
       
   137     }
       
   138 
       
   139 // End of File.