18
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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: Provides Blid UI class methods.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <AknsUtils.h>
|
|
21 |
#include <blid.rsg>
|
|
22 |
#include <akncontext.h>
|
|
23 |
#include <hlplch.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <blid.mbg>
|
|
26 |
#include <CSatelliteInfoUI.h>
|
|
27 |
|
|
28 |
#include "CBlidAppUi.h"
|
|
29 |
#include "Blid.hrh"
|
|
30 |
#include "CBlidDocument.h"
|
|
31 |
#include "CBlidMainView.h"
|
|
32 |
#include "CBlidNavigationView.h"
|
|
33 |
#include "CBlidTripMeterView.h"
|
|
34 |
#include "CBlidSettingsView.h"
|
|
35 |
#include "CBlidSavedWayptsView.h"
|
|
36 |
#include "CBlidSatelliteView.h"
|
|
37 |
#include "CBlidEng.h"
|
|
38 |
#include "Blidutils.h"
|
|
39 |
#include "CHtkNavigationControl.h"
|
|
40 |
#include "CHtkTripMeterControl.h"
|
|
41 |
#include "FileSystemInfo.h"
|
|
42 |
#include "BlidUID.h"
|
|
43 |
#include "CBlidSatelliteControl.h"
|
|
44 |
|
|
45 |
#ifdef _DEBUG
|
|
46 |
_LIT( KPanicMsg, "CBlidAppUi::TabChangedL");
|
|
47 |
|
|
48 |
enum TPanicCode
|
|
49 |
{
|
|
50 |
KBlidNullPointer = 1
|
|
51 |
};
|
|
52 |
#endif
|
|
53 |
|
|
54 |
// ================= MEMBER FUNCTIONS =======================
|
|
55 |
//
|
|
56 |
// ----------------------------------------------------------
|
|
57 |
// CBlidAppUi::ConstructL
|
|
58 |
// Second phase construction
|
|
59 |
// ----------------------------------------------------------
|
|
60 |
//
|
|
61 |
void CBlidAppUi::ConstructL()
|
|
62 |
|
|
63 |
{
|
|
64 |
RDebug::Print(_L("CBlidAppUi::ConstructL() called"));
|
|
65 |
|
|
66 |
TLocale locale;
|
|
67 |
locale.SetUnitsGeneral(EUnitsMetric);
|
|
68 |
locale.Set();
|
|
69 |
|
|
70 |
|
|
71 |
BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible);
|
|
72 |
|
|
73 |
//Code added for HTK tool kit support
|
|
74 |
// Create the environment
|
|
75 |
iAlfEnv = CAlfEnv::NewL();
|
|
76 |
|
|
77 |
// assign private path to the texture manager
|
|
78 |
CFileSystemInfo* fileSystemInfo = CFileSystemInfo::NewLC(TUid::Uid(KBLIDUID3));
|
|
79 |
TFileName path = fileSystemInfo->PrivatePath();
|
|
80 |
CleanupStack::PopAndDestroy(fileSystemInfo);
|
|
81 |
|
|
82 |
iAlfEnv->TextureManager().SetImagePathL( path );
|
|
83 |
|
|
84 |
//End of addition.
|
|
85 |
iContextPane = ETrue;
|
|
86 |
iIsSatViewActive = EFalse;
|
|
87 |
|
|
88 |
CBlidBaseView* navigationView = CBlidNavigationView::NewLC( *this, *iAlfEnv );
|
|
89 |
AddViewL( navigationView ); // transfer ownership to CAknViewAppUi
|
|
90 |
CleanupStack::Pop( navigationView ); // navigationView
|
|
91 |
|
|
92 |
CBlidBaseView* tripMeterView = CBlidTripMeterView::NewLC( *this, *iAlfEnv );
|
|
93 |
AddViewL( tripMeterView );
|
|
94 |
CleanupStack::Pop( tripMeterView ); // tripMeterView
|
|
95 |
|
|
96 |
CBlidBaseView* settingsView = CBlidSettingsView::NewLC(*this);
|
|
97 |
AddViewL( settingsView );
|
|
98 |
CleanupStack::Pop( settingsView ); // settingsView
|
|
99 |
|
|
100 |
CBlidBaseView* savedwayptsView = CBlidSavedWayptsView::NewLC(*this);
|
|
101 |
AddViewL( savedwayptsView );
|
|
102 |
CleanupStack::Pop( savedwayptsView ); // savedwayptsView
|
|
103 |
|
|
104 |
CBlidMainView* mainview = CBlidMainView::NewLC( *this, *iAlfEnv );
|
|
105 |
AddViewL( mainview );
|
|
106 |
CleanupStack::Pop( mainview ); // mainview
|
|
107 |
|
|
108 |
CBlidSatelliteView* mainSatview = CBlidSatelliteView::NewLC( *this, *iAlfEnv );
|
|
109 |
AddViewL( mainSatview );
|
|
110 |
CleanupStack::Pop( mainSatview ); // mainSatview
|
|
111 |
|
|
112 |
SetDefaultViewL( *mainview );
|
|
113 |
|
|
114 |
//start requesting
|
|
115 |
CBlidEng* engine = BlidDocument()->Engine();
|
|
116 |
|
|
117 |
if( engine->LocationModel() )
|
|
118 |
{
|
|
119 |
HBufC* srvName = StringLoader::LoadLC(
|
|
120 |
R_BLID_SERVICE_RULE_NAME, iCoeEnv );
|
|
121 |
|
|
122 |
engine->LocationModel()->InitialLocationRequestL( *srvName );
|
|
123 |
CleanupStack::PopAndDestroy(srvName); //srvName
|
|
124 |
engine->LocationModel()->StartRequesting();
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
// ----------------------------------------------------
|
|
129 |
// CBlidAppUi::~CBlidAppUi
|
|
130 |
// Destructor
|
|
131 |
// Frees reserved resources
|
|
132 |
// ----------------------------------------------------
|
|
133 |
//
|
|
134 |
CBlidAppUi::~CBlidAppUi()
|
|
135 |
{
|
|
136 |
delete iAlfEnv;
|
|
137 |
}
|
|
138 |
|
|
139 |
// ----------------------------------------------------
|
|
140 |
// CBlidAppUi::LocDocument
|
|
141 |
// Returns the Location document object.
|
|
142 |
// ----------------------------------------------------
|
|
143 |
//
|
|
144 |
CBlidDocument* CBlidAppUi::BlidDocument() const
|
|
145 |
{
|
|
146 |
// Explicit cast: the document must always be of type CBlidDocument
|
|
147 |
return static_cast<CBlidDocument*>(Document());
|
|
148 |
}
|
|
149 |
|
|
150 |
// ----------------------------------------------------
|
|
151 |
// CBlidAppUi::ShowDialog
|
|
152 |
// Displayes Overwrite waypoint note
|
|
153 |
// ----------------------------------------------------
|
|
154 |
//
|
|
155 |
void CBlidAppUi::ShowDialogL( const BlidNotes::TBlidNotes /*aNoteId*/ )
|
|
156 |
{
|
|
157 |
BlidNotes::OverWriteWaypointNoteL();
|
|
158 |
}
|
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
// ----------------------------------------------------
|
|
163 |
// CBlidAppUi::SkinChange
|
|
164 |
// Handle skin change
|
|
165 |
// ----------------------------------------------------
|
|
166 |
//
|
|
167 |
void CBlidAppUi::SkinChange()
|
|
168 |
{
|
|
169 |
iContextPane = !iContextPane;
|
|
170 |
}
|
|
171 |
|
|
172 |
// ----------------------------------------------------
|
|
173 |
// CBlidAppUi::HandleCommandL
|
|
174 |
// Handle options menu commands
|
|
175 |
// ----------------------------------------------------
|
|
176 |
//
|
|
177 |
void CBlidAppUi::HandleCommandL(TInt aCommand)
|
|
178 |
{
|
|
179 |
switch ( aCommand )
|
|
180 |
{
|
|
181 |
case EAknCmdHelp:
|
|
182 |
{
|
|
183 |
HlpLauncher::LaunchHelpApplicationL(iCoeEnv->WsSession(),
|
|
184 |
AppHelpContextL());
|
|
185 |
break;
|
|
186 |
}
|
|
187 |
// these all are same: save & exit
|
|
188 |
case EAknSoftkeyBack:
|
|
189 |
case EAknSoftkeyExit:
|
|
190 |
case EEikCmdExit:
|
|
191 |
{
|
|
192 |
CBlidTripMeterView* view = static_cast<CBlidTripMeterView*>( View( TUid::Uid( EBlidTripMeterView ) ) );
|
|
193 |
if( view )
|
|
194 |
{
|
|
195 |
view->GetControl()->SaveOdometerValue();
|
|
196 |
}
|
|
197 |
//////////////////////////////////////
|
|
198 |
RWsSession& ws = iCoeEnv->WsSession();
|
|
199 |
TApaTaskList taskList(ws);
|
|
200 |
TUid appUid = { KBLIDUID3 };
|
|
201 |
TApaTask task = taskList.FindApp( appUid );
|
|
202 |
if ( task.Exists() )
|
|
203 |
{
|
|
204 |
// stop any task runing for this application.
|
|
205 |
task.EndTask();
|
|
206 |
}
|
|
207 |
////////////////////////////////////////
|
|
208 |
Exit();
|
|
209 |
break;
|
|
210 |
}
|
|
211 |
case EBlidCmdSettings:
|
|
212 |
{
|
|
213 |
ActivateLocalViewL( TUid::Uid(EBlidSettingsView) );
|
|
214 |
break;
|
|
215 |
}
|
|
216 |
case EBlidCmdSatelliteStatus:
|
|
217 |
{
|
|
218 |
TRAPD( error, LaunchSatelliteInfoDlgL() );
|
|
219 |
if ( error != KErrNone )
|
|
220 |
{
|
|
221 |
// need to be NULL, before leave
|
|
222 |
iSatelliteInfo = NULL;
|
|
223 |
User::Leave( error );
|
|
224 |
}
|
|
225 |
break;
|
|
226 |
}
|
|
227 |
default:
|
|
228 |
break;
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
// ----------------------------------------------------
|
|
233 |
// CBlidAppUi::TabChangedL
|
|
234 |
// Called when Tab is changed, activates appropriate view
|
|
235 |
// ----------------------------------------------------
|
|
236 |
//
|
|
237 |
void CBlidAppUi::TabChangedL(TInt aIndex)
|
|
238 |
{
|
|
239 |
// Gets a subpane control by ID
|
|
240 |
CAknNavigationControlContainer* naviCtrlContainer =
|
|
241 |
static_cast<CAknNavigationControlContainer*>
|
|
242 |
( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
|
|
243 |
__ASSERT_DEBUG( naviCtrlContainer,
|
|
244 |
User::Panic(KPanicMsg, KBlidNullPointer) );
|
|
245 |
|
|
246 |
// Return topmost object from navigation pane's object stack.
|
|
247 |
CAknNavigationDecorator* decorator = naviCtrlContainer->Top();
|
|
248 |
__ASSERT_DEBUG( decorator && decorator->ControlType() ==
|
|
249 |
CAknNavigationDecorator::ETabGroup,
|
|
250 |
User::Panic( KPanicMsg, KBlidNullPointer ) );
|
|
251 |
|
|
252 |
CAknTabGroup* tabGroup =
|
|
253 |
static_cast< CAknTabGroup* > ( decorator->DecoratedControl() );
|
|
254 |
__ASSERT_DEBUG( tabGroup && aIndex >= 0 && aIndex < tabGroup->TabCount(),
|
|
255 |
User::Panic(KPanicMsg, KBlidNullPointer));
|
|
256 |
ActivateLocalViewL(TUid::Uid(tabGroup->TabIdFromIndex(aIndex)));
|
|
257 |
}
|
|
258 |
|
|
259 |
// ----------------------------------------------------
|
|
260 |
// CBlidAppUi::HandleForegroundEventL
|
|
261 |
// Called whenever app goes to background or comes to foreground
|
|
262 |
// ----------------------------------------------------
|
|
263 |
//
|
|
264 |
void CBlidAppUi::HandleForegroundEventL(TBool aForeground)
|
|
265 |
{
|
|
266 |
CAknAppUi::HandleForegroundEventL( aForeground );
|
|
267 |
iForeground = aForeground;
|
|
268 |
|
|
269 |
CBlidEng* engine = BlidDocument()->Engine();
|
|
270 |
if (aForeground)
|
|
271 |
{
|
|
272 |
engine->SetAppMode(CBlidEng::EAppForeground);
|
|
273 |
if (engine->LocationModel())
|
|
274 |
{
|
|
275 |
if (engine->LocationModel()->GetRegisteredViewId()
|
|
276 |
== EBlidNavigationView)
|
|
277 |
{
|
|
278 |
CBlidNavigationView* view =
|
|
279 |
static_cast<CBlidNavigationView*> (View(TUid::Uid(
|
|
280 |
EBlidNavigationView)));
|
|
281 |
view->GetControl()->UpdateL();
|
|
282 |
}
|
|
283 |
if (engine->LocationModel()->GetRegisteredViewId()
|
|
284 |
== EBlidTripMeterView)
|
|
285 |
{
|
|
286 |
CBlidTripMeterView* view =
|
|
287 |
static_cast<CBlidTripMeterView*> (View(TUid::Uid(
|
|
288 |
EBlidTripMeterView)));
|
|
289 |
view->GetControl()->UpdateL();
|
|
290 |
}
|
|
291 |
if (engine->LocationModel()->GetRegisteredViewId()
|
|
292 |
== EBlidMainSatelliteView)
|
|
293 |
{
|
|
294 |
CBlidSatelliteView* view = static_cast<CBlidSatelliteView*> (View(
|
|
295 |
TUid::Uid(EBlidMainSatelliteView)));
|
|
296 |
view->GetControl()->UpdateL();
|
|
297 |
}
|
|
298 |
if (engine->LocationModel()->GetRegisteredViewId()
|
|
299 |
== EBlidMainView)
|
|
300 |
{
|
|
301 |
CBlidMainView* view = static_cast<CBlidMainView*> (View(
|
|
302 |
TUid::Uid(EBlidMainView)));
|
|
303 |
view->GetControl()->UpdateL();
|
|
304 |
}
|
|
305 |
}
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
engine->SetAppMode(CBlidEng::EAppBackground);
|
|
310 |
engine->SetBackLightStateL(CBlidEng::EBlidBacklightNormal);
|
|
311 |
if (engine->LocationModel()->GetRegisteredViewId()
|
|
312 |
== EBlidNavigationView)
|
|
313 |
{
|
|
314 |
CBlidNavigationView* view =
|
|
315 |
static_cast<CBlidNavigationView*> (View(TUid::Uid(
|
|
316 |
EBlidNavigationView)));
|
|
317 |
view->GetControl()->StopPlayerL();
|
|
318 |
}
|
|
319 |
}
|
|
320 |
|
|
321 |
if (iSatelliteInfo)
|
|
322 |
{
|
|
323 |
iSatelliteInfo->HandleForegroundEventL( aForeground );
|
|
324 |
}
|
|
325 |
|
|
326 |
}
|
|
327 |
|
|
328 |
// ----------------------------------------------------
|
|
329 |
// CBlidAppUi::ProcessKeyEventL
|
|
330 |
// Process key event
|
|
331 |
// ----------------------------------------------------
|
|
332 |
//
|
|
333 |
TBool CBlidAppUi::ProcessKeyEventL( const TKeyEvent& /*aKeyEvent*/,
|
|
334 |
TEventCode /*aType*/ )
|
|
335 |
{
|
|
336 |
return EKeyWasNotConsumed;
|
|
337 |
}
|
|
338 |
|
|
339 |
// ----------------------------------------------------
|
|
340 |
// CBlidAppUi::TabObserver
|
|
341 |
// Retruns CBlidAppUi pointer, which is Tab observer
|
|
342 |
// ----------------------------------------------------
|
|
343 |
//
|
|
344 |
MAknTabObserver* CBlidAppUi::TabObserver()
|
|
345 |
{
|
|
346 |
return this;
|
|
347 |
}
|
|
348 |
|
|
349 |
// ----------------------------------------------------
|
|
350 |
// CBlidAppUi::LaunchSatelliteInfoDlgL
|
|
351 |
// Launches Satellite info dialog
|
|
352 |
// ----------------------------------------------------
|
|
353 |
//
|
|
354 |
void CBlidAppUi::LaunchSatelliteInfoDlgL()
|
|
355 |
{
|
|
356 |
HBufC* srvName = StringLoader::LoadLC(
|
|
357 |
R_BLID_SERVICE_RULE_NAME,
|
|
358 |
iCoeEnv );
|
|
359 |
iSatelliteInfo = CSatelliteInfoUI::NewL();
|
|
360 |
iSatelliteInfo->ExecuteLD( *srvName );
|
|
361 |
CleanupStack::PopAndDestroy(srvName); //srvName
|
|
362 |
iSatelliteInfo = NULL;
|
|
363 |
}
|
|
364 |
|
|
365 |
// ----------------------------------------------------
|
|
366 |
// CBlidAppUi::IsForeground
|
|
367 |
// Checks if App is in foreground
|
|
368 |
// ----------------------------------------------------
|
|
369 |
//
|
|
370 |
TBool CBlidAppUi::IsForeground()
|
|
371 |
{
|
|
372 |
return iForeground;
|
|
373 |
}
|
|
374 |
|
|
375 |
// ----------------------------------------------------
|
|
376 |
// CBlidAppUi::HandleResourceChangeL
|
|
377 |
// Handles a change to the resources
|
|
378 |
// ----------------------------------------------------
|
|
379 |
//
|
|
380 |
void CBlidAppUi::HandleResourceChangeL( TInt aType )
|
|
381 |
{
|
|
382 |
CAknAppUi::HandleResourceChangeL( aType );
|
|
383 |
CBlidEng* engine = BlidDocument()->Engine();
|
|
384 |
|
|
385 |
if( engine->LocationModel() )
|
|
386 |
{
|
|
387 |
CBlidNavigationView* NavView = static_cast<CBlidNavigationView*>(View(TUid::Uid(EBlidNavigationView)));
|
|
388 |
NavView->HandleResourceChangeL( aType );
|
|
389 |
|
|
390 |
CBlidTripMeterView* TripView = static_cast<CBlidTripMeterView*>(View(TUid::Uid(EBlidTripMeterView)));
|
|
391 |
TripView->HandleResourceChangeL( aType );
|
|
392 |
|
|
393 |
CBlidMainView* MainView = static_cast<CBlidMainView*>(View(TUid::Uid(EBlidMainView)));
|
|
394 |
MainView->HandleResourceChangeL( aType );
|
|
395 |
|
|
396 |
CBlidSatelliteView* SatView = static_cast<CBlidSatelliteView*>(View(TUid::Uid(EBlidMainSatelliteView)));
|
|
397 |
SatView->HandleResourceChangeL( aType );
|
|
398 |
}
|
|
399 |
}
|
|
400 |
|
|
401 |
// ----------------------------------------------------
|
|
402 |
// CBlidAppUi::SetSatelliteViewActive
|
|
403 |
// Set satellite view active or inactive
|
|
404 |
// ----------------------------------------------------
|
|
405 |
//
|
|
406 |
void CBlidAppUi::SetSatelliteViewActive( TBool aActive )
|
|
407 |
{
|
|
408 |
iIsSatViewActive = aActive;
|
|
409 |
}
|
|
410 |
|
|
411 |
// ----------------------------------------------------
|
|
412 |
// CBlidAppUi::IsSatelliteViewActive
|
|
413 |
// Check if Satellite view is active
|
|
414 |
// ----------------------------------------------------
|
|
415 |
//
|
|
416 |
TBool CBlidAppUi::IsSatelliteViewActive( )
|
|
417 |
{
|
|
418 |
return iIsSatViewActive;
|
|
419 |
}
|
|
420 |
|
|
421 |
// ----------------------------------------------------
|
|
422 |
// CBlidAppUi::ResetOdoMeterValueL
|
|
423 |
// Resets the odometer value
|
|
424 |
// ----------------------------------------------------
|
|
425 |
//
|
|
426 |
void CBlidAppUi::ResetOdoMeterValueL()
|
|
427 |
{
|
|
428 |
CBlidTripMeterView* view = static_cast<CBlidTripMeterView*>(View(TUid::Uid(EBlidTripMeterView)));
|
|
429 |
if( view )
|
|
430 |
{
|
|
431 |
view->GetControl()->ResetOdometerDistanceL();
|
|
432 |
}
|
|
433 |
}
|
|
434 |
// End of File
|