diff -r cad71a31b7fc -r e36f3802f733 srsf/vcexecutorapp/src/appcontrollerpropertyhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/srsf/vcexecutorapp/src/appcontrollerpropertyhandler.cpp Wed Sep 01 12:29:17 2010 +0100 @@ -0,0 +1,117 @@ +/* +* 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 +#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