|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Application UI class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikenv.h> |
|
21 #include <coemain.h> |
|
22 #include <coehelp.h> |
|
23 #include <bacntf.h> |
|
24 #include <starterclient.h> |
|
25 #include <telinternalpskeys.h> |
|
26 #include <activeidle2domainpskeys.h> |
|
27 #include <telremotepartyinformationpskeys.h> |
|
28 #include <telinformationpskeys.h> |
|
29 #include <UikonInternalPSKeys.h> |
|
30 #include <startupdomainpskeys.h> |
|
31 #include <apgtask.h> |
|
32 #include <apgwgnam.h> |
|
33 #include <barsread.h> |
|
34 #include <coemain.h> |
|
35 #include <AknsConstants.h> // KAknsMessageSkinChange |
|
36 #include <bautils.h> |
|
37 #include <StringLoader.h> |
|
38 #include <aknsoundsystem.h> |
|
39 #include <aknnotewrappers.h> // for Notification for startup... |
|
40 #include <eikbtgpc.h> |
|
41 #include <eiksoftkeyimage.h> // EikSoftkeyImage |
|
42 #include <featmgr.h> // Feature Manager |
|
43 #include <bldvariant.hrh> // System variant definition |
|
44 #include <phoneui.rsg> |
|
45 #include "phoneui.pan" |
|
46 #include "cphoneappui.h" |
|
47 #include "cphoneapplication.h" |
|
48 #include "cphonedocument.h" |
|
49 #include "cphonekeys.h" |
|
50 #include "cphoneview.h" // from PhoneUIView |
|
51 #include "cphoneviewcontroller.h" |
|
52 #include "cphoneuicontroller.h" |
|
53 #include "cphonepubsubproxy.h" |
|
54 #include "phonelogger.h" |
|
55 #include "phoneconstants.h" |
|
56 #include "cphoneclearblacklist.h" |
|
57 #include "cphonestatuspane.h" |
|
58 #include "cphoneqwertyhandler.h" |
|
59 #include "tphonecmdparaminteger.h" |
|
60 #ifndef __WINS__ |
|
61 #include <f32file.h> |
|
62 #endif |
|
63 |
|
64 |
|
65 // ================= MEMBER FUNCTIONS ======================= |
|
66 |
|
67 // --------------------------------------------------------- |
|
68 // CPhoneAppUI::CPhoneAppUI() |
|
69 // Default constructor |
|
70 // (other items were commented in a header). |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 CPhoneAppUI::CPhoneAppUI() : |
|
74 iAppsReady( EPhoneStartupInitial ) |
|
75 { |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CPhoneAppUI::~CPhoneAppUI() |
|
80 // Destructor |
|
81 // (other items were commented in a header). |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 CPhoneAppUI::~CPhoneAppUI() |
|
85 { |
|
86 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAppUI::~CPhoneAppUI() "); |
|
87 if ( iPhoneViewController ) |
|
88 { |
|
89 RemoveFromStack( iPhoneViewController->PhoneView() ); |
|
90 delete iPhoneViewController; |
|
91 } |
|
92 delete iPhoneUIController; |
|
93 delete iQwertyHandler; |
|
94 |
|
95 CPhoneRecoverySystem::Remove( iStartupSignalRecoveryId ); |
|
96 |
|
97 delete iEnvChangeNotifier; |
|
98 iEnvChangeNotifier = NULL; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CPhoneAppUI::ConstructL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CPhoneAppUI::ConstructL() |
|
106 { |
|
107 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAppUI::ConstructL() "); |
|
108 // Requires the availability of CBA and Menubar resources |
|
109 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
110 SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | CAknAppUiBase::EDisableSendKeyLong ); |
|
111 |
|
112 SetAliasKeyCodeResolverL( this ); |
|
113 |
|
114 // Set phone application to be system application so it can't be closed |
|
115 iEikonEnv->SetSystem( ETrue ); |
|
116 |
|
117 // Disable priority changes of window server and set |
|
118 // process priority (phone app might be on the background |
|
119 // and so it's priority might be low). |
|
120 iEikonEnv->WsSession().ComputeMode( |
|
121 RWsSession::EPriorityControlDisabled ); |
|
122 RThread().SetProcessPriority( EPriorityHigh ); |
|
123 |
|
124 // System enviroment change notifier. |
|
125 iEnvChangeNotifier = CEnvironmentChangeNotifier::NewL( |
|
126 CActive::EPriorityStandard, TCallBack( HandleCallBackL, this ) ); |
|
127 |
|
128 iEnvChangeNotifier->Start(); |
|
129 |
|
130 // Push key sounds to sound system. |
|
131 CAknKeySoundSystem* keySounds = KeySounds(); |
|
132 keySounds->PushContextL( R_PHONEUI_DEFAULT_SKEY_LIST ); |
|
133 |
|
134 iPhoneViewController = CPhoneViewController::NewL( ClientRect() ); |
|
135 iPhoneUIController = CPhoneUIController::NewL( iPhoneViewController ); |
|
136 iQwertyHandler = CPhoneQwertyHandler::NewL(); |
|
137 |
|
138 // Blacklist singleton is initialized here |
|
139 // return value is ignored since we do not require its services in this class |
|
140 CPhoneClearBlacklist::CreateL( |
|
141 iEikonEnv->WsSession(), |
|
142 *iPhoneViewController->PhoneView()->DrawableWindow() ); |
|
143 |
|
144 RegisterViewL( *iPhoneViewController->PhoneView() ); |
|
145 AddToStackL( iPhoneViewController->PhoneView(), ECoeStackPriorityDefault ); |
|
146 |
|
147 const_cast<CEikAppUi*>( |
|
148 iEikonEnv->EikAppUi() )->AddViewActivationObserverL( this ); |
|
149 |
|
150 // Eikon server window group |
|
151 iEikonServerWgId = |
|
152 iEikonEnv->WsSession().FindWindowGroupIdentifier( 0, KPhoneEikonServer ); |
|
153 __ASSERT_ALWAYS( iEikonServerWgId != KErrNotFound, Panic( EPhoneUiNoWindowGroup ) ); |
|
154 iEikonEnv->RootWin().EnableFocusChangeEvents(); |
|
155 iEikonEnv->RootWin().EnableGroupChangeEvents(); |
|
156 |
|
157 // CLI Name. |
|
158 TInt err = RProperty::Define( |
|
159 KPSUidTelRemotePartyInformation, |
|
160 KTelCLIName, |
|
161 RProperty::EText, |
|
162 KPhoneReadPolicy, |
|
163 KPhoneWritePolicy ); |
|
164 |
|
165 __PHONELOG1( |
|
166 EBasic, |
|
167 EPhonePhoneapp, |
|
168 "CPhoneAppUI::ConstructL() - Define CLIName property (status=%d)", |
|
169 err ); |
|
170 |
|
171 // CLI Number. |
|
172 err = RProperty::Define( |
|
173 KPSUidTelRemotePartyInformation, |
|
174 KTelCLINumber, |
|
175 RProperty::EText, |
|
176 KPhoneReadPolicy, |
|
177 KPhoneWritePolicy ); |
|
178 |
|
179 __PHONELOG1( |
|
180 EBasic, |
|
181 EPhonePhoneapp, |
|
182 "CPhoneAppUI::ConstructL() - Define CLINumber property (status=%d)", |
|
183 err ); |
|
184 |
|
185 // Define the top application system property |
|
186 err = RProperty::Define( |
|
187 KPSUidUikon, |
|
188 KUikVideoCallTopApp, |
|
189 RProperty::EInt, |
|
190 KPhoneReadPolicy, |
|
191 KPhoneWritePolicy ); |
|
192 |
|
193 __PHONELOG1( |
|
194 EBasic, |
|
195 EPhonePhoneapp, |
|
196 "CPhoneAppUI::ConstructL() Define top application property (status=%d)", |
|
197 err ); |
|
198 |
|
199 // Startup event signalling |
|
200 // Define the telephony application system property |
|
201 |
|
202 err = RProperty::Define( |
|
203 KPSUidTelInformation, |
|
204 KTelPhoneUid, |
|
205 RProperty::EInt, |
|
206 KPhoneReadPolicy, |
|
207 KPhoneWritePolicy ); |
|
208 |
|
209 // DefineNewPSKeys: |
|
210 |
|
211 // UID: KPSUidTelInternalInformation: |
|
212 err = RProperty::Define( |
|
213 KPSUidTelInternalInformation, |
|
214 KTelRemotePartyContactInfo, |
|
215 RProperty::EByteArray, |
|
216 KPhoneReadPolicy, |
|
217 KPhoneWritePolicy ); |
|
218 |
|
219 // VT UID. |
|
220 err = RProperty::Define( |
|
221 KPSUidTelInternalInformation, |
|
222 KTelVideoCallUid, |
|
223 RProperty::EInt, |
|
224 KPhoneReadPolicy, |
|
225 KPhoneWritePolicy ); |
|
226 |
|
227 // TELINTERNALPSKEY CHANGE |
|
228 // Move to AudioHandling |
|
229 // UID: KPSUidTelAudioPreference |
|
230 // Call Audio Routing |
|
231 err = RProperty::Define( |
|
232 KPSUidTelAudioPreference, |
|
233 KTelAudioOutput, |
|
234 RProperty::EInt, |
|
235 KPhoneReadPolicyAlwaysPass, |
|
236 KPhoneWritePolicy ); |
|
237 |
|
238 // UID: KPSUidNEInformation |
|
239 err = RProperty::Define( |
|
240 KPSUidNEInformation, |
|
241 KTelNumberEntryInfo, |
|
242 RProperty::EInt, |
|
243 KPhoneReadPolicyAlwaysPass, |
|
244 KPhoneWritePolicy ); |
|
245 |
|
246 __PHONELOG1( |
|
247 EBasic, |
|
248 EPhonePhoneapp, |
|
249 "CPhoneAppUI::ConstructL() Define phone property (status=%d)", |
|
250 err ); |
|
251 |
|
252 // Add DoStartupSignalL to the recovery system |
|
253 iStartupSignalRecoveryId = |
|
254 CPhoneRecoverySystem::Instance()->AddL( |
|
255 TCallBack( DoStartupSignalL, this ), |
|
256 CTeleRecoverySystem::EPhonePriorityHigh, |
|
257 CTeleRecoverySystem::EPhoneStateIdle ); |
|
258 |
|
259 // Call DoStartupSignalL within recovery system |
|
260 const TInt startupState = CPhonePubSubProxy::Instance()->Value( |
|
261 KPSUidStartup, |
|
262 KPSGlobalSystemState ); |
|
263 |
|
264 __PHONELOG1( |
|
265 EBasic, |
|
266 EPhonePhoneapp, |
|
267 "CPhoneAppUI::ConstructL() StartupState value", |
|
268 startupState ); |
|
269 |
|
270 if ( startupState == ESwStateCriticalPhaseOK || |
|
271 startupState == ESwStateEmergencyCallsOnly || |
|
272 startupState == ESwStateNormalRfOn || |
|
273 startupState == ESwStateNormalRfOff || |
|
274 startupState == ESwStateNormalBTSap ) |
|
275 { |
|
276 __PHONELOG( |
|
277 EBasic, |
|
278 EPhonePhoneapp, |
|
279 "CPhoneAppUI::ConstructL() Notify Starter that phone is ready..." ); |
|
280 |
|
281 CPhoneRecoverySystem::Instance()->RecoverNow( |
|
282 iStartupSignalRecoveryId, |
|
283 CTeleRecoverySystem::EPhonePriorityHigh ); |
|
284 } |
|
285 else |
|
286 { |
|
287 __PHONELOG( |
|
288 EBasic, |
|
289 EPhonePhoneapp, |
|
290 "CPhoneAppUI::ConstructL() Startup not ready yet. Start listening..." ); |
|
291 CPhonePubSubProxy::Instance()->NotifyChangeL( |
|
292 KPSUidStartup, |
|
293 KPSGlobalSystemState, |
|
294 this ); |
|
295 } |
|
296 |
|
297 |
|
298 // THE VERY LAST STEP: DROP PRIORITY. |
|
299 RThread().SetPriority( EPriorityNormal ); |
|
300 |
|
301 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
302 { |
|
303 // Indicate to the system that the Phone has been started |
|
304 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
305 KPSUidTelInformation, |
|
306 KTelPhoneUid, |
|
307 KUidPhoneApplication.iUid ); |
|
308 } |
|
309 |
|
310 // Update the Apps ready flag |
|
311 iAppsReady += EPhoneStartedUp; |
|
312 |
|
313 if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ) ) |
|
314 { |
|
315 iOnScreenDialer = ETrue; |
|
316 } |
|
317 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::ConstructL() Phone started..." ); |
|
318 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::ConstructL() done..." ); |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CPhoneAppUI::DoStartupSignalL |
|
323 // |
|
324 // Callback function. |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 TInt CPhoneAppUI::DoStartupSignalL( TAny* aAny ) |
|
328 { |
|
329 CPhoneAppUI* appUi = |
|
330 static_cast< CPhoneAppUI* >( aAny ); |
|
331 |
|
332 return |
|
333 !appUi->iLightIdleReached ? |
|
334 appUi->DoStartupSignalIdleL() : |
|
335 appUi->DoStartupSignalSecurityL(); |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CPhoneAppUI::DoStartupSignalIdleL |
|
340 // ----------------------------------------------------------------------------- |
|
341 // |
|
342 TInt CPhoneAppUI::DoStartupSignalIdleL() |
|
343 { |
|
344 TBool idleReached = EFalse; |
|
345 |
|
346 // Check if Idle application has been started. |
|
347 const TInt idleUid = CPhonePubSubProxy::Instance()->Value( |
|
348 KPSUidAiInformation, |
|
349 KActiveIdleUid ); |
|
350 |
|
351 if ( idleUid != 0 && idleUid != KErrNotFound ) |
|
352 { |
|
353 // Idle application has already started |
|
354 if ( !( iAppsReady & EPhoneIdleStartedUp ) ) |
|
355 { |
|
356 __PHONELOG1( EBasic, EPhonePhoneapp, "CPhoneAppUI::ConstructL() Idle App started (uid=%d)!", idleUid ); |
|
357 iAppsReady += EPhoneIdleStartedUp; |
|
358 |
|
359 // Remove Phone application from Fast Swap Window. |
|
360 iPhoneViewController->SetHiddenL( ETrue ); |
|
361 |
|
362 // Set Idle's UID to PubSub. |
|
363 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
364 KPSUidUikon, |
|
365 KUikVideoCallTopApp, |
|
366 idleUid ); |
|
367 } |
|
368 } |
|
369 else |
|
370 { |
|
371 CPhonePubSubProxy::Instance()->NotifyChangeL( |
|
372 KPSUidAiInformation, |
|
373 KActiveIdleUid, |
|
374 this ); |
|
375 } |
|
376 |
|
377 const TInt current = CPhonePubSubProxy::Instance()->Value( |
|
378 KPSUidStartup, |
|
379 KPSGlobalSystemState ); |
|
380 |
|
381 __PHONELOG1( EBasic, EPhonePhoneapp, "CPhoneAppUI::DoStartupSignalIdleL() System state=%d", current ); |
|
382 if ( current == ESwStateSelfTestOK || |
|
383 current == ESwStateCriticalPhaseOK ) |
|
384 { |
|
385 // Check that both the Phone and Idle applications are ready |
|
386 idleReached = ( iAppsReady & EPhoneStartedUp ) && |
|
387 ( iAppsReady & EPhoneIdleStartedUp ); |
|
388 |
|
389 if ( idleReached ) |
|
390 { |
|
391 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::DoStartupSignalIdleL() Phone and Idle apps have both been started" ); |
|
392 |
|
393 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
394 KPSUidStartup, |
|
395 KPSPhonePhase1Ok, |
|
396 EPhonePhase1Ok ); |
|
397 } |
|
398 } |
|
399 else |
|
400 { |
|
401 idleReached = ( iAppsReady & EPhoneIdleStartedUp ) && |
|
402 ( current == ESwStateEmergencyCallsOnly || |
|
403 current == ESwStateNormalRfOn || |
|
404 current == ESwStateNormalRfOff || |
|
405 current == ESwStateNormalBTSap ); |
|
406 |
|
407 __PHONELOG1( EBasic, EPhonePhoneapp, "CPhoneAppUI::DoStartupSignalIdleL() System state is not at SelfTestOk. Idle reached anyway?=%d", idleReached ); |
|
408 } |
|
409 |
|
410 if ( idleReached ) |
|
411 { |
|
412 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::DoStartupSignalIdleL() Idle reached!" ); |
|
413 // Now err == KErrNone and it means that |
|
414 // we have succeeded in signalling. |
|
415 CPhoneRecoverySystem::Instance()->EnablePreconditionL(); |
|
416 |
|
417 // Update the Phone light idle flag |
|
418 iLightIdleReached = ETrue; |
|
419 |
|
420 // Notify the UI controller that the phone is ready |
|
421 iPhoneUIController->HandlePhoneStartupL(); |
|
422 } |
|
423 else |
|
424 { |
|
425 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::DoStartupSignalIdleL() Idle is not reached yet!" ); |
|
426 // Idle has not been reached yet. Indicate to the recovery |
|
427 // system that this iteration has failed so that it will |
|
428 // try again at a later time. |
|
429 User::Leave( KErrNotReady ); |
|
430 } |
|
431 |
|
432 return KErrNone; |
|
433 } |
|
434 |
|
435 // ----------------------------------------------------------------------------- |
|
436 // CPhoneAppUI::DoStartupSignalSecurityL |
|
437 // ----------------------------------------------------------------------------- |
|
438 // |
|
439 TInt CPhoneAppUI::DoStartupSignalSecurityL() |
|
440 { |
|
441 TInt err = KErrNone; |
|
442 return err; |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------- |
|
446 // CPhoneAppUI::HandlePropertyChangedL |
|
447 // ----------------------------------------------------------- |
|
448 // |
|
449 void CPhoneAppUI::HandlePropertyChangedL( |
|
450 const TUid& aCategory, |
|
451 const TUint aKey, |
|
452 const TInt aValue ) |
|
453 { |
|
454 __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAppUI::HandlePropertyChangedL( ) "); |
|
455 |
|
456 if ( aCategory == KPSUidAiInformation ) |
|
457 { |
|
458 // Call state event |
|
459 if ( aKey == KActiveIdleUid ) |
|
460 { |
|
461 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUi::HandleChangeL() Idle event" ); |
|
462 TInt idleUid = aValue; |
|
463 |
|
464 // If idle startup is ok. |
|
465 if ( idleUid != 0 ) |
|
466 { |
|
467 // If idle startup is ok for the first time, then recover |
|
468 // the Start signal processing |
|
469 if ( !( iAppsReady & EPhoneIdleStartedUp ) ) |
|
470 { |
|
471 __PHONELOG( EBasic, EPhonePhoneapp, |
|
472 "CPhoneAppUI::HandlePropertyChangedL() Idle App started!" ); |
|
473 iAppsReady += EPhoneIdleStartedUp; |
|
474 // Try to update the startup signal again |
|
475 CPhoneRecoverySystem::Instance()->RecoverNow( |
|
476 iStartupSignalRecoveryId, |
|
477 CTeleRecoverySystem::EPhonePriorityHigh ); |
|
478 // Remove Phone application from Fast Swap Window. |
|
479 iPhoneViewController->SetHiddenL( ETrue ); |
|
480 // Set Idle's UID to PubSub. |
|
481 CPhonePubSubProxy::Instance()->ChangePropertyValue( |
|
482 KPSUidUikon, |
|
483 KUikVideoCallTopApp, |
|
484 idleUid ); |
|
485 } |
|
486 } |
|
487 } |
|
488 } |
|
489 |
|
490 if ( aCategory == KPSUidStartup ) |
|
491 { |
|
492 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUi::HandleChangeL() Starter event" ); |
|
493 const TInt startupState = CPhonePubSubProxy::Instance()->Value( |
|
494 KPSUidStartup, |
|
495 KPSGlobalSystemState ); |
|
496 |
|
497 __PHONELOG1( EBasic, EPhonePhoneapp, "CPhoneAppUI::HandleChangeL() StartupState value", startupState ); |
|
498 if ( startupState == ESwStateCriticalPhaseOK || |
|
499 startupState == ESwStateEmergencyCallsOnly || |
|
500 startupState == ESwStateNormalRfOn || |
|
501 startupState == ESwStateNormalRfOff || |
|
502 startupState == ESwStateNormalBTSap ) |
|
503 { |
|
504 // Try to update the startup signal again |
|
505 CPhoneRecoverySystem::Instance()->RecoverNow( |
|
506 iStartupSignalRecoveryId, |
|
507 CTeleRecoverySystem::EPhonePriorityHigh ); |
|
508 } |
|
509 } |
|
510 } |
|
511 |
|
512 |
|
513 // ----------------------------------------------------------------------------- |
|
514 // CPhoneAppUI::HandleEnvironmentChangeL |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 void CPhoneAppUI::HandleEnvironmentChangeL( const TInt aChanges ) |
|
518 { |
|
519 // Pass environment changes to the UI controller |
|
520 iPhoneUIController->HandleEnvironmentChangeL( aChanges ); |
|
521 } |
|
522 |
|
523 // ----------------------------------------------------------------------------- |
|
524 // CPhoneAppUI::HandleWsEventL |
|
525 // ----------------------------------------------------------------------------- |
|
526 // |
|
527 void CPhoneAppUI::HandleWsEventL( |
|
528 const TWsEvent& aEvent, |
|
529 CCoeControl* aDestination ) |
|
530 { |
|
531 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneAppUI::HandleWsEventL" ); |
|
532 |
|
533 // Only handle window server events if startup is finished |
|
534 if ( iLightIdleReached ) |
|
535 { |
|
536 __PHONELOG3( EBasic, EPhonePhoneapp, "CPhoneAppUI::HandleWsEvent( key(%d), iCode(%d), type(%d) )", |
|
537 aEvent.Key()->iScanCode, aEvent.Key()->iCode, aEvent.Type() ); |
|
538 |
|
539 CEikonEnv& eikEnv = *iEikonEnv; |
|
540 CCoeEnv& coeEnv = eikEnv; |
|
541 |
|
542 const TInt type = aEvent.Type(); |
|
543 switch ( type ) |
|
544 { |
|
545 case EEventFocusGained: |
|
546 { |
|
547 const TInt foregroundApp = |
|
548 iPhoneViewController->ForegroundApplicationWindowGroupId(); |
|
549 const TInt thisApplicationWgId = |
|
550 iPhoneViewController->ApplicationWindowGroupId(); |
|
551 |
|
552 if ( thisApplicationWgId != foregroundApp ) |
|
553 { |
|
554 // Focus gained but phone is not in fore then phone need |
|
555 // to bring idle to fore if needed. |
|
556 iPhoneUIController->HandleIdleForegroundEventL(); |
|
557 } |
|
558 else |
|
559 { |
|
560 iPhoneUIController->HandlePhoneForegroundEventL(); |
|
561 } |
|
562 } |
|
563 break; |
|
564 |
|
565 case EEventFocusLost: |
|
566 { |
|
567 const TInt windowGroupId = |
|
568 coeEnv.WsSession().GetFocusWindowGroup(); |
|
569 const TInt foregroundAppWgId = |
|
570 iPhoneViewController->ForegroundApplicationWindowGroupId(); |
|
571 const TInt phoneApplicationWgId = |
|
572 iPhoneViewController->ApplicationWindowGroupId(); |
|
573 // If phone app is not in fore and we receive focuslost then we |
|
574 // need to send focus lost event to state which then updates |
|
575 // FSW to correct state. |
|
576 if ( ( foregroundAppWgId != phoneApplicationWgId ) && |
|
577 ( windowGroupId != phoneApplicationWgId ) && |
|
578 ( windowGroupId != iEikonServerWgId ) ) |
|
579 { |
|
580 iPhoneUIController->HandlePhoneFocusLostEventL(); |
|
581 } |
|
582 } |
|
583 break; |
|
584 |
|
585 case EEventKey: |
|
586 { |
|
587 TKeyEvent* keyEvent = aEvent.Key(); |
|
588 |
|
589 if ( keyEvent->iScanCode == EStdKeyNo ) |
|
590 { |
|
591 NoKeySpecialHandlingL( *keyEvent, EEventKey ); |
|
592 } |
|
593 |
|
594 //will be called if exit number is typed (*#1234#) |
|
595 if ( keyEvent->iCode == EEikCmdExit ) |
|
596 { |
|
597 Exit(); |
|
598 return; |
|
599 } |
|
600 |
|
601 if ( iQwertyHandler->IsQwertyInput() ) |
|
602 { |
|
603 TInt code = iQwertyHandler->NumericKeyCode( *keyEvent ); |
|
604 TBool fepSimulated = keyEvent->iModifiers & EModifierSpecial; |
|
605 if ( !fepSimulated && |
|
606 ( ( code != EKeyNull && code != keyEvent->iCode ) || |
|
607 ( code == EKeyNull && CPhoneKeys::IsNumericKey( |
|
608 *keyEvent, |
|
609 ( TEventCode ) aEvent.Type() ) ) ) |
|
610 ) |
|
611 { |
|
612 // Modify event according to keyboard layout |
|
613 TWsEvent newWsEvent = aEvent; |
|
614 TKeyEvent* newKeyEvent = newWsEvent.Key(); |
|
615 newKeyEvent->iCode = code; |
|
616 TInt shiftMask = EModifierLeftShift | |
|
617 EModifierRightShift | |
|
618 EModifierShift; |
|
619 shiftMask = ~shiftMask; |
|
620 newKeyEvent->iModifiers = newKeyEvent->iModifiers & shiftMask; |
|
621 return CAknAppUi::HandleWsEventL( newWsEvent, aDestination ); |
|
622 } |
|
623 } |
|
624 } |
|
625 break; |
|
626 |
|
627 case EEventKeyUp: |
|
628 { |
|
629 TKeyEvent* keyEvent = aEvent.Key(); |
|
630 |
|
631 if ( keyEvent->iScanCode == EStdKeyNo ) |
|
632 { |
|
633 NoKeySpecialHandlingL( *keyEvent, EEventKeyUp ); |
|
634 } |
|
635 } |
|
636 break; |
|
637 |
|
638 case EEventKeyDown: |
|
639 { |
|
640 TKeyEvent* keyEvent = aEvent.Key(); |
|
641 |
|
642 if ( keyEvent->iScanCode == EStdKeyNo ) |
|
643 { |
|
644 NoKeySpecialHandlingL( *keyEvent, EEventKeyDown ); |
|
645 } |
|
646 } |
|
647 break; |
|
648 |
|
649 |
|
650 default: |
|
651 break; |
|
652 } |
|
653 } |
|
654 // All events are sent to base class. |
|
655 CAknAppUi::HandleWsEventL( aEvent, aDestination ); |
|
656 } |
|
657 |
|
658 |
|
659 // --------------------------------------------------------- |
|
660 // CPhoneAppUI::NoKeySpecialHandlingL |
|
661 // Handle no key specific cases. |
|
662 // (other items were commented in a header). |
|
663 // --------------------------------------------------------- |
|
664 // |
|
665 void CPhoneAppUI::NoKeySpecialHandlingL( const TKeyEvent& aEvent, |
|
666 TEventCode aType ) |
|
667 { |
|
668 CEikonEnv& eikEnv = *iEikonEnv; |
|
669 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneAppUI::NoKeySpecialHandling" ); |
|
670 |
|
671 // Handle case where menu bar is opened or a blocking dialog is |
|
672 // displayed and the end key is pressed. HandleKeyEventL will not be |
|
673 // called in this case so it has to be handled here. |
|
674 if ( eikEnv.AppUiFactory()->MenuBar()->IsDisplayed() || |
|
675 iPhoneViewController->BlockingDialogIsDisplayed() ) |
|
676 { |
|
677 // Send key event to the UI controller |
|
678 iPhoneUIController->HandleKeyEventL( aEvent, aType ); |
|
679 } |
|
680 } |
|
681 |
|
682 // --------------------------------------------------------- |
|
683 // CPhoneAppUI::HandleKeyEventL |
|
684 // Handle key events. |
|
685 // (other items were commented in a header). |
|
686 // --------------------------------------------------------- |
|
687 // |
|
688 TKeyResponse CPhoneAppUI::HandleKeyEventL( |
|
689 const TKeyEvent& aKeyEvent, |
|
690 TEventCode aType ) |
|
691 { |
|
692 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneAppUI::HandleKeyEventL" ); |
|
693 // Let key event handler handle event. |
|
694 return iPhoneUIController->HandleKeyEventL( aKeyEvent, aType ); |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // CPhoneAppUI::ProcessCommandL |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 void CPhoneAppUI::ProcessCommandL( TInt aCommand ) |
|
702 { |
|
703 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneAppUI::ProcessCommandL()" ); |
|
704 |
|
705 if( !iPhoneUIController->ProcessCommandL( aCommand ) ) |
|
706 { |
|
707 // State didn't handle the command so pass it up |
|
708 CAknAppUi::ProcessCommandL( aCommand ); |
|
709 } |
|
710 |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CPhoneAppUI::HandleCommandL |
|
715 // |
|
716 // Forwards the request to the main view. |
|
717 // ----------------------------------------------------------------------------- |
|
718 // |
|
719 void CPhoneAppUI::HandleCommandL( TInt aCommand ) |
|
720 { |
|
721 __LOGMETHODSTARTEND( EPhoneControl, "CPhoneAppUI::HandleCommandL()" ); |
|
722 |
|
723 switch (aCommand) |
|
724 { |
|
725 case EEikCmdExit: |
|
726 { |
|
727 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::HandleCommandL -- EEikCmdExit" ); |
|
728 Exit(); |
|
729 } |
|
730 break; |
|
731 default: |
|
732 { |
|
733 if( !iPhoneUIController->HandleCommandL( aCommand ) ) |
|
734 { |
|
735 // State didn't handle the command so pass it up |
|
736 CAknAppUi::HandleCommandL( aCommand ); |
|
737 } |
|
738 } |
|
739 break; |
|
740 } |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CPhoneAppUI::DynInitMenuPaneL |
|
745 // |
|
746 // Forwards the request to the main view. |
|
747 // ----------------------------------------------------------------------------- |
|
748 // |
|
749 void CPhoneAppUI::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
750 { |
|
751 iPhoneUIController->DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
752 } |
|
753 |
|
754 // --------------------------------------------------------- |
|
755 // CPAAppUIS60Base::DynInitMenuBarL |
|
756 // --------------------------------------------------------- |
|
757 // |
|
758 void CPhoneAppUI::DynInitMenuBarL( |
|
759 TInt aResourceId, CEikMenuBar* aMenuBar) |
|
760 { |
|
761 iPhoneUIController->DynInitMenuBarL( aResourceId, aMenuBar ); |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CPhoneAppUI::HandleForegroundEventL |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 void CPhoneAppUI::HandleForegroundEventL( TBool aForeground ) |
|
769 { |
|
770 __PHONELOG1( |
|
771 EBasic, |
|
772 EPhonePhoneapp, |
|
773 "CPhoneAppUI::HandleForegroundEventL( InForeground=%d )", |
|
774 aForeground ); |
|
775 |
|
776 iPhoneUIController->HandleForegroundEventL( aForeground ); |
|
777 |
|
778 CAknAppUi::HandleForegroundEventL( aForeground ); |
|
779 } |
|
780 |
|
781 // ----------------------------------------------------------------------------- |
|
782 // CPhoneAppUI::HandleStatusPaneSizeChange |
|
783 // ----------------------------------------------------------------------------- |
|
784 // |
|
785 void CPhoneAppUI::HandleStatusPaneSizeChange() |
|
786 { |
|
787 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::HandleStatusPaneSizeChange" ); |
|
788 CAknAppUi::HandleStatusPaneSizeChange(); |
|
789 |
|
790 LayoutMainView(); |
|
791 } |
|
792 |
|
793 // ----------------------------------------------------------------------------- |
|
794 // CPhoneAppUI::HandleViewDeactivation |
|
795 // ----------------------------------------------------------------------------- |
|
796 // |
|
797 void CPhoneAppUI::HandleViewDeactivation( |
|
798 const TVwsViewId& aViewIdToBeDeactivated, |
|
799 const TVwsViewId& aNewlyActivatedViewId ) |
|
800 { |
|
801 __PHONELOG2( |
|
802 EBasic, |
|
803 EPhonePhoneapp, |
|
804 "CPhoneAppUI::HandleViewDeactivation( aViewIdToBeDeactivated(%d), aNewlyActivatedViewId(%d) )", |
|
805 aViewIdToBeDeactivated.iViewUid, |
|
806 aNewlyActivatedViewId.iViewUid ); |
|
807 |
|
808 CAknAppUi::HandleViewDeactivation( |
|
809 aViewIdToBeDeactivated, |
|
810 aNewlyActivatedViewId ); |
|
811 } |
|
812 |
|
813 // ----------------------------------------------------------------------------- |
|
814 // CPhoneAppUI::HandleApplicationSpecificEventL |
|
815 // ----------------------------------------------------------------------------- |
|
816 // |
|
817 void CPhoneAppUI::HandleApplicationSpecificEventL( |
|
818 TInt aType, |
|
819 const TWsEvent& aEvent ) |
|
820 { |
|
821 __LOGMETHODSTARTEND( EPhonePhoneapp, "CPhoneAppUI::HandleApplicationSpecificEventL" ); |
|
822 |
|
823 if( aType == EEikKeyLockEnabled ) |
|
824 { |
|
825 iPhoneUIController->HandleKeyLockEnabled( ETrue ); |
|
826 } |
|
827 else if( aType == EEikKeyLockDisabled ) |
|
828 { |
|
829 iPhoneUIController->HandleKeyLockEnabled( EFalse ); |
|
830 } |
|
831 |
|
832 CAknAppUi::HandleApplicationSpecificEventL( aType, aEvent ); |
|
833 } |
|
834 |
|
835 // ----------------------------------------------------------------------------- |
|
836 // CPhoneAppUI::HandleResourceChangeL |
|
837 // ----------------------------------------------------------------------------- |
|
838 // |
|
839 void CPhoneAppUI::HandleResourceChangeL( TInt aType ) |
|
840 { |
|
841 __LOGMETHODSTARTEND( EPhonePhoneapp, "CPhoneAppUI::HandleResourceChangeL" ); |
|
842 |
|
843 CAknAppUi::HandleResourceChangeL( aType ); |
|
844 |
|
845 if ( aType == KAknsMessageSkinChange || |
|
846 aType == KEikDynamicLayoutVariantSwitch ) |
|
847 { |
|
848 LayoutMainView(); |
|
849 iPhoneViewController->HandleResourceChangeL( aType ); |
|
850 } |
|
851 } |
|
852 |
|
853 // --------------------------------------------------------- |
|
854 // CPhoneAppUI::HandleViewActivation |
|
855 // Handles the activation of the view aNewlyActivatedViewId |
|
856 // before the old view |
|
857 // aViewIdToBeDeactivated is to be deactivated. |
|
858 // (other items were commented in a header). |
|
859 // --------------------------------------------------------- |
|
860 // |
|
861 void CPhoneAppUI::HandleViewActivation( |
|
862 const TVwsViewId& /*aNewlyActivatedViewId*/, |
|
863 const TVwsViewId& /*aViewIdToBeDeactivated*/ ) |
|
864 { |
|
865 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::HandleViewActivation" ); |
|
866 } |
|
867 |
|
868 // --------------------------------------------------------- |
|
869 // CPhoneAppUI::HelpContextL |
|
870 // This routine will be called for returning help context |
|
871 // when AppHelpContextL() is called in |
|
872 // CPhoneViewController::LaunchHelpApplicationL() |
|
873 // --------------------------------------------------------- |
|
874 // |
|
875 CArrayFix<TCoeHelpContext>* CPhoneAppUI::HelpContextL() const |
|
876 { |
|
877 CArrayFix<TCoeHelpContext>* result = |
|
878 new(ELeave) CArrayFixFlat<TCoeHelpContext>( 1 ); |
|
879 |
|
880 CleanupStack::PushL( result ); |
|
881 // Get the help context name from the View controller |
|
882 TCoeHelpContext helpContext( KUidPhoneApplication, |
|
883 iPhoneViewController->HelpContext() ); |
|
884 result->AppendL( helpContext ); |
|
885 CleanupStack::Pop( result ); |
|
886 |
|
887 return result; |
|
888 } |
|
889 |
|
890 // ----------------------------------------------------------------------------- |
|
891 // CPhoneAppUi::LayoutMainView |
|
892 // ----------------------------------------------------------------------------- |
|
893 // |
|
894 void CPhoneAppUI::LayoutMainView() |
|
895 { |
|
896 __LOGMETHODSTARTEND( EPhonePhoneapp, "CPhoneAppUI::LayoutMainView" ); |
|
897 iPhoneViewController->HandleLayoutChange( ClientRect() ); |
|
898 } |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // CPhoneAppUi::GetAliasKeyCode |
|
902 // ----------------------------------------------------------------------------- |
|
903 // |
|
904 TInt CPhoneAppUI::GetAliasKeyCode( TUint& aCode, |
|
905 const TKeyEvent& aKeyEvent, |
|
906 TEventCode /*aType*/) |
|
907 { |
|
908 aCode = aKeyEvent.iCode; |
|
909 return KErrNone; |
|
910 } |
|
911 |
|
912 |
|
913 // ----------------------------------------------------------------------------- |
|
914 // CPhoneAppUI::HandleCallBackL |
|
915 // Called when the observed value changes |
|
916 // |
|
917 // Callback function. |
|
918 // ----------------------------------------------------------------------------- |
|
919 // |
|
920 TInt CPhoneAppUI::HandleCallBackL( TAny* aAny ) |
|
921 { |
|
922 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::HandleCallBackL" ); |
|
923 CPhoneAppUI* appUi = |
|
924 static_cast< CPhoneAppUI* >( aAny ); |
|
925 appUi->DoHandleCallBackL(); |
|
926 return KErrNone; |
|
927 } |
|
928 |
|
929 // ----------------------------------------------------------------------------- |
|
930 // CPhoneAppUI::DoHandleCallBackL |
|
931 // Call back to a specific instance. |
|
932 // ----------------------------------------------------------------------------- |
|
933 // |
|
934 void CPhoneAppUI::DoHandleCallBackL() |
|
935 { |
|
936 __PHONELOG( EBasic, EPhonePhoneapp, "CPhoneAppUI::DoHandleCallBackL" ); |
|
937 const TInt change = iEnvChangeNotifier->Change(); |
|
938 HandleEnvironmentChangeL( change ); |
|
939 } |
|
940 |
|
941 // End of File |