|
1 /* |
|
2 * Copyright (c) 2008 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: 'Set Place' component for retrieving place. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <evtmgmteditorui.rsg> |
|
19 #include <aknlistquerydialog.h> |
|
20 #include <StringLoader.h> |
|
21 #include <CLmkLandmarkSelectorDlg.h> |
|
22 #include <TLmkItemIdDbCombiInfo.h> |
|
23 #include <lbsposition.h> |
|
24 #include <aknnotewrappers.h> |
|
25 #include <aknmessagequerydialog.h> |
|
26 #include <AknIconArray.h> // Icon Array |
|
27 #include <evteditor.mbg> |
|
28 #include <AknsUtils.h> |
|
29 #include <AknsSkinInstance.h> |
|
30 #include <data_caging_path_literals.hrh> |
|
31 #include <gulicon.h> // Gul Icon |
|
32 #include <eikapp.h> |
|
33 #include <aknconsts.h> |
|
34 #include <textresolver.h> |
|
35 |
|
36 #include "evteditor.h" |
|
37 #include "evtmgmteditorui.hrh" |
|
38 #include "evtmgmtuiplacecomponent.h" |
|
39 #include "evtdebug.h" |
|
40 #include "evtmgmtuilocsettinglauncher.h" |
|
41 #include "evtmgmtuilocsettinglauncherobserver.h" |
|
42 #include "evteditorconsts.h" |
|
43 #include "evtmgmtuilbtadapter.h" |
|
44 |
|
45 // CONSTANTS |
|
46 const TInt KSetPlaceGranularity = 3; |
|
47 const TInt KMToKMConversion = 1000; |
|
48 _LIT( KFloatAccuracyFormat, "%.2f" ); |
|
49 |
|
50 static TInt LinkClickedL(TAny* aPtr); |
|
51 |
|
52 static TInt LinkClickedL(TAny* aPtr) |
|
53 { |
|
54 CEvtMgmtUiPlaceComponent* self = static_cast<CEvtMgmtUiPlaceComponent*>(aPtr); |
|
55 self->LaunchPositioningSettingsL(); |
|
56 return ETrue; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CEvtMgmtUiPlaceComponent ::NewLC() |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CEvtMgmtUiPlaceComponent* CEvtMgmtUiPlaceComponent::NewLC(const TPtrC aPrevPlace, TCoordinate& aTriggerLocation ) |
|
64 { |
|
65 CEvtMgmtUiPlaceComponent * self = new (ELeave) CEvtMgmtUiPlaceComponent( aTriggerLocation); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(aPrevPlace); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CEvtMgmtUiPlaceComponent ::NewL() |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CEvtMgmtUiPlaceComponent* CEvtMgmtUiPlaceComponent::NewL(const TPtrC aPrevPlace, TCoordinate& aTriggerLocation ) |
|
76 { |
|
77 CEvtMgmtUiPlaceComponent * self = CEvtMgmtUiPlaceComponent::NewLC( aPrevPlace, aTriggerLocation ); |
|
78 CleanupStack::Pop(self); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CEvtMgmtUiPlaceComponent ::CEvtMgmtUiPlaceComponent() |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CEvtMgmtUiPlaceComponent::CEvtMgmtUiPlaceComponent( TCoordinate& aTriggerLocation ):iTriggerLocation(aTriggerLocation) |
|
87 { |
|
88 iIsDlgOutstanding = EFalse; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CEvtMgmtUiPlaceComponent ::~CEvtMgmtUiPlaceComponent() |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CEvtMgmtUiPlaceComponent::~CEvtMgmtUiPlaceComponent() |
|
96 { |
|
97 delete iPlace; |
|
98 iPlace = NULL; |
|
99 |
|
100 if( iMapAdapter ) |
|
101 { |
|
102 delete iMapAdapter; |
|
103 iMapAdapter = NULL; |
|
104 } |
|
105 |
|
106 if( iLocationServiceAdapter ) |
|
107 { |
|
108 delete iLocationServiceAdapter; |
|
109 iLocationServiceAdapter = NULL; |
|
110 } |
|
111 |
|
112 if( iWaitDialogLauncher ) |
|
113 { |
|
114 delete iWaitDialogLauncher; |
|
115 iWaitDialogLauncher = NULL; |
|
116 } |
|
117 |
|
118 if(iPosSetLauncher) |
|
119 { |
|
120 delete iPosSetLauncher; |
|
121 iPosSetLauncher = NULL; |
|
122 } |
|
123 |
|
124 if( iIsDlgOutstanding ) |
|
125 { |
|
126 TKeyEvent key; |
|
127 key.iCode = EKeyEscape; |
|
128 key.iModifiers = 0; |
|
129 TRAP_IGNORE( CEikonEnv::Static()->SimulateKeyEventL(key, EEventKey)) ; |
|
130 } |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CEvtMgmtUiPlaceComponent ::ConstructL() |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 void CEvtMgmtUiPlaceComponent ::ConstructL(const TPtrC aPrevPlace) |
|
138 { |
|
139 iPlace = aPrevPlace.AllocL(); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlg() |
|
144 // It is used as a wrapper class to trap leaving function DisplayPlacePopupDlgL() |
|
145 // @param[in] aStatus - status which will contain success/failure state |
|
146 // based on retrieval of location is successful or failed |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlg( TRequestStatus& aStatus ) |
|
150 { |
|
151 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlg()" ); |
|
152 iStatus = &aStatus; |
|
153 TInt response(0); |
|
154 |
|
155 // show 'set place' popup dialog and retrieve location information |
|
156 TRAPD( err, response = DisplayPlacePopupDlgL() ); |
|
157 |
|
158 if( err != KErrNone )// if the request is failed |
|
159 { |
|
160 iIsDlgOutstanding = EFalse; |
|
161 //TRAP_IGNORE( ResolveErrorL( err ) ); |
|
162 User::RequestComplete( iStatus, err ); |
|
163 } |
|
164 else |
|
165 { |
|
166 //if from landmark, complete the request otherwise wait till asychronous |
|
167 //operation is completed |
|
168 if( response == EEvtMgmtUiSetPlaceLandmark ) |
|
169 { |
|
170 if( iStatus ) |
|
171 User::RequestComplete( iStatus, KErrNone ); |
|
172 } |
|
173 |
|
174 //if dialog is cancelled |
|
175 if( response == KErrCancel ) |
|
176 { |
|
177 if( iStatus ) |
|
178 User::RequestComplete( iStatus, KErrCancel ); |
|
179 } |
|
180 } |
|
181 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlg()" ); |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CEvtMgmtUiPlaceComponent::Place() |
|
186 // returns place value |
|
187 // ----------------------------------------------------------------------------- |
|
188 |
|
189 TPtrC CEvtMgmtUiPlaceComponent::Place() const |
|
190 { |
|
191 if(iPlace) |
|
192 return *iPlace; |
|
193 else |
|
194 return KNullDesC(); |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CEvtMgmtUiPlaceComponent::TriggerLocation() |
|
199 // returns location recentrly retrieved |
|
200 // ----------------------------------------------------------------------------- |
|
201 |
|
202 TCoordinate& CEvtMgmtUiPlaceComponent::TriggerLocation() const |
|
203 { |
|
204 return iTriggerLocation; |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // CEvtMgmtUiPlaceComponent::HandleMapAndNavigationResonseL() |
|
209 // Derived from MEvtMgmtUiMapAndNavigationObserver |
|
210 // --------------------------------------------------------------------------- |
|
211 // |
|
212 void CEvtMgmtUiPlaceComponent::HandleMapAndNavigationResponseL( TInt aErrorCode, const TPtrC aPlace, TCoordinate aTriggerLocation ) |
|
213 { |
|
214 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::HandleMapAndNavigationResponseL()" ); |
|
215 if( aErrorCode == KErrNone ) |
|
216 { |
|
217 //if successful , set place and location to those retrieved from map |
|
218 if(aPlace.Length()) |
|
219 { |
|
220 delete iPlace; |
|
221 iPlace = NULL; |
|
222 iPlace = aPlace.AllocL(); |
|
223 } |
|
224 |
|
225 // Get Place |
|
226 aErrorCode = GetPlaceL(); |
|
227 |
|
228 iTriggerLocation = aTriggerLocation; |
|
229 } |
|
230 |
|
231 // complete 'set place' operation selected from map |
|
232 if(iStatus) |
|
233 User::RequestComplete( iStatus, aErrorCode ); |
|
234 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::HandleMapAndNavigationResponseL()" ); |
|
235 } |
|
236 |
|
237 |
|
238 //--------------------------------------------------------------------------- |
|
239 // CEvtMgmtUiPlaceComponent::HandleLocationServiceResponseL() |
|
240 // Derived from MEvtMgmtUiLocationServiceObserver |
|
241 // --------------------------------------------------------------------------- |
|
242 // |
|
243 void CEvtMgmtUiPlaceComponent::HandleLocationServiceResponseL( const TInt aStatus ) |
|
244 { |
|
245 EVTUIDEBUG1("+ CEvtMgmtUiPlaceComponent::HandleLocationServiceResponseL() - %d", aStatus ); |
|
246 TInt err = aStatus; |
|
247 // Stop the running wait dialog |
|
248 TInt buttonId = iWaitDialogLauncher->StopWaitDialogL(); |
|
249 |
|
250 if( EEikBidCancel != buttonId ) // if busy dialog is not cancelled |
|
251 { |
|
252 switch( aStatus ) |
|
253 { |
|
254 case KErrNone: |
|
255 case KPositionPartialUpdate: |
|
256 { |
|
257 if(iLocationServiceAdapter) |
|
258 { |
|
259 EVTUIDEBUG("========== Retrieving current location ========" ); |
|
260 |
|
261 //Set location |
|
262 iTriggerLocation = iLocationServiceAdapter->CurrentPosition(); |
|
263 TPosition pos = iLocationServiceAdapter->CurrentPosition(); |
|
264 |
|
265 if ( !Math::IsNaN( pos.HorizontalAccuracy() ) ) |
|
266 DisplayAccuracyNoteL(pos); |
|
267 else |
|
268 DisplayAccuracyNoteL(); |
|
269 |
|
270 // Get Place |
|
271 err = GetPlaceL(); |
|
272 } |
|
273 EVTUIDEBUG("========== Retrieved current location ========" ); |
|
274 break; |
|
275 } |
|
276 default: |
|
277 { |
|
278 break; |
|
279 } |
|
280 } |
|
281 // complete 'set place' operation selected from current location |
|
282 if( iStatus ) |
|
283 User::RequestComplete( iStatus, err ); |
|
284 } |
|
285 else |
|
286 { |
|
287 TRAP( err, DisplayErrorNoteL( R_EVTUI_CANCEL_REQUESTING_LOCATION ) ); |
|
288 EVTUIDEBUG1("Erro while displaying error note =%d", err ); |
|
289 |
|
290 // complete 'set place' operation selected from current location |
|
291 if( iStatus ) |
|
292 User::RequestComplete( iStatus, KErrCancel ); |
|
293 } |
|
294 |
|
295 //Delete LocAcq object |
|
296 if( iLocationServiceAdapter ) |
|
297 { |
|
298 delete iLocationServiceAdapter; |
|
299 iLocationServiceAdapter = NULL; |
|
300 } |
|
301 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::HandleLocationServiceResponseL()"); |
|
302 } |
|
303 |
|
304 //--------------------------------------------------------------------------- |
|
305 // CEvtMgmtUiPlaceComponent::HandleLocationServiceErrorL() |
|
306 // Derived from MEvtMgmtUiLocationServiceObserver |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CEvtMgmtUiPlaceComponent::HandleLocationServiceErrorL( TInt aErrorCode ) |
|
310 { |
|
311 EVTUIDEBUG1("+ CEvtMgmtUiPlaceComponent::HandleLocationServiceErrorL - %d", aErrorCode ); |
|
312 |
|
313 //Error handling |
|
314 switch( aErrorCode ) |
|
315 { |
|
316 case KErrNotFound: //if no psy selected |
|
317 { |
|
318 //Delete wait dialog |
|
319 if( iWaitDialogLauncher ) |
|
320 iWaitDialogLauncher->StopWaitDialogL(); |
|
321 |
|
322 if( DisplayNoPositioningMethodInfoNoteL( R_EVTUI_MESSAGE_QUERY ) ) //if Open is pressed |
|
323 { |
|
324 return; |
|
325 } |
|
326 break; |
|
327 } |
|
328 case KErrCancel: |
|
329 { |
|
330 //Delete wait dialog |
|
331 if( iWaitDialogLauncher ) |
|
332 iWaitDialogLauncher->StopWaitDialogL(); |
|
333 |
|
334 TRAPD( err, DisplayErrorNoteL( R_EVTUI_CANCEL_REQUESTING_LOCATION ) ); |
|
335 EVTUIDEBUG1("Erro while displaying error note =%d", err ); |
|
336 |
|
337 break; |
|
338 } |
|
339 case KErrTimedOut: |
|
340 default: |
|
341 { |
|
342 //Delete wait dialog |
|
343 if( iWaitDialogLauncher ) |
|
344 iWaitDialogLauncher->StopWaitDialogL(); |
|
345 |
|
346 //disply retry message |
|
347 CAknErrorNote* errNote = new(ELeave) CAknErrorNote( ETrue ); |
|
348 TBuf<128> msg; |
|
349 CEikonEnv::Static()->ReadResourceAsDes16L(msg, R_EVTUI_RETRY_REQUESTING_LOCATION ); |
|
350 errNote->ExecuteLD( msg ); |
|
351 |
|
352 break; |
|
353 } |
|
354 } |
|
355 |
|
356 //delete LocAcq object |
|
357 if( iLocationServiceAdapter ) |
|
358 { |
|
359 delete iLocationServiceAdapter; |
|
360 iLocationServiceAdapter = NULL; |
|
361 } |
|
362 |
|
363 // Complete 'set place' operation selected from current location with failure |
|
364 User::RequestComplete( iStatus, KErrCancel ); |
|
365 |
|
366 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::HandleLocationServiceErrorL()"); |
|
367 } |
|
368 |
|
369 //--------------------------------------------------------------------------- |
|
370 // CEvtMgmtUiPlaceComponent::HandleDialogDismissed() |
|
371 // Derived from MEvtMgmtUiWaitDialogLauncherObserver |
|
372 // --------------------------------------------------------------------------- |
|
373 // |
|
374 void CEvtMgmtUiPlaceComponent::HandleDialogDismissed( TInt aButtonId ) |
|
375 { |
|
376 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::HandleDialogDismissed()"); |
|
377 if( EEikBidCancel == aButtonId && iLocationServiceAdapter && |
|
378 iLocationServiceAdapter->IsActive() ) |
|
379 { |
|
380 EVTUIDEBUG("wait dialog is dismissed manually" ); |
|
381 |
|
382 //Cancel Outstanding Request |
|
383 iLocationServiceAdapter->CancelRequest(); |
|
384 } |
|
385 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::HandleDialogDismissed()"); |
|
386 } |
|
387 |
|
388 //--------------------------------------------------------------------------- |
|
389 // CEvtMgmtUiPlaceComponent::NotifyLocSettingLaucherChangeL() |
|
390 // Derived from MEvtMgmtUiLocSettingsLauncherObserver |
|
391 // --------------------------------------------------------------------------- |
|
392 // |
|
393 void CEvtMgmtUiPlaceComponent::NotifyLocSettingLaucherChangeL( TInt /*aErrorCode*/ ) |
|
394 { |
|
395 // Nothing to do. |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // void CEvtMgmtUiPlaceComponent::DisplayErrorNoteL() |
|
400 // It is used to display error note. |
|
401 // @param[in] aResourceId - resource ID of the text to be displayed on error note. |
|
402 // --------------------------------------------------------------------------- |
|
403 // |
|
404 void CEvtMgmtUiPlaceComponent::DisplayErrorNoteL(TInt aResourceId ) |
|
405 { |
|
406 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::DisplayErrorNoteL" ); |
|
407 CAknErrorNote* errNote = new(ELeave) CAknErrorNote( ETrue ); |
|
408 TBuf<32> msg; |
|
409 CEikonEnv::Static()->ReadResourceAsDes16L(msg, aResourceId ); |
|
410 iIsDlgOutstanding = ETrue; |
|
411 errNote->ExecuteLD( msg ); |
|
412 iIsDlgOutstanding = EFalse; |
|
413 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::DisplayErrorNoteL" ); |
|
414 } |
|
415 |
|
416 // --------------------------------------------------------------------------- |
|
417 // TInt CEvtMgmtUiPlaceComponent::GetPlaceL() |
|
418 // Displays the Query dialog for getting place. |
|
419 // --------------------------------------------------------------------------- |
|
420 // |
|
421 TInt CEvtMgmtUiPlaceComponent::GetPlaceL() |
|
422 { |
|
423 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::GetPlaceL()"); |
|
424 |
|
425 HBufC* place = HBufC::NewLC( KPlaceMaxLength ); |
|
426 place->Des().Copy( *iPlace ); |
|
427 TPtr placePtr(place->Des()); |
|
428 TInt ret = KErrCancel; |
|
429 |
|
430 HBufC* prompt = StringLoader::LoadLC(R_LOCEV_NOTE_PROMPT_TEXT); |
|
431 |
|
432 CAknTextQueryDialog* dlg = new(ELeave) CAknTextQueryDialog( placePtr ,*prompt, CAknQueryDialog::ENoTone ); |
|
433 if( EEikBidOk == dlg->ExecuteLD( R_EVTUI_PLACE_DATA_QUERY )) |
|
434 { |
|
435 delete iPlace; |
|
436 iPlace = NULL; |
|
437 iPlace = place->AllocL(); |
|
438 ret = KErrNone; |
|
439 } |
|
440 |
|
441 CleanupStack::PopAndDestroy(2); // prompt, place |
|
442 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::GetPlaceL()"); |
|
443 return ret; |
|
444 } |
|
445 |
|
446 // --------------------------------------------------------------------------- |
|
447 // TInt CEvtMgmtUiPlaceComponent::LaunchPositioningSettingsL() |
|
448 // It is used to launch position settings |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 void CEvtMgmtUiPlaceComponent::LaunchPositioningSettingsL() |
|
452 { |
|
453 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::LaunchPositioningSettingsL()"); |
|
454 if(!iPosSetLauncher) |
|
455 { |
|
456 iPosSetLauncher = CEvtMgmtUiLocSettingsLauncher::NewL(); |
|
457 } |
|
458 iPosSetLauncher->SetObserver(this); |
|
459 iPosSetLauncher->LaunchL(); |
|
460 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::LaunchPositioningSettingsL()"); |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlgL() |
|
465 // It is used to display 'set place' popup dialog and retrieve place |
|
466 // using selected method. |
|
467 // @ret it returns the option selected. |
|
468 // it leaves with KErrCancel, if popup dialog is cancelled. |
|
469 // it may leave with other errors, if retrieval of place fails. |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 TInt CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlgL() |
|
473 { |
|
474 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::DisplayPlacePopupDlgL()"); |
|
475 TInt index; |
|
476 const TInt KCpIconIndex = 0; |
|
477 const TInt KLmkIconIndex = 1; |
|
478 const TInt KMapIconIndex = 2; |
|
479 const TInt KIconTextLength = 1; |
|
480 _LIT(KTab, "\t"); |
|
481 HBufC* dummy = NULL; |
|
482 |
|
483 // Retrieve number of landmarks stored in landmark database. |
|
484 TInt lmks = LandmarksL(); |
|
485 |
|
486 //Retrive strings for popup dialog. |
|
487 |
|
488 //Current Location |
|
489 dummy = StringLoader::LoadLC(R_EVTUI_CREATENEW_FORM_PLACEPOPUPOPTION_CURRENTPLACE); |
|
490 HBufC* cp = HBufC::NewL( KIconTextLength + KTab().Length() + |
|
491 dummy->Length() + KTab().Length( )+ KTab().Length() ); |
|
492 TPtr ptrDummy = cp->Des(); |
|
493 ptrDummy.Num(KCpIconIndex); |
|
494 ptrDummy.Append(KTab); |
|
495 ptrDummy.Append(*dummy); |
|
496 ptrDummy.Append(KTab); |
|
497 ptrDummy.Append(KTab); |
|
498 CleanupStack::PopAndDestroy(dummy); |
|
499 CleanupStack::PushL(cp); |
|
500 |
|
501 //Landmark |
|
502 dummy = StringLoader::LoadLC(R_EVTUI_CREATENEW_FORM_PLACEPOPUPOPTION_LANDMARK); |
|
503 HBufC* lmk = HBufC::NewL( KIconTextLength + KTab().Length() + |
|
504 dummy->Length() + KTab().Length( )+ KTab().Length() ); |
|
505 ptrDummy.Set(lmk->Des()); |
|
506 ptrDummy.Num(KLmkIconIndex); |
|
507 ptrDummy.Append(KTab); |
|
508 ptrDummy.Append(*dummy); |
|
509 ptrDummy.Append(KTab); |
|
510 ptrDummy.Append(KTab); |
|
511 CleanupStack::PopAndDestroy(dummy); |
|
512 CleanupStack::PushL(lmk); |
|
513 |
|
514 //Map |
|
515 dummy = StringLoader::LoadLC(R_EVTUI_CREATENEW_FORM_PLACEPOPUPOPTION_FROMMAP); |
|
516 HBufC* map = HBufC::NewL( KIconTextLength + KTab().Length() + |
|
517 dummy->Length() + KTab().Length( )+ KTab().Length() ); |
|
518 ptrDummy.Set(map->Des()); |
|
519 ptrDummy.Num(KMapIconIndex); |
|
520 ptrDummy.Append(KTab); |
|
521 ptrDummy.Append(*dummy); |
|
522 ptrDummy.Append(KTab); |
|
523 ptrDummy.Append(KTab); |
|
524 CleanupStack::PopAndDestroy(dummy); |
|
525 CleanupStack::PushL(map); |
|
526 |
|
527 HBufC* title = StringLoader::LoadLC(R_EVTUI_CREATENEW_FORM_PLACEPOPUP_TITLE); |
|
528 |
|
529 //Create array |
|
530 CDesCArrayFlat* array = new(ELeave)CDesCArrayFlat( KSetPlaceGranularity ); |
|
531 CleanupStack::PushL(array); |
|
532 |
|
533 //Add current location |
|
534 array->AppendL(*cp); |
|
535 |
|
536 //if landmarks are present, then add 'Landmark' |
|
537 if( lmks ) |
|
538 array->AppendL(*lmk); |
|
539 |
|
540 //Create map object to retrieve place from maps |
|
541 if( iMapAdapter ) |
|
542 { |
|
543 delete iMapAdapter; |
|
544 iMapAdapter = NULL; |
|
545 } |
|
546 iMapAdapter = CEvtMgmtUiMapNavigationAdapter::NewL(); |
|
547 iMapAdapter->SetPlaceL( *iPlace ); |
|
548 iMapAdapter->SetLocation( iTriggerLocation ); |
|
549 iMapAdapter->SetObserver( this ); |
|
550 |
|
551 //if map service providers are present, then add 'From map' |
|
552 if(iMapAdapter->MapServiceProvidersL()) |
|
553 array->AppendL(*map); |
|
554 else //if map service provider is not present, delete map object |
|
555 { |
|
556 delete iMapAdapter; |
|
557 iMapAdapter = NULL; |
|
558 } |
|
559 |
|
560 //popup dialog |
|
561 CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &index ); |
|
562 dlg->PrepareLC(R_EVTMGMTUI_LIST_QUERY); |
|
563 UpdateIconsL( *dlg ); |
|
564 dlg->SetItemTextArray(array ); |
|
565 dlg->SetOwnershipType(ELbmOwnsItemArray); |
|
566 dlg->QueryHeading()->SetTextL(*title); |
|
567 |
|
568 iIsDlgOutstanding = ETrue; |
|
569 if ( dlg->RunLD() ) //if item is selected |
|
570 { |
|
571 iIsDlgOutstanding = EFalse; |
|
572 CleanupStack::Pop();// pop up array since ownership is handed to dlg |
|
573 CleanupStack::PopAndDestroy(4) ;//title, map, lmk, cp |
|
574 switch(index) |
|
575 { |
|
576 case EEvtMgmtUiSetPlaceCurrentPlace: //if current place is selected |
|
577 { |
|
578 EVTUIDEBUG("= Set Current place"); |
|
579 PlaceFromCurrentLocationL(); |
|
580 break; |
|
581 } |
|
582 case EEvtMgmtUiSetPlaceLandmark: |
|
583 { |
|
584 if(lmks) //if landmarks are present, 'Landmark' is pressed |
|
585 { |
|
586 EVTUIDEBUG("= Set Landmark place"); |
|
587 PlaceFromLandmarkL(); |
|
588 break; |
|
589 } |
|
590 //else 'From map' is pressed, hence request place from map |
|
591 //break; ....intentionally commented |
|
592 } |
|
593 case EEvtMgmtUiSetPlaceFromMap: |
|
594 { |
|
595 EVTUIDEBUG("= Set Map place"); |
|
596 index = EEvtMgmtUiSetPlaceFromMap; |
|
597 iMapAdapter->PlaceFromMapL(); |
|
598 break; |
|
599 } |
|
600 default: |
|
601 { |
|
602 break; |
|
603 } |
|
604 } |
|
605 return index; |
|
606 } |
|
607 else |
|
608 { |
|
609 iIsDlgOutstanding = EFalse; |
|
610 CleanupStack::Pop();// pop up array since ownership is handed to dlg |
|
611 CleanupStack::PopAndDestroy(4) ;//title, map, lmk, cp |
|
612 return KErrCancel; |
|
613 } |
|
614 } |
|
615 |
|
616 // ----------------------------------------------------------------------------- |
|
617 // CEvtMgmtUiPlaceComponent::PlaceFromLandmarkL() |
|
618 // It retrieves place and location details from landmark |
|
619 // ----------------------------------------------------------------------------- |
|
620 // |
|
621 void CEvtMgmtUiPlaceComponent::PlaceFromLandmarkL() |
|
622 { |
|
623 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::PlaceFromLandmarkL()"); |
|
624 _LIT(KCommaSeparator,", "); |
|
625 TLmkItemIdDbCombiInfo lmkInfo; |
|
626 CLmkLandmarkSelectorDlg* dlg = CLmkLandmarkSelectorDlg::NewL(); |
|
627 iIsDlgOutstanding = ETrue; |
|
628 if(dlg->ExecuteLD(lmkInfo)) |
|
629 { |
|
630 iIsDlgOutstanding = EFalse; |
|
631 CPosLandmarkDatabase* lmkDb = lmkInfo.GetLmDb(); |
|
632 CleanupStack::PushL(lmkDb); |
|
633 CPosLandmark* lmk = lmkDb->ReadLandmarkLC( lmkInfo.GetItemId() ); |
|
634 |
|
635 //retrieve lat long info |
|
636 TLocality locality; |
|
637 lmk->GetPosition( locality ); |
|
638 if(Math::IsNaN( locality.Latitude() ) || Math::IsNaN( locality.Longitude() ) ) |
|
639 { |
|
640 CAknErrorNote* errNote = new(ELeave) CAknErrorNote( ETrue ); |
|
641 TBuf<128> msg; |
|
642 CEikonEnv::Static()->ReadResourceAsDes16L(msg, R_EVTUI_LANDMARK_LOCMISS_ERROR ); |
|
643 errNote->ExecuteLD( msg ); |
|
644 CleanupStack::PopAndDestroy(2);//lmk,lmkDb |
|
645 iIsDlgOutstanding = EFalse; |
|
646 User::Leave(KErrCancel); |
|
647 } |
|
648 iTriggerLocation = locality; |
|
649 |
|
650 //retrive position description |
|
651 delete iPlace; |
|
652 iPlace = NULL; |
|
653 iPlace = HBufC::NewL(KPlaceMaxLength); |
|
654 TPtr placePtr = iPlace->Des(); |
|
655 |
|
656 TPtrC ptr(KNullDesC); |
|
657 |
|
658 if(lmk->GetLandmarkName(ptr)!=KErrNotFound) |
|
659 { |
|
660 placePtr.Copy(ptr); |
|
661 placePtr.Append(_L(" ")); |
|
662 } |
|
663 if(lmk->GetPositionField(EPositionFieldStreet,ptr)!=KErrNotFound && ptr.Compare(KNullDesC)!=0) |
|
664 { |
|
665 placePtr.Append(ptr); |
|
666 placePtr.Append(KCommaSeparator); |
|
667 } |
|
668 if(lmk->GetPositionField(EPositionFieldCity,ptr)!=KErrNotFound && ptr.Compare(KNullDesC)!=0) |
|
669 { |
|
670 placePtr.Append(ptr); |
|
671 placePtr.Append(KCommaSeparator); |
|
672 } |
|
673 if(lmk->GetPositionField(EPositionFieldState,ptr)!=KErrNotFound && ptr.Compare(KNullDesC)!=0) |
|
674 { |
|
675 placePtr.Append(ptr); |
|
676 placePtr.Append(KCommaSeparator); |
|
677 } |
|
678 if(lmk->GetPositionField(EPositionFieldCounty,ptr)!=KErrNotFound && ptr.Compare(KNullDesC)!=0) |
|
679 { |
|
680 placePtr.Append(KCommaSeparator); |
|
681 placePtr.Append(ptr); |
|
682 } |
|
683 if(lmk->GetPositionField(EPositionFieldCountry,ptr)!=KErrNotFound && ptr.Compare(KNullDesC)!=0) |
|
684 { |
|
685 placePtr.Append(ptr); |
|
686 placePtr.Append(KCommaSeparator); |
|
687 } |
|
688 TInt commaDesLen = KCommaSeparator().Length(); |
|
689 if(placePtr.Mid(placePtr.Length()-commaDesLen,commaDesLen).Compare(KCommaSeparator)==0) |
|
690 placePtr.Delete(placePtr.Length()-commaDesLen, commaDesLen); |
|
691 else |
|
692 placePtr.Delete(placePtr.Length()-1,1); |
|
693 |
|
694 //iEvent.SetPlaceL(*place); |
|
695 CleanupStack::PopAndDestroy(2);//lmk,lmkDb |
|
696 } |
|
697 else |
|
698 { |
|
699 iIsDlgOutstanding = EFalse; |
|
700 if( iStatus ) |
|
701 User::RequestComplete( iStatus, KErrCancel ); |
|
702 } |
|
703 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::PlaceFromLandmarkL()"); |
|
704 } |
|
705 |
|
706 // ----------------------------------------------------------------------------- |
|
707 // CEvtMgmtUiPlaceComponent::LandmarksL() |
|
708 // It returns total number of landmarks stored. |
|
709 // If there is any error in retrieving details, it will return zero landmark. |
|
710 // ----------------------------------------------------------------------------- |
|
711 // |
|
712 TInt CEvtMgmtUiPlaceComponent::LandmarksL() |
|
713 { |
|
714 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::LandmarksL()" ); |
|
715 TInt lmks = 0; |
|
716 |
|
717 CPosLandmarkDatabase* lmkDb; |
|
718 lmkDb = CPosLandmarkDatabase::OpenL(); |
|
719 CleanupStack::PushL(lmkDb); |
|
720 // Initialize Landmarks data base if required |
|
721 CPosLmOperation* operation = lmkDb->InitializeL(); |
|
722 CleanupStack::PushL(operation); |
|
723 operation->ExecuteL(); |
|
724 CPosLmItemIterator* iterator = lmkDb->LandmarkIteratorL(); |
|
725 CleanupStack::PushL(iterator); |
|
726 lmks = iterator->NumOfItemsL(); |
|
727 CleanupStack::PopAndDestroy(3); //lmkDb, iterator and operation |
|
728 |
|
729 EVTUIDEBUG1("Number of Landmarks = %d", lmks ); |
|
730 |
|
731 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::LandmarksL()" ); |
|
732 return lmks; |
|
733 } |
|
734 |
|
735 // ----------------------------------------------------------------------------- |
|
736 // CEvtMgmtUiPlaceComponent::PlaceFromCurrentLocationL() |
|
737 // It initiates set place request from current location. |
|
738 // If there is no positioning method enabled, it will leave with KErrCancel. |
|
739 // Otherwise it will request current location and will launch busy dialog |
|
740 // ----------------------------------------------------------------------------- |
|
741 // |
|
742 void CEvtMgmtUiPlaceComponent::PlaceFromCurrentLocationL() |
|
743 { |
|
744 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::PlaceFromCurrentLocationL()" ); |
|
745 // Delete any previously created LocAcq object. |
|
746 if( !iLocationServiceAdapter ) |
|
747 { |
|
748 //Create new LocAcq object |
|
749 iLocationServiceAdapter = CEvtMgmtUiLocationServiceAdapter::NewL( *this ); |
|
750 } |
|
751 |
|
752 EVTUIDEBUG("Before iLocationServiceAdapter->LocationRequestL" ); |
|
753 iLocationServiceAdapter->LocationRequestL(); |
|
754 EVTUIDEBUG("After iLocationServiceAdapter->LocationRequestL" ); |
|
755 |
|
756 if( iWaitDialogLauncher ) |
|
757 { |
|
758 EVTUIDEBUG("Deleting iWaitDialogLauncher..." ); |
|
759 delete iWaitDialogLauncher; |
|
760 iWaitDialogLauncher = NULL; |
|
761 } |
|
762 |
|
763 // Create the wait dialog launcher |
|
764 iWaitDialogLauncher = CEvtMgmtUiWaitDialogLauncher::NewL(); |
|
765 iWaitDialogLauncher->SetObserver(this); |
|
766 iWaitDialogLauncher->SetTextL( R_EVTUI_WAIT_REQUESTING_LOCATION ); |
|
767 |
|
768 EVTUIDEBUG("Before iWaitDialogLauncher->StartWaitDialogL" ); |
|
769 //Start busy wait dialog while requesting current location |
|
770 TRAPD( error, iWaitDialogLauncher->StartWaitDialogL()); |
|
771 EVTUIDEBUG1("After iWaitDialogLauncher->StartWaitDialogL - %d", error ); |
|
772 |
|
773 //if error while displaying dialog, delete LocAcq object and leave |
|
774 if( error ) |
|
775 { |
|
776 delete iLocationServiceAdapter; |
|
777 iLocationServiceAdapter = NULL; |
|
778 |
|
779 User::Leave( error ); |
|
780 } |
|
781 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::PlaceFromCurrentLocationL()" ); |
|
782 } |
|
783 |
|
784 // ----------------------------------------------------------------------------- |
|
785 // CEvtMgmtUiPlaceComponent::DisplayNoPositioningMethodInfoNoteL() |
|
786 // It displays message query if there is no positioning method enabled. |
|
787 // @param aResourceId - resource id of the wait dialog to be displayed. |
|
788 // @ret If pressed Open, it will return true. |
|
789 // If pressed Close, it will return false. |
|
790 // ----------------------------------------------------------------------------- |
|
791 // |
|
792 TBool CEvtMgmtUiPlaceComponent::DisplayNoPositioningMethodInfoNoteL( TInt aResourceId ) |
|
793 { |
|
794 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::DisplayNoPositioningMethodInfoNoteL()"); |
|
795 TBool response = EFalse; |
|
796 |
|
797 //all strings |
|
798 HBufC* errMsg = StringLoader::LoadLC( R_EVTUI_POSITIONINGERROR, CCoeEnv::Static() ); |
|
799 HBufC* errMsgLink = StringLoader::LoadLC( R_EVTUI_POSITIONINGERROR_LINK, CCoeEnv::Static() ); |
|
800 HBufC* errMsgTitle = StringLoader::LoadLC( R_EVTUI_POSITIONINGERROR_HEADER, CCoeEnv::Static() ); |
|
801 HBufC* errCompleteMsg = HBufC::NewLC( errMsg->Length() + KNewLine().Length() + errMsgLink->Length() ); |
|
802 errCompleteMsg->Des().Copy(*errMsg); |
|
803 errCompleteMsg->Des().Append(KNewLine); |
|
804 errCompleteMsg->Des().Append(*errMsgLink); |
|
805 |
|
806 //Launch dialog |
|
807 CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*errCompleteMsg); |
|
808 dlg->PrepareLC( aResourceId ); |
|
809 dlg->SetLinkTextL(*errMsgLink); |
|
810 TCallBack callBack = TCallBack(LinkClickedL, this); |
|
811 dlg->SetLink( callBack ); |
|
812 dlg->QueryHeading()->SetTextL( *errMsgTitle ); |
|
813 if( dlg->RunLD() == EAknSoftkeyOk ) |
|
814 { |
|
815 CleanupStack::PopAndDestroy(4); //errMsgTitle, errMsg, errMsgLink, errCompleteMsg |
|
816 |
|
817 if( ! iLocationServiceAdapter->AllPositionMethodsDisabledL() ) //if atleast one psy is enabled |
|
818 { |
|
819 response = ETrue; |
|
820 //request current location |
|
821 PlaceFromCurrentLocationL(); |
|
822 } |
|
823 else |
|
824 response = EFalse; |
|
825 } |
|
826 else |
|
827 { |
|
828 response = EFalse; |
|
829 CleanupStack::PopAndDestroy(4); //errMsgTitle, errMsg, errMsgLink, errCompleteMsg |
|
830 } |
|
831 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::DisplayNoPositioningMethodInfoNoteL()"); |
|
832 return response; |
|
833 } |
|
834 |
|
835 // ----------------------------------------------------------------------------- |
|
836 // CEvtMgmtUiPlaceComponent::UpdateIconsL |
|
837 // It update icons |
|
838 // ----------------------------------------------------------------------------- |
|
839 void CEvtMgmtUiPlaceComponent::UpdateIconsL( CAknListQueryDialog& aDialog ) |
|
840 { |
|
841 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::UpdateIconsL()" ); |
|
842 |
|
843 CAknIconArray* icons = new( ELeave ) CAknIconArray( KSetPlaceGranularity ); |
|
844 CleanupStack::PushL( icons ); |
|
845 |
|
846 TFileName *iconFile = IconFileNameLC(); |
|
847 |
|
848 AddIconL( *icons, |
|
849 *iconFile, |
|
850 KAknsIIDQgnPropLocevCurrentLocation, |
|
851 EMbmEvteditorQgn_prop_locev_current_location, EMbmEvteditorQgn_prop_locev_current_location_mask); |
|
852 |
|
853 AddIconL( *icons, |
|
854 *iconFile, |
|
855 KAknsIIDQgnPropLocevLandmark, |
|
856 EMbmEvteditorQgn_prop_locev_landmark, EMbmEvteditorQgn_prop_locev_landmark_mask); |
|
857 |
|
858 AddIconL( *icons, |
|
859 *iconFile, |
|
860 KAknsIIDQgnPropLocevMap, |
|
861 EMbmEvteditorQgn_prop_locev_map, EMbmEvteditorQgn_prop_locev_map_mask); |
|
862 |
|
863 CleanupStack::PopAndDestroy(iconFile); |
|
864 |
|
865 //set new icons to array |
|
866 aDialog.SetIconArrayL( icons ); |
|
867 CleanupStack::Pop(icons); |
|
868 |
|
869 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::UpdateIconsL()" ); |
|
870 |
|
871 } |
|
872 |
|
873 // ----------------------------------------------------------------------------- |
|
874 // CEvtMgmtUiPlaceComponent::AddIconL |
|
875 // Append icon to icon array. CAknIconArray owns icons so it is |
|
876 // easier to it leave safely. |
|
877 // @param aIcons icon array |
|
878 // @param aIconFileWithPath icon file name with path |
|
879 // @param aSkinID skin id of the icon |
|
880 // @param aIconGraphicsIndex picture index |
|
881 // @param aIconGraphicsMaskIndex mask index |
|
882 // ----------------------------------------------------------------------------- |
|
883 void CEvtMgmtUiPlaceComponent::AddIconL( CAknIconArray& aIcons, |
|
884 const TDesC& aIconFileWithPath, |
|
885 TAknsItemID aSkinID, |
|
886 TInt aIconGraphicsIndex, |
|
887 TInt aIconGraphicsMaskIndex ) |
|
888 { |
|
889 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
890 |
|
891 EVTUIDEBUG( "AknsUtils::SkinInstance" ); |
|
892 |
|
893 CFbsBitmap* bitmap = NULL; |
|
894 CFbsBitmap* bitmapMask = NULL; |
|
895 TRAPD( err, AknsUtils::CreateIconL( skin, |
|
896 aSkinID, |
|
897 bitmap, |
|
898 bitmapMask, |
|
899 aIconFileWithPath, |
|
900 aIconGraphicsIndex, |
|
901 aIconGraphicsMaskIndex ) ); |
|
902 |
|
903 |
|
904 EVTUIDEBUG1( "AknsUtils::CreateIconL - %d", err ); |
|
905 if(err != KErrNone) |
|
906 { |
|
907 TRAP( err, AknIconUtils::CreateIconL( bitmap, |
|
908 bitmapMask, |
|
909 aIconFileWithPath, |
|
910 aIconGraphicsIndex, |
|
911 aIconGraphicsMaskIndex ) ); |
|
912 EVTUIDEBUG1( "AknIconUtils::CreateIconL - %d", err ); |
|
913 } |
|
914 User::LeaveIfError( err ); |
|
915 |
|
916 CleanupStack::PushL( bitmap ); |
|
917 CleanupStack::PushL( bitmapMask ); |
|
918 |
|
919 CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask ); |
|
920 |
|
921 // Remove the Bitmap and the Bitmap Icon from the Clean up stack since |
|
922 // the ownership is taken over by the icon |
|
923 CleanupStack::Pop( bitmapMask ); |
|
924 CleanupStack::Pop( bitmap ); |
|
925 |
|
926 CleanupStack::PushL( icon ); |
|
927 aIcons.AppendL( icon ); |
|
928 CleanupStack::Pop( icon ); // icon |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // CEvtMgmtUiPlaceComponent::IconFileNameLC |
|
933 // Gets Events Management UI icon file path and name. Ownership |
|
934 // is transferred, item is left in the cleanup stack. |
|
935 // @return TFileName* The full name of the Events UI icon file. |
|
936 // ----------------------------------------------------------------------------- |
|
937 TFileName* CEvtMgmtUiPlaceComponent::IconFileNameLC() const |
|
938 { |
|
939 TFileName* fileName = new(ELeave) TFileName; |
|
940 CleanupStack::PushL( fileName ); |
|
941 |
|
942 TFileName* tmpName = new(ELeave) TFileName; |
|
943 CleanupStack::PushL( tmpName ); |
|
944 |
|
945 tmpName->Append( KDC_BITMAP_DIR ); |
|
946 tmpName->Append( KEvtMgmtUiIconFileName ); |
|
947 |
|
948 CEikAppUi *appUi = ( CEikAppUi *)( CEikonEnv::Static()->AppUi()); |
|
949 TFileName appDrive = appUi->Application()->AppFullName(); |
|
950 |
|
951 TParse parse; |
|
952 User::LeaveIfError( parse.Set( appDrive, NULL, NULL ) ); |
|
953 User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) ); |
|
954 |
|
955 fileName->Copy(parse.FullName()); |
|
956 |
|
957 CleanupStack::PopAndDestroy( tmpName ); |
|
958 |
|
959 return fileName; |
|
960 } |
|
961 |
|
962 // --------------------------------------------------------- |
|
963 // CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL |
|
964 // It is used to display accuracy note |
|
965 // --------------------------------------------------------- |
|
966 // |
|
967 void CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL() |
|
968 { |
|
969 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL() - Unknown" ); |
|
970 HBufC* infoMsg = StringLoader::LoadLC(R_LOCEV_NOTE_LIST_ACC_UNKNOWN, CEikonEnv::Static()); |
|
971 CAknInformationNote* infoNote = new(ELeave) CAknInformationNote( ETrue ); |
|
972 infoNote->ExecuteLD( *infoMsg ); |
|
973 CleanupStack::PopAndDestroy(); //infoMsg |
|
974 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL()" ); |
|
975 } |
|
976 |
|
977 // --------------------------------------------------------- |
|
978 // CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL |
|
979 // It is used to display accuracy note |
|
980 // --------------------------------------------------------- |
|
981 // |
|
982 void CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL(TPosition& aPos) |
|
983 { |
|
984 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL() - TPosition" ); |
|
985 _LIT(KNewLine, "\n"); |
|
986 HBufC* acclevel = NULL; |
|
987 HBufC* accString = NULL; |
|
988 |
|
989 // Calculate the Accuracy Level |
|
990 TReal accuracy = aPos.HorizontalAccuracy(); |
|
991 EVTUIDEBUG1("Horizontal Accuracy = %f", accuracy ); |
|
992 |
|
993 if(accuracy < KLowAccuracyMaxLimit ) |
|
994 acclevel = StringLoader::LoadLC(R_EVTUI_ACCURACYLEVEL_HIGH ); |
|
995 if(accuracy >=KLowAccuracyMaxLimit && accuracy <= KMediumAccuracyMaxLimit ) |
|
996 acclevel = StringLoader::LoadLC(R_EVTUI_ACCURACYLEVEL_MEDIUM ); |
|
997 if(accuracy > KMediumAccuracyMaxLimit ) |
|
998 acclevel = StringLoader::LoadLC( R_EVTUI_ACCURACYLEVEL_LOW ); |
|
999 |
|
1000 // Get the Accuracy String |
|
1001 GetAccuracyStringL( accuracy, accString ); |
|
1002 CleanupStack::PushL( accString ); |
|
1003 |
|
1004 HBufC* infoMsg = HBufC::NewLC( acclevel->Length() + KNewLine().Length() + accString->Length() ); |
|
1005 TPtr ptrMsg = infoMsg->Des(); |
|
1006 ptrMsg.Copy( *acclevel ); |
|
1007 ptrMsg.Append( KNewLine ); |
|
1008 ptrMsg.Append( *accString ); |
|
1009 CAknInformationNote* infoNote = new(ELeave) CAknInformationNote( ETrue ); |
|
1010 infoNote->ExecuteLD( *infoMsg ); |
|
1011 CleanupStack::PopAndDestroy(3); //infoMsg, accString, acclevel |
|
1012 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL()" ); |
|
1013 } |
|
1014 |
|
1015 |
|
1016 // --------------------------------------------------------- |
|
1017 // CEvtMgmtUiPlaceComponent::ResolveErrorL |
|
1018 // Resolves the Error code |
|
1019 // --------------------------------------------------------- |
|
1020 // |
|
1021 void CEvtMgmtUiPlaceComponent::ResolveErrorL( TInt aErrorCode ) |
|
1022 { |
|
1023 TPtrC buf; |
|
1024 CTextResolver* textResolver = CTextResolver::NewLC( *(CEikonEnv::Static()) ); |
|
1025 buf.Set(textResolver->ResolveErrorString(aErrorCode)); |
|
1026 |
|
1027 CAknErrorNote* dialog = |
|
1028 new(ELeave)CAknErrorNote(ETrue); |
|
1029 dialog->SetTone(CAknNoteDialog::EErrorTone); |
|
1030 dialog->ExecuteLD( buf ); |
|
1031 |
|
1032 CleanupStack::PopAndDestroy( textResolver ); |
|
1033 } |
|
1034 |
|
1035 // --------------------------------------------------------- |
|
1036 // CEvtMgmtUiPlaceComponent::DisplayAccuracyNoteL |
|
1037 // It is used to provide Accuracy String based on current |
|
1038 // System of Measurement Settings |
|
1039 // --------------------------------------------------------- |
|
1040 // |
|
1041 void CEvtMgmtUiPlaceComponent::GetAccuracyStringL( TReal& aAccuracy, HBufC*& aAccuracyString ) |
|
1042 { |
|
1043 EVTUIDEBUG("+ CEvtMgmtUiPlaceComponent::GetAccuracyStringL()" ); |
|
1044 TInt settingsValue = 0; |
|
1045 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidLocNotationPref) ); |
|
1046 CleanupStack::PushL( repository ); |
|
1047 User::LeaveIfError( repository->Get( KLocSystemofMeasurements, |
|
1048 settingsValue )); |
|
1049 CleanupStack::PopAndDestroy( repository ); |
|
1050 |
|
1051 aAccuracy = aAccuracy/KMToKMConversion; |
|
1052 |
|
1053 switch( static_cast<TLocSystemofMeasurementValues>( settingsValue ) ) |
|
1054 { |
|
1055 case ELocImperial: // mile |
|
1056 { |
|
1057 aAccuracy *= KUnitConversion; |
|
1058 TReal approxAccuracy; |
|
1059 TBuf<8> accuracyString; |
|
1060 Math::Round( approxAccuracy, aAccuracy, 2 ); |
|
1061 accuracyString.Format(KFloatAccuracyFormat, approxAccuracy); |
|
1062 aAccuracyString = StringLoader::LoadL( R_LOCEV_NOTE_TXT_ACC_MILES, accuracyString, CEikonEnv::Static() ); |
|
1063 break; |
|
1064 } |
|
1065 case ELocMetric: // metric |
|
1066 { |
|
1067 TReal approxAccuracy; |
|
1068 TBuf<8> accuracyString; |
|
1069 Math::Round( approxAccuracy, aAccuracy, 2 ); |
|
1070 accuracyString.Format(KFloatAccuracyFormat, approxAccuracy); |
|
1071 aAccuracyString = StringLoader::LoadL( R_LOCEV_NOTE_TXT_ACC_KM, accuracyString, CEikonEnv::Static() ); |
|
1072 } |
|
1073 break; |
|
1074 default: |
|
1075 break; |
|
1076 } |
|
1077 EVTUIDEBUG("- CEvtMgmtUiPlaceComponent::GetAccuracyStringL()" ); |
|
1078 } |
|
1079 //end of file |