|
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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // @file ctlbsconfigreader.cpp |
|
15 // This is the Cpp file which contains the ini file configuration reader classes |
|
16 // |
|
17 // |
|
18 |
|
19 // User includes |
|
20 #include "ctlbsconfigreader.h" |
|
21 |
|
22 // Epoc includes |
|
23 #include <f32file.h> |
|
24 |
|
25 // Lbs includes |
|
26 #include <lbsclasstypes.h> |
|
27 #include <lbssatellite.h> |
|
28 |
|
29 // Literals Used |
|
30 _LIT8(KNotANumber, "nan"); |
|
31 |
|
32 |
|
33 CConfigReaderBase::CConfigReaderBase(const TDesC& aConfigFileName, const TDesC& aConfigSection) : iConfigFileName(aConfigFileName), iConfigSection(aConfigSection) |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 CConfigReaderBase::~CConfigReaderBase() |
|
39 { |
|
40 } |
|
41 |
|
42 |
|
43 void CConfigReaderBase::AppendFieldChar(TUint aChar) |
|
44 { |
|
45 if (iSentence.Length() >= iSentence.MaxLength()) |
|
46 { |
|
47 return; |
|
48 } |
|
49 |
|
50 iSentence.Append(aChar); |
|
51 |
|
52 // If aChar is not a field delimiter then just add it to buffer and return |
|
53 if (aChar != ',' && aChar != '*') |
|
54 { |
|
55 iFieldLength++; |
|
56 return; |
|
57 } |
|
58 |
|
59 // Got a field delimiter increase the number of fields |
|
60 // aChar == ',' || aChar == '*' |
|
61 |
|
62 TPtrC8 thisField = iSentence.Mid(iFieldStart, iFieldLength); |
|
63 iFields[iNumFields].Set(thisField); |
|
64 iNumFields++; |
|
65 |
|
66 // Next field starts here |
|
67 iFieldStart = iSentence.Length(); |
|
68 iFieldLength = 0; |
|
69 } |
|
70 |
|
71 |
|
72 void CConfigReaderBase::ProcessStringL(const TDesC8& aData) |
|
73 { |
|
74 TInt length = aData.Length(); |
|
75 |
|
76 for (TInt index = 0; index < length; index++) |
|
77 { |
|
78 TUint ch = aData[index]; |
|
79 |
|
80 switch(iReadState) |
|
81 { |
|
82 // Keep reading until a section is found. |
|
83 case EStartSection: |
|
84 { |
|
85 if (ch == '[') |
|
86 { |
|
87 iReadSection.SetLength(0); |
|
88 iReadState = EProcessSection; |
|
89 } |
|
90 break; |
|
91 } |
|
92 |
|
93 // Found a section, keep reading until end of section found. |
|
94 case EProcessSection: |
|
95 { |
|
96 // End of section, check if it's ours. |
|
97 if (ch == ']') |
|
98 { |
|
99 // Need to convert from TBuf8 to TBuf for the comparision. |
|
100 TBuf<KMaxSentence> cmpSection; |
|
101 cmpSection.Copy(iReadSection); |
|
102 |
|
103 // Not our section. |
|
104 if (iConfigSection.Compare(cmpSection) != 0) |
|
105 { |
|
106 iReadState = EStartSection; |
|
107 } |
|
108 |
|
109 // Is our section. |
|
110 else |
|
111 { |
|
112 iReadState = EStartSentence; |
|
113 } |
|
114 } |
|
115 else |
|
116 { |
|
117 iReadSection.Append(ch); |
|
118 } |
|
119 break; |
|
120 } |
|
121 |
|
122 case EStartSentence: |
|
123 { |
|
124 // |
|
125 if (ch == '$') |
|
126 { |
|
127 iReadState = EProcessSentence; |
|
128 iSentence.SetLength(0); |
|
129 iNumFields = 0; |
|
130 iFieldStart = 0; |
|
131 iFieldLength = 0; |
|
132 for (TInt i = 0; i < KMaxFields; i++) |
|
133 { |
|
134 iFields[i].Set(KNullDesC8); |
|
135 } |
|
136 } |
|
137 |
|
138 // If we find a section we know to stop reading sentences for our section |
|
139 // and we let the other section be handled, but it will not match ours. |
|
140 else if (ch == '[') |
|
141 { |
|
142 iReadSection.SetLength(0); |
|
143 iReadState = EProcessSection; |
|
144 } |
|
145 |
|
146 break; |
|
147 } |
|
148 |
|
149 case EProcessSentence: |
|
150 { |
|
151 AppendFieldChar(ch); // calling this don't you end up with a * in the field, does it matter |
|
152 |
|
153 if (ch == '*') |
|
154 { |
|
155 iReadState = EStartSentence; |
|
156 HandleSentenceL(); |
|
157 } |
|
158 break; |
|
159 } |
|
160 } |
|
161 } |
|
162 } |
|
163 |
|
164 |
|
165 void CConfigReaderBase::ExtractValueL(const TPtrC8& aField, TInt& aValue) |
|
166 { |
|
167 if (aField.Length() != 0) |
|
168 { |
|
169 TLex8 lex(aField); |
|
170 TInt err = lex.Val(aValue); |
|
171 User::LeaveIfError(err); |
|
172 } |
|
173 } |
|
174 |
|
175 |
|
176 void CConfigReaderBase::ExtractValueL(const TPtrC8& aField, TReal32& aValue) |
|
177 { |
|
178 TRealX nan; |
|
179 nan.SetNaN(); |
|
180 |
|
181 aValue = nan; |
|
182 |
|
183 if (aField.Length() != 0) |
|
184 { |
|
185 if (aField.CompareF(KNotANumber)) |
|
186 { |
|
187 TLex8 lex(aField); |
|
188 TInt err = lex.Val(aValue); |
|
189 User::LeaveIfError(err); |
|
190 } |
|
191 } |
|
192 } |
|
193 |
|
194 |
|
195 void CConfigReaderBase::ExtractValueL(const TPtrC8& aField, TReal64& aValue) |
|
196 { |
|
197 TRealX nan; |
|
198 nan.SetNaN(); |
|
199 |
|
200 aValue = nan; |
|
201 |
|
202 if (aField.Length() != 0) |
|
203 { |
|
204 if (aField.CompareF(KNotANumber)) |
|
205 { |
|
206 TLex8 lex(aField); |
|
207 TInt err = lex.Val(aValue); |
|
208 User::LeaveIfError(err); |
|
209 } |
|
210 } |
|
211 } |
|
212 |
|
213 /* |
|
214 void CConfigReaderBase::ExtractDegreesL(const TPtrC8& aField, TReal64& aDegrees) |
|
215 { |
|
216 TRealX nan; |
|
217 nan.SetNaN(); |
|
218 |
|
219 aDegrees = nan; |
|
220 |
|
221 if (aField.Length() != 0) |
|
222 { |
|
223 TLex8 lex(aField); |
|
224 TInt err = lex.Val(aDegrees); |
|
225 User::LeaveIfError(err); |
|
226 |
|
227 ConvertDecimalMinutesToDecimalDegrees(aDegrees); |
|
228 } |
|
229 } |
|
230 */ |
|
231 |
|
232 |
|
233 void CConfigReaderBase::ProcessL() |
|
234 { |
|
235 if (iConfigFileName.Length() == 0) |
|
236 { |
|
237 User::LeaveIfError(KErrArgument); |
|
238 } |
|
239 |
|
240 RFs fs; |
|
241 User::LeaveIfError(fs.Connect()); |
|
242 CleanupClosePushL(fs); |
|
243 |
|
244 RFile iniFile; |
|
245 |
|
246 User::LeaveIfError(iniFile.Open(fs, iConfigFileName, EFileRead|EFileShareReadersOnly)); |
|
247 |
|
248 CleanupClosePushL(iniFile); |
|
249 |
|
250 TBuf8<KMaxIniFileBuffer> buf; |
|
251 |
|
252 // Loop until EOF. |
|
253 User::LeaveIfError(iniFile.Read(buf)); |
|
254 while (buf.Length() > 0) |
|
255 { |
|
256 // Process data read from file. |
|
257 ProcessStringL(buf); |
|
258 |
|
259 // Refresh buffer from file. |
|
260 User::LeaveIfError(iniFile.Read(buf)); |
|
261 } |
|
262 |
|
263 CleanupStack::PopAndDestroy(2, &fs); // iniFile, fs. |
|
264 } |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 /*********************** Update Info Reader ************************/ |
|
273 |
|
274 CUpdateConfigReader* CUpdateConfigReader::NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TLbsModuleUpdateItem>& aUpdateArr) |
|
275 { |
|
276 return new (ELeave) CUpdateConfigReader(aConfigFileName, aConfigSection, aUpdateArr); |
|
277 } |
|
278 |
|
279 |
|
280 CUpdateConfigReader::CUpdateConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TLbsModuleUpdateItem>& aUpdateArr) : CConfigReaderBase(aConfigFileName, aConfigSection), iUpdateArr(aUpdateArr) |
|
281 { |
|
282 } |
|
283 |
|
284 |
|
285 void CUpdateConfigReader::HandleSentenceL() |
|
286 { |
|
287 // Not a update sentence, ignore all other valid sentences. |
|
288 if ( (iNumFields == EUpdateType) || (iFields[EUpdateType].Compare(_L8("update")) != 0) ) |
|
289 { |
|
290 return; |
|
291 } |
|
292 |
|
293 // Determine the number of times to repeat the update. |
|
294 TInt repeat = 1; |
|
295 |
|
296 if (iFields[EUpdateRepeat].Length() != 0) |
|
297 { |
|
298 ExtractValueL(iFields[1], repeat); |
|
299 } |
|
300 |
|
301 // Determine the number of measurements for each update. |
|
302 TInt numOfMeasurements = 0; |
|
303 |
|
304 if (iFields[ENumOfMeasurements].Length() != 0) |
|
305 { |
|
306 ExtractValueL(iFields[ENumOfMeasurements], numOfMeasurements); // make this member, then set up this + error in the default + extract maybe |
|
307 } |
|
308 |
|
309 // Add repeat items to the pos info array. |
|
310 for (TInt i = 0; i < repeat; i++) |
|
311 { |
|
312 TPositionGpsMeasurementInfo measureInfo; |
|
313 TPositionGpsMeasurementData measureData; |
|
314 |
|
315 |
|
316 // Alloc a update item. |
|
317 iUpdate = new(ELeave) TLbsModuleUpdateItem(); |
|
318 |
|
319 |
|
320 // Set measurement info. |
|
321 for (TInt j = 0; j < numOfMeasurements; j++) |
|
322 { |
|
323 measureData.SetSatelliteId(j + 1); |
|
324 measureData.SetCarrierNoiseRatio((j+1) + 1); |
|
325 measureData.SetDoppler((j+1) + 2); |
|
326 measureData.SetWholeGpsChips((j+1) + 3); |
|
327 measureData.SetFractionalGpsChips((j+1) + 4); |
|
328 measureData.SetMultiPathIndicator(TPositionGpsMeasurementData::EMultiPathLow); |
|
329 measureData.SetPseudoRangeRmsError((j+1) + 5); |
|
330 |
|
331 User::LeaveIfError(measureInfo.AppendMeasurementData(measureData)); |
|
332 } |
|
333 measureInfo.SetGpsTimeOfWeek(i + 1000); |
|
334 iUpdate->SetMeasurement(measureInfo); |
|
335 |
|
336 |
|
337 // Set position update. |
|
338 // Optional fields are present fill out pos info based on them. |
|
339 if (iFields[3].Length() != 0) |
|
340 { |
|
341 DefaultData(); // This will ensure the pos info items are set to a default value for any incomplete sentences. |
|
342 ExtractDataL(); |
|
343 } |
|
344 |
|
345 // Otherwise use default values. |
|
346 else |
|
347 { |
|
348 DefaultData(); |
|
349 } |
|
350 |
|
351 |
|
352 // Optional error value is present. Set update error. |
|
353 TInt updateErr = KErrNone; |
|
354 if (iFields[EUpdateErr].Length() != 0) |
|
355 { |
|
356 ExtractValueL(iFields[EUpdateErr], updateErr); |
|
357 } |
|
358 iUpdate->SetError(updateErr); |
|
359 |
|
360 // Optional time delay(could be negative) |
|
361 TInt updateDelay = 0; |
|
362 if (iFields[EUpdateDelay].Length() != 0) |
|
363 { |
|
364 ExtractValueL(iFields[EUpdateDelay], updateDelay); |
|
365 } |
|
366 iUpdate->SetDelay(updateDelay); |
|
367 |
|
368 |
|
369 // Add to array, and reset pointer. |
|
370 iUpdateArr.AppendL(iUpdate); |
|
371 iUpdate = NULL; |
|
372 } |
|
373 } |
|
374 |
|
375 |
|
376 void CUpdateConfigReader::ExtractDataL() |
|
377 { |
|
378 // Access the position info from the update structure. |
|
379 TPositionSatelliteInfo posInfo = iUpdate->Position(); |
|
380 TPosition position; |
|
381 |
|
382 // Process fields. |
|
383 TReal64 latitude; |
|
384 TReal64 longitude; |
|
385 TReal32 altitude; |
|
386 TReal32 horzAccuracy; |
|
387 TReal32 vertAccuracy; |
|
388 |
|
389 ExtractValueL(iFields[EPosLatitude], latitude); |
|
390 ExtractValueL(iFields[EPosLongitude], longitude); |
|
391 ExtractValueL(iFields[EPosAltitude], altitude); |
|
392 ExtractValueL(iFields[EPosHorzAccuracy], horzAccuracy); |
|
393 ExtractValueL(iFields[EPosVertAccuracy], vertAccuracy); |
|
394 |
|
395 // Set values. |
|
396 position.SetCoordinate(latitude, longitude, altitude); |
|
397 position.SetAccuracy(horzAccuracy, vertAccuracy); |
|
398 position.SetCurrentTime(); |
|
399 |
|
400 posInfo.SetPosition(position); |
|
401 |
|
402 iUpdate->SetPosition(posInfo); |
|
403 } |
|
404 |
|
405 |
|
406 void CUpdateConfigReader::DefaultData() |
|
407 { |
|
408 // Access the position info from the update structure. |
|
409 TPositionSatelliteInfo posSatalliteInfo = iUpdate->Position(); |
|
410 |
|
411 |
|
412 // Fill out default position data. |
|
413 TPosition position; |
|
414 |
|
415 position.SetCoordinate(DEFAULT_NOTIFY_POS_UPDATE_LATITUDE, DEFAULT_NOTIFY_POS_UPDATE_LONGITUDE, DEFAULT_NOTIFY_POS_UPDATE_ALTITUDE); |
|
416 position.SetAccuracy(DEFAULT_NOTIFY_POS_UPDATE_HORIZONTAL_ACCURACY, DEFAULT_NOTIFY_POS_UPDATE_VERTICAL_ACCURACY); |
|
417 position.SetCurrentTime(); |
|
418 |
|
419 posSatalliteInfo.SetPosition(position); |
|
420 |
|
421 |
|
422 // Fill out default course data. |
|
423 TCourse course; |
|
424 |
|
425 course.SetSpeed(DEFAULT_NOTIFY_POS_UPDATE_SPEED); |
|
426 course.SetHeading(DEFAULT_NOTIFY_POS_UPDATE_HEADING); |
|
427 course.SetSpeedAccuracy(DEFAULT_NOTIFY_POS_UPDATE_SPEED_ACCURACY); |
|
428 course.SetHeadingAccuracy(DEFAULT_NOTIFY_POS_UPDATE_HEADING_ACCURACY); |
|
429 |
|
430 posSatalliteInfo.SetCourse(course); |
|
431 |
|
432 |
|
433 // Fill out default satalliteInfo. |
|
434 TSatelliteData satellite; |
|
435 |
|
436 satellite.SetSatelliteId(DEFAULT_NOTIFY_POS_UPDATE_SATELLITE_ID1); |
|
437 satellite.SetAzimuth(DEFAULT_NOTIFY_POS_UPDATE_AZIMUTH1); |
|
438 satellite.SetElevation(DEFAULT_NOTIFY_POS_UPDATE_ELEVATION1); |
|
439 satellite.SetIsUsed(DEFAULT_NOTIFY_POS_UPDATE_IS_USED1); |
|
440 satellite.SetSignalStrength(DEFAULT_NOTIFY_POS_UPDATE_SIGNAL_STRENGTH1); |
|
441 |
|
442 posSatalliteInfo.AppendSatelliteData(satellite); |
|
443 |
|
444 satellite.SetSatelliteId(DEFAULT_NOTIFY_POS_UPDATE_SATELLITE_ID2); |
|
445 satellite.SetAzimuth(DEFAULT_NOTIFY_POS_UPDATE_AZIMUTH2); |
|
446 satellite.SetElevation(DEFAULT_NOTIFY_POS_UPDATE_ELEVATION2); |
|
447 satellite.SetIsUsed(DEFAULT_NOTIFY_POS_UPDATE_IS_USED2); |
|
448 satellite.SetSignalStrength(DEFAULT_NOTIFY_POS_UPDATE_SIGNAL_STRENGTH2); |
|
449 |
|
450 posSatalliteInfo.AppendSatelliteData(satellite); |
|
451 |
|
452 |
|
453 iUpdate->SetPosition(posSatalliteInfo); |
|
454 } |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 /*********************** Position Info Reader ************************/ |
|
462 |
|
463 CPosInfoConfigReader* CPosInfoConfigReader::NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TAny>& aPosInfoArr) |
|
464 { |
|
465 return new (ELeave) CPosInfoConfigReader(aConfigFileName, aConfigSection, aPosInfoArr); |
|
466 } |
|
467 |
|
468 |
|
469 CPosInfoConfigReader::CPosInfoConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, RPointerArray<TAny>& aPosInfoArr) : CConfigReaderBase(aConfigFileName, aConfigSection), iPosInfoArr(aPosInfoArr) |
|
470 { |
|
471 } |
|
472 |
|
473 |
|
474 void CPosInfoConfigReader::HandleSentenceL() |
|
475 { |
|
476 // Not a position info sentence, ignore all other valid sentences. |
|
477 if ( (iNumFields == 0) || ( |
|
478 (iFields[0].Compare(_L8("position")) != 0) && |
|
479 (iFields[0].Compare(_L8("course")) != 0) && |
|
480 (iFields[0].Compare(_L8("satellite")) != 0) )) |
|
481 { |
|
482 return; |
|
483 } |
|
484 |
|
485 // Determine the number of times to repeat the pos info. |
|
486 TInt repeat = 1; |
|
487 |
|
488 if (iFields[1].Length() != 0) |
|
489 { |
|
490 ExtractValueL(iFields[1], repeat); |
|
491 } |
|
492 |
|
493 // Add repeat items to the pos info array. |
|
494 for (TInt i = 0; i < repeat; i++) |
|
495 { |
|
496 // Alloc a Satellite type info. |
|
497 iPosInfo = new(ELeave) TPositionSatelliteInfo(); |
|
498 |
|
499 // Optional fields are present fill out pos info based on them. |
|
500 if (iFields[2].Length() != 0) |
|
501 { |
|
502 DefaultData(); // This will ensure the pos info items are set to a default value for any incomplete sentences. |
|
503 ExtractDataL(); |
|
504 } |
|
505 |
|
506 // Otherwise use default values. |
|
507 else |
|
508 { |
|
509 DefaultData(); |
|
510 } |
|
511 |
|
512 // Add to array, and reset pointer. |
|
513 User::LeaveIfError(iPosInfoArr.Append(iPosInfo)); |
|
514 iPosInfo = NULL; |
|
515 } |
|
516 } |
|
517 |
|
518 // i think we will always have to call default to ensure we set things for missing fields |
|
519 void CPosInfoConfigReader::ExtractDataL() |
|
520 { |
|
521 // TODO: we need to support something like this, ie $position,1,10,2.3* which is lat, long only |
|
522 // I think it will because extract value deals with empty strings |
|
523 if (iPosInfo->PositionClassType() & EPositionInfoClass) |
|
524 { |
|
525 TPosition position; |
|
526 TPositionInfo& posInfo = static_cast<TPositionInfo&>(*iPosInfo); |
|
527 |
|
528 TReal64 latitude; |
|
529 TReal64 longitude; |
|
530 TReal32 altitude; |
|
531 // TODO: TUid datum; |
|
532 TReal32 horzAccuracy; |
|
533 TReal32 vertAccuracy; |
|
534 |
|
535 ExtractValueL(iFields[EPosLatitude], latitude); |
|
536 ExtractValueL(iFields[EPosLongitude], longitude); |
|
537 ExtractValueL(iFields[EPosAltitude], altitude); |
|
538 // TODO: ExtractUidL() not sure what datum is |
|
539 ExtractValueL(iFields[EPosHorzAccuracy], horzAccuracy); |
|
540 ExtractValueL(iFields[EPosVertAccuracy], vertAccuracy); |
|
541 |
|
542 position.SetCoordinate(latitude, longitude, altitude); |
|
543 position.SetAccuracy(horzAccuracy, vertAccuracy); |
|
544 position.SetCurrentTime(); |
|
545 |
|
546 posInfo.SetPosition(position); |
|
547 } |
|
548 |
|
549 if (iPosInfo->PositionClassType() & EPositionCourseInfoClass) |
|
550 { |
|
551 TCourse course; |
|
552 TPositionCourseInfo& posCourseInfo = static_cast<TPositionCourseInfo&>(*iPosInfo); |
|
553 |
|
554 TReal32 speed; |
|
555 TReal32 heading; |
|
556 TReal32 speedAccuracy; |
|
557 TReal32 headingAccuracy; |
|
558 |
|
559 ExtractValueL(iFields[EPosSpeed], speed); |
|
560 ExtractValueL(iFields[EPosHeading], heading); |
|
561 ExtractValueL(iFields[EPosSpeedAccuracy], speedAccuracy); |
|
562 ExtractValueL(iFields[EPosHeadingAccuracy], headingAccuracy); |
|
563 |
|
564 course.SetSpeed(speed); |
|
565 course.SetHeading(heading); |
|
566 course.SetSpeedAccuracy(speedAccuracy); |
|
567 course.SetHeadingAccuracy(headingAccuracy); |
|
568 |
|
569 posCourseInfo.SetCourse(course); |
|
570 } |
|
571 |
|
572 if (iPosInfo->PositionClassType() & EPositionSatelliteInfoClass) |
|
573 { |
|
574 // TODO satellite info |
|
575 } |
|
576 } |
|
577 |
|
578 |
|
579 void CPosInfoConfigReader::DefaultData() |
|
580 { |
|
581 |
|
582 if (iPosInfo->PositionClassType() & EPositionInfoClass) |
|
583 { |
|
584 TPosition position; |
|
585 TPositionInfo& posInfo = static_cast<TPositionInfo&>(*iPosInfo); |
|
586 |
|
587 position.SetCoordinate(DEFAULT_NOTIFY_POS_UPDATE_LATITUDE, DEFAULT_NOTIFY_POS_UPDATE_LONGITUDE, DEFAULT_NOTIFY_POS_UPDATE_ALTITUDE); |
|
588 position.SetAccuracy(DEFAULT_NOTIFY_POS_UPDATE_HORIZONTAL_ACCURACY, DEFAULT_NOTIFY_POS_UPDATE_VERTICAL_ACCURACY); |
|
589 position.SetCurrentTime(); |
|
590 |
|
591 posInfo.SetPosition(position); |
|
592 } |
|
593 |
|
594 if (iPosInfo->PositionClassType() & EPositionCourseInfoClass) |
|
595 { |
|
596 TCourse course; |
|
597 TPositionCourseInfo& posCourseInfo = static_cast<TPositionCourseInfo&>(*iPosInfo); |
|
598 |
|
599 course.SetSpeed(DEFAULT_NOTIFY_POS_UPDATE_SPEED); |
|
600 course.SetHeading(DEFAULT_NOTIFY_POS_UPDATE_HEADING); |
|
601 course.SetSpeedAccuracy(DEFAULT_NOTIFY_POS_UPDATE_SPEED_ACCURACY); |
|
602 course.SetHeadingAccuracy(DEFAULT_NOTIFY_POS_UPDATE_HEADING_ACCURACY); |
|
603 |
|
604 posCourseInfo.SetCourse(course); |
|
605 } |
|
606 |
|
607 if (iPosInfo->PositionClassType() & EPositionSatelliteInfoClass) |
|
608 { |
|
609 TSatelliteData satellite; |
|
610 TPositionSatelliteInfo& posSatalliteInfo = static_cast<TPositionSatelliteInfo&>(*iPosInfo); |
|
611 |
|
612 satellite.SetSatelliteId(DEFAULT_NOTIFY_POS_UPDATE_SATELLITE_ID1); |
|
613 satellite.SetAzimuth(DEFAULT_NOTIFY_POS_UPDATE_AZIMUTH1); |
|
614 satellite.SetElevation(DEFAULT_NOTIFY_POS_UPDATE_ELEVATION1); |
|
615 satellite.SetIsUsed(DEFAULT_NOTIFY_POS_UPDATE_IS_USED1); |
|
616 satellite.SetSignalStrength(DEFAULT_NOTIFY_POS_UPDATE_SIGNAL_STRENGTH1); |
|
617 |
|
618 posSatalliteInfo.AppendSatelliteData(satellite); |
|
619 |
|
620 satellite.SetSatelliteId(DEFAULT_NOTIFY_POS_UPDATE_SATELLITE_ID2); |
|
621 satellite.SetAzimuth(DEFAULT_NOTIFY_POS_UPDATE_AZIMUTH2); |
|
622 satellite.SetElevation(DEFAULT_NOTIFY_POS_UPDATE_ELEVATION2); |
|
623 satellite.SetIsUsed(DEFAULT_NOTIFY_POS_UPDATE_IS_USED2); |
|
624 satellite.SetSignalStrength(DEFAULT_NOTIFY_POS_UPDATE_SIGNAL_STRENGTH2); |
|
625 |
|
626 posSatalliteInfo.AppendSatelliteData(satellite); |
|
627 } |
|
628 |
|
629 /* For extended tests when/if we have them. |
|
630 if (infoBase.PositionClassType() & EPositionClassTestExtension) |
|
631 { |
|
632 TExtPosInfo* genInfo = reinterpret_cast<TExtPosInfo*>(buffer); |
|
633 |
|
634 genInfo->iGalaxy = DEFAULT_NOTIFY_POS_UPDATE_EXT_GALAXY; |
|
635 genInfo->iSolarSystem = DEFAULT_NOTIFY_POS_UPDATE_EXT_SOLARSYS; |
|
636 genInfo->iStarDate = DEFAULT_NOTIFY_POS_UPDATE_EXT_STARDATE; |
|
637 } |
|
638 */ |
|
639 } |
|
640 |
|
641 |
|
642 /*********************** Module Status Reader ************************/ |
|
643 |
|
644 CModuleStatusConfigReader* CModuleStatusConfigReader::NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionModuleStatus& aModuleStatus) |
|
645 { |
|
646 return new (ELeave) CModuleStatusConfigReader(aConfigFileName, aConfigSection, aModuleStatus); |
|
647 } |
|
648 |
|
649 |
|
650 CModuleStatusConfigReader::CModuleStatusConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionModuleStatus& aModuleStatus) : CConfigReaderBase(aConfigFileName, aConfigSection), iModuleStatus(aModuleStatus) |
|
651 { |
|
652 } |
|
653 |
|
654 |
|
655 void CModuleStatusConfigReader::ExtractValueDevice(const TPtrC8& aField, TPositionModuleStatus::TDeviceStatus& aValue) |
|
656 { |
|
657 // Set device status. |
|
658 if (aField.Length() != 0) |
|
659 { |
|
660 if (aField.Compare(_L8("device_error")) == 0) |
|
661 { |
|
662 aValue = TPositionModuleStatus::EDeviceError; |
|
663 } |
|
664 |
|
665 else if (aField.Compare(_L8("device_disable")) == 0) |
|
666 { |
|
667 aValue = TPositionModuleStatus::EDeviceDisabled; |
|
668 } |
|
669 |
|
670 else if (aField.Compare(_L8("device_inactive")) == 0) |
|
671 { |
|
672 aValue = TPositionModuleStatus::EDeviceInactive; |
|
673 } |
|
674 |
|
675 else if (aField.Compare(_L8("device_initalising")) == 0) |
|
676 { |
|
677 aValue = TPositionModuleStatus::EDeviceInitialising; |
|
678 } |
|
679 |
|
680 else if (aField.Compare(_L8("device_standby")) == 0) |
|
681 { |
|
682 aValue = TPositionModuleStatus::EDeviceStandBy; |
|
683 } |
|
684 |
|
685 else if (aField.Compare(_L8("device_ready")) == 0) |
|
686 { |
|
687 aValue = TPositionModuleStatus::EDeviceReady; |
|
688 } |
|
689 |
|
690 else if (aField.Compare(_L8("device_active")) == 0) |
|
691 { |
|
692 aValue = TPositionModuleStatus::EDeviceActive; |
|
693 } |
|
694 } |
|
695 } |
|
696 |
|
697 |
|
698 void CModuleStatusConfigReader::ExtractValueDataQuality(const TPtrC8& aField, TPositionModuleStatus::TDataQualityStatus& aValue) |
|
699 { |
|
700 // Set data quality. |
|
701 if (aField.Length() != 0) |
|
702 { |
|
703 if (aField.Compare(_L8("data_quality_loss")) == 0) |
|
704 { |
|
705 aValue = TPositionModuleStatus::EDataQualityLoss; |
|
706 } |
|
707 |
|
708 else if (aField.Compare(_L8("data_quality_partial")) == 0) |
|
709 { |
|
710 aValue = TPositionModuleStatus::EDataQualityPartial; |
|
711 } |
|
712 |
|
713 else if (aField.Compare(_L8("data_quality_normal")) == 0) |
|
714 { |
|
715 aValue = TPositionModuleStatus::EDataQualityNormal; |
|
716 } |
|
717 } |
|
718 } |
|
719 |
|
720 |
|
721 void CModuleStatusConfigReader::HandleSentenceL() |
|
722 { |
|
723 // Not a 'updateoptions' sentence, ignore all other valid sentences. |
|
724 if ( (iNumFields == 0) || (iFields[EModuleStatusType].Compare(_L8("modstatus")) != 0) ) |
|
725 { |
|
726 return; |
|
727 } |
|
728 |
|
729 // Set default values for any fields not present in the sentence. |
|
730 DefaultData(); |
|
731 |
|
732 // Set values from set fields in the sentence. |
|
733 if (iNumFields == 3) |
|
734 { |
|
735 ExtractDataL(); |
|
736 } |
|
737 } |
|
738 |
|
739 |
|
740 void CModuleStatusConfigReader::ExtractDataL() |
|
741 { |
|
742 |
|
743 TPositionModuleStatus::TDeviceStatus device; |
|
744 TPositionModuleStatus::TDataQualityStatus dataQuality; |
|
745 |
|
746 ExtractValueDevice(iFields[EModuleStatusDevice], device); |
|
747 ExtractValueDataQuality(iFields[EModuleStatusDataQuality], dataQuality); |
|
748 |
|
749 iModuleStatus.SetDeviceStatus(device); |
|
750 iModuleStatus.SetDataQualityStatus(dataQuality); |
|
751 } |
|
752 |
|
753 |
|
754 void CModuleStatusConfigReader::DefaultData() |
|
755 { |
|
756 iModuleStatus.SetDeviceStatus(TPositionModuleStatus::EDeviceReady); |
|
757 iModuleStatus.SetDataQualityStatus(TPositionModuleStatus::EDataQualityNormal); |
|
758 } |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 /*********************** Update Options Reader ************************/ |
|
764 |
|
765 CUpdateOptsConfigReader* CUpdateOptsConfigReader::NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionUpdateOptions& aUpdateOpts) |
|
766 { |
|
767 return new (ELeave) CUpdateOptsConfigReader(aConfigFileName, aConfigSection, aUpdateOpts); |
|
768 } |
|
769 |
|
770 |
|
771 CUpdateOptsConfigReader::CUpdateOptsConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, TPositionUpdateOptions& aUpdateOpts) : CConfigReaderBase(aConfigFileName, aConfigSection), iUpdateOpts(aUpdateOpts) |
|
772 { |
|
773 |
|
774 } |
|
775 |
|
776 |
|
777 void CUpdateOptsConfigReader::ExtractValueL(const TPtrC8& aField, TTimeIntervalMicroSeconds& aValue) |
|
778 { |
|
779 if (aField.Length() != 0) |
|
780 { |
|
781 TLex8 lex(aField); |
|
782 TInt64 value; |
|
783 TInt err = lex.Val(value); |
|
784 User::LeaveIfError(err); |
|
785 aValue = value; |
|
786 } |
|
787 } |
|
788 |
|
789 |
|
790 void CUpdateOptsConfigReader::ExtractValue(const TPtrC8& aField, TBool& aValue) |
|
791 { |
|
792 aValue = EFalse; |
|
793 if (aField.Length() != 0) |
|
794 { |
|
795 if (aField.Compare(_L8("true")) == 0) |
|
796 { |
|
797 aValue = ETrue; |
|
798 } |
|
799 } |
|
800 } |
|
801 |
|
802 |
|
803 void CUpdateOptsConfigReader::HandleSentenceL() |
|
804 { |
|
805 // Not a 'updateoptions' sentence, ignore all other valid sentences. |
|
806 if ( (iNumFields == 0) || (iFields[EUpdateOptsType].Compare(_L8("updateoptions")) != 0) ) |
|
807 { |
|
808 return; |
|
809 } |
|
810 |
|
811 // Set default values for any fields not present in the sentence. |
|
812 DefaultData(); |
|
813 |
|
814 // Set values from set fields in the sentence. |
|
815 if (iNumFields == 5) |
|
816 { |
|
817 ExtractDataL(); |
|
818 } |
|
819 } |
|
820 |
|
821 |
|
822 void CUpdateOptsConfigReader::ExtractDataL() |
|
823 { |
|
824 TTimeIntervalMicroSeconds interval; |
|
825 TTimeIntervalMicroSeconds timeout; |
|
826 TTimeIntervalMicroSeconds maxage; |
|
827 TBool partialUpdates; |
|
828 |
|
829 ExtractValueL(iFields[EUpdateOptsInterval], interval); |
|
830 ExtractValueL(iFields[EUpdateOptsTimeOut], timeout); |
|
831 ExtractValueL(iFields[EUpdateOptsMaxAge], maxage); |
|
832 ExtractValue(iFields[EUpdateOptsPartialUpdates], partialUpdates); |
|
833 |
|
834 iUpdateOpts.SetUpdateInterval(interval); |
|
835 iUpdateOpts.SetUpdateTimeOut(timeout); |
|
836 iUpdateOpts.SetMaxUpdateAge(maxage); |
|
837 iUpdateOpts.SetAcceptPartialUpdates(partialUpdates); |
|
838 } |
|
839 |
|
840 |
|
841 void CUpdateOptsConfigReader::DefaultData() |
|
842 { |
|
843 iUpdateOpts.SetUpdateInterval(0); |
|
844 iUpdateOpts.SetUpdateTimeOut(0); |
|
845 iUpdateOpts.SetMaxUpdateAge(0); |
|
846 iUpdateOpts.SetAcceptPartialUpdates(EFalse); |
|
847 } |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 CAgpsModuleModesConfigReader* CAgpsModuleModesConfigReader::NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
853 RPointerArray<TLbsGpsOptions>& aModuleModes) |
|
854 { |
|
855 return new (ELeave) CAgpsModuleModesConfigReader(aConfigFileName, aConfigSection, aModuleModes); |
|
856 } |
|
857 CAgpsModuleModesConfigReader::CAgpsModuleModesConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
858 RPointerArray<TLbsGpsOptions>& aModuleModes) |
|
859 : CConfigReaderBase(aConfigFileName, aConfigSection), iModuleModes(aModuleModes) |
|
860 { |
|
861 } |
|
862 |
|
863 void CAgpsModuleModesConfigReader::HandleSentenceL() |
|
864 { |
|
865 // Not a 'modulemodes' sentence, ignore all other valid sentences. |
|
866 if ( (iNumFields == 0) || (iFields[EModuleModesType].Compare(_L8("modulemodes")) != 0) ) |
|
867 { |
|
868 return; |
|
869 } |
|
870 |
|
871 // Set default values for any fields not present in the sentence. |
|
872 DefaultData(); |
|
873 |
|
874 // Set values from set fields in the sentence. |
|
875 if (iNumFields > 1) |
|
876 { |
|
877 ExtractDataL(); |
|
878 } |
|
879 } |
|
880 |
|
881 void CAgpsModuleModesConfigReader::DefaultData() |
|
882 /** |
|
883 * Does nothing since there is no default data to be set for the expected gps mode |
|
884 */ |
|
885 { |
|
886 } |
|
887 |
|
888 void CAgpsModuleModesConfigReader::ExtractDataL() |
|
889 { |
|
890 TInt gpsModeInt; |
|
891 ExtractValueL(iFields[EGpsModeField], gpsModeInt); |
|
892 CLbsAdmin::TGpsMode gpsMode(static_cast<CLbsAdmin::TGpsMode>(gpsModeInt)); |
|
893 |
|
894 if(iNumFields == EGpsModeField+1) |
|
895 { // there is no options array |
|
896 TLbsGpsOptions* gpsOptions = new(ELeave) TLbsGpsOptions; |
|
897 gpsOptions->SetGpsMode(gpsMode); |
|
898 iModuleModes.AppendL(gpsOptions); |
|
899 } |
|
900 else |
|
901 { |
|
902 TLbsGpsOptionsArray* gpsOptionsArray = new(ELeave) TLbsGpsOptionsArray; |
|
903 gpsOptionsArray->SetGpsMode(gpsMode); |
|
904 |
|
905 for(TInt index = EBegginingOfGpsOptionsArray; index < iNumFields; ++index) |
|
906 { |
|
907 TLbsGpsOptionsItem optionsItem; |
|
908 TInt posUpdateTypeInt; |
|
909 ExtractValueL(iFields[index], posUpdateTypeInt); |
|
910 TLbsGpsOptionsItem::TPosUpdateType posUpdateType(static_cast<TLbsGpsOptionsItem::TPosUpdateType>(posUpdateTypeInt)); |
|
911 optionsItem.SetLocUpdateType(posUpdateType); |
|
912 gpsOptionsArray->AppendOptionItem(optionsItem); |
|
913 } |
|
914 |
|
915 iModuleModes.AppendL(gpsOptionsArray); |
|
916 } |
|
917 } |
|
918 |
|
919 |
|
920 CClientDetailsConfigReader* CClientDetailsConfigReader::NewL(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
921 RArray<TCTClientDetails>& aClientDetailsArray) |
|
922 { |
|
923 return new (ELeave) CClientDetailsConfigReader(aConfigFileName, aConfigSection, aClientDetailsArray); |
|
924 } |
|
925 CClientDetailsConfigReader::CClientDetailsConfigReader(const TDesC &aConfigFileName, const TDesC& aConfigSection, |
|
926 RArray<TCTClientDetails>& aClientDetailsArray) |
|
927 : CConfigReaderBase(aConfigFileName, aConfigSection), |
|
928 iClientDetailsArray(aClientDetailsArray) |
|
929 { |
|
930 } |
|
931 |
|
932 void CClientDetailsConfigReader::HandleSentenceL() |
|
933 { |
|
934 // Not a 'clientdetails' sentence, ignore all other valid sentences. |
|
935 if ( (iNumFields == 0) || (iFields[0].Compare(_L8("clientdetails")) != 0) ) |
|
936 { |
|
937 return; |
|
938 } |
|
939 |
|
940 ExtractDataL(); |
|
941 } |
|
942 |
|
943 void CClientDetailsConfigReader::DefaultData() |
|
944 /** |
|
945 * Does nothing since there is no default data to be set for the expected gps mode |
|
946 */ |
|
947 { |
|
948 } |
|
949 |
|
950 void CClientDetailsConfigReader::ExtractDataL() |
|
951 { |
|
952 TCTClientDetails clientDetails; |
|
953 TInt value; |
|
954 |
|
955 if(iNumFields > 1) |
|
956 { // initial delay - after which session ID it should start - default is 0 |
|
957 ExtractValueL(iFields[1], value); |
|
958 clientDetails.iSessionIdDelay = value; |
|
959 } |
|
960 |
|
961 if(iNumFields > 2) |
|
962 { // initial delay - after which step in the session it should start - default is 0 |
|
963 ExtractValueL(iFields[2], value); |
|
964 clientDetails.iSessionStepDelay = value; |
|
965 } |
|
966 |
|
967 if(iNumFields > 3) |
|
968 { // number of NPUDs issued by the client - default is 1 |
|
969 ExtractValueL(iFields[3], value); |
|
970 clientDetails.iNumberOfNPUDs = value > 0 ? value : 1; |
|
971 } |
|
972 |
|
973 if(iNumFields > 4) |
|
974 { // the update interval - default is 0 (no tracking) |
|
975 ExtractValueL(iFields[4], value); |
|
976 clientDetails.iUpdateOptions.SetUpdateInterval(value); |
|
977 } |
|
978 |
|
979 if(clientDetails.iNumberOfNPUDs == 1 || clientDetails.iUpdateOptions.UpdateInterval() == 0) |
|
980 { // if one of the params indicates no tracking then set the others to say the same |
|
981 clientDetails.iUpdateOptions.SetUpdateInterval(0); |
|
982 } |
|
983 |
|
984 if(iNumFields > 5) |
|
985 { // the max fix time - default is 0 (no timeout) |
|
986 ExtractValueL(iFields[5], value); |
|
987 clientDetails.iUpdateOptions.SetUpdateTimeOut(value); |
|
988 } |
|
989 |
|
990 if(iNumFields > 6) |
|
991 { // the max update age - default is 0 |
|
992 ExtractValueL(iFields[6], value); |
|
993 clientDetails.iUpdateOptions.SetMaxUpdateAge(value); |
|
994 } |
|
995 |
|
996 if(iNumFields > 7) |
|
997 { // if partial updates should be accepted - default is EFalse |
|
998 if (iFields[7].Compare(_L8("true")) == 0) |
|
999 { |
|
1000 clientDetails.iUpdateOptions.SetAcceptPartialUpdates(ETrue); |
|
1001 } |
|
1002 } |
|
1003 |
|
1004 if(iNumFields > 8) |
|
1005 { |
|
1006 { // if partial updates should be accepted - default is EFalse |
|
1007 if (iFields[8].Compare(_L8("cancel")) == 0) |
|
1008 { |
|
1009 clientDetails.iCancelRequest = ETrue; |
|
1010 } |
|
1011 } |
|
1012 } |
|
1013 |
|
1014 if(iNumFields > 9) |
|
1015 { // delay after which step in the session the last request should be cancelled - default is 0 |
|
1016 ExtractValueL(iFields[9], value); |
|
1017 clientDetails.iSessionIdCancel = value; |
|
1018 } |
|
1019 |
|
1020 if(iNumFields > 10) |
|
1021 { // delay after which session ID the last request should be cancelled - default is 0 |
|
1022 ExtractValueL(iFields[10], value); |
|
1023 clientDetails.iSessionStepCancel = value; |
|
1024 } |
|
1025 |
|
1026 iClientDetailsArray.AppendL(clientDetails); |
|
1027 } |