diff -r 6df133bd92e1 -r 075425b8d9a4 radioengine/utils/api/cradiorepositoryentity.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/radioengine/utils/api/cradiorepositoryentity.inl Fri Jun 11 13:38:32 2010 +0300 @@ -0,0 +1,143 @@ +/* +* Copyright (c) 2009 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: +* +*/ + +// System includes +#include + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +EXPORT_C CRadioRepositoryEntity* CRadioRepositoryEntity::NewL( const TUid& aUid, + TUint32 aKey, + MRadioRepositoryEntityObserver& aObserver, + CActive::TPriority aPriority ) + { + LEVEL3( LOG_METHOD_AUTO ); + CRadioRepositoryEntity* self = new ( ELeave ) CRadioRepositoryEntity( aUid, aKey, aObserver, aPriority ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +CRadioRepositoryEntity::CRadioRepositoryEntity( const TUid& aUid, + TUint32 aKey, + MRadioRepositoryEntityObserver& aObserver, + CActive::TPriority aPriority ) + : CRadioRepositoryEntityBase( aUid, aKey, aObserver, aPriority ) + { + LEVEL3( LOG_METHOD_AUTO ); + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +void CRadioRepositoryEntity::ConstructL() + { + LEVEL3( LOG_METHOD_AUTO ); + iRepository = CRepository::NewL( iUid ); + + CActiveScheduler::Add( this ); + iRepository->Get( iKey, iValue ); + User::LeaveIfError( iRepository->NotifyRequest( iKey, iStatus ) ); + SetActive(); + } + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- +// +template +EXPORT_C CRadioRepositoryEntity::~CRadioRepositoryEntity() + { + LEVEL3( LOG_METHOD_AUTO ); + Cancel(); + delete iRepository; + } + +// ----------------------------------------------------------------------------- +// Sets the value of the key. +// ----------------------------------------------------------------------------- +// +template +TInt CRadioRepositoryEntity::SetValue( const T& aValue, TBool aSavingEnabled ) + { + LEVEL3( LOG_METHOD_AUTO ); + iValue = aValue; + if ( aSavingEnabled ) + { + return iRepository->Set( iKey, aValue ); + } + return KErrNone; + } + +// ----------------------------------------------------------------------------- +// Returns the cached copy of the key's value. +// ----------------------------------------------------------------------------- +// +template +const T& CRadioRepositoryEntity::Value() const + { + LEVEL3( LOG_METHOD_AUTO ); + return iValue; + } + +// ----------------------------------------------------------------------------- +// Forcibly updates the cached value from the repository. +// ----------------------------------------------------------------------------- +// +template +void CRadioRepositoryEntity::UpdateL() + { + LEVEL3( LOG_METHOD_AUTO ); + User::LeaveIfError( iRepository->Get( iKey, iValue ) ); + } + +// ----------------------------------------------------------------------------- +// Executed when the key's value is changed. +// ----------------------------------------------------------------------------- +// +template +void CRadioRepositoryEntity::RunL() + { + LEVEL3( LOG_METHOD_AUTO ); + User::LeaveIfError( iRepository->NotifyRequest( iKey, iStatus ) ); + SetActive(); + + TInt err = iRepository->Get( iKey, iValue ); + iObserver.HandleRepositoryValueChangeL( iUid, iKey, iValue, err ); + } + +// ----------------------------------------------------------------------------- +// Cancels all pending notifications. +// ----------------------------------------------------------------------------- +// +template +void CRadioRepositoryEntity::DoCancel() + { + LEVEL3( LOG_METHOD_AUTO ); + iRepository->NotifyCancel( iKey ); + }