|
1 /* |
|
2 * Copyright (c) 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: Provides Blid main view class methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <aknlists.h> |
|
20 #include <AknQueryDialog.h> |
|
21 #include <StringLoader.h> |
|
22 #include <eikmenub.h> // CEikMenuBar |
|
23 #include <Blid.rsg> |
|
24 #include <EPos_CPosLandmarkDatabase.h> |
|
25 #include <EPos_CPosLmItemIterator.h> |
|
26 #include <e32std.h> |
|
27 #include <CLmkEditorDlg.h> |
|
28 #include <TLmkItemIdDbCombiInfo.h> |
|
29 #include <alf/alfimageloaderutil.h> |
|
30 |
|
31 #include "CBlidBaseView.h" |
|
32 #include "CBlidAppUi.h" |
|
33 #include "CBlidBaseContainer.h" |
|
34 #include "MBlidRouter.h" |
|
35 #include "MBlidSettings.h" |
|
36 #include "MBlidLocation.h" |
|
37 #include "CBlidEng.h" |
|
38 #include "CBlidDocument.h" |
|
39 #include "Blid.hrh" |
|
40 #include "bliduiconsts.h" |
|
41 #include "CBlidCurrentPositionDlg.h" |
|
42 |
|
43 #include <locationvariationdomaincrkeys.h> |
|
44 #include <centralrepository.h> |
|
45 |
|
46 enum TPanicCode |
|
47 { |
|
48 KBlidNullPointer = 1 |
|
49 }; |
|
50 |
|
51 // Start with the assumption that PSY is not connected |
|
52 TInt CBlidBaseView::iPSYTimeoutCount = 0; |
|
53 TBool CBlidBaseView::iOnline = EFalse; |
|
54 |
|
55 const TInt KMiddleSKId = 3; |
|
56 |
|
57 |
|
58 // ================= MEMBER FUNCTIONS ======================= |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // CBlidBaseView::CBlidBaseView |
|
62 // First phase constructor, should not leave |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 CBlidBaseView::CBlidBaseView( MKeyProcessor& aKeyProcessor ) |
|
66 : iKeyProcessor(aKeyProcessor) |
|
67 { |
|
68 StringLoader::Load( iManualWaypointName, R_BLID_DESTINATION_COORDINATES, iCoeEnv ); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // CBlidBaseView::BaseConstructL |
|
73 // Symbian 2nd phase constructor can leave. |
|
74 // --------------------------------------------------------- |
|
75 // |
|
76 void CBlidBaseView::BaseConstructL( TInt aResId ) |
|
77 { |
|
78 FeatureManager::InitializeLibL(); |
|
79 CAknView::BaseConstructL( aResId ); |
|
80 |
|
81 iEngine = static_cast<CBlidDocument*>(AppUi()->Document())->Engine(); |
|
82 |
|
83 if( !iEngine->LocationModel() ) |
|
84 { |
|
85 iEngine->CreateModelL( CBlidEng::EBlidLocation ); |
|
86 } |
|
87 iLocation = iEngine->LocationModel(); |
|
88 __ASSERT_DEBUG( iLocation, User::Panic(_L("CBlidOwnPosView"), |
|
89 KBlidNullPointer)); |
|
90 |
|
91 iRouter = iEngine->RouterModel(); |
|
92 |
|
93 iImageLoaderUtil = new (ELeave) CAlfImageLoaderUtil(); |
|
94 |
|
95 iConFileName.Zero(); |
|
96 iConFileName.Append( _L("z") ); |
|
97 iConFileName.Append( KBlidSystemIconPath ); |
|
98 |
|
99 iIsSettingsViewActive = EFalse; |
|
100 |
|
101 __ASSERT_DEBUG( iRouter, User::Panic(_L("CBlidOwnPosView"), |
|
102 KBlidNullPointer)); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CBlidBaseView::~CLocBaseView() |
|
107 // Destructor, frees allocated resources |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 CBlidBaseView::~CBlidBaseView() |
|
111 { |
|
112 FeatureManager::UnInitializeLib(); |
|
113 delete iImageLoaderUtil; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------- |
|
117 // CBlidBaseView::ProcessKeyEventL |
|
118 // Processes the key event |
|
119 // --------------------------------------------------------- |
|
120 // |
|
121 TBool CBlidBaseView::ProcessKeyEventL( const TKeyEvent& aKeyEvent, |
|
122 TEventCode aType ) |
|
123 { |
|
124 return iKeyProcessor.ProcessKeyEventL( aKeyEvent, aType ); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------- |
|
128 // CBlidBaseView::TabObserver() |
|
129 // Returns the tab observer |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 MAknTabObserver* CBlidBaseView::TabObserver() |
|
133 { |
|
134 return iKeyProcessor.TabObserver(); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------- |
|
138 // CBlidBaseView::DynInitMenuPaneL |
|
139 // Called to initialize the menu pane at run time |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CBlidBaseView::DynInitMenuPaneL( |
|
143 TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
144 { |
|
145 #ifdef _DEBUG |
|
146 RDebug::Print(_L("CBlidCompassView::DynInitMenuPaneL() called")); |
|
147 #endif |
|
148 switch( aResourceId ) |
|
149 { |
|
150 case R_BLID_VIEW_MENU: |
|
151 { |
|
152 if ( !(iLocation->IsGPSDataAvailable() && |
|
153 iLocation->SatelliteCapability()) ) |
|
154 { |
|
155 aMenuPane->SetItemDimmed( EBlidCmdSatelliteStatus, ETrue ); |
|
156 } |
|
157 if ( (!iRouter->Count()) || FeatureManager::FeatureSupported( KFeatureIdLandmarks ) ) |
|
158 { |
|
159 aMenuPane->SetItemDimmed( EBlidCmdSavedWaypoints, ETrue ); |
|
160 } |
|
161 |
|
162 // hide the save position. |
|
163 if(!iLocation->IsOnline()) |
|
164 { |
|
165 aMenuPane->SetItemDimmed( EBlidCmdCurrentLocation, ETrue ); |
|
166 } |
|
167 |
|
168 |
|
169 |
|
170 } |
|
171 //-fallthrough |
|
172 case R_BLID_VIEW_OK_MENU: |
|
173 { |
|
174 if ( !iRouter->IsAnyPointSet() ) |
|
175 { |
|
176 aMenuPane->SetItemDimmed( EBlidCmdStopNavigation, ETrue ); |
|
177 } |
|
178 break; |
|
179 } |
|
180 case R_BLID_MAIN_MENU: |
|
181 { |
|
182 CBlidBaseView::HandleHelpFeature( aMenuPane ); |
|
183 break; |
|
184 } |
|
185 |
|
186 case R_BLID_SET_DESTINATION_MENU: |
|
187 { |
|
188 if ( iRouter->Count() <= 0 ) |
|
189 { |
|
190 aMenuPane->SetItemDimmed( EBlidCmdWaypoint, ETrue ); |
|
191 } |
|
192 else |
|
193 { |
|
194 aMenuPane->SetItemDimmed( EBlidCmdWaypoint, EFalse ); |
|
195 } |
|
196 |
|
197 // Features manager checks for waypoint/landmarks variation |
|
198 if ( FeatureManager::FeatureSupported( KFeatureIdLandmarks ) ) |
|
199 { |
|
200 aMenuPane->SetItemDimmed( EBlidCmdWaypoint, ETrue ); |
|
201 } |
|
202 else |
|
203 { |
|
204 aMenuPane->SetItemDimmed( EBlidCmdLmk, ETrue ); |
|
205 } |
|
206 |
|
207 if ( FeatureManager::FeatureSupported( KFeatureIdLandmarks ) ) |
|
208 { |
|
209 if( IsLmAvailableL() ) |
|
210 { |
|
211 aMenuPane->SetItemDimmed( EBlidCmdLmk, EFalse ); |
|
212 } |
|
213 else |
|
214 { |
|
215 aMenuPane->SetItemDimmed( EBlidCmdLmk, ETrue ); |
|
216 } |
|
217 } |
|
218 break; |
|
219 |
|
220 } |
|
221 case R_BLID_SAVE_CURRENT_LOCATION_MENU: |
|
222 { |
|
223 TInt settingsValue = 0; |
|
224 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidLocLocalVariation) ); |
|
225 CleanupStack::PushL( repository ); |
|
226 User::LeaveIfError( repository->Get( KLocHideCoordinates, |
|
227 settingsValue )); |
|
228 CleanupStack::PopAndDestroy( repository ); |
|
229 |
|
230 if ( ELocCoordinatesHidden == settingsValue ) |
|
231 { |
|
232 aMenuPane->SetItemDimmed( EBlidCmdShowDetails, ETrue ); |
|
233 } |
|
234 else |
|
235 { |
|
236 aMenuPane->SetItemDimmed( EBlidCmdShowDetails, EFalse ); |
|
237 } |
|
238 |
|
239 break; |
|
240 } |
|
241 default: |
|
242 { |
|
243 break; |
|
244 } |
|
245 } |
|
246 } |
|
247 |
|
248 // ---------------------------------------------------------------------------- |
|
249 // CBlidBaseView::NotifyL |
|
250 // Called by location model to notify about updates in location |
|
251 // ---------------------------------------------------------------------------- |
|
252 // |
|
253 void CBlidBaseView::NotifyL( const TBool /*aOnlineMode*/ ) |
|
254 { |
|
255 if( iPopupDialog ) |
|
256 { |
|
257 iPopupDialog->ChangeDlgSoftKey(); |
|
258 } |
|
259 // GPS available |
|
260 CBlidBaseContainer::SetGPSAvailability(ETrue); |
|
261 } |
|
262 |
|
263 // ---------------------------------------------------------------------------- |
|
264 // CBlidBaseView::NotifyError |
|
265 // Called by location model to notify about error in location |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 void CBlidBaseView::NotifyErrorL( TInt /*aErrorCode*/ ) |
|
269 { |
|
270 if( iPopupDialog ) |
|
271 { |
|
272 iPopupDialog->ChangeDlgSoftKey(); |
|
273 } |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------- |
|
277 // CBlidBaseView::HandleHelpFeature |
|
278 // Handles the Help option command |
|
279 // --------------------------------------------------------- |
|
280 // |
|
281 void CBlidBaseView::HandleHelpFeature( CEikMenuPane* aMenuPane ) const |
|
282 { |
|
283 //implementation for req 406-917. Hide position view based on feature variation flag |
|
284 TInt helpSettingValue = ELocHelpNotHidden; |
|
285 CRepository* repository = CRepository::NewL( TUid::Uid( KCRUidLocLocalVariation) ); |
|
286 CleanupStack::PushL( repository ); |
|
287 User::LeaveIfError( repository->Get( KLocHideHelp, |
|
288 helpSettingValue )); |
|
289 CleanupStack::PopAndDestroy( repository ); |
|
290 |
|
291 |
|
292 if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) && !helpSettingValue) |
|
293 { |
|
294 aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse ); |
|
295 } |
|
296 else |
|
297 { |
|
298 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
299 } |
|
300 } |
|
301 |
|
302 // ---------------------------------------------------------------------------- |
|
303 // CBlidBaseView::InsertWaypointL |
|
304 // Insers a waypoint |
|
305 // ---------------------------------------------------------------------------- |
|
306 // |
|
307 TBool CBlidBaseView::InsertWaypointL() |
|
308 { |
|
309 TInt index(KErrCancel); |
|
310 TBuf<KBlidWaypointNameMaxLen> textData; |
|
311 StringLoader::Load( textData, R_BLID_WAYPOINT_NAME, iCoeEnv ); |
|
312 TInt errorCode(KErrNone); |
|
313 TBool returnValue(ETrue); |
|
314 TInt removedIndex; |
|
315 |
|
316 do |
|
317 { |
|
318 if(errorCode != KErrNone) |
|
319 { |
|
320 return EFalse; |
|
321 } |
|
322 |
|
323 CAknTextQueryDialog* dlg = new(ELeave) CAknTextQueryDialog(textData, |
|
324 CAknQueryDialog::ENoTone); |
|
325 |
|
326 if (!dlg->ExecuteLD(R_BLID_WAYPOINT_QUERY)) |
|
327 { |
|
328 return EFalse; |
|
329 } |
|
330 |
|
331 }while( CheckIfExistL( textData, errorCode, removedIndex ) ); |
|
332 |
|
333 if(errorCode != KErrNone) |
|
334 { |
|
335 return EFalse; |
|
336 } |
|
337 |
|
338 /// if KMaxNumberOfWaypoints or more than that is already present |
|
339 /// display note. |
|
340 if ( iRouter->Count() >= KMaxNumberOfWaypoints ) |
|
341 { |
|
342 static_cast<CBlidAppUi*>(AppUi() |
|
343 )->ShowDialogL( BlidNotes::EBlidOverWriteWaypointNote ); |
|
344 return EFalse; |
|
345 } |
|
346 |
|
347 TInt retVal(KErrNone); |
|
348 if ( index >=0 ) |
|
349 { |
|
350 if ( iRouter->IndexOfWaypoint() >=0 && |
|
351 index >= iRouter->IndexOfWaypoint() ) |
|
352 { |
|
353 index++; |
|
354 } |
|
355 retVal = iRouter->RemoveL( index ); |
|
356 if(retVal == KErrDiskFull) |
|
357 { |
|
358 BlidNotes::OutOfMemoryNoteL(); |
|
359 } |
|
360 } |
|
361 |
|
362 if(retVal == KErrNone) |
|
363 { |
|
364 TNamedCoordinate* waypoint = new(ELeave)TNamedCoordinate(); |
|
365 CleanupStack::PushL( waypoint ); |
|
366 waypoint->SetName( textData ); |
|
367 TPosition position = iLocation->GetCurrentPosition(); |
|
368 waypoint->SetCoordinate( position.Latitude(), |
|
369 position.Longitude(), |
|
370 position.Altitude() ); |
|
371 position.SetHorizontalAccuracy(position.HorizontalAccuracy()); |
|
372 waypoint->SetAccuracy(position.HorizontalAccuracy()); |
|
373 //iRouter takes waypoint's ownership |
|
374 TInt retVal = iRouter->AppendL( waypoint, ETrue); |
|
375 if(retVal == KErrDiskFull) |
|
376 { |
|
377 delete waypoint; |
|
378 BlidNotes::OutOfMemoryNoteL(); |
|
379 returnValue = EFalse; |
|
380 } |
|
381 CleanupStack::Pop(); //waypoint |
|
382 } |
|
383 return returnValue; |
|
384 } |
|
385 |
|
386 // ---------------------------------------------------------------------------- |
|
387 // CBlidBaseView::SelectWaypoint |
|
388 // Select a waypoint |
|
389 // ---------------------------------------------------------------------------- |
|
390 // |
|
391 TInt CBlidBaseView::SelectWaypointL() |
|
392 { |
|
393 TInt index(KErrCancel); |
|
394 TInt currentIndex(0); |
|
395 CEikFormattedCellListBox* listBox = |
|
396 new(ELeave)CAknSinglePopupMenuStyleListBox; |
|
397 CleanupStack::PushL( listBox ); |
|
398 |
|
399 HBufC* name = NULL; |
|
400 TInt count( iRouter->Count() ); |
|
401 TNamedCoordinate* waypoint = iRouter->Waypoint(); |
|
402 |
|
403 CDesCArray* array = new(ELeave)CDesCArrayFlat(KMaxNumberOfWaypoints); |
|
404 CleanupStack::PushL( array ); |
|
405 |
|
406 TInt waypointAdditionCount = 0; |
|
407 // fill up the array with waypoint's names from the engine. |
|
408 for ( TInt i = 0; i < count; i++ ) |
|
409 { |
|
410 name = iRouter->At(i).Name(); |
|
411 if ( name ) |
|
412 { |
|
413 CleanupStack::PushL( name ); |
|
414 array->AppendL( *name ); |
|
415 waypointAdditionCount ++; |
|
416 CleanupStack::PopAndDestroy(name); //name |
|
417 } |
|
418 else |
|
419 { |
|
420 currentIndex = i; |
|
421 } |
|
422 } |
|
423 |
|
424 |
|
425 CAknPopupList* popupList = CAknPopupList::NewL( listBox, |
|
426 R_AVKON_SOFTKEYS_OK_CANCEL, |
|
427 AknPopupLayouts::EPopupSNotePopupWindow); |
|
428 CleanupStack::PushL(popupList); |
|
429 |
|
430 HBufC* title = iCoeEnv->AllocReadResourceLC( R_BLID_QUERY_WAYPOINT ); |
|
431 popupList->SetTitleL( *title ); |
|
432 CleanupStack::PopAndDestroy(title); //title |
|
433 title = NULL; |
|
434 |
|
435 listBox->ConstructL( popupList, |
|
436 EAknListBoxSelectionList | EAknListBoxLoopScrolling); |
|
437 |
|
438 listBox->CreateScrollBarFrameL(ETrue); |
|
439 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
440 CEikScrollBarFrame::EAuto, |
|
441 CEikScrollBarFrame::EAuto); |
|
442 |
|
443 //listbox's model take ownership of array |
|
444 listBox->Model()->SetItemTextArray(array); |
|
445 |
|
446 CleanupStack::Pop(popupList); // popupList |
|
447 CleanupStack::Pop(array); //array |
|
448 TBool isEmpty = array->Count() == 0; |
|
449 |
|
450 if ( popupList->ExecuteLD() ) |
|
451 { |
|
452 index = listBox->CurrentItemIndex(); |
|
453 } |
|
454 CleanupStack::PopAndDestroy(listBox); //listBox |
|
455 |
|
456 if(isEmpty) |
|
457 { |
|
458 return KErrCancel; |
|
459 } |
|
460 |
|
461 if(waypoint && waypointAdditionCount != iRouter->Count()) |
|
462 { |
|
463 if(index >= currentIndex) |
|
464 { |
|
465 index += 1; |
|
466 } |
|
467 } |
|
468 if ( index != KErrCancel ) |
|
469 { |
|
470 TNamedCoordinate waypoint = iRouter->At(index); |
|
471 if(waypoint.Accuracy() >= KBlidPoorAccuracy) |
|
472 { |
|
473 HBufC* noteText = StringLoader::LoadLC( R_BLID_CONF_DEST_INACCURATE , iCoeEnv ); |
|
474 CAknQueryDialog* dlg = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone); |
|
475 if(dlg->ExecuteLD(R_BLID_CONFIRMATION_QUERY, *noteText)) |
|
476 { |
|
477 CleanupStack::PopAndDestroy( noteText ); |
|
478 return index; |
|
479 } |
|
480 else |
|
481 { |
|
482 CleanupStack::PopAndDestroy( noteText ); |
|
483 return KErrCancel; |
|
484 } |
|
485 } |
|
486 } |
|
487 return index; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------- |
|
491 // CBlidBaseView::CheckIfExist |
|
492 // Checks if a waypoint exists |
|
493 // --------------------------------------------------------- |
|
494 // |
|
495 TBool CBlidBaseView::CheckIfExistL( const TDes& aName, TInt& aErrorCode, TInt& aRemovedIndex ) |
|
496 { |
|
497 TInt i(0); |
|
498 TInt count( iRouter->Count() ); |
|
499 HBufC* name = NULL; |
|
500 TBool retVal; |
|
501 aRemovedIndex = KErrNotFound; |
|
502 |
|
503 for ( i = 0; i < count; i++ ) |
|
504 { |
|
505 name = iRouter->At( i ).Name(); |
|
506 if ( name && name->Compare( aName ) == 0 ) |
|
507 { |
|
508 CleanupStack::PushL(name); |
|
509 HBufC* text; |
|
510 text = StringLoader::LoadLC(R_BLID_QUERY_WAYPOINT_NAME_EXISTS, |
|
511 *name, |
|
512 iCoeEnv); |
|
513 |
|
514 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
515 CleanupStack::PushL(dlg); |
|
516 dlg->SetPromptL( *text ); |
|
517 CleanupStack::Pop( dlg ); |
|
518 retVal = dlg->ExecuteLD(R_BLID_CONFIRMATION_QUERY); |
|
519 |
|
520 if(retVal) |
|
521 { |
|
522 TInt retVal = iRouter->RemoveL(i); |
|
523 aRemovedIndex = i; |
|
524 if(retVal == KErrDiskFull) |
|
525 { |
|
526 aErrorCode = KErrDiskFull; |
|
527 BlidNotes::OutOfMemoryNoteL(); |
|
528 } |
|
529 } |
|
530 CleanupStack::PopAndDestroy(2); //name and text |
|
531 return !retVal; |
|
532 } |
|
533 delete name; |
|
534 name = NULL; |
|
535 } |
|
536 return EFalse; |
|
537 } |
|
538 |
|
539 // ---------------------------------------------------- |
|
540 // CBlidBaseView::LaunchLandmarksDialogL |
|
541 // Launch the landmarks dialog |
|
542 // ---------------------------------------------------- |
|
543 // |
|
544 TInt CBlidBaseView::LaunchLandmarksDialogL() |
|
545 { |
|
546 CPosLandmarkDatabase* lDb = NULL; |
|
547 TPosLmItemId selectedItem; |
|
548 iLandmarkInfo = CLmkLandmarkSelectorDlg::NewL(); |
|
549 iLandmarkInfo->SetMopParent(this); |
|
550 TLmkItemIdDbCombiInfo* selected = new (ELeave) TLmkItemIdDbCombiInfo(); |
|
551 CleanupStack::PushL(selected); |
|
552 TInt retVal = iLandmarkInfo->ExecuteLD( *selected ); |
|
553 if( retVal != KErrNone ) |
|
554 { |
|
555 selectedItem = selected->GetItemId(); |
|
556 lDb = selected->GetLmDb(); |
|
557 if(lDb) |
|
558 { |
|
559 CleanupStack::PushL( lDb ); |
|
560 CPosLandmark *landmarkInfo = lDb->ReadLandmarkLC(selectedItem); |
|
561 CleanupStack::PushL( landmarkInfo ); |
|
562 CPosLandmark* landMark = CPosLandmark::NewL(*landmarkInfo); |
|
563 CleanupStack::Pop( landmarkInfo ); |
|
564 TLocality lmkPosition; |
|
565 TInt error = landMark->GetPosition(lmkPosition); |
|
566 if( Math::IsNaN(lmkPosition.Latitude()) || |
|
567 Math::IsNaN(lmkPosition.Longitude()) ) |
|
568 { |
|
569 TPtrC landmarkname; |
|
570 landMark->GetLandmarkName(landmarkname); |
|
571 // Fix done for TSW error EPZO-75PBW8 |
|
572 HBufC* lmkName = NULL; |
|
573 lmkName = HBufC::NewL( landmarkname.Length() ); |
|
574 lmkName->Des().Copy( landmarkname ); |
|
575 TPtr lmkActualName( lmkName->Des() ); |
|
576 TBuf<1> charsToRemove; |
|
577 charsToRemove.Append(TChar(TInt(CEditableText::EParagraphDelimiter))); |
|
578 AknTextUtils::ReplaceCharacters( lmkActualName, charsToRemove, TChar(TInt(CEditableText::ESpace))); |
|
579 BlidNotes::EmptyLandmarkNoteL( *lmkName ); |
|
580 delete lmkName; |
|
581 // end of error fix. |
|
582 delete landMark; |
|
583 retVal = 0; |
|
584 } |
|
585 else |
|
586 { |
|
587 TLocality lmkPosition; |
|
588 landMark->GetPosition(lmkPosition); |
|
589 TReal accuracy = lmkPosition.HorizontalAccuracy(); |
|
590 if(accuracy >= KBlidPoorAccuracy) |
|
591 { |
|
592 HBufC* noteText = StringLoader::LoadLC( R_BLID_CONF_DEST_INACCURATE , iCoeEnv ); |
|
593 CAknQueryDialog* dlg = CAknQueryDialog::NewL(CAknQueryDialog::ENoTone); |
|
594 if(dlg->ExecuteLD(R_BLID_CONFIRMATION_QUERY, *noteText)) |
|
595 { |
|
596 iRouter->SetLandmark(landMark); |
|
597 } |
|
598 else |
|
599 { |
|
600 delete landMark; |
|
601 } |
|
602 CleanupStack::PopAndDestroy(noteText); |
|
603 } |
|
604 else |
|
605 { |
|
606 iRouter->SetLandmark(landMark); |
|
607 } |
|
608 |
|
609 } |
|
610 CleanupStack::PopAndDestroy(1); // ReadLandmarkLC |
|
611 landMark = NULL; |
|
612 landmarkInfo = NULL; |
|
613 CleanupStack::PopAndDestroy( lDb ); |
|
614 } |
|
615 } |
|
616 CleanupStack::Pop(1); //selectedItem |
|
617 iLandmarkInfo = NULL; |
|
618 delete selected; |
|
619 return retVal; |
|
620 } |
|
621 |
|
622 // ---------------------------------------------------------------------------- |
|
623 // CBlidBaseView::SaveCurrentPositionAsLandmarkL |
|
624 // Called to save the current location as a landmark in landmark database |
|
625 // ---------------------------------------------------------------------------- |
|
626 // |
|
627 void CBlidBaseView::SaveCurrentPositionAsLandmarkL() |
|
628 { |
|
629 CLmkEditorDlg::TLmkEditorParams editParams; |
|
630 editParams.iAttributes = CLmkEditorDlg::ELmkAll; |
|
631 editParams.iEditorMode = CLmkEditorDlg::ELmkEditor; |
|
632 |
|
633 TPosition position = iLocation->GetCurrentPosition(); |
|
634 |
|
635 CPosLandmark* landmark = CPosLandmark::NewLC(); |
|
636 TLocality location; |
|
637 location.SetCoordinate(position.Latitude(), |
|
638 position.Longitude(), |
|
639 position.Altitude()); |
|
640 location.SetHorizontalAccuracy(position.HorizontalAccuracy()); |
|
641 location.SetVerticalAccuracy(position.VerticalAccuracy()); |
|
642 |
|
643 landmark->SetPositionL(location); |
|
644 CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL(); |
|
645 CleanupStack::PushL(db); |
|
646 |
|
647 CPosLmOperation* operation = db->InitializeL(); |
|
648 CleanupStack::PushL(operation); |
|
649 operation->ExecuteL(); |
|
650 CLmkEditorDlg *dlg = CLmkEditorDlg::NewL(*db, |
|
651 *landmark, |
|
652 editParams); |
|
653 dlg->ExecuteLD(); |
|
654 CleanupStack::PopAndDestroy(3); // landmark, operation and db |
|
655 } |
|
656 |
|
657 // ---------------------------------------------------------------------------- |
|
658 // CBlidBaseView::LaunchManualWaypointDialogL |
|
659 // Launches the manual waypoint dialog |
|
660 // ---------------------------------------------------------------------------- |
|
661 // |
|
662 TInt CBlidBaseView::LaunchManualWaypointDialogL() |
|
663 { |
|
664 TInt retVal; |
|
665 TCoordinate coord(0,0); |
|
666 TLocality loc(coord,0); |
|
667 TTime time; |
|
668 time.HomeTime(); |
|
669 TPosition pos(loc, time); |
|
670 |
|
671 CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(pos); |
|
672 retVal = dlg->ExecuteLD(R_BLID_MANUAL_LOCATION_QUERY_DIALOG); |
|
673 if( retVal ) |
|
674 { |
|
675 iRouter->SetManualWaypoint(pos.Latitude(), pos.Longitude(), iManualWaypointName); |
|
676 } |
|
677 return retVal; |
|
678 } |
|
679 |
|
680 // ---------------------------------------------------------------------------- |
|
681 // CBlidBaseView::Update |
|
682 // ---------------------------------------------------------------------------- |
|
683 // |
|
684 void CBlidBaseView::Update(CBlidBaseContainer* aContainer) |
|
685 { |
|
686 aContainer->SetRect(ClientRect()); |
|
687 aContainer->DrawNow(); |
|
688 } |
|
689 |
|
690 // ---------------------------------------------------------------------------- |
|
691 // CBlidBaseView::CBAPtr |
|
692 // Returns the current CBA |
|
693 // ---------------------------------------------------------------------------- |
|
694 // |
|
695 CEikButtonGroupContainer* CBlidBaseView::CBAPtr() const |
|
696 { |
|
697 return (Cba()); |
|
698 } |
|
699 |
|
700 // ---------------------------------------------------------------------------- |
|
701 // CBlidBaseView::SetMiddleSoftKeyLabelL |
|
702 // Sets the Middle Soft Key label. |
|
703 // ---------------------------------------------------------------------------- |
|
704 // |
|
705 void CBlidBaseView::SetMiddleSoftKeyLabelL( |
|
706 const TInt aResourceId, |
|
707 const TInt aCommandId ) |
|
708 { |
|
709 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
710 if ( cbaGroup ) |
|
711 { |
|
712 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
713 cbaGroup->AddCommandToStackL(KMiddleSKId, |
|
714 aCommandId, |
|
715 *middleSKText ); |
|
716 CleanupStack::PopAndDestroy( middleSKText ); |
|
717 } |
|
718 } |
|
719 |
|
720 // ---------------------------------------------------------------------------- |
|
721 // CBlidBaseView::RemoveMiddleSoftKeyLabel |
|
722 // Remove the Middle Soft Key label. |
|
723 // ---------------------------------------------------------------------------- |
|
724 // |
|
725 void CBlidBaseView::RemoveMiddleSoftKeyLabel( const TInt aCommandId ) |
|
726 { |
|
727 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
728 if ( cbaGroup ) |
|
729 { |
|
730 cbaGroup->RemoveCommandFromStack(KMiddleSKId, |
|
731 aCommandId ); |
|
732 } |
|
733 } |
|
734 |
|
735 // ---------------------------------------------------------------------------- |
|
736 // CBlidBaseView::SetMSKDimmed |
|
737 // Sets the Middle Soft Key as not visible. |
|
738 // ---------------------------------------------------------------------------- |
|
739 // |
|
740 void CBlidBaseView::SetMSKNotVisible() |
|
741 { |
|
742 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
743 if ( cbaGroup ) |
|
744 { |
|
745 cbaGroup->MakeCommandVisible(EAknSoftkeyContextOptions, EFalse); |
|
746 iMSKVisible = EFalse; |
|
747 } |
|
748 } |
|
749 |
|
750 // ---------------------------------------------------------------------------- |
|
751 // CBlidBaseView::SetMSKVisible |
|
752 // Sets the Middle Soft Key as visible. |
|
753 // ---------------------------------------------------------------------------- |
|
754 // |
|
755 void CBlidBaseView::SetMSKVisible() |
|
756 { |
|
757 CEikButtonGroupContainer* cbaGroup = Cba(); |
|
758 if ( cbaGroup ) |
|
759 { |
|
760 cbaGroup->MakeCommandVisible(EAknSoftkeyContextOptions, ETrue); |
|
761 iMSKVisible = ETrue; |
|
762 } |
|
763 } |
|
764 |
|
765 // ---------------------------------------------------------------------------- |
|
766 // CBlidBaseView::UpdateMskStateL |
|
767 // Update Middle Soft Key label/Icon. |
|
768 // ---------------------------------------------------------------------------- |
|
769 // |
|
770 void CBlidBaseView::UpdateMskStateL() |
|
771 { |
|
772 if (!iLocation->IsGPSDataAvailable()) |
|
773 { |
|
774 SetMSKNotVisible(); |
|
775 } |
|
776 else |
|
777 { |
|
778 if(!iMSKVisible) |
|
779 { |
|
780 SetMSKVisible(); |
|
781 MenuBar()->SetContextMenuTitleResourceId( |
|
782 R_BLID_OWN_POS_VIEW_OK_MENUBAR); |
|
783 } |
|
784 } |
|
785 } |
|
786 |
|
787 #ifdef RD_SCALABLE_UI_V2 |
|
788 // --------------------------------------------------------------------------- |
|
789 // CBlidBaseView::HandleListBoxEventL |
|
790 // Handles listbox item selection |
|
791 // --------------------------------------------------------------------------- |
|
792 // |
|
793 void CBlidBaseView::HandleListBoxEventL( |
|
794 CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
795 { |
|
796 switch ( aEventType ) |
|
797 { |
|
798 case EEventEnterKeyPressed: |
|
799 case EEventItemSingleClicked: |
|
800 HandleListBoxSelectionL(); |
|
801 break; |
|
802 default: |
|
803 break; |
|
804 } |
|
805 } |
|
806 |
|
807 #endif //RD_SCALABLE_UI_V2 |
|
808 // --------------------------------------------------------------------------- |
|
809 // CBlidBaseView::IsLmFeatureAvailable |
|
810 // Checks if Landmarks feature i available |
|
811 // --------------------------------------------------------------------------- |
|
812 // |
|
813 TBool CBlidBaseView::IsLmFeatureAvailable() |
|
814 { |
|
815 return FeatureManager::FeatureSupported( KFeatureIdLandmarks ); |
|
816 } |
|
817 |
|
818 // --------------------------------------------------------------------------- |
|
819 // CBlidBaseView::IsLmAvailableL |
|
820 // Checks if there are any landmarks in the default database |
|
821 // --------------------------------------------------------------------------- |
|
822 // |
|
823 TBool CBlidBaseView::IsLmAvailableL() |
|
824 { |
|
825 TBool lResult = ETrue; |
|
826 // Check if there are any landmarks present. If not the |
|
827 // dim the landmark item from the set destination menu pane |
|
828 CPosLandmarkDatabase* lmkDb; |
|
829 lmkDb = CPosLandmarkDatabase::OpenL(); |
|
830 CleanupStack::PushL(lmkDb); |
|
831 // Initialize Landmarks data base if required |
|
832 CPosLmOperation* operation = lmkDb->InitializeL(); |
|
833 CleanupStack::PushL(operation); |
|
834 operation->ExecuteL(); |
|
835 CPosLmItemIterator* iterator = lmkDb->LandmarkIteratorL(); |
|
836 CleanupStack::PushL(iterator); |
|
837 |
|
838 if( iterator->NumOfItemsL() == 0 ) |
|
839 { |
|
840 lResult = EFalse; |
|
841 } |
|
842 else |
|
843 { |
|
844 lResult = ETrue; |
|
845 } |
|
846 CleanupStack::PopAndDestroy(3); //lmkDb, iterator and operation |
|
847 return lResult; |
|
848 } |
|
849 |
|
850 // --------------------------------------------------------------------------- |
|
851 // CBlidBaseView::IsWpAvailable |
|
852 // Checks if waypoints are available |
|
853 // --------------------------------------------------------------------------- |
|
854 // |
|
855 TBool CBlidBaseView::IsWpAvailable() |
|
856 { |
|
857 if ( iRouter->Count() <= 0 ) |
|
858 { |
|
859 return EFalse; |
|
860 } |
|
861 return ETrue; |
|
862 } |
|
863 |
|
864 |
|
865 // ---------------------------------------------------------------------------- |
|
866 // CBlidBaseView::ActivateCorrectViewL |
|
867 // Activates the view |
|
868 // ---------------------------------------------------------------------------- |
|
869 // |
|
870 void CBlidBaseView::ActivateCorrectViewL( TInt aIndex ) |
|
871 { |
|
872 switch( aIndex ) |
|
873 { |
|
874 case EBlidNavigationViewId: |
|
875 { |
|
876 AppUi()->ActivateLocalViewL( TUid::Uid( EBlidNavigationView ) ); |
|
877 break; |
|
878 } |
|
879 case EBlidTripMeterViewId: |
|
880 { |
|
881 AppUi()->ActivateLocalViewL( TUid::Uid( EBlidTripMeterView ) ); |
|
882 break; |
|
883 } |
|
884 default: |
|
885 break; |
|
886 } |
|
887 } |
|
888 |
|
889 |
|
890 // ---------------------------------------------------------------------------- |
|
891 // CBlidBaseView::ShowCurrentPositionInfoL |
|
892 // Launches the current position dialog |
|
893 // ---------------------------------------------------------------------------- |
|
894 // |
|
895 void CBlidBaseView::ShowCurrentPositionInfoL() |
|
896 { |
|
897 iPopupDialog = CBlidCurrentPositionDlg::NewL( *this, iLocation, iEngine ); |
|
898 iPopupDialog->ExecuteLD(); |
|
899 iPopupDialog = NULL; |
|
900 } |
|
901 |
|
902 // ---------------------------------------------------------------------------- |
|
903 // CBlidBaseView::SaveCurrentPositionL |
|
904 // Saves current position as landmark or as waypoint |
|
905 // ---------------------------------------------------------------------------- |
|
906 // |
|
907 void CBlidBaseView::SaveCurrentPositionL() |
|
908 { |
|
909 if ( !FeatureManager::FeatureSupported( KFeatureIdLandmarks ) ) |
|
910 { |
|
911 if ( InsertWaypointL() ) |
|
912 { |
|
913 static_cast<CBlidDocument*>(AppUi()->Document())->SaveL(); |
|
914 } |
|
915 } |
|
916 else |
|
917 { |
|
918 SaveCurrentPositionAsLandmarkL(); |
|
919 } |
|
920 } |
|
921 |
|
922 // ---------------------------------------------------- |
|
923 // CBlidBaseView::BlidDocument |
|
924 // Returns the Location document object. |
|
925 // ---------------------------------------------------- |
|
926 // |
|
927 CBlidDocument* CBlidBaseView::BlidDocument() |
|
928 { |
|
929 // Explicit cast: the document must always be of type CBlidDocument |
|
930 return static_cast<CBlidDocument*>(AppUi()->Document()); |
|
931 } |
|
932 |
|
933 // ---------------------------------------------------------------------------- |
|
934 // CBlidBaseView::ActivateSatelliteViewL |
|
935 // Activates the Satellite view |
|
936 // ---------------------------------------------------------------------------- |
|
937 // |
|
938 void CBlidBaseView::ActivateSatelliteViewL( ) |
|
939 { |
|
940 AppUi()->ActivateLocalViewL( TUid::Uid( EBlidMainSatelliteView ) ); |
|
941 } |
|
942 |
|
943 // ---------------------------------------------------------------------------- |
|
944 // CBlidBaseView::IsSatViewActive |
|
945 // Checks if Satellite view is active |
|
946 // ---------------------------------------------------------------------------- |
|
947 // |
|
948 TBool CBlidBaseView::IsSatViewActive( ) |
|
949 { |
|
950 return (static_cast<CBlidAppUi*>(AppUi()))->IsSatelliteViewActive(); |
|
951 } |
|
952 |
|
953 // ---------------------------------------------------------------------------- |
|
954 // CBlidBaseView::IsForeGroundApp |
|
955 // Checks if Blid app is in foreground |
|
956 // ---------------------------------------------------------------------------- |
|
957 // |
|
958 TBool CBlidBaseView::IsForeGroundApp( ) |
|
959 { |
|
960 return ( static_cast<CBlidAppUi*>(AppUi())->IsForeground() ); |
|
961 } |
|
962 |
|
963 // ---------------------------------------------------------------------------- |
|
964 // CBlidBaseView::ExitMainApplicationL |
|
965 // Exit the application |
|
966 // ---------------------------------------------------------------------------- |
|
967 // |
|
968 void CBlidBaseView::ExitMainApplicationL( TInt aButtonId ) |
|
969 { |
|
970 static_cast<CBlidAppUi*>(AppUi())->HandleCommandL( aButtonId ); |
|
971 } |
|
972 |
|
973 // ---------------------------------------------------------------------------- |
|
974 // CBlidBaseView::LaunchTripContextMenuL |
|
975 // Launches the context menu for tripmeter view |
|
976 // ---------------------------------------------------------------------------- |
|
977 // |
|
978 void CBlidBaseView::LaunchTripContextMenuL() |
|
979 { |
|
980 CEikMenuBar* menubar = static_cast<CAknViewAppUi*> |
|
981 (iAvkonAppUi)->View(TUid::Uid( EBlidTripMeterView ))->MenuBar(); |
|
982 if ( menubar ) |
|
983 { |
|
984 menubar->SetContextMenuTitleResourceId(R_BLID_TRIP_METER_VIEW_OK_MENUBAR); |
|
985 menubar->TryDisplayContextMenuBarL(); |
|
986 } |
|
987 } |
|
988 |
|
989 // ---------------------------------------------------------------------------- |
|
990 // CBlidBaseView::LaunchNavigationContextMenuL |
|
991 // Launches the context menu for Navigation view |
|
992 // ---------------------------------------------------------------------------- |
|
993 // |
|
994 void CBlidBaseView::LaunchNavigationContextMenuL() |
|
995 { |
|
996 CEikMenuBar* menubar = static_cast<CAknViewAppUi*> |
|
997 (iAvkonAppUi)->View(TUid::Uid( EBlidNavigationView ))->MenuBar(); |
|
998 |
|
999 if ( menubar ) |
|
1000 { |
|
1001 menubar->SetContextMenuTitleResourceId(R_BLID_VIEW_OK_MENUBAR); |
|
1002 menubar->StopDisplayingMenuBar(); |
|
1003 menubar->TryDisplayContextMenuBarL(); |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 // ---------------------------------------------------------------------------- |
|
1008 // CBlidBaseView::LaunchSatelliteInfoDlgL |
|
1009 // Launches the Satellite info dialog |
|
1010 // ---------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CBlidBaseView::LaunchSatelliteInfoDlgL() |
|
1013 { |
|
1014 static_cast<CBlidAppUi*>(AppUi())->LaunchSatelliteInfoDlgL( ); |
|
1015 } |
|
1016 |
|
1017 // ---------------------------------------------------------------------------- |
|
1018 // CBlidBaseView::ActivateNavigationViewL |
|
1019 // Activates the navigation view |
|
1020 // ---------------------------------------------------------------------------- |
|
1021 // |
|
1022 void CBlidBaseView::ActivateNavigationViewL( ) |
|
1023 { |
|
1024 AppUi()->ActivateLocalViewL( TUid::Uid( EBlidNavigationView ) ); |
|
1025 } |
|
1026 |
|
1027 // ---------------------------------------------------------------------------- |
|
1028 // CBlidBaseView::ChangeViewSoftKeyL |
|
1029 // Changes the soft key |
|
1030 // ---------------------------------------------------------------------------- |
|
1031 // |
|
1032 void CBlidBaseView::ChangeViewSoftKeyL( ) |
|
1033 { |
|
1034 CBAPtr()->SetCommandSetL( R_BLID_SOFTKEYS_INFO_EXIT ); |
|
1035 CBAPtr()->DrawDeferred(); |
|
1036 } |
|
1037 |
|
1038 // ---------------------------------------------------------------------------- |
|
1039 // CBlidBaseView::ApplicationRect |
|
1040 // Returns the application rect |
|
1041 // ---------------------------------------------------------------------------- |
|
1042 // |
|
1043 TRect CBlidBaseView::ApplicationRect( ) const |
|
1044 { |
|
1045 return AppUi()->ApplicationRect(); |
|
1046 } |
|
1047 |
|
1048 // ---------------------------------------------------------------------------- |
|
1049 // CBlidBaseView::ImageLoaderUtils |
|
1050 // Returns the image loader utils |
|
1051 // ---------------------------------------------------------------------------- |
|
1052 // |
|
1053 CAlfImageLoaderUtil* CBlidBaseView::ImageLoaderUtils( ) const |
|
1054 { |
|
1055 return iImageLoaderUtil; |
|
1056 } |
|
1057 |
|
1058 // ---------------------------------------------------------------------------- |
|
1059 // CBlidBaseView::ImagePathName |
|
1060 // Returns the image path |
|
1061 // ---------------------------------------------------------------------------- |
|
1062 // |
|
1063 TFileName CBlidBaseView::ImagePathName( ) const |
|
1064 { |
|
1065 return iConFileName; |
|
1066 } |
|
1067 |
|
1068 // ---------------------------------------------------------------------------- |
|
1069 // CBlidBaseView::IsSettingsViewActive |
|
1070 // Checks if settings view is active |
|
1071 // ---------------------------------------------------------------------------- |
|
1072 // |
|
1073 TBool CBlidBaseView::IsSettingsViewActive() |
|
1074 { |
|
1075 return iIsSettingsViewActive; |
|
1076 } |
|
1077 |
|
1078 // ---------------------------------------------------------------------------- |
|
1079 // CBlidBaseView::CoeEnv |
|
1080 // Returns the control environment |
|
1081 // ---------------------------------------------------------------------------- |
|
1082 // |
|
1083 CCoeEnv* CBlidBaseView::CoeEnv() |
|
1084 { |
|
1085 return iCoeEnv; |
|
1086 } |
|
1087 // End of File |
|
1088 |