williamr@4: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: // All rights reserved. williamr@4: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@4: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: // williamr@4: // Initial Contributors: williamr@4: // Nokia Corporation - initial contribution. williamr@4: // williamr@4: // Contributors: williamr@4: // williamr@4: // Description: williamr@4: // williamr@4: williamr@4: /** williamr@4: @file williamr@4: @internalComponent williamr@4: @prototype williamr@4: */ williamr@4: williamr@4: williamr@4: #ifndef LBS_SUPL_PSY_ADAPTATION_H williamr@4: #define LBS_SUPL_PSY_ADAPTATION_H williamr@4: williamr@4: #include williamr@4: #include williamr@4: #include williamr@4: #include "lbsnetinternalapi.h" williamr@4: #include "lbsnetinternalmsgtypes.h" williamr@4: williamr@4: williamr@4: /** williamr@4: The MLbsSuplPsyAdaptationObserver class is used in partnership with williamr@4: CLbsSuplPsyAdaptation. The observer interface is used by LBS to provide williamr@4: responses to requests made by the SUPL PSY via CLbsSuplPsyAdaptation. williamr@4: williamr@4: Although all the interface methods in the MLbsSuplPsyAdaptationObserver williamr@4: are synchronous they should return quickly. If required, the SUPL PSY should williamr@4: internally queue the responses and process them asynchronously. williamr@4: williamr@4: @see CLbsSuplPsyAdaptation williamr@4: */ williamr@4: class MLbsSuplPsyAdaptationObserver williamr@4: { williamr@4: public: williamr@4: virtual TVersion Version() = 0; williamr@4: williamr@4: virtual void OnLocationUpdate(TUint aRequestId, TPositionInfoBase& aPosition, TInt aReason) = 0; williamr@4: williamr@4: /** williamr@4: LBS issues a single call to OnSessionComplete() to close a session and return the final williamr@4: result code to the SUPL PSY. williamr@4: williamr@4: The aReason parameter indicates the overall success or failure for the request. williamr@4: williamr@4: The request ID parameter identifies the session that is being closed. This ID is allocated when williamr@4: a new request is created: williamr@4: williamr@4: In normal situations, OnSessionComplete() will be invoked when the overall request has williamr@4: finished. OnSessionComplete() can also be used by LBS to terminate a request if a protocol williamr@4: conflict has arisen. For example, the local SUPL subsystem or a remote SUPL Server is unable to williamr@4: simultaneously perform two requests (for example a TerminalBased AGPS session is active). williamr@4: williamr@4: @param aRequestId The Id of the request being closed. williamr@4: williamr@4: @param aReason Reason for the completion of the request. KErrNone if the request is successfully williamr@4: completed, or one of a range of error codes otherwise. williamr@4: */ williamr@4: virtual void OnSessionComplete(TUint aRequestId, TInt aReason) = 0; williamr@4: }; williamr@4: williamr@4: williamr@4: /** williamr@4: The SUPL PSY adaptation interface is a point to point interface between the SUPL PSY and williamr@4: the Netowrk Gateway and allows the SUPL PSY to ask a remote SUPL Server for the position of williamr@4: the device. As the interface is point to point, only one instance is allowed and must be shared williamr@4: between one or more SUPL PSYs. It is the responsibility of the SUPL PSY(s) to combine multiple williamr@4: requests coming from multiple users. williamr@4: williamr@4: The CLbsSuplPsyAdaptation class is used in partnership with MLbsSuplPsyAdaptationObserver. williamr@4: LBS responds to requests from the SUPL PSY via that observer class. williamr@4: williamr@4: Although all the interface methods in the class are synchronous they must return immediately. williamr@4: When the SUPL PSY makes a request via CLbsSuplPsyAdaptation the LBS subsystem must williamr@4: queue the request internally and return control to the caller immediately. Afterwards, when williamr@4: the SUPL Server provides a response LBS uses the corresponding notification method in the williamr@4: MLbsSuplPsyAdaptationObserver class. williamr@4: williamr@4: The interface is a temporary solution and should be removed (or incorporated into the SUPL PSY) williamr@4: once a common codeline is established. williamr@4: williamr@4: The interface, even though declared as internalAll, MUST be used by the SUPL PSY EXCLUSIVELY. williamr@4: It MUST NOT be used by the Generic Network PSY, or any other components. williamr@4: williamr@4: @see MLbsSuplPsyAdaptationObserver williamr@4: */ williamr@4: NONSHARABLE_CLASS(CLbsSuplPsyAdaptation) : public CActive, public MLbsNetChannelObserver williamr@4: { williamr@4: public: williamr@4: static CLbsSuplPsyAdaptation * NewL(MLbsSuplPsyAdaptationObserver& aObserver); williamr@4: ~ CLbsSuplPsyAdaptation (); williamr@4: williamr@4: /** williamr@4: RequestLocationUpdate() should be used by the SUPL PSY to request a SUPL Server to williamr@4: calculate the current location of the handset and return it to the terminal. williamr@4: williamr@4: When the location information is received from the SUPL Server it is being forwarded to williamr@4: the SUPl PSY via the method MLbsSuplPsyAdaptationObserver::OnLocationUpdate(). williamr@4: williamr@4: The position information returned is network calculated and is normally williamr@4: expected to be an approximate location only. For example, related to the position williamr@4: of the current serving cell. It may also be a position calculated by the network with williamr@4: the assistance of the terminal (the terminal sends measurements to the network). williamr@4: williamr@4: This method automatically cancels any active location request and williamr@4: replaces it with the new request. The CancelLocationRequest() method is used when the williamr@4: SYPL PSY wants to a cancel request but does not immediately wish to replace it with williamr@4: another. williamr@4: williamr@4: The aRequestId parameter is generated by the SUPL PSY and is used to connect all williamr@4: corresponding responses and further requests. The same request ID must be used the williamr@4: SUPL PSY if it wishes to cancel the request. Similarly, the same request ID must also williamr@4: be supplied by LBS when it responds to the SUPL PSY williamr@4: via the MLbsSuplPsyAdaptationObserver::OnLocationUpdate() method. williamr@4: williamr@4: The request ID is also passed by the LBS subsystem when it closes a session via the williamr@4: method MLbsSuplPsyAdaptationObserver::OnSessionComplete(). williamr@4: williamr@4: @param aRequestId The Id of the location request. This is generated by the SUPL PSY williamr@4: and must be used by LBS when it returns the obtained position information. williamr@4: williamr@4: @param aProtocolModuleId The Id of the protocol Module to be used. williamr@4: @param aProtocolModuleId The Id of the protocol Module to be used. williamr@4: @param aNewClient Indicates the first request from a new client. williamr@4: williamr@4: williamr@4: @see CLbsAdmin williamr@4: @see MLbsSuplPsyAdaptationObserver::OnSessionComplete() williamr@4: @see MLbsSuplPsyAdaptationObserver::OnLocationUpdate() williamr@4: @see CancelLocationRequest williamr@4: */ williamr@4: void RequestLocationUpdate(TUint aRequestId, TBool aNewClient, TUid aProtocolModule); williamr@4: williamr@4: /** williamr@4: This method attempts to cancel a request to obtain the location williamr@4: of the terminal. The previous request will have been initiated by calling williamr@4: RequestLocationUpdate() williamr@4: williamr@4: Note: If the SUPL PSY wishes to stop the location request and immediately issue a williamr@4: new location request it should issue a subsequent call to RequestLocationUpdate(). williamr@4: Submitting a new location request, automatically cancels any outstanding transfer. williamr@4: williamr@4: In some circumstances, LBS may still return the associated position to the SUPl PSY. williamr@4: This situation can occur when the cancel request is performed after a point where it williamr@4: is no longer possible to stop the request being sent. williamr@4: williamr@4: @param aRequestId The Id of the network location request to be cancelled. williamr@4: @param aReason Indicates why the LBS subsystem wants the terminate the request. williamr@4: williamr@4: @see RequestLocationUpdate() williamr@4: @see MLbsSuplPsyAdaptationObserver::OnLocationUpdate() williamr@4: */ williamr@4: void CancelLocationRequest(TUint aRequestId, TInt aReason); williamr@4: williamr@4: virtual void ProcessNetChannelMessage(RLbsNetChannel::TLbsNetChannelId aChannelId, const TLbsNetInternalMsgBase& aMessage); williamr@4: williamr@4: private: williamr@4: /** williamr@4: * From CActive williamr@4: */ williamr@4: void RunL(); williamr@4: williamr@4: /** williamr@4: * From CActive williamr@4: */ williamr@4: void DoCancel(); williamr@4: williamr@4: /** williamr@4: * From CActive williamr@4: */ williamr@4: TInt RunError( TInt aError ); williamr@4: williamr@4: TLbsNetInternalMsgBase* CreateTLbsCellLocationRequestMsgL(TUint aRequestId, TBool aNewClient, TUid aProtocolModule); williamr@4: williamr@4: private: williamr@4: CLbsSuplPsyAdaptation (MLbsSuplPsyAdaptationObserver& aObserver); williamr@4: void ConstructL(); williamr@4: /** williamr@4: * Construct HPositionGenericInfo and set requested fields williamr@4: */ williamr@4: HPositionGenericInfo* ConstructGenericInfoL( williamr@4: TInt aBufferSize = KPositionGenericInfoDefaultBufferSize ) const; williamr@4: williamr@4: private: williamr@4: // Callback function for get location request complete event williamr@4: MLbsSuplPsyAdaptationObserver& iObserver; williamr@4: williamr@4: RLbsNetChannel iPsyChannel; williamr@4: williamr@4: TLbsNetInternalMsgBase* iSentMsg; williamr@4: williamr@4: // position info williamr@4: TPositionInfoBase* iPositionInfo; williamr@4: williamr@4: TUint iRequestid; williamr@4: williamr@4: TBool iLocRequest; williamr@4: }; williamr@4: williamr@4: williamr@4: #endif // LBS_SUPL_PSY_ADAPTATION_H