profilesservices/ProfileEngine/WrapperSrc/CProEngProfileActivationDelegate.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 15:29:50 +0300
branchRCL_3
changeset 24 8ee96d21d9bf
parent 8 f62c3a3d66b8
child 25 7e0eff37aedb
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Implementation of CProEngProfileActivationDelegate.
*
*/



// INCLUDE FILES
#include    "CProEngProfileActivationDelegate.h"
#include    <centralrepository.h>
#include    <MProEngProfileActivationObserver.h>
#include    <ProfileEnginePrivatePSKeys.h>  // KProEngActiveProfileChanged
#include    <ProfileEngineSDKCRKeys.h> // KCRUidProfileEngine etc.

// ============================ MEMBER FUNCTIONS ===============================

// -----------------------------------------------------------------------------
// CProEngProfileActivationDelegate::CProEngProfileActivationDelegate
// -----------------------------------------------------------------------------
//
CProEngProfileActivationDelegate::CProEngProfileActivationDelegate(
        MProEngProfileActivationObserver& aObserver )
    : CProEngPubSubObserverBase( KProEngActiveProfileChanged ),
      iObserver( aObserver )
    {
    }

// -----------------------------------------------------------------------------
// CProEngProfileActivationDelegate::ConstructL
// -----------------------------------------------------------------------------
//
void CProEngProfileActivationDelegate::ConstructL()
    {
    iRepository = CRepository::NewL( KCRUidProfileEngine );
    }

// -----------------------------------------------------------------------------
// CProEngProfileActivationDelegate::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CProEngProfileActivationDelegate* CProEngProfileActivationDelegate::NewL(
        MProEngProfileActivationObserver& aObserver )
    {
    CProEngProfileActivationDelegate* self =
        new ( ELeave ) CProEngProfileActivationDelegate( aObserver );

    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop( self );

    return self;
    }

// -----------------------------------------------------------------------------
// CProEngProfileActivationDelegate::~CProEngProfileActivationDelegate
// -----------------------------------------------------------------------------
//
CProEngProfileActivationDelegate::~CProEngProfileActivationDelegate()
    {
    delete iRepository;
    }

// -----------------------------------------------------------------------------
// CProEngProfileActivationDelegate::NotifyObserverL
// -----------------------------------------------------------------------------
//
void CProEngProfileActivationDelegate::NotifyObserverL()
    {
    // Read the id of the current active profile and pass it to the observer
    TInt profileId( 0 );
    User::LeaveIfError( iRepository->Get( KProEngActiveProfile, profileId ) );
    iObserver.HandleProfileActivatedL( profileId );
    }

// -----------------------------------------------------------------------------
// CProEngProfileActivationDelegate::NotifyError
// -----------------------------------------------------------------------------
//
void CProEngProfileActivationDelegate::NotifyError( TInt aError )
    {
    iObserver.HandleProfileActivationNotificationError( aError );
    }

//  End of File