|
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 // |
|
15 |
|
16 #include <e32base.h> |
|
17 |
|
18 // LBS-specific |
|
19 #include <lbs.h> |
|
20 #include <lbs/lbslocerrors.h> |
|
21 #include "lbsdevloggermacros.h" |
|
22 |
|
23 #include "lbsprocessuiddefs.h" |
|
24 #include "ngmessageswitch.h" |
|
25 #include "lbsnetinternalapi.h" |
|
26 #include "nrhpanic.h" |
|
27 |
|
28 |
|
29 // |
|
30 // CNGMessageSendBufferBase |
|
31 // |
|
32 |
|
33 CNGMessageSendBufferBase::CNGMessageSendBufferBase(RLbsNetChannel& aGatewayChannel, CLbsAdmin& aAdmin) : |
|
34 CActive(EPriorityStandard), |
|
35 iAdmin(aAdmin), |
|
36 iNetGatewayChannel(aGatewayChannel) |
|
37 |
|
38 { |
|
39 CActiveScheduler::Add(this); |
|
40 } |
|
41 |
|
42 CNGMessageSendBufferBase::~CNGMessageSendBufferBase() |
|
43 { |
|
44 Cancel(); |
|
45 } |
|
46 |
|
47 void CNGMessageSendBufferBase::RunL() |
|
48 { |
|
49 // This must be implemented by the child class, so leave here |
|
50 User::Leave(KErrNotSupported); |
|
51 } |
|
52 |
|
53 void CNGMessageSendBufferBase::DoCancel() |
|
54 { |
|
55 iNetGatewayChannel.CancelSendMessageNotification(); |
|
56 } |
|
57 |
|
58 void CNGMessageSendBufferBase::SendMessageToNetwork(const TLbsNetInternalMsgBase& aMessage) |
|
59 { |
|
60 iNetGatewayChannel.SendMessage(aMessage, iStatus); |
|
61 SetActive(); |
|
62 } |
|
63 |
|
64 // |
|
65 // CNGMessageSendBuffer |
|
66 // |
|
67 |
|
68 // Dummy params used for initialising member variables |
|
69 const TLbsNetSessionIdInt KInvalidSessionId; |
|
70 const TPositionInfo KInvalidPosInfo; |
|
71 const TTime KInvalidTTime(0); |
|
72 |
|
73 |
|
74 // |
|
75 // CNGMessageSendBuffer |
|
76 // |
|
77 |
|
78 |
|
79 CNGMessageSendBuffer::CNGMessageSendBuffer(RLbsNetChannel& aGatewayChannel, CLbsAdmin& aAdmin) : |
|
80 CNGMessageSendBufferBase(aGatewayChannel, aAdmin), |
|
81 iEmergencyBuffer(2), // two spaces allocated - all we need to process an emergency |
|
82 iEmergencyPrivacyResponseData(KInvalidSessionId, TLbsNetworkEnumInt::EPrivacyResponseUnknown, KErrNone), |
|
83 iEmergencyLocationResponseData(KInvalidSessionId, KErrNone, KInvalidPosInfo, KInvalidTTime) |
|
84 { |
|
85 } |
|
86 |
|
87 CNGMessageSendBuffer::~CNGMessageSendBuffer() |
|
88 { |
|
89 iEmergencyBuffer.Reset(); |
|
90 iBuffer.ResetAndDestroy(); |
|
91 } |
|
92 |
|
93 CNGMessageSendBuffer* CNGMessageSendBuffer::NewL(RLbsNetChannel& aGatewayChannel, CLbsAdmin& aAdmin) |
|
94 { |
|
95 CNGMessageSendBuffer* self = new (ELeave) CNGMessageSendBuffer(aGatewayChannel, aAdmin); |
|
96 return self; |
|
97 } |
|
98 |
|
99 void CNGMessageSendBuffer::RunL() |
|
100 { |
|
101 User::LeaveIfError(iStatus.Int()); |
|
102 |
|
103 // Send the next message in the buffer, |
|
104 // if there is one there. |
|
105 if (iEmergencyBuffer.Count() > 0) |
|
106 { |
|
107 // Send the emergency related message to the Network Gateway |
|
108 TLbsNetInternalMsgBase* msg = iEmergencyBuffer[0]; |
|
109 SendMessageToNetwork(*msg); |
|
110 iEmergencyBuffer.Remove(0); |
|
111 } |
|
112 else if (iBuffer.Count() > 0) |
|
113 { |
|
114 // Send the message to the Network Gateway |
|
115 TLbsNetInternalMsgBase* msg = iBuffer[0]; |
|
116 SendMessageToNetwork(*msg); |
|
117 |
|
118 // Remove and delete the item from the buffer if it was a "newed" one |
|
119 iBuffer.Remove(0); |
|
120 delete msg; |
|
121 } |
|
122 } |
|
123 |
|
124 /* Error function that catches the leave from RunL. |
|
125 |
|
126 For this class, it is not a fatal error if the property |
|
127 returns an error, so only log the error with LBS devlogger. |
|
128 */ |
|
129 TInt CNGMessageSendBuffer::RunError(TInt aError) |
|
130 { |
|
131 LBSLOG_ERR2(ELogP3, "CNGMessageSendBuffer::RunError : %d", aError); |
|
132 return KErrNone; |
|
133 } |
|
134 |
|
135 void CNGMessageSendBuffer::BufferData(TLbsNetInternalMsgBase* aData) |
|
136 { |
|
137 // Add the data to the buffer |
|
138 iBuffer.Append(aData); |
|
139 } |
|
140 |
|
141 void CNGMessageSendBuffer::BufferEmergencyData(TLbsNetInternalMsgBase* aData) |
|
142 { |
|
143 // Add the data to the emergency buffer |
|
144 TInt err = iEmergencyBuffer.Append(aData); |
|
145 // there should always be enough space in this array of pointers because we pre-alloated |
|
146 __ASSERT_DEBUG(KErrNone == err, Panic(ENrhPanicOOMWhenProcessingEmergency)); |
|
147 |
|
148 } |
|
149 |
|
150 |
|
151 void CNGMessageSendBuffer::SendNetLocResponseToNetwork( |
|
152 const TLbsNetSessionIdInt& aSessionId, |
|
153 TInt aCompletionCode, |
|
154 const TPositionInfoBase& aPosInfo, |
|
155 const TTime& aTimeStamp, |
|
156 TBool aEmergency) |
|
157 { |
|
158 TLbsNetLocationResponseMsg msg(aSessionId, |
|
159 aCompletionCode, |
|
160 aPosInfo, |
|
161 aTimeStamp); |
|
162 |
|
163 if (!IsActive()) |
|
164 { |
|
165 SendMessageToNetwork(msg); |
|
166 } |
|
167 else |
|
168 { |
|
169 TLbsNetLocationResponseMsg* bufMsg = NULL; |
|
170 if (aEmergency) |
|
171 { |
|
172 iEmergencyLocationResponseData = msg; |
|
173 bufMsg = &iEmergencyLocationResponseData; |
|
174 BufferEmergencyData(bufMsg); |
|
175 } |
|
176 else |
|
177 { |
|
178 bufMsg = new TLbsNetLocationResponseMsg(msg); |
|
179 if (bufMsg) |
|
180 { |
|
181 BufferData(bufMsg); |
|
182 } |
|
183 else |
|
184 { |
|
185 LBSLOG_ERR(ELogP3, "CNGMessageSendBuffer::SendNetLocResponseToNetwork: Failed to allocate memory."); |
|
186 } |
|
187 } |
|
188 |
|
189 // coverity [memory_leak] |
|
190 // we do not delete bufMsg here as it is now owned by iBuffer |
|
191 } |
|
192 } |
|
193 |
|
194 void CNGMessageSendBuffer::SendMtlrResponseToNetwork( |
|
195 const TLbsNetSessionIdInt& aSessionId, |
|
196 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aResult, |
|
197 TInt /* aReason */, |
|
198 TBool aEmergency) |
|
199 { |
|
200 |
|
201 TLbsNetMtLrReponseMsg* bufMsg = NULL; |
|
202 |
|
203 TLbsNetMtLrReponseMsg msg(aSessionId, aResult, KErrNone); |
|
204 |
|
205 if (!IsActive()) |
|
206 { |
|
207 SendMessageToNetwork(msg); |
|
208 } |
|
209 else |
|
210 { |
|
211 |
|
212 if (aEmergency) |
|
213 { |
|
214 iEmergencyPrivacyResponseData = msg; |
|
215 bufMsg = &iEmergencyPrivacyResponseData; |
|
216 BufferEmergencyData(bufMsg); |
|
217 } |
|
218 else |
|
219 { |
|
220 bufMsg = new TLbsNetMtLrReponseMsg(msg); |
|
221 if (bufMsg) |
|
222 { |
|
223 BufferData(bufMsg); |
|
224 } |
|
225 else |
|
226 { |
|
227 LBSLOG_ERR(ELogP3, "CNGMessageSendBuffer::SendMtlrResponseToNetwork: Failed to allocate memory."); |
|
228 } |
|
229 } |
|
230 |
|
231 // coverity [memory_leak] |
|
232 // we do not delete bufMsg here as it is now owned by iBuffer |
|
233 } |
|
234 } |
|
235 |
|
236 void CNGMessageSendBuffer::SendX3pRequestToNetwork( |
|
237 const TLbsNetSessionIdInt& aSessionId, |
|
238 const TDesC& aDestId, |
|
239 TUint aTransmitPriority, |
|
240 const TLbsNetPosRequestOptionsTechnologyInt& aOptions) |
|
241 { |
|
242 TLbsNetTransmitLocationRequestMsg msg(aSessionId, |
|
243 aDestId, |
|
244 aTransmitPriority, |
|
245 aOptions); |
|
246 |
|
247 |
|
248 if (!IsActive()) |
|
249 { |
|
250 SendMessageToNetwork(msg); |
|
251 } |
|
252 else |
|
253 { |
|
254 TLbsNetTransmitLocationRequestMsg* bufMsg = new TLbsNetTransmitLocationRequestMsg(msg); |
|
255 if (bufMsg) |
|
256 { |
|
257 BufferData(bufMsg); |
|
258 } |
|
259 else |
|
260 { |
|
261 LBSLOG_ERR(ELogP3, "CNGMessageSendBuffer::SendX3pRequestToNetwork: Failed to allocate memory."); |
|
262 } |
|
263 |
|
264 // coverity [memory_leak] |
|
265 // we do not delete bufMsg here as it is now owned by iBuffer |
|
266 } |
|
267 } |
|
268 |
|
269 void CNGMessageSendBuffer::SendX3pCancelToNetwork( |
|
270 const TLbsNetSessionIdInt& aSessionId, |
|
271 TInt aReason) |
|
272 { |
|
273 TLbsNetTransmitLocationCancelMsg msg(aSessionId, aReason); |
|
274 |
|
275 if (!IsActive()) |
|
276 { |
|
277 SendMessageToNetwork(msg); |
|
278 } |
|
279 else |
|
280 { |
|
281 TLbsNetTransmitLocationCancelMsg* bufMsg = new TLbsNetTransmitLocationCancelMsg(msg); |
|
282 if (bufMsg) |
|
283 { |
|
284 BufferData(bufMsg); |
|
285 } |
|
286 else |
|
287 { |
|
288 LBSLOG_ERR(ELogP3, "CNGMessageSendBuffer::SendX3pCancelToNetwork: Failed to allocate memory."); |
|
289 } |
|
290 |
|
291 // coverity [memory_leak] |
|
292 // we do not delete bufMsg here as it is now owned by iBuffer |
|
293 } |
|
294 } |
|
295 |
|
296 void CNGMessageSendBuffer::SendExternalLocateCancelToNetwork(const TLbsNetSessionIdInt& aSessionId, |
|
297 TInt aReason) |
|
298 { |
|
299 TLbsNetCancelFromPrivacyControllerMsg msg(aSessionId, |
|
300 aReason); |
|
301 |
|
302 if (!IsActive()) |
|
303 { |
|
304 SendMessageToNetwork(msg); |
|
305 } |
|
306 else |
|
307 { |
|
308 TLbsNetCancelFromPrivacyControllerMsg* bufMsg = new TLbsNetCancelFromPrivacyControllerMsg(msg); |
|
309 if (bufMsg) |
|
310 { |
|
311 BufferData(bufMsg); |
|
312 } |
|
313 else |
|
314 { |
|
315 LBSLOG_ERR(ELogP3, "CNGMessageSendBuffer::SendExternalLocateCancelToNetwor: Failed to allocate memory."); |
|
316 } |
|
317 |
|
318 // coverity [memory_leak] |
|
319 // we do not delete bufMsg here as it is now owned by iBuffer |
|
320 } |
|
321 } |
|
322 |
|
323 |
|
324 // |
|
325 // CNGMessageSwitch |
|
326 // |
|
327 |
|
328 CNGMessageSwitch::CNGMessageSwitch(CLbsAdmin& aAdmin): |
|
329 iAdmin(aAdmin) |
|
330 { |
|
331 } |
|
332 |
|
333 CNGMessageSwitch* CNGMessageSwitch::NewL(CLbsAdmin& aAdmin) |
|
334 { |
|
335 CNGMessageSwitch* self = new (ELeave) CNGMessageSwitch(aAdmin); |
|
336 CleanupStack::PushL(self); |
|
337 self->ConstructL(); |
|
338 CleanupStack::Pop(self); |
|
339 return(self); |
|
340 } |
|
341 |
|
342 void CNGMessageSwitch::ConstructL() |
|
343 { |
|
344 iObservers.ReserveL(2); |
|
345 iNetworkGateway.OpenL(RLbsNetChannel::EChannelNRH2NG, *this); |
|
346 |
|
347 iNetworkGatewaySendBuffer = CNGMessageSendBuffer::NewL(iNetworkGateway, iAdmin); |
|
348 |
|
349 } |
|
350 |
|
351 CNGMessageSwitch::~CNGMessageSwitch() |
|
352 { |
|
353 |
|
354 iRefPosBuffer.Close(); |
|
355 |
|
356 iFNPPosBuffer.ResetAndDestroy(); |
|
357 |
|
358 delete iNetworkGatewaySendBuffer; |
|
359 |
|
360 iNetworkGateway.Close(); |
|
361 |
|
362 iObservers.Close(); |
|
363 } |
|
364 |
|
365 TInt CNGMessageSwitch::RegisterObserver(MNGMessageSwitchObserver* aObserver) |
|
366 { |
|
367 return iObservers.Append(aObserver); |
|
368 } |
|
369 |
|
370 void CNGMessageSwitch::SendX3pRequest(const TLbsNetSessionIdInt& aSessionId, |
|
371 const TDesC& aDestId, |
|
372 TUint aTransmitPriority, |
|
373 const TLbsNetPosRequestOptionsTechnologyInt& aOptions) |
|
374 { |
|
375 iNetworkGatewaySendBuffer->SendX3pRequestToNetwork(aSessionId, aDestId, aTransmitPriority, aOptions); |
|
376 } |
|
377 |
|
378 void CNGMessageSwitch::SendX3pCancel(const TLbsNetSessionIdInt& aSessionId, |
|
379 TInt aReason) |
|
380 { |
|
381 iNetworkGatewaySendBuffer->SendX3pCancelToNetwork(aSessionId, aReason); |
|
382 } |
|
383 |
|
384 void CNGMessageSwitch::SendMTLRResponse(const TLbsNetSessionIdInt& aSessionId, |
|
385 TLbsNetworkEnumInt::TLbsPrivacyResponseInt aResult, |
|
386 TInt aReason, |
|
387 TBool aEmergency) |
|
388 { |
|
389 iNetworkGatewaySendBuffer->SendMtlrResponseToNetwork(aSessionId, aResult, aReason, aEmergency); |
|
390 } |
|
391 void CNGMessageSwitch::SendExternalLocateCancel(const TLbsNetSessionIdInt& aSessionId, TInt aReason) |
|
392 { |
|
393 iNetworkGatewaySendBuffer->SendExternalLocateCancelToNetwork(aSessionId, aReason); |
|
394 } |
|
395 |
|
396 void CNGMessageSwitch::SendNetLocResponse( |
|
397 const TLbsNetSessionIdInt& aSessionId, |
|
398 TInt aCompletionCode, |
|
399 const TLbsNetPosRequestQualityInt& aRequestQuality, |
|
400 const TPositionInfoBase& aPosInfo, |
|
401 const TTime& aTimeStamp, |
|
402 TBool aEmergency) |
|
403 { |
|
404 // Send a Network Location Response to the network |
|
405 iNetworkGatewaySendBuffer->SendNetLocResponseToNetwork(aSessionId, |
|
406 aCompletionCode, |
|
407 aPosInfo, |
|
408 aTimeStamp, |
|
409 aEmergency); |
|
410 |
|
411 // Let the observers know what the quality criteria were, so that if |
|
412 // the network modifies teht final position the client can see if it |
|
413 // matches the orignal criteria. |
|
414 const TInt count = iObservers.Count(); |
|
415 for (TInt i = 0; i < count; i++) |
|
416 { |
|
417 iObservers[i]->OnNetLocResponse(aSessionId,aRequestQuality); |
|
418 } |
|
419 } |
|
420 |
|
421 /** |
|
422 From MLbsNetChannelObserver. |
|
423 Called when a message is sent by the Network Gateway. |
|
424 */ |
|
425 void CNGMessageSwitch::ProcessNetChannelMessage(RLbsNetChannel::TLbsNetChannelId aChannelId, const TLbsNetInternalMsgBase& aMessage) |
|
426 { |
|
427 __ASSERT_DEBUG(aChannelId == RLbsNetChannel::EChannelNRH2NG, Panic(ENrhPanicUnexpectedNetChannelId)); |
|
428 (void) aChannelId; |
|
429 |
|
430 switch(aMessage.Type()) |
|
431 { |
|
432 case TLbsNetInternalMsgBase::ELocationRequest: |
|
433 { |
|
434 const TLbsNetLocationRequestMsg* msg = |
|
435 static_cast<const TLbsNetLocationRequestMsg*>(&aMessage); |
|
436 const TInt count = iObservers.Count(); |
|
437 // for an NI the REF location may arrive before the location request |
|
438 TPositionInfo posInfo; |
|
439 TInt err = GetNetworkReferencePosition(msg->SessionId(), posInfo); |
|
440 |
|
441 for (TInt i = 0; i < count; i++) |
|
442 { |
|
443 iObservers[i]->OnNetLocRequest(msg->SessionId(), |
|
444 msg->Method(), |
|
445 msg->Service(), |
|
446 msg->IsEmergency(), |
|
447 msg->Quality()); |
|
448 if (KErrNone == err) // if no error then there is a reference position so pass it on |
|
449 { |
|
450 iObservers[i]->OnNetLocReferenceUpdate(msg->SessionId(), posInfo); |
|
451 } |
|
452 } |
|
453 break; |
|
454 } |
|
455 |
|
456 case TLbsNetInternalMsgBase::ESessionComplete: |
|
457 { |
|
458 const TLbsNetSessionCompleteMsg* msg = |
|
459 static_cast<const TLbsNetSessionCompleteMsg*>(&aMessage); |
|
460 |
|
461 const TInt count = iObservers.Count(); |
|
462 for (TInt i = 0; i < count; i++) |
|
463 { |
|
464 iObservers[i]->OnSessionComplete(msg->SessionId(), |
|
465 msg->Reason()); |
|
466 } |
|
467 |
|
468 // We know the request session has finished now, so remove |
|
469 // any buffered reference or final network positions. |
|
470 RemoveBufferedNetworkPositions(msg->SessionId()); |
|
471 break; |
|
472 } |
|
473 |
|
474 case TLbsNetInternalMsgBase::EPrivacyRequest: |
|
475 { |
|
476 const TLbsNetMtLrRequestMsg* msg = |
|
477 static_cast<const TLbsNetMtLrRequestMsg*>(&aMessage); |
|
478 |
|
479 const TInt count = iObservers.Count(); |
|
480 for (TInt i = 0; i < count; i++) |
|
481 { |
|
482 iObservers[i]->OnMTLRRequest(msg->SessionId(), |
|
483 TLbsNetworkEnumInt::EServiceMobileTerminated, |
|
484 msg->IsEmergency(), |
|
485 msg->RequestInfo(), |
|
486 msg->Privacy()); |
|
487 } |
|
488 break; |
|
489 } |
|
490 |
|
491 case TLbsNetInternalMsgBase::ENetworkLocationUpdate: |
|
492 { |
|
493 const TLbsNetLocationUpdateMsg * msg = |
|
494 static_cast<const TLbsNetLocationUpdateMsg*>(&aMessage); |
|
495 // its either a REF location or a FNP |
|
496 const TPositionInfoBase& positionInfo = msg->PositionInfo(); |
|
497 |
|
498 TPositionModuleInfo::TTechnologyType techType = positionInfo.PositionMode(); |
|
499 |
|
500 const TInt count = iObservers.Count(); |
|
501 |
|
502 |
|
503 if (TPositionModuleInfo::ETechnologyNetwork == techType) |
|
504 { // reference position add to ref pos list |
|
505 TNetPosItem item; |
|
506 item.iSessionId = msg->SessionId(); |
|
507 Mem::Copy(&item.iPosInfo, &positionInfo, positionInfo.PositionClassSize()); |
|
508 |
|
509 // OOM - do nothing here - just ignore the error which results in the REF pos |
|
510 // not being saved. Note we do enure that the mobiles position |
|
511 // does get sent out to the network - its juts means that the callback |
|
512 // that delivers the REF pos to the privacy system does not happen! |
|
513 iRefPosBuffer.Append(item); |
|
514 |
|
515 for (TInt i = 0; i < count; i++) |
|
516 { |
|
517 iObservers[i]->OnNetLocReferenceUpdate(msg->SessionId(), positionInfo); |
|
518 } |
|
519 } |
|
520 else |
|
521 { |
|
522 // save FNP here - for processing |
|
523 // completion of X3Ps when session completes |
|
524 TNetFNPPosItem* item = new TNetFNPPosItem(); |
|
525 if (item == NULL) |
|
526 { |
|
527 // OOM - do nothing here - just discard the FNP.. |
|
528 // Note thats OK becuase we don't need to save the FNP for tp process |
|
529 // emergencies just X3Ps. |
|
530 } |
|
531 else |
|
532 { |
|
533 item->iSessionId = msg->SessionId(); |
|
534 |
|
535 Mem::Copy(&item->iPosInfo, &positionInfo, positionInfo.PositionClassSize()); |
|
536 iFNPPosBuffer.Append(item); // here, ownership passes to pointer array! |
|
537 } |
|
538 for (TInt i = 0; i < count; i++) |
|
539 { |
|
540 iObservers[i]->OnNetLocFinalUpdate(msg->SessionId(), positionInfo); |
|
541 } |
|
542 } |
|
543 break; |
|
544 } |
|
545 case TLbsNetInternalMsgBase::ETransmitLocationRequest:// outgoing only |
|
546 case TLbsNetInternalMsgBase::ELocationResponse: // outgoing only |
|
547 case TLbsNetInternalMsgBase::EPrivacyResponse: // outgoing only |
|
548 default: |
|
549 { |
|
550 break; |
|
551 } |
|
552 } |
|
553 } |
|
554 |
|
555 |
|
556 /** SessionId comparison for RArray<TNetPosItem>::Find(). |
|
557 */ |
|
558 TBool CNGMessageSwitch::IsSessionIdEqual( |
|
559 const TLbsNetSessionIdInt* aSessionId, |
|
560 const TNetPosItem& aItem) |
|
561 { |
|
562 return (*aSessionId == aItem.iSessionId); |
|
563 } |
|
564 /** SessionId comparison for RPointerArray<TNetFNPPosItem>::Find(). |
|
565 */ |
|
566 TBool CNGMessageSwitch::IsFNPSessionIdEqual( |
|
567 const TLbsNetSessionIdInt* aSessionId, |
|
568 const TNetFNPPosItem& aItem) |
|
569 { |
|
570 return (*aSessionId == aItem.iSessionId); |
|
571 } |
|
572 |
|
573 /** |
|
574 */ |
|
575 TInt CNGMessageSwitch::GetNetworkReferencePosition( |
|
576 const TLbsNetSessionIdInt& aSessionId, |
|
577 TPositionInfoBase& aPosInfo) |
|
578 { |
|
579 // Try to find the update if it has already happened. |
|
580 TInt index = iRefPosBuffer.Find(aSessionId, IsSessionIdEqual); |
|
581 if (index >= 0) |
|
582 { |
|
583 const TNetPosItem& item = iRefPosBuffer[index]; |
|
584 Mem::Copy(&aPosInfo, &item.iPosInfo, item.iPosInfo.PositionClassSize()); |
|
585 return KErrNone; |
|
586 } |
|
587 else |
|
588 { |
|
589 return KErrNotFound; |
|
590 } |
|
591 } |
|
592 |
|
593 /** |
|
594 */ |
|
595 TInt CNGMessageSwitch::GetNetworkFinalPosition( |
|
596 const TLbsNetSessionIdInt& aSessionId, |
|
597 TPositionInfoBase& aPosInfo) |
|
598 { |
|
599 // Try to find the update if it has already happened. |
|
600 TInt index = iFNPPosBuffer.Find(aSessionId, IsFNPSessionIdEqual); |
|
601 if (index >= 0) |
|
602 { |
|
603 const TNetFNPPosItem* item = iFNPPosBuffer[index]; |
|
604 Mem::Copy(&aPosInfo, &item->iPosInfo, item->iPosInfo.PositionClassSize()); |
|
605 return KErrNone; |
|
606 } |
|
607 else |
|
608 { |
|
609 return KErrNotFound; |
|
610 } |
|
611 } |
|
612 |
|
613 void CNGMessageSwitch::RemoveBufferedNetworkPositions(const TLbsNetSessionIdInt& aSessionId) |
|
614 { |
|
615 // Remove any reference positions |
|
616 TInt index = iRefPosBuffer.Find(aSessionId, IsSessionIdEqual); |
|
617 while (index >= 0) |
|
618 { |
|
619 iRefPosBuffer.Remove(index); |
|
620 index = iRefPosBuffer.Find(aSessionId, IsSessionIdEqual); |
|
621 } |
|
622 |
|
623 index = iFNPPosBuffer.Find(aSessionId, IsFNPSessionIdEqual); |
|
624 while (index >= 0) |
|
625 { |
|
626 TNetFNPPosItem* fnpPsItem = iFNPPosBuffer[index]; |
|
627 delete fnpPsItem; |
|
628 iFNPPosBuffer.Remove(index); |
|
629 index = iFNPPosBuffer.Find(aSessionId, IsFNPSessionIdEqual); |
|
630 } |
|
631 } |
|
632 |