phoneapp/phoneuiutils/src/cphonecenrepeventhandler.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Mar 2010 09:28:42 +0200
changeset 21 92ab7f8d0eab
parent 0 5f000ab63145
child 51 f39ed5e045e0
child 62 5266b1f337bd
permissions -rw-r--r--
Revision: 201007 Kit: 201011

/*
* Copyright (c) 2005 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:  see class description.
 *
*/


// INCLUDE FILES
#include "phonelogger.h"
#include "phoneui.pan"

#include "cphonecenrepeventhandler.h"
#include "cphonecenrepproxy.h"

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

// ----------------------------------------------------------------------------
// CPhoneCenRepEventHandler* CPhoneCenRepEventHandler::NewL()
// ----------------------------------------------------------------------------

CPhoneCenRepEventHandler* CPhoneCenRepEventHandler::NewL( 
    const TUid& aUid )
    {       
    CPhoneCenRepEventHandler* self = 
        new ( ELeave ) CPhoneCenRepEventHandler( aUid );

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

    return self;
    }

// ----------------------------------------------------------------------------
// CPhoneCenRepEventHandler::CPhoneCenRepEventHandler
// ----------------------------------------------------------------------------

CPhoneCenRepEventHandler::CPhoneCenRepEventHandler( const TUid& aUid ) :
    iUid( aUid )
    {
    }

// ----------------------------------------------------------------------------
// CPhoneCenRepEventHandler::~CPhoneCenRepEventHandler
// ----------------------------------------------------------------------------

CPhoneCenRepEventHandler::~CPhoneCenRepEventHandler()
    {
    if ( iCenRepNotifyHandler )
        {
        iCenRepNotifyHandler->StopListening();
        }
    delete iCenRepNotifyHandler;
    delete iRepository;
    }

// ----------------------------------------------------------------------------
// CPhoneCenRepEventHandler::ConstructL
// ----------------------------------------------------------------------------

void CPhoneCenRepEventHandler::ConstructL()
    {
    __PHONELOG1( 
        EBasic, 
        EPhonePhoneapp, 
        "CPhoneCenRepEventHandler::ConstructL: uid=%d", 
        iUid );

    iRepository = CRepository::NewL( iUid );
    
    iCenRepNotifyHandler = CCenRepNotifyHandler::NewL( 
        *this, 
        *iRepository );

    iCenRepNotifyHandler->StartListeningL();
    }

// ----------------------------------------------------------------------------
// CPhoneCenRepEventHandler::HandleNotifyGeneric
// ----------------------------------------------------------------------------
void CPhoneCenRepEventHandler::HandleNotifyGeneric( TUint32 aId )
    {
    
    __PHONELOG2( 
        EBasic, 
        EPhonePhoneapp, 
        "CPhoneCenRepEventHandler::HandleNotifyGeneric: uid=%d, id=%d", 
        iUid,
        aId );

    CPhoneCenRepProxy::Instance()->HandleNotify( iUid, aId );
    }

// ----------------------------------------------------------------------------
// CPhoneCenRepEventHandler::HandleNotifyError
// ----------------------------------------------------------------------------
void CPhoneCenRepEventHandler::HandleNotifyError( 
    TUint32 /*aId*/, 
    TInt error, 
    CCenRepNotifyHandler* /*aHandler*/ )
    {
    if ( error )
        {
        __PHONELOG2( 
            EBasic, 
            EPhonePhoneapp, 
            "CPhoneCenRepEventHandler::HandleNotifyError: uid=%d, error = %d", 
            iUid,
            error );        
        }

    // Resume listening
    TRAPD( err, iCenRepNotifyHandler->StartListeningL() );
    if ( KErrNone != err )
        {
        Panic( err );
        }
    }

// End of File