|
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 // server side implementation of the LBS X3P request |
|
15 // |
|
16 // |
|
17 |
|
18 #include "lbsdevloggermacros.h" |
|
19 #include "lbsnrhx3pserver.h" |
|
20 #include "nrhpanic.h" |
|
21 #include "opensessionparams.h" |
|
22 #include <lbs/lbslocerrors.h> |
|
23 #include "lbsnrhmessageenums.h" |
|
24 #include <lbs/lbstransmitlocationlogevent.h> |
|
25 #include "lbsqualityprofile.h" |
|
26 #include "LbsInternalInterface.h" |
|
27 #include "lbsdevloggermacros.h" |
|
28 #include "lbssatellite.h" |
|
29 #include <lbs/lbsgpsmeasurement.h> |
|
30 |
|
31 CNrhX3pServerSubsession::CNrhX3pServerSubsession(RLbsLogger& aLogger) : |
|
32 iTransmitOptions(TTimeIntervalMicroSeconds(10000000)), |
|
33 iSessionId(), |
|
34 iRefLocErrorCode(KErrNone), |
|
35 iLogger(aLogger) |
|
36 { |
|
37 } |
|
38 |
|
39 CNrhX3pServerSubsession::~CNrhX3pServerSubsession() |
|
40 { |
|
41 if (iServer->X3pObserver() != NULL) |
|
42 { |
|
43 iServer->X3pObserver()->RemoveObserver(this); |
|
44 } |
|
45 |
|
46 // cancel ANY outstanding requests with KErrServerTerminated |
|
47 // or some other error code to indicate that the session has been closed |
|
48 // early |
|
49 if (!iTransmitPositionMessage.IsNull()) |
|
50 { |
|
51 #ifdef ENABLE_LBS_DEV_LOGGER |
|
52 TFileName* processName = new TFileName; |
|
53 if (processName != NULL) |
|
54 { |
|
55 LBSLOG_GETPROCESSNAME(iTransmitPositionMessage, *processName); |
|
56 if (processName->Length() > 0) |
|
57 { |
|
58 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(TransmitPosition) %S\n", processName); |
|
59 LBSLOG(ELogP9, " Return = KErrServerTerminated\n"); |
|
60 } |
|
61 delete processName; |
|
62 } |
|
63 #endif |
|
64 iTransmitPositionMessage.Complete(KErrServerTerminated); |
|
65 } |
|
66 |
|
67 if (!iReferencePositionMessage.IsNull()) |
|
68 { |
|
69 #ifdef ENABLE_LBS_DEV_LOGGER |
|
70 TFileName* processName = new TFileName; |
|
71 if (processName != NULL) |
|
72 { |
|
73 LBSLOG_GETPROCESSNAME(iReferencePositionMessage, *processName); |
|
74 if (processName->Length() > 0) |
|
75 { |
|
76 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(ReportReferenceLocation) %S\n", processName); |
|
77 LBSLOG(ELogP9, " Return = KErrServerTerminated\n"); |
|
78 } |
|
79 delete processName; |
|
80 } |
|
81 #endif |
|
82 iReferencePositionMessage.Complete(KErrServerTerminated); |
|
83 } |
|
84 } |
|
85 |
|
86 CNrhX3pServerSubsession* CNrhX3pServerSubsession::NewL(RLbsLogger& aLogger) |
|
87 { |
|
88 CNrhX3pServerSubsession* self = new (ELeave) CNrhX3pServerSubsession(aLogger); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop(self); |
|
92 return self; |
|
93 } |
|
94 |
|
95 void CNrhX3pServerSubsession::ConstructL() |
|
96 { |
|
97 CLbsAdmin* admin = CLbsAdmin::NewL(); |
|
98 CleanupStack::PushL(admin); |
|
99 // Set the default X3P timeout to one in the current profile: |
|
100 |
|
101 // Retrieve the Id of the quality profile to use |
|
102 TLbsQualityProfileId profileId(KLbsNullQualityProfileId); |
|
103 admin->Get(KLbsSettingQualityProfileTransmitLocate, profileId); |
|
104 |
|
105 // Retrieve the data for the quality profile |
|
106 TQualityProfile qualityProfile; |
|
107 TInt err = LbsQualityProfile::GetQualityProfileById(profileId, qualityProfile); |
|
108 if (err == KErrNone) |
|
109 { |
|
110 // Use the maxfix time from the quality profile |
|
111 iTransmitOptions.SetTimeOut(qualityProfile.MaxFixTime()); |
|
112 } |
|
113 CleanupStack::PopAndDestroy(admin); |
|
114 } |
|
115 |
|
116 // from MSubSessionImpl |
|
117 void CNrhX3pServerSubsession::DispatchL(const RMessage2& aMessage) |
|
118 { |
|
119 switch(aMessage.Function()) |
|
120 { |
|
121 case EX3pTransmitPosition: |
|
122 TransmitPosition(aMessage); |
|
123 break; |
|
124 |
|
125 case EX3pCancelTransmitPosition: |
|
126 CancelTransmitPosition(aMessage); |
|
127 break; |
|
128 |
|
129 case EX3pSetTransmitOptions: |
|
130 SetTransmitOptions(aMessage); |
|
131 break; |
|
132 |
|
133 case EX3pGetTransmitOptions: |
|
134 GetTransmitOptions(aMessage); |
|
135 break; |
|
136 |
|
137 case EX3pReportReferenceLocation: |
|
138 ReportReferenceLocation(aMessage); |
|
139 break; |
|
140 } |
|
141 |
|
142 } |
|
143 void CNrhX3pServerSubsession::DispatchError(const RMessage2& /*aMessage*/, |
|
144 TInt /*aError*/) |
|
145 { |
|
146 |
|
147 } |
|
148 |
|
149 void CNrhX3pServerSubsession::CreateSubSessionL(const RMessage2& /*aMessage*/, |
|
150 const CSecureServerBase* aServer) |
|
151 { |
|
152 __ASSERT_DEBUG(aServer != NULL, Panic(ENrhPanicInvalidServerPointer)); |
|
153 |
|
154 // Get hold of something for this subsession |
|
155 // to pass on its messages to |
|
156 iServer = static_cast<const CNrhServer*>(aServer); |
|
157 |
|
158 // Register as an observer of the X3P Handler |
|
159 if (iServer->X3pObserver() != NULL) |
|
160 { |
|
161 iServer->X3pObserver()->AddObserverL(this); |
|
162 } |
|
163 } |
|
164 |
|
165 void CNrhX3pServerSubsession::CloseSubSession() |
|
166 { |
|
167 } |
|
168 |
|
169 // via MSubSessionImpl::MRelease |
|
170 void CNrhX3pServerSubsession::VirtualRelease() |
|
171 { |
|
172 //delete ourselves - can be called on a via CS on a leave |
|
173 delete this; // we are allocated via GetImpl(), and a handle to "us" is returned |
|
174 } |
|
175 |
|
176 void CNrhX3pServerSubsession::TransmitPosition(const RMessage2& aMessage) |
|
177 { |
|
178 // If a preceding request for reference location failed |
|
179 // make this request fail with the same error code. |
|
180 // |
|
181 if (iRefLocErrorCode != KErrNone) |
|
182 { |
|
183 #ifdef ENABLE_LBS_DEV_LOGGER |
|
184 TFileName* processName = new TFileName; |
|
185 if (processName != NULL) |
|
186 { |
|
187 LBSLOG_GETPROCESSNAME(aMessage, *processName); |
|
188 if (processName->Length() > 0) |
|
189 { |
|
190 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(TransmitPosition) %S\n", processName); |
|
191 LBSLOG2(ELogP9, " Return = %d\n", iRefLocErrorCode); |
|
192 } |
|
193 delete processName; |
|
194 } |
|
195 #endif |
|
196 aMessage.Complete(iRefLocErrorCode); |
|
197 iRefLocErrorCode = KErrNone; |
|
198 return; |
|
199 } |
|
200 |
|
201 // Check that this sub-session doesn't already |
|
202 // have an outstanding request |
|
203 if (!iTransmitPositionMessage.IsNull()) |
|
204 { |
|
205 #ifdef ENABLE_LBS_DEV_LOGGER |
|
206 TFileName* processName = new TFileName; |
|
207 if (processName != NULL) |
|
208 { |
|
209 LBSLOG_GETPROCESSNAME(aMessage, *processName); |
|
210 if (processName->Length() > 0) |
|
211 { |
|
212 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::Panic(TransmitPosition) %S\n", processName); |
|
213 LBSLOG2(ELogP9, " Return = %d\n", EPositionDuplicateRequest); |
|
214 } |
|
215 delete processName; |
|
216 } |
|
217 #endif |
|
218 aMessage.Panic(KPosClientFault, EPositionDuplicateRequest); |
|
219 return; |
|
220 } |
|
221 |
|
222 // Check that Transmit Position is allowed by |
|
223 // the LbsAdmin setting |
|
224 if (!CheckTransmitPositionAdminSettings()) |
|
225 { |
|
226 // Transmit Position not allowed; complete the client |
|
227 // requests with an error |
|
228 |
|
229 if (!iReferencePositionMessage.IsNull()) |
|
230 { |
|
231 #ifdef ENABLE_LBS_DEV_LOGGER |
|
232 TFileName* processName = new TFileName; |
|
233 if (processName != NULL) |
|
234 { |
|
235 LBSLOG_GETPROCESSNAME(iReferencePositionMessage, *processName); |
|
236 if (processName->Length()> 0) |
|
237 { |
|
238 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(ReportReferenceLocation) %S\n", processName); |
|
239 LBSLOG(ELogP9, " Return = KErrAccessDenied\n"); |
|
240 } |
|
241 delete processName; |
|
242 } |
|
243 #endif |
|
244 iReferencePositionMessage.Complete(KErrAccessDenied); |
|
245 } |
|
246 #ifdef ENABLE_LBS_DEV_LOGGER |
|
247 TFileName* processName = new TFileName; |
|
248 if (processName != NULL) |
|
249 { |
|
250 LBSLOG_GETPROCESSNAME(aMessage, *processName); |
|
251 if (processName->Length()> 0) |
|
252 { |
|
253 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(TransmitPosition) %S\n", processName); |
|
254 LBSLOG(ELogP9, " Return = KErrAccessDenied\n"); |
|
255 } |
|
256 delete processName; |
|
257 } |
|
258 #endif |
|
259 aMessage.Complete(KErrAccessDenied); |
|
260 |
|
261 return; |
|
262 } |
|
263 |
|
264 // Read in the request parameters |
|
265 TPtr8 ptr(reinterpret_cast<TUint8*>(&iTransmitParams), |
|
266 sizeof(iTransmitParams), |
|
267 sizeof(iTransmitParams)); |
|
268 TInt err = MessageUtils::Read(aMessage, 0, ptr); // this panics client if there's an error |
|
269 if (err == KErrNone) |
|
270 { |
|
271 // Request a new X3P from the X3P handler. |
|
272 if(iServer->X3pObserver() != NULL) |
|
273 { |
|
274 err = iServer->X3pObserver()->OnTransmitPosition(iTransmitParams.iDestinationId, |
|
275 iTransmitParams.iPriority, |
|
276 iTransmitOptions, |
|
277 iSessionId); |
|
278 |
|
279 } |
|
280 else |
|
281 { |
|
282 err = KErrNotFound; |
|
283 } |
|
284 if (err != KErrNone) |
|
285 { |
|
286 // Error starting the X3P request, so complete the |
|
287 // client request with the error. |
|
288 #ifdef ENABLE_LBS_DEV_LOGGER |
|
289 TFileName * processName = new TFileName; |
|
290 if (processName != NULL) |
|
291 { |
|
292 LBSLOG_GETPROCESSNAME(aMessage, *processName); |
|
293 if (processName->Length()> 0) |
|
294 { |
|
295 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(TransmitPosition) %S\n", processName); |
|
296 LBSLOG2(ELogP9, " Return = %d\n", err); |
|
297 } |
|
298 delete processName; |
|
299 } |
|
300 #endif |
|
301 aMessage.Complete(err); |
|
302 } |
|
303 else |
|
304 { |
|
305 // Store the message to be completed asynchronously. |
|
306 iTransmitPositionMessage = aMessage; |
|
307 |
|
308 // Store the position info size - this is |
|
309 // used when writing the sent position back to the client. |
|
310 |
|
311 iClientPosInfoClassSize = iTransmitParams.iPositionInfoClassSize; |
|
312 |
|
313 // Need the secure id of the client for logging |
|
314 RThread client; |
|
315 aMessage.Client(client); |
|
316 iClientUid = client.SecureId(); |
|
317 } |
|
318 } |
|
319 } |
|
320 |
|
321 void CNrhX3pServerSubsession::CancelTransmitPosition(const RMessage2& aMessage) |
|
322 { |
|
323 if(iServer->X3pObserver() != NULL) |
|
324 { |
|
325 iServer->X3pObserver()->OnCancelTransmitPosition(iSessionId); |
|
326 } |
|
327 aMessage.Complete(KErrNone); |
|
328 } |
|
329 |
|
330 void CNrhX3pServerSubsession::SetTransmitOptions(const RMessage2& aMessage) |
|
331 { |
|
332 TPckg<TLbsTransmitPositionOptions> optionsPckg(iTransmitOptions); |
|
333 TInt err = MessageUtils::Read(aMessage, 0, optionsPckg); |
|
334 aMessage.Complete(err); |
|
335 } |
|
336 |
|
337 void CNrhX3pServerSubsession::GetTransmitOptions(const RMessage2& aMessage) |
|
338 { |
|
339 TPckg<TLbsTransmitPositionOptions> optionsPckg(iTransmitOptions); |
|
340 TInt err = MessageUtils::Write(aMessage, 0, optionsPckg); |
|
341 aMessage.Complete(err); |
|
342 } |
|
343 |
|
344 void CNrhX3pServerSubsession::ReportReferenceLocation(const RMessage2& aMessage) |
|
345 { |
|
346 // Check that this sub-session doesn't already |
|
347 // have an outstanding request |
|
348 if ((!iTransmitPositionMessage.IsNull()) || (!iReferencePositionMessage.IsNull())) |
|
349 { |
|
350 #ifdef ENABLE_LBS_DEV_LOGGER |
|
351 TFileName* processName = new TFileName; |
|
352 if (processName != NULL) |
|
353 { |
|
354 LBSLOG_GETPROCESSNAME(aMessage, *processName); |
|
355 if (processName->Length() > 0) |
|
356 { |
|
357 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::Panic(ReportReferenceLocation) %S\n", processName); |
|
358 LBSLOG2(ELogP9, " Return = %d\n", EPositionDuplicateRequest); |
|
359 } |
|
360 delete processName; |
|
361 } |
|
362 #endif |
|
363 aMessage.Panic(KPosClientFault, EPositionDuplicateRequest); |
|
364 } |
|
365 |
|
366 // Check that Transmit Position is allowed by |
|
367 // the LbsAdmin setting |
|
368 if (!CheckTransmitPositionAdminSettings()) |
|
369 { |
|
370 // Transmit Position not allowed; complete the client |
|
371 // request with an error |
|
372 #ifdef ENABLE_LBS_DEV_LOGGER |
|
373 TFileName* processName = new TFileName; |
|
374 if (processName != NULL) |
|
375 { |
|
376 LBSLOG_GETPROCESSNAME(aMessage, *processName); |
|
377 if (processName->Length() > 0) |
|
378 { |
|
379 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(ReportReferenceLocation) %S\n", processName); |
|
380 LBSLOG(ELogP9, " Return = KErrAccessDenied\n"); |
|
381 } |
|
382 delete processName; |
|
383 } |
|
384 #endif |
|
385 aMessage.Complete(KErrAccessDenied); |
|
386 |
|
387 // Make sure the Transmit Location request following this |
|
388 // failed ReportReferenceLocation won't be serviced either |
|
389 iRefLocErrorCode = KErrAccessDenied; |
|
390 return; |
|
391 } |
|
392 else |
|
393 { |
|
394 // Read in the request parameters |
|
395 TTransmitPositionParams params; |
|
396 TPtr8 ptr(reinterpret_cast<TUint8*>(¶ms), |
|
397 sizeof(params), |
|
398 sizeof(params)); |
|
399 TInt err = MessageUtils::Read(aMessage, 0, ptr); // this panics client if there's an error |
|
400 if (err == KErrNone) |
|
401 { |
|
402 // Store the message to be completed asynchronously. |
|
403 iReferencePositionMessage = aMessage; |
|
404 |
|
405 // Store the position info type and size - these are |
|
406 // used when writing the sent position back to the client. |
|
407 iClientRefPosInfoClassSize = params.iPositionInfoClassSize; |
|
408 } |
|
409 } |
|
410 } |
|
411 |
|
412 void CNrhX3pServerSubsession::OnTransmitLocationComplete(const TLbsNetSessionIdInt& aSessionId, |
|
413 const TPositionInfoBase& aPositionInfo, |
|
414 TInt aReason) |
|
415 { |
|
416 // Check to see if the completed request is the |
|
417 // one started by this subsession. |
|
418 if (aSessionId == iSessionId) |
|
419 { |
|
420 // There may be an outstanding request for |
|
421 // reference location when the Transmit Location |
|
422 // is cancelled or times out. |
|
423 if (!iReferencePositionMessage.IsNull()) |
|
424 { |
|
425 // There's no reference position at this point. |
|
426 #ifdef ENABLE_LBS_DEV_LOGGER |
|
427 TFileName* processName = new TFileName; |
|
428 if (processName != NULL) |
|
429 { |
|
430 LBSLOG_GETPROCESSNAME(iReferencePositionMessage, *processName); |
|
431 if (processName->Length() > 0) |
|
432 { |
|
433 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(ReportReferenceLocation) %S\n", processName); |
|
434 LBSLOG(ELogP9, " < TPositionInfoBase aPositionInfo = \n"); |
|
435 LBSLOG_TPOSITIONINFOBASE(aPositionInfo); |
|
436 LBSLOG2(ELogP9, " Return = %d\n", aReason); |
|
437 } |
|
438 delete processName; |
|
439 } |
|
440 #endif |
|
441 iReferencePositionMessage.Complete(aReason); |
|
442 } |
|
443 |
|
444 // Only write the position back if there was no error. |
|
445 TInt err(KErrNone); |
|
446 if (aReason == KErrNone || aReason == KPositionQualityLoss) |
|
447 { |
|
448 // Need to do this in two steps: |
|
449 // 1) copy aPositionInfo into a local position info type |
|
450 // that is the same as the client(?!?) |
|
451 // 2) write the local position info into the client memory |
|
452 // |
|
453 // Edge cases: |
|
454 // 1) aPositionInfo is a smaller type than the client is expecting; |
|
455 // do we copy just the data in aPositionInfo, and change the |
|
456 // 'type' data of the client pos info, or copy over the data |
|
457 // in aPositionInfo and leave the missing bits as junk? |
|
458 // 2) The client pos info is smaller than aPositionInfo - just |
|
459 // copy over the data that will fit in? |
|
460 |
|
461 // Current strategy: copy over data equal to the size of |
|
462 // the client position info, minus the class type at the |
|
463 // start. This will leave the client position info class |
|
464 // type as it was, but copy over the data it covers and no |
|
465 // more. if aPositionInfo is a bigger type, the extra data |
|
466 // is ignored; if it is smaller, then the 'missing' extra |
|
467 // data will be junk when written into the client. |
|
468 const TUint8* start = reinterpret_cast<const TUint8*>(&aPositionInfo) + sizeof(TPositionClassTypeBase); |
|
469 TInt length = (iClientPosInfoClassSize - sizeof(TPositionClassTypeBase)); |
|
470 TPtr8 ptr(const_cast<TUint8*>(start), length, length); |
|
471 err = iTransmitPositionMessage.Write(1, ptr, sizeof(TPositionClassTypeBase)); |
|
472 if(err) |
|
473 { |
|
474 #ifdef ENABLE_LBS_DEV_LOGGER |
|
475 TFileName* processName = new TFileName; |
|
476 if (processName != NULL) |
|
477 { |
|
478 LBSLOG_GETPROCESSNAME(iTransmitPositionMessage, *processName); |
|
479 if (processName->Length() > 0) |
|
480 { |
|
481 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::Panic(TransmitPosition) %S\n", processName); |
|
482 LBSLOG2(ELogP9, " Return = %d\n", err); |
|
483 } |
|
484 delete processName; |
|
485 } |
|
486 #endif |
|
487 _LIT(KServerMessageUtilsWrite8, "RMessageWrite8"); |
|
488 iTransmitPositionMessage.Panic(KServerMessageUtilsWrite8, err); |
|
489 } |
|
490 } |
|
491 |
|
492 if (err == KErrNone) |
|
493 { |
|
494 #ifdef ENABLE_LBS_DEV_LOGGER |
|
495 TFileName* processName = new TFileName; |
|
496 if (processName != NULL) |
|
497 { |
|
498 LBSLOG_GETPROCESSNAME(iTransmitPositionMessage, *processName); |
|
499 if (processName->Length() > 0) |
|
500 { |
|
501 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(TransmitPosition) %S\n", processName); |
|
502 LBSLOG(ELogP9, " < TPositionInfoBase aPositionInfo = \n"); |
|
503 LBSLOG_TPOSITIONINFOBASE(aPositionInfo); |
|
504 LBSLOG2(ELogP9, " Return = %d\n", aReason); |
|
505 } |
|
506 delete processName; |
|
507 } |
|
508 #endif |
|
509 iTransmitPositionMessage.Complete(aReason); |
|
510 } |
|
511 |
|
512 /** LBSLOGGER - Start Logging */ |
|
513 // ------------------------------------------------------------------------- |
|
514 CLbsTransmitLocationLogEvent* event = NULL; |
|
515 TPositionInfoBase& position = const_cast<TPositionInfoBase&>(aPositionInfo); |
|
516 TInt err2(KErrNone); |
|
517 if(position.PositionClassType() != EPositionGpsMeasurementInfoClass) |
|
518 { |
|
519 TRAP(err2, event = CLbsTransmitLocationLogEvent::NewL(iClientUid, &position, iTransmitParams.iDestinationId)); |
|
520 } |
|
521 else |
|
522 { |
|
523 TRAP(err2, event = CLbsTransmitLocationLogEvent::NewL(iClientUid, NULL, iTransmitParams.iDestinationId)); |
|
524 } |
|
525 if (err2 == KErrNone) |
|
526 { |
|
527 event->SetX3PApp(iClientUid); |
|
528 switch (aReason) |
|
529 { |
|
530 case KErrNone: |
|
531 { |
|
532 event->SetRequestOutcome(ELbsRequestOutcomeSuccess); |
|
533 break; |
|
534 } |
|
535 case KErrCancel: |
|
536 { |
|
537 event->SetRequestOutcome(ELbsRequestOutcomeCancel); |
|
538 break; |
|
539 } |
|
540 default: |
|
541 { |
|
542 event->SetRequestOutcome(ELbsRequestOutcomeFail); |
|
543 break; |
|
544 } |
|
545 } |
|
546 |
|
547 iLogger.AddEvent(*event); |
|
548 |
|
549 delete event; |
|
550 } |
|
551 // ------------------------------------------------------------------------- |
|
552 /** LBSLOGGER - End Logging */ |
|
553 } |
|
554 } |
|
555 |
|
556 void CNrhX3pServerSubsession::OnReferenceLocationAvailable(const TLbsNetSessionIdInt& aSessionId, |
|
557 const TPositionInfoBase& aPositionInfo) |
|
558 { |
|
559 // Do nothing if the client doesn't want to know about Reference Location |
|
560 if (iReferencePositionMessage.IsNull()) |
|
561 { |
|
562 return; |
|
563 } |
|
564 |
|
565 // Check if the completed request is the |
|
566 // one started by this subsession. |
|
567 if (aSessionId == iSessionId) |
|
568 { |
|
569 |
|
570 TInt err(KErrNone); |
|
571 const TUint8* start = reinterpret_cast<const TUint8*>(&aPositionInfo) + sizeof(TPositionClassTypeBase); |
|
572 TInt length = (iClientRefPosInfoClassSize - sizeof(TPositionClassTypeBase)); |
|
573 TPtr8 ptr(const_cast<TUint8*>(start), length, length); |
|
574 err = iReferencePositionMessage.Write(1, ptr, sizeof(TPositionClassTypeBase)); |
|
575 |
|
576 if (err == KErrNone) |
|
577 { |
|
578 #ifdef ENABLE_LBS_DEV_LOGGER |
|
579 TFileName* processName = new TFileName; |
|
580 if (processName != NULL) |
|
581 { |
|
582 LBSLOG_GETPROCESSNAME(iReferencePositionMessage, *processName); |
|
583 if (processName->Length() > 0) |
|
584 { |
|
585 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::RunL(ReportReferenceLocation) %S\n", processName); |
|
586 LBSLOG(ELogP9, " < TPositionInfoBase aPositionInfo = \n"); |
|
587 LBSLOG_TPOSITIONINFOBASE(aPositionInfo); |
|
588 LBSLOG(ELogP9, " Return = KErrNone\n"); |
|
589 } |
|
590 delete processName; |
|
591 } |
|
592 #endif |
|
593 iReferencePositionMessage.Complete(KErrNone); |
|
594 } |
|
595 else |
|
596 { |
|
597 #ifdef ENABLE_LBS_DEV_LOGGER |
|
598 TFileName* processName = new TFileName; |
|
599 if (processName != NULL) |
|
600 { |
|
601 LBSLOG_GETPROCESSNAME(iReferencePositionMessage, *processName); |
|
602 if (processName->Length() > 0) |
|
603 { |
|
604 LBSLOG2(ELogP9, "->A RLbsTransmitPosition::Panic(ReportReferenceLocation) %S\n", processName); |
|
605 LBSLOG2(ELogP9, " Return = %d\n", err); |
|
606 } |
|
607 delete processName; |
|
608 } |
|
609 #endif |
|
610 _LIT(KServerMessageUtilsWrite8, "RMessageWrite8"); |
|
611 iReferencePositionMessage.Panic(KServerMessageUtilsWrite8, err); |
|
612 } |
|
613 } |
|
614 } |
|
615 |
|
616 /* Check that an X3P is allowed, given the current network roaming status |
|
617 */ |
|
618 TBool CNrhX3pServerSubsession::CheckTransmitPositionAdminSettings() |
|
619 { |
|
620 TBool x3pAllowed(EFalse); |
|
621 CLbsAdmin::TTransmitLocateService serviceStatus(CLbsAdmin::ETransmitLocateOff); |
|
622 RLbsNetworkRegistrationStatus::TLbsNetworkRegistrationStatus netRegStatus(RLbsNetworkRegistrationStatus::ENetworkRegistrationUnknown); |
|
623 |
|
624 CNrhServer* nrhServer = const_cast<CNrhServer*>(iServer); |
|
625 TInt err = nrhServer->NetworkRegistrationStatus().GetNetworkRegistrationStatus(netRegStatus); |
|
626 if (err == KErrNone) |
|
627 { |
|
628 switch (netRegStatus) |
|
629 { |
|
630 case RLbsNetworkRegistrationStatus::ERegisteredHomeNetwork: |
|
631 { |
|
632 err = iServer->Admin()->Get(KLbsSettingHomeTransmitLocate, serviceStatus); |
|
633 break; |
|
634 } |
|
635 case RLbsNetworkRegistrationStatus::ERegisteredRoamingNetwork: |
|
636 case RLbsNetworkRegistrationStatus::ENotRegistered: |
|
637 { |
|
638 err = iServer->Admin()->Get(KLbsSettingRoamingTransmitLocate, serviceStatus); |
|
639 break; |
|
640 } |
|
641 case RLbsNetworkRegistrationStatus::ENetworkRegistrationUnknown: |
|
642 default: |
|
643 { |
|
644 LBSLOG_WARN2(ELogP4, |
|
645 "Unrecognised TLbsNetworkRegistrationStatus (%d), defaulting to not allowing new X3P", |
|
646 netRegStatus); |
|
647 serviceStatus = CLbsAdmin::ETransmitLocateOff; |
|
648 break; |
|
649 } |
|
650 } |
|
651 |
|
652 if (serviceStatus == CLbsAdmin::ETransmitLocateOn) |
|
653 { |
|
654 x3pAllowed = ETrue; |
|
655 } |
|
656 } |
|
657 |
|
658 return x3pAllowed; |
|
659 } |