diff -r 984e13af52c4 -r fc7b30ed2058 connectionmonitoring/connmon/connectionmonitor/src/cellulardatausagekeyupdater.cpp --- a/connectionmonitoring/connmon/connectionmonitor/src/cellulardatausagekeyupdater.cpp Thu Jul 15 19:05:04 2010 +0300 +++ b/connectionmonitoring/connmon/connectionmonitor/src/cellulardatausagekeyupdater.cpp Thu Aug 19 10:18:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 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" @@ -71,7 +71,8 @@ { // Cancel outstanding request, if exists Cancel(); - delete iRepository; + delete iCommsRepository; + delete iCmmRepository; } // ----------------------------------------------------------------------------- @@ -81,50 +82,75 @@ void CCellularDataUsageKeyUpdater::UpdateKeyL( const TInt aRegistration ) const { LOGENTRFN("CCellularDataUsageKeyUpdater::UpdateKeyL()") - LOGIT1("CCellularDataUsageKeyUpdater::UpdateKeyL: aRegistration <%d>", + LOGIT1("CCellularDataUsageKeyUpdater::UpdateKeyL: aRegistration <%d>", aRegistration) - - TCmGenConnSettings occSettings = ReadGenConnSettingsL(); - + TInt value( ECmCellularDataUsageDisabled ); - - if ( aRegistration == ENetworkRegistrationExtRoamingInternational ) - { - value = occSettings.iCellularDataUsageVisitor; - } - else if ( aRegistration == ENetworkRegistrationExtHomeNetwork || - aRegistration == ENetworkRegistrationExtRoamingNational ) - { - value = occSettings.iCellularDataUsageHome; + + // If dial-up PDP context override is active, disable cellular data usage (temporarily). + if ( iServer->GetDialUpOverrideStatus() != EConnMonDialUpOverrideActive ) + { + TCmGenConnSettings occSettings = ReadGenConnSettingsL(); + + if ( aRegistration == ENetworkRegistrationExtRoamingInternational ) + { + value = occSettings.iCellularDataUsageVisitor; + } + else if ( aRegistration == ENetworkRegistrationExtHomeNetwork || + aRegistration == ENetworkRegistrationExtRoamingNational ) + { + value = occSettings.iCellularDataUsageHome; + } } - CRepository* cmRepository = NULL; - - TRAPD( err, cmRepository = CRepository::NewL( KCRUidCmManager ) ) - - if ( err == KErrNone ) + TInt previous( 0 ); + TInt err = iCmmRepository->Get( KCurrentCellularDataUsage, previous ); + if ( err == KErrNone && ( value != previous ) ) + { + iCmmRepository->Set( KCurrentCellularDataUsage, value ); + LOGIT1("KCurrentCellularDataUsage set to %d", value) + } + else { - TInt previous( 0 ); - err = cmRepository->Get( KCurrentCellularDataUsage, previous ); - - if ( err == KErrNone && ( value != previous ) ) + LOGIT2("KCurrentCellularDataUsage already up-to-date %d <%d>", previous, err) + } + + LOGEXITFN("CCellularDataUsageKeyUpdater::UpdateKeyL()") + } + +// ----------------------------------------------------------------------------- +// Return ETrue if dial-up PDP context override feature is enabled. +// ----------------------------------------------------------------------------- +// +TBool CCellularDataUsageKeyUpdater::DialUpOverrideEnabled() const + { + LOGENTRFN("CCellularDataUsageKeyUpdater::DialUpOverrideEnabled()") + TBool result( EFalse ); + + if ( iCmmRepository ) + { + TInt value( 0 ); + TInt err = iCmmRepository->Get( KDialUpOverride, value ); + if ( err == KErrNone ) { - cmRepository->Set( KCurrentCellularDataUsage, value ); - LOGIT1("KCurrentCellularDataUsage set to %d", value) + if ( value ) + { + result = ETrue; + LOGIT("ConstructL: Dial-up override enabled") + } + else + { + LOGIT("ConstructL: Dial-up override disabled") + } } else { - LOGIT1("KCurrentCellularDataUsage already up-to-date %d", previous) + LOGIT1("Failed to read KDialUpOverride-key from repository <%d>", err) } - - delete cmRepository; - } - else - { - LOGIT1("CCRepository::NewL( KCRUidCmManager ) FAILED <%d>", err) } - LOGEXITFN("CCellularDataUsageKeyUpdater::UpdateKeyL()") + LOGEXITFN1("CCellularDataUsageKeyUpdater::DialUpOverrideEnabled()", result) + return result; } // ----------------------------------------------------------------------------- @@ -136,7 +162,8 @@ CActive( EConnMonPriorityNormal ), iServer( aServer ) { - iRepository = NULL; + iCommsRepository = NULL; + iCmmRepository = NULL; iErrorCounter = 0; } @@ -146,13 +173,21 @@ // void CCellularDataUsageKeyUpdater::ConstructL() { - iRepository = CRepository::NewL( KCDCommsRepositoryId ); - + iCommsRepository = CRepository::NewL( KCDCommsRepositoryId ); + + // Open CmManager central repository. + TRAPD( err, iCmmRepository = CRepository::NewL( KCRUidCmManager ) ) + if ( err ) + { + LOGIT1("CRepository::NewL( KCRUidCmManager ) FAILED <%d>", err) + err = KErrNone; + } + // Find out Default connection table id. // It contains iCellularDataUsageHome and iCellularDataUsageVisitor keys. CMDBSession* db = CMDBSession::NewLC( CMDBSession::LatestVersion() ); - TRAPD( err, iTableId = CCDDefConnRecord::TableIdL( *db ) ) - + TRAP( err, iTableId = CCDDefConnRecord::TableIdL( *db ) ) + if ( err ) { LOGIT1("ERROR, CCDDefConnRecord::TableIdL() <%d>", err) @@ -176,8 +211,8 @@ // TInt CCellularDataUsageKeyUpdater::RequestNotifications() { - LOGIT1("Calling iRepository->NotifyRequest() for table 0x%08X", iTableId) - TInt err = iRepository->NotifyRequest( iTableId, KCDMaskShowRecordType, iStatus ); + LOGIT1("Calling iCommsRepository->NotifyRequest() for table 0x%08X", iTableId) + TInt err = iCommsRepository->NotifyRequest( iTableId, KCDMaskShowRecordType, iStatus ); if ( err == KErrNone ) { @@ -185,7 +220,7 @@ } else { - LOGIT1("ERROR, iRepository->NotifyRequest() <%d>", err) + LOGIT1("ERROR, iCommsRepository->NotifyRequest() <%d>", err) } return err; @@ -197,7 +232,7 @@ // void CCellularDataUsageKeyUpdater::DoCancel() { - iRepository->NotifyCancel( iTableId, KCDMaskShowRecordType ); + iCommsRepository->NotifyCancel( iTableId, KCDMaskShowRecordType ); } // -----------------------------------------------------------------------------