srsf/vcexecutorapp/src/appcontrollerpropertyhandler.cpp
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:29:17 +0100
branchRCL_3
changeset 23 e36f3802f733
parent 0 bf1d17376201
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201033 Kit: 201035

/*
* Copyright (c) 2006 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:  Active object for subscribing to Publish & Suscribe properties
*
*/


// INCLUDE FILES
#include <e32svr.h>
#include "appcontrollerpropertyhandler.h"
#include "appcontroller.h"

// ---------------------------------------------------------
// CAppControllerPropertyHandler::NewL
// Symbian OS two-phased constructor
// ---------------------------------------------------------
//
CAppControllerPropertyHandler* CAppControllerPropertyHandler::NewL(
    TUid aCategory, TUint aKey, CVCApplicationControllerImpl* aController)
    {
    CAppControllerPropertyHandler* self = new ( ELeave ) CAppControllerPropertyHandler( aController );
    CleanupStack::PushL( self );
    self->ConstructL( aCategory, aKey );
    CleanupStack::Pop( self );
    return self;
    }


// ---------------------------------------------------------
// CAppControllerPropertyHandler::CAppControllerPropertyHandler
// C++ constructor
// ---------------------------------------------------------
//
CAppControllerPropertyHandler::CAppControllerPropertyHandler( CVCApplicationControllerImpl* aController )
													: CActive( EPriorityStandard ), 
													iController( aController )
    {
    }

// ---------------------------------------------------------
// CAppControllerPropertyHandler::ConstructL
// Symbian OS 2nd phase constructor
// ---------------------------------------------------------
//
void CAppControllerPropertyHandler::ConstructL(TUid aCategory, TUint aKey )
    {
    User::LeaveIfError( iProperty.Attach( aCategory, aKey ) );

    CActiveScheduler::Add(this);
    // Initial subscription and process current property value
    RunL();

    iRequestIssued = ETrue;
    }

// Destructor
CAppControllerPropertyHandler::~CAppControllerPropertyHandler()
    {
    Cancel();
    iProperty.Close();
    }


// ---------------------------------------------------------
// CAppControllerPropertyHandler::DoCancel   
// Cancel the request to receive events
// ---------------------------------------------------------
//
void CAppControllerPropertyHandler::DoCancel()
    {
    iProperty.Cancel();
    }


// ---------------------------------------------------------
// CAppControllerPropertyHandler::RunL
// Handle a change event.
// ---------------------------------------------------------
//
void CAppControllerPropertyHandler::RunL()
    {
    // Resubscribe before processing new value to prevent missing updates
    iProperty.Subscribe( iStatus );
    SetActive();

    if ( iRequestIssued )
        {
        iController->HandleCurrentCallStatusChange();
        }
    }


// ---------------------------------------------------------
// CAppControllerPropertyHandler::Value
// Get current property value
// ---------------------------------------------------------
//
TInt CAppControllerPropertyHandler::Value()
    {
    TInt value = 0;
    iProperty.Get( value );
    return value;
    }


// End of File