phoneengine/PhoneCntFinder/src/Misc/CPhCntProfileEngineImpl.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2002 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 Profile information retrieval.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "CPhCntProfileEngineImpl.h"
       
    21 #include    <MProfile.h>
       
    22 
       
    23 // CONSTANTS
       
    24 _LIT( KPhCntProfilePanic, "PhCntProfile" );
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CPhCntProfileEngineImpl::NewL
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CPhCntProfileEngineImpl* CPhCntProfileEngineImpl::NewL()
       
    33     {
       
    34     CPhCntProfileEngineImpl* self = 
       
    35         new ( ELeave ) CPhCntProfileEngineImpl;
       
    36     
       
    37     return self;
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CPhCntProfileEngineImpl::~CPhCntProfileEngineImpl
       
    42 // -----------------------------------------------------------------------------
       
    43 //      
       
    44 CPhCntProfileEngineImpl::~CPhCntProfileEngineImpl()
       
    45     {
       
    46     if ( iProfile )
       
    47         {
       
    48         iProfile->Release();
       
    49         iProfile = NULL;
       
    50         }
       
    51 
       
    52     if ( iEngine )
       
    53         {
       
    54         iEngine->Release();
       
    55         iEngine = NULL;
       
    56         }
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CPhCntProfileEngineImpl::RefreshL
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CPhCntProfileEngineImpl::RefreshL()
       
    64     {
       
    65     if ( !iEngine )
       
    66         {
       
    67         iEngine = CreateProfileEngineL();
       
    68         }
       
    69 
       
    70     MProfile* profile = iEngine->ActiveProfileL();
       
    71 
       
    72     if ( iProfile )
       
    73         {
       
    74         iProfile->Release();
       
    75         iProfile = NULL;
       
    76         }
       
    77     iProfile = profile;
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CPhCntProfileEngineImpl::HasProfile
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TBool CPhCntProfileEngineImpl::HasProfile() const
       
    85     {
       
    86     return iProfile != NULL;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CPhCntProfileEngineImpl::Profile
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 MProfile& CPhCntProfileEngineImpl::Profile()
       
    94     {
       
    95     __ASSERT_ALWAYS( iProfile, User::Panic( KPhCntProfilePanic, 0 ) );
       
    96     return *iProfile;
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CPhCntProfileEngineImpl::SetActiveProfileL
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 void CPhCntProfileEngineImpl::SetActiveProfileL( const TInt aProfileId )
       
   104     {
       
   105     if ( !iEngine )
       
   106         {
       
   107         iEngine = CreateProfileEngineL();
       
   108         }
       
   109 
       
   110     iEngine->SetActiveProfileL( aProfileId );
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CPhCntProfileEngineImpl::IsFeatureSupported
       
   115 //
       
   116 // (other items were commented in a header).
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 TBool CPhCntProfileEngineImpl::IsFeatureSupported(
       
   120         TProfileFeatureId aFeatureId ) const
       
   121     {
       
   122     return iEngine->IsFeatureSupported( aFeatureId );
       
   123     }
       
   124 
       
   125 //  End of File