diff -r a2efdd544abf -r b47902b73a93 datasourcemodules/networkpositioningmodule/src/cnetenvironment.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/datasourcemodules/networkpositioningmodule/src/cnetenvironment.cpp Fri Jun 04 10:34:15 2010 +0100 @@ -0,0 +1,156 @@ +// 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: +// + +/** + @file + @InternalComponent +*/ + +#include "cnetenvironment.h" +#include "cpositionerq.h" +#include "cnetrequesthandler.h" +#include "cnetresponsehandler.h" +#include "cnetmodstatushandler.h" +#include "psylogging.h" +#include "netpsy.hrh" + +/** + * Destructor + */ +CNETEnvironment::~CNETEnvironment() + { + Dll::SetTls(NULL); + + delete iPositionerQ; + delete iRequestHandler; + delete iResponseHandler; + delete iModStatusHandler; + } + +/** + * Constructor + */ +CNETEnvironment::CNETEnvironment() + { + } + +/** +Close the environment +*/ +void CNETEnvironment::CloseInstance() + { + CObject::Close(); + } + +/** + * CNETEnvironment::RegisterPSYL + * + * @param aPSY, the MPOsitioner instance to add to the queue. + */ +void CNETEnvironment::RegisterPSYL(MPositioner* aPSY) + { + if(iPositionerQ) + { + iPositionerQ->RegisterPSYL(aPSY); + } + } + +/** + * CNETEnvironment::UnregisterPSYL + * + * @param aPSY, the MPositioner instance to remove from the queue. + */ +void CNETEnvironment::UnregisterPSY(MPositioner* aPSY) + { + if(iPositionerQ) + { + iPositionerQ->UnregisterPSY(aPSY); + } + } + + +/** + * CPositionerQ::NewL Two-phased constructor. + * Creates a new instance of a CNETEnvironment implementation. + * + * @return the CPositionerEnvironment implementation. + */ +CPositionerEnvironment* CNETEnvironment::NewL() + { + // Have we loaded the environment already + if ( !Dll::Tls() ) + { + CNETEnvironment* self = new( ELeave ) CNETEnvironment(); + + CleanupClosePushL(*self); + self->ConstructL(); + CleanupStack::Pop(); + + Dll::SetTls(self); + } + else + { + CPositionerEnvironment * theEnv = reinterpret_cast(Dll::Tls()); + theEnv->Open(); + } + + return reinterpret_cast(Dll::Tls()); + } + +void CNETEnvironment::ConstructL() + { + TRACESTRING("CNETEnvironment::ConstructL start"); + + + // Do not change order of construction! + CPositionerEnvironment::ConstructL(); + iPositionerQ = CPositionerQ::NewL(); + iRequestHandler = CNETRequestHandler::NewL(iPositionerQ); + iResponseHandler = CNETResponseHandler::NewL(iPositionerQ, iRequestHandler); + iModStatusHandler = CNETModStatusHandler::NewL(iPositionerQ); + + TRACESTRING("CNETEnvironment::ConstructL end"); + } + +/** + * Returns the CNETRequestHandler instance + * + * @return the CNETRequestHandler + */ +CRequestHandler* CNETEnvironment::GetRequestHandler() + { + return iRequestHandler; + } + +/** + * Returns the CNETResponseHandler instance. + * + * @return the CNETResponseHandler + */ +CResponseHandler* CNETEnvironment::GetResponseHandler() + { + return iResponseHandler; + } + +void CNETEnvironment::GetEnvCriteria(TPositionCriteria& aCriteria) + { + aCriteria = iCriteria; + } + + +TPositionCriteria& CNETEnvironment::GetEnvCriteria() + { + return iCriteria; + }