|
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 the main objects in the LBS Network Gateway. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 @released |
|
22 */ |
|
23 |
|
24 #ifndef LBSNETGATEWAY_H_ |
|
25 #define LBSNETGATEWAY_H_ |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <e32property.h> |
|
29 #include <lbs/lbsnetclasstypes.h> |
|
30 #include "lbscommoninternaldatatypes.h" |
|
31 #include <lbs/lbsnetcommon.h> |
|
32 #include <lbs/lbsnetprotocolbase.h> |
|
33 #include <lbs/lbsadmin.h> |
|
34 #include "lbsprocesssupervisor.h" |
|
35 #include "agpschannel.h" |
|
36 #include "netrequestchannel.h" |
|
37 #include "netlocationchannel.h" |
|
38 #include "netregstatusmonitor.h" |
|
39 #include "LbsLogger.h" |
|
40 #include "LbsExternalLocateLogEvent.h" |
|
41 #if defined(_DEBUG) |
|
42 #include "LbsOomListener.h" |
|
43 #endif |
|
44 #include "rlbslocmonitorsession.h" |
|
45 #include "rlbslocmonitorareapositioner.h" |
|
46 #include "cpsyrequestchannel.h" |
|
47 |
|
48 class CNetworkRegistrationStatusMonitor; |
|
49 class CRejectPrivacyRequestCallback; |
|
50 class CNetObserver; |
|
51 |
|
52 const TLbsNetSessionId KInvalidNetSessionId = TLbsNetSessionId(TUid::Uid(0x00000001), 0xACACACAC); |
|
53 |
|
54 class CProtocolModuleInfo : public CBase |
|
55 { |
|
56 public: |
|
57 static CProtocolModuleInfo* NewL(TLbsProtocolModuleId aModuleId, CNetObserver* aObs, CLbsNetworkProtocolBase* aNetworkProtocol, TBool aHome, TBool aRoaming); |
|
58 ~CProtocolModuleInfo(); |
|
59 |
|
60 TLbsProtocolModuleId ModuleUid(); |
|
61 void SetObserver(CNetObserver* aObserver); |
|
62 CNetObserver* Observer(); |
|
63 void SetProtocolModule(CLbsNetworkProtocolBase* aProtocolModule); |
|
64 CLbsNetworkProtocolBase* ProtocolModule(); |
|
65 void SetHome(); |
|
66 TBool Home(); |
|
67 void SetRoaming(); |
|
68 TBool Roaming(); |
|
69 |
|
70 private: |
|
71 CProtocolModuleInfo(TLbsProtocolModuleId aModuleId, CNetObserver* aObs, CLbsNetworkProtocolBase* aNetworkProtocol, TBool aHome, TBool aRoaming); |
|
72 void ConstructL(); |
|
73 |
|
74 private: |
|
75 TLbsProtocolModuleId iModuleId; |
|
76 CNetObserver* iObs; |
|
77 CLbsNetworkProtocolBase* iNetworkProtocol; |
|
78 TBool iHome; |
|
79 TBool iRoaming; |
|
80 }; |
|
81 |
|
82 |
|
83 /** The main class in the Network Gateway. |
|
84 |
|
85 This class acts as the junction point where messages to/from |
|
86 the network module are translated into messsages sent to/from |
|
87 the various components of the LBS sub-system. |
|
88 |
|
89 It contains a number of active objects to service the asynchronous |
|
90 requests coming from the other LBS components via either |
|
91 publish & subscribe (RProperty) or a message queue (RMsgQueue). |
|
92 |
|
93 It also implements the observer interface from the Network Protocol |
|
94 plugin module in order to receive messages from the network. |
|
95 |
|
96 */ |
|
97 class CNetworkGateway : public CBase, |
|
98 public MLbsNetworkProtocolObserver2, |
|
99 public MNetworkLocationObserver, |
|
100 public MAgpsObserver, |
|
101 public MNetworkRequestObserver, |
|
102 public MLbsProcessCloseDown, |
|
103 public MLbsProcessReset, |
|
104 public MNetworkRegistrationStatusObserver, |
|
105 public MPsyRequestObserver |
|
106 { |
|
107 friend class CNetObserver; |
|
108 |
|
109 public: |
|
110 static CNetworkGateway* NewL(); |
|
111 ~CNetworkGateway(); |
|
112 |
|
113 void SetReceivingProtocolModule(TLbsProtocolModuleId aId); |
|
114 |
|
115 protected: |
|
116 // Process messages coming in from other LBS sub-components |
|
117 |
|
118 //from MNetworkLocationObserver (NLM) |
|
119 void ProcessNetworkLocationMessage(const TLbsNetLocMsgBase& aMessage); |
|
120 |
|
121 // from MPsyRequestObserver |
|
122 void ProcessPsyMessage(const TLbsNetInternalMsgBase& aMessage); |
|
123 |
|
124 //from MNetworkRequestObserver |
|
125 void ProcessNetRequestMessage(const TLbsNetInternalMsgBase& aMessage); |
|
126 |
|
127 //from MAgpsObserver (from the AGPS manager) |
|
128 void OnAssistanceDataRequest(TLbsAsistanceDataGroupInt aDataItemMask); |
|
129 void OnSelfLocationRequest(const TLbsNetSessionIdInt& aSessionId, const TLbsNetPosRequestOptionsAssistanceInt& aOptions); |
|
130 void OnSelfLocationCancel(const TLbsNetSessionIdInt& aSessionId, TInt aReason); |
|
131 void OnSystemStatusAdvice(TBool aTracking); |
|
132 |
|
133 // from MNetworkRegistrationStatusObserver |
|
134 void OnNetworkRegistrationStatusChange( |
|
135 RLbsNetworkRegistrationStatus::TLbsNetworkRegistrationStatus aStatus); |
|
136 |
|
137 protected: |
|
138 // Process messages coming in from the network |
|
139 // (see MLbsNetworkProtocolObserver2) |
|
140 void GetCurrentCapabilities(TLbsNetPosCapabilities& aCapabilities) const; |
|
141 |
|
142 void ProcessStatusUpdate(TLbsNetProtocolServiceMask aActiveServiceMask); |
|
143 |
|
144 void ProcessPrivacyRequest(const TLbsNetSessionId& aSessionId, |
|
145 TBool aEmergency, |
|
146 const TLbsNetPosRequestPrivacy& aPrivacy, |
|
147 const TLbsExternalRequestInfo& aRequestInfo); |
|
148 |
|
149 void ProcessLocationRequest(const TLbsNetSessionId& aSessionId, |
|
150 TBool aEmergency, |
|
151 TLbsNetProtocolService aService, |
|
152 const TLbsNetPosRequestQuality& aQuality, |
|
153 const TLbsNetPosRequestMethod& aMethod); |
|
154 |
|
155 void ProcessSessionComplete(const TLbsNetSessionId& aSessionId, |
|
156 TInt aReason); |
|
157 |
|
158 void ProcessAssistanceData(TLbsAsistanceDataGroup aDataMask, |
|
159 const RLbsAssistanceDataBuilderSet& aData, |
|
160 TInt aReason); |
|
161 |
|
162 void ProcessAssistanceData(TLbsAsistanceDataGroup aDataMask, |
|
163 const RLbsAssistanceDataBuilderSet& aData, |
|
164 TInt aReason, |
|
165 const TLbsNetSessionIdArray& aSessionIdArray); |
|
166 |
|
167 void ProcessLocationUpdate(const TLbsNetSessionId& aSessionId, |
|
168 const TPositionInfoBase& aPosInfo); |
|
169 |
|
170 protected: |
|
171 // Process the close-down request from LbsRoot |
|
172 void OnProcessCloseDown(); |
|
173 |
|
174 // Process a (test-only) request to reset the internal state |
|
175 // of data buffers, etc. E.g. The assistance data properties. |
|
176 void OnProcessReset(); |
|
177 void ResetAssistanceDataBufferL(); |
|
178 |
|
179 |
|
180 private: |
|
181 |
|
182 CNetworkGateway(); |
|
183 void ConstructL(); |
|
184 |
|
185 // Values representing sessions that require module info to be stored. |
|
186 // Keep exactly in this order as we use these values to index into arrays. |
|
187 enum _TSessionTypes |
|
188 { |
|
189 ESelfLocation =0, |
|
190 ENetworkLocation, |
|
191 EPSYLocation, |
|
192 EX3p, // last of the SET Initiated |
|
193 EMtlrHome, |
|
194 EMtlrRoaming, |
|
195 EInvalidSession |
|
196 }; |
|
197 typedef TUint32 TSessionTypes; |
|
198 |
|
199 // Determine the original PM for a session using the given session id. |
|
200 CLbsNetworkProtocolBase* FindOriginalPMFromID(const TLbsNetSessionId& aId, TSessionTypes& aType); |
|
201 |
|
202 void LoadProtocolModuleL(TLbsProtocolModuleId aModuleId); |
|
203 |
|
204 CLbsNetworkProtocolBase* DefaultPm(); |
|
205 TBool ValidPm(TUid aPmUid); |
|
206 |
|
207 CProtocolModuleInfo* ModuleInfo(TLbsProtocolModuleId aUid); |
|
208 void DeleteLoadedModules(); |
|
209 |
|
210 CLbsAdmin::TGpsMode GetAdminGpsMode() const; |
|
211 |
|
212 TBool IsProtocolModulePermitted(TUid aProtocolUid) const; |
|
213 |
|
214 void ConvertToTLbsNetPosRequestQualityInt( |
|
215 const TLbsNetPosRequestQuality& aSource, |
|
216 TLbsNetPosRequestQualityInt& aDest) const; |
|
217 void ConvertToTLbsNetPosRequestQuality( |
|
218 const TLbsNetPosRequestQualityInt& aSource, |
|
219 TLbsNetPosRequestQuality& aDest) const; |
|
220 void ConvertToTLbsNetPosRequestOptions( |
|
221 const TLbsNetPosRequestOptionsInt& aSource, |
|
222 TLbsNetPosRequestOptions& aDest) const; |
|
223 void ConvertToTLbsNetPosRequestOptionsAssistance( |
|
224 const TLbsNetPosRequestOptionsAssistanceInt& aSource, |
|
225 TLbsNetPosRequestOptionsAssistance& aDest) const; |
|
226 void ConvertToTLbsNetPosRequestOptionsTechnology( |
|
227 const TLbsNetPosRequestOptionsTechnologyInt& aSource, |
|
228 TLbsNetPosRequestOptionsTechnology& aDest) const; |
|
229 private: |
|
230 CLbsAdmin* iAdmin; |
|
231 CNetworkLocationChannel* iNetworkLocationChannel; |
|
232 CAgpsChannel* iAgpsChannel; |
|
233 CNetworkRequestChannel* iNetworkRequestChannel; |
|
234 CPsyRequestChannel* iPSYChannel; |
|
235 CLbsCloseDownRequestDetector* iCloseDownRequestDetector; |
|
236 CNetworkRegistrationStatusMonitor* iNetworkRegistrationStatusMonitor; |
|
237 |
|
238 // Logging |
|
239 RLbsLogger iLogger; |
|
240 CLbsExternalLocateLogEvent* iExternalLogEvent; |
|
241 TBool iSeenLocationUpdate; |
|
242 TBool iCancelled; // Required as reason still comes into SessionComplete as KErrNone |
|
243 |
|
244 // Monitoring home/roaming status |
|
245 TLbsAdminProtocolModulesInfo::TLbsProtocolModuleIdArray iHomePmUidArray; |
|
246 TInt iHomePmCount; |
|
247 |
|
248 TLbsAdminProtocolModulesInfo::TLbsProtocolModuleIdArray iRoamingPmUidArray; |
|
249 TInt iRoamingPmCount; |
|
250 |
|
251 CProtocolModuleInfo* iModules[KLbsAdminMaxProtocolModuleIds*2]; |
|
252 RLbsNetworkRegistrationStatus::TLbsNetworkRegistrationStatus iRegistrationStatus; |
|
253 |
|
254 TInt iDefaultHomePmIndex; |
|
255 TInt iDefaultRoamingPmIndex; |
|
256 |
|
257 TUint iPmCount; |
|
258 TLbsAdminProtocolModuleLoadingInfo iLoadInfo; |
|
259 |
|
260 TLbsProtocolModuleId iHomePmUid; |
|
261 TLbsProtocolModuleId iRoamingPmUid; |
|
262 |
|
263 /** A member used to make callbacks asynchronously */ |
|
264 CRejectPrivacyRequestCallback* iRejectPrivacyRequest; |
|
265 |
|
266 // For all types of session, we store the module that is being used. |
|
267 CLbsNetworkProtocolBase* iModuleForSession[EInvalidSession]; |
|
268 |
|
269 TLbsProtocolModuleId iReceivingModuleId; |
|
270 #if defined(_DEBUG) |
|
271 CLbsOomListener* iOomListener; |
|
272 #endif |
|
273 |
|
274 // Session with the location monitor |
|
275 RLbsLocMonitorSession iLocMonSession; |
|
276 // Subsession with the location monitor |
|
277 RLbsLocMonitorAreaPositioner iLocMonSubSession; |
|
278 }; |
|
279 |
|
280 |
|
281 #endif // LBSNETGATEWAY_H_ |