profilesservices/ProfileEngine/WrapperSrc/CProEngProfileActivationDelegate.cpp
changeset 0 8c5d936e5675
child 8 f62c3a3d66b8
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     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:  Implementation of CProEngProfileActivationDelegate.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CProEngProfileActivationDelegate.h"
       
    22 #include    <centralrepository.h>
       
    23 #include    <MProEngProfileActivationObserver.h>
       
    24 #include    "ProfileEnginePrivatePSKeys.h"  // KProEngActiveProfileChanged
       
    25 #include    "ProfileEngineSDKCRKeys.h" // KCRUidProfileEngine etc.
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CProEngProfileActivationDelegate::CProEngProfileActivationDelegate
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CProEngProfileActivationDelegate::CProEngProfileActivationDelegate(
       
    34         MProEngProfileActivationObserver& aObserver )
       
    35     : CProEngPubSubObserverBase( KProEngActiveProfileChanged ),
       
    36       iObserver( aObserver )
       
    37     {
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CProEngProfileActivationDelegate::ConstructL
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CProEngProfileActivationDelegate::ConstructL()
       
    45     {
       
    46     iRepository = CRepository::NewL( KCRUidProfileEngine );
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CProEngProfileActivationDelegate::NewL
       
    51 // Two-phased constructor.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CProEngProfileActivationDelegate* CProEngProfileActivationDelegate::NewL(
       
    55         MProEngProfileActivationObserver& aObserver )
       
    56     {
       
    57     CProEngProfileActivationDelegate* self =
       
    58         new ( ELeave ) CProEngProfileActivationDelegate( aObserver );
       
    59 
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop( self );
       
    63 
       
    64     return self;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CProEngProfileActivationDelegate::~CProEngProfileActivationDelegate
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CProEngProfileActivationDelegate::~CProEngProfileActivationDelegate()
       
    72     {
       
    73     delete iRepository;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CProEngProfileActivationDelegate::NotifyObserverL
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CProEngProfileActivationDelegate::NotifyObserverL()
       
    81     {
       
    82     // Read the id of the current active profile and pass it to the observer
       
    83     TInt profileId( 0 );
       
    84     User::LeaveIfError( iRepository->Get( KProEngActiveProfile, profileId ) );
       
    85     iObserver.HandleProfileActivatedL( profileId );
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CProEngProfileActivationDelegate::NotifyError
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CProEngProfileActivationDelegate::NotifyError( TInt aError )
       
    93     {
       
    94     iObserver.HandleProfileActivationNotificationError( aError );
       
    95     }
       
    96 
       
    97 //  End of File
       
    98