datasourcemodules/networkpositioningmodule/src/cnetenvironment.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @InternalComponent
       
    19 */
       
    20 
       
    21 #include "cnetenvironment.h"
       
    22 #include "cpositionerq.h"
       
    23 #include "cnetrequesthandler.h"
       
    24 #include "cnetresponsehandler.h"
       
    25 #include "cnetmodstatushandler.h"
       
    26 #include "psylogging.h"
       
    27 #include "netpsy.hrh"
       
    28 
       
    29 /**
       
    30  * Destructor
       
    31  */
       
    32 CNETEnvironment::~CNETEnvironment()
       
    33 	{
       
    34     Dll::SetTls(NULL);
       
    35     
       
    36     delete iPositionerQ;
       
    37     delete iRequestHandler;
       
    38     delete iResponseHandler;
       
    39 	delete iModStatusHandler;
       
    40 	}
       
    41 
       
    42 /**
       
    43  * Constructor
       
    44  */
       
    45 CNETEnvironment::CNETEnvironment()
       
    46 	{
       
    47 	}
       
    48 
       
    49 /**
       
    50 Close the environment
       
    51 */
       
    52 void CNETEnvironment::CloseInstance()
       
    53 	{
       
    54 	CObject::Close();
       
    55 	}
       
    56 
       
    57 /**
       
    58  * CNETEnvironment::RegisterPSYL
       
    59  * 
       
    60  * @param aPSY, the MPOsitioner instance to add to the queue.
       
    61  */
       
    62 void CNETEnvironment::RegisterPSYL(MPositioner* aPSY)
       
    63 	{
       
    64 	if(iPositionerQ)
       
    65 		{
       
    66 		iPositionerQ->RegisterPSYL(aPSY);
       
    67 		}
       
    68 	}
       
    69 
       
    70 /**
       
    71  * CNETEnvironment::UnregisterPSYL
       
    72  * 
       
    73  * @param aPSY, the MPositioner instance to remove from the queue.
       
    74  */
       
    75 void CNETEnvironment::UnregisterPSY(MPositioner* aPSY)
       
    76 	{
       
    77 	if(iPositionerQ)
       
    78 		{
       
    79 		iPositionerQ->UnregisterPSY(aPSY);
       
    80 		}
       
    81 	}
       
    82 
       
    83 
       
    84 /**
       
    85  * CPositionerQ::NewL Two-phased constructor.
       
    86  * Creates a new instance of a CNETEnvironment implementation.
       
    87  * 
       
    88  * @return the CPositionerEnvironment implementation.
       
    89  */
       
    90 CPositionerEnvironment* CNETEnvironment::NewL()
       
    91     {
       
    92 	// Have we loaded the environment already
       
    93     if ( !Dll::Tls() ) 
       
    94         {
       
    95         CNETEnvironment* self = new( ELeave ) CNETEnvironment();
       
    96         
       
    97         CleanupClosePushL(*self);
       
    98         self->ConstructL();
       
    99         CleanupStack::Pop();
       
   100 
       
   101         Dll::SetTls(self);
       
   102 		}
       
   103 	else
       
   104 		{
       
   105 		CPositionerEnvironment * theEnv = reinterpret_cast<CPositionerEnvironment*>(Dll::Tls());
       
   106 		theEnv->Open();
       
   107 		}
       
   108  
       
   109     return reinterpret_cast<CPositionerEnvironment*>(Dll::Tls());
       
   110     }
       
   111 
       
   112 void CNETEnvironment::ConstructL()
       
   113     {
       
   114     TRACESTRING("CNETEnvironment::ConstructL start");
       
   115     
       
   116     
       
   117 	// Do not change order of construction!
       
   118     CPositionerEnvironment::ConstructL();
       
   119 	iPositionerQ = CPositionerQ::NewL();
       
   120 	iRequestHandler = CNETRequestHandler::NewL(iPositionerQ);
       
   121 	iResponseHandler = CNETResponseHandler::NewL(iPositionerQ, iRequestHandler);
       
   122 	iModStatusHandler = CNETModStatusHandler::NewL(iPositionerQ);	
       
   123 
       
   124     TRACESTRING("CNETEnvironment::ConstructL end");
       
   125     }
       
   126 
       
   127 /**
       
   128  * Returns the CNETRequestHandler instance
       
   129  *
       
   130  * @return the CNETRequestHandler
       
   131  */
       
   132 CRequestHandler* CNETEnvironment::GetRequestHandler()
       
   133 	{
       
   134     return iRequestHandler;
       
   135 	}
       
   136 	
       
   137 /**
       
   138  * Returns the CNETResponseHandler instance.
       
   139  *
       
   140  * @return the CNETResponseHandler
       
   141  */
       
   142 CResponseHandler* CNETEnvironment::GetResponseHandler()
       
   143 	{
       
   144     return iResponseHandler;
       
   145 	}
       
   146 
       
   147 void CNETEnvironment::GetEnvCriteria(TPositionCriteria& aCriteria)
       
   148 	{
       
   149 	aCriteria = iCriteria;
       
   150 	}
       
   151 
       
   152 
       
   153 TPositionCriteria& CNETEnvironment::GetEnvCriteria()
       
   154 	{
       
   155 	return iCriteria;
       
   156 	}