locationmgmt/agpslocationmgr/src/lbspoweradvicehandler.cpp
author andy simpson <andrews@symbian.org>
Fri, 03 Sep 2010 13:33:59 +0100
branchRCL_3
changeset 56 8765b1ff8332
parent 0 9cfd9a3ee49c
permissions -rw-r--r--
Merge after removal of incorrect RCL_3 drop

// Copyright (c) 2006-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:
//

#include "LbsInternalInterface.h"
#include "lbspoweradvicehandler.h"

CPowerModeAdviceHandler * CPowerModeAdviceHandler::NewL
	(
	MPowerModeObserver* aObserver
	)
	{

	CPowerModeAdviceHandler * self = new(ELeave) CPowerModeAdviceHandler (aObserver);

	CleanupStack::PushL(self);

	self->ConstructL();
	CleanupStack::Pop();

	return self;
	}
	

	
CPowerModeAdviceHandler::CPowerModeAdviceHandler(MPowerModeObserver* aObserver) : 
CActive(CActive::EPriorityStandard),	
iObserver(aObserver)
	{

	}

void CPowerModeAdviceHandler::DoCancel()
	{
	iManagerPowerModeAdvice.CancelNotifyPowerModeAdviceUpdate();
	}

void CPowerModeAdviceHandler::ConstructL()
	{

   	iManagerPowerModeAdvice.OpenL(KLbsGpsLocManagerUid);

  	CActiveScheduler::Add(this);
	}

//------------------------------------------------------------------------------------------------------------
CPowerModeAdviceHandler::~CPowerModeAdviceHandler()
	{
	Cancel();
	iManagerPowerModeAdvice.Close();
	}
   
void CPowerModeAdviceHandler::RunL()
	{
	
	TInt status = iStatus.Int();
	User::LeaveIfError(status);
	
	StartGettingPowerUpdates();
	
	CLbsLocationSourceGpsBase::TPowerMode powerModeAdvice;

	User::LeaveIfError(iManagerPowerModeAdvice.GetPowerModeAdvice(powerModeAdvice));
	
	if (iObserver)
		{
		iObserver->PowerModeAdvice(powerModeAdvice); // call back to MainLogic
		}
	
	}

void CPowerModeAdviceHandler::StartGettingPowerUpdates()
	{
	Cancel();
	iManagerPowerModeAdvice.NotifyPowerModeAdviceUpdate(iStatus);

	SetActive();
	
	}