datasourcemodules/gpspositioningmodule/lbsagpspsy/src/responsehandler/cfinalnetdatabus.cpp
changeset 36 b47902b73a93
parent 0 9cfd9a3ee49c
equal deleted inserted replaced
35:a2efdd544abf 36:b47902b73a93
       
     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 // netfinaldataDataBus.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @InternalComponent
       
    21 */
       
    22 
       
    23 #include "cfinalnetdatabus.h"
       
    24 #include "lbsdevloggermacros.h"
       
    25 
       
    26 /**
       
    27 Create a net final data bus, this should be called from the location cache
       
    28 
       
    29 @return The pointer to the location data bus
       
    30 @see CLocationCache
       
    31 */
       
    32 CFinalNetDataBus* CFinalNetDataBus::NewL(MDataBusObserver& aObserver)	
       
    33 	{
       
    34 	CFinalNetDataBus* self = new (ELeave) CFinalNetDataBus(aObserver);
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL();
       
    37 	CleanupStack::Pop(self);
       
    38 	return self;
       
    39 	} 
       
    40 	
       
    41 /**
       
    42 constructor, note the location data bus is owned by location cache and used by CRequestQ, and it is a module-based CActive object.
       
    43 Set the data bus as standard priority by default.
       
    44 Add itself to Active Scheduler
       
    45 
       
    46 @param aModuleId Position module Id
       
    47 @see CRequestQ
       
    48 @see CLocationCache
       
    49 */
       
    50 CFinalNetDataBus::CFinalNetDataBus(MDataBusObserver& aObserver) : CActive(CActive::EPriorityStandard), iObs(aObserver)
       
    51 	{
       
    52 	CActiveScheduler::Add(this);
       
    53 	}
       
    54 
       
    55 /**
       
    56 Open the RProperty object wrappered by the data bus.
       
    57 Location data bus is implemented as Publish & Subscribe mechanism.
       
    58 */
       
    59 void CFinalNetDataBus::ConstructL()
       
    60 	{
       
    61 	iFinalNetDataBus.OpenL(RLbsNetworkPositionUpdates::ENetworkPositionFinal);
       
    62 	}
       
    63 
       
    64 /**
       
    65 Cancel any outstanding request to the CActive object.
       
    66 Close the RProperty.
       
    67 */
       
    68 CFinalNetDataBus::~CFinalNetDataBus()
       
    69 	{
       
    70 	Cancel(); // just in case...
       
    71 	iFinalNetDataBus.Close();
       
    72 	}
       
    73 
       
    74 
       
    75 /**
       
    76 Subscribe to the data bus. It will be called by objects which listen to the data bus.
       
    77 It will eventually call RProperty::Subscribe()
       
    78 Set active the data bus active object
       
    79 Panic if there are no data bus observers already set.
       
    80 */
       
    81 void CFinalNetDataBus::Subscribe()
       
    82 	{
       
    83 	if(!IsActive())
       
    84 		{
       
    85 		iFinalNetDataBus.NotifyNetworkLocationUpdate(iStatus);
       
    86 		SetActive();
       
    87 		}
       
    88 	}
       
    89 
       
    90 /**
       
    91 Cancel the subscribe to the data bus. Cancel any outstanding request to the CActive object.
       
    92 Panic if there are no data bus observers already set.
       
    93 */
       
    94 void CFinalNetDataBus::UnSubscribe()
       
    95 	{
       
    96 	Cancel();
       
    97 	}
       
    98 
       
    99 /**
       
   100 Get the last position from the bus 
       
   101  */
       
   102 TInt CFinalNetDataBus::GetLastPositionInfo(TPositionInfo& aFNPInfo, TTime& aActualTime)
       
   103 	{
       
   104 	TLbsNetSessionIdInt sessionId;
       
   105 	TTime targetTime;
       
   106 	
       
   107 	TInt error = iFinalNetDataBus.GetPositionInfo(sessionId, aFNPInfo, targetTime, aActualTime);
       
   108 	if(error == KErrNone && (aFNPInfo.PositionMode() & TPositionModuleInfo::ETechnologyTerminal))
       
   109 		{
       
   110 		error = KErrNotFound;	// filter out terminal assisted FNPs
       
   111 		}
       
   112 	return error;
       
   113 	}
       
   114 
       
   115 /**
       
   116 from CActive, the main event processing loop
       
   117 Whenever there is a new event, i.e. the position info data is published to the data bus, notify the data bus observer by LocationDataAvailableL()
       
   118 */
       
   119 void CFinalNetDataBus::RunL()
       
   120 	{
       
   121 	TLbsNetSessionIdInt sessionId;
       
   122 	TTime targetTime;
       
   123 	TTime actualTime;
       
   124 	
       
   125 	TInt error = iFinalNetDataBus.GetPositionInfo(sessionId, iPositionInfo, targetTime, actualTime);
       
   126 	
       
   127 	if(iPositionInfo.PositionMode() & TPositionModuleInfo::ETechnologyNetwork)// filter out terminal assisted FNPs
       
   128 		{
       
   129 		iObs.DataUpdate(iPositionInfo, iStatus.Int(), error, actualTime);
       
   130 		}
       
   131 	}
       
   132 	
       
   133 /**
       
   134 from CActive
       
   135 Cancels the request for position update notification
       
   136 It will eventually cancel an outstanding subscription request for this property handle.
       
   137 */
       
   138 void CFinalNetDataBus::DoCancel()
       
   139 	{
       
   140 	iFinalNetDataBus.CancelNotifyNetworkLocationUpdate();
       
   141 	}
       
   142 	
       
   143 /**
       
   144 from CActive
       
   145 Simply fwds any errors to the observers
       
   146 */
       
   147 TInt CFinalNetDataBus::RunError(TInt aError)
       
   148 	{
       
   149 	return iObs.DataError(aError, iStatus.Int());
       
   150 	}
       
   151