diff -r 000000000000 -r 5a93021fdf25 bearermanagement/mpm/src/mpmcsidwatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bearermanagement/mpm/src/mpmcsidwatcher.cpp Thu Dec 17 08:55:21 2009 +0200 @@ -0,0 +1,147 @@ +/* +* Copyright (c) 2008-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: Listen connect screen id key changes in central repository. +* +*/ + +#include +#include +#include +#include // FeatureManager +#include "mpmcsidwatcher.h" +#include "mpmlogger.h" + +// --------------------------------------------------------------------------- +// Default constructor +// --------------------------------------------------------------------------- +// +CMpmCsIdWatcher::CMpmCsIdWatcher() + : CActive( EPriorityStandard ) + { + CActiveScheduler::Add( this ); + } + + +// --------------------------------------------------------------------------- +// Creates central repositor object +// --------------------------------------------------------------------------- +// +void CMpmCsIdWatcher::ConstructL() + { + iRepository = CRepository::NewL( KMpmOccCenRepUid ); + + // Check whether user connection is supported + FeatureManager::InitializeLibL(); + iUserConnectionSupported = FeatureManager::FeatureSupported( + KFeatureIdFfConnectionOverride ); + + FeatureManager::UnInitializeLib(); + } + + +// --------------------------------------------------------------------------- +// Creates new object +// --------------------------------------------------------------------------- +// +CMpmCsIdWatcher* CMpmCsIdWatcher::NewL() + { + CMpmCsIdWatcher* self = new( ELeave ) CMpmCsIdWatcher(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +CMpmCsIdWatcher::~CMpmCsIdWatcher() + { + Cancel(); + delete iRepository; + } + +// --------------------------------------------------------------------------- +// Order notification from changes +// --------------------------------------------------------------------------- +// +void CMpmCsIdWatcher::StartL() + { + // Request notification + User::LeaveIfError( iRepository->NotifyRequest( KMpmConnectScreenId, + iStatus )); + SetActive(); + + // Get value from central repository + User::LeaveIfError(iRepository->Get(KMpmConnectScreenId, iConnectScreenId)); + } + +// --------------------------------------------------------------------------- +// Return connect screen id +// --------------------------------------------------------------------------- +// +TUint32 CMpmCsIdWatcher::ConnectScreenId() const + { + if ( iUserConnectionSupported ) + { + // Return real value if user connection is supported + return iConnectScreenId; + } + else + { + // Return 0xFFFFFFFF if user connection is not supported + return 0xFFFFFFFF; + } + } + +// --------------------------------------------------------------------------- +// From class CActive. +// When there is a change in central repository key, event is received in here +// --------------------------------------------------------------------------- +// +void CMpmCsIdWatcher::RunL() + { + // Leave if error + User::LeaveIfError( iStatus.Int() ); + + // Request new notification + User::LeaveIfError( iRepository->NotifyRequest( KMpmConnectScreenId, + iStatus )); + SetActive(); + + // Get value from central repository + iRepository->Get( KMpmConnectScreenId, iConnectScreenId ); + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Nothing to do over here +// --------------------------------------------------------------------------- +// +TInt CMpmCsIdWatcher::RunError( TInt /*aError*/ ) + { + return KErrNone; + } + +// --------------------------------------------------------------------------- +// From class CActive. +// Cancel outstanding request +// --------------------------------------------------------------------------- +// +void CMpmCsIdWatcher::DoCancel() + { + iRepository->NotifyCancel( KMpmConnectScreenId ); + } +