locationmgmt/agpslocationmgr/src/lbspoweradvicehandler.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 25 May 2010 14:13:22 +0300
branchRCL_3
changeset 31 b6bc347ed8ca
parent 0 9cfd9a3ee49c
permissions -rw-r--r--
Revision: 201014 Kit: 2010121

// 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();
	
	}