profilesservices/ProfileEngine/WrapperSrc/CProEngProfileActivationDelegate.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 23:06:10 +0200
branchRCL_3
changeset 8 f62c3a3d66b8
parent 0 8c5d936e5675
child 24 8ee96d21d9bf
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* 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