|
1 // Copyright (c) 2006-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 // Definition of network position (reference/final) handler sub-component of the NRH |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef _X3PHANDLER_H |
|
24 #define _X3PHANDLER_H |
|
25 |
|
26 #include <lbs/lbsloccommon.h> |
|
27 #include <lbs/lbsadmin.h> |
|
28 #include "LbsInternalInterface.h" |
|
29 #include "ngmessageswitch.h" |
|
30 #include "x3prequest.h" |
|
31 #include "agpsinterfacehandler.h" |
|
32 |
|
33 /* Observer class used to inform of the status of an ongoing X3P |
|
34 */ |
|
35 class MX3pHandlerObserver |
|
36 { |
|
37 public: |
|
38 /* Notification of the completion of an X3P. |
|
39 |
|
40 Note that the X3P may have completed because of an error, |
|
41 in which case aPositionInfo will not be valid. |
|
42 |
|
43 @param aSessionId SessionId of the completed session |
|
44 @param aPositionInfo Contains the position sent to the network. |
|
45 If there was an error during the transmit |
|
46 location service then this value will be |
|
47 invalid |
|
48 @param aReason Reason the session was completed. KErrNone if the |
|
49 the session completed normally. KErrCancel if the |
|
50 session was cancelled (either by the client of the |
|
51 network). KErrTimedOut if the session timed out |
|
52 before it could be completed. |
|
53 */ |
|
54 virtual void OnTransmitLocationComplete(const TLbsNetSessionIdInt& aSessionId, |
|
55 const TPositionInfoBase& aPositionInfo, |
|
56 TInt aReason) = 0; |
|
57 |
|
58 /* Notification of network-provided Reference Location. |
|
59 |
|
60 Note that aReason may show an error has happened, |
|
61 in which case aPositionInfo will not be valid. |
|
62 |
|
63 @param aSessionId SessionId of the session where the request originated. |
|
64 @param aPositionInfo Contains the reference position provided by the network. |
|
65 If there was an error during the transmit |
|
66 location service then this value will be |
|
67 invalid. |
|
68 @param aReason Reason the location is being notified. KErrNone if the |
|
69 the location has been normally provided by the network. |
|
70 KErrCancel if the session was cancelled (either by the |
|
71 client of the network). KErrTimedOut if the session timed |
|
72 out before it could be completed. |
|
73 */ |
|
74 virtual void OnReferenceLocationAvailable(const TLbsNetSessionIdInt& aSessionId, |
|
75 const TPositionInfoBase& aPositionInfo) = 0; |
|
76 }; |
|
77 |
|
78 /* |
|
79 * Defines functions called by the server's subsessions to pass on |
|
80 * requests from an X3P client |
|
81 */ |
|
82 class MX3pHandlerNotifier |
|
83 { |
|
84 public: |
|
85 virtual TInt OnTransmitPosition(const TDesC& aDestinationId, |
|
86 TUint aTransmitPriority, |
|
87 const TLbsTransmitPositionOptions& aTransmitOptions, |
|
88 TLbsNetSessionIdInt& aSessionId) = 0; |
|
89 virtual void OnCancelTransmitPosition(const TLbsNetSessionIdInt& aSessionId) = 0; |
|
90 |
|
91 virtual void AddObserverL(MX3pHandlerObserver* aObserver) = 0; |
|
92 virtual void RemoveObserver(MX3pHandlerObserver* aObserver) = 0; |
|
93 }; |
|
94 |
|
95 /* |
|
96 */ |
|
97 class CX3pHandler : public CBase, |
|
98 public MX3pRequestObserver, |
|
99 public MNGMessageSwitchObserver, |
|
100 public MX3pHandlerNotifier |
|
101 { |
|
102 public: |
|
103 static CX3pHandler* NewL(CNGMessageSwitch& aMessageSwitch, MX3pStatusHandler& aX3pStatusHandler, CLbsAdmin& aLbsAdmin); |
|
104 ~CX3pHandler(); |
|
105 |
|
106 public: // From class MNGMessageSwitchObserver |
|
107 void OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
108 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
109 TBool aIsEmergency, |
|
110 const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
111 const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy); |
|
112 |
|
113 void OnSessionComplete(const TLbsNetSessionIdInt& aSessionId, TInt aReason); |
|
114 |
|
115 void OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
116 const TLbsNetPosRequestMethodInt& aNetPosMethod, |
|
117 TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
118 TBool aIsEmergency, |
|
119 const TLbsNetPosRequestQualityInt& aQuality); |
|
120 void OnNetLocResponse(const TLbsNetSessionIdInt& aSessionId, |
|
121 const TLbsNetPosRequestQualityInt& aQuality); |
|
122 |
|
123 void OnNetLocReferenceUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
124 const TPositionInfoBase& aPosInfo); |
|
125 |
|
126 void OnNetLocFinalUpdate(const TLbsNetSessionIdInt& aSessionId, |
|
127 const TPositionInfoBase& aPosInfo); |
|
128 |
|
129 public: // From MX3pRequestObserver |
|
130 void OnRequestTimeout(const TLbsNetSessionIdInt& aTimedOutRequestId); |
|
131 |
|
132 protected: |
|
133 CX3pHandler(CNGMessageSwitch& aMessageSwitch, MX3pStatusHandler& aX3pStatusHandler, CLbsAdmin& aLbsAdmin); |
|
134 void ConstructL(); |
|
135 |
|
136 protected: // From MX3pServerHandler |
|
137 TInt OnTransmitPosition(const TDesC& aDestinationId, |
|
138 TUint aTransmitPriority, |
|
139 const TLbsTransmitPositionOptions& aTransmitOptions, |
|
140 TLbsNetSessionIdInt& aSessionId); |
|
141 void OnCancelTransmitPosition(const TLbsNetSessionIdInt& aSessionId); |
|
142 |
|
143 void AddObserverL(MX3pHandlerObserver* aObserver); |
|
144 void RemoveObserver(MX3pHandlerObserver* aObserver); |
|
145 |
|
146 private: |
|
147 // Request a new X3P |
|
148 void TransmitLocationRequestL(const TDesC& aDestinationID, |
|
149 TUint aTransmitPriority, |
|
150 const TLbsTransmitPositionOptions& aTransmitOptions, |
|
151 TLbsNetSessionIdInt& aSessionId); |
|
152 // Cancel a current X3P session |
|
153 void TransmitLocationCancel(const TLbsNetSessionIdInt& aSessionId); |
|
154 |
|
155 private: |
|
156 void HandleTimedOutRequest(const TLbsNetSessionIdInt& aRequestId); |
|
157 void HandleCompletedRequest(const TLbsNetSessionIdInt& aRequestId, TInt aReason); |
|
158 void ActivateRequest(); |
|
159 TInt HighestPriorityIndex(); |
|
160 void RecalculateActiveIndex(const TLbsNetSessionIdInt& aSessionId); |
|
161 TInt FindSessionById(const TLbsNetSessionIdInt& aSessionId); |
|
162 void HandleReferenceLocation(const TLbsNetSessionIdInt& aRequestId, const TPositionInfo& aRefPosInfo); |
|
163 void UpdateX3pStatus(); |
|
164 void GetAdminTechnologyType(TPositionModuleInfo::TTechnologyType& aMode); |
|
165 |
|
166 private: |
|
167 CNGMessageSwitch& iMessageSwitch; |
|
168 TInt iNextSessionId; |
|
169 CLbsAdmin& iAdmin; |
|
170 TInt iActiveRequestIndex; |
|
171 CX3pRequest* iActiveRequest; |
|
172 RPointerArray<CX3pRequest> iX3pRequests; |
|
173 RPointerArray<MX3pHandlerObserver> iX3pObservers; |
|
174 |
|
175 TLbsNetSessionIdInt iTimedOutRequestId; |
|
176 TPositionInfo iRefPosInfo; |
|
177 |
|
178 TBool iReceivedFinalNetPosInfo; |
|
179 TPositionInfo iFinalNetPosInfo; |
|
180 |
|
181 MX3pStatusHandler& iX3pStatusHandler; |
|
182 CLbsAdmin::TLbsBehaviourMode iLbsBehaviourMode; |
|
183 TPositionModuleInfoExtended::TDeviceGpsModeCapabilities iDeviceGpsModeCaps; |
|
184 }; |
|
185 |
|
186 |
|
187 #endif // _X3PHANDLER_H |