|
1 // Copyright (c) 2005-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 // Client API to the LBS Network Simulator for |
|
15 // the (test) LBS protocol module. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalTechnology |
|
22 @released |
|
23 */ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <e32debug.h> |
|
27 #include <ecom/ecom.h> |
|
28 #include <lbs/lbsadmin.h> |
|
29 #include "lbsdevloggermacros.h" |
|
30 #include "csecureprocessasbase.h" |
|
31 #include "netgateway.h" |
|
32 #include "lbsngnlmint.h" |
|
33 |
|
34 |
|
35 // moved from the netgatewaymain.cpp file to maintain neutrality of that file. |
|
36 CBase* CSecureProcessASBase::CreateRootObjectL() |
|
37 { |
|
38 CNetworkGateway* server = CNetworkGateway::NewL(); |
|
39 return server; |
|
40 } |
|
41 |
|
42 TInt CSecureProcessASBase::EntryPointL(CBase* /*aBaseObj*/) |
|
43 { |
|
44 // EntryPointL not used by CNetGateway |
|
45 return KErrNone; |
|
46 } |
|
47 |
|
48 void CSecureProcessASBase::Final() |
|
49 { |
|
50 } |
|
51 |
|
52 |
|
53 // |
|
54 // CNetworkGateway |
|
55 // |
|
56 |
|
57 /** |
|
58 */ |
|
59 CNetworkGateway* CNetworkGateway::NewL() |
|
60 { |
|
61 CNetworkGateway* self = new (ELeave) CNetworkGateway; |
|
62 CleanupStack::PushL(self); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(self); |
|
65 return self; |
|
66 } |
|
67 |
|
68 /** |
|
69 */ |
|
70 CNetworkGateway::CNetworkGateway() : |
|
71 iCurrentNetLocReqId(KInvalidNetSessionId), |
|
72 iNetLocReqLocReqReceived(EFalse) |
|
73 { |
|
74 } |
|
75 |
|
76 /** |
|
77 */ |
|
78 CNetworkGateway::~CNetworkGateway() |
|
79 { |
|
80 delete iNetworkLocationChannel; |
|
81 |
|
82 delete iCloseDownRequestDetector; |
|
83 |
|
84 REComSession::FinalClose(); |
|
85 } |
|
86 |
|
87 /** |
|
88 */ |
|
89 void CNetworkGateway::ConstructL() |
|
90 { |
|
91 iCloseDownRequestDetector = CLbsCloseDownRequestDetector::NewL(this, KLbsNetLocManagerUid); |
|
92 iNetworkLocationChannel = CNetworkLocationChannel::NewL(*this); |
|
93 } |
|
94 |
|
95 |
|
96 void CNetworkGateway::GetCurrentCapabilities(TLbsNetPosCapabilities& /*aCapabilities*/) const |
|
97 { |
|
98 } |
|
99 |
|
100 void CNetworkGateway::ProcessStatusUpdate(TLbsNetProtocolServiceMask /*aActiveServiceMask*/) |
|
101 { |
|
102 } |
|
103 |
|
104 void CNetworkGateway::ProcessPrivacyRequest(const TLbsNetSessionId& /*aSessionId*/, |
|
105 TBool /*aEmergency*/, |
|
106 const TLbsNetPosRequestPrivacy& /*aPrivacy*/, |
|
107 const TLbsExternalRequestInfo& /*aRequestInfo*/) |
|
108 { |
|
109 } |
|
110 |
|
111 void CNetworkGateway::ProcessLocationRequest(const TLbsNetSessionId& /*aSessionId*/, |
|
112 TBool /*aEmergency*/, |
|
113 TLbsNetProtocolService /*aService*/, |
|
114 const TLbsNetPosRequestQuality& /*aQuality*/, |
|
115 const TLbsNetPosRequestMethod& /*aMethod*/) |
|
116 { |
|
117 } |
|
118 |
|
119 void CNetworkGateway::ProcessSessionComplete(const TLbsNetSessionId& /*aSessionId*/, |
|
120 TInt /*aReason*/) |
|
121 { |
|
122 } |
|
123 |
|
124 |
|
125 void CNetworkGateway::ProcessAssistanceData(TLbsAsistanceDataGroup /*aDataMask*/, |
|
126 const RLbsAssistanceDataBuilderSet& /*aData*/, |
|
127 TInt /*aReason*/) |
|
128 { |
|
129 } |
|
130 |
|
131 void CNetworkGateway::ProcessNetworkBasedLocation(const TPositionInfoBase& /*aPosInfo*/) |
|
132 { |
|
133 } |
|
134 |
|
135 |
|
136 void CNetworkGateway::ProcessLocationUpdate(const TLbsNetSessionId& /*aSessionId*/, |
|
137 const TPositionInfoBase& /*aPosInfo*/) |
|
138 { |
|
139 } |
|
140 |
|
141 |
|
142 void CNetworkGateway::ProcessNetworkLocationMessage(const TLbsNetLocMsgBase& aMessage) |
|
143 { |
|
144 LBSLOG(ELogP2, "CNetworkGateway::ProcessNetworkLocationMessage:"); |
|
145 LBSLOG2(ELogP3, "Type : %d", aMessage.Type()); |
|
146 |
|
147 switch (aMessage.Type()) |
|
148 { |
|
149 case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationRequest: |
|
150 { |
|
151 TInt reason = KErrNone; |
|
152 const TLbsNetLocNetworkLocationRequestMsg& req = static_cast<const TLbsNetLocNetworkLocationRequestMsg&>(aMessage); |
|
153 iCurrentNetLocReqId = req.SessionId(); |
|
154 |
|
155 if (req.Quality().MaxFixTime() == 0)//answer req with incorrect session id |
|
156 { |
|
157 iCurrentNetLocReqId.SetSessionNum(999); |
|
158 TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason); |
|
159 iNetworkLocationChannel->SendNetworkLocationMessage(msg); |
|
160 } |
|
161 |
|
162 else if (req.Quality().MaxFixTime() == 1)//answer req with unknown response type |
|
163 { |
|
164 TLbsNetLocNetworkLocationCancelMsg msg(iCurrentNetLocReqId, reason); |
|
165 iNetworkLocationChannel->SendNetworkLocationMessage(msg); |
|
166 } |
|
167 |
|
168 else |
|
169 { |
|
170 TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason); |
|
171 iNetworkLocationChannel->SendNetworkLocationMessage(msg); |
|
172 } |
|
173 |
|
174 // for testing return a fixed test location |
|
175 TPositionCourseInfo posInfo; |
|
176 TPosition pos; |
|
177 pos.SetCoordinate(50, 80); |
|
178 posInfo.SetPosition(pos); |
|
179 |
|
180 TCourse course; |
|
181 course.SetSpeed(10.0); |
|
182 course.SetVerticalSpeed(20.0); |
|
183 course.SetHeading(30.0); |
|
184 course.SetSpeedAccuracy(1.0); |
|
185 course.SetVerticalSpeedAccuracy(2.0); |
|
186 course.SetHeadingAccuracy(3.0); |
|
187 course.SetCourse(40.0); |
|
188 course.SetCourseAccuracy(4.0); |
|
189 |
|
190 posInfo.SetCourse(course); |
|
191 |
|
192 iNetworkLocationChannel->SetReferencePosition(iCurrentNetLocReqId, posInfo); |
|
193 break; |
|
194 } |
|
195 case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationCancel: |
|
196 { |
|
197 const TLbsNetLocNetworkLocationCancelMsg& cancel = static_cast<const TLbsNetLocNetworkLocationCancelMsg&>(aMessage); |
|
198 // for test netlocmanager, return the location info directly without sending request to network protocol |
|
199 iCurrentNetLocReqId = cancel.SessionId(); |
|
200 TInt reason = KErrNone; |
|
201 TLbsNetLocNetworkLocationCompleteMsg msg(iCurrentNetLocReqId, reason); |
|
202 iNetworkLocationChannel->SendNetworkLocationMessage(msg); |
|
203 break; |
|
204 } |
|
205 case TLbsNetLocMsgBase::ENetLocMsgNetworkLocationComplete: |
|
206 default: |
|
207 { |
|
208 break; |
|
209 } |
|
210 } |
|
211 } |
|
212 |
|
213 void CNetworkGateway::ProcessAssistanceDataRequest(TLbsAsistanceDataGroup /*aDataMask*/) |
|
214 { |
|
215 } |
|
216 |
|
217 |
|
218 void CNetworkGateway::ProcessNetRequestMessage(const TLbsNetInternalMsgBase& /*aMessage*/) |
|
219 { |
|
220 } |
|
221 |
|
222 /* Observer that is called when LbsRoot has requested the Network Gateway to shutdown. |
|
223 */ |
|
224 void CNetworkGateway::OnProcessCloseDown() |
|
225 { |
|
226 // For now, simply close down as soon as possible. |
|
227 // In future the close down may need to be asynchronous, |
|
228 // to allow the buffers in CAgpsChannel and CNetRequestChannel |
|
229 // to be processed normally. |
|
230 |
|
231 iNetworkLocationChannel->Cancel(); |
|
232 CActiveScheduler::Stop(); |
|
233 } |
|
234 |