|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for handling SUPL_POS message. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <bautils.h> |
|
21 #include <flogger.h> |
|
22 |
|
23 #include <lbs/epos_comasuplpossessionbase.h> |
|
24 #include <lbs/epos_comasuplpospayload.h> |
|
25 #include <lbs/epos_comasuplvelocity.h> |
|
26 #include <lbs/epos_comasuplinforequestlist.h> |
|
27 #include <lbs/epos_comasuplsetcapabilities.h> |
|
28 #include <lbs/epos_eomasuplposerrors.h> |
|
29 |
|
30 #include "epos_comasuplpos.h" |
|
31 #include "epos_comasuplposrequestor.h" |
|
32 #include "epos_comasuplposstate.h" |
|
33 #include "epos_omasuplconstants.h" |
|
34 #include "epos_comasupltrace.h" |
|
35 #include "epos_comasuplasnbase.h" |
|
36 |
|
37 _LIT(KTraceFileName,"SUPL_OMA_SESSION::EPos_COMASuplPosState.cpp"); |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // COMASuplPosState::COMASuplPosState |
|
43 // C++ constructor can NOT contain any code, that might leave. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 COMASuplPosState::COMASuplPosState(COMASuplPosSessionBase* aPOSSession,TInt aMsgTimeout,COMASuplSETCapabilities* aSETCapabilities, |
|
47 COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase): |
|
48 iPOSSession(aPOSSession), |
|
49 iSETCapabilities(aSETCapabilities), |
|
50 iOMASuplAsnHandlerBase(aOMASuplAsnHandlerBase) |
|
51 { |
|
52 iMessageTimeOut = aMsgTimeout * KSecond; |
|
53 iCurrentState = ESUPL_POS; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // COMASuplPosState::~COMASuplPosState |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 COMASuplPosState::~COMASuplPosState() |
|
61 { |
|
62 delete iPOSRequestor; |
|
63 delete iRemainingPospayload; |
|
64 |
|
65 if(iTrace) |
|
66 iTrace->Trace(_L("COMASuplPosState::~COMASuplPosState..."), KTraceFileName, __LINE__); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // COMASuplPosState::ConstructL |
|
71 // Symbian 2nd phase constructor can leave. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void COMASuplPosState::ConstructL() |
|
75 { |
|
76 COMASuplState::BaseConstructL(); |
|
77 iTrace->Trace(_L("COMASuplPosState::ConstructL..."), KTraceFileName, __LINE__); |
|
78 |
|
79 if(iPOSSession) |
|
80 { |
|
81 iPOSRequestor = COMASuplPOSRequestor::NewL(this,iPOSSession); |
|
82 iOMASuplPosPayLoad = COMASuplPosPayload::NewL(); |
|
83 iOMASuplVelocity = COMASuplVelocity::NewL(); |
|
84 |
|
85 |
|
86 iPOSRequestor->CreateListL(); |
|
87 iPOSRequestor->AppendInfoRequest(iOMASuplPosPayLoad);//ownership is towords iPOSRequestor |
|
88 iPOSRequestor->AppendInfoRequest(iOMASuplVelocity); |
|
89 } |
|
90 iIsLastPosPayloadSegmented = EFalse; |
|
91 iIsAnyPosPayloadFromPosInit = EFalse; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // COMASuplPosState::NewL |
|
96 // Two-phased constructor. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 COMASuplPosState* COMASuplPosState::NewL(COMASuplPosSessionBase* aPOSSession,TInt aMsgTimeout,COMASuplSETCapabilities* aSETCapabilities, |
|
100 COMASuplAsnHandlerBase* aOMASuplAsnHandlerBase) |
|
101 { |
|
102 COMASuplPosState* self = new ( ELeave ) COMASuplPosState(aPOSSession,aMsgTimeout,aSETCapabilities,aOMASuplAsnHandlerBase); |
|
103 CleanupStack::PushL( self ); |
|
104 self->ConstructL(); |
|
105 CleanupStack::Pop(self); |
|
106 return self; |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // COMASuplPosState::GenerateMessage |
|
111 // Generates SUPL_POS message |
|
112 // (other items were commented in a header). |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt COMASuplPosState::GenerateMessageL() |
|
116 { |
|
117 iTrace->Trace(_L("Start of COMASuplPosState::GenerateMessage"), KTraceFileName, __LINE__); |
|
118 TInt err = KErrNone; |
|
119 iGenerationStatus = ETrue; |
|
120 if(iPOSSession) |
|
121 { |
|
122 if(iIsLastPosPayloadSegmented) |
|
123 { |
|
124 OperationCompleteL(KErrNone); |
|
125 } |
|
126 else |
|
127 { |
|
128 iOMASuplPosPayLoad->SetStatus(KErrOMASuplParamNotSet);//Set this explicitly...so that one can set it again |
|
129 err = iPOSRequestor->GetSuplInfoL(); |
|
130 } |
|
131 |
|
132 if(err != KErrNone) |
|
133 { |
|
134 iGenerationStatus = EFalse; |
|
135 } |
|
136 } |
|
137 |
|
138 return err; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // COMASuplPosState::EncodeMessageL |
|
143 // Encodes message ...returns encoded data |
|
144 // (other items were commented in a header). |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 HBufC8* COMASuplPosState::EncodeMessageL(TOMASuplVersion& aSuplVersion,COMASuplSessionID* aSessionId,TInt& aError) |
|
148 { |
|
149 iTrace->Trace(_L("Starting Encoding..."), KTraceFileName, __LINE__); |
|
150 COMASuplState::EncodeMessageL(aSuplVersion,aSessionId,aError); |
|
151 HBufC8 *encodedBuffer = NULL; |
|
152 TInt error; |
|
153 aError = KErrNone; |
|
154 iRequestError = KErrNone; |
|
155 |
|
156 |
|
157 COMASuplAsnMessageBase* OMASuplMessageBase = iOMASuplAsnHandlerBase->CreateOMASuplMessageL(COMASuplAsnMessageBase::ESUPL_POS); |
|
158 CleanupStack::PushL(OMASuplMessageBase); |
|
159 COMASuplPos* OMASuplPos = static_cast<COMASuplPos*>(OMASuplMessageBase); |
|
160 OMASuplPos->SetMessageBase(aSuplVersion,aSessionId); |
|
161 IterateSuplInfoListL(OMASuplPos,aError); |
|
162 |
|
163 TRAPD(err,encodedBuffer = iOMASuplAsnHandlerBase->EncodeL(OMASuplPos,error)); |
|
164 CleanupStack::PopAndDestroy(OMASuplMessageBase); |
|
165 |
|
166 LogPosPayLoadData(); |
|
167 LogVelocity(); |
|
168 |
|
169 if(aError == KErrNone || aError == KErrOMASuplLastPosMsg ) |
|
170 { |
|
171 if ( error == KErrNone && err == KErrNone ) |
|
172 { |
|
173 iTrace->Trace(_L("Encoding Done..."), KTraceFileName, __LINE__); |
|
174 aError = KErrNone; |
|
175 return encodedBuffer; |
|
176 } |
|
177 else |
|
178 { |
|
179 iTrace->Trace(_L("Encoding Failed."), KTraceFileName, __LINE__); |
|
180 aError = error; |
|
181 delete encodedBuffer; |
|
182 } |
|
183 return NULL; |
|
184 } |
|
185 else |
|
186 { |
|
187 aError = KErrOMAManParamMissing; |
|
188 iTrace->Trace(_L("POS failed to give manadatory ..."), KTraceFileName, __LINE__); |
|
189 delete encodedBuffer; |
|
190 return NULL; |
|
191 } |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // COMASuplPosState::ProcessMessage |
|
196 // process message... |
|
197 // (other items were commented in a header). |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 TInt COMASuplPosState::ProcessMessageL(COMASuplAsnMessageBase* aDecodedMessage ) |
|
201 { |
|
202 iTrace->Trace(_L("COMASuplPosState::ProcessMessageL"), KTraceFileName, __LINE__); |
|
203 |
|
204 COMASuplPos* OMASuplPos = static_cast <COMASuplPos*>(aDecodedMessage); |
|
205 |
|
206 //Retrieve the Pos Payload from Supl Pos Message |
|
207 COMASuplPosPayload* OMASuplPosPayLoad = NULL; |
|
208 OMASuplPosPayLoad = OMASuplPos->SuplPos(); |
|
209 |
|
210 if(!CheckPOSPayloadType(OMASuplPosPayLoad)) // Check is POS method mismatch with SETCaps |
|
211 { |
|
212 iTrace->Trace(_L("COMASuplPosState::ProcessMessageL POS method Mismatched. "), KTraceFileName, __LINE__); |
|
213 return KErrSuplposMethodMismatch; |
|
214 } |
|
215 if(iPOSSession) |
|
216 { |
|
217 TRAP_IGNORE(iPOSSession->HandleSuplPosMessageL(OMASuplPosPayLoad)); |
|
218 iTrace->Trace(_L("COMASuplPosState::ProcessMessageL...PosPayLoad sent to POS Msg Plugin..."), KTraceFileName, __LINE__); |
|
219 } |
|
220 return KErrNone; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // COMASuplPosState::CancelOperation |
|
225 // Cancels Operation...which will be depend on derived class implementation |
|
226 // (other items were commented in a header). |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void COMASuplPosState::CancelOperation() |
|
230 { |
|
231 COMASuplState::CancelOperation(); |
|
232 if(iPOSRequestor) |
|
233 { |
|
234 iPOSRequestor->Cancel(); |
|
235 } |
|
236 iTrace->Trace(_L("COMASuplPosState::CancelOperation..."), KTraceFileName, __LINE__); |
|
237 } |
|
238 // ----------------------------------------------------------------------------- |
|
239 // COMASuplPosState::StartTimer |
|
240 // StartTimer...starts the timer ... |
|
241 // (other items were commented in a header). |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void COMASuplPosState::StartTimer() |
|
245 { |
|
246 iTrace->Trace(_L("COMASuplPosState::StartTimer..."), KTraceFileName, __LINE__); |
|
247 if(IsLastMessage() && !iIsLastPosPayloadSegmented) |
|
248 { |
|
249 iTrace->Trace(_L("Timer Started for POS"), KTraceFileName, __LINE__); |
|
250 COMASuplState::StartTimer(); |
|
251 } |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // COMASuplPosState::IsLastMessage |
|
256 // Is last message |
|
257 // (other items were commented in a header). |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 TBool COMASuplPosState::IsLastMessage() |
|
261 { |
|
262 iTrace->Trace(_L("COMASuplPosState::IsLastMessage"), KTraceFileName, __LINE__); |
|
263 if(iRequestError == KErrOMASuplLastPosMsg) |
|
264 { |
|
265 iTrace->Trace(_L("COMASuplPosState::IsLastMessage... Last Message from POS"), KTraceFileName, __LINE__); |
|
266 return ETrue; |
|
267 } |
|
268 else |
|
269 { |
|
270 iTrace->Trace(_L("COMASuplPosState::IsLastMessage...More data from POS Payload..."), KTraceFileName, __LINE__); |
|
271 return EFalse; |
|
272 } |
|
273 } |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // COMASuplPosState::OperationCompleteL |
|
277 // Gets control when any of the asynchronous requests are completed |
|
278 // (other items were commented in a header). |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void COMASuplPosState::OperationCompleteL(TInt aErrorCode) |
|
282 { |
|
283 iGenerationStatus = EFalse; |
|
284 PseudoSegmentationL(); |
|
285 if(iMsgStateObserver) |
|
286 iMsgStateObserver->OperationCompleteL(aErrorCode); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // COMASuplPosState::GetPositionComplete |
|
291 // No use |
|
292 // (other items were commented in a header). |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 void COMASuplPosState::GetPositionComplete(TInt /*aError*/) |
|
296 { |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // COMASuplPosState::IterateSuplInfoListL |
|
301 // Interates thro' request list |
|
302 // (other items were commented in a header). |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 void COMASuplPosState::IterateSuplInfoListL(COMASuplPos* aOMASuplPos,TInt &aError) |
|
306 { |
|
307 iTrace->Trace(_L("COMASuplPosState::IterateSuplInfoList..."), KTraceFileName, __LINE__); |
|
308 COMASuplInfoRequestList* OMASuplInfoRequestList = iPOSRequestor->GetOMASuplInfoRequestList(); |
|
309 |
|
310 if(!OMASuplInfoRequestList) |
|
311 { |
|
312 iTrace->Trace(_L("Failed to retrived list(RequestList).COMASuplPosState::FillSuplInfoList"), KTraceFileName, __LINE__); |
|
313 aError = KErrCompletion; |
|
314 return; |
|
315 } |
|
316 |
|
317 TInt NoOfElements = OMASuplInfoRequestList->GetCount(); |
|
318 |
|
319 aError = KErrNone; |
|
320 |
|
321 for(TInt cnt = 0; cnt < NoOfElements; ++cnt) |
|
322 { |
|
323 COMASuplInfoRequest* info = OMASuplInfoRequestList->GetElement(cnt); |
|
324 if(!info) |
|
325 { |
|
326 iTrace->Trace(_L("Failed to retrive list(info).COMASuplPosState::IterateSuplInfoList"), KTraceFileName, __LINE__); |
|
327 continue; |
|
328 } |
|
329 |
|
330 TInt posError = info->Status(); |
|
331 switch(info->Type()) |
|
332 { |
|
333 case COMASuplInfoRequest::EOMASuplVelocity: |
|
334 { |
|
335 if(posError == KErrNone) |
|
336 { |
|
337 if(iOMASuplVelocity)//Use velocity |
|
338 { |
|
339 COMASuplVelocity* OMASuplVelocity = static_cast <COMASuplVelocity *>(iOMASuplVelocity->CloneL());//Ownership transfer to callee |
|
340 aOMASuplPos->SetVelocity(OMASuplVelocity); |
|
341 } |
|
342 } |
|
343 break; |
|
344 } |
|
345 |
|
346 case COMASuplInfoRequest::EOMASuplPosPayload: |
|
347 { |
|
348 if( (posError == KErrNone || posError == KErrOMASuplLastPosMsg) && iOMASuplPosPayLoad)//Use PosPayload |
|
349 { |
|
350 COMASuplPosPayload* OMASuplPosPayload =static_cast <COMASuplPosPayload *>(iOMASuplPosPayLoad->CloneL());//Ownership transfer to callee |
|
351 aOMASuplPos->SetSuplPos(OMASuplPosPayload); |
|
352 if(posError == KErrOMASuplLastPosMsg) |
|
353 { |
|
354 iRequestError = KErrOMASuplLastPosMsg; |
|
355 } |
|
356 } |
|
357 else |
|
358 { |
|
359 aError = posError; |
|
360 } |
|
361 break; |
|
362 } |
|
363 } |
|
364 } |
|
365 |
|
366 iTrace->Trace(_L("Done...COMASuplPosState::IterateSuplInfoList"), KTraceFileName, __LINE__); |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // COMASuplPosState::IsGenerationInProgress() |
|
371 // returns status of generation of Message |
|
372 // (other items were commented in a header). |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 TBool COMASuplPosState::IsGenerationInProgress() |
|
376 { |
|
377 return iGenerationStatus; |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // COMASuplPosState::CheckPOSPayloadType() |
|
382 // returns EFalse if there is mismatch in POS Payload type |
|
383 // (other items were commented in a header). |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 TBool COMASuplPosState::CheckPOSPayloadType(const COMASuplPosPayload *aPosPayload) |
|
387 { |
|
388 if(!iSETCapabilities) |
|
389 { |
|
390 return EFalse; |
|
391 } |
|
392 |
|
393 HBufC8* Payload = NULL; |
|
394 COMASuplPosPayload::TOMASuplPosPayloadType ReceivedPayloadType; |
|
395 aPosPayload->GetPosPayload(Payload,ReceivedPayloadType); |
|
396 |
|
397 TOMASuplPosTechnology posTech; |
|
398 COMASuplSETCapabilities::TOMASuplPrefMethod prefMethod; |
|
399 TOMASuplPosProtocol posProtocol; |
|
400 iSETCapabilities->GetSETCapabilities(posTech,prefMethod, posProtocol); |
|
401 |
|
402 TBool SETtia801,SETRRLP,SETRRC; |
|
403 posProtocol.GetPosProtocol(SETtia801,SETRRLP,SETRRC); |
|
404 |
|
405 if(ReceivedPayloadType == COMASuplPosPayload::ETIA801) |
|
406 { |
|
407 iTrace->Trace(_L("Received POS protocol method is TIA801 "), KTraceFileName, __LINE__); |
|
408 return SETtia801; |
|
409 } |
|
410 |
|
411 if(ReceivedPayloadType == COMASuplPosPayload::ERRLP) |
|
412 { |
|
413 iTrace->Trace(_L("Received POS protocol method is RRLP "), KTraceFileName, __LINE__); |
|
414 return SETRRLP; |
|
415 } |
|
416 |
|
417 if(ReceivedPayloadType == COMASuplPosPayload::ERRC) |
|
418 { |
|
419 iTrace->Trace(_L("Received POS protocol method is RRC "), KTraceFileName, __LINE__); |
|
420 return SETRRC; |
|
421 } |
|
422 |
|
423 return EFalse; |
|
424 } |
|
425 |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // COMASuplPosState::IsSegmentationDone |
|
429 // Does the pseudo segmentation done... |
|
430 // (other items were commented in a header). |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 TBool COMASuplPosState::IsSegmentationDone() const |
|
434 { |
|
435 return iIsLastPosPayloadSegmented; |
|
436 } |
|
437 |
|
438 // ----------------------------------------------------------------------------- |
|
439 // COMASuplPosState::PseudoSegmentation |
|
440 // Does the pseudo segmentation. |
|
441 // (other items were commented in a header). |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 void COMASuplPosState::PseudoSegmentationL() |
|
445 { |
|
446 TInt posPosPayLoadError = iOMASuplPosPayLoad->Status(); |
|
447 if(posPosPayLoadError == KErrNone || posPosPayLoadError == KErrOMASuplLastPosMsg || !iIsAnyPosPayloadFromPosInit) |
|
448 { |
|
449 HBufC8* payLoad = NULL; |
|
450 iOMASuplPosPayLoad->GetPosPayload(payLoad,iPosPayLoadType); |
|
451 if(!iIsLastPosPayloadSegmented) // First time ..will hold data |
|
452 { |
|
453 if(payLoad) |
|
454 { |
|
455 TInt posPayloadLength = payLoad->Length(); |
|
456 TBuf<64> msg; |
|
457 msg.Copy(_L("Received Pospayload having length : ")); |
|
458 msg.AppendNum(posPayloadLength); |
|
459 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
460 msg.Copy(_L("Logging Received POS Payload from POS Msg Plugin: ")); |
|
461 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
462 |
|
463 LogPacket(payLoad->Des()); |
|
464 |
|
465 if( posPayloadLength > KMaxPosPayloadLength ) |
|
466 { |
|
467 delete iRemainingPospayload; |
|
468 posPayloadLength = posPayloadLength - KMaxPosPayloadLength; // Length of remaining data |
|
469 msg.Copy(_L("Remaining POS Payload after segmentation: ")); |
|
470 msg.AppendNumUC(posPayloadLength); |
|
471 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
472 iRemainingPospayload = HBufC8::NewL(posPayloadLength); |
|
473 iRemainingPospayload->Des().Copy(payLoad->Des().Mid(KMaxPosPayloadLength ));// Copy rest data |
|
474 payLoad->Des().Copy(payLoad->Des().Left(KMaxPosPayloadLength)); |
|
475 iIsLastPosPayloadSegmented = ETrue; |
|
476 |
|
477 TInt len = payLoad->Length(); |
|
478 msg.Copy(_L("Segmentationed POS Payload data...: ")); |
|
479 msg.AppendNum(len); |
|
480 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
481 LogPacket(payLoad->Des()); |
|
482 } |
|
483 } |
|
484 } |
|
485 else |
|
486 { |
|
487 iOMASuplVelocity->SetStatus(KErrOMASuplParamNotSet);//Set this explicitly...so that velocity will not be reconsider |
|
488 TInt remainingPosPayloadLength = iRemainingPospayload->Length(); |
|
489 if( remainingPosPayloadLength > KMaxPosPayloadLength ) |
|
490 { |
|
491 payLoad->Des().Copy(iRemainingPospayload->Des().Left(KMaxPosPayloadLength)); |
|
492 iRemainingPospayload->Des().Copy(iRemainingPospayload->Des().Mid(KMaxPosPayloadLength));// Copy rest data |
|
493 } |
|
494 else |
|
495 { |
|
496 payLoad->Des().Copy(iRemainingPospayload->Des()); |
|
497 iIsLastPosPayloadSegmented = EFalse; |
|
498 } |
|
499 |
|
500 TInt len = payLoad->Length(); |
|
501 TBuf<64> msg; |
|
502 msg.Copy(_L("Segmentationed POS Payload data...: ")); |
|
503 msg.AppendNum(len); |
|
504 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
505 |
|
506 } |
|
507 } |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // COMASuplPosState::SetRemainingPosPayloadFromSuplPosInit |
|
512 // Sets remaining pos payload from SUPL_POS_INIT |
|
513 // (other items were commented in a header). |
|
514 // ----------------------------------------------------------------------------- |
|
515 // |
|
516 void COMASuplPosState::SetRemainingPosPayloadFromSuplPosInitL(COMASuplPosPayload* aRemainingPospayload) |
|
517 { |
|
518 if(aRemainingPospayload) |
|
519 { |
|
520 iIsAnyPosPayloadFromPosInit = ETrue; |
|
521 iIsLastPosPayloadSegmented = ETrue; |
|
522 |
|
523 HBufC8* payLoad = NULL; |
|
524 COMASuplPosPayload::TOMASuplPosPayloadType payLoadType; |
|
525 aRemainingPospayload->GetPosPayload(payLoad,payLoadType); |
|
526 |
|
527 HBufC8* payLoadBuffer = HBufC8::NewL(payLoad->Length()); |
|
528 payLoadBuffer->Des().Copy(payLoad->Des()); |
|
529 iOMASuplPosPayLoad->SetPosPayload(payLoadBuffer,payLoadType); //Setting POS payload buffer |
|
530 iOMASuplPosPayLoad->SetStatus(KErrNone); |
|
531 |
|
532 iRemainingPospayload = HBufC8::NewL(payLoad->Length()); |
|
533 iRemainingPospayload->Des().Copy(payLoad->Des()); |
|
534 delete aRemainingPospayload; |
|
535 } |
|
536 } |
|
537 |
|
538 // ----------------------------------------------------------------------------- |
|
539 // COMASuplPosState::LogPosPayLoadData |
|
540 // // Logs PosPayLoadData in epostrace file |
|
541 // (other items were commented in a header). |
|
542 // ----------------------------------------------------------------------------- |
|
543 // |
|
544 void COMASuplPosState::LogPosPayLoadData() |
|
545 { |
|
546 |
|
547 #ifdef PRINT_MESSAGE |
|
548 |
|
549 if(iOMASuplPosPayLoad) |
|
550 { |
|
551 TInt posPosPayLoadError = iOMASuplPosPayLoad->Status(); |
|
552 if(!(posPosPayLoadError == KErrNone || posPosPayLoadError == KErrOMASuplLastPosMsg )) |
|
553 { |
|
554 iTrace->Trace(_L("No POS Payload data provided for SUPL_POS from PosMsgPlugin"), KTraceFileName, __LINE__); |
|
555 return; |
|
556 } |
|
557 |
|
558 iTrace->Trace(_L("**************** Start of SUPL POS PosPayLoad Data from PosMsgPlugin**********************"), KTraceFileName, __LINE__); |
|
559 HBufC8* payLoad = NULL; |
|
560 COMASuplPosPayload::TOMASuplPosPayloadType payLoadType; |
|
561 |
|
562 iOMASuplPosPayLoad->GetPosPayload(payLoad,payLoadType); |
|
563 HBufC* payLoadBuffer = NULL; |
|
564 if(payLoad) |
|
565 { |
|
566 TInt err; |
|
567 TRAP(err,payLoadBuffer = HBufC::NewL(payLoad->Length())) ; |
|
568 err = 0; |
|
569 payLoadBuffer->Des().Copy(payLoad->Des()); |
|
570 } |
|
571 |
|
572 if(payLoadType == COMASuplPosPayload::ETIA801) |
|
573 { |
|
574 iTrace->Trace(_L("POS DATA Type - ETIA801 "), KTraceFileName, __LINE__); |
|
575 if(payLoadBuffer && payLoad) |
|
576 iTrace->Trace(payLoadBuffer->Des(),KTraceFileName, __LINE__); |
|
577 } |
|
578 else if(payLoadType == COMASuplPosPayload::ERRLP) |
|
579 { |
|
580 iTrace->Trace(_L("POS DATA Type - ERRLP "), KTraceFileName, __LINE__); |
|
581 } |
|
582 else if(payLoadType == COMASuplPosPayload::ERRC) |
|
583 { |
|
584 iTrace->Trace(_L("POS DATA Type - ERRC "), KTraceFileName, __LINE__); |
|
585 if(payLoadBuffer && payLoad ) |
|
586 iTrace->Trace(payLoadBuffer->Des(),KTraceFileName, __LINE__); |
|
587 } |
|
588 |
|
589 delete payLoadBuffer; |
|
590 payLoadBuffer = NULL; |
|
591 |
|
592 iTrace->Trace(_L("**************** End of SUPL POS PosPayLoad Data **********************"), KTraceFileName, __LINE__); |
|
593 } |
|
594 #endif |
|
595 |
|
596 } |
|
597 |
|
598 // ----------------------------------------------------------------------------- |
|
599 // COMASuplPosState::LogVelocity |
|
600 // Logs Velocity in epostrace file |
|
601 // (other items were commented in a header). |
|
602 // ----------------------------------------------------------------------------- |
|
603 // |
|
604 void COMASuplPosState::LogVelocity() |
|
605 { |
|
606 |
|
607 #ifdef PRINT_MESSAGE |
|
608 if(iOMASuplVelocity) |
|
609 { |
|
610 TInt posVelocityError = iOMASuplVelocity->Status(); |
|
611 if(posVelocityError != KErrNone ) |
|
612 { |
|
613 iTrace->Trace(_L("No Velocity Information provided for SUPL_POS "), KTraceFileName, __LINE__); |
|
614 return; |
|
615 } |
|
616 |
|
617 iTrace->Trace(_L("Velocity Information for SUPL_POS "), KTraceFileName, __LINE__); |
|
618 TBuf<256> msg; |
|
619 TOMASuplVelocityType velocityType = iOMASuplVelocity->VelType(); |
|
620 COMASuplHorizVelocity* horizVelocity = iOMASuplVelocity->Velocity(); |
|
621 TUint16 bearing; |
|
622 TUint16 horSpeed; |
|
623 switch(velocityType) |
|
624 { |
|
625 case EHorizVelocity: |
|
626 { |
|
627 iTrace->Trace(_L("Velocity Type : EHorizVelocity - Values "), KTraceFileName, __LINE__); |
|
628 horizVelocity->GetHorizVel(bearing,horSpeed); |
|
629 |
|
630 msg.Append(_L("Bearing ")); |
|
631 msg.AppendNum(bearing); |
|
632 msg.Append(_L("Horizontal Speed ")); |
|
633 msg.AppendNum(horSpeed); |
|
634 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
635 break; |
|
636 } |
|
637 case EHorizAndVertVelocity: |
|
638 { |
|
639 TUint8 verDirect; |
|
640 TUint8 verSpeed; |
|
641 COMASuplHorizAndVertVelocity* horizVertVel = (COMASuplHorizAndVertVelocity*)horizVelocity; |
|
642 horizVertVel->GetHorizAndVertVel(bearing,horSpeed,verDirect,verSpeed); |
|
643 |
|
644 iTrace->Trace(_L("Velocity Type : EHorizVelocity - Values "), KTraceFileName, __LINE__); |
|
645 |
|
646 msg.Append(_L("Bearing ")); |
|
647 msg.AppendNum(bearing); |
|
648 msg.Append(_L("Horizontal Speed ")); |
|
649 msg.AppendNum(horSpeed); |
|
650 msg.Append(_L("Vertical Direction ")); |
|
651 msg.AppendNum(verDirect); |
|
652 msg.Append(_L("Vertical Speed ")); |
|
653 msg.AppendNum(verSpeed); |
|
654 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
655 |
|
656 break; |
|
657 } |
|
658 case EHorizUncertVelocity: |
|
659 { |
|
660 TUint8 uncertSpeed; |
|
661 COMASuplHorizUncertVelocity* horizUncertVel = (COMASuplHorizUncertVelocity*)horizVelocity; |
|
662 |
|
663 horizUncertVel->GetHorizUncertVel(bearing,horSpeed,uncertSpeed); |
|
664 |
|
665 iTrace->Trace(_L("Velocity Type : EHorizUncertVelocity - Values "), KTraceFileName, __LINE__); |
|
666 |
|
667 msg.Append(_L("Bearing ")); |
|
668 msg.AppendNum(bearing); |
|
669 msg.Append(_L("Horizontal Speed ")); |
|
670 msg.AppendNum(horSpeed); |
|
671 msg.Append(_L("Uncertainity Speed ")); |
|
672 msg.AppendNum(uncertSpeed); |
|
673 |
|
674 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
675 |
|
676 break; |
|
677 } |
|
678 case EHorizAndVertUncertVelocity: |
|
679 { |
|
680 TUint8 verDirect; |
|
681 TUint8 verSpeed; |
|
682 TUint8 horizUncertSpeed; |
|
683 TUint8 vertUncertSpeed; |
|
684 |
|
685 COMASuplHorizAndVertUncertVelocity* horizVertUncertVel = (COMASuplHorizAndVertUncertVelocity*)horizVelocity; |
|
686 |
|
687 horizVertUncertVel->GetHorizVertUncertVel(bearing,horSpeed,verDirect,verSpeed, |
|
688 horizUncertSpeed,vertUncertSpeed); |
|
689 |
|
690 iTrace->Trace(_L("Velocity Type : EHorizAndVertUncertVelocity - Values "), KTraceFileName, __LINE__); |
|
691 |
|
692 msg.Append(_L("Bearing ")); |
|
693 msg.AppendNum(bearing); |
|
694 msg.Append(_L("Horizontal Speed ")); |
|
695 msg.AppendNum(horSpeed); |
|
696 msg.Append(_L("Vertical Direction ")); |
|
697 msg.AppendNum(verDirect); |
|
698 msg.Append(_L("Vertical Speed ")); |
|
699 msg.AppendNum(verSpeed); |
|
700 msg.Append(_L("Horiz Uncertain Speed ")); |
|
701 msg.AppendNum(horizUncertSpeed); |
|
702 msg.Append(_L("Vertical Uncertain Speed ")); |
|
703 msg.AppendNum(vertUncertSpeed); |
|
704 iTrace->Trace(msg, KTraceFileName, __LINE__); |
|
705 |
|
706 break; |
|
707 } |
|
708 } |
|
709 } |
|
710 #endif |
|
711 |
|
712 } |
|
713 |
|
714 void COMASuplPosState::LogPacket(const TDesC8& |
|
715 #ifdef PRINT_MESSAGE |
|
716 aPacket |
|
717 #endif |
|
718 ) |
|
719 { |
|
720 #ifdef PRINT_MESSAGE |
|
721 |
|
722 RFileLogger logger; |
|
723 TInt err = logger.Connect(); |
|
724 if(err == KErrNone) |
|
725 { |
|
726 const TText* hdr1 = _S("Header"); |
|
727 const TText* mrg1 = _S("End"); |
|
728 logger.CreateLog(_L("epos"),_L("PayloadFromPOSPlugin.txt"),EFileLoggingModeAppend); |
|
729 logger.HexDump(hdr1, mrg1, aPacket.Ptr(), aPacket.Length() ); |
|
730 } |
|
731 logger.Close(); |
|
732 #endif |
|
733 } |
|
734 |
|
735 |
|
736 // End of File |