coreapplicationuis/SysAp/Src/SysApAppUi.cpp
changeset 48 2222076f5c60
parent 29 6a787171e1de
child 49 76883296a0d5
equal deleted inserted replaced
40:951aeeb3da43 48:2222076f5c60
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  CSysApAppUi implementation.
    14 * Description:  CSysApAppUi implementation.
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 
       
    19 // INCLUDES
    17 // INCLUDES
    20 
    18 
    21 #include <avkon.hrh>
    19 #include <startupdomainpskeys.h>
    22 #include <avkon.rsg>
    20 #include "sysapappui.h"
    23 #include <eikon.hrh>
    21 #include "coreapplicationuisprivatepskeys.h"
    24 #include <apgwgnam.h>
    22 #include <HbDeviceMessageBoxSymbian.h>
    25 #include <eiksrv.h>
    23 //#include <hbdevicepowermenusymbian.h>
    26 #include <eikdll.h>
    24 #include <sacls.h>
    27 #include <AknSmallIndicator.h>
    25 #include <featmgr.h>
    28 #include <AknBatteryNotify.h>
    26 #include <DevEncProtectedPSKey.h>
    29 #include <AknSignalNotify.h>
    27 #include <ctsydomainpskeys.h>
    30 #include <AknGlobalNote.h>
    28 #include <secuisystemlock.h>
    31 #include <AknGlobalListQuery.h>
    29 #include <apgtask.h>
    32 #include <aknsoundsystem.h>
       
    33 #include <apgcli.h>
       
    34 
       
    35 #include <hwrmpowerstatesdkpskeys.h>
    30 #include <hwrmpowerstatesdkpskeys.h>
    36 #include <hwrmdomainpskeys.h>
    31 #include <wlaninternalpskeys.h> 
    37 
    32 #include <HbDeviceNotificationDialogSymbian.h>
    38 #include <PSVariables.h>
    33 //#include <HbDeviceInputDialogSymbian.h>
    39 #include "coreapplicationuisprivatepskeys.h"
    34 #include <hbsymbianvariant.h>
    40 #include <ctsydomainpskeys.h>
    35 #include <UikonInternalPSKeys.h>
    41 #include <startupdomainpskeys.h>
    36 
    42 #include <startupdomaincrkeys.h>
    37 //#include "SysApWsClient.h"
    43 
    38 #include "SysApFeatureManager.h"
    44 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    39 #include "SysApNspsHandler.h"
    45   #include <ASShdAlarm.h>
       
    46 #else
       
    47   #include <asshddefs.h>
       
    48   #include <ASShdAlarmCal.h>
       
    49   #include <asshdalarm.h>
       
    50 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    51 
       
    52 #include <MProfileEngine.h>
       
    53 #include <MProfileName.h>
       
    54 #include <MProfilesNamesArray.h>
       
    55 #include <MProfile.h>
       
    56 #include <StringLoader.h>
       
    57 #include <secuisystemlock.h>
       
    58 #include <secui.h>
       
    59 #include <settingsinternalcrkeys.h>
       
    60 
       
    61 #include <AknNotifierController.h>
       
    62 #include <eikappui.h>
       
    63 #include <es_enum.h>
       
    64 #include <data_caging_path_literals.hrh>
       
    65 #include <eikon.hrh>
       
    66 
       
    67 #include "SysApSimChanged.h"
       
    68 
       
    69 #include <SysAp.rsg>
       
    70 #include "SysApLightsController.h"
       
    71 
       
    72 #include "SysApPubSubObserver.h"
    40 #include "SysApPubSubObserver.h"
    73 #include "SysApProfileObserver.h"
    41 #include "sysapdefaultkeyhandler.h"
    74 
    42 #include "SysApStartupController.h"
       
    43 #include "MSysApOfflineModeController.h"
       
    44 #include "SysApCenRepController.h"
    75 #include "sysapcenreplightsettingsobserver.h"
    45 #include "sysapcenreplightsettingsobserver.h"
    76 #include "SysApCenRepLogsObserver.h"
    46 #include "SysApCenRepLogsObserver.h"
    77 #include "SysApCenRepBTObserver.h"
    47 #include "SysApCenRepBTObserver.h"
    78 #include "SysApCenRepHacSettingObserver.h"
    48 #include "SysApCenRepHacSettingObserver.h"
    79 #include "SysApCenRepController.h"
    49 #include "sysapaudioroutingobserver.h"
    80 #include "coreapplicationuisprivatecrkeys.h"
    50 #include "sysapbatteryinfocontroller.h"
    81 #include "coreapplicationuisprivatepskeys.h"
    51 #include "SysApSimChanged.h"
    82 #include <UikonInternalPSKeys.h>
    52 #include "MSysApBtSapController.h"
    83 
    53 #include "MSysApBtController.h"
    84 #include "SysApStartupController.h"
    54 #include "MSysApUsbIndicator.h"
    85 #include "SysApConnectionMonitorObserver.h"
    55 #include "sysapkeymanagement.h"
    86 #include "SysApPowerKeyMenuObserver.h"
       
    87 #include "SysApSsSettingsObserver.h"
       
    88 #include "SysApAppUi.h"
       
    89 #include "SysApShutdownImage.h"
    56 #include "SysApShutdownImage.h"
    90 #include "SysApEtelConnector.h"
    57 
    91 
    58 #include <settingsinternalcrkeys.h>
    92 #include "SysApApp.h"
    59 #include <keyguardaccessapi.h>
    93 #include "SysApMsgSimMemLowQuery.h"
    60 #include <eikdef.h>
    94 #include "SysApNspsHandler.h"
    61 #include <eikenv.h>
    95 #include "SysApWaitNote.h"
    62 
    96 #include "SysApConfirmationQuery.h"
    63 class CHbSymbianVariant;
    97 #include "SysApFeatureManager.h"
       
    98 #include "SysApSubscriber.h"
       
    99 #include "MSysApOfflineModeController.h"
       
   100 #include "MSysApBtController.h"
       
   101 #include "MSysApBtSapController.h"
       
   102 #include "MSysApLocationPrivacyIndicator.h"
       
   103 #include "MSysApUsbIndicator.h"
       
   104 
       
   105 #include <sysap.mbg>
       
   106 
       
   107 #include "SysApShutdownAnimation.h"
       
   108 
       
   109 //#include <hwrmfmtx.h>
       
   110 //#include <hwrmfmtxdomainpskeys.h>
       
   111 //#include <hwrmfmtxdomaincrkeys.h>
       
   112 //#include "sysapcenrepfmtxobserver.h"
       
   113 
       
   114 #include "SysApKeySndHandler.h"
       
   115 
       
   116 #include <ir_sock.h> // KIrdaPropertyCategory // KIrdaStatus
       
   117 
       
   118 #include <networkhandlingdomainpskeys.h>
       
   119 
       
   120 // POC launching
       
   121 #include <AiwServiceHandler.h>
       
   122 #include <AiwPoCParameters.h>
       
   123 
       
   124 #include <sacls.h>  // KUidPhonePwr
       
   125 
       
   126 #include <wlaninternalpskeys.h>  // WLan indicator
       
   127 
       
   128 #include <ecom/ecom.h>
       
   129 #include "sysapkeymanagement.h"
       
   130 
       
   131 #include "SysApMediatorObserver.h"
       
   132 
       
   133 #include <SecondaryDisplay/SecondaryDisplaySysApAPI.h>
       
   134 #include "aknSDData.h"
       
   135 
       
   136 #include <AknTaskList.h>
       
   137 #include <layoutmetadata.cdl.h>
       
   138 
       
   139 #include "sysapdefaultkeyhandler.h"
       
   140 #include "sysapaudioroutingobserver.h"
       
   141 #include "sysapcenrepcallforwardingobserver.h"
       
   142 #include "sysapcenrepmsgwaitingobserver.h"
       
   143 
       
   144 #ifdef RD_MULTIPLE_DRIVE
       
   145  #include "sysapdrivelist.h"
       
   146  #include "sysapdriveunlockhandler.h"
       
   147  #include "sysapdriveejecthandler.h"
       
   148 #endif // RD_MULTIPLE_DRIVE
       
   149 
       
   150 #include "sysappsmcontroller.h"
       
   151 #include "sysapbatteryinfocontroller.h"
       
   152 
       
   153 #include <keylockpolicyapi.h>
       
   154 
       
   155 #include <UsbWatcherInternalPSKeys.h> // USB transfer modes
       
   156 #include <usbpersonalityids.h>
       
   157 #include <smsuaddr.h>
       
   158 #include <featmgr.h>
       
   159 #include <DevEncProtectedPSKey.h>
       
   160 
       
   161 // CONSTANTS
       
   162 const TInt KPowerKeyMenuSelectionCancelled( -1 );
       
   163 const TInt KPowerKeyMenuSelectionSwitchOff( 0 );
       
   164 const TInt KModifierMask( 0 );
    64 const TInt KModifierMask( 0 );
   165 const TInt KDelayBeforeShuttingDownInAlarmAndChargingStates( 500000 );
       
   166 const TInt KDelayBeforeShowingGprsSuspendedNote( 500000 );
       
   167 const TInt KDelayBeforeNextScanningRound( 1000000 );
       
   168 const TInt KActiveProfile( 0 ); //The value of ActiveProfile for accessory default profile selection in GS/SD.
       
   169 const TInt KProfileListInitialIndex( 0 );
       
   170 const TInt KMaxProfileNameLength( 64 );
       
   171 const TInt KTimeToShowShutdownNote( 2000000 ); //2 seconds time for Goodbye note to show before being shutdown
       
   172 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   173 const TInt KCoefficientToMakeMicroToMilliSeconds = 1000;
       
   174 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   175 
       
   176 /* ENABLE ANIMATION: Add id of background image.
       
   177    Example: const TInt KBackgroundImageID = EMbmSysapQgn_graf_startup_bg;
       
   178    If there is no image defined, clear screen is used.*/
       
   179 const TInt KBackgroundImageID = 0;
       
   180 #ifndef RD_MULTIPLE_DRIVE
       
   181 const TInt32 KAutolockAppUid = 0x100059B5;
       
   182 const TInt KFileManagerAppUid = 0x101F84EB;
       
   183 #endif // RD_MULTIPLE_DRIVE
       
   184 const TInt KCoefficientKhzToMhz = 1000;
       
   185 const TInt KDecimalsInMhzFrequency = 2;
       
   186 
       
   187 _LIT_SECURITY_POLICY_PASS(KAlwaysPassPolicy);
    65 _LIT_SECURITY_POLICY_PASS(KAlwaysPassPolicy);
   188 _LIT_SECURITY_POLICY_C1(KWriteDeviceDataPolicy, ECapabilityWriteDeviceData);
    66 _LIT_SECURITY_POLICY_C1(KWriteDeviceDataPolicy, ECapabilityWriteDeviceData);
       
    67 const TInt KDelayBeforeNextScanningRound( 1000000 );
   189 
    68 
   190 // ============================ MEMBER FUNCTIONS ==============================
    69 // ============================ MEMBER FUNCTIONS ==============================
   191 
    70 
   192 // ----------------------------------------------------------------------------
    71 // ----------------------------------------------------------------------------
   193 // CSysApAppUi::CSysApAppUi()
    72 // CSysApAppUi::CSysApAppUi()
   194 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
   195 
    74 
   196 CSysApAppUi::CSysApAppUi() :
    75 CSysApAppUi::CSysApAppUi()
   197     iSysApCenRepLogsObserver( NULL ),
    76     :iSysApShutdownImage(NULL),
   198     iSysApCenRepHacSettingObserver( NULL ),
    77      iPowerMenuDialog(NULL),
   199     iSysApPowerKeyMenuObserver( NULL ),
    78      iDeviceLockEnabled(EFalse),
   200     iSysApShutdownImage( NULL ),
    79      iKeyLockEnabled(EFalse),
   201     iSysApConfirmationQuery( NULL ),
    80      iPowerKeyPopupMenuActive(EFalse),
   202     iSysApConfirmationQueryForRestart( NULL ),
    81      iResourcesFreed (EFalse),
   203     iSignalNotify( NULL ),
    82      iShutdownStarted (EFalse),
   204 #ifndef RD_MULTIPLE_DRIVE
    83      iSysApAudioRoutingObserver (NULL),
   205     iMemoryCardDialog( 0 ),
    84      iSysApBatteryInfoController (NULL),
   206 #endif // RD_MULTIPLE_DRIVE
    85      iSysApPsmController(NULL),
   207     iProfileNote( NULL ),
    86      iSapTimer (NULL),
   208     iProfileNoteId( 0 ),
    87      iSysApCenRepLogsObserver (NULL),
   209     iPowerKeyPopupMenuActive( EFalse ),
    88      iSysApUsbIndicatorController(NULL),
   210     iDisablePowerkeyMenu( EFalse ),
    89      iKeyguardController (NULL),
   211     iDeviceLockEnabled( EFalse ),
    90      iKeyLockOnBeforeCall (EFalse),
   212     iKeyLockEnabled( EFalse ),
    91      iCheckLongPowerKeyEvent (EFalse)
   213     iShowkeypadActivatedNoteAfterSoftReject( EFalse ),
    92 	{
   214     iEmergencyCallActive( EFalse ),
    93 	TRACES( RDebug::Print( _L("CSysApAppUi::CSysApAppUi()") ) );
   215     iSimChangedDone( EFalse ),
       
   216     iResourcesFreed( EFalse ),
       
   217 #ifndef RD_MULTIPLE_DRIVE
       
   218     iHideFirstBeep( ETrue ),
       
   219 #endif // RD_MULTIPLE_DRIVE
       
   220     iShutdownStarted( EFalse ),
       
   221     iIgnoreAccessorySpecificProfileChanges( ETrue ),
       
   222     iAccessoryJustConnected( EFalse ),
       
   223     iHandleNextProfileEvent( ETrue ),
       
   224     iActivateBt( EFalse ),
       
   225     iDeactivateBt( EFalse ),
       
   226     iGprsActivated( EFalse ),
       
   227     iGprsSuspended( EFalse ),
       
   228     iCallActivated( EFalse ),
       
   229     iGprsSuspendedNoteShown( EFalse ),
       
   230     iMMCEjectUsed( EFalse ),
       
   231 #ifndef RD_MULTIPLE_DRIVE
       
   232     iMMCPowerMenuEjectUsed( EFalse ),
       
   233     iMMCInserted( EFalse ),
       
   234 #endif // RD_MULTIPLE_DRIVE
       
   235     iTimer( NULL ),
       
   236     iSapTimer( NULL ),
       
   237 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   238     iAnimTimer( NULL ),
       
   239 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   240     iSysApTimer( NULL ),
       
   241 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   242     iAnimationShowingTime( 0 ),
       
   243 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   244     iShutdownContinued( EFalse ),
       
   245     iSysApAudioRoutingObserver( NULL ),
       
   246     iSysApCenRepCallForwardingObserver( NULL ),
       
   247     iSysApCenRepMsgWaitingObserver( NULL ),
       
   248 	iKeyBoardRepeatCount(-1)
       
   249     {
       
   250     TRACES( RDebug::Print( _L("CSysApAppUi::CSysApAppUi()") ) );
       
   251     }
    94     }
   252 
    95 
   253 // ----------------------------------------------------------------------------
    96 // ----------------------------------------------------------------------------
   254 // CSysApAppUi::ConstructL()
    97 // CSysApAppUi::ConstructL()
   255 // ----------------------------------------------------------------------------
    98 // ----------------------------------------------------------------------------
   256 
    99 
   257 void CSysApAppUi::ConstructL()
   100 void CSysApAppUi::ConstructL()
   258     {
   101     {
   259     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: START") ) );
   102     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: START") ) );
   260     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying BaseConstructL( EAknEnableSkin )") ) );
   103     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying BaseConstructL()") ) );
   261     BaseConstructL( EAknEnableSkin );
   104     BaseConstructL();
   262     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: BaseConstructL() OK") ) );
   105     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: BaseConstructL() OK") ) );
   263     
   106 
   264    
       
   265 
       
   266     /*SysAp is set as system application (Symbian terminology). This means some special privilege compared
       
   267       to other applications. For example it does not get closed when system is asked to close applications
       
   268     */
       
   269     iEikonEnv->SetSystem( ETrue );
   107     iEikonEnv->SetSystem( ETrue );
   270 
   108 
   271     iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
   109     iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled );
   272 
   110     
   273     static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PushContextL( R_AVKON_SILENT_SKEY_LIST );
       
   274 
       
   275     RThread().SetProcessPriority( EPriorityForeground );
   111     RThread().SetProcessPriority( EPriorityForeground );
   276 
   112     
   277     /*SysAp does not have any visible Status pane. An exception will be Charging state
       
   278     where SysAp shows Status Pane as it is the only running application.
       
   279     */
       
   280     TInt mode;
   113     TInt mode;
   281     User::LeaveIfError( RProperty::Get( KPSUidStartup, KPSGlobalStartupMode, mode ) );
   114     User::LeaveIfError( RProperty::Get( KPSUidStartup, KPSGlobalStartupMode, mode ) );
   282 
   115     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: KPSGlobalStartupMode = %d"), mode ) );
   283     if( mode == EStartupModeCharging || mode == EStartupModeAlarm )
   116     
   284         {
   117     //SysAp needs to capture PowerKey events because it handles all functionality related to that
   285         SetStatusPaneLayoutL(
   118     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CEikApplication::RootWin()") ) );
   286             mode == EStartupModeCharging ? ESysApCharging : ESysApAlarm );
   119     RWindowGroup groupWin = iCoeEnv->RootWin();
   287 
   120     User::LeaveIfError ( iCapturedEKeyPowerOff = groupWin.CaptureKey( EKeyPowerOff, KModifierMask, KModifierMask ) );
   288         SetKeyEventFlags(
   121     User::LeaveIfError ( iCapturedEKeyPowerOffUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyDevice2, KModifierMask, KModifierMask ) );
   289             CAknAppUiBase::EDisableSendKeyShort |
   122      
   290             CAknAppUiBase::EDisableSendKeyLong );
   123     TRACES ( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApDefaultKeyHandler::NewL()") ) );
   291         }
   124     iSysApDefaultKeyHandler = CSysApDefaultKeyHandler::NewL(*this);
   292     else
   125     
   293         {
       
   294         SetStatusPaneLayoutL( ESysApNormal );
       
   295         }
       
   296 
       
   297     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApFeatureManager::NewL()") ) );
       
   298     iSysApFeatureManager = CSysApFeatureManager::NewL();
       
   299 
       
   300     // Setup USB charging detector
       
   301     iSysApUsbChargerDetector.EnableUsbCharging(
       
   302         iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) &&
       
   303         iSysApFeatureManager->Supported( KSysApFeatureIdUsbChargingWithoutReminderNotes ) );
       
   304 
       
   305     // Construct notifiers that are used frequently or in OOM situations.
       
   306     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CAknBatteryNotify::NewL()") ) );
       
   307     iBatteryNotify = CAknBatteryNotify::NewL();
       
   308     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CAknSignalNotify::NewL()") ) );
       
   309     iSignalNotify = CAknSignalNotify::NewL();
       
   310     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying new ( ELeave ) CSysApMsgSimMemLowQuery") ) );
       
   311     iSysApMsgSimMemLowQuery = new( ELeave ) CSysApMsgSimMemLowQuery( iSysApFeatureManager->CoverDisplaySupported() );
       
   312 
       
   313     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApPubSubObserver::NewL()") ) );
       
   314     iSysApPubSubObserver = CSysApPubSubObserver::NewL( *this );
       
   315     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsPoCIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   316     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPoCIndicator, ECoreAppUIsPocIndicatorUninitialized );
       
   317     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsPoCMissedIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   318     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPoCMissedIndicator, ECoreAppUIsPocMissedIndicatorUninitialized );
       
   319     
       
   320     // initial value won't be set to KCoreAppUIsUSBFileTransfer, because UsbMscPersonality-plugin may also define it if USB cable is connected during boot
       
   321     // remove this definition after all clients have taken the USB personality ids in use
       
   322     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsUSBFileTransfer, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   323     
       
   324     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   325     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator, ECoreAppUIsVideoSharingIndicatorUninitialized );
       
   326 
       
   327     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApAccessoryObserver::NewL()") ) );
       
   328     iSysApAccessoryObserver = CSysApAccessoryObserver::NewL( *this );
       
   329 
       
   330     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepController::NewL()") ) );
       
   331     iSysApCenRepController = CSysApCenRepController::NewL();
       
   332 
       
   333     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepLightSettingsObserver::NewL") ) );
       
   334     iSysApCenRepLightSettingsObserver = CSysApCenRepLightSettingsObserver::NewL( *this );
       
   335 
       
   336     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepBtObserver::NewL") ) );
       
   337     iSysApCenRepBtObserver = CSysApCenRepBtObserver::NewL( *this );
       
   338 
       
   339 /*    if ( iSysApFeatureManager->FmTxSupported() )
       
   340         {
       
   341         TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepFmTxObserver::NewL") ) );        
       
   342         iSysApCenRepFmTxObserver = CSysApCenRepFmTxObserver::NewL( *this );    
       
   343         }
       
   344 */
       
   345     // Define P&S keys "owned" by SysAp
   126     // Define P&S keys "owned" by SysAp
   346     RProperty::Define( KPSUidUikon, KUikMMCInserted, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   127     RProperty::Define( KPSUidUikon, KUikMMCInserted, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   347     //initially assuming that the memory card is not inserted
   128     //initially assuming that the memory card is not inserted
   348     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
   129     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
   349     TDriveInfo driveInfo;
   130     TDriveInfo driveInfo;
   350     TInt driveNumber; 
   131     TInt driveNumber; 
   351     TInt err;    
   132     TInt err;    
   352     RFs& fileServer = iEikonEnv->FsSession();  
   133     RFs& fileServer = iEikonEnv->FsSession();  
   353     for ( driveNumber = EDriveD; driveNumber < EDriveZ; driveNumber++ )
   134     for ( driveNumber = EDriveD; driveNumber < EDriveZ; driveNumber++ )
   354          {
   135          {
   355 	  err = fileServer.Drive(driveInfo,driveNumber);
   136       err = fileServer.Drive(driveInfo,driveNumber);
   356           if(driveNumber == EDriveF && err == KErrNone && driveInfo.iType == EMediaHardDisk &&  driveInfo.iDriveAtt & KDriveAttRemovable)     
   137           if(driveNumber == EDriveF && err == KErrNone && driveInfo.iType == EMediaHardDisk &&  driveInfo.iDriveAtt & KDriveAttRemovable)     
   357         	{     
   138             {     
   358         	TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: err = %d, driveInfo.iType = %d, driveInfo.iDriveAtt %d, KDriveAttRemovable = %d "),err,driveInfo.iType,driveInfo.iDriveAtt,KDriveAttRemovable) );     
   139             TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: err = %d, driveInfo.iType = %d, driveInfo.iDriveAtt %d, KDriveAttRemovable = %d "),err,driveInfo.iType,driveInfo.iDriveAtt,KDriveAttRemovable) );     
   359         	RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
   140             RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
   360                 break;  // Memory card drive found...     
   141                 break;  // Memory card drive found...     
   361       		}
   142             }
   362          } 
   143          }
       
   144            
       
   145     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApFeatureManager::NewL()") ) );
       
   146     iSysApFeatureManager = CSysApFeatureManager::NewL();
       
   147     
       
   148     // Setup USB charging detector
       
   149      iSysApUsbChargerDetector.EnableUsbCharging(
       
   150          iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) &&
       
   151          iSysApFeatureManager->Supported( KSysApFeatureIdUsbChargingWithoutReminderNotes ) );
       
   152     
       
   153     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApPubSubObserver::NewL()") ) );
       
   154     iSysApPubSubObserver = CSysApPubSubObserver::NewL( *this );
       
   155 
       
   156     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsPoCIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   157     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPoCIndicator, ECoreAppUIsPocIndicatorUninitialized );
       
   158     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsPoCMissedIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   159     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPoCMissedIndicator, ECoreAppUIsPocMissedIndicatorUninitialized );
       
   160     
       
   161     // initial value won't be set to KCoreAppUIsUSBFileTransfer, because UsbMscPersonality-plugin may also define it if USB cable is connected during boot
       
   162     // remove this definition after all clients have taken the USB personality ids in use
       
   163     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsUSBFileTransfer, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   164     
       
   165     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
       
   166     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsVideoSharingIndicator, ECoreAppUIsVideoSharingIndicatorUninitialized );
   363 
   167 
   364     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   168     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   365     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsDisableKeyguard, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   169     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsDisableKeyguard, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   366     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsSoftReject, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   170     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsSoftReject, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   367     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsUipInd, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   171     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsUipInd, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   379     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsMtvDvbhStatus, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   183     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsMtvDvbhStatus, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   380     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   184     RProperty::Define( KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   381 
   185 
   382     // Initialize P&S keys "owned" by SysAp
   186     // Initialize P&S keys "owned" by SysAp
   383     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, ECoreAppUIsHideAlarmUninitialized );
   187     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, ECoreAppUIsHideAlarmUninitialized );
   384 
   188     
       
   189     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApAccessoryObserver::NewL()") ) );
       
   190     iSysApAccessoryObserver = CSysApAccessoryObserver::NewL( *this );
       
   191     
       
   192     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepController::NewL()") ) );
       
   193     iSysApCenRepController = CSysApCenRepController::NewL();
       
   194     
       
   195     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepLightSettingsObserver::NewL") ) );
       
   196     iSysApCenRepLightSettingsObserver = CSysApCenRepLightSettingsObserver::NewL( *this );
       
   197     
       
   198     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApCenRepBtObserver::NewL") ) );
       
   199     iSysApCenRepBtObserver = CSysApCenRepBtObserver::NewL( *this );
       
   200     
   385     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApStartupController::NewL()") ) );
   201     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApStartupController::NewL()") ) );
   386     iSysApStartupController = CSysApStartupController::NewL( *this, iSysApFeatureManager->OfflineModeSupported() );
   202     iSysApStartupController = CSysApStartupController::NewL( *this, iSysApFeatureManager->OfflineModeSupported() );
   387 
   203 
       
   204     iActiveProfileBeforeOfflineMode = iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode );    
       
   205            
       
   206     iSysApFeatureManager->FeatureVariationCheckDone();        
       
   207     
   388     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApLightsController::NewL()") ) );
   208     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApLightsController::NewL()") ) );
   389     iSysApLightsController = CSysApLightsController::NewL( *this,
   209     iSysApLightsController = CSysApLightsController::NewL( *this,
   390                                                            iSysApCenRepLightSettingsObserver->GetLightsTimeout(),
   210                                                            iSysApCenRepLightSettingsObserver->GetLightsTimeout(),
   391                                                            iSysApFeatureManager->CoverDisplaySupported() );
   211                                                            iSysApFeatureManager->CoverDisplaySupported() );
   392 
   212             
   393     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApEtelConnector::NewL()") ) );
       
   394     iSysApEtelConnector = CSysApEtelConnector::NewL( *this );
       
   395 
       
   396     //SysAp needs to capture PowerKey events because it handles all functionality related to that
       
   397     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CEikApplication::RootWin()") ) );
       
   398     RWindowGroup groupWin = iCoeEnv->RootWin();
       
   399     User::LeaveIfError ( iCapturedEKeyPowerOff = groupWin.CaptureKey( EKeyPowerOff, KModifierMask, KModifierMask ) );
       
   400     User::LeaveIfError ( iCapturedEKeyPowerOffUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyDevice2, KModifierMask, KModifierMask ) );
       
   401 
       
   402     TRACES ( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApDefaultKeyHandler::NewL()") ) );
       
   403     iSysApDefaultKeyHandler = CSysApDefaultKeyHandler::NewL( *this );
       
   404 
       
   405 
       
   406     if ( iSysApFeatureManager->GripNotSupported() )
       
   407         {
       
   408         RProperty::Set( KPSUidHWRM, KHWRMGripStatus, EPSHWRMGripOpen );
       
   409         }
       
   410 
       
   411 #ifndef RD_MULTIPLE_DRIVE
       
   412     if ( iSysApFeatureManager->MmcSupported() )
       
   413         {
       
   414         iSysApMMCObserver = CSysApMMCObserver::NewL( this, &iEikonEnv->FsSession(), iSysApFeatureManager->MmcHotSwapSupported() );
       
   415         }
       
   416 #else // RD_MULTIPLE_DRIVE
       
   417     iSysApDriveList = CSysApDriveList::NewL( iEikonEnv->FsSession() );
       
   418     if ( iSysApFeatureManager->MmcSupported() )
       
   419         {
       
   420         iSysApMMCObserver = CSysApMMCObserver::NewL(
       
   421             iEikonEnv->FsSession(), *iSysApDriveList, *this, iSysApFeatureManager->MmcHotSwapSupported() );
       
   422         iSysApDriveUnlockHandler = CSysApDriveUnlockHandler::NewL(
       
   423             *iSysApDriveList, *this, iSysApFeatureManager->MemoryCardLockSupported() );
       
   424         iSysApDriveEjectHandler = CSysApDriveEjectHandler::NewL(
       
   425             *iSysApDriveList, *this, iEikonEnv->FsSession() );
       
   426         }
       
   427 #endif // RD_MULTIPLE_DRIVE
       
   428 
       
   429     //Instantiate the KEF plugin manager
       
   430 	//Trap constuction, since Sysap may live without iSysApKeyManagement
       
   431     TRAPD(keyManagementErr, iSysApKeyManagement=CSysApKeyManagement::NewL(CCoeEnv::Static()->RootWin(), *this));
       
   432 
       
   433     if (keyManagementErr)
       
   434     	{
       
   435     	TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : CSysApKeyManagement::NewL returns error=%d"), keyManagementErr ) );
       
   436     	}
       
   437 
       
   438     iSysApFeatureManager->FeatureVariationCheckDone();
       
   439 
       
   440     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApProfileObserver::NewL()") ) );
       
   441     iSysApProfileObserver = CSysApProfileObserver::NewL( *this );
       
   442 
       
   443     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying MProfileEngine* CreateProfileEngineL()") ) );
       
   444     iProfileEngine = CreateProfileEngineL( &( iEikonEnv->FsSession() ) );
       
   445 
       
   446     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying CreateSysApOfflineModeControllerL()") ) );
   213     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying CreateSysApOfflineModeControllerL()") ) );
   447     iSysApOfflineModeController = CreateSysApOfflineModeControllerL( *this );
   214     iSysApOfflineModeController = CreateSysApOfflineModeControllerL( *this );
   448 
   215     
   449     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying DoInitialSwStateCheckL()") ) );
   216     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : trying DoInitialSwStateCheckL()") ) );
   450     iSysApStartupController->DoInitialSwStateCheckL();
   217     iSysApStartupController->DoInitialSwStateCheckL();
   451 
   218     
   452     iActiveProfileBeforeOfflineMode = iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode );
   219     TRACES( RDebug::Print( _L("CCSysApAppUi::ConstructL  trying CSysApCenRepHacSettingObserver::NewL") ) );
   453 
   220     iSysApCenRepHacSettingObserver = CSysApCenRepHacSettingObserver::NewL( *this ); 
   454     // Initialize animdll for handling side volume keys
   221     
   455     // (needed before normal mode in case emergency number is dialed from PIN query)
   222     //Instantiate the KEF plugin manager
   456     iSysApKeySndHandler = CSysApKeySndHandler::NewL(iEikonEnv->WsSession());
   223     //Trap constuction, since Sysap may live without iSysApKeyManagement
   457 
   224     TRAPD(keyManagementErr, iSysApKeyManagement=CSysApKeyManagement::NewL(CCoeEnv::Static()->RootWin(), *this));
   458     // Initialize shutdown image (needed by nspshandler)
   225 
       
   226     if (keyManagementErr)
       
   227         {
       
   228         TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL : CSysApKeyManagement::NewL returns error=%d"), keyManagementErr ) );
       
   229         }
       
   230     
       
   231     iKeyguardController = CKeyguardAccessApi::NewL();
   459     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApShutdownImage::NewL()") ) );
   232     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApShutdownImage::NewL()") ) );
   460     iSysApShutdownImage = CSysApShutdownImage::NewL();
   233     iSysApShutdownImage = CSysApShutdownImage::NewL();//NULL; //
   461 
   234     
   462     // Initialize nsps handler. Needed for proper lights control during PIN query.
   235     RProperty::Define( KPSUidCoreApplicationUIs,KCoreAppUIsPowerMenuCustomDialogStatus, RProperty::EInt, KAlwaysPassPolicy, KWriteDeviceDataPolicy );
   463     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: trying CSysApNspsHandler::NewL") ) );
   236     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsPowerMenuCustomDialogStatus, ECoreAppUIsPowerMenuCustomDialogUninitialized );
   464     iSysApNspsHandler = CSysApNspsHandler::NewL( iEikonEnv->WsSession(), iSysApShutdownImage->ShutdownCoeControlWindow() );
   237     
   465 
   238     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: END") ) );    
   466 #ifdef RD_LIGHT_CONTROL_CHANGE
   239     }
   467     // NSPS Plugin has been loaded, inform lights controller that in can activate key event forwarding
   240 
   468     iSysApLightsController->KeyEventForwardingReady();
   241 // ----------------------------------------------------------------------------
   469 #endif // RD_LIGHT_CONTROL_CHANGE    
   242 // CSysApAppUi::FreeResources()
   470 
   243 // ----------------------------------------------------------------------------
   471     // Create HAC setting observer now because telephony state may change before entering to normal state
   244 
   472     TRACES( RDebug::Print( _L("CCSysApAppUi::ConstructL  trying CSysApCenRepHacSettingObserver::NewL") ) );
   245 void CSysApAppUi::FreeResources()
   473     iSysApCenRepHacSettingObserver = CSysApCenRepHacSettingObserver::NewL( *this );
   246     {
   474 
   247     TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources") ) );
   475     TRACES( RDebug::Print( _L("CSysApAppUi::ConstructL: END") ) );
   248     delete iSysApBatteryInfoController;
   476     }
   249     delete iSysApPsmController;
   477 
   250     delete iSysApAudioRoutingObserver;
   478 // ----------------------------------------------------------------------------
   251 
   479 // CSysApAppUi::~CSysApAppUi()
   252     if ( iSapTimer )
   480 // ----------------------------------------------------------------------------
   253         {
       
   254         iSapTimer->Cancel();
       
   255         delete iSapTimer;
       
   256         }
       
   257     //Powermenu
       
   258     if (iPowerMenuDialog!=NULL)
       
   259         {
       
   260         //PowerMenu already exist
       
   261         delete iPowerMenuDialog;
       
   262         iPowerMenuDialog = NULL;
       
   263         }
       
   264     
       
   265     RWindowGroup groupWin = iCoeEnv->RootWin();
       
   266     groupWin.CancelCaptureKey( iCapturedEKeyPowerOff );
       
   267     groupWin.CancelCaptureKeyUpAndDowns( iCapturedEKeyPowerOffUpAndDowns );
       
   268     
       
   269     delete iSysApDefaultKeyHandler;
       
   270     delete iSysApCenRepLightSettingsObserver;
       
   271     delete iSysApCenRepBtObserver;
       
   272     delete iSysApCenRepHacSettingObserver;
       
   273     delete iSysApCenRepController;
       
   274 
       
   275     delete iSysApPubSubObserver;
       
   276     
       
   277     delete iSysApLightsController;
       
   278     delete iSysApFeatureManager;
       
   279     
       
   280     delete iSysApCenRepLogsObserver;
       
   281     delete iSysApOfflineModeController;
       
   282     
       
   283     delete iSysApUsbIndicatorController;
       
   284     delete iKeyguardController;
       
   285     
       
   286     delete iSysApKeyManagement;
       
   287     iSysApKeyManagement = NULL;
       
   288     
       
   289     REComSession::FinalClose();
       
   290     iResourcesFreed = ETrue;
       
   291     TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources:END") ) );
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // CStartupAppUi::PrepareToExit()
       
   296 // ---------------------------------------------------------------------------
       
   297 void CSysApAppUi::PrepareToExit()
       
   298     {
       
   299     TRACES("CSysApAppUi::PrepareToExit()");
       
   300     CEikAppUi::PrepareToExit();
       
   301     }
       
   302 
       
   303 
       
   304 // ----------------------------------------------------------------------------
       
   305 // CSysApAppUi::StateOfProperty()
       
   306 // ----------------------------------------------------------------------------
       
   307 TInt CSysApAppUi::StateOfProperty( const TUid& aCategory, const TUint aKey ) const
       
   308     {
       
   309     TInt err( KErrNone );
       
   310     TInt value( 0 );
       
   311     err = RProperty::Get( aCategory, aKey, value );
       
   312     if ( err )
       
   313         {
       
   314         TRACES( RDebug::Print( _L("CSysApAppUi::StateOfProperty. RProperty::Get: err=%d"), err ) );
       
   315         return err;
       
   316         }
       
   317     return value;
       
   318     }
       
   319 
       
   320 // ----------------------------------------------------------------------------
       
   321 // CSysApAppUi::OfflineModeActive()
       
   322 // ----------------------------------------------------------------------------
       
   323 TBool CSysApAppUi::OfflineModeActive()
       
   324     {
       
   325     if(iSysApOfflineModeController)
       
   326         {
       
   327         return iSysApOfflineModeController->OfflineModeActive();
       
   328         }
       
   329     else
       
   330         {
       
   331         return EFalse;
       
   332         }
       
   333     }
       
   334 
       
   335 // ----------------------------------------------------------------------------
       
   336 // CSysApAppUi::GoOnlineL()
       
   337 // ----------------------------------------------------------------------------
       
   338 
       
   339 void CSysApAppUi::GoOnlineL( TBool /* aDoProfileChange */ )
       
   340     {
       
   341     if ( iSysApFeatureManager->OfflineModeSupported() )
       
   342         {
       
   343 //        TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: going from off-line into on-line: aDoProfileChange=%d" ), aDoProfileChange ) );
       
   344         iActivateBt = iSysApOfflineModeController->MustBtBeActivated();
       
   345         iSysApOfflineModeController->SwitchFromOfflineToOnlineModeL();
       
   346         TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: iActivateBt = %d" ), iActivateBt ) );
       
   347         }
       
   348     }
       
   349 
       
   350 // ----------------------------------------------------------------------------
       
   351 // CSysApAppUi::GoOfflineL()
       
   352 // ----------------------------------------------------------------------------
       
   353 
       
   354 void CSysApAppUi::GoOfflineL()
       
   355     {
       
   356     if ( iSysApFeatureManager->OfflineModeSupported() )
       
   357         {
       
   358         TRACES( RDebug::Print( _L("CSysApAppUi::GoOfflineL" ) ) );
       
   359         iDeactivateBt = ETrue;
       
   360         iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
       
   361         }
       
   362     }
       
   363 
       
   364 #ifndef SYSAP_USE_STARTUP_UI_PHASE
       
   365 // need to configure the above macro.
       
   366 #else // SYSAP_USE_STARTUP_UI_PHASE
       
   367 
       
   368 // ----------------------------------------------------------------------------
       
   369 // CSysApAppUi::HandleUiReadyAfterBootL()
       
   370 // Called when startup UI activities has been finished
       
   371 // ----------------------------------------------------------------------------
       
   372 
       
   373 void CSysApAppUi::HandleUiReadyAfterBootL()
       
   374     {
       
   375     TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL" ) ) );    
       
   376     TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
       
   377 
       
   378     UpdateBatteryBarsL( state );   
       
   379     DoSwStateNormalConstructionL();
       
   380     HandleAccessoryProfileInStartupL();
       
   381 
       
   382     if ( iSysApPsmController )
       
   383         {
       
   384         if ( iCharging ) // if charger is connected on boot PSM queries may need to be shown
       
   385             {
       
   386             HandleChargingStatusL( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
       
   387             }
       
   388         }
       
   389     
       
   390     TInt batteryStatus = StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryStatus );
       
   391     TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d" ), batteryStatus ) );
       
   392     if(  batteryStatus == EBatteryStatusLow || batteryStatus == EBatteryStatusEmpty )
       
   393         {
       
   394         // low and empty battery states are informed to the user in device startup
       
   395         HandleBatteryStatusL( batteryStatus );
       
   396         }
       
   397     else if ( iSysApPsmController && !iCharging )
       
   398         {
       
   399             TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d, iCharging %d -> disable partial psm" ), batteryStatus, iCharging ) );
       
   400 
       
   401             iSysApPsmController->BatteryLow( EFalse );
       
   402             iSysApPsmController->DoEnablePartialPsm( EFalse );
       
   403         }
       
   404     
       
   405     if ( ! iSysApUsbIndicatorController )
       
   406         {
       
   407         TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
       
   408         if ( usbErr )
       
   409             {
       
   410             TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: error in constructing USB ind. controller %d" ), usbErr ) );
       
   411             }
       
   412         }
       
   413    }
       
   414 
       
   415 // ----------------------------------------------------------------------------
       
   416 // CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
       
   417 // This method is not called after boot has finished.
       
   418 // ----------------------------------------------------------------------------
       
   419 
       
   420 void CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
       
   421     {
       
   422     TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: %d" ), aSwState ) );
       
   423 
       
   424     TRAPD( simChangedErr, DoSimChangedFromPreviousBootL() );
       
   425     TRACES( RDebug::Print( _L("CSysApAppUi::DoStateChangedL: simChangedErr = %d" ), simChangedErr ) );
       
   426     simChangedErr = simChangedErr; // suppress 'variable not used' warning
       
   427     LogsObserverL().HandleSimChangedCheckDoneL();
       
   428 
       
   429     if ( iSysApFeatureManager->PowerSaveSupported() )
       
   430         {
       
   431         // create controller before checking battery state, so that power saving can be enabled during boot if needed
       
   432         if ( !iSysApPsmController ) // created only in first state change
       
   433             {
       
   434             iSysApPsmController = CSysApPsmController::NewL( *this );        
       
   435             }
       
   436 
       
   437         // in charger boot explicitly disable partial power save mode
       
   438         if ( aSwState == RStarterSession::ECharging )
       
   439             {
       
   440             iSysApPsmController->ChargerConnected();
       
   441             iSysApPsmController->DoEnablePartialPsm( EFalse ); // disable partial power save now
       
   442             }
       
   443         }
       
   444 
       
   445     if ( aSwState == RStarterSession::ECharging || aSwState == RStarterSession::EAlarm )
       
   446         {
       
   447         TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
       
   448         //Also Charging status will be updated with the following function.
       
   449         UpdateBatteryBarsL( state );    
       
   450         }
       
   451         
       
   452     if( IsStateNormal() )
       
   453         {
       
   454         TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
       
   455 
       
   456         iSysApBtController = CreateSysApBtControllerL( *this );
       
   457         iSysApBtSapController = CreateSysApBtSapControllerL( *this );
       
   458 
       
   459         if ( iActivateBt )
       
   460             {
       
   461             TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Activating BT" ) ) );
       
   462             SetBtPowerState( ETrue );
       
   463             }
       
   464 
       
   465         if ( iDeactivateBt )
       
   466             {
       
   467             TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Deactivating BT" ) ) );
       
   468             SetBtPowerState( EFalse );
       
   469             }
       
   470 
       
   471         if ( !StarterSession().Handle() )
       
   472             {
       
   473             User::Leave( KErrBadHandle );
       
   474             }
       
   475 
       
   476 /*        if ( !KeyLock().Handle() )
       
   477             {
       
   478             User::Leave( KErrBadHandle );
       
   479             }
       
   480 */
       
   481 #ifdef __SYSAP_MODULE_TEST
       
   482         ModuleTestShowUiNoteL( _L("SysAp: SW state normal!") );
       
   483 #endif
       
   484         }
       
   485 
       
   486     // Allow lights
       
   487     iSysApLightsController->AllowLightsOn();
       
   488     }
       
   489 
       
   490 #endif // SYSAP_USE_STARTUP_UI_PHASE
   481 
   491 
   482 CSysApAppUi::~CSysApAppUi()
   492 CSysApAppUi::~CSysApAppUi()
   483     {
   493     {
   484     TRACES( RDebug::Print( _L("~CSysApAppUi() started") ) );
   494     TRACES( RDebug::Print( _L("~CSysApAppUi() started") ) );
   485     if( !iResourcesFreed )
   495     if( !iResourcesFreed )
   486         {
   496       {
   487         FreeResources();
   497         FreeResources();
   488 
   498       }
   489         iStarterSession.Close();
   499     }
   490 
   500         
   491         }
   501 TBool CSysApAppUi::ResourcesFreed() const
   492 
   502     {
   493     delete iSysApShutdownImage;
   503     return iResourcesFreed;
   494 
   504     }
       
   505 
       
   506 void CSysApAppUi::ShowExampleUiNoteL( const TDesC& noteText )const
       
   507     {          
       
   508     //   QString msg  = QString::fromUtf16(aStringPointer.Ptr(),aStringPointer.Length());
       
   509  	TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: constructing CHbDeviceMessageBoxSymbian:BeGIN") ) );    
       
   510     CHbDeviceMessageBoxSymbian *note = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EInformation);
       
   511  	CleanupStack::PushL(note);
       
   512     TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: construction of CHbDeviceMessageBoxSymbian:END") ) ); 
       
   513 	//	HbMessageBox *note = new HbMessageBox (HbMessageBox ::MessageTypeInformation);
       
   514     note->SetTextL(noteText);
       
   515     //  note->SetTimeout(HbPopup::NoTimeout);
       
   516 	note->SetTimeout(5);
       
   517  	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::Begin") ) );    
       
   518     note->ShowL();
       
   519 	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::End") ) );
       
   520 	CleanupStack::PopAndDestroy(note);
       
   521     }
       
   522 
       
   523 
       
   524 void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn )
       
   525     {
       
   526     ExecQueryL( aQuery, aReturn, KNullDesC8 );
       
   527     }
       
   528 
       
   529 // ----------------------------------------------------------------------------
       
   530 // CSysApAppUi::ExecQueryL
       
   531 // ----------------------------------------------------------------------------
       
   532 //
       
   533 void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn, const TDesC8& /*aParam*/ )
       
   534     {
       
   535     TRACES( RDebug::Print(_L("CSysApAppUi::ExecQueryL: aQuery=%d"), aQuery ) );
       
   536 
       
   537     switch ( aQuery )
       
   538         {
       
   539         case EGetHwrmLight: // get handle to HWRM client session. Returns CHWRMLight*.
       
   540             {
       
   541             THwrmLightBuf retBuf( iSysApLightsController->GetHwrmLight() );
       
   542             aReturn.Copy( retBuf );
       
   543             }
       
   544             break;
       
   545 
       
   546         case EGetKeylock: // get handle to keylock client session. Returns RAknKeylock2*.
       
   547             {
       
   548             // do nothing
       
   549             }
       
   550             break;
       
   551 
       
   552 
       
   553         default:
       
   554             __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecQueryL: Invalid query"), KErrArgument ) );
       
   555             User::Leave( KErrArgument );
       
   556             break;
       
   557         }
       
   558     }
       
   559 
       
   560 // ----------------------------------------------------------------------------
       
   561 // CSysApAppUi::ExecCommandL
       
   562 // ----------------------------------------------------------------------------
       
   563 //
       
   564 void CSysApAppUi::ExecCommandL( TSysapCommand aCommand )
       
   565     {
       
   566     ExecCommandL( aCommand, KNullDesC8 );
       
   567     }
       
   568 
       
   569 // ----------------------------------------------------------------------------
       
   570 // CSysApAppUi::ExecCommandL
       
   571 // ----------------------------------------------------------------------------
       
   572 //
       
   573 void CSysApAppUi::ExecCommandL( TSysapCommand aCommand, const TDesC8&  /* aParam */ )
       
   574     {
       
   575     TRACES( RDebug::Print(_L("CSysApAppUi::ExecCommandL: aCommand=%d"), aCommand ) );
       
   576 
       
   577     switch ( aCommand )
       
   578         {
       
   579         case EResetKeyguardState: // reset the internal keyguard flags of the SysAp, except for iKeyLockOnBeforeCradle
       
   580             iKeyLockOnBeforeCall = EFalse;
       
   581             iKeyLockOnBeforeAlarm = EFalse;
       
   582             break;
       
   583 
       
   584         default:
       
   585             // do nothing in release builds since no harm is done
       
   586             __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecCommandL: Invalid command"), KErrArgument ) );
       
   587             break;
       
   588         }
       
   589     }
       
   590     
       
   591 // ----------------------------------------------------------------------------
       
   592 // CSysApAppUi::TimerExpiredL()
       
   593 // ----------------------------------------------------------------------------
       
   594 void CSysApAppUi::TimerExpiredL()
       
   595     {
       
   596 /*
       
   597  * Not suppported , will take care in wk25
       
   598  * #ifndef RD_MULTIPLE_DRIVE 
       
   599  * CloseUIAppsInHotSwapL();
       
   600  * #endif // RD_MULTIPLE_DRIVE
       
   601 */   
       
   602    }
       
   603 
       
   604 
       
   605   // ----------------------------------------------------------------------------
       
   606 // CSysApAppUi::KeyLockState() const
       
   607 // ----------------------------------------------------------------------------
       
   608 
       
   609 TBool CSysApAppUi::KeyLockState() const
       
   610     {
       
   611     return iKeyLockEnabled;
       
   612     }
       
   613 
       
   614 // ----------------------------------------------------------------------------
       
   615 // CSysApAppUi::DeviceLockState() const
       
   616 // ----------------------------------------------------------------------------
       
   617 
       
   618 TBool CSysApAppUi::DeviceLockState() const
       
   619     {
       
   620     return iDeviceLockEnabled;
       
   621     }
       
   622     
       
   623 // ----------------------------------------------------------------------------
       
   624 // CSysApAppUi::SysApFeatureManager
       
   625 // ----------------------------------------------------------------------------
       
   626 
       
   627 CSysApFeatureManager& CSysApAppUi::SysApFeatureManager()
       
   628     {
       
   629     __ASSERT_DEBUG( iSysApFeatureManager, User::Panic( _L("iSysApFeatureManager == NULL"), KErrBadHandle ) );
       
   630 
       
   631     return *iSysApFeatureManager;
       
   632     }
       
   633     
       
   634 // ----------------------------------------------------------------------------
       
   635 // CSysApAppUi::ActivateKeyeventForwardingForLights()
       
   636 // ----------------------------------------------------------------------------
       
   637 
       
   638 void CSysApAppUi::ActivateKeyeventForwardingForLights(TBool aActivate)
       
   639     {
       
   640     if( iSysApNspsHandler )
       
   641         {
       
   642         if ( aActivate )
       
   643             {
       
   644             iSysApNspsHandler->ActivateKeyeventForwardingForLights();
       
   645             }
       
   646         else
       
   647             {
       
   648             iSysApNspsHandler->DeActivateKeyeventForwardingForLights();
       
   649             }
       
   650         }
       
   651     }
       
   652 
       
   653 // ----------------------------------------------------------------------------
       
   654 // CSysApAppUi::StarterSession()
       
   655 // ----------------------------------------------------------------------------
       
   656 
       
   657 RStarterSession& CSysApAppUi::StarterSession()
       
   658     {
       
   659     if ( !iStarterSession.Handle() )
       
   660         {
       
   661         // All server connections are tried to be made KTriesToConnectServer times because occasional
       
   662         // fails on connections are possible at least on some servers
       
   663         TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: trying RStarterSession::Connect()") ) );
       
   664         TInt thisTry = 0;
       
   665         TInt err;
       
   666         while ( ( err = iStarterSession.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
       
   667             {
       
   668             User::After( KTimeBeforeRetryingServerConnection );
       
   669             }
       
   670 
       
   671         if ( err != KErrNone )
       
   672             {
       
   673             // What do in error case?
       
   674             TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: RStarterSession::Connect() failed with %d"), err ) );
       
   675             }
       
   676         }
       
   677 
       
   678     return iStarterSession;
       
   679     }
       
   680 
       
   681 // ----------------------------------------------------------------------------
       
   682 // CSysApAppUi::SetBtPowerState()
       
   683 // ----------------------------------------------------------------------------
       
   684 TInt CSysApAppUi::SetBtPowerState( TBool aBtState )
       
   685     {
       
   686     if ( iSysApBtController )
       
   687         {
       
   688         return iSysApBtController->SetPowerState( aBtState );
       
   689         }
       
   690     else
       
   691         {
       
   692         return KErrNotReady;
       
   693         }
       
   694     }
       
   695 
       
   696 // ----------------------------------------------------------------------------
       
   697 // CSysApAppUi::SetStarterState()
       
   698 // ----------------------------------------------------------------------------
       
   699 
       
   700 TInt CSysApAppUi::SetStarterState( const RStarterSession::TGlobalState aState )
       
   701     {
       
   702     if ( iSysApStartupController->GlobalStateChangeAllowed( aState ) )
       
   703         {
       
   704         TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d" ), aState ) );
       
   705         return StarterSession().SetState( aState );
       
   706         }
       
   707     else
       
   708         {
       
   709         TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d - not allowed" ), aState ) );
       
   710         return KErrNone;
       
   711         }
       
   712     }
       
   713 
       
   714 // ----------------------------------------------------------------------------
       
   715 // CSysApAppUi::SetNetworkConnectionAllowed()
       
   716 // ----------------------------------------------------------------------------
       
   717 
       
   718 void CSysApAppUi::SetNetworkConnectionAllowed( TCoreAppUIsNetworkConnectionAllowed aNetworkConnectionAllowed )
       
   719     {
       
   720     TRACES( RDebug::Print( _L("CSysApAppUi::SetNetworkConnectionAllowed: status: %d" ), aNetworkConnectionAllowed ) );
       
   721 
       
   722     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIs, KCoreAppUIsNetworkConnectionAllowed, (TInt) aNetworkConnectionAllowed );
       
   723 
       
   724     // Also set the Symbian PS key used for the same purpose:
       
   725     RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, aNetworkConnectionAllowed ? ESAPhoneOn : ESAPhoneOff);
       
   726     }
       
   727 
       
   728 // ----------------------------------------------------------------------------
       
   729 // CSysApAppUi::BluetoothPowerMode()
       
   730 // ----------------------------------------------------------------------------
       
   731 TInt CSysApAppUi::BluetoothPowerMode() const
       
   732     {
       
   733     return iSysApCenRepBtObserver->BluetoothPowerMode();
       
   734     }
       
   735 
       
   736 // ----------------------------------------------------------------------------
       
   737 // CSysApAppUi::SimSupported()
       
   738 // ----------------------------------------------------------------------------
       
   739 TBool CSysApAppUi::SimSupported()
       
   740     {
       
   741     return iSysApFeatureManager->SimSupported();
       
   742     }
       
   743 
       
   744 // ----------------------------------------------------------------------------
       
   745 // CSysApAppUi::BtSapEnabled()
       
   746 // ----------------------------------------------------------------------------
       
   747 
       
   748 TBool CSysApAppUi::BtSapEnabled()
       
   749     {
       
   750     if ( iSysApBtSapController )
       
   751         {
       
   752         return iSysApBtSapController->BtSapEnabled();    
       
   753         }  
       
   754     return EFalse;
       
   755     }
       
   756 
       
   757 
       
   758 // ----------------------------------------------------------------------------
       
   759 // CSysApAppUi::OfflineModeChangedL()
       
   760 // ----------------------------------------------------------------------------
       
   761 void CSysApAppUi::OfflineModeChangedL()
       
   762     {
       
   763 #ifdef SYSAP_USE_STARTUP_UI_PHASE    
       
   764     // if UI is not ready, don't update indicators
       
   765     if ( !UiReady() )
       
   766         {
       
   767         return;
       
   768         }
       
   769 #endif // SYSAP_USE_STARTUP_UI_PHASE
       
   770 
       
   771     SetHacIndicatorL();
       
   772     }
       
   773 
       
   774 // ----------------------------------------------------------------------------
       
   775 // CSysApAppUi::UiReady()
       
   776 // 
       
   777 // ----------------------------------------------------------------------------
       
   778 
       
   779 TBool CSysApAppUi::UiReady() const
       
   780     {
       
   781 #ifdef SYSAP_USE_STARTUP_UI_PHASE    
       
   782     return iSysApStartupController->UiReady(); 
       
   783 #else // SYSAP_USE_STARTUP_UI_PHASE
       
   784     // if startup UI phase information is not used, global system state normal is handled as UI idle state
       
   785     return IsStateNormal();
       
   786 #endif // SYSAP_USE_STARTUP_UI_PHASE        
       
   787     }
       
   788 
       
   789 
       
   790 // ----------------------------------------------------------------------------
       
   791 // CSysApAppUi::CompleteShutdown()
       
   792 // ----------------------------------------------------------------------------
       
   793 
       
   794 void CSysApAppUi::CompleteShutdown( const TBool aReset, const TInt aResetReason )
       
   795     {
       
   796     TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): START" ) ) );
       
   797     
       
   798     iCheckLongPowerKeyEvent = ETrue;
       
   799 
       
   800     PrepareForShutdownImage();//SysAp's internal preparation for ShutDown with image
       
   801 
       
   802     FreeResources();
       
   803 
       
   804     if ( aReset )
       
   805         {
       
   806         __ASSERT_DEBUG( aResetReason >= RStarterSession::ELanguageSwitchReset &&
       
   807                         aResetReason <= RStarterSession::EDataRestoreReset,
       
   808                         User::Invariant() );
       
   809         StarterSession().Reset( static_cast<RStarterSession::TResetReason>( aResetReason ) );
       
   810         }
       
   811     else
       
   812         {
       
   813         StarterSession().Shutdown();
       
   814         }
       
   815 
       
   816     StarterSession().Close();
       
   817 
       
   818     TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): END" ) ) );
       
   819     }
       
   820 
       
   821 
       
   822 
       
   823 // ----------------------------------------------------------------------------
       
   824 // CSysApAppUi::DoShutdownL( const TBool aReset, const TSWStartupReason aSWStartupReason )
       
   825 // ----------------------------------------------------------------------------
       
   826 
       
   827 void CSysApAppUi::DoShutdownL( const TBool aReset, const TInt aResetReason )
       
   828     {
       
   829     TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: aResetReason:%d, aReset:%d" ),
       
   830         aResetReason, aReset ) );
   495 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
   831 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
   496     if (iSysApShutdownAnimation)
   832     TBool animationenabled( EFalse );
   497         {
       
   498         RemoveFromStack( iSysApShutdownAnimation );
       
   499 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   833 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   500         delete iSysApShutdownAnimation;
   834 
   501 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
   835     if( OkToInitiateShutdown() )
   502         }
   836         {
   503 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   837         TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was OkToToInitiateShutdown" ) ) );
   504 
   838 
   505     delete iProfileNote;
   839 
   506 
   840         if ( !aReset && iSysApFeatureManager->Supported(KSysApFeatureIdGoodbyeNote) )
   507 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
   841             {
   508     if( iAnimTimer )
   842             // show shutdown note
   509         {
   843             }
   510         iAnimTimer->Cancel();
   844 
   511         }
   845         if( !aReset )
   512     delete iAnimTimer;
   846             {
   513 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   514 
       
   515     delete iSysApPowerKeyMenuObserver;
       
   516 
       
   517     delete iSysApStartupController;
       
   518 
       
   519 #ifdef RD_MULTIPLE_DRIVE
       
   520     iInsertedMemoryCards.Close();
       
   521     delete  iSysApDriveEjectHandler;
       
   522     delete iSysApDriveUnlockHandler;
       
   523     delete iSysApDriveList;
       
   524 #endif // RD_MULTIPLE_DRIVE
       
   525 
       
   526     TRACES( RDebug::Print( _L("~CSysApAppUi() completed") ) );
       
   527     }
       
   528 
       
   529 
       
   530 // ----------------------------------------------------------------------------
       
   531 // CSysApAppUi::HandleLocationPrivacyIndicatorL()
       
   532 // ----------------------------------------------------------------------------
       
   533 
       
   534 void CSysApAppUi::HandleLocationPrivacyIndicatorL( const TInt aState )
       
   535     {
       
   536     TRACES( RDebug::Print( _L("CSysApAppUi::HandleLocationPrivacyIndicatorL() state=%d"), aState ) );
       
   537     if ( iSysApFeatureManager->LocationPrivacySupported() )
       
   538         {
       
   539         // Phase 1. Set all Location Privacy indicators off
       
   540         if ( iSysApLocationPrivacyIndicator->iIndicatorIdAcceptAll != KSysApNoIndicator )
       
   541             {
       
   542             SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll, EAknIndicatorStateOff );
       
   543             }
       
   544         if ( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll != KSysApNoIndicator )
       
   545             {
       
   546             SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll, EAknIndicatorStateOff );
       
   547             }
       
   548         if ( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk != KSysApNoIndicator )
       
   549             {
       
   550             SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk, EAknIndicatorStateOff );
       
   551             }
       
   552         if ( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy != KSysApNoIndicator )
       
   553             {
       
   554             SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy, EAknIndicatorStateOff );
       
   555             }
       
   556         // Phase 2. Set the required Location Privacy indicator on
       
   557         switch ( aState )
       
   558             {
       
   559             case EPSLocPrivAcceptAll:
       
   560                 if ( iSysApLocationPrivacyIndicator->iIndicatorIdAcceptAll != KSysApNoIndicator )
       
   561                     {
       
   562                     SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdAcceptAll, EAknIndicatorStateOn );
       
   563                     }
       
   564                 break;
       
   565             case EPSLocPrivRejectAll:
       
   566                 if ( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll != KSysApNoIndicator )
       
   567                     {
       
   568                     SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdRejectAll, EAknIndicatorStateOn );
       
   569                     }
       
   570                 break;
       
   571             case EPSLocPrivAlwaysAsk:
       
   572                 if ( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk != KSysApNoIndicator )
       
   573                     {
       
   574                     SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdAlwaysAsk, EAknIndicatorStateOn );
       
   575                     }
       
   576                 break;
       
   577             case EPSLocPrivIndividualPrivacy:
       
   578                 if ( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy != KSysApNoIndicator )
       
   579                     {
       
   580                     SetIndicatorStateL( iSysApLocationPrivacyIndicator->iIndicatorIdIndividualPrivacy, EAknIndicatorStateOn );
       
   581                     }
       
   582                 break;
       
   583             default:
       
   584                 break;
       
   585             }
       
   586         }
       
   587     }
       
   588 
       
   589 
       
   590 // ----------------------------------------------------------------------------
       
   591 // CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
       
   592 // ----------------------------------------------------------------------------
       
   593 
       
   594 TKeyResponse CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
       
   595     {
       
   596     if ( ! iShutdownStarted )
       
   597         {
       
   598         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
       
   599                                aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
       
   600 
       
   601 #ifdef _DEBUG
       
   602         // camery latency measurement environment instrumentation, don't remove
       
   603         if ( aType == EEventKey && aKeyEvent.iCode == EKeyCamera )
       
   604             {
       
   605             TRACES( RDebug::Print( _L("e_KEY_EVENT_SENDING 0") ) );
       
   606             }
       
   607 #endif // _DEBUG
       
   608 
       
   609         TKeyResponse response( EKeyWasNotConsumed );
       
   610         if (iSysApKeyManagement && aKeyEvent.iCode != EKeyPowerOff && aKeyEvent.iCode != 'E')
       
   611             {
       
   612             response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
       
   613             }
       
   614         
       
   615         if( aType == EEventKey )
       
   616             {
       
   617             switch ( aKeyEvent.iCode )
       
   618                 {
       
   619 #ifdef _DEBUG
       
   620                 case 'E': //For testing
       
   621                     Exit();
       
   622                     break;
       
   623 #endif
       
   624                 case EKeyPowerOff:
       
   625                     //Short power key press
       
   626                     iKeyBoardRepeatCount++;
       
   627                     if( aKeyEvent.iRepeats == 0 )
       
   628                         {
       
   629                         TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Short powerkey") ) );
       
   630                         iLastPowerKeyWasShort = ETrue;
       
   631                         HandleShortPowerKeyPressedL();
       
   632                         iIgnoreNextPowerKeyRepeats = EFalse;
       
   633                         }
       
   634                     //Long power key press
       
   635                     else if( aKeyEvent.iRepeats > 0 && iKeyBoardRepeatCount >= iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApPowerkeyRepeatcount ))
       
   636                         {
       
   637                         iKeyBoardRepeatCount = -1;
       
   638                         TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Long powerkey") ) );
       
   639                         iLastPowerKeyWasShort = EFalse;
       
   640                         HandleLongPowerKeyPressedL();
       
   641                         }
       
   642                     break;
       
   643 
       
   644                 default:
       
   645                 	{
       
   646                 	TKeyResponse response = EKeyWasNotConsumed;
       
   647                 	if (iSysApKeyManagement)
       
   648                 		{
       
   649                 		response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
       
   650                 		}
       
   651 
       
   652                     if ( response == EKeyWasNotConsumed ) // none of the plugins consumed the key, offer it to default handling
       
   653                         {
       
   654                         iSysApDefaultKeyHandler->HandleKeyEventL( aKeyEvent, aType );
       
   655                         }
       
   656                 	}
       
   657                     break;
       
   658                 }
       
   659             }
       
   660         else if( aType == EEventKeyUp )
       
   661             {
       
   662             if( aKeyEvent.iScanCode == EStdKeyDevice2 )
       
   663                 {
       
   664                 if ( iIgnoreNextPowerKeyUpEvent )
       
   665                     {
       
   666                     if ( !iPowerKeyPopupMenuDismissed ) // If the popup menu has been dismissed, do nothing
       
   667                         {
       
   668                         iPowerKeyPopupMenuActive = ETrue;
       
   669                         iIgnoreNextPowerKeyUpEvent = EFalse;
       
   670                         }
       
   671                     }
       
   672                 else if( iLastPowerKeyWasShort )
       
   673                     {
       
   674                     if ( iPowerKeyPopupMenuActive )
       
   675                         {
       
   676                         if ( iGlobalListQuery )
       
   677                             {
       
   678                             if ( iSysApFeatureManager->NoPowerKeySupported() )
       
   679                                 {
       
   680                             	CancelGlobalListQuery();
       
   681                                 }
       
   682                             else
       
   683                                 {
       
   684                                 iGlobalListQuery->MoveSelectionDown();	
       
   685                                 }                            
       
   686                             }
       
   687                         }
       
   688                     }
       
   689 
       
   690                 }
       
   691             }
       
   692 
       
   693         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL:ended, aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
       
   694                                aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
       
   695         }
       
   696     else // shutdown started
       
   697         {
       
   698         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d"),
       
   699                                aKeyEvent.iCode, aKeyEvent.iScanCode, aType ) );
       
   700 
       
   701         // When shutdown has been started, only device mode key events are passed to plug-in framework
       
   702         // This for enabling plug-in activities during shutdown animation
       
   703         if ( IsDeviceModeKey( aKeyEvent ) ) // Other key events are not passed, because they must cancel the shutdown animation as stated in UI spefication
       
   704             {
       
   705             if ( aType == EEventKey && iSysApKeyManagement )
       
   706                 {
       
   707                 iSysApKeyManagement->HandleKeyEventL( aKeyEvent, aType );
       
   708                 }
       
   709             }
       
   710     #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
   847     #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
   711         else if ( aType == EEventKey && iSysApShutdownAnimation && !iShutdownContinued )
   848 //            TRAPD( err, ShowAnimationL() );
   712             {
   849 //            if ( err )
   713             if ( aKeyEvent.iCode != EKeyPowerOff || iLastPowerKeyWasShort )
   850                 {
   714                 {
   851      //           TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
   715                 iSysApShutdownAnimation->Cancel();
   852                 CompleteShutdown(aReset, aResetReason);
   716                 NotifyShutdownAnimationSkip();
   853                 }
   717                 }
   854             }
   718             }
   855         else // aReset
   719 
   856            {
       
   857             CompleteShutdown(aReset, aResetReason);
       
   858             }
       
   859     #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
   860             TRAPD( err, animationenabled = ShowAnimationL() );
       
   861             if ( err )
       
   862                 {
       
   863                 TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
       
   864                 }
       
   865             }
       
   866 
       
   867         if ( !animationenabled )
       
   868             {
       
   869             CompleteShutdown(aReset, aResetReason);
       
   870             }
   720     #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   871     #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   721 
       
   722         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: ended") ) );
       
   723         }
       
   724     return EKeyWasConsumed;
       
   725     }
       
   726 
       
   727 // ----------------------------------------------------------------------------
       
   728 // CSysApAppUi::HandleCommandL( TInt aCommand)
       
   729 // ----------------------------------------------------------------------------
       
   730 
       
   731 void CSysApAppUi::HandleCommandL( TInt aCommand )
       
   732     {
       
   733     TRACES( RDebug::Print( _L("CSysApAppUi::HandleCommandL aCommend: %d"), aCommand ) );
       
   734     switch ( aCommand )
       
   735         {
       
   736         case EEikCmdExit:   // EAknCmdExit
       
   737             Exit();
       
   738             break;
       
   739         default:
       
   740             break;
       
   741         }
       
   742     }
       
   743 
       
   744 // ----------------------------------------------------------------------------
       
   745 // CSysApAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
       
   746 // ----------------------------------------------------------------------------
       
   747 
       
   748 void CSysApAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
       
   749     {
       
   750     TRACES( RDebug::Print( _L("CSysApAppUi::HandleApplicationSpecificEventL: aType:%d"), aType ) );
       
   751 
       
   752     CAknAppUi::HandleApplicationSpecificEventL(aType, aEvent);
       
   753     
       
   754     if ( ResourcesFreed() )
       
   755         {
       
   756         TRACES( RDebug::Print( _L("CSysApAppUi::HandleApplicationSpecificEventL: discarded, shutting down") ) );
       
   757         return;
       
   758         }
       
   759     
       
   760     switch( aType )
       
   761         {
       
   762         case EEikKeyLockEnabled:
       
   763             iKeyLockEnabled = ETrue;
       
   764             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 1 );
       
   765             SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOn );
       
   766             iSysApLightsController->KeylockStateChangedL( ETrue );
       
   767             break;
       
   768         case EEikKeyLockDisabled:
       
   769             iKeyLockEnabled = EFalse;
       
   770             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
       
   771             SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOff );
       
   772             if (! iDeviceLockEnabled )
       
   773                 {
       
   774                 iSysApLightsController->KeylockStateChangedL( EFalse );
       
   775                 if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
   776                     {
       
   777                     if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
       
   778                         {
       
   779                         RunUnlockNotifierL();
       
   780                         }
       
   781                     }
       
   782                 }
       
   783             break;
       
   784         case EEikKeyLockPowerKeyPressed: //sent when power key is captured by keylockserver
       
   785             HandleShortPowerKeyPressedL();
       
   786             break;
       
   787 
       
   788         case EEikKeyLockLightsOnRequest:
       
   789             iSysApLightsController->SetLightsOnUnlockNoteL();
       
   790             break;
       
   791 
       
   792         case EEikEcsQueryLights: // emergency note is shown
       
   793             iSysApLightsController->SetLightsOnEcsQueryL();
       
   794             break;
       
   795 
       
   796         case EEikSecurityQueryLights: // for device lock security query
       
   797             iSysApLightsController->SetLightsOnSecurityQueryL();
       
   798             break;
       
   799 
       
   800         default:
       
   801             break;
       
   802             }
       
   803     }
       
   804 
       
   805 
       
   806 // ----------------------------------------------------------------------------
       
   807 // CSysApAppUi::InitializeStatusPaneAreaL()
       
   808 // ----------------------------------------------------------------------------
       
   809 
       
   810 void CSysApAppUi::InitializeStatusPaneAreaL()
       
   811     {
       
   812     TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): START") ) );
       
   813     TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
       
   814 
       
   815     //Also Charging status will be updated with the following function.
       
   816     UpdateBatteryBarsL( state );
       
   817 
       
   818 #ifdef SYSAP_USE_STARTUP_UI_PHASE
       
   819     if ( OfflineModeActive() )
       
   820         {
       
   821         UpdateSignalBarsL( KAknSignalOffLineMode );
       
   822         }
   872         }
   823     else
   873     else
   824         {
   874         {
   825         UpdateSignalBarsL();    
   875         TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was not OkToToInitiateShutdown" ) ) );
   826         }          
   876         }
   827 #else
   877     TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: END" ) ) );
   828     UpdateSignalBarsL();
   878     }
   829 #endif // SYSAP_USE_STARTUP_UI_PHASE
   879 
   830     
   880 
   831     SetSignalIndicatorL();
   881 
   832     SetIhfIndicatorL();
   882 /* 
   833     SetHacIndicatorL();
   883 ----------------------------------------------------------------------------
   834     LogsObserverL().HandleUiReadyL();
   884 CSysApAppUi::IsEncryptionOperationOngoingL()
   835 
   885 Introduced the code as a part of Sub : 405-3362 - Power Management SUB for ES 
   836     if ( iSysApEtelConnector )
   886 recapture functionalities in platform which support multidrive as well. 
   837         {
   887 -------------------------------------------------------------------------------
   838         iSysApEtelConnector->ReadSimSmsStoreStatusInStartup();
   888 */
   839         }
   889 TBool CSysApAppUi::IsEncryptionOperationOngoingL() const
   840 
   890     {
   841     SetEnvelopeIndicatorL();
   891         TBool deFeatureSupported(EFalse);
   842 
   892         FeatureManager::InitializeLibL();
   843     TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): accessories") ) );
   893         deFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature);
   844 
   894         FeatureManager::UnInitializeLib();
   845     TAccMode accessoryState(EAccModeHandPortable);
   895 
   846     if ( iSysApAccessoryObserver )
   896         if(deFeatureSupported)
   847         {
   897             {         
   848         accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
   898             /**
   849         }
   899              * Store the last memory status changed
   850 
   900              * 0: Idle. It can be Encrypted or Decrypted
   851     if( accessoryState == EAccModeWiredHeadset ||
   901              * 1: Encrypting
   852         accessoryState == EAccModeWirelessHeadset ||
   902              * 2: Decrypting
   853         accessoryState == EAccModeHeadphones )
   903              **/
   854         {
   904              
   855         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
   905             RProperty deProperty;
   856         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
   906             User::LeaveIfError(deProperty.Attach(KDevEncProtectedUid, KDevEncOperationKey,EOwnerThread));
   857         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOn );
   907             TInt deValue = 0;
   858         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
   908             if((deProperty.Get(deValue)== KErrNone)&&( deValue == EOpEncrypting || deValue == EOpDecrypting))
   859         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
   909                 {
   860         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
   910                 deProperty.Close();
   861         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
   911                 return ETrue;
   862         }
       
   863     else if( accessoryState == EAccModeLoopset )
       
   864         {
       
   865         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
   866         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
   867         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOn );
       
   868         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
   869         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
   870         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
   871         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
   872         }
       
   873     else if( accessoryState == EAccModeTextDevice )
       
   874         {
       
   875         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
   876         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
   877         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOn );
       
   878         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
   879         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
   880         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
   881         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
   882         }
       
   883     else if( accessoryState == EAccModeWiredCarKit || accessoryState == EAccModeWirelessCarKit )
       
   884         {
       
   885         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
   886         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
   887         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
   888         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
   889         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOn );
       
   890         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
   891         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
   892         }
       
   893     else if( accessoryState == EAccModeTVOut )
       
   894         {
       
   895         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
   896         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
   897         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
   898         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
   899         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
   900         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOn );
       
   901         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
   902         }
       
   903     else if (accessoryState == EAccModeHDMI )
       
   904         {
       
   905         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
   906                 SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
   907                 SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
   908                 SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
   909                 SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
   910                 SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff);
       
   911                 SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOn );
       
   912         }
       
   913     else // all indicators off
       
   914         {
       
   915         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
   916         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
   917         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
   918         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
   919         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
   920         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
   921         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
   922         }
       
   923 
       
   924     TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): msg") ) );
       
   925     state = StateOfProperty( KUidSystemCategory, KUidOutboxStatusValue );
       
   926     if( state == ESADocumentsInOutbox )
       
   927         {
       
   928         SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOn );
       
   929         }
       
   930     else
       
   931         {
       
   932         SetIndicatorStateL( EAknIndicatorOutbox, EAknIndicatorStateOff );
       
   933         }
       
   934 
       
   935     state = StateOfProperty( KAlarmServerPubSubCategory, KWakeupAlarmPubSubKey );
       
   936     
       
   937     if( state == EActiveWakeupAlarmSet )
       
   938         {
       
   939         TRACES( RDebug::Print(_L("CSysApAppUi::InitializeStatusPaneAreaL called the SetIndicatorStateL with EActiveWakeupAlarmSet ")));
       
   940         SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOn );
       
   941         }
       
   942     else
       
   943         {
       
   944         TRACES( RDebug::Print(_L("CSysApAppUi::InitializeStatusPaneAreaL called the SetIndicatorStateL with EActiveNoWakeupAlarmsSet ")));
       
   945         SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOff );
       
   946         }
       
   947 
       
   948     state = StateOfProperty( KIrdaPropertyCategory, KIrdaStatus );
       
   949     if( state == TIrdaStatusCodes::EIrLoaded || state == TIrdaStatusCodes::EIrDisconnected || state == TIrdaStatusCodes::EIrBlocked )
       
   950         {
       
   951         SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateAnimate );
       
   952         }
       
   953     else if( state == TIrdaStatusCodes::EIrConnected  )
       
   954         {
       
   955         SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOn );
       
   956         }
       
   957     else
       
   958         {
       
   959         SetIndicatorStateL( EAknIndicatorIrActive, EAknIndicatorStateOff );
       
   960         }
       
   961 
       
   962     iSysApCenRepCallForwardingObserver->UpdateCallForwardingIndicatorsL();
       
   963 
       
   964     iSysApCenRepMsgWaitingObserver->UpdateMessageWaitingIndicatorsL();
       
   965 
       
   966     state = StateOfProperty( KPSUidNetworkInfo, KNWHomeZoneStatus );
       
   967     if( state == ENWNone || state == ENWCityZone )
       
   968         {
       
   969         SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOff );
       
   970         }
       
   971     else if( state == ENWHomeZone )
       
   972         {
       
   973         SetIndicatorStateL( EAknIndicatorHomeZone, EAknIndicatorStateOn );
       
   974         }
       
   975 
       
   976     // Initialize WLan state
       
   977     state = StateOfProperty( KPSUidWlan, KPSWlanIndicator );
       
   978     HandleWlanIndicatorL(state);
       
   979 
       
   980     // Initialize Tarm state
       
   981     state = StateOfProperty( KPSUidCoreApplicationUIs, KCoreAppUIsTarmIndicator );
       
   982     HandleTarmIndicatorL(state);
       
   983 
       
   984     TRACES( RDebug::Print( _L("CSysApAppUi::InitializeStatusPaneAreaL(): END") ) );
       
   985     }
       
   986 
       
   987 // ----------------------------------------------------------------------------
       
   988 // CSysApAppUi::HandleWlanIndicator()
       
   989 // ----------------------------------------------------------------------------
       
   990 void CSysApAppUi::HandleWlanIndicatorL( TInt aValue )
       
   991     {
       
   992     if ( aValue == EPSWlanIndicatorAvailable )
       
   993         {
       
   994         SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOff );
       
   995         SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOff );
       
   996         SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOn  );
       
   997         }
       
   998     else if ( aValue == EPSWlanIndicatorActive )
       
   999         {
       
  1000         SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOff );
       
  1001         SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOff );
       
  1002         SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOn  );
       
  1003         }
       
  1004     else if ( aValue == EPSWlanIndicatorActiveSecure )
       
  1005         {
       
  1006         SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOff );
       
  1007         SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOff );
       
  1008         SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOn  );
       
  1009         }
       
  1010     else // No indication required
       
  1011         {
       
  1012         SetIndicatorStateL( EAknIndicatorWlanAvailable,    EAknIndicatorStateOff );
       
  1013         SetIndicatorStateL( EAknIndicatorWlanActive,       EAknIndicatorStateOff );
       
  1014         SetIndicatorStateL( EAknIndicatorWlanActiveSecure, EAknIndicatorStateOff );
       
  1015         }
       
  1016     }
       
  1017 
       
  1018 // ----------------------------------------------------------------------------
       
  1019 // CSysApAppUi::HandleTarmIndicatorL()
       
  1020 // ----------------------------------------------------------------------------
       
  1021 
       
  1022 void CSysApAppUi::HandleTarmIndicatorL( TInt aValue )
       
  1023     {
       
  1024     if ( aValue == ECoreAppUIsTarmTerminalSecurityOnIndicatorOn )
       
  1025         {
       
  1026         SetIndicatorStateL( EAknIndicatorTARM, EAknIndicatorStateOff );
       
  1027         SetIndicatorStateL( EAknIndicatorTARMModuleOn, EAknIndicatorStateOn );
       
  1028         }
       
  1029     else if ( aValue == ECoreAppUIsTarmMngActiveIndicatorOn )
       
  1030         {
       
  1031         SetIndicatorStateL( EAknIndicatorTARMModuleOn, EAknIndicatorStateOff );
       
  1032         SetIndicatorStateL( EAknIndicatorTARM, EAknIndicatorStateOn );
       
  1033         }
       
  1034     else
       
  1035         {
       
  1036         SetIndicatorStateL( EAknIndicatorTARM, EAknIndicatorStateOff );
       
  1037         SetIndicatorStateL( EAknIndicatorTARMModuleOn, EAknIndicatorStateOff );
       
  1038         }
       
  1039     }
       
  1040 
       
  1041 // ----------------------------------------------------------------------------
       
  1042 // CSysApAppUi::HandleShortPowerKeyPressedL()
       
  1043 // ----------------------------------------------------------------------------
       
  1044 
       
  1045 void CSysApAppUi::HandleShortPowerKeyPressedL()
       
  1046     {
       
  1047     TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  1048 
       
  1049     TRACES (
       
  1050         RDebug::Print(
       
  1051         _L("CSysApAppUi::HandleShortPowerKeyPressedL() callState:%d, iDeviceLockEnabled:%d" ),
       
  1052         callState,
       
  1053         iDeviceLockEnabled );
       
  1054     );
       
  1055     iSysApLightsController->PowerKeyPressedL();
       
  1056 
       
  1057     RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsHideAlarm, ECoreAppUIsHideAlarm );
       
  1058 
       
  1059 
       
  1060     if( UiReady() && !iDeviceLockEnabled )
       
  1061         {
       
  1062         if ( iPowerKeyPopupMenuActive )
       
  1063             {
       
  1064             //Do nothing here. EEventKeyUp moves selection in the list!
       
  1065             }
       
  1066         else if ( !iKeyLockEnabled
       
  1067             && callState != EPSCTsyCallStateAlerting
       
  1068             && callState != EPSCTsyCallStateRinging
       
  1069             && callState != EPSCTsyCallStateDialling )
       
  1070             //Show power key menu
       
  1071             {
       
  1072             ShowPowerKeyPopUpMenuL();
       
  1073             }
       
  1074         }
       
  1075     else 
       
  1076         {
       
  1077         TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
       
  1078         
       
  1079         if( swState == ESwStateAlarm )
       
  1080             //From Alarm state even a short press causes shutdown but charger state need to be checked
       
  1081             {
       
  1082             TInt chargerState( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
       
  1083             if( chargerState == EChargingStatusNotConnected )
       
  1084                 //shutdown
       
  1085                 {
       
  1086                 StartShutDownTimerOnAlarmAndChargingStates();
       
  1087                 }
   912                 }
  1088             else
   913             else
  1089                 //to charging state
   914                 {
  1090                 {
   915                 deProperty.Close();
  1091                 SetStarterState( RStarterSession::ECharging );
   916                 return EFalse;
  1092                 }
   917                 }
  1093             }
   918             }
  1094         }
   919         else
       
   920             {
       
   921             return EFalse;
       
   922             }
  1095     }
   923     }
  1096 
   924 
  1097 // ----------------------------------------------------------------------------
   925 // ----------------------------------------------------------------------------
  1098 // CSysApAppUi::HandleLongPowerKeyPressedL()
   926 // CSysApAppUi::HandleLongPowerKeyPressedL()
  1099 // ----------------------------------------------------------------------------
   927 // ----------------------------------------------------------------------------
  1102     {
   930     {
  1103     TRACES( RDebug::Print( _L("CSysApAppUi::HandleLongPowerKeyPressedL()") ) );
   931     TRACES( RDebug::Print( _L("CSysApAppUi::HandleLongPowerKeyPressedL()") ) );
  1104 
   932 
  1105     TInt swState;
   933     TInt swState;
  1106     RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
   934     RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
  1107 
   935     
  1108     iSysApLightsController->PowerKeyPressedL();
   936     iSysApLightsController->PowerKeyPressedL();  //need to handle later.
  1109 
   937 
  1110     if( swState == ESwStateStartingCriticalApps ||
   938     if( swState == ESwStateStartingCriticalApps ||
  1111         swState == ESwStateSelfTestOK ||
   939         swState == ESwStateSelfTestOK ||
  1112         swState == ESwStateSecurityCheck ||
   940         swState == ESwStateSecurityCheck ||
  1113         swState == ESwStateCriticalPhaseOK ||
   941         swState == ESwStateCriticalPhaseOK ||
  1119         {
   947         {
  1120         if( !iDeviceLockEnabled )
   948         if( !iDeviceLockEnabled )
  1121             {
   949             {
  1122             if( iPowerKeyPopupMenuActive )
   950             if( iPowerKeyPopupMenuActive )
  1123                 {
   951                 {
  1124                 if ( iGlobalListQuery )
   952                 // do nothing
  1125                     {
       
  1126                     iGlobalListQuery->SelectItem();
       
  1127                     }
       
  1128                 }
   953                 }
  1129             else if( !iIgnoreNextPowerKeyRepeats )
   954             else if( !iIgnoreNextPowerKeyRepeats )
  1130                 {
   955                 {
  1131                 if( !iKeyLockEnabled && !IsEncryptionOperationOngoingL() )
   956                 if( !iKeyLockEnabled && !IsEncryptionOperationOngoingL() )
  1132                     {
   957                     {
  1152             }
   977             }
  1153         }
   978         }
  1154     }
   979     }
  1155 
   980 
  1156 // ----------------------------------------------------------------------------
   981 // ----------------------------------------------------------------------------
  1157 // CSysApAppUi::FreeResources()
   982 // CSysApAppUi::IsDeviceModeKey
  1158 // ----------------------------------------------------------------------------
   983 // ----------------------------------------------------------------------------
  1159 
   984 
  1160 void CSysApAppUi::FreeResources()
   985 TBool CSysApAppUi::IsDeviceModeKey( const TKeyEvent& aKeyEvent ) const
  1161     {
   986     {
  1162     TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources") ) );
   987     return CSysApDefaultKeyHandler::IsDeviceModeKey( aKeyEvent );
  1163 
   988     }
  1164     delete iSysApBatteryInfoController;
   989 
  1165     delete iSysApPsmController;
   990 
  1166 
   991 // ----------------------------------------------------------------------------
  1167     delete iSysApAudioRoutingObserver;
   992 // CSysApAppUi::ShowShutdownImage
  1168 
   993 // ----------------------------------------------------------------------------
  1169     delete iProfileNamesArray;
   994 //
  1170     iProfileNamesArray = NULL;
   995 TInt CSysApAppUi::ShowShutdownImage( TInt aBitmapId )
  1171 
   996     {
  1172     if ( iTimer )
   997     TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImage") ) );
  1173         {
   998 
  1174         iTimer->Cancel();
   999     TRAPD( err, ShowShutdownImageL( aBitmapId ) );
  1175         delete iTimer;
  1000 
  1176         }
  1001     if ( err != KErrNone )
  1177 
  1002         {
  1178     if ( iSapTimer )
  1003         TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL failed, err=%d"), err ) );
  1179         {
       
  1180         iSapTimer->Cancel();
       
  1181         delete iSapTimer;
       
  1182         }
       
  1183 
       
  1184     if ( iSysApTimer )
       
  1185         {
       
  1186         iSysApTimer->Cancel();
       
  1187         delete iSysApTimer;
       
  1188         }
       
  1189 
       
  1190     delete iGlobalListQuery;
       
  1191 
       
  1192     RWindowGroup groupWin = iCoeEnv->RootWin();
       
  1193     groupWin.CancelCaptureKey( iCapturedEKeyPowerOff );
       
  1194     groupWin.CancelCaptureKeyUpAndDowns( iCapturedEKeyPowerOffUpAndDowns );
       
  1195 
       
  1196     delete iSysApDefaultKeyHandler;
       
  1197 
       
  1198     if ( iProfileEngine )
       
  1199         {
       
  1200         iProfileEngine->Release();
       
  1201         }
       
  1202 
       
  1203     delete iSysApSsSettingsObserver;
       
  1204     delete iSysApEtelConnector;
       
  1205 
       
  1206     delete iSysApProfileObserver;
       
  1207     delete iSysApNspsHandler;
       
  1208     delete iSysApKeySndHandler;
       
  1209     delete iSysApCenRepMsgWaitingObserver;
       
  1210     delete iSysApCenRepCallForwardingObserver;
       
  1211     delete iSysApConnectionMonitorObserver;
       
  1212     delete iSysApCenRepLightSettingsObserver;
       
  1213     delete iSysApCenRepLogsObserver;
       
  1214     delete iSysApCenRepBtObserver;
       
  1215 //    delete iSysApCenRepFmTxObserver;
       
  1216     delete iSysApCenRepHacSettingObserver;
       
  1217     delete iSysApCenRepController;
       
  1218 
       
  1219     delete iSysApPubSubObserver;
       
  1220 
       
  1221     delete iSysApMMCObserver;
       
  1222     delete iSysApMsgSimMemLowQuery;
       
  1223     delete iSysApWaitNote;
       
  1224     delete iSysApConfirmationQuery;
       
  1225     delete iSysApConfirmationQueryForRestart;
       
  1226     delete iSysApOfflineModeController;
       
  1227     delete iSysApUsbIndicatorController;
       
  1228     delete iSysApBtController;
       
  1229     delete iSysApBtSapController;
       
  1230     delete iSignalNotify;
       
  1231     delete iBatteryNotify;
       
  1232     delete iSysApSystemLock;
       
  1233     delete iSysApLocationPrivacyIndicator;
       
  1234     delete iSysApAccessoryObserver;
       
  1235     delete iSysApMediatorObserver;
       
  1236 
       
  1237     delete iSysApKeyManagement;
       
  1238     iSysApKeyManagement = NULL;
       
  1239     delete iSysApLightsController;
       
  1240     iKeyLock.Close();
       
  1241     delete iSysApFeatureManager;
       
  1242 
       
  1243     // Cleanup ECom, used by key management and light control
       
  1244     REComSession::FinalClose();
       
  1245 
       
  1246     iResourcesFreed = ETrue;
       
  1247     TRACES( RDebug::Print( _L("CSysApAppUi::FreeResources:END") ) );
       
  1248     }
       
  1249 
       
  1250 // ----------------------------------------------------------------------------
       
  1251 // CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
       
  1252 // ----------------------------------------------------------------------------
       
  1253 
       
  1254 void CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
       
  1255     {
       
  1256     TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL aNote: %d"), aNote ) );
       
  1257 
       
  1258     TInt tone( EAvkonSIDNoSound );
       
  1259     TAknGlobalNoteType noteType( EAknGlobalBatteryLowNote );
       
  1260     CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
  1261     TInt secondaryDisplayId(SecondaryDisplay::ECmdNoNote);
       
  1262 
       
  1263     switch ( aNote )
       
  1264         {
       
  1265         case EBatteryLowNote:
       
  1266             noteType = EAknGlobalBatteryLowNote;
       
  1267             tone = EAvkonSIDBatteryLowTone;
       
  1268             break;
       
  1269         case EBatteryFullNote:
       
  1270             noteType = EAknGlobalBatteryFullNote;
       
  1271             tone = EAvkonSIDInformationTone;
       
  1272             break;
       
  1273         case ERechargeBatteryNote:
       
  1274             iSysApLightsController->BatteryEmptyL( ETrue );
       
  1275             noteType = EAknGlobalRechargeBatteryNote;
       
  1276             tone = EAvkonSIDRechargeBatteryTone;
       
  1277             break;
       
  1278         case ENotChargingNote:
       
  1279             noteType = EAknGlobalNotChargingNote;
       
  1280             tone = EAvkonSIDWrongCharger;
       
  1281             break;
       
  1282         case EInsertSimNote:
       
  1283             noteType = EAknGlobalInformationNote;
       
  1284             tone = EAvkonSIDInformationTone;
       
  1285             secondaryDisplayId = SecondaryDisplay::ECmdShowInsertSimNote;
       
  1286             break;
       
  1287         case EMemoryCardRemovedWithoutEjectNote:
       
  1288             noteType = EAknGlobalInformationNote;
       
  1289             tone = EAvkonSIDInformationTone;
       
  1290             secondaryDisplayId = SecondaryDisplay::ECmdShowMemoryCardRemovedWithoutEjectNote;
       
  1291             break;
       
  1292         case EGprsSuspendedNote:
       
  1293             noteType = EAknGlobalInformationNote;
       
  1294             tone = EAvkonSIDInformationTone;
       
  1295             secondaryDisplayId = SecondaryDisplay::ECmdShowGprsSuspendedNote;
       
  1296             break;
       
  1297         case EGprsResumedNote:
       
  1298             noteType = EAknGlobalInformationNote;
       
  1299             tone = EAvkonSIDInformationTone;
       
  1300             secondaryDisplayId = SecondaryDisplay::ECmdShowGprsResumedNote;
       
  1301             break;
       
  1302         case EShutdownNote:
       
  1303             noteType = EAknGlobalInformationNote;
       
  1304             tone = EAvkonSIDInformationTone;
       
  1305             secondaryDisplayId = SecondaryDisplay::ECmdShowShutdownNote;
       
  1306             break;
       
  1307         case ECannotActivateOfflineModeNote:
       
  1308             noteType = EAknGlobalErrorNote;
       
  1309             tone = EAvkonSIDErrorTone;
       
  1310             secondaryDisplayId = SecondaryDisplay::ECmdShowCannotActivateOfflineModeNote;
       
  1311             break;
       
  1312         case ECannotDeactivateOfflineModeNote:
       
  1313             noteType = EAknGlobalErrorNote;
       
  1314             tone = EAvkonSIDErrorTone;
       
  1315             secondaryDisplayId = SecondaryDisplay::ECmdShowCannotDeactivateOfflineModeNote;
       
  1316             break;
       
  1317         case EKeypadActiveNote:
       
  1318             noteType = EAknGlobalInformationNote;
       
  1319             tone = EAvkonSIDInformationTone;
       
  1320             secondaryDisplayId = SecondaryDisplay::ECmdShowKeypadActiveNote;
       
  1321             break;
       
  1322 /*        case EFmTxAccessoryStandbyNote:
       
  1323             noteType = EAknGlobalInformationNote; 
       
  1324             tone = EAvkonSIDInformationTone;
       
  1325             secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxStandbyInAccessoryConnectionNote;
       
  1326             break;
       
  1327         case EFmTxAccessoryForbidsNote:
       
  1328             noteType = EAknGlobalInformationNote; 
       
  1329             tone = EAvkonSIDInformationTone;
       
  1330             secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxCannotEnableWhileAccessoryConnectedNote;
       
  1331             break;
       
  1332         case EFmTxVolumeDisabledNote:
       
  1333             noteType = EAknGlobalInformationNote; 
       
  1334             tone = EAvkonSIDInformationTone;
       
  1335             secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxVolumeDisabledNote;
       
  1336             break;
       
  1337         case EFmTxOnNote:
       
  1338             noteType = EAknGlobalInformationNote; 
       
  1339             tone = EAvkonSIDInformationTone;
       
  1340             secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxTuneRadioToFrequencyNote;
       
  1341             break;
       
  1342         case EFmTxOffNote:
       
  1343             noteType = EAknGlobalInformationNote; 
       
  1344             tone = EAvkonSIDInformationTone;
       
  1345             secondaryDisplayId = SecondaryDisplay::ECmdShowFmTxDisabledNote;
       
  1346             break;
       
  1347 */        case EBatteryFullUnplugChargerNote:
       
  1348             noteType = EAknGlobalBatteryFullUnplugNote;
       
  1349             tone = EAvkonSIDInformationTone;
       
  1350             break;
       
  1351         case EUnplugChargerNote:
       
  1352             noteType = EAknGlobalUnplugChargerNote;
       
  1353             tone = EAvkonSIDInformationTone;
       
  1354             break;
       
  1355         case EPowerSaveModeActivated:
       
  1356             noteType = EAknGlobalConfirmationNote;
       
  1357             tone = EAvkonSIDConfirmationTone;
       
  1358             secondaryDisplayId = SecondaryDisplay::ECmdShowPowerSavingActivatedNote;
       
  1359             break;
       
  1360         case EPowerSaveModeDeactivated:
       
  1361             noteType = EAknGlobalConfirmationNote;
       
  1362             tone = EAvkonSIDConfirmationTone;
       
  1363             secondaryDisplayId = SecondaryDisplay::ECmdShowPowerSavingDeactivatedNote;
       
  1364             break;
       
  1365         case ECannotActivatePowerSaveMode:
       
  1366             noteType = EAknGlobalWarningNote;
       
  1367             tone = EAvkonSIDWarningTone;
       
  1368             secondaryDisplayId = SecondaryDisplay::ECmdShowCannotActivatePowerSavingNote;
       
  1369             break;
       
  1370         case ECannotDeactivatePowerSaveMode:
       
  1371             noteType = EAknGlobalWarningNote;
       
  1372             tone = EAvkonSIDWarningTone;
       
  1373             secondaryDisplayId = SecondaryDisplay::ECmdShowCannotDeactivatePowerSavingNote;
       
  1374             break;
       
  1375         default:
       
  1376             break;
       
  1377 
       
  1378         }
       
  1379 
       
  1380     TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
       
  1381 
       
  1382     if( UiReady() || swState == ESwStateSecurityCheck)
       
  1383         {
       
  1384         HBufC* noteStringBuf = NULL;
       
  1385 
       
  1386         switch ( aNote )
       
  1387             {
       
  1388             case EInsertSimNote:
       
  1389                 noteStringBuf = StringLoader::LoadLC( R_QTN_SU_NOTE_INSERT_SIM, iEikonEnv );
       
  1390                 break;
       
  1391             case EMemoryCardRemovedWithoutEjectNote:
       
  1392                 noteStringBuf = StringLoader::LoadLC( R_QTN_MEMS_EJECT_ERROR, iEikonEnv );
       
  1393                 note->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY );
       
  1394                 break;
       
  1395             case EGprsSuspendedNote:
       
  1396                 noteStringBuf = StringLoader::LoadLC( R_QTN_GPRS_CONF_GPRS_SUSPENDED, iEikonEnv );
       
  1397                 break;
       
  1398             case EGprsResumedNote:
       
  1399                 noteStringBuf = StringLoader::LoadLC( R_QTN_GPRS_CONF_GPRS_RESUMED, iEikonEnv );
       
  1400                 break;
       
  1401             case EShutdownNote:
       
  1402                 noteStringBuf = StringLoader::LoadLC( R_QTN_PWRC_INFO_GOODBYE, iEikonEnv);
       
  1403                 break;
       
  1404             case ECannotActivateOfflineModeNote:
       
  1405                 noteStringBuf = StringLoader::LoadLC( R_QTN_ERR_OFFLINE_UNABLE, iEikonEnv );
       
  1406                 break;
       
  1407             case ECannotDeactivateOfflineModeNote:
       
  1408                 noteStringBuf = StringLoader::LoadLC( R_QTN_ERR_OFFLINE_UNABLE_PROFILE, iEikonEnv );
       
  1409                 break;
       
  1410             case EKeypadActiveNote:
       
  1411                 if ( iSysApFeatureManager->PenEnabled() )
       
  1412                     {
       
  1413                     noteStringBuf = StringLoader::LoadLC( R_QTN_KEYG_CONF_DISPLAY_KEYS_ACTIVE,
       
  1414                                                           iEikonEnv );
       
  1415                     }
       
  1416                 else
       
  1417                     {
       
  1418                     noteStringBuf = StringLoader::LoadLC( R_QTN_KEYG_CONF_KEYPAD_ACTIVE,
       
  1419                                                           iEikonEnv );
       
  1420                     }
       
  1421                 note->SetAnimation( R_QGN_NOTE_KEYGUARD_OPEN_ANIM );
       
  1422                 break;
       
  1423 /*            case EFmTxOnNote:
       
  1424                 {
       
  1425                 const TInt KFrequencyMaxLength(7);
       
  1426                 // read frequency
       
  1427                 TInt frequencykHz = iSysApCenRepFmTxObserver->Frequency();
       
  1428                 TReal frequencyMHz = static_cast<TReal>( frequencykHz ) / KCoefficientKhzToMhz; // kHz to Mhz
       
  1429                 TBuf<KFrequencyMaxLength> frequencyAsString;
       
  1430                 frequencyAsString.AppendNum( frequencyMHz, TRealFormat( KFrequencyMaxLength, KDecimalsInMhzFrequency ) );
       
  1431                 AknTextUtils::LanguageSpecificNumberConversion( frequencyAsString );
       
  1432                 noteStringBuf 
       
  1433                       = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_CHANGE_FREQ, 
       
  1434                                               frequencyAsString,
       
  1435                                               iEikonEnv );
       
  1436                 break;
       
  1437                 }
       
  1438             case EFmTxAccessoryForbidsNote:
       
  1439                 {
       
  1440                 noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_ACCESSORY_FORBIDS, 
       
  1441                                                        iEikonEnv );
       
  1442                 break;
       
  1443                 }
       
  1444             case EFmTxAccessoryStandbyNote:
       
  1445                 {                                     
       
  1446                 noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_ACCESSORY_STANDBY, 
       
  1447                                                        iEikonEnv );
       
  1448                 break;
       
  1449                 }
       
  1450             case EFmTxVolumeDisabledNote:
       
  1451                 {
       
  1452                 noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_VOLUME_DISABLED, 
       
  1453                                                        iEikonEnv );
       
  1454                 break;
       
  1455                 }
       
  1456             case EFmTxOffNote:
       
  1457                 {
       
  1458                 noteStringBuf = StringLoader::LoadLC( R_QTN_FMTX_SYSAP_INFO_NOTE_DISABLED, 
       
  1459                                                        iEikonEnv );
       
  1460                 break;
       
  1461                 }
       
  1462 */            case EPowerSaveModeActivated:
       
  1463                 noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_ACTIVATED_CONF_NOTE, iEikonEnv );
       
  1464                 break;
       
  1465             case EPowerSaveModeDeactivated:
       
  1466                 noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_DEACTIVATED_CONF_NOTE, iEikonEnv );
       
  1467                 break;
       
  1468             case ECannotActivatePowerSaveMode:
       
  1469                 noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_FAILED_WARNING_NOTE, iEikonEnv );
       
  1470                 break;
       
  1471             case ECannotDeactivatePowerSaveMode:
       
  1472                 noteStringBuf = StringLoader::LoadLC( R_QTN_POWER_SAVING_DEACTIVATION_FAILED_WARNING_NOTE, iEikonEnv ); 
       
  1473                 break;
       
  1474             default:
       
  1475                 break;
       
  1476             }
       
  1477 
       
  1478         note->SetTone( tone );
       
  1479 
       
  1480         // Set secondary display data if necessary
       
  1481 /*        if ( iSysApFeatureManager->CoverDisplaySupported() && secondaryDisplayId != SecondaryDisplay::ECmdNoNote)
       
  1482             {
       
  1483             TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL - Notifying secondary display") ) );
       
  1484             CAknSDData* sd;
       
  1485             
       
  1486             if ( aNote == EFmTxOnNote ) // frequency information is passed to secondary display
       
  1487                 {
       
  1488                 SecondaryDisplay::TFmTxFrequencyInKhzPckg pckg( iSysApCenRepFmTxObserver->Frequency() );
       
  1489                 sd = CAknSDData::NewL( SecondaryDisplay::KCatSysAp, secondaryDisplayId, pckg );
       
  1490                 }
       
  1491             else
       
  1492                 {
       
  1493                 sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, secondaryDisplayId, KNullDesC8);
       
  1494                 }
       
  1495              
       
  1496             note->SetSecondaryDisplayData(sd); // ownership to notifier client
       
  1497             }
       
  1498 */
       
  1499         if ( noteStringBuf )
       
  1500             {
       
  1501             TPtr textBuffer = noteStringBuf->Des();
       
  1502             TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL Next:note->ShowNoteL" ) ) );
       
  1503             note->ShowNoteL( noteType, textBuffer );
       
  1504             CleanupStack::PopAndDestroy( ); // noteStringbuf
       
  1505             }
       
  1506         else
       
  1507             {
       
  1508             TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL Next:note->ShowNoteL" ) ) );
       
  1509             note->ShowNoteL( noteType, KNullDesC );
       
  1510             }
       
  1511         }
       
  1512     else if( swState == ESwStateAlarm || swState == ESwStateCharging )
       
  1513         {
       
  1514         if ( aNote != EUnplugChargerNote ) // don't play tone when charger is disconnected in charging state
       
  1515             {
       
  1516             static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( tone );    
       
  1517             }
       
  1518         }
       
  1519 
       
  1520     CleanupStack::PopAndDestroy(); // note
       
  1521     }
       
  1522 
       
  1523 // ----------------------------------------------------------------------------
       
  1524 // CSysApAppUi::ShowChargingNoteL()
       
  1525 // ----------------------------------------------------------------------------
       
  1526 
       
  1527 void CSysApAppUi::ShowChargingNoteL()
       
  1528     {
       
  1529     TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL") ) );
       
  1530     TBool showNote( ETrue );
       
  1531 
       
  1532     TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
       
  1533     TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL: swState: %d"), swState ) );
       
  1534 
       
  1535     if( UiReady() || swState == ESwStateSecurityCheck )
       
  1536         {
       
  1537         if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ==  EPSCTsyCallStateRinging )
       
  1538             {
       
  1539             showNote = EFalse;
       
  1540             }
       
  1541         TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL KCTsyCallState=%d"), StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ) );
       
  1542         if ( showNote ) // Power Mgmt UI spec defines that no Charging note is shown while the phone is ringing/alerting
       
  1543             {
       
  1544             CAknGlobalNote* chargingNote = CAknGlobalNote::NewLC();
       
  1545             chargingNote->SetTone( EAvkonSIDChargingBatteryTone );
       
  1546             chargingNote->ShowNoteL( EAknGlobalChargingNote, KNullDesC );
       
  1547             CleanupStack::PopAndDestroy( chargingNote );
       
  1548             }
       
  1549         }
       
  1550     else if( swState == ESwStateAlarm || swState == ESwStateCharging )
       
  1551         {
       
  1552         TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL - Just play tone") ) );
       
  1553         static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDChargingBatteryTone );
       
  1554         }
       
  1555     else
       
  1556         {
       
  1557         TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL - No note shown") ) );
       
  1558         }
       
  1559     }
       
  1560 
       
  1561 // ----------------------------------------------------------------------------
       
  1562 // CSysApAppUi::HandleChargerNotesL()
       
  1563 // ----------------------------------------------------------------------------
       
  1564 void CSysApAppUi::HandleChargerNotesL( const TInt aValue )
       
  1565     {
       
  1566     TBool showNote(StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging);
       
  1567     if ( aValue == EChargingStatusCharging )
       
  1568         {
       
  1569         iSysApLightsController->BatteryEmptyL( EFalse );
       
  1570         TRACES( RDebug::Print( _L("SysAp: charger connected") ) );
       
  1571         iSysApLightsController->ChargerConnectedL( ETrue );
       
  1572         ShowChargingNoteL();
       
  1573         }
       
  1574     //Display Not Charging note
       
  1575     else if ( aValue == EChargingStatusError )
       
  1576         {
       
  1577         if(showNote)
       
  1578             {
       
  1579             ShowUiNoteL( ENotChargingNote );
       
  1580             }
       
  1581         }
       
  1582     else if ( aValue == EChargingStatusChargingComplete )
       
  1583         {
       
  1584         iSysApLightsController->ChargingCompleteL();
       
  1585         
       
  1586         TSysApNoteIds note( EBatteryFullNote );
       
  1587         
       
  1588         if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
       
  1589              iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
       
  1590             {
       
  1591             note = EBatteryFullUnplugChargerNote;
       
  1592             }
       
  1593         iSysApUsbChargerDetector.Reset();
       
  1594         if(showNote)
       
  1595             {
       
  1596             ShowUiNoteL( note );
       
  1597             }
       
  1598         }
       
  1599     else if ( aValue == EChargingStatusNotConnected )
       
  1600         {
       
  1601         TRACES( RDebug::Print( _L("SysAp: charger removed") ) );
       
  1602         iSysApLightsController->ChargerConnectedL( EFalse );
       
  1603         
       
  1604         if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
       
  1605              iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
       
  1606             {
       
  1607 		if(showNote)
       
  1608                 {
       
  1609                 ShowUiNoteL( EUnplugChargerNote );
       
  1610                 }
       
  1611             }
       
  1612         iSysApUsbChargerDetector.Reset();
       
  1613         }
       
  1614     else if ( aValue == EChargingStatusNotCharging )
       
  1615         {
       
  1616         TRACES( RDebug::Print( _L("SysAp: Not charging") ) );
       
  1617         }
       
  1618     else if ( aValue == EChargingStatusAlmostComplete )
       
  1619         {
       
  1620         TRACES( RDebug::Print( _L("SysAp: Charging almost complete") ) );
       
  1621         }
       
  1622     else if ( aValue == EChargingStatusChargingContinued )
       
  1623         {
       
  1624         //in this case we simply want to scroll the battery bars and not turn light on or show ui note
       
  1625         // set lights controller iBatteryEmpty to EFalse
       
  1626         iSysApLightsController->BatteryEmptyL( EFalse );
       
  1627         TRACES( RDebug::Print( _L("SysAp: charging continues") ) );
       
  1628         }
       
  1629     }
       
  1630 
       
  1631 // ----------------------------------------------------------------------------
       
  1632 // CSysApAppUi::ShowProfileNoteL()
       
  1633 // ----------------------------------------------------------------------------
       
  1634 
       
  1635 void CSysApAppUi::ShowProfileNoteL()
       
  1636     {
       
  1637     TRACES( RDebug::Print( _L("CSysApAppUi::ShowProfileNoteL") ) );
       
  1638 
       
  1639     if ( UiReady() )
       
  1640         {
       
  1641         if ( iProfileNote )
       
  1642             {
       
  1643             // when a call is coming in, there might be a pending "Selected profile"
       
  1644             // we don't want to show anymore
       
  1645             iProfileNote->CancelNoteL( iProfileNoteId );
       
  1646             }
       
  1647 
       
  1648         TBufC<KMaxProfileNameLength> profileName;
       
  1649         HBufC* noteStringBuf = NULL;
       
  1650         ActiveProfileNameL( profileName.Des() );
       
  1651         noteStringBuf = StringLoader::LoadLC( R_TEXT_MODE_SELECTED, profileName, iEikonEnv );
       
  1652         TPtr textBuffer = noteStringBuf->Des();
       
  1653         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( textBuffer );
       
  1654 
       
  1655         // profile note is constructed when it is needed for the first time
       
  1656         if ( !iProfileNote )
       
  1657             {
       
  1658             iProfileNote = CAknGlobalNote::NewL();
       
  1659             iProfileNote->SetTone( EAvkonSIDConfirmationTone );
       
  1660             }
       
  1661 
       
  1662         // Set secondary display data if necessary
       
  1663         if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  1664             {
       
  1665             TRACES( RDebug::Print( _L("CSysApAppUi::ShowProfileNoteL - Notifying secondary display") ) );
       
  1666             SecondaryDisplay::TProfileName sdProfileName;
       
  1667             sdProfileName.Append(profileName.Left(SecondaryDisplay::KProfileNameMaxLen));
       
  1668             SecondaryDisplay::TProfileNotePckg pckg(sdProfileName);
       
  1669             CAknSDData* sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, SecondaryDisplay::ECmdShowProfileNote, pckg);
       
  1670             iProfileNote->SetSecondaryDisplayData(sd); // ownership to notifier client
       
  1671             }
       
  1672 
       
  1673         iProfileNoteId = iProfileNote->ShowNoteL( EAknGlobalConfirmationNote, textBuffer );
       
  1674 
       
  1675         CleanupStack::PopAndDestroy( ); // noteStringbuf
       
  1676 
       
  1677         iSysApLightsController->ProfileChangedL(); // All notes should always turn lights on.
       
  1678         }
       
  1679     }
       
  1680 
       
  1681 // ----------------------------------------------------------------------------
       
  1682 // CSysApAppUi::ShowQueryL()
       
  1683 // ----------------------------------------------------------------------------
       
  1684 
       
  1685 void CSysApAppUi::ShowQueryL( const TSysApConfirmationQueryIds aQueryId, const TDesC& aValue )
       
  1686     {
       
  1687     CancelGlobalListQuery();
       
  1688 
       
  1689     if ( aQueryId == ESysApRestartPhoneQuery )
       
  1690         {
       
  1691         iDisablePowerkeyMenu = ETrue;
       
  1692         // Cancel any other query that might be outstanding (i.e. ESysApRemoveMmcNote),
       
  1693         // to avoid multiple overlapping queries causing problems
       
  1694         if ( iSysApConfirmationQuery )
       
  1695             {
       
  1696             iSysApConfirmationQuery->Cancel();
       
  1697             }
       
  1698 
       
  1699         if ( !iSysApConfirmationQueryForRestart )
       
  1700             {
       
  1701             TRACES( RDebug::Print( _L("CSysApAppUi::ShowQueryL: trying CSysApConfirmationQuery::NewL() for restart") ) );
       
  1702             iSysApConfirmationQueryForRestart = CSysApConfirmationQuery::NewL( *this );
       
  1703             }
       
  1704 
       
  1705         iSysApConfirmationQueryForRestart->ShowQueryL( aQueryId, iEikonEnv );
       
  1706         }
       
  1707     else
       
  1708         {
       
  1709         if ( !iSysApConfirmationQuery )
       
  1710             {
       
  1711             TRACES( RDebug::Print( _L("CSysApAppUi::ShowQueryL: trying CSysApConfirmationQuery::NewL()") ) );
       
  1712             iSysApConfirmationQuery = CSysApConfirmationQuery::NewL( *this );
       
  1713             }
       
  1714 
       
  1715         iSysApConfirmationQuery->ShowQueryL( aQueryId, aValue, iEikonEnv );
       
  1716         }
       
  1717     }
       
  1718 
       
  1719 // ----------------------------------------------------------------------------
       
  1720 // CSysApAppUi::UpdateBatteryBarsL( const TInt aState )
       
  1721 // ----------------------------------------------------------------------------
       
  1722 
       
  1723 void CSysApAppUi::UpdateBatteryBarsL( const TInt aState )
       
  1724     {
       
  1725     TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
       
  1726     TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL aState: %d, chargerState:%d"), aState, state ) );
       
  1727     HandleUsbCharger( state );
       
  1728     if( state == EChargingStatusCharging ||
       
  1729         state == EChargingStatusChargingContinued ||
       
  1730         state == EChargingStatusAlmostComplete )
       
  1731         {
       
  1732         if ( !iCharging )
       
  1733             {
       
  1734             TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Starting Charging") ) );
       
  1735             iBatteryNotify->StartChargingL();
       
  1736             iCharging = ETrue;
       
  1737             }
       
  1738 
       
  1739         // When Avkon supports battery state sending while charging,
       
  1740         // add setting battery level here also.
       
  1741         }
       
  1742     else
       
  1743         {
       
  1744         if ( iCharging )
       
  1745             {
       
  1746             TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Stopping Charging") ) );
       
  1747             iBatteryNotify->StopChargingL();
       
  1748             iCharging = EFalse;
       
  1749             }
       
  1750 
       
  1751         if( state == KErrUnknown || aState == KErrUnknown )
       
  1752             {
       
  1753             TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: CAknBatteryNotify::SetBatteryLevelL(0)") ) );
       
  1754             iBatteryNotify->SetBatteryLevelL( 0 );
       
  1755             }
       
  1756         else
       
  1757             {
       
  1758             TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: CAknBatteryNotify::SetBatteryLevelL(%d)"), aState - EBatteryLevelLevel0 ) );
       
  1759             iBatteryNotify->SetBatteryLevelL( aState - EBatteryLevelLevel0 );
       
  1760             }
       
  1761         }
       
  1762     
       
  1763     if ( !iSysApPsmController ) // created here if first state change has not occurred yet
       
  1764         {
       
  1765         iSysApPsmController = CSysApPsmController::NewL( *this );        
       
  1766         }
       
  1767 
       
  1768     if ( iSysApPsmController )
       
  1769         {
       
  1770         if ( iSysApPsmController->FullPsmEnabled() )
       
  1771             {
       
  1772             iBatteryNotify->SetBatteryStateL( EAknBatteryIndicatorPowerSave );
       
  1773             }
       
  1774         else
       
  1775             {
       
  1776             iBatteryNotify->SetBatteryStateL( EAknBatteryIndicatorNormal );
       
  1777             }            
       
  1778         }
       
  1779         
       
  1780     if ( iSysApBatteryInfoController )        
       
  1781         {
       
  1782         iSysApBatteryInfoController->BatteryLevelUpdatedL();
       
  1783         }
       
  1784     }
       
  1785 
       
  1786 // ----------------------------------------------------------------------------
       
  1787 // CSysApAppUi::UpdateSignalBarsL()
       
  1788 // ----------------------------------------------------------------------------
       
  1789 
       
  1790 void CSysApAppUi::UpdateSignalBarsL()
       
  1791     {
       
  1792     UpdateSignalBarsL(iSysApEtelConnector->GetSignalBars());
       
  1793     }
       
  1794 
       
  1795 // ----------------------------------------------------------------------------
       
  1796 // CSysApAppUi::UpdateSignalBarsL( const TInt aState )
       
  1797 // ----------------------------------------------------------------------------
       
  1798 
       
  1799 void CSysApAppUi::UpdateSignalBarsL( const TInt aState )
       
  1800     {
       
  1801     TRACES( RDebug::Print( _L("CSysApAppUi::UpdateSignalBarsL aState: %d"), aState ) );
       
  1802 
       
  1803     if( aState == KAknSignalOffLineMode || (iSysApOfflineModeController->OfflineModeActive() && !iEmergencyCallActive) )
       
  1804         {
       
  1805         iSignalNotify->SetSignalLevelL( KAknSignalOffLineMode );
       
  1806         }
       
  1807     else if( aState <= 0 )
       
  1808         {
       
  1809         // Do not update indicator show zero bars if we should be showing X over bars
       
  1810         // This is required for indicator to work correctly in BT SAP mode.
       
  1811         // Cannot use check for BT SAP enabled status, as zero bars notify comes before enabled status changes.
       
  1812         if ( !iIgnoreZeroNetworkBarNotifications )
       
  1813             {
       
  1814             iSignalNotify->SetSignalLevelL( 0 );
       
  1815             }
       
  1816         }
       
  1817     else
       
  1818         {
       
  1819         iSignalNotify->SetSignalLevelL( aState );
       
  1820         }
       
  1821     }
       
  1822 
       
  1823 // ----------------------------------------------------------------------------
       
  1824 // CSysApAppUi::SetSignalIndicatorL()
       
  1825 // ----------------------------------------------------------------------------
       
  1826 
       
  1827 void CSysApAppUi::SetSignalIndicatorL()
       
  1828     {
       
  1829     TSysApNetworkMode networkMode( ESysApGSM );
       
  1830 
       
  1831     TInt networkModeFromNetworkInfo( StateOfProperty( KPSUidNetworkInfo, KNWTelephonyNetworkMode ) );
       
  1832     if ( networkModeFromNetworkInfo == ENWNetworkModeWcdma )
       
  1833         {
       
  1834         networkMode = ESysApWCDMA;
       
  1835         }
       
  1836     else
       
  1837         {
       
  1838         networkMode = ESysApGSM;
       
  1839         }
       
  1840 
       
  1841     TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorL: networkMode = %d" ), networkMode ) );
       
  1842 
       
  1843     if( iSysApOfflineModeController->OfflineModeActive() && !iEmergencyCallActive )
       
  1844         {
       
  1845         // The device is in Offline Mode
       
  1846         if ( iSysApFeatureManager->Supported( KSysApFeatureIdGprs_G_Icon ) )
       
  1847             {
       
  1848             iSignalNotify->SetGprsStateL( EAknSignalGprsIndicatorOff );
       
  1849             }
       
  1850         else
       
  1851             {
       
  1852             iSignalNotify->SetCommonPacketDataStateL( EAknSignalCommonPacketDataIndicatorOff );
       
  1853             }
       
  1854         iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
       
  1855         iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff);
       
  1856         }
       
  1857     else
       
  1858         {
       
  1859         // The device is in Online Mode
       
  1860         switch ( networkMode )
       
  1861             {
       
  1862             case ESysApGSM:
       
  1863                 SetSignalIndicatorGsmL();
       
  1864                 break;
       
  1865 
       
  1866             case ESysApWCDMA:
       
  1867                 SetSignalIndicatorWcdmaL();
       
  1868                 break;
       
  1869 
       
  1870             default:
       
  1871                 break;
       
  1872             }
       
  1873         }
       
  1874     }
       
  1875 
       
  1876 // ----------------------------------------------------------------------------
       
  1877 // CSysApAppUi::SetSignalIndicatorGsmL()
       
  1878 // ----------------------------------------------------------------------------
       
  1879 void CSysApAppUi::SetSignalIndicatorGsmL()
       
  1880     {
       
  1881     TInt signalGprsIndicatorState( 0 );
       
  1882     TInt signalIndicatorState( 0 );
       
  1883 	TInt bearerValue = EBearerUnknown;
       
  1884 
       
  1885 	if(iSysApConnectionMonitorObserver)
       
  1886 		{
       
  1887 		bearerValue = iSysApConnectionMonitorObserver->GetBearerValue();
       
  1888 		}
       
  1889 
       
  1890 	if(bearerValue == EBearerEdgeGPRS)
       
  1891 		{
       
  1892 		TInt egprsStatus = StateOfProperty( KUidSystemCategory, KPSUidGprsStatusValue );
       
  1893 	    TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorGsmL gprsStatus: %d" ), egprsStatus ) );
       
  1894 	    iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
       
  1895 	    iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff );
       
  1896 	    switch ( egprsStatus )
       
  1897 	        {
       
  1898 	        case EPSGprsContextActive:
       
  1899 	            signalGprsIndicatorState = EAknSignalEdgeIndicatorContext;
       
  1900 	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorContext;
       
  1901 	            iGprsActivated = ETrue;
       
  1902 	            iGprsSuspended = EFalse;
       
  1903 	            HandleGprsNotesL();
       
  1904 	            break;
       
  1905 
       
  1906 	        case EPSGprsContextActivating:
       
  1907 	            signalGprsIndicatorState = EAknSignalEdgeIndicatorEstablishingContext;
       
  1908 	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorEstablishingContext;
       
  1909 	            iGprsActivated = EFalse;
       
  1910 	            iGprsSuspended = EFalse;
       
  1911 	            break;
       
  1912 
       
  1913 	        case EPSGprsSuspend:
       
  1914 	            signalGprsIndicatorState = EAknSignalEdgeIndicatorSuspended;
       
  1915 	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorSuspended;
       
  1916 	            iGprsSuspended = ETrue;
       
  1917 	            HandleGprsNotesL();
       
  1918 	            break;
       
  1919 
       
  1920 	        case EPSGprsAttach:
       
  1921 	            signalGprsIndicatorState = EAknSignalEdgeIndicatorAttached;
       
  1922 	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorAttached;
       
  1923 	            iGprsActivated = EFalse;
       
  1924 	            iGprsSuspended = EFalse;
       
  1925 	            break;
       
  1926 
       
  1927 	        case EPSGprsMultibleContextActive:
       
  1928 	            signalGprsIndicatorState = EAknSignalEdgeIndicatorMultipdp;
       
  1929 	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorMultipdp;
       
  1930 	            iGprsActivated = ETrue;
       
  1931 	            iGprsSuspended = EFalse;
       
  1932 	            HandleGprsNotesL();
       
  1933 	            break;
       
  1934 
       
  1935 	        case EPSGprsUnattached:
       
  1936 	        default:
       
  1937 	            signalGprsIndicatorState = EAknSignalEdgeIndicatorOff;
       
  1938 	            signalIndicatorState = EAknSignalCommonPacketDataIndicatorOff;
       
  1939 	            iGprsSuspendedNoteShown = EFalse;
       
  1940 	            iGprsActivated = EFalse;
       
  1941 	            iGprsSuspended = EFalse;
       
  1942 	            iCallActivated = EFalse;
       
  1943 	            break;
       
  1944 	        }
       
  1945         }
       
  1946 	else
       
  1947 		{
       
  1948 
       
  1949 		TInt gprsStatus = StateOfProperty( KUidSystemCategory, KPSUidGprsStatusValue );
       
  1950     	TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorGsmL gprsStatus: %d" ), gprsStatus ) );
       
  1951     	iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
       
  1952     	iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff );
       
  1953     	switch ( gprsStatus )
       
  1954             {
       
  1955             case EPSGprsContextActive:
       
  1956                 signalGprsIndicatorState = EAknSignalGprsIndicatorContext;
       
  1957                 signalIndicatorState = EAknSignalCommonPacketDataIndicatorContext;
       
  1958                 iGprsActivated = ETrue;
       
  1959                 iGprsSuspended = EFalse;
       
  1960                 HandleGprsNotesL();
       
  1961                 break;
       
  1962 
       
  1963             case EPSGprsContextActivating:
       
  1964                 signalGprsIndicatorState = EAknSignalGprsIndicatorEstablishingContext;
       
  1965                 signalIndicatorState = EAknSignalCommonPacketDataIndicatorEstablishingContext;
       
  1966                 iGprsActivated = EFalse;
       
  1967                 iGprsSuspended = EFalse;
       
  1968                 break;
       
  1969 
       
  1970             case EPSGprsSuspend:
       
  1971                 signalGprsIndicatorState = EAknSignalGprsIndicatorSuspended;
       
  1972                 signalIndicatorState = EAknSignalCommonPacketDataIndicatorSuspended;
       
  1973                 iGprsSuspended = ETrue;
       
  1974                 HandleGprsNotesL();
       
  1975                 break;
       
  1976 
       
  1977             case EPSGprsAttach:
       
  1978                 signalGprsIndicatorState = EAknSignalGprsIndicatorAttached;
       
  1979                 signalIndicatorState = EAknSignalCommonPacketDataIndicatorAttached;
       
  1980                 iGprsActivated = EFalse;
       
  1981                 iGprsSuspended = EFalse;
       
  1982                 break;
       
  1983 
       
  1984             case EPSGprsMultibleContextActive:
       
  1985                 signalGprsIndicatorState = EAknSignalGprsIndicatorMultipdp;
       
  1986                 signalIndicatorState = EAknSignalCommonPacketDataIndicatorMultipdp;
       
  1987                 iGprsActivated = ETrue;
       
  1988                 iGprsSuspended = EFalse;
       
  1989                 HandleGprsNotesL();
       
  1990                 break;
       
  1991 
       
  1992             case EPSGprsUnattached:
       
  1993             default:
       
  1994                 signalGprsIndicatorState = EAknSignalGprsIndicatorOff;
       
  1995                 signalIndicatorState = EAknSignalCommonPacketDataIndicatorOff;
       
  1996                 iGprsSuspendedNoteShown = EFalse;
       
  1997                 iGprsActivated = EFalse;
       
  1998                 iGprsSuspended = EFalse;
       
  1999                 iCallActivated = EFalse;
       
  2000                 break;
       
  2001             }
       
  2002 		}
       
  2003 
       
  2004 	if(bearerValue == EBearerEdgeGPRS) //EdgeGPRS connection
       
  2005 		{
       
  2006 		if( iSysApFeatureManager->Supported( KSysApFeatureIdUseEdgeGPRSIcon ) )
       
  2007 	    	{
       
  2008 	    	iSignalNotify->SetEdgeStateL( signalGprsIndicatorState );
       
  2009 	    	}
       
  2010 	    else
       
  2011         	{
       
  2012         	iSignalNotify->SetCommonPacketDataStateL( signalIndicatorState );
       
  2013         	}
       
  2014 		}
       
  2015 	else
       
  2016 		{
       
  2017 
       
  2018 	    if ( iSysApFeatureManager->Supported( KSysApFeatureIdGprs_G_Icon ) )
       
  2019     	    {
       
  2020         	iSignalNotify->SetGprsStateL( signalGprsIndicatorState );
       
  2021         	}
       
  2022     	else
       
  2023         	{
       
  2024         	TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorGsmL SetCommonPacketDataStateL( %d )" ), signalIndicatorState ) );
       
  2025         	iSignalNotify->SetCommonPacketDataStateL( signalIndicatorState );
       
  2026         	}
       
  2027 		}
       
  2028     }
       
  2029 
       
  2030 // ----------------------------------------------------------------------------
       
  2031 // CSysApAppUi::SetSignalIndicatorWcdmaL()
       
  2032 // ----------------------------------------------------------------------------
       
  2033 void CSysApAppUi::SetSignalIndicatorWcdmaL()
       
  2034     {
       
  2035     TInt wcdmaStatus;
       
  2036     wcdmaStatus = StateOfProperty( KUidSystemCategory, KPSUidWcdmaStatusValue );
       
  2037     TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorWcdmaL: wcdmaStatus: %d" ), wcdmaStatus ) );
       
  2038 
       
  2039     if ( iSysApFeatureManager->Supported( KSysApFeatureIdGprs_G_Icon ) )
       
  2040         {
       
  2041         iSignalNotify->SetGprsStateL( EAknSignalGprsIndicatorOff );
       
  2042         }
       
  2043     else
       
  2044         {
       
  2045         iSignalNotify->SetCommonPacketDataStateL( EAknSignalCommonPacketDataIndicatorOff );
       
  2046         }
       
  2047 
       
  2048     TInt signalWcdmaIndicatorState;
       
  2049     TInt signalHsdpaIndicatorState;
       
  2050 
       
  2051     switch ( wcdmaStatus )
       
  2052         {
       
  2053         case EPSWcdmaContextActive:
       
  2054             signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorContext;
       
  2055             signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorContext;
       
  2056             break;
       
  2057         case EPSWcdmaContextActivating:
       
  2058             signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorEstablishingContext;
       
  2059             signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorEstablishingContext;
       
  2060             break;
       
  2061         case EPSWcdmaSuspend:
       
  2062             signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorSuspended;
       
  2063             signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorSuspended;
       
  2064             break;
       
  2065         case EPSWcdmaAttach:
       
  2066             signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorAttached;
       
  2067             signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorAttached;
       
  2068             break;
       
  2069         case EPSWcdmaMultipleContextActive:
       
  2070             signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorMultipdp;
       
  2071             signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorMultipdp;
       
  2072             break;
       
  2073         case EPSWcdmaUnattached:
       
  2074         default:
       
  2075             signalWcdmaIndicatorState = EAknSignalWcdmaIndicatorAvailable;
       
  2076             signalHsdpaIndicatorState = EAknSignalHsdpaIndicatorAvailable;
       
  2077             break;
       
  2078         }
       
  2079 
       
  2080     TBool showHsdpaAvailable = EFalse;
       
  2081 
       
  2082     if ( iSysApFeatureManager->Supported( KSysApFeatureIdUseHsdpaAvailableIcon ) )
       
  2083         {
       
  2084         // HSDPA Resource Availability information is a configurable feature.
       
  2085         showHsdpaAvailable = iSysApEtelConnector->HsdpaAvailable();
       
  2086         }
       
  2087     
       
  2088     TBool isHsdpaBearer = iSysApEtelConnector->IsBearerHsdpa();
       
  2089     
       
  2090     TRACES( RDebug::Print( _L("CSysApAppUi::SetSignalIndicatorWcdmaL: isHdpaBearer=%d, showHsdpaAvailable=%d" ),
       
  2091             isHsdpaBearer, showHsdpaAvailable ) );
       
  2092     
       
  2093     if ( isHsdpaBearer || showHsdpaAvailable )
       
  2094         {
       
  2095         iSignalNotify->SetWcdmaStateL( EAknSignalWcdmaIndicatorOff );
       
  2096     	iSignalNotify->SetHsdpaStateL( signalHsdpaIndicatorState );
       
  2097         }
       
  2098     else
       
  2099         {
       
  2100         iSignalNotify->SetHsdpaStateL( EAknSignalHsdpaIndicatorOff );
       
  2101         iSignalNotify->SetWcdmaStateL( signalWcdmaIndicatorState );
       
  2102         }
       
  2103     }
       
  2104 
       
  2105 // ----------------------------------------------------------------------------
       
  2106 // CSysApAppUi::HandleGprsNotesL()
       
  2107 // ----------------------------------------------------------------------------
       
  2108 
       
  2109 void CSysApAppUi::HandleGprsNotesL()
       
  2110     {
       
  2111     TRACES( RDebug::Print( _L("CSysApAppUi::HandleGprsNotesL" ) ) );
       
  2112     if ( iSysApFeatureManager->Supported( KSysApFeatureIdGPRSNotes ) )
       
  2113         {
       
  2114         // In WCDMA system, receiving or making calls has no effect to the possibly
       
  2115         // existing PDP contexts i.e. GPRS notes are not needed.
       
  2116         TInt networkMode = StateOfProperty( KPSUidNetworkInfo, KNWTelephonyNetworkMode );
       
  2117         TRACES( RDebug::Print( _L("CSysApAppUi::HandleGprsNotesL: networkMode %d" ), networkMode ) );
       
  2118         if ( networkMode != ENWNetworkModeWcdma )
       
  2119             {
       
  2120             if ( iGprsActivated && iGprsSuspended && iCallActivated && !iGprsSuspendedNoteShown )
       
  2121                 {
       
  2122                 StartGprsSuspendedTimer();
       
  2123                 }
       
  2124             else if ( iGprsSuspendedNoteShown && !iGprsSuspended )
       
  2125                 {
       
  2126                 ShowUiNoteL( EGprsResumedNote );
       
  2127                 iGprsSuspendedNoteShown = EFalse;
       
  2128                 iGprsSuspended = EFalse;
       
  2129                 iCallActivated = EFalse;
       
  2130                 }
       
  2131             }
       
  2132         }
       
  2133     }
       
  2134 
       
  2135 // ----------------------------------------------------------------------------
       
  2136 // CSysApAppUi::SetIndicatorStateL( TInt aIndicator, TInt aState )
       
  2137 // ----------------------------------------------------------------------------
       
  2138 
       
  2139 void CSysApAppUi::SetIndicatorStateL( const TInt aIndicator, const TInt aState ) const
       
  2140     {
       
  2141     CAknSmallIndicator* theIndicator = CAknSmallIndicator::NewLC( TUid::Uid( aIndicator ) );
       
  2142     theIndicator->SetIndicatorStateL( aState );
       
  2143     CleanupStack::PopAndDestroy(); //theIndicator
       
  2144     }
       
  2145 
       
  2146 // ----------------------------------------------------------------------------
       
  2147 // CSysApAppUi::GoOnlineL()
       
  2148 // ----------------------------------------------------------------------------
       
  2149 
       
  2150 void CSysApAppUi::GoOnlineL( TBool aDoProfileChange )
       
  2151     {
       
  2152     if ( iSysApFeatureManager->OfflineModeSupported() )
       
  2153         {
       
  2154         TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: going from off-line into on-line: aDoProfileChange=%d" ), aDoProfileChange ) );
       
  2155         // in case profile change is not needed, event handling for subsequent profile changes are must be allowed
       
  2156         iHandleNextProfileEvent = !aDoProfileChange;
       
  2157         iActivateBt = iSysApOfflineModeController->MustBtBeActivated();
       
  2158 
       
  2159         if ( aDoProfileChange )
       
  2160             {
       
  2161             TRAPD( err, ActivateProfileL( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode ) ) );
       
  2162             if ( err == KErrNotFound )
       
  2163                 {
       
  2164                 // Activate general profile instead, if previously used profile was not found
       
  2165                 TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: Previously used profile was not found, restoring to general profile" ) ) );
       
  2166                 ActivateProfileL(KGeneralProfileId);
       
  2167                 }
       
  2168             }
       
  2169 
       
  2170         iSysApOfflineModeController->SwitchFromOfflineToOnlineModeL();
       
  2171         TRACES( RDebug::Print( _L("CSysApAppUi::GoOnlineL: iActivateBt = %d" ), iActivateBt ) );
       
  2172         }
       
  2173     }
       
  2174 
       
  2175 // ----------------------------------------------------------------------------
       
  2176 // CSysApAppUi::GoOfflineL()
       
  2177 // ----------------------------------------------------------------------------
       
  2178 
       
  2179 void CSysApAppUi::GoOfflineL()
       
  2180     {
       
  2181     if ( iSysApFeatureManager->OfflineModeSupported() )
       
  2182         {
       
  2183         TRACES( RDebug::Print( _L("CSysApAppUi::GoOfflineL" ) ) );
       
  2184         iHandleNextProfileEvent = EFalse;
       
  2185         iDeactivateBt = ETrue;
       
  2186         ActivateProfileL( KOfflineModeProfileId );
       
  2187         iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
       
  2188         }
       
  2189     }
       
  2190 
       
  2191 // ----------------------------------------------------------------------------
       
  2192 // CSysApAppUi::SwitchFromOnlineToOfflineModeL()
       
  2193 // ----------------------------------------------------------------------------
       
  2194 void CSysApAppUi::SwitchFromOnlineToOfflineModeL()
       
  2195     {
       
  2196 /*    if ( iSysApFeatureManager->FmTxSupported() )
       
  2197         {
       
  2198         TFmTxState state = static_cast<TFmTxState>(StateOfProperty( KPSUidHWRMFmTx, KHWRMFmTxStatus ));
       
  2199         switch ( state )
       
  2200             {
       
  2201             case EFmTxStateActive:
       
  2202             case EFmTxStateInactive:
       
  2203             case EFmTxStateScanning:
       
  2204                 ShowQueryL( ESysApUseFmTxInOfflineQuery ); // show "use fm tx in offline?" if FM TX is on
       
  2205                 break;
       
  2206             
       
  2207             default:
       
  2208                 // do nothing
       
  2209                 break;                
       
  2210             }
       
  2211         }
       
  2212 */    iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
       
  2213     }
       
  2214 
       
  2215 // ----------------------------------------------------------------------------
       
  2216 // CSysApAppUi::OfflineModeChangedL()
       
  2217 // ----------------------------------------------------------------------------
       
  2218 void CSysApAppUi::OfflineModeChangedL()
       
  2219     {
       
  2220 #ifdef SYSAP_USE_STARTUP_UI_PHASE    
       
  2221     // if UI is not ready, don't update indicators
       
  2222     if ( !UiReady() )
       
  2223         {
       
  2224         return;
       
  2225         }
       
  2226 #endif // SYSAP_USE_STARTUP_UI_PHASE
       
  2227     
       
  2228     // Update network bar indicator
       
  2229     if ( OfflineModeActive() )
       
  2230         {
       
  2231         UpdateSignalBarsL( KAknSignalOffLineMode );
       
  2232         }
       
  2233     else
       
  2234         {
       
  2235         UpdateSignalBarsL();    
       
  2236         }        
       
  2237     
       
  2238     // Update network mode indicator
       
  2239     SetSignalIndicatorL();
       
  2240     
       
  2241     // Update HAC indicator
       
  2242     SetHacIndicatorL();
       
  2243     }
       
  2244 
       
  2245 // ----------------------------------------------------------------------------
       
  2246 // CSysApAppUi::OfflineModeActive()
       
  2247 // ----------------------------------------------------------------------------
       
  2248 TBool CSysApAppUi::OfflineModeActive()
       
  2249     {
       
  2250     return iSysApOfflineModeController->OfflineModeActive();
       
  2251     }
       
  2252 
       
  2253 // ----------------------------------------------------------------------------
       
  2254 // CSysApAppUi::DoNotActivateBt()
       
  2255 // ----------------------------------------------------------------------------
       
  2256 void CSysApAppUi::DoNotActivateBt()
       
  2257     {
       
  2258     iSysApOfflineModeController->DoNotActivateBt();
       
  2259     }
       
  2260 
       
  2261 // ----------------------------------------------------------------------------
       
  2262 // CSysApAppUi::SetBtPowerState()
       
  2263 // ----------------------------------------------------------------------------
       
  2264 TInt CSysApAppUi::SetBtPowerState( TBool aBtState )
       
  2265     {
       
  2266     if ( iSysApBtController )
       
  2267         {
       
  2268         return iSysApBtController->SetPowerState( aBtState );
       
  2269         }
       
  2270     else
       
  2271         {
       
  2272         return KErrNotReady;
       
  2273         }
       
  2274     }
       
  2275 
       
  2276 // ----------------------------------------------------------------------------
       
  2277 // CSysApAppUi::KeyLockState() const
       
  2278 // ----------------------------------------------------------------------------
       
  2279 
       
  2280 TBool CSysApAppUi::KeyLockState() const
       
  2281     {
       
  2282     return iKeyLockEnabled;
       
  2283     }
       
  2284 
       
  2285 // ----------------------------------------------------------------------------
       
  2286 // CSysApAppUi::DeviceLockState() const
       
  2287 // ----------------------------------------------------------------------------
       
  2288 
       
  2289 TBool CSysApAppUi::DeviceLockState() const
       
  2290     {
       
  2291     return iDeviceLockEnabled;
       
  2292     }
       
  2293 /*
       
  2294 // ----------------------------------------------------------------------------
       
  2295 // CSysApAppUi::ChangeFmTxStateL()
       
  2296 // ----------------------------------------------------------------------------     
       
  2297 void CSysApAppUi::ChangeFmTxStateL( TBool aEnable )
       
  2298     {
       
  2299     // disable fm transmission
       
  2300     CHWRMFmTx* fmtx = CHWRMFmTx::NewLC();
       
  2301     if ( aEnable )
       
  2302        {
       
  2303        fmtx->EnableL();
       
  2304        }
       
  2305     else 
       
  2306        {
       
  2307        fmtx->DisableL();
       
  2308        }
       
  2309     CleanupStack::PopAndDestroy( fmtx );
       
  2310     } 
       
  2311 */
       
  2312 
       
  2313 // ----------------------------------------------------------------------------
       
  2314 // CSysApAppUi::SetIhfIndicatorL()
       
  2315 // ----------------------------------------------------------------------------
       
  2316 void CSysApAppUi::SetIhfIndicatorL()
       
  2317     {
       
  2318     TBool accessoryConnected ( EFalse );
       
  2319 
       
  2320     TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  2321 
       
  2322     TAccMode accMode(EAccModeHandPortable);
       
  2323 
       
  2324     if ( iSysApAccessoryObserver )
       
  2325         {
       
  2326         accMode = iSysApAccessoryObserver->GetAccessoryMode();
       
  2327 
       
  2328         if ( accMode != EAccModeHandPortable )
       
  2329             {
       
  2330             accessoryConnected = ETrue;
       
  2331             }
       
  2332         }
       
  2333 
       
  2334     if( (callState != EPSCTsyCallStateNone && IhfEnabledL() && !accessoryConnected)
       
  2335         || accMode == EAccModeMusicStand )  // Music stand always shows IHF indicator
       
  2336         {
       
  2337         SetIndicatorStateL( EAknIndicatorIHFActive, EAknIndicatorStateOn );
       
  2338 
       
  2339         if ( accMode == EAccModeMusicStand )
       
  2340             {
       
  2341             // hide other accessory indicators to prevent displaying of duplicate icons in some cases
       
  2342             // e.g. when wireless hf is connected
       
  2343             SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2344             SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2345             SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2346             SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2347             SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2348             SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
  2349             SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2350             }
       
  2351         }
       
  2352     else
       
  2353         {
       
  2354         SetIndicatorStateL( EAknIndicatorIHFActive, EAknIndicatorStateOff );
       
  2355         }
       
  2356     }
       
  2357 
       
  2358 // ----------------------------------------------------------------------------
       
  2359 // CSysApAppUi::HandleSmsStorageNotificationL( TBool aSimStoreFull )
       
  2360 // ----------------------------------------------------------------------------
       
  2361 
       
  2362 void CSysApAppUi::HandleSmsStorageNotificationL( TBool aSimStoreFull )
       
  2363     {
       
  2364     TRACES( RDebug::Print( _L("CSysApAppUi::HandleSmsStorageNotificationL: aSimStoreFull: %d "), aSimStoreFull ) );
       
  2365 
       
  2366     if ( aSimStoreFull )
       
  2367         {
       
  2368         HBufC* noteStringBuf;
       
  2369         noteStringBuf = StringLoader::LoadLC( R_QTN_MEMLO_MEMORY_LOW_SIM_MES, iEikonEnv );
       
  2370         TPtr textBuffer = noteStringBuf->Des();
       
  2371         iSysApMsgSimMemLowQuery->StartL( textBuffer );
       
  2372         CleanupStack::PopAndDestroy();
       
  2373         }
       
  2374 
       
  2375     SetEnvelopeIndicatorL();
       
  2376     }
       
  2377 
       
  2378 // ----------------------------------------------------------------------------
       
  2379 // CSysApAppUi::HandleNspsRawKeyEventL()
       
  2380 // ----------------------------------------------------------------------------
       
  2381 
       
  2382 void CSysApAppUi::HandleNspsRawKeyEventL()
       
  2383     {
       
  2384 #ifdef __SYSAP_MODULE_TEST
       
  2385     ModuleTestShowUiNoteL( _L("Network wakeup from NSPS") );
       
  2386 #endif
       
  2387 
       
  2388     if ( iSysApEtelConnector )
       
  2389         {
       
  2390         iSysApEtelConnector->CommandNetCsWakeupOnNsps();
       
  2391         }
       
  2392     }
       
  2393 
       
  2394 // ----------------------------------------------------------------------------
       
  2395 // CSysApAppUi::HandleNetworkNspsNotification( RMmCustomAPI::TNspsStatus aNspsStatus )
       
  2396 // ----------------------------------------------------------------------------
       
  2397 
       
  2398 void CSysApAppUi::HandleNetworkNspsNotification( RMmCustomAPI::TNspsStatus aNspsStatus )
       
  2399     {
       
  2400     TRACES( RDebug::Print( _L("CSysApAppUi::HandleNetworkNspsNotification aNspsStatus:%d, iNsps:%d )" ), aNspsStatus, iNsps ) );
       
  2401     if( iSysApNspsHandler )
       
  2402         {
       
  2403         if( aNspsStatus == RMmCustomAPI::ENspsOn )
       
  2404             {
       
  2405             if( !iNsps )
       
  2406                 {
       
  2407 #ifdef __SYSAP_MODULE_TEST
       
  2408                 TRAPD( err, ModuleTestShowUiNoteL( _L("Setting NSPS on") ) );
       
  2409 #endif
       
  2410                 iSysApNspsHandler->SetNspsOn();
       
  2411                 iNsps = ETrue;
       
  2412                 }
       
  2413             }
       
  2414         else if( aNspsStatus == RMmCustomAPI::ENspsOff )
       
  2415             {
       
  2416             if( iNsps )
       
  2417                 {
       
  2418 #ifdef __SYSAP_MODULE_TEST
       
  2419                 TRAPD( err, ModuleTestShowUiNoteL( _L("Setting NSPS off") ) );
       
  2420 #endif
       
  2421                 iSysApNspsHandler->SetNspsOff();
       
  2422                 iNsps = EFalse;
       
  2423                 }
       
  2424             }
       
  2425         }
       
  2426     }
       
  2427 
       
  2428 // ----------------------------------------------------------------------------
       
  2429 // CSysApAppUi::HandleMessageTonePlayingQuitability( TInt aTonePlayingStatus )
       
  2430 // ----------------------------------------------------------------------------
       
  2431 
       
  2432 void CSysApAppUi::HandleMessageTonePlayingQuitability( TInt aTonePlayingStatus )
       
  2433     {
       
  2434     if( iSysApNspsHandler )
       
  2435         {
       
  2436         if( aTonePlayingStatus == ECoreAppUIsStopTonePlaying )
       
  2437             {
       
  2438             iSysApNspsHandler->SetMessageToneNotPlaying();
       
  2439             }
       
  2440         else if( aTonePlayingStatus == ECoreAppUIsTonePlaying )
       
  2441             {
       
  2442             iSysApNspsHandler->SetMessageTonePlaying();
       
  2443             }
       
  2444         }
       
  2445     }
       
  2446 
       
  2447 // ----------------------------------------------------------------------------
       
  2448 // CSysApAppUi::ActivateKeyeventForwardingForLights()
       
  2449 // ----------------------------------------------------------------------------
       
  2450 
       
  2451 void CSysApAppUi::ActivateKeyeventForwardingForLights(TBool aActivate)
       
  2452     {
       
  2453     if( iSysApNspsHandler )
       
  2454         {
       
  2455         if ( aActivate )
       
  2456             {
       
  2457             iSysApNspsHandler->ActivateKeyeventForwardingForLights();
       
  2458             }
       
  2459         else
       
  2460             {
       
  2461             iSysApNspsHandler->DeActivateKeyeventForwardingForLights();
       
  2462             }
       
  2463         }
       
  2464     }
       
  2465 
       
  2466 // ----------------------------------------------------------------------------
       
  2467 // CSysApAppUi::StartShutDownTimerOnAlarmAndChargingStates()
       
  2468 // ----------------------------------------------------------------------------
       
  2469 
       
  2470 void CSysApAppUi::StartShutDownTimerOnAlarmAndChargingStates()
       
  2471     {
       
  2472     if( !iAlarmOrChargingStateShutdownStarted )
       
  2473         {
       
  2474         if ( !iTimer )
       
  2475             {
       
  2476             TRAPD( err, iTimer = CPeriodic::NewL( EPriorityNormal ) );
       
  2477 
       
  2478             if ( err != KErrNone )
       
  2479                 {
       
  2480                 TRACES( RDebug::Print( _L("CSysApAppUi::StartShutDownTimerOnAlarmAndChargingStates: CPeriodic::NewL failed: %d"), err ) );
       
  2481                 return;
       
  2482                 }
       
  2483             }
       
  2484         iTimer->Cancel();
       
  2485         iTimer->Start( KDelayBeforeShuttingDownInAlarmAndChargingStates,
       
  2486                        KDelayBeforeShuttingDownInAlarmAndChargingStates,
       
  2487                        TCallBack( DoShutdownOnAlarmStateAfterCallBack, this ) );
       
  2488         iAlarmOrChargingStateShutdownStarted = ETrue;
       
  2489         }
       
  2490     }
       
  2491 
       
  2492 // ----------------------------------------------------------------------------
       
  2493 // CSysApAppUi::DoShutdownOnAlarmStateAfterCallBack( TAny* aObject )
       
  2494 // ----------------------------------------------------------------------------
       
  2495 
       
  2496 TInt CSysApAppUi::DoShutdownOnAlarmStateAfterCallBack( TAny* aObject )
       
  2497     {
       
  2498     CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
       
  2499 
       
  2500     if ( appUi->iTimer )
       
  2501         {
       
  2502         appUi->iTimer->Cancel();
       
  2503         }
       
  2504 
       
  2505     TRAP_IGNORE( appUi->DoShutdownL( EFalse, KDummyReason ) );
       
  2506 
       
  2507     return KErrNone;
       
  2508     }
       
  2509 
       
  2510 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  2511 // ----------------------------------------------------------------------------
       
  2512 // CSysApAppUi::StartAnimTiming()
       
  2513 // ----------------------------------------------------------------------------
       
  2514 void CSysApAppUi::StartAnimTiming()
       
  2515     {
       
  2516     TRACES( RDebug::Print( _L("CSysApAppUi::StartAnimTiming() Start animation timer, time %d ms" ), iAnimationShowingTime  ) );
       
  2517 
       
  2518     if ( !iAnimTimer )
       
  2519         {
       
  2520         TRAPD( err, iAnimTimer = CPeriodic::NewL( EPriorityNormal ) );
       
  2521 
       
  2522         if ( err != KErrNone )
       
  2523             {
       
  2524             TRACES( RDebug::Print( _L("CSysApAppUi::StartAnimTiming() CPeriodic::NewL failed %d " ), err ) );
       
  2525             return;
       
  2526             }
       
  2527         }
       
  2528 
       
  2529     iAnimTimer->Start(
       
  2530         iAnimationShowingTime*KCoefficientToMakeMicroToMilliSeconds,
       
  2531         iAnimationShowingTime*KCoefficientToMakeMicroToMilliSeconds,
       
  2532         TCallBack( DoStopAnimTiming, this ) );
       
  2533     }
       
  2534 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  2535 
       
  2536 // ----------------------------------------------------------------------------
       
  2537 // CSysApAppUi::DoStopAnimTiming( TAny* aObject )
       
  2538 // ----------------------------------------------------------------------------
       
  2539 
       
  2540 TInt CSysApAppUi::DoStopAnimTiming( TAny* aObject )
       
  2541     {
       
  2542     TInt err(KErrNone);
       
  2543     CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
       
  2544 
       
  2545     // This method could theoretically be called by two timers (iAnimTimer and one in CSysApShutdownAnimation),
       
  2546     // so a check is needed to prevent multiple executions.
       
  2547     if ( !(appUi->iShutdownContinued) )
       
  2548         {
       
  2549         appUi->iShutdownContinued = ETrue;
       
  2550 
       
  2551         TRACES( RDebug::Print( _L("CSysApAppUi::DoStopAnimTiming() Animation timer completed or animation skipped" ) ) );
       
  2552 
       
  2553 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  2554         if ( appUi->iAnimTimer )
       
  2555             {
       
  2556             appUi->iAnimTimer->Cancel();
       
  2557             }
       
  2558 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  2559 
       
  2560         if ( appUi->iTimer )
       
  2561             {
       
  2562             appUi->iTimer->Cancel();
       
  2563             }
       
  2564 
       
  2565         TRACES( RDebug::Print( _L("CSysApAppUi::DoStopAnimTiming() Call ContinueShutdown(...)" ) ) );
       
  2566         appUi->ContinueShutdown();
       
  2567         TRACES( RDebug::Print( _L("CSysApAppUi::DoStopAnimTiming() end") ) );
       
  2568         }
  1004         }
  2569 
  1005 
  2570     return err;
  1006     return err;
  2571     }
  1007     }
  2572 
  1008 
  2573 
  1009 
  2574 // ----------------------------------------------------------------------------
  1010 // ----------------------------------------------------------------------------
  2575 // CSysApAppUi::StartGprsSuspendedTimer()
  1011 // CSysApAppUi::ShowShutdownImageL
  2576 // ----------------------------------------------------------------------------
  1012 // ----------------------------------------------------------------------------
  2577 
  1013 //
  2578 void CSysApAppUi::StartGprsSuspendedTimer()
  1014 void CSysApAppUi::ShowShutdownImageL( TInt aBitmapId )
  2579     {
  1015     {
  2580     TRACES( RDebug::Print( _L("CSysApAppUi::StartGprsSuspendedTimer()") ) );
  1016     TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL") ) );
  2581     if( !iAlarmOrChargingStateShutdownStarted ) // not relevant if shutting down
  1017     // do nothing
  2582         {
  1018     if ( !iSysApShutdownImage ) // Shutdown image may be shown without entering normal state (e.g. charging), so construct here
  2583         if ( !iTimer )
  1019         {
  2584             {
  1020         TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::NewL()") ) );
  2585             TRAPD( err, iTimer = CPeriodic::NewL( EPriorityNormal ) );
  1021         iSysApShutdownImage = CSysApShutdownImage::NewL();
  2586 
  1022         }
  2587             if ( err != KErrNone )
  1023     TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::ShowShutdownImageL()") ) );
  2588                 {
  1024     iSysApShutdownImage->ShowShutdownImageL( aBitmapId );
  2589                 TRACES( RDebug::Print( _L("CSysApAppUi::StartGprsSuspendedTimer: CPeriodic::NewL failed: %d"), err ) );
  1025    }
  2590                 return;
  1026    
  2591                 }
       
  2592             }
       
  2593 
       
  2594         iTimer->Cancel();
       
  2595         iTimer->Start( KDelayBeforeShowingGprsSuspendedNote,
       
  2596                        KDelayBeforeShowingGprsSuspendedNote,
       
  2597                        TCallBack( ShowGprsSuspendedNoteAfterCallBack, this ) );
       
  2598         }
       
  2599     }
       
  2600 
       
  2601 // ----------------------------------------------------------------------------
       
  2602 // CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack( TAny* aObject )
       
  2603 // ----------------------------------------------------------------------------
       
  2604 
       
  2605 TInt CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack( TAny* aObject )
       
  2606     {
       
  2607     TRACES( RDebug::Print( _L("CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack") ) );
       
  2608 
       
  2609     CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
       
  2610 
       
  2611     if ( appUi->iTimer )
       
  2612         {
       
  2613         appUi->iTimer->Cancel();
       
  2614         }
       
  2615 
       
  2616     // Note is needed if call is still active and used network is not WCDMA
       
  2617     TInt callType = appUi->StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallType );
       
  2618     TInt networkMode = appUi->StateOfProperty( KPSUidNetworkInfo, KNWTelephonyNetworkMode );
       
  2619     TRACES( RDebug::Print(
       
  2620         _L("CSysApAppUi::ShowGprsSuspendedNoteAfterCallBack: callType %d networkMode %d"),
       
  2621         callType, networkMode ) );
       
  2622     if ( EPSCTsyCallTypeCSVoice == callType && ENWNetworkModeWcdma != networkMode )
       
  2623         {
       
  2624         appUi->iGprsSuspendedNoteShown = ETrue;
       
  2625         TRAP_IGNORE( appUi->ShowUiNoteL( EGprsSuspendedNote ) );
       
  2626         }
       
  2627     return KErrNone;
       
  2628     }
       
  2629 
       
  2630 // ----------------------------------------------------------------------------
       
  2631 // CSysApAppUi::HandleAccessoryConnectedL()
       
  2632 // ----------------------------------------------------------------------------
       
  2633 
       
  2634 void CSysApAppUi::HandleAccessoryConnectedL( TAccMode aAccessoryState )
       
  2635     {
       
  2636     TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL( aAccessoryState: %d ) "), aAccessoryState ) );
       
  2637 
       
  2638     if ( aAccessoryState == EAccModeWirelessHeadset ||
       
  2639          aAccessoryState == EAccModeWiredHeadset ||
       
  2640          aAccessoryState == EAccModeHeadphones )
       
  2641         {
       
  2642         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2643         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2644         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOn );
       
  2645         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2646         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2647         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
  2648         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2649         }
       
  2650     else if ( aAccessoryState == EAccModeLoopset )
       
  2651         {
       
  2652         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2653         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2654         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOn );
       
  2655         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2656         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2657         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
  2658         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2659         }
       
  2660     else if ( aAccessoryState == EAccModeTextDevice )
       
  2661         {
       
  2662         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2663         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2664         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOn );
       
  2665         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2666         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2667         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
  2668         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2669         }
       
  2670     else if ( aAccessoryState == EAccModeWirelessCarKit || aAccessoryState == EAccModeWiredCarKit )
       
  2671         {
       
  2672         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2673         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2674         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2675         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2676         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOn );
       
  2677         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
  2678         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2679         }
       
  2680     else if ( aAccessoryState == EAccModeTVOut )
       
  2681         {
       
  2682         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2683         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2684         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2685         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2686         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2687         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOn );
       
  2688         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2689         }
       
  2690     else if (aAccessoryState == EAccModeHDMI )
       
  2691             {
       
  2692             SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2693                     SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2694                     SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2695                     SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2696                     SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2697                     SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff);
       
  2698                     SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOn );
       
  2699             }
       
  2700 
       
  2701     TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
       
  2702     TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL: swState: %d"), swState ) );
       
  2703 
       
  2704     if( UiReady() || swState == ESwStateSecurityCheck )
       
  2705         {
       
  2706         iSysApLightsController->AccessoryConnectedL( ETrue );
       
  2707         }
       
  2708 
       
  2709     if ( ( ! iIgnoreAccessorySpecificProfileChanges ) && ( ! iSysApOfflineModeController->OfflineModeActive() ) )
       
  2710         {
       
  2711         TInt profileId( 0 );
       
  2712         TInt currentProfile( 0 );
       
  2713         currentProfile = ActiveProfileId();
       
  2714 
       
  2715         if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) < 1 )
       
  2716             // accessory not connected already
       
  2717              {
       
  2718             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 1 );
       
  2719             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected, currentProfile );
       
  2720             }
       
  2721 
       
  2722         if ( aAccessoryState == EAccModeWirelessCarKit )
       
  2723             {
       
  2724             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApWirelessCarkit );
       
  2725             }
       
  2726         else if( aAccessoryState == EAccModeWiredHeadset ||
       
  2727                  aAccessoryState == EAccModeWirelessHeadset )
       
  2728             {
       
  2729             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApHeadset );
       
  2730             }
       
  2731         else if( aAccessoryState == EAccModeLoopset  )
       
  2732             {
       
  2733             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApLoopset );
       
  2734             }
       
  2735         else if( aAccessoryState == EAccModeTextDevice )
       
  2736             {
       
  2737             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApTty );
       
  2738             }
       
  2739         else if( aAccessoryState == EAccModeTVOut || aAccessoryState == EAccModeHDMI )
       
  2740             {
       
  2741             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApTvOut );
       
  2742             }
       
  2743         else if( aAccessoryState == EAccModeHeadphones )
       
  2744             {
       
  2745             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApHeadphones );
       
  2746             }
       
  2747         else if ( aAccessoryState == EAccModeWiredCarKit )
       
  2748             {
       
  2749             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApCarkit );
       
  2750             }
       
  2751         else if ( aAccessoryState == EAccModeMusicStand )
       
  2752             {
       
  2753             profileId = iSysApCenRepController->ProfileIdForSelectedAccessory( ESysApMusicStand );
       
  2754             }
       
  2755 
       
  2756         // Carkit and music stand have also light on permanently option that needs to be checked
       
  2757         if( aAccessoryState == EAccModeWiredCarKit || aAccessoryState == EAccModeMusicStand )
       
  2758             {
       
  2759             // When device is placed on a handsfree cradle, keyguard must be disabled (unless device is locked)
       
  2760             // Note: It is assumed that if carkit/music stand is connected, the phone is in the cradle.
       
  2761             if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCall || iKeyLockOnBeforeAlarm )
       
  2762                 {
       
  2763                 iKeyLockOnBeforeCradle = ETrue;
       
  2764 
       
  2765                 if ( iKeyLockEnabled && !iDeviceLockEnabled )
       
  2766                     {
       
  2767                     KeyLock().DisableWithoutNote();
       
  2768                     }
       
  2769                 }
       
  2770             }
       
  2771 
       
  2772         if( profileId != KActiveProfile )
       
  2773             {
       
  2774             /*-1 because the first item in Accessory default profiles shared data values
       
  2775             is KActiveProfile and that must be subtracted from the index of profile to be activated*/
       
  2776 
       
  2777             profileId -= 1;
       
  2778 
       
  2779             TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL: current profile: %d, accessory profile: %d" ),
       
  2780                                currentProfile, profileId ) );
       
  2781 
       
  2782             if ( profileId != currentProfile )
       
  2783                 {
       
  2784                 iAccessoryJustConnected = ETrue;
       
  2785                 iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired, 1 );
       
  2786                 ActivateProfileL( profileId );
       
  2787                 }
       
  2788             }
       
  2789         }
       
  2790     SetIhfIndicatorL();
       
  2791     SetHacIndicatorL();
       
  2792     }
       
  2793 
       
  2794 // ----------------------------------------------------------------------------
       
  2795 // CSysApAppUi::HandleAccessoryDisconnectedL()
       
  2796 // ----------------------------------------------------------------------------
       
  2797 
       
  2798 void CSysApAppUi::HandleAccessoryDisconnectedL()
       
  2799     {
       
  2800     TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryDisconnectedL()" ) ) );
       
  2801 
       
  2802 
       
  2803     TAccMode accessoryState(EAccModeHandPortable);
       
  2804     if ( iSysApAccessoryObserver )
       
  2805         {
       
  2806         accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
       
  2807         }
       
  2808 
       
  2809     if ( accessoryState == EAccModeHandPortable )
       
  2810         {
       
  2811         SetIndicatorStateL( EAknIndicatorTvOut, EAknIndicatorStateOff );
       
  2812         SetIndicatorStateL( EAknIndicatorLoopset, EAknIndicatorStateOff );
       
  2813         SetIndicatorStateL( EAknIndicatorHeadset, EAknIndicatorStateOff );
       
  2814         SetIndicatorStateL( EAknIndicatorTTY,     EAknIndicatorStateOff );
       
  2815         SetIndicatorStateL( EAknIndicatorHeadsetUnavailable, EAknIndicatorStateOff );
       
  2816         SetIndicatorStateL( EAknIndicatorCarkit, EAknIndicatorStateOff );
       
  2817         SetIndicatorStateL(  EAknIndicatorHDMI, EAknIndicatorStateOff );
       
  2818 
       
  2819         iSysApLightsController->AccessoryConnectedL( EFalse );
       
  2820 
       
  2821         if ( ! iIgnoreAccessorySpecificProfileChanges )
       
  2822             {
       
  2823             TInt activeProfile ( ActiveProfileId() );
       
  2824 
       
  2825             TInt activeProfileBeforeConnectingAccessory(
       
  2826                  iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected )
       
  2827                                                         );
       
  2828             if ( activeProfileBeforeConnectingAccessory < 0 ) // error
       
  2829                 {
       
  2830                 activeProfileBeforeConnectingAccessory = 0; // General Profile
       
  2831                 }
       
  2832             TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryDisconnectedL: active profile now: %d, active profile before: %d," ),
       
  2833                                    activeProfile, activeProfileBeforeConnectingAccessory ) );
       
  2834 
       
  2835             if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired ) == 1 )
       
  2836                 {
       
  2837                 iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired, 0 );
       
  2838                 if ( activeProfile != activeProfileBeforeConnectingAccessory && ! iSysApOfflineModeController->OfflineModeActive() )
       
  2839                     {
       
  2840                     ActivateProfileL( activeProfileBeforeConnectingAccessory );
       
  2841                     }
       
  2842                 }
       
  2843             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 0 );
       
  2844             }
       
  2845         }
       
  2846 
       
  2847     SetIhfIndicatorL();
       
  2848     SetHacIndicatorL();
       
  2849 
       
  2850     // If lock disabled because of accessory, reactivate it, unless phone call or alarm is ongoing
       
  2851     if ( iKeyLockOnBeforeCradle )
       
  2852         {
       
  2853         iKeyLockOnBeforeCradle = EFalse;
       
  2854         if ( !iKeyLockOnBeforeCall && !iKeyLockOnBeforeAlarm )
       
  2855             {
       
  2856             if ( !iDeviceLockEnabled )
       
  2857                 {
       
  2858                 KeyLock().EnableKeyLock();
       
  2859                 }
       
  2860             else
       
  2861                 {
       
  2862                 KeyLock().EnableAutoLockEmulation();
       
  2863                 }
       
  2864             }
       
  2865         }
       
  2866     }
       
  2867 
       
  2868 // ----------------------------------------------------------------------------
       
  2869 // CSysApAppUi::HandleAccessoryProfileInStartupL()
       
  2870 // ----------------------------------------------------------------------------
       
  2871 
       
  2872 void CSysApAppUi::HandleAccessoryProfileInStartupL()
       
  2873     {
       
  2874     TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL" ) ) );
       
  2875 
       
  2876     if ( !iSysApOfflineModeController->OfflineModeActive() )
       
  2877         {
       
  2878         iIgnoreAccessorySpecificProfileChanges = EFalse;
       
  2879         TBool accessoryConnectedInShutdown( EFalse );
       
  2880         TInt accessoryTemp( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) );
       
  2881         if ( accessoryTemp == 1 )
       
  2882             {
       
  2883             accessoryConnectedInShutdown = ETrue;
       
  2884             }
       
  2885 
       
  2886         TBool accessoryConnectedNow ( EFalse );
       
  2887 
       
  2888         TAccMode accessoryState(EAccModeHandPortable);
       
  2889         if ( iSysApAccessoryObserver )
       
  2890             {
       
  2891             accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
       
  2892             }
       
  2893 
       
  2894         if ( accessoryState != EAccModeHandPortable )
       
  2895             {
       
  2896             accessoryConnectedNow = ETrue;
       
  2897             }
       
  2898         TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL: accessoryConnectedInShutdown: %d, accessoryConnectedNow: %d" ),
       
  2899                               accessoryConnectedInShutdown, accessoryConnectedNow ) );
       
  2900 
       
  2901         if ( accessoryConnectedInShutdown && !accessoryConnectedNow )
       
  2902             {
       
  2903             HandleAccessoryDisconnectedL();
       
  2904             }
       
  2905         else if ( !accessoryConnectedInShutdown && accessoryConnectedNow )
       
  2906             {
       
  2907             HandleAccessoryConnectedL( accessoryState );
       
  2908             }
       
  2909         else if ( !accessoryConnectedNow )
       
  2910             {
       
  2911             TInt activeProfile ( ActiveProfileId() );
       
  2912             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected, activeProfile );
       
  2913             }
       
  2914         }
       
  2915     }
       
  2916 
       
  2917 #ifndef RD_MULTIPLE_DRIVE
       
  2918 
       
  2919 // ----------------------------------------------------------------------------
       
  2920 // CSysApAppUi::ResolveUidFromThread()
       
  2921 // ----------------------------------------------------------------------------
       
  2922 TInt32 CSysApAppUi::ResolveUidFromThread( TUint aThreadId ) const
       
  2923     {
       
  2924     TInt resolvedUid = 0;
       
  2925 
       
  2926     RThread appThread;
       
  2927     TInt err = appThread.Open( aThreadId );
       
  2928 
       
  2929     if ( err == KErrNone )
       
  2930         {
       
  2931         resolvedUid = appThread.SecureId().iId;
       
  2932         }
       
  2933 
       
  2934     appThread.Close();
       
  2935 
       
  2936     TRACES( RDebug::Print( _L("CSysApAppUi::ResolveUidFromThread: err=%d, aThreadId=%d, resolvedUid=0x%x"),
       
  2937                            err, aThreadId, resolvedUid ) );
       
  2938 
       
  2939     return resolvedUid;
       
  2940     }
       
  2941 
       
  2942 // ----------------------------------------------------------------------------
       
  2943 // CSysApAppUi::CloseUIAppsInHotSwapL()
       
  2944 // ----------------------------------------------------------------------------
       
  2945 void CSysApAppUi::CloseUIAppsInHotSwapL()
       
  2946     {
       
  2947     TRACES( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL") ) );
       
  2948 
       
  2949     CArrayFixFlat<TInt>* wgIds=new(ELeave) CArrayFixFlat<TInt>(4);
       
  2950     CleanupStack::PushL(wgIds);
       
  2951     User::LeaveIfError(iCoeEnv->WsSession().WindowGroupList(0, wgIds));
       
  2952     TInt lastEntry=wgIds->Count()-1;
       
  2953     TRACES( RDebug::Print( _L( "CSysApAppUi::CloseUIAppsInHotSwapL: Found %d UI applications running." ), lastEntry + 1 ) );
       
  2954     TInt numberOfApplicationsToShutDown( 0 );
       
  2955     iApplicationScanningRoundNumber++;
       
  2956 
       
  2957     for ( TInt i=lastEntry; i>=0; i--)
       
  2958         {
       
  2959         CApaWindowGroupName* doomedApp = CApaWindowGroupName::NewLC(iCoeEnv->WsSession(),wgIds->At(i));
       
  2960 
       
  2961         TBool systemApp = doomedApp->IsSystem();
       
  2962         TBool hiddenApp = doomedApp->Hidden();
       
  2963 
       
  2964         if ( systemApp || hiddenApp )
       
  2965             {
       
  2966             TRACES (
       
  2967                     TPtrC caption=doomedApp->Caption();
       
  2968                     RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Privileged app \"%S\" UID 0x%x will not be closed, system: %d, hidden: %d" ),
       
  2969                                    &caption,
       
  2970                                    doomedApp->AppUid().iUid,
       
  2971                                    systemApp,
       
  2972                                    hiddenApp);
       
  2973                     );
       
  2974             }
       
  2975         else if ( ( iFileManagerCloseDisabled && doomedApp->AppUid().iUid == KFileManagerAppUid ) ||
       
  2976                   doomedApp->AppUid().iUid == KAutolockAppUid )
       
  2977             {
       
  2978             // An additional failure protection: Autolock must not be closed in any circumstances
       
  2979             TRACES (
       
  2980                     TPtrC caption=doomedApp->Caption();
       
  2981                     RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Privileged app \"%S\" will not be closed, UID 0x%x"),
       
  2982                                    &caption,
       
  2983                                    doomedApp->AppUid().iUid );
       
  2984                     );
       
  2985             }
       
  2986         else if ( doomedApp->AppUid().iUid == 0 && !iTimeToKill )
       
  2987             {
       
  2988 #ifdef _DEBUG
       
  2989             TApaTask task(iCoeEnv->WsSession());
       
  2990             task.SetWgId(wgIds->At(i));
       
  2991             TUint threadId = (TUint)(task.ThreadId());
       
  2992             TInt32 uid = ResolveUidFromThread( threadId );
       
  2993             // CApaWindowGroupName stores the application UID, and in early application startup state AppUid()-method returns 0
       
  2994             // In order not to accidentally close application that hasn't yet its window group properly set up, decicision whether
       
  2995             // to close the application is postponed, in maximum to the end of the waiting period.
       
  2996             TRACES ( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Unknown app will not be closed yet, threadId=%d, UID 0x%x, size=%d"),
       
  2997                                     threadId, uid, sizeof(TApaTask) ) );
       
  2998 #endif // _DEBUG
       
  2999             numberOfApplicationsToShutDown++; // wait note must be displayed
       
  3000             }
       
  3001         else
       
  3002             {
       
  3003             numberOfApplicationsToShutDown++;
       
  3004             TApaTask* task = new (ELeave) TApaTask(iCoeEnv->WsSession());
       
  3005             CleanupDeletePushL(task);
       
  3006             task->SetWgId(wgIds->At(i));
       
  3007 
       
  3008             TRACES (
       
  3009                     const TDesC& caption = doomedApp->Caption();
       
  3010                     const TDesC& docname = doomedApp->DocName();
       
  3011                     const TDesC& wgname = doomedApp->WindowGroupName();
       
  3012                     TUid uid = doomedApp->AppUid();
       
  3013                     RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Closing app \"%S\" (ThreadId %d, WgId %d, UID 0x%X); Docname: %S, WGName : %S"),
       
  3014                                    &caption,
       
  3015                                    (TUint)(task->ThreadId()),
       
  3016                                    wgIds->At(i),
       
  3017                                    uid.iUid,
       
  3018                                    &docname,
       
  3019                                    &wgname);
       
  3020                     );
       
  3021 
       
  3022             ResolveUidFromThread( (TUint)(task->ThreadId()) );
       
  3023 
       
  3024             if ( iApplicationScanningRoundNumber == 1 )
       
  3025                 {
       
  3026                 task->EndTask(); // applications are kindly requested to close themselves on the first round
       
  3027                 }
       
  3028             else if ( iTimeToKill )
       
  3029                 {
       
  3030                 TBool doKill = ETrue;
       
  3031 
       
  3032                 // final check, window group may still be uninitialized so use thread id for checking UID
       
  3033                 if ( doomedApp->AppUid().iUid == 0 )
       
  3034                     {
       
  3035                     if ( ResolveUidFromThread( (TUint)(task->ThreadId()) ) == KAutolockAppUid )
       
  3036                         {
       
  3037                         doKill = EFalse;
       
  3038                         }
       
  3039                     }
       
  3040 
       
  3041                 if ( doKill )
       
  3042                     {
       
  3043                     TRACES( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Killing app \"%S\""), &caption ) );
       
  3044                     task->KillTask(); // used after timeout on the last round
       
  3045                     }
       
  3046                 }
       
  3047 
       
  3048             CleanupStack::PopAndDestroy(); // task
       
  3049             }
       
  3050         CleanupStack::PopAndDestroy();  // doomedApp
       
  3051         }
       
  3052     CleanupStack::PopAndDestroy(); // wgIds
       
  3053 
       
  3054     if ( numberOfApplicationsToShutDown > 0 && iApplicationScanningRoundNumber <= KMaxExitTimeInHotSwap )
       
  3055         {
       
  3056         TRACES( RDebug::Print( _L("CSysApAppUi::CloseUIAppsInHotSwapL: Show wait note, unless already showing") ) );
       
  3057         if ( !iSysApWaitNote )
       
  3058             {
       
  3059             HBufC* noteStringBuf = StringLoader::LoadLC( R_QTN_MEMC_WAIT_EJECT, iEikonEnv );
       
  3060             iSysApWaitNote = CSysApWaitNote::NewL( iSysApFeatureManager->CoverDisplaySupported() );
       
  3061             iSysApWaitNote->ShowNoteL( EClosingApplicationsNote, noteStringBuf );
       
  3062             CleanupStack::PopAndDestroy();
       
  3063             }
       
  3064 
       
  3065         if ( iApplicationScanningRoundNumber >= KMaxExitTimeInHotSwap )
       
  3066             {
       
  3067             iTimeToKill = ETrue;
       
  3068             }
       
  3069 
       
  3070         if ( !iSysApTimer )
       
  3071             {
       
  3072             iSysApTimer = new ( ELeave ) CSysApTimer( *this );
       
  3073             }
       
  3074 
       
  3075         iSysApTimer->ActivateTimerL( KApplicationScanningInterval );
       
  3076         }
       
  3077     else
       
  3078         {
       
  3079         iFileManagerCloseDisabled = EFalse;
       
  3080         CompleteAppsShuttingInHotSwapL();
       
  3081         }
       
  3082     }
       
  3083 
       
  3084 #endif // RD_MULTIPLE_DRIVE
       
  3085 
       
  3086 // ----------------------------------------------------------------------------
       
  3087 // CSysApAppUi::TimerExpiredL()
       
  3088 // ----------------------------------------------------------------------------
       
  3089 void CSysApAppUi::TimerExpiredL()
       
  3090     {
       
  3091 #ifndef RD_MULTIPLE_DRIVE
       
  3092     CloseUIAppsInHotSwapL();
       
  3093 #endif // RD_MULTIPLE_DRIVE
       
  3094     }
       
  3095 
       
  3096 #ifndef RD_MULTIPLE_DRIVE
       
  3097 // ----------------------------------------------------------------------------
       
  3098 // CSysApAppUi::CompleteAppsShuttingInHotSwapL()
       
  3099 // ----------------------------------------------------------------------------
       
  3100 void CSysApAppUi::CompleteAppsShuttingInHotSwapL()
       
  3101     {
       
  3102     TRACES( RDebug::Print( _L("CSysApAppUi::CompleteAppsShuttingInHotSwapL iMMCEjectUsed=%d, iMMCInserted=%d"), iMMCEjectUsed, iMMCInserted ) );
       
  3103     CancelWaitNote();
       
  3104 
       
  3105     if ( iMMCEjectUsed ) // From Powerkey Menu
       
  3106         {
       
  3107         DismountMMC();
       
  3108         TRACES( RDebug::Print( _L( "CSysApAppUi::CompleteAppsShuttingInHotSwapL: Show note: Remove MMC and press OK...." ) ) );
       
  3109         ShowQueryL( ESysApRemoveMmcNote );
       
  3110         }
       
  3111     else if ( !iMMCInserted ) // The MMC might have been already re-mounted, that's why !iMMCInserted
       
  3112         {
       
  3113         ShowMMCDismountedDialogL();
       
  3114         }
       
  3115     }
       
  3116 #endif // RD_MULTIPLE_DRIVE
       
  3117 
       
  3118 // ----------------------------------------------------------------------------
       
  3119 // CSysApAppUi::InitCloseSimApplicationsL()
       
  3120 // ----------------------------------------------------------------------------
       
  3121 void CSysApAppUi::InitCloseSimApplicationsL()
       
  3122     {
       
  3123     iApplicationScanningRoundNumberInBtSap = 0;
       
  3124     iTimeToKillInBtSap = EFalse;
       
  3125     CloseSimApplicationsL();
       
  3126     }
       
  3127 
       
  3128 // ----------------------------------------------------------------------------
       
  3129 // CSysApAppUi::CloseSimApplicationsL()
       
  3130 // ----------------------------------------------------------------------------
       
  3131 void CSysApAppUi::CloseSimApplicationsL()
       
  3132     {
       
  3133     iApplicationScanningRoundNumberInBtSap++;
       
  3134     TRACES( RDebug::Print( _L("CSysApAppUi::CloseSimApplicationsL: scanning round = %d"),
       
  3135                            iApplicationScanningRoundNumberInBtSap ) );
       
  3136 
       
  3137     if ( iApplicationScanningRoundNumberInBtSap == KMaxExitTimeInBtSap )
       
  3138         {
       
  3139         iTimeToKillInBtSap = ETrue;
       
  3140         }
       
  3141 
       
  3142     const TInt KNumberOfSimDependantApps( 7 );
       
  3143     TUid simDependantAppUid[ KNumberOfSimDependantApps ];
       
  3144     simDependantAppUid[ 0 ] = KSysApGSUid;
       
  3145     simDependantAppUid[ 1 ] = KSysApSATUid;
       
  3146     simDependantAppUid[ 2 ] = KSysApMailboxUid;
       
  3147     simDependantAppUid[ 3 ] = KSysApSpeedDialingUid;
       
  3148     simDependantAppUid[ 4 ] = KSysApSimDirectoryUid;
       
  3149     simDependantAppUid[ 5 ] = KSysApMCEUid;
       
  3150     simDependantAppUid[ 6 ] = KSysApCellBroadcastMessagesUid;
       
  3151 
       
  3152     TBool appsExiting( EFalse );
       
  3153     TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
       
  3154 
       
  3155     for ( TInt i = 0; i < KNumberOfSimDependantApps; i++ )
       
  3156         {
       
  3157         TApaTask apaTask = apaTaskList.FindApp( simDependantAppUid[ i ] );
       
  3158         if ( apaTask.Exists() )
       
  3159             {
       
  3160             appsExiting = ETrue;
       
  3161             if ( iApplicationScanningRoundNumberInBtSap == 1 )
       
  3162                 {
       
  3163                 apaTask.EndTask();  // applications are kindly requested to close themselves on the first round
       
  3164                 }
       
  3165             else if ( iTimeToKillInBtSap )
       
  3166                 {
       
  3167                 apaTask.KillTask(); // used after timeout on the last round
       
  3168                 }
       
  3169             }
       
  3170         }
       
  3171 
       
  3172     if ( !appsExiting || iTimeToKillInBtSap )
       
  3173         {
       
  3174         iSysApBtSapController->SimApplicationsClosed();
       
  3175         }
       
  3176     else
       
  3177         {
       
  3178         if ( !iSapTimer )
       
  3179             {
       
  3180             iSapTimer = CPeriodic::NewL( EPriorityNormal );
       
  3181             }
       
  3182         iSapTimer->Cancel();
       
  3183         iSapTimer->Start( KDelayBeforeNextScanningRound,
       
  3184                           KDelayBeforeNextScanningRound,
       
  3185                           TCallBack( DoCloseSimApplicationsAfterCallBack, this ) );
       
  3186         }
       
  3187     }
       
  3188 
       
  3189 // ----------------------------------------------------------------------------
       
  3190 // CSysApAppUi::DoCloseSimApplicationsAfterCallBack
       
  3191 // ----------------------------------------------------------------------------
       
  3192 TInt CSysApAppUi::DoCloseSimApplicationsAfterCallBack( TAny* aObject )
       
  3193     {
       
  3194     CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
       
  3195 
       
  3196     if ( appUi->iSapTimer )
       
  3197         {
       
  3198         appUi->iSapTimer->Cancel();
       
  3199         }
       
  3200 
       
  3201     TRAP_IGNORE( appUi->CloseSimApplicationsL() );
       
  3202 
       
  3203     return KErrNone;
       
  3204     }
       
  3205 
       
  3206 // ----------------------------------------------------------------------------
       
  3207 // CSysApAppUi::AlertUiAlertingL( const TBool aAlerting )
       
  3208 // ----------------------------------------------------------------------------
       
  3209 void CSysApAppUi::AlertUiAlertingL( const TBool aAlerting )
       
  3210     {
       
  3211     TRACES( RDebug::Print( _L("CSysApAppUi::AlertUiAlerting aAlerting:%d"), aAlerting ) );
       
  3212 
       
  3213     if ( aAlerting )
       
  3214         {
       
  3215         TInt swState;
       
  3216         RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
       
  3217 
       
  3218         if( swState == ESwStateCharging )
       
  3219             {
       
  3220             SetStarterState( RStarterSession::EAlarm );
       
  3221             }
       
  3222         }
       
  3223 
       
  3224     iSysApLightsController->AlarmOccuredL( aAlerting );
       
  3225     }
       
  3226 
       
  3227 // ----------------------------------------------------------------------------
       
  3228 // CSysApAppUi::AlertUiKeyLockOff( const TBool aKeyLockOff )
       
  3229 // ----------------------------------------------------------------------------
       
  3230 
       
  3231 void CSysApAppUi::AlertUiKeyLockOff( const TBool aKeyLockOff )
       
  3232     {
       
  3233     TRACES( RDebug::Print( _L("CSysApAppUi::AlertUiKeyLockOff aKeyLockOff:%d, devicelock:%d"), 
       
  3234         aKeyLockOff, iDeviceLockEnabled ) );
       
  3235     
       
  3236     if( aKeyLockOff )
       
  3237         {
       
  3238         // Notification to release keypad might come several times if e.g. calls are received
       
  3239         if ( !iKeyLockOnBeforeAlarm )
       
  3240             {
       
  3241             if ( iKeyLockEnabled || iKeyLockOnBeforeCradle || iKeyLockOnBeforeCall )
       
  3242                 {
       
  3243                 iKeyLockOnBeforeAlarm = ETrue;
       
  3244                 }
       
  3245             }
       
  3246         KeyLock().DisableWithoutNote();
       
  3247         }
       
  3248     else
       
  3249         {
       
  3250         if (iDeviceLockEnabled)
       
  3251             {
       
  3252             // Re-enable keylock in devicelock case only if phone call is not ongoing or is 
       
  3253             // connected. Otherwise e.g. messages can be read using softkeys during ongoing call.
       
  3254             TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  3255             if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateConnected )
       
  3256                 {
       
  3257                 KeyLock().EnableAutoLockEmulation();
       
  3258                 }
       
  3259             }
       
  3260         else if ( iKeyLockOnBeforeAlarm && !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeCall )
       
  3261             {
       
  3262             KeyLock().EnableKeyLock();
       
  3263             }
       
  3264         iKeyLockOnBeforeAlarm = EFalse;
       
  3265         }
       
  3266     }
       
  3267 
       
  3268 // ----------------------------------------------------------------------------
       
  3269 // CSysApAppUi::HandleLightsRequireL()
       
  3270 // ----------------------------------------------------------------------------
       
  3271 
       
  3272 void CSysApAppUi::HandleLightsRequireL() const
       
  3273     {
       
  3274     iSysApLightsController->HandleLightsRequireL();
       
  3275     }
       
  3276 
       
  3277 // ----------------------------------------------------------------------------
       
  3278 // CSysApAppUi::HandleRawKeyEventLightsRequireL()
       
  3279 // ----------------------------------------------------------------------------
       
  3280 
       
  3281 void CSysApAppUi::HandleRawKeyEventLightsRequireL() const
       
  3282     {
       
  3283     iSysApLightsController->HandleRawKeyEventLightsRequireL();
       
  3284     }
       
  3285 
       
  3286 // ----------------------------------------------------------------------------
       
  3287 // CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightParameter )
       
  3288 // ----------------------------------------------------------------------------
       
  3289 
       
  3290 void CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightsParameter ) const
       
  3291     {
       
  3292     iSysApLightsController->HandleForcedLightsVTRequireL( aLightsParameter );
       
  3293     }
       
  3294 
       
  3295 // ----------------------------------------------------------------------------
       
  3296 // CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightParameter )
       
  3297 // ----------------------------------------------------------------------------
       
  3298 
       
  3299 void CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightsParameter ) const
       
  3300     {
       
  3301     iSysApLightsController->HandleForcedLightsSSRequireL( aLightsParameter );
       
  3302     }
       
  3303 
       
  3304 // ---------------------------------------------------------------------------- 
       
  3305 // CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightParameter ) 
       
  3306 // ---------------------------------------------------------------------------- 
       
  3307 void CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightsParameter ) const 
       
  3308     { 
       
  3309     iSysApLightsController->HandleForcedLightsATCRequireL( aLightsParameter ); 
       
  3310     } 
       
  3311       
       
  3312 // ----------------------------------------------------------------------------
       
  3313 // CSysApAppUi::SwitchLightsOnSoftRejectL()
       
  3314 // ----------------------------------------------------------------------------
       
  3315 void CSysApAppUi::SwitchLightsOnSoftRejectL()
       
  3316     {
       
  3317     iSysApLightsController->SwitchLightsOnSoftRejectL();
       
  3318     }
       
  3319 
       
  3320 // ----------------------------------------------------------------------------
       
  3321 // CSysApAppUi::StateOfProperty()
       
  3322 // ----------------------------------------------------------------------------
       
  3323 TInt CSysApAppUi::StateOfProperty( const TUid& aCategory, const TUint aKey ) const
       
  3324     {
       
  3325     TInt err( KErrNone );
       
  3326     TInt value( 0 );
       
  3327     err = RProperty::Get( aCategory, aKey, value );
       
  3328     if ( err )
       
  3329         {
       
  3330         TRACES( RDebug::Print( _L("CSysApAppUi::StateOfProperty. RProperty::Get: err=%d"), err ) );
       
  3331         return err;
       
  3332         }
       
  3333     return value;
       
  3334     }
       
  3335 
       
  3336 // ----------------------------------------------------------------------------
       
  3337 // CSysApAppUi::BluetoothPowerMode()
       
  3338 // ----------------------------------------------------------------------------
       
  3339 TInt CSysApAppUi::BluetoothPowerMode() const
       
  3340     {
       
  3341     return iSysApCenRepBtObserver->BluetoothPowerMode();
       
  3342     }
       
  3343 
       
  3344 // ----------------------------------------------------------------------------
       
  3345 // CSysApAppUi::ActivateProfileL( const TInt aProfileId ) const
       
  3346 // ----------------------------------------------------------------------------
       
  3347 
       
  3348 void CSysApAppUi::ActivateProfileL( const TInt aProfileId ) const
       
  3349     {
       
  3350     TRACES( RDebug::Print( _L("CSysApAppUi::ActivateProfile aProfileId: %d"), aProfileId ) );
       
  3351     //No use of returning the Profile error code since it only tells if the activation was succesfull or not.
       
  3352     iProfileEngine->SetActiveProfileL( aProfileId );
       
  3353     }
       
  3354 
       
  3355 // ----------------------------------------------------------------------------
       
  3356 // CSysApAppUi::ActivateOnlineProfileL() const
       
  3357 // ----------------------------------------------------------------------------
       
  3358 
       
  3359 void CSysApAppUi::ActivateOnlineProfileL() const
       
  3360     {
       
  3361     ActivateProfileL( iProfileToBeActivated );
       
  3362     }
       
  3363 
       
  3364 // ----------------------------------------------------------------------------
       
  3365 // CSysApAppUi::ActiveProfileNameL( TPtr aProfileName ) const
       
  3366 // ----------------------------------------------------------------------------
       
  3367 
       
  3368 void CSysApAppUi::ActiveProfileNameL( TPtr aProfileName )
       
  3369     {
       
  3370     TRACES( RDebug::Print( _L("CSysApAppUi::ActiveProfileNameL START") ) );
       
  3371     MProfile* profile = iProfileEngine->ActiveProfileL();
       
  3372     const MProfileName& mProfileName = profile->ProfileName();
       
  3373     aProfileName = mProfileName.Name();
       
  3374     profile->Release();
       
  3375     TRACES( RDebug::Print( _L("CSysApAppUi::ActiveProfileNameL END") ) );
       
  3376     }
       
  3377 
       
  3378 // ----------------------------------------------------------------------------
       
  3379 // CSysApAppUi::CheckSilentModeL()
       
  3380 // ----------------------------------------------------------------------------
       
  3381 void CSysApAppUi::CheckSilentModeL()
       
  3382     {
       
  3383     TBool isSilent( EFalse );
       
  3384     MProfile* profile = iProfileEngine->ActiveProfileL();
       
  3385     isSilent = profile->IsSilent();
       
  3386     profile->Release();
       
  3387     if ( isSilent )
       
  3388         {
       
  3389         TRACES( RDebug::Print( _L("CSysApAppUi::CheckSilentModeL: active profile is SILENT") ) );
       
  3390         iSysApLightsController->SetSilentModeOn( ETrue );
       
  3391         }
       
  3392     else
       
  3393         {
       
  3394         TRACES( RDebug::Print( _L("CSysApAppUi::CheckSilentModeL: active profile is NOT SILENT") ) );
       
  3395         iSysApLightsController->SetSilentModeOn( EFalse );
       
  3396         }
       
  3397     }
       
  3398 
       
  3399 // ----------------------------------------------------------------------------
       
  3400 // CSysApAppUi::HandleProfileChangedL( const TInt aValue )
       
  3401 // ----------------------------------------------------------------------------
       
  3402 void CSysApAppUi::HandleProfileChangedL( const TInt aNewProfileId )
       
  3403     {
       
  3404     TRACES( RDebug::Print( _L("CSysApAppUi::HandleProfileChangedL: aNewProfileId=%d"), aNewProfileId ) );
       
  3405     CheckSilentModeL();
       
  3406     if ( iHandleNextProfileEvent )
       
  3407         {
       
  3408         if ( iAccessoryJustConnected )
       
  3409             {
       
  3410             iAccessoryJustConnected = EFalse;
       
  3411             }
       
  3412         else
       
  3413             {
       
  3414             // if the user delibarately changes profiles, the selected profile will
       
  3415             // remain active after disconnecting an accessory.
       
  3416             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileUpdateRequired, 0 );
       
  3417             }
       
  3418 
       
  3419 		// Added as a part of REQ 415-6750 : Conditional UI-note for "Activated profile"
       
  3420         TInt   noNeedToShowTheNote = 0;      // if True, then note should not be shown
       
  3421         TInt    err = KErrNone;                            
       
  3422                                      
       
  3423       	err = RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsProfileActivatedNote, 
       
  3424                               noNeedToShowTheNote );   
       
  3425 		/*
       
  3426   		If there occured an error, it is likely caused by the non-existing property. 
       
  3427   		So trying to set it only if no error occured for maintaining the default behavior. 
       
  3428 		*/       
       
  3429         if( KErrNone == err )
       
  3430             { 
       
  3431             TInt error = RProperty::Set( KPSUidCoreApplicationUIs, KCoreAppUIsProfileActivatedNote, 
       
  3432                                      ECoreAppUIsProfileActivatedNoteNotShown );
       
  3433             }
       
  3434                
       
  3435         if(!noNeedToShowTheNote)  //    The value doesn't deny the showing, then...
       
  3436             {
       
  3437             ShowProfileNoteL();
       
  3438             }    
       
  3439         }
       
  3440 
       
  3441     if ( aNewProfileId != KOfflineModeProfileId )
       
  3442         {
       
  3443         iActiveProfileBeforeOfflineMode = aNewProfileId;
       
  3444         iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApProfileBeforeOfflineMode, aNewProfileId );
       
  3445         }
       
  3446 
       
  3447     if ( aNewProfileId == KOfflineModeProfileId && ! iSysApOfflineModeController->OfflineModeActive() )
       
  3448         {
       
  3449         if ( BtSapEnabled() )
       
  3450             {
       
  3451             // Choosing "Offline Mode" will disconnect BT SAP
       
  3452             // SwitchFromOnlineToOfflineModeL() will be called from CSysApBtSapController
       
  3453             iSysApBtSapController->SwitchingToOffline();
       
  3454             iSysApBtSapController->Disconnect();
       
  3455             }
       
  3456         else
       
  3457             {
       
  3458             SwitchFromOnlineToOfflineModeL();
       
  3459             }
       
  3460         }
       
  3461     else if ( aNewProfileId != KOfflineModeProfileId && iSysApOfflineModeController->OfflineModeActive() )
       
  3462         {
       
  3463         if ( BtSapEnabled() )
       
  3464             {
       
  3465             iSysApOfflineModeController->DoNotActivateRF(); // Will be activated after BT SAP disconnection
       
  3466             }
       
  3467         iSysApOfflineModeController->SwitchFromOfflineToOnlineModeL();
       
  3468         }
       
  3469     iHandleNextProfileEvent = ETrue;
       
  3470     }
       
  3471 
       
  3472 
       
  3473 // ----------------------------------------------------------------------------
       
  3474 // CSysApAppUi::RestoreProfileL()
       
  3475 // ----------------------------------------------------------------------------
       
  3476 
       
  3477 void CSysApAppUi::RestoreProfileL( const TBool aOffline )
       
  3478     {
       
  3479     iHandleNextProfileEvent = EFalse;
       
  3480     if ( aOffline )
       
  3481         {
       
  3482         ActivateProfileL( KOfflineModeProfileId );
       
  3483         }
       
  3484     else
       
  3485         {
       
  3486         ActivateProfileL( iActiveProfileBeforeOfflineMode );
       
  3487         }
       
  3488     }
       
  3489 
       
  3490 // ----------------------------------------------------------------------------
       
  3491 // CSysApAppUi::ActiveProfileId()
       
  3492 // ----------------------------------------------------------------------------
       
  3493 
       
  3494 TInt CSysApAppUi::ActiveProfileId()
       
  3495     {
       
  3496     return iProfileEngine->ActiveProfileId();
       
  3497     }
       
  3498 
       
  3499 // ----------------------------------------------------------------------------
       
  3500 // CSysApAppUi::ShowPowerKeyPopUpMenuL()
       
  3501 // ----------------------------------------------------------------------------
       
  3502 
       
  3503 void CSysApAppUi::ShowPowerKeyPopUpMenuL()
       
  3504     {
       
  3505     TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL iPowerKeyPopupMenuActive: %d" ),
       
  3506                           iPowerKeyPopupMenuActive ) );
       
  3507 
       
  3508     if ( !iPowerKeyPopupMenuActive && !iDisablePowerkeyMenu 
       
  3509          && iSysApPowerKeyMenuObserver ) // normal state construction has been executed
       
  3510         {
       
  3511         iPowerKeyPopupMenuDismissed = EFalse;
       
  3512         iPowerkeyMenuPowerOffShown = EFalse;
       
  3513         CancelGlobalListQuery();
       
  3514 
       
  3515         iGlobalListQuery = CAknGlobalListQuery::NewL();
       
  3516 
       
  3517         iSysApPowerKeyMenuObserver->Cancel();
       
  3518 
       
  3519         CDesCArray* profileNameCDesCArray; // Array for Powerkey Menu items
       
  3520 
       
  3521         RArray<TInt> itemIdArray; // needed for cover UI
       
  3522         CleanupClosePushL(itemIdArray);
       
  3523 
       
  3524         // make sure old profile names array is clean
       
  3525         delete iProfileNamesArray;
       
  3526         iProfileNamesArray = NULL;
       
  3527 
       
  3528         // Must pop iProfileNamesArray here as cannot leave trap harness with uneven push/pop count.
       
  3529         // This is because profileEngine doesn't provide non-LC version of ProfilesNamesArrayLC
       
  3530         TRAPD( err,
       
  3531               iProfileNamesArray = iProfileEngine->ProfilesNamesArrayLC();
       
  3532               CleanupStack::Pop();
       
  3533              );
       
  3534 
       
  3535         if ( err != KErrNone )
       
  3536             {
       
  3537             // creating menu failed, return (i.e. just don't show the menu)
       
  3538             TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL iProfileEngine->ProfilesNamesArrayLC() ERROR: %d" ), err ) );
       
  3539             iNumberOfProfileNamesInPowerKeyMenu = 0;
       
  3540             }
       
  3541         else
       
  3542             {
       
  3543             iNumberOfProfileNamesInPowerKeyMenu = iProfileNamesArray->MdcaCount();
       
  3544             TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL iNumberOfProfileNamesInPowerKeyMenu: %d" ),
       
  3545                                   iNumberOfProfileNamesInPowerKeyMenu ) );
       
  3546             }
       
  3547 
       
  3548         if ( BtSapEnabled() )
       
  3549             {
       
  3550             profileNameCDesCArray = new( ELeave ) CDesCArrayFlat( iNumberOfProfileNamesInPowerKeyMenu + 4 );
       
  3551             }
       
  3552         else
       
  3553             {
       
  3554             profileNameCDesCArray = new( ELeave ) CDesCArrayFlat( iNumberOfProfileNamesInPowerKeyMenu + 3 );
       
  3555             }
       
  3556 
       
  3557         CleanupStack::PushL( profileNameCDesCArray );
       
  3558         profileNameCDesCArray->Reset();
       
  3559         HBufC* itemStringBuf;
       
  3560 
       
  3561         TInt powerMenuItemIndex( 0 );
       
  3562 
       
  3563         // "Switch off" menu item
       
  3564         if ( !IsEncryptionOperationOngoingL() )
       
  3565             {
       
  3566         itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_SWITCH_OFF, iEikonEnv );
       
  3567         profileNameCDesCArray->InsertL( 0, itemStringBuf->Des() );
       
  3568         CleanupStack::PopAndDestroy(); // itemStringBuf
       
  3569         if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3570             {
       
  3571             itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemSwitchOff);
       
  3572             }
       
  3573             iPowerkeyMenuPowerOffShown = ETrue;
       
  3574         powerMenuItemIndex++;
       
  3575             }
       
  3576 
       
  3577         iPowerkeyMenuLockKeypadShown     = EFalse;
       
  3578         iPowerkeyMenuExitSapShown        = EFalse;
       
  3579         iPowerkeyMenuLockSystemShown     = EFalse;
       
  3580         iPowerkeyMenuEjectShown          = EFalse;
       
  3581 
       
  3582         iPowerkeyMenuLockKeypadSelection = KErrAccessDenied;
       
  3583         iPowerkeyMenuExitSapSelection    = KErrAccessDenied;
       
  3584         iPowerkeyMenuLockSystemSelection = KErrAccessDenied;
       
  3585 
       
  3586 #ifndef RD_MULTIPLE_DRIVE
       
  3587         iPowerkeyMenuEjectSelection     = KErrAccessDenied;
       
  3588 #else // RD_MULTIPLE_DRIVE
       
  3589         iPowerkeyMenuEjectSelectionBase = KErrAccessDenied;
       
  3590 #endif // RD_MULTIPLE_DRIVE
       
  3591 
       
  3592         // "Lock keypad" menu item
       
  3593 		
       
  3594 		TInt callState ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  3595 		TInt callType ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallType ) );
       
  3596 		if ( !( callState == EPSCTsyCallStateConnected && callType == EPSCTsyCallTypeH324Multimedia ) )
       
  3597 			{
       
  3598 			if ( iSysApFeatureManager->GripNotSupported() ||
       
  3599 				( (!iSysApFeatureManager->GripNotSupported() ) && ( StateOfProperty( KPSUidHWRM, KHWRMGripStatus ) ==  EPSHWRMGripClosed ) ) )
       
  3600 				// "Lock keypad" command is shown always when there is no grip, and if there
       
  3601 				// there is no grip, only when the grip is closed.
       
  3602 				{
       
  3603 				if ( CKeyLockPolicyApi::KeyguardAllowed() )
       
  3604 					{
       
  3605 					if ( iSysApFeatureManager->PenEnabled() )
       
  3606 						{
       
  3607 						itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_LOCK_DISPLAY, iEikonEnv );
       
  3608 						}
       
  3609 					else
       
  3610 						{
       
  3611 						itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_LOCK_KEYS, iEikonEnv );
       
  3612 						}                
       
  3613 					profileNameCDesCArray->AppendL( itemStringBuf->Des() );
       
  3614 					CleanupStack::PopAndDestroy(); // itemStringBuf
       
  3615 					if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3616 						{
       
  3617 						itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemLockKeypad);
       
  3618 						}
       
  3619 					iPowerkeyMenuLockKeypadShown = ETrue;
       
  3620 					iPowerkeyMenuLockKeypadSelection = powerMenuItemIndex;
       
  3621 					powerMenuItemIndex++;
       
  3622 					}
       
  3623 				}
       
  3624 			}
       
  3625 
       
  3626         // "Exit SIM access profile" menu item
       
  3627 
       
  3628         if ( BtSapEnabled() )
       
  3629             {
       
  3630             TRACES( RDebug::Print(_L( "CSysApAppUi::ShowPowerKeyPopUpMenuL: show \"Exit SIM access profile\" item" ) ) );
       
  3631             itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_EXIT_SIM_ACCESS, iEikonEnv );
       
  3632             profileNameCDesCArray->AppendL( itemStringBuf->Des() );
       
  3633             CleanupStack::PopAndDestroy(); // itemStringBuf
       
  3634             if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3635                 {
       
  3636                 itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemExitBtSap);
       
  3637                 }
       
  3638             iPowerkeyMenuExitSapShown = ETrue;
       
  3639             iPowerkeyMenuExitSapSelection = powerMenuItemIndex;
       
  3640             powerMenuItemIndex++;
       
  3641             }
       
  3642 
       
  3643         // Profile menu items
       
  3644 
       
  3645         TInt arrayIndex ( 0 );
       
  3646         TBufC<KMaxProfileNameLength> profileName;
       
  3647 
       
  3648         for ( arrayIndex = 0; arrayIndex < iNumberOfProfileNamesInPowerKeyMenu; arrayIndex++ )
       
  3649             {
       
  3650             profileName = iProfileNamesArray->MdcaPoint( arrayIndex );
       
  3651             TPtr profileNamePtr = profileName.Des();
       
  3652             AknTextUtils::DisplayTextLanguageSpecificNumberConversion( profileNamePtr );
       
  3653             profileNameCDesCArray->AppendL( profileNamePtr );
       
  3654 
       
  3655             if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3656                 {
       
  3657                 TInt profileId = ( iProfileNamesArray->ProfileName( arrayIndex ) )->Id();
       
  3658                 itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemProfileItemBase+profileId);
       
  3659                 }
       
  3660             powerMenuItemIndex++;
       
  3661             }
       
  3662 
       
  3663         // "Lock device" menu item
       
  3664 
       
  3665         callState = StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState );
       
  3666         
       
  3667         TInt devLockStatus( EAutolockStatusUninitialized );
       
  3668         devLockStatus = StateOfProperty( KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus );  // check whether Autolock has been started
       
  3669         
       
  3670 
       
  3671         if ( callState == EPSCTsyCallStateNone && devLockStatus != EAutolockStatusUninitialized )
       
  3672             {
       
  3673             TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: adding \"Lock device\", devLockStatus=%d" ), devLockStatus ) );
       
  3674 			iPowerkeyMenuLockSystemShown = ETrue;
       
  3675             itemStringBuf = StringLoader::LoadLC( R_QTN_SET_SEC_LOCK_SYSTEM, iEikonEnv );
       
  3676             profileNameCDesCArray->AppendL( itemStringBuf->Des() );
       
  3677             CleanupStack::PopAndDestroy(); // itemStringBuf
       
  3678             if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3679                 {
       
  3680                 itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemLockDevice);
       
  3681                 }
       
  3682             iPowerkeyMenuLockSystemShown = ETrue;
       
  3683             iPowerkeyMenuLockSystemSelection = powerMenuItemIndex;
       
  3684             powerMenuItemIndex++;
       
  3685             }
       
  3686 
       
  3687         // "Eject MMC" menu item
       
  3688 
       
  3689         TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  3690 
       
  3691 #ifndef RD_MULTIPLE_DRIVE
       
  3692 			if ( !IsEncryptionOperationOngoingL() )
       
  3693 			{
       
  3694         if ( iSysApFeatureManager->MmcHotSwapSupported() &&
       
  3695              iMMCInserted &&
       
  3696              iSysApFeatureManager->EjectRequiredInPowerMenu() &&
       
  3697              propertyValue != KUsbPersonalityIdMS )
       
  3698             {
       
  3699             iPowerkeyMenuEjectShown = ETrue;
       
  3700             TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: adding \"Eject\"" ) ) );
       
  3701             itemStringBuf = StringLoader::LoadLC( R_QTN_PWRC_EJECT_MMC, iEikonEnv );
       
  3702             profileNameCDesCArray->AppendL( itemStringBuf->Des() );
       
  3703             CleanupStack::PopAndDestroy(); // itemStringBuf
       
  3704             if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3705                 {
       
  3706                 itemIdArray.AppendL(SecondaryDisplay::EPwrMenuItemEjectMMC);
       
  3707                 }
       
  3708             iPowerkeyMenuEjectShown = ETrue;
       
  3709             iPowerkeyMenuEjectSelection = powerMenuItemIndex;
       
  3710             powerMenuItemIndex++;
       
  3711             }
       
  3712         }
       
  3713 
       
  3714 #else // RD_MULTIPLE_DRIVE
       
  3715 			if ( !IsEncryptionOperationOngoingL() )
       
  3716 			{
       
  3717         if ( iSysApFeatureManager->MmcHotSwapSupported() &&
       
  3718              iSysApFeatureManager->EjectRequiredInPowerMenu() &&
       
  3719              propertyValue != KUsbPersonalityIdMS )
       
  3720             {
       
  3721             // Reset old eject status and dialog
       
  3722             iSysApDriveList->ResetDrivesToEject();
       
  3723             if ( iSysApConfirmationQuery )
       
  3724                 {
       
  3725                 if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
       
  3726                     {
       
  3727                     iSysApConfirmationQuery->Cancel();
       
  3728                     }
       
  3729                 }
       
  3730 
       
  3731             // Append memory cards for eject selection
       
  3732             TInt count( iInsertedMemoryCards.Count() );
       
  3733             for ( TInt i( 0 ); i < count; ++i )
       
  3734                 {
       
  3735                 itemStringBuf = iSysApDriveList->GetFormattedDriveNameLC(
       
  3736                     iInsertedMemoryCards[ i ].iDrive,
       
  3737                     R_QTN_PWRC_EJECT_MEMORY_STORAGE );
       
  3738                 profileNameCDesCArray->AppendL( *itemStringBuf );
       
  3739                 CleanupStack::PopAndDestroy( itemStringBuf );
       
  3740 
       
  3741                 if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3742                     {
       
  3743                     itemIdArray.AppendL( SecondaryDisplay::EPwrMenuItemEjectItemBase + i );
       
  3744                     }
       
  3745                 }
       
  3746             if ( count > 0 )
       
  3747                 {
       
  3748                 TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: added \"Eject\"" ) ) );
       
  3749                 iPowerkeyMenuEjectShown = ETrue;
       
  3750                 iPowerkeyMenuEjectSelectionBase = powerMenuItemIndex;
       
  3751                 powerMenuItemIndex += count;
       
  3752                 }
       
  3753             }
       
  3754 				}
       
  3755 #endif // RD_MULTIPLE_DRIVE
       
  3756         
       
  3757         // Activate/deactive power save mode
       
  3758         if ( iSysApPsmController ) // variable feature, not create if power save is not used
       
  3759             {
       
  3760             TBool showActivate = !(iSysApPsmController->FullPsmEnabled());
       
  3761             
       
  3762             TInt textId = ( showActivate ? R_QTN_PWRC_ACTIVATE_POWER_SAVING : R_QTN_PWRC_DEACTIVATE_POWER_SAVING );
       
  3763             
       
  3764             itemStringBuf = StringLoader::LoadLC( textId, iEikonEnv );
       
  3765             iSysApPsmController->SetNextUiOperation( showActivate );
       
  3766             
       
  3767             if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3768                 {
       
  3769                 itemIdArray.AppendL( showActivate ? 
       
  3770                                      SecondaryDisplay::EPwrMenuItemActivatePowerSaving :
       
  3771                                      SecondaryDisplay::EPwrMenuItemDeactivatePowerSaving );
       
  3772                 }
       
  3773                 
       
  3774             profileNameCDesCArray->AppendL( itemStringBuf->Des() );
       
  3775             CleanupStack::PopAndDestroy( itemStringBuf );
       
  3776                 
       
  3777             iSysApPsmController->SetUiItemId( powerMenuItemIndex );
       
  3778             powerMenuItemIndex++;    
       
  3779             }
       
  3780         
       
  3781         TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL NumberOfAllItemsInPowerKeyMenu: %d" ),
       
  3782                               profileNameCDesCArray->Count() ) );
       
  3783 
       
  3784         iSysApPowerKeyMenuObserver->Start();
       
  3785 
       
  3786         // Set secondary display data if necessary
       
  3787         if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  3788             {
       
  3789             CAknSDData* sd = CAknSDData::NewL(SecondaryDisplay::KCatSysAp, SecondaryDisplay::ECmdShowPowerKeyListQuery, KNullDesC8);
       
  3790             sd->InsertGlobalListQueryItemIdsL(itemIdArray);
       
  3791             iGlobalListQuery->SetSecondaryDisplayData(sd); // ownership to notifier client
       
  3792             }
       
  3793 
       
  3794         iGlobalListQuery->ShowListQueryL( (MDesCArray*) profileNameCDesCArray,
       
  3795                                           iSysApPowerKeyMenuObserver->iStatus,
       
  3796                                           KProfileListInitialIndex );
       
  3797 
       
  3798         TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: list query shown" ) ) );
       
  3799 
       
  3800         CleanupStack::PopAndDestroy( profileNameCDesCArray ); // profileNameCDesCArray
       
  3801         TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL: profileNameCDesCArray popped" ) ) );
       
  3802 
       
  3803         CleanupStack::Pop(&itemIdArray);
       
  3804         itemIdArray.Close();
       
  3805 
       
  3806         // Without following variable set ETrue powerkey up event would change the hightlighted item to be
       
  3807         // the second one instead of the wanted first one.
       
  3808         iIgnoreNextPowerKeyUpEvent = ETrue;
       
  3809 
       
  3810         if ( iSysApBatteryInfoController )        
       
  3811             {
       
  3812             iSysApBatteryInfoController->PowerMenuShownL();
       
  3813             }
       
  3814         
       
  3815         TRACES( RDebug::Print(_L("CSysApAppUi::ShowPowerKeyPopUpMenuL:end" ) ) );
       
  3816     }
       
  3817 }
       
  3818 
       
  3819 // ----------------------------------------------------------------------------
       
  3820 // CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL( TInt aSelection )
       
  3821 // ----------------------------------------------------------------------------
       
  3822 
       
  3823 void CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL( TInt aSelection )
       
  3824     {
       
  3825     iPowerKeyPopupMenuDismissed = ETrue;
       
  3826     iPowerKeyPopupMenuActive = EFalse;
       
  3827     TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: START aSelection:%d" ), aSelection ) );
       
  3828     if ( aSelection == KPowerKeyMenuSelectionCancelled )
       
  3829         {
       
  3830         TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: Powerkey menu cancelled" ) ) );
       
  3831         }
       
  3832     else if( aSelection < KPowerKeyMenuSelectionCancelled )
       
  3833         {
       
  3834         iIgnoreNextPowerKeyUpEvent = EFalse;
       
  3835         }
       
  3836     else
       
  3837         {
       
  3838         TInt firstProfileItemIndex( 1 + Max( 0, iPowerkeyMenuLockKeypadSelection, iPowerkeyMenuExitSapSelection ) ); // index of "General" profile
       
  3839 
       
  3840         if ( aSelection == KPowerKeyMenuSelectionSwitchOff )
       
  3841             {
       
  3842             TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Switch off\" selected" ) ) );
       
  3843             DoShutdownL( EFalse, KDummyReason );
       
  3844             }
       
  3845 
       
  3846         else if ( iPowerkeyMenuLockKeypadShown && aSelection == iPowerkeyMenuLockKeypadSelection )
       
  3847             {
       
  3848             TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Lock keypad\" selected" ) ) );
       
  3849             KeyLock().EnableKeyLock();
       
  3850             }
       
  3851 
       
  3852         else if ( iPowerkeyMenuExitSapShown && aSelection == iPowerkeyMenuExitSapSelection )
       
  3853             {
       
  3854             TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Exit SAP\" selected" ) ) );
       
  3855             ShowQueryL( ESysApBtSapDisconnectQuery );
       
  3856             }
       
  3857 
       
  3858         else if ( aSelection < firstProfileItemIndex + iNumberOfProfileNamesInPowerKeyMenu )
       
  3859             {
       
  3860             __ASSERT_DEBUG( iProfileNamesArray, User::Invariant() );
       
  3861 
       
  3862             if ( iProfileNamesArray )
       
  3863                 {
       
  3864                 iProfileToBeActivated = ( iProfileNamesArray->ProfileName( aSelection - firstProfileItemIndex ) )->Id();
       
  3865 
       
  3866                 TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: profile id: %d selected" ), iProfileToBeActivated ) );
       
  3867                 if ( ! iSysApOfflineModeController->OfflineModeActive() ||
       
  3868                     ( iProfileToBeActivated ) == KOfflineModeProfileId )
       
  3869                     {
       
  3870                     ActivateProfileL( iProfileToBeActivated );
       
  3871                     }
       
  3872                 else
       
  3873                     {
       
  3874                     // iProfileToBeActivated profile will be activated from iSysApOfflineModeController if ok
       
  3875                     iSysApOfflineModeController->GoOnlineIfOkL();
       
  3876                     }
       
  3877                 }
       
  3878             }
       
  3879 
       
  3880         else if ( iPowerkeyMenuLockSystemShown && aSelection == iPowerkeyMenuLockSystemSelection )
       
  3881             {
       
  3882             TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Lock system\" selected" ) ) );
       
  3883             iSysApSystemLock->SetLockedL();
       
  3884             }
       
  3885 #ifndef RD_MULTIPLE_DRIVE
       
  3886         else if ( iPowerkeyMenuEjectShown && aSelection == iPowerkeyMenuEjectSelection )
       
  3887             {
       
  3888             TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Eject\" selected" ) ) );
       
  3889             ShowQueryL( ESysApEjectMmcQuery );
       
  3890             }
       
  3891 #else // RD_MULTIPLE_DRIVE
       
  3892         else if ( iPowerkeyMenuEjectShown &&
       
  3893                 aSelection >= iPowerkeyMenuEjectSelectionBase &&
       
  3894                 aSelection < iPowerkeyMenuEjectSelectionBase + iInsertedMemoryCards.Count() )
       
  3895             {
       
  3896             iDriveToEject =
       
  3897                 iInsertedMemoryCards[ aSelection - iPowerkeyMenuEjectSelectionBase ].iDrive;
       
  3898             TRACES( RDebug::Print(
       
  3899                 _L( "CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Eject\" selected, drive=%d" ),
       
  3900                 iDriveToEject ) );
       
  3901             iSysApDriveList->ResetDrivesToEject();
       
  3902             RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3903             EjectMMCL();
       
  3904             }
       
  3905 #endif // RD_MULTIPLE_DRIVE
       
  3906         else if ( iSysApPsmController && aSelection == iSysApPsmController->UiItemId() )
       
  3907             {
       
  3908             TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: \"Activate|Deactivate power save\" selected" ) ) );
       
  3909             iSysApPsmController->DoEnableFullPsm( iSysApPsmController->NextUiOperation() );
       
  3910             }
       
  3911 
       
  3912         }
       
  3913 
       
  3914     delete iProfileNamesArray;
       
  3915     iProfileNamesArray = NULL;
       
  3916 
       
  3917     TRACES( RDebug::Print(_L("CSysApAppUi::PowerKeyPopUpMenuSelectionDoneL: END" ) ) );
       
  3918     }
       
  3919 
       
  3920 // ----------------------------------------------------------------------------
       
  3921 // CSysApAppUi::SetDeviceLockEnabledL( const TBool aLockEnabled )
       
  3922 // ----------------------------------------------------------------------------
       
  3923 
       
  3924 void CSysApAppUi::SetDeviceLockEnabledL( const TBool aLockEnabled )
       
  3925     {
       
  3926     TRACES( RDebug::Print(_L("CSysApAppUi::SetDeviceLockEnabledL aLockEnabled:%d" ), aLockEnabled ) );
       
  3927     TBool currentState( iDeviceLockEnabled );
       
  3928     
       
  3929     iDeviceLockEnabled = aLockEnabled;
       
  3930     
       
  3931     if ( currentState != iDeviceLockEnabled ) // filter out unnecessary light status modifications
       
  3932         {
       
  3933         iSysApLightsController->DeviceLockStateChangedL( iDeviceLockEnabled );
       
  3934         }
       
  3935     
       
  3936     if( iDeviceLockEnabled )
       
  3937         {
       
  3938         if( iKeyLockEnabled )
       
  3939             {
       
  3940             KeyLock().DisableWithoutNote();
       
  3941             }
       
  3942         }
       
  3943     else
       
  3944         {
       
  3945         // let's not activate keylock in case device lock was disabled during call or in cradle
       
  3946         iKeyLockOnBeforeCall = EFalse;
       
  3947         iKeyLockOnBeforeCradle = EFalse;
       
  3948 
       
  3949         // Memory card needs to be unlocked when device is unlocked
       
  3950         if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
  3951             {
       
  3952             RunUnlockNotifierL();
       
  3953             }
       
  3954         }
       
  3955     }
       
  3956 
       
  3957 // ----------------------------------------------------------------------------
       
  3958 // CSysApAppUi::DoNotEnableKeylock()
       
  3959 // ----------------------------------------------------------------------------
       
  3960 
       
  3961 void CSysApAppUi::DoNotEnableKeylock()
       
  3962     {
       
  3963     if ( !iKeyLockOnBeforeCradle )
       
  3964         {
       
  3965         iShowkeypadActivatedNoteAfterSoftReject = iKeyLockOnBeforeCall;
       
  3966         }
       
  3967 
       
  3968     iKeyLockOnBeforeCall = EFalse;
       
  3969     }
       
  3970 
       
  3971 // ----------------------------------------------------------------------------
       
  3972 // CSysApAppUi::DoShutdownL( const TBool aReset, const TSWStartupReason aSWStartupReason )
       
  3973 // ----------------------------------------------------------------------------
       
  3974 
       
  3975 void CSysApAppUi::DoShutdownL( const TBool aReset, const TInt aResetReason )
       
  3976     {
       
  3977     TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: aResetReason:%d, aReset:%d" ),
       
  3978         aResetReason, aReset ) );
       
  3979 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  3980     TBool animationenabled( EFalse );
       
  3981 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  3982 
       
  3983     if( OkToInitiateShutdown() )
       
  3984         {
       
  3985         TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was OkToToInitiateShutdown" ) ) );
       
  3986 
       
  3987 
       
  3988         if ( !aReset && iSysApFeatureManager->Supported(KSysApFeatureIdGoodbyeNote) )
       
  3989             {
       
  3990             TRAPD( ignore, ShowShutdownNoteL() );
       
  3991             if ( ignore ) ignore = 0; // hide compiler warning about not using variable
       
  3992             }
       
  3993 
       
  3994         if( !aReset )
       
  3995             {
       
  3996     #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  3997             TRAPD( err, ShowAnimationL() );
       
  3998             if ( err )
       
  3999                 {
       
  4000                 TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
       
  4001                 CompleteShutdown(aReset, aResetReason);
       
  4002                 }
       
  4003             }
       
  4004         else // aReset
       
  4005             {
       
  4006             CompleteShutdown(aReset, aResetReason);
       
  4007             }
       
  4008     #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4009             TRAPD( err, animationenabled = ShowAnimationL() );
       
  4010             if ( err )
       
  4011                 {
       
  4012                 TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL ShowAnimationL() leaved: %d" ), err ) );
       
  4013                 }
       
  4014             }
       
  4015 
       
  4016         if ( !animationenabled )
       
  4017             {
       
  4018             CompleteShutdown(aReset, aResetReason);
       
  4019             }
       
  4020     #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4021         }
       
  4022     else
       
  4023         {
       
  4024         TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: Was not OkToToInitiateShutdown" ) ) );
       
  4025         }
       
  4026     TRACES( RDebug::Print(_L("CSysApAppUi::DoShutdownL: END" ) ) );
       
  4027     }
       
  4028 
       
  4029 // ----------------------------------------------------------------------------
       
  4030 // CSysApAppUi::ContinueShutdown()
       
  4031 // ----------------------------------------------------------------------------
       
  4032 
       
  4033 void CSysApAppUi::ContinueShutdown()
       
  4034     {
       
  4035     TRACES( RDebug::Print(_L("CSysApAppUi::ContinueShutdown() started" ) ) );
       
  4036     CompleteShutdown();
       
  4037     TRACES( RDebug::Print(_L("CSysApAppUi::ContinueShutdown() completed" ) ) );
       
  4038     }
       
  4039 
       
  4040 // ----------------------------------------------------------------------------
       
  4041 // CSysApAppUi::ShowAnimationL()
       
  4042 // ----------------------------------------------------------------------------
       
  4043 
       
  4044 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4045 void
       
  4046 #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4047 TBool
       
  4048 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4049 CSysApAppUi::ShowAnimationL()
       
  4050     {
       
  4051     TRACES( RDebug::Print(_L("CSysApAppUi::ShowAnimationL(): START" ) ) );
       
  4052 
       
  4053     TRACES( RDebug::Print( _L("CSysApAppUi::ShowAnimationL: Initialise shutdown animation") ) );
       
  4054 
       
  4055 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4056 
       
  4057     PrepareForShutdownAnimation();
       
  4058 
       
  4059     iSysApShutdownAnimation = CSysApShutdownAnimation::NewL( *iSysApShutdownImage );
       
  4060     iSysApShutdownAnimation->Play( TCallBack( DoStopAnimTiming, this ) );
       
  4061 
       
  4062     TRACES( RDebug::Print(_L("CSysApAppUi::ShowAnimationL(): End" ) ) );
       
  4063 
       
  4064 #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4065     iSysApShutdownAnimation = CSysApShutdownAnimation::NewL( this );
       
  4066     AddToStackL( iSysApShutdownAnimation );
       
  4067     iAnimationShowingTime = iSysApShutdownAnimation->ShowingTime();
       
  4068     TRACES( RDebug::Print( _L("CSysApAppUi::ShowAnimationL: Shutdown animation initialised. Animation time = %d") ,iAnimationShowingTime) );
       
  4069 
       
  4070     TBool ret_val( EFalse );
       
  4071 
       
  4072     if ( iAnimationShowingTime )
       
  4073         {
       
  4074         if ( iSysApFeatureManager->CoverDisplaySupported() )
       
  4075             {
       
  4076             // Construct mediator observer
       
  4077             iSysApMediatorObserver = CSysApMediatorObserver::NewL( this );
       
  4078 
       
  4079             // Sync animation
       
  4080             TInt err = iSysApMediatorObserver->SyncShutdownAnimation();
       
  4081 
       
  4082             if ( err != KErrNone )
       
  4083                 {
       
  4084                 // Pretend coverUI synced instantly if error in issuing command.
       
  4085                 ShutdownAnimationSyncOK();
       
  4086                 }
       
  4087             }
       
  4088         else
       
  4089             {
       
  4090             // Pretend coverUI synced instantly when it is not supported.
       
  4091             ShutdownAnimationSyncOK();
       
  4092             }
       
  4093 
       
  4094         ret_val = ETrue;
       
  4095         }
       
  4096 
       
  4097     TRACES( RDebug::Print(_L("CSysApAppUi::ShowAnimationL(): returns: %d" ),ret_val ) );
       
  4098     return ret_val;
       
  4099 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4100     }
       
  4101 
       
  4102 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4103 // ----------------------------------------------------------------------------
       
  4104 // CSysApAppUi::ShutdownAnimationSyncOK()
       
  4105 // ----------------------------------------------------------------------------
       
  4106 
       
  4107 void CSysApAppUi::ShutdownAnimationSyncOK()
       
  4108     {
       
  4109     TRACES( RDebug::Print(_L("CSysApAppUi::ShutdownAnimationSyncOK(): Call PrepareForShutdownAnimation()" ) ) );
       
  4110     PrepareForShutdownAnimation();//SysAp's internal preparation for ShutDown with animation
       
  4111     TRACES( RDebug::Print(_L("CSysApAppUi::ShutdownAnimationSyncOK(): Called PrepareForShutdownAnimation()" ) ) );
       
  4112     }
       
  4113 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4114 
       
  4115 // ----------------------------------------------------------------------------
       
  4116 // CSysApAppUi::SkipShutdownAnimation()
       
  4117 // ----------------------------------------------------------------------------
       
  4118 
       
  4119 void CSysApAppUi::SkipShutdownAnimation()
       
  4120     {
       
  4121     TRACES( RDebug::Print(_L("CSysApAppUi::SkipShutdownAnimation() " ) ) );
       
  4122 
       
  4123 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4124     if ( iSysApShutdownAnimation )
       
  4125         {
       
  4126         iSysApShutdownAnimation->Cancel();
       
  4127         }
       
  4128 #else // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4129     if ( iAnimationShowingTime )
       
  4130         {
       
  4131         iSysApShutdownAnimation->EndAnimation();
       
  4132         }
       
  4133 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4134     }
       
  4135 
       
  4136 // ----------------------------------------------------------------------------
       
  4137 // CSysApAppUi::NotifyShutdownAnimationSkip()
       
  4138 // ----------------------------------------------------------------------------
       
  4139 
       
  4140 void CSysApAppUi::NotifyShutdownAnimationSkip()
       
  4141     {
       
  4142     TRACES( RDebug::Print(_L("CSysApAppUi::NotifyShutdownAnimationSkip() " ) ) );
       
  4143 
       
  4144     if ( iSysApMediatorObserver )
       
  4145         {
       
  4146         iSysApMediatorObserver->ShutdownAnimationSkipped();
       
  4147         }
       
  4148     }
       
  4149 
       
  4150 // ----------------------------------------------------------------------------
       
  4151 // CSysApAppUi::CompleteShutdown()
       
  4152 // ----------------------------------------------------------------------------
       
  4153 
       
  4154 void CSysApAppUi::CompleteShutdown( const TBool aReset, const TInt aResetReason )
       
  4155     {
       
  4156     TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): START" ) ) );
       
  4157 
       
  4158     PrepareForShutdownImage();//SysAp's internal preparation for ShutDown with image
       
  4159 
       
  4160     FreeResources();
       
  4161 
       
  4162     if ( aReset )
       
  4163         {
       
  4164         __ASSERT_DEBUG( aResetReason >= RStarterSession::ELanguageSwitchReset &&
       
  4165                         aResetReason <= RStarterSession::EDataRestoreReset,
       
  4166                         User::Invariant() );
       
  4167         StarterSession().Reset( static_cast<RStarterSession::TResetReason>( aResetReason ) );
       
  4168         }
       
  4169     else
       
  4170         {
       
  4171         StarterSession().Shutdown();
       
  4172         }
       
  4173 
       
  4174     StarterSession().Close();
       
  4175 
       
  4176     TRACES( RDebug::Print(_L("CSysApAppUi::CompleteShutdown(): END" ) ) );
       
  4177     }
       
  4178 
       
  4179 #ifndef SYSAP_USE_STARTUP_UI_PHASE
       
  4180 // ----------------------------------------------------------------------------
       
  4181 // CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
       
  4182 // This method is not called after boot has finished.
       
  4183 // ----------------------------------------------------------------------------
       
  4184 
       
  4185 void CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
       
  4186     {
       
  4187     TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: %d" ), aSwState ) );
       
  4188 
       
  4189     switch ( aSwState )
       
  4190         {
       
  4191         case RStarterSession::ENormal:
       
  4192             SetStatusPaneLayoutL( ESysApNormal );
       
  4193             break;
       
  4194         case RStarterSession::ECharging:
       
  4195             SetStatusPaneLayoutL( ESysApCharging );
       
  4196             break;
       
  4197         case RStarterSession::EAlarm:
       
  4198             SetStatusPaneLayoutL( ESysApAlarm );
       
  4199             break;
       
  4200         default:
       
  4201             break;
       
  4202         };
       
  4203 
       
  4204     TRAPD( simChangedErr, DoSimChangedFromPreviousBootL() );
       
  4205     TRACES( RDebug::Print( _L("CSysApAppUi::DoStateChangedL: simChangedErr = %d" ), simChangedErr ) );
       
  4206     simChangedErr = simChangedErr; // suppress 'variable not used' warning
       
  4207     LogsObserverL().HandleSimChangedCheckDoneL();
       
  4208 
       
  4209     if ( iSysApFeatureManager->PowerSaveSupported() )
       
  4210         {
       
  4211         // create controller before checking battery state, so that power saving can be enabled during boot if needed
       
  4212         if ( !iSysApPsmController ) // created only in first state change
       
  4213             {
       
  4214             iSysApPsmController = CSysApPsmController::NewL( *this );        
       
  4215             }
       
  4216 
       
  4217         // in charger boot explicitly disable partial power save mode
       
  4218         if ( aSwState == RStarterSession::ECharging && !iCharging )
       
  4219             {
       
  4220             iSysApPsmController->ChargerConnected();
       
  4221             iSysApPsmController->DoEnablePartialPsm( EFalse ); // disable partial power save now
       
  4222             }
       
  4223         }
       
  4224 
       
  4225     TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
       
  4226     //Also Charging status will be updated with the following function.
       
  4227     UpdateBatteryBarsL( state );
       
  4228 
       
  4229     if( IsStateNormal() )
       
  4230         {
       
  4231         TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
       
  4232 
       
  4233         DoSwStateNormalConstructionL();
       
  4234 
       
  4235         InitializeStatusPaneAreaL();
       
  4236         CheckSilentModeL();
       
  4237         HandleAccessoryProfileInStartupL();
       
  4238 
       
  4239         if ( iSysApFeatureManager->MmcSupported() )
       
  4240             {
       
  4241 #ifndef RD_MULTIPLE_DRIVE
       
  4242             MountMMC();
       
  4243             MMCStatusChangedL();
       
  4244             iHideFirstBeep = EFalse;
       
  4245 #else // RD_MULTIPLE_DRIVE
       
  4246             iSysApDriveList->MountDrive( iSysApDriveList->DefaultMemoryCard() );
       
  4247             UpdateInsertedMemoryCardsL();
       
  4248 #endif // RD_MULTIPLE_DRIVE
       
  4249             }
       
  4250         if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
  4251             {
       
  4252             iSysApMMCObserver->StartMountObserver();
       
  4253             }
       
  4254 
       
  4255         
       
  4256         if ( iSysApPsmController )
       
  4257             {
       
  4258             if ( iCharging ) // if charger is connected on boot PSM queries may need to be shown
       
  4259                 {
       
  4260                 HandleChargingStatusL( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
       
  4261                 }
       
  4262             }
       
  4263         
       
  4264         TInt batteryStatus = StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryStatus );
       
  4265         TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: batteryStatus %d" ), batteryStatus ) );
       
  4266         if(  batteryStatus == EBatteryStatusLow || batteryStatus == EBatteryStatusEmpty )
       
  4267             {
       
  4268             // low and empty battery states are informed to the user in device startup
       
  4269             HandleBatteryStatusL( batteryStatus );
       
  4270             }
       
  4271         else if ( iSysApPsmController && !iCharging )
       
  4272         	{
       
  4273 				TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: batteryStatus %d, iCharging %d -> disable partial psm" ), batteryStatus, iCharging ) );
       
  4274 
       
  4275 				iSysApPsmController->BatteryLow( EFalse );
       
  4276 				iSysApPsmController->DoEnablePartialPsm( EFalse );
       
  4277 			}
       
  4278 
       
  4279         iSysApBtController = CreateSysApBtControllerL( *this );
       
  4280         iSysApBtSapController = CreateSysApBtSapControllerL( *this );
       
  4281 
       
  4282         if ( iActivateBt )
       
  4283             {
       
  4284             TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Activating BT" ) ) );
       
  4285             SetBtPowerState( ETrue );
       
  4286             }
       
  4287 
       
  4288         if ( iDeactivateBt )
       
  4289             {
       
  4290             TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Deactivating BT" ) ) );
       
  4291             SetBtPowerState( EFalse );
       
  4292             }
       
  4293         iSysApLocationPrivacyIndicator = CreateSysApLocationPrivacyIndicatorL( *this );
       
  4294         iSysApLocationPrivacyIndicator->InitL();
       
  4295 
       
  4296         if ( ! iSysApUsbIndicatorController )
       
  4297             {
       
  4298             TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
       
  4299             if ( usbErr )
       
  4300                 {
       
  4301                 TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: error in constructing USB ind. controller %d" ), usbErr ) );
       
  4302                 }
       
  4303             }
       
  4304 
       
  4305         // Other late initializations.
       
  4306         // In order to prevent unexpected behaviour e.g. in OOM situations, these calls are made to ensure
       
  4307         // that the services are connected when they are needed for the first time.
       
  4308         if ( !StarterSession().Handle() )
       
  4309             {
       
  4310             User::Leave( KErrBadHandle );
       
  4311             }
       
  4312 
       
  4313         if ( !KeyLock().Handle() )
       
  4314             {
       
  4315             User::Leave( KErrBadHandle );
       
  4316             }
       
  4317 
       
  4318 #ifdef __SYSAP_MODULE_TEST
       
  4319         ModuleTestShowUiNoteL( _L("SysAp: SW state normal!") );
       
  4320 #endif
       
  4321         }
       
  4322 
       
  4323     // Allow lights
       
  4324     iSysApLightsController->AllowLightsOn();
       
  4325     }
       
  4326 
       
  4327 #else // SYSAP_USE_STARTUP_UI_PHASE
       
  4328 
       
  4329 // ----------------------------------------------------------------------------
       
  4330 // CSysApAppUi::HandleUiReadyAfterBootL()
       
  4331 // Called when startup UI activities has been finished
       
  4332 // ----------------------------------------------------------------------------
       
  4333 
       
  4334 void CSysApAppUi::HandleUiReadyAfterBootL()
       
  4335     {
       
  4336     TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL" ) ) );
       
  4337     
       
  4338     SetStatusPaneLayoutL( ESysApNormal );
       
  4339     
       
  4340     TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
       
  4341     //Also Charging status will be updated with the following function.
       
  4342     UpdateBatteryBarsL( state );
       
  4343     
       
  4344     DoSwStateNormalConstructionL();
       
  4345 
       
  4346     InitializeStatusPaneAreaL();
       
  4347     CheckSilentModeL();
       
  4348     HandleAccessoryProfileInStartupL();
       
  4349     
       
  4350     if ( iSysApFeatureManager->MmcSupported() )
       
  4351         {
       
  4352 #ifndef RD_MULTIPLE_DRIVE
       
  4353         MountMMC();
       
  4354         MMCStatusChangedL();
       
  4355         iHideFirstBeep = EFalse;
       
  4356 #else // RD_MULTIPLE_DRIVE
       
  4357         iSysApDriveList->MountDrive( iSysApDriveList->DefaultMemoryCard() );
       
  4358         UpdateInsertedMemoryCardsL();
       
  4359 #endif // RD_MULTIPLE_DRIVE
       
  4360         }
       
  4361     
       
  4362     if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
  4363         {
       
  4364         iSysApMMCObserver->StartMountObserver();
       
  4365         }
       
  4366 
       
  4367     if ( iSysApPsmController )
       
  4368         {
       
  4369         if ( iCharging ) // if charger is connected on boot PSM queries may need to be shown
       
  4370             {
       
  4371             HandleChargingStatusL( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
       
  4372             }
       
  4373         }
       
  4374     
       
  4375     TInt batteryStatus = StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryStatus );
       
  4376     TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d" ), batteryStatus ) );
       
  4377     if(  batteryStatus == EBatteryStatusLow || batteryStatus == EBatteryStatusEmpty )
       
  4378         {
       
  4379         // low and empty battery states are informed to the user in device startup
       
  4380         HandleBatteryStatusL( batteryStatus );
       
  4381         }
       
  4382     else if ( iSysApPsmController && !iCharging )
       
  4383       	{
       
  4384 		    TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: batteryStatus %d, iCharging %d -> disable partial psm" ), batteryStatus, iCharging ) );
       
  4385 
       
  4386 			iSysApPsmController->BatteryLow( EFalse );
       
  4387 			iSysApPsmController->DoEnablePartialPsm( EFalse );
       
  4388         }
       
  4389 
       
  4390     iSysApLocationPrivacyIndicator = CreateSysApLocationPrivacyIndicatorL( *this );
       
  4391     iSysApLocationPrivacyIndicator->InitL();
       
  4392 
       
  4393     if ( ! iSysApUsbIndicatorController )
       
  4394         {
       
  4395         TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
       
  4396         if ( usbErr )
       
  4397             {
       
  4398             TRACES( RDebug::Print(_L("CSysApAppUi::HandleUiReadyAfterBootL: error in constructing USB ind. controller %d" ), usbErr ) );
       
  4399             }
       
  4400         }
       
  4401     }
       
  4402 
       
  4403 // ----------------------------------------------------------------------------
       
  4404 // CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
       
  4405 // This method is not called after boot has finished.
       
  4406 // ----------------------------------------------------------------------------
       
  4407 
       
  4408 void CSysApAppUi::DoStateChangedL(const RStarterSession::TGlobalState aSwState)
       
  4409     {
       
  4410     TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL: %d" ), aSwState ) );
       
  4411 
       
  4412     switch ( aSwState )
       
  4413         {
       
  4414         case RStarterSession::ENormal:
       
  4415             // status pane layout will updated when UI is ready
       
  4416             break;
       
  4417         case RStarterSession::ECharging:
       
  4418             SetStatusPaneLayoutL( ESysApCharging );
       
  4419             break;
       
  4420         case RStarterSession::EAlarm:
       
  4421             SetStatusPaneLayoutL( ESysApAlarm );
       
  4422             break;
       
  4423         default:
       
  4424             break;
       
  4425         };
       
  4426 
       
  4427     TRAPD( simChangedErr, DoSimChangedFromPreviousBootL() );
       
  4428     TRACES( RDebug::Print( _L("CSysApAppUi::DoStateChangedL: simChangedErr = %d" ), simChangedErr ) );
       
  4429     simChangedErr = simChangedErr; // suppress 'variable not used' warning
       
  4430     LogsObserverL().HandleSimChangedCheckDoneL();
       
  4431 
       
  4432     if ( iSysApFeatureManager->PowerSaveSupported() )
       
  4433         {
       
  4434         // create controller before checking battery state, so that power saving can be enabled during boot if needed
       
  4435         if ( !iSysApPsmController ) // created only in first state change
       
  4436             {
       
  4437             iSysApPsmController = CSysApPsmController::NewL( *this );        
       
  4438             }
       
  4439 
       
  4440         // in charger boot explicitly disable partial power save mode
       
  4441         if ( aSwState == RStarterSession::ECharging )
       
  4442             {
       
  4443             iSysApPsmController->ChargerConnected();
       
  4444             iSysApPsmController->DoEnablePartialPsm( EFalse ); // disable partial power save now
       
  4445             }
       
  4446         }
       
  4447 
       
  4448     if ( aSwState == RStarterSession::ECharging || aSwState == RStarterSession::EAlarm )
       
  4449         {
       
  4450         TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
       
  4451         //Also Charging status will be updated with the following function.
       
  4452         UpdateBatteryBarsL( state );    
       
  4453         }
       
  4454         
       
  4455     if( IsStateNormal() )
       
  4456         {
       
  4457         TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
       
  4458 
       
  4459         iSysApBtController = CreateSysApBtControllerL( *this );
       
  4460         iSysApBtSapController = CreateSysApBtSapControllerL( *this );
       
  4461 
       
  4462         if ( iActivateBt )
       
  4463             {
       
  4464             TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Activating BT" ) ) );
       
  4465             SetBtPowerState( ETrue );
       
  4466             }
       
  4467 
       
  4468         if ( iDeactivateBt )
       
  4469             {
       
  4470             TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL Deactivating BT" ) ) );
       
  4471             SetBtPowerState( EFalse );
       
  4472             }
       
  4473 
       
  4474         // Other late initializations.
       
  4475         // In order to prevent unexpected behaviour e.g. in OOM situations, these calls are made to ensure
       
  4476         // that the services are connected when they are needed for the first time.
       
  4477         if ( !StarterSession().Handle() )
       
  4478             {
       
  4479             User::Leave( KErrBadHandle );
       
  4480             }
       
  4481 
       
  4482         if ( !KeyLock().Handle() )
       
  4483             {
       
  4484             User::Leave( KErrBadHandle );
       
  4485             }
       
  4486 
       
  4487 #ifdef __SYSAP_MODULE_TEST
       
  4488         ModuleTestShowUiNoteL( _L("SysAp: SW state normal!") );
       
  4489 #endif
       
  4490         }
       
  4491 
       
  4492     // Allow lights
       
  4493     iSysApLightsController->AllowLightsOn();
       
  4494     }
       
  4495 
       
  4496 
       
  4497 #endif // SYSAP_USE_STARTUP_UI_PHASE
       
  4498 
       
  4499 // ----------------------------------------------------------------------------
       
  4500 // CSysApAppUi::UiReady()
       
  4501 // 
       
  4502 // ----------------------------------------------------------------------------
       
  4503 
       
  4504 TBool CSysApAppUi::UiReady() const
       
  4505     {
       
  4506 #ifdef SYSAP_USE_STARTUP_UI_PHASE    
       
  4507     return iSysApStartupController->UiReady(); 
       
  4508 #else // SYSAP_USE_STARTUP_UI_PHASE
       
  4509     // if startup UI phase information is not used, global system state normal is handled as UI idle state
       
  4510     return IsStateNormal();
       
  4511 #endif // SYSAP_USE_STARTUP_UI_PHASE        
       
  4512     }
       
  4513 
       
  4514 // ----------------------------------------------------------------------------
       
  4515 // CSysApAppUi::PrepareForShutdownAnimation()
       
  4516 // ----------------------------------------------------------------------------
       
  4517 void CSysApAppUi::PrepareForShutdownAnimation()
       
  4518     {
       
  4519     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() begin") ) );
       
  4520 
       
  4521 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4522     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() showtime = %d"), iAnimationShowingTime ) );
       
  4523     if ( iAnimationShowingTime )
       
  4524         {
       
  4525 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4526         static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDPowerOffTone );
       
  4527         CancelGlobalListQuery();
       
  4528 
       
  4529         if ( iSysApPowerKeyMenuObserver )
       
  4530             {
       
  4531             iSysApPowerKeyMenuObserver->Cancel();
       
  4532             }
       
  4533 
       
  4534         // deactivate notifiers before showing the shutdown image
       
  4535         AknNotifierController::CancelAllNotifications();
       
  4536         AknNotifierController::HideAllNotifications(ETrue);
       
  4537         RWindowGroup groupWin = iCoeEnv->RootWin();
       
  4538         iCapturedAppskey = groupWin.CaptureKey( EKeyApplication, KModifierMask, KModifierMask );
       
  4539         iCapturedAppskeyUpAndDowns = groupWin.CaptureKeyUpAndDowns( EStdKeyApplication0, KModifierMask, KModifierMask );
       
  4540         iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront );
       
  4541 
       
  4542         TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() Draw background image" ) ) );
       
  4543 
       
  4544         ShowShutdownImage( KBackgroundImageID );
       
  4545 
       
  4546 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4547         TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() Show Shutdown animation" ) ) );
       
  4548         TInt err(0);
       
  4549         TRAP( err, iSysApShutdownAnimation->StartL( iLastPowerKeyWasShort ) );
       
  4550         if ( err )
       
  4551             {
       
  4552             TRACES( RDebug::Print( _L("SysAp: Shutdown animation fails. Error code: %d" ), err ) );
       
  4553             // Start animation timing immediatily if animation starting fails.
       
  4554             // Otherwise animation will call StartAnimTiming when it is ready.
       
  4555             StartAnimTiming();
       
  4556             }
       
  4557         }
       
  4558 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  4559 
       
  4560     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownAnimation() end") ) );
       
  4561     }
       
  4562 
       
  4563 
       
  4564 // ----------------------------------------------------------------------------
  1027 // ----------------------------------------------------------------------------
  4565 // CSysApAppUi::PrepareForShutdownImage()
  1028 // CSysApAppUi::PrepareForShutdownImage()
  4566 // ----------------------------------------------------------------------------
  1029 // ----------------------------------------------------------------------------
  4567 
  1030 
  4568 void CSysApAppUi::PrepareForShutdownImage()
  1031 void CSysApAppUi::PrepareForShutdownImage()
  4569     {
  1032     {
  4570     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() START" ) ) );
  1033     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() START" ) ) );
  4571 
  1034  
  4572     // If RD_STARTUP_ANIMATION_CUSTOMIZATION is enabled, the following actions are always taken in PrepareForShutdownAnimation
  1035     // If RD_STARTUP_ANIMATION_CUSTOMIZATION is enabled, the following actions are always taken in PrepareForShutdownAnimation
  4573 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
  1036 #ifndef RD_STARTUP_ANIMATION_CUSTOMIZATION
  4574     if ( !iAnimationShowingTime ) // actions already taken in PrepareForShutdownAnimation
  1037     if ( !iAnimationShowingTime ) // actions already taken in PrepareForShutdownAnimation
  4575         {
  1038         {
  4576         static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDPowerOffTone );
  1039         static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDPowerOffTone );
  4591 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
  1054 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
  4592 
  1055 
  4593 #ifndef __SYSAP_MODULE_TEST //to make errors during shutdown sequence being seen more easily
  1056 #ifndef __SYSAP_MODULE_TEST //to make errors during shutdown sequence being seen more easily
  4594     iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront );
  1057     iEikonEnv->RootWin().SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront );
  4595     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() Show Shutdown image" ) ) );
  1058     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() Show Shutdown image" ) ) );
  4596     ShowShutdownImage( EMbmSysapQgn_startup_screen );
  1059     ShowShutdownImage( 1  );//EMbmSysapQgn_startup_screen
  4597 #endif
  1060 #endif
  4598     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() END" ) ) );
  1061     TRACES( RDebug::Print( _L("CSysApAppUi::PrepareForShutdownImage() END" ) ) );
  4599     }
       
  4600 
       
  4601 // ----------------------------------------------------------------------------
       
  4602 // CSysApAppUi::SetStatusPaneLauoutL( const TSysApPhoneState aState )
       
  4603 // ----------------------------------------------------------------------------
       
  4604 
       
  4605 void CSysApAppUi::SetStatusPaneLayoutL( const TSysApPhoneState aState )
       
  4606     {
       
  4607     TRACES( RDebug::Print( _L("CSysApAppUi::SetStatusPaneLayoutL aState: %d"), aState ) );
       
  4608     if( aState == ESysApNormal )
       
  4609         //Status pane cannot be even visible on Normal mode
       
  4610         {
       
  4611         StatusPane()->MakeVisible( EFalse );
       
  4612         StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_EMPTY );
       
  4613         }
       
  4614     else if( aState == ESysApCharging )
       
  4615         //SysAp's statuspane is visible on Charging mode
       
  4616         {
       
  4617         StatusPane()->MakeVisible( ETrue );
       
  4618         StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE );
       
  4619         }
       
  4620     else if( aState == ESysApAlarm )
       
  4621     	{
       
  4622     	if ( !Layout_Meta_Data::IsLandscapeOrientation() )
       
  4623     		{
       
  4624     		// Portrait mode
       
  4625 	        StatusPane()->MakeVisible( ETrue );
       
  4626 	        StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE );
       
  4627     		}
       
  4628     	else
       
  4629     		{
       
  4630     		// Landscape mode
       
  4631 	        TInt layout = R_AVKON_STATUS_PANE_LAYOUT_POWER_OFF_RECHARGE;
       
  4632 	        // For side softkey devices, use different layout
       
  4633 	        if (AVKONENV->StatusPaneResIdForCurrentLayout(R_AVKON_STATUS_PANE_LAYOUT_USUAL) == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_RIGHT)
       
  4634 	        	layout = R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_RIGHT;
       
  4635 	        else if (AVKONENV->StatusPaneResIdForCurrentLayout(R_AVKON_STATUS_PANE_LAYOUT_USUAL) == R_AVKON_STACON_PANE_LAYOUT_USUAL_SOFTKEYS_LEFT)
       
  4636 	        	layout = R_AVKON_STACON_PANE_LAYOUT_EMPTY_SOFTKEYS_LEFT;
       
  4637 
       
  4638 	        StatusPane()->MakeVisible( ETrue );
       
  4639 	        StatusPane()->SwitchLayoutL( layout );
       
  4640     		}
       
  4641     	}
       
  4642     }
  1062     }
  4643 
  1063 
  4644 // ----------------------------------------------------------------------------
  1064 // ----------------------------------------------------------------------------
  4645 // CSysApAppUi::OkToInitiateShutdown()
  1065 // CSysApAppUi::OkToInitiateShutdown()
  4646 // ----------------------------------------------------------------------------
  1066 // ----------------------------------------------------------------------------
  4670         {
  1090         {
  4671         return EFalse;
  1091         return EFalse;
  4672         }
  1092         }
  4673     }
  1093     }
  4674 
  1094 
  4675 /**
  1095 
  4676  * To check the for an emergency call. 
  1096 void CSysApAppUi::PopupNote()
  4677  * 
  1097     {
  4678  * @return ETrue if there is an emergency call active otherwise, EFalse.
  1098     iIgnoreNextPowerKeyUpEvent = ETrue;
  4679  */
  1099     // TRACES( RDebug::Print( _L("CSysApAppUi::Key was consumed") ) );
  4680 TBool IsEmergencyCall()
  1100     _LIT(KPowerPressKey,"Short power key");
  4681         {
  1101     HBufC* aString = HBufC16::NewLC(50);
  4682         TBool retVal( EFalse );
  1102     TPtrC aStringPointer = aString->Des();
  4683         TInt err( KErrNone );
  1103     aStringPointer.Set(KPowerPressKey);
  4684         TInt state( 0 );
  1104     TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
  4685      
  1105     ShowExampleUiNoteL( aStringPointer );  
  4686         err = RProperty::Get(KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo, state );
  1106     CleanupStack::PopAndDestroy(); // aString
  4687         if ( err == KErrNone && state )
  1107     }
  4688             {
  1108 
  4689             retVal = ETrue;            
  1109 
  4690             }
  1110 // ----------------------------------------------------------------------------
  4691         return retVal;
  1111 // CSysApAppUi::SetUsbAttachStatus
  4692         }	
  1112 // ----------------------------------------------------------------------------
  4693 
  1113 #ifndef RD_MULTIPLE_DRIVE
  4694 // ----------------------------------------------------------------------------
  1114 void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
  4695 // CSysApAppUi::HandleCurrentCallStateChangeL()
  1115     {
  4696 // ----------------------------------------------------------------------------
  1116     // Prevent double beep when USB file transfer gets activated but
  4697 
  1117     // allow MMC inserted beep when:
  4698 void CSysApAppUi::HandleCurrentCallStateChangeL( TInt aCurrentCallState )
  1118     // a) USB file transfer is active
  4699     {
  1119     // b) MMC is not inserted when USB cable is attached
  4700     TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: KUidCurrentCall: %d" ), aCurrentCallState ) );
  1120     iHideNextBeep = ( iMMCInserted && aUsbAttached );
  4701 
  1121     }
  4702     if( iPowerKeyPopupMenuActive )
  1122 #else // RD_MULTIPLE_DRIVE
  4703         {
  1123 void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
  4704         CancelGlobalListQuery();
  1124     {
  4705         }
  1125     TRACES( RDebug::Print(
  4706 
  1126         _L( "CSysApAppUi::SetUsbAttachStatus: aUsbAttached: %d" ),
  4707     switch ( aCurrentCallState )
  1127         aUsbAttached ) );
  4708         {
  1128 
  4709         case EPSCTsyCallStateRinging:
  1129     if ( aUsbAttached )
  4710             {
  1130         {
  4711             iSysApLightsController->CallComingInL( ETrue );
  1131           // For ignoring extra beeps caused by USB file transfer
  4712             // Disable keylock when a call is coming in
  1132 /*        iSysApDriveList->ResetDrivesInsertBeepIgnored();
  4713             if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle || iKeyLockOnBeforeAlarm )
  1133         iSysApDriveList->MarkDrivesInsertBeepIgnored( iInsertedMemoryCards );
  4714                 {
  1134         // Will take care in next sub
  4715                 TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateRinging: disable keylock") ) );
  1135 */        }
  4716                 iKeyLockOnBeforeCall = ETrue;
  1136     }
  4717 
  1137 #endif // RD_MULTIPLE_DRIVE
  4718                 if ( iKeyLockEnabled || iDeviceLockEnabled )
  1138 
  4719                     {
  1139 
  4720                     if ( !iSysApFeatureManager->TouchUnlockStrokeSupported() )
  1140 // ----------------------------------------------------------------------------
  4721                         {
  1141 // CSysApAppUi::UsbChargerDetector
  4722                         KeyLock().DisableWithoutNote();
  1142 // ----------------------------------------------------------------------------
  4723                         }
  1143 //
  4724                     }
  1144 TSysApUsbChargerDetector& CSysApAppUi::UsbChargerDetector()
  4725                 }
  1145     {
  4726             break;
  1146     return iSysApUsbChargerDetector;
  4727             }
  1147     }
  4728             
  1148 
  4729         case EPSCTsyCallStateDialling:
  1149 
  4730             {
  1150 // ----------------------------------------------------------------------------
  4731             // Disable keypad lock during an emergency call
  1151 // CSysApAppUi::HandleAccessoryDisconnectedL()
  4732             // no need to disable the key lock when a call is made using the wireless car-kit
  1152 // ----------------------------------------------------------------------------
  4733             // but if the call is an emergency one then we will disable the keypad lock
  1153 
  4734             if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle )
  1154 void CSysApAppUi::HandleAccessoryDisconnectedL()
  4735                 {
  1155     {
  4736                 TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateDialling: disable keylock") ) );
  1156     TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryDisconnectedL()" ) ) );
  4737                 iKeyLockOnBeforeCall = ETrue;
  1157 
  4738 
  1158 
  4739                 if ( IsEmergencyCall() && (iKeyLockEnabled || iDeviceLockEnabled ))
  1159     TAccMode accessoryState(EAccModeHandPortable);
  4740                     {
  1160     if ( iSysApAccessoryObserver )
  4741                     KeyLock().DisableWithoutNote();
  1161         {
  4742                     }
  1162         accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
  4743                 }
  1163         }
  4744 
  1164 
  4745             // Enable signal & network indicators when an emergency call is made in Offline Mode
  1165     if ( accessoryState == EAccModeHandPortable )
  4746             if( iSysApOfflineModeController->OfflineModeActive() )
  1166         {
  4747                     {
  1167         iSysApLightsController->AccessoryConnectedL( EFalse );
  4748                     // Signal indicators not updated with VoIP call
  1168         iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 0 );
  4749                     if ( StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) != EPSCTsyCallTypeVoIP) 
       
  4750                         {
       
  4751                         iEmergencyCallActive = ETrue;
       
  4752                         UpdateSignalBarsL();
       
  4753                         SetSignalIndicatorL();
       
  4754                         }
       
  4755                     }
       
  4756             break;
       
  4757             }
       
  4758             
       
  4759         case EPSCTsyCallStateConnected:
       
  4760             {
       
  4761             if (StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) == EPSCTsyCallTypeCSVoice)
       
  4762                 {
       
  4763                 // Check if GPRS suspended note is required
       
  4764                 iCallActivated = ETrue;
       
  4765                 HandleGprsNotesL();
       
  4766                 }
       
  4767             if ( iDeviceLockEnabled )
       
  4768                 {
       
  4769                 // Enable keylock via autolock emulation if device lock enabled. 
       
  4770                 // Otherwise e.g. messages can be read using softkeys during ongoing call.
       
  4771                 KeyLock().EnableAutoLockEmulation();
       
  4772                 }
       
  4773             break;
       
  4774             }
       
  4775 
       
  4776         case EPSCTsyCallStateNone:
       
  4777             {
       
  4778             // Reset timers in ScreenSaver and Autolock
       
  4779             User::ResetInactivityTime();
       
  4780 
       
  4781             if ( iEmergencyCallActive )
       
  4782                 {
       
  4783                 iEmergencyCallActive = EFalse;
       
  4784                 UpdateSignalBarsL( 0 );
       
  4785                 SetSignalIndicatorL();
       
  4786                 }
       
  4787             if ( iKeyLockOnBeforeCall )
       
  4788                 {
       
  4789                 TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateNone: enable keylock") ) );
       
  4790                 iKeyLockOnBeforeCall = EFalse;
       
  4791                 if ( !iDeviceLockEnabled )
       
  4792                     {
       
  4793                     if ( !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeAlarm &&
       
  4794                           !iSysApFeatureManager->TouchUnlockStrokeSupported() )
       
  4795                         {
       
  4796                         if ( iSysApCenRepController->GetInt( KCRUidCommonTelephonySettings, KSettingsSummaryAfterCall ) == 1 )
       
  4797                             {
       
  4798                             KeyLock().EnableWithoutNote(); // Let's not hide "Summary After Call" dialog
       
  4799                             }
       
  4800                         else
       
  4801                             {
       
  4802                             KeyLock().EnableKeyLock();
       
  4803                             }
       
  4804                         }
       
  4805                     }
       
  4806                 else
       
  4807                     {
       
  4808                     KeyLock().EnableAutoLockEmulation();
       
  4809                     }
       
  4810                 }
       
  4811             if ( iShowkeypadActivatedNoteAfterSoftReject )
       
  4812                 {
       
  4813                 ShowUiNoteL( EKeypadActiveNote );
       
  4814                 iShowkeypadActivatedNoteAfterSoftReject = EFalse;
       
  4815                 }
       
  4816             iCallActivated = EFalse;
       
  4817             break;
       
  4818             }
       
  4819             
       
  4820         default:
       
  4821             break;
       
  4822         }
       
  4823 
       
  4824     if ( aCurrentCallState != EPSCTsyCallStateRinging )
       
  4825         {
       
  4826         iSysApLightsController->CallComingInL( EFalse );
       
  4827         }
  1169         }
  4828 
  1170 
  4829     SetIhfIndicatorL();
  1171     SetIhfIndicatorL();
  4830     SetHacIndicatorL();
  1172     SetHacIndicatorL();
  4831     }
  1173 
  4832 
  1174     // If lock disabled because of accessory, reactivate it, unless phone call or alarm is ongoing
  4833 // ----------------------------------------------------------------------------
  1175     if ( iKeyLockOnBeforeCradle )
  4834 // CSysApAppUi::DoSwStateNormalConstructionL()
  1176         {
  4835 // ----------------------------------------------------------------------------
  1177         iKeyLockOnBeforeCradle = EFalse;
  4836 
  1178         if ( !iKeyLockOnBeforeCall && !iKeyLockOnBeforeAlarm )
  4837 void CSysApAppUi::DoSwStateNormalConstructionL()
  1179             {
  4838     {
  1180             if ( !iDeviceLockEnabled )
  4839     // Let's ensure that the lights will remain on for 15 secs after sw state normal
  1181                 {
  4840     User::ResetInactivityTime();
  1182                 iKeyguardController->EnableKeyguard(ETrue);
  4841 
       
  4842     TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : START" ) ) );
       
  4843 
       
  4844     // In case of unexpected reset (e.g. hidden boot) the keylock must be enabled silently. Locking is done
       
  4845     // prior to time-consuming initializations, because otherwise UI is in unlocked state for a few seconds.
       
  4846     if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive ) == 1  )
       
  4847         {
       
  4848         TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: enabling keylock") ) );
       
  4849         KeyLock().EnableWithoutNote();
       
  4850         }
       
  4851 
       
  4852     // Initiate bearer change observation
       
  4853     iSysApConnectionMonitorObserver = CSysApConnectionMonitorObserver::NewL( *this );
       
  4854 
       
  4855     TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: trying CSysApSsSettingsObserver::NewL()") ) );
       
  4856     iSysApSsSettingsObserver = CSysApSsSettingsObserver::NewL( *this );
       
  4857 
       
  4858     TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: trying new ( ELeave ) CSysApPowerKeyMenuObserver") ) );
       
  4859     iSysApPowerKeyMenuObserver = new( ELeave ) CSysApPowerKeyMenuObserver( *this );
       
  4860 
       
  4861     TRACES( RDebug::Print( _L("SysAp: trying CSystemLock::NewL" ) ) );
       
  4862     iSysApSystemLock = CSystemLock::NewL();
       
  4863 
       
  4864     iSysApCenRepCallForwardingObserver = CSysApCenRepCallForwardingObserver::NewL( *this );
       
  4865 
       
  4866     iSysApCenRepMsgWaitingObserver = CSysApCenRepMsgWaitingObserver::NewL( *this );
       
  4867 
       
  4868     
       
  4869     if ( iSysApFeatureManager->Supported( KSysApFeatureIdBatteryInfoPopup ) )
       
  4870         {
       
  4871         iSysApBatteryInfoController = CSysApBatteryInfoController::NewL( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsConf, 
       
  4872                                                                                                      KCoreAppUIsBatteryInformationLowThreshold ) );    
       
  4873         }
       
  4874     
       
  4875 
       
  4876     TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : END" ) ) );
       
  4877     }
       
  4878 
       
  4879 // ----------------------------------------------------------------------------
       
  4880 // CSysApAppUi::DoSimChangedFromPreviousBootL()
       
  4881 // ----------------------------------------------------------------------------
       
  4882 
       
  4883 void CSysApAppUi::DoSimChangedFromPreviousBootL()
       
  4884     {
       
  4885     TRACES( RDebug::Print( _L("CSysApAppUi::DoSimChangedFromPreviousBootL: iSimChangedDone=%d" ), iSimChangedDone ) );
       
  4886 
       
  4887     if ( !iSimChangedDone  )
       
  4888         {
       
  4889         iSimChangedDone = ETrue;
       
  4890         CSysApSimChanged* simChanged = CSysApSimChanged::NewL( *this, iEikonEnv->FsSession() );
       
  4891         CleanupStack::PushL( simChanged );
       
  4892         simChanged->HandleSimChangedL();
       
  4893         CleanupStack::PopAndDestroy( simChanged );
       
  4894         }
       
  4895     }
       
  4896 
       
  4897 // ----------------------------------------------------------------------------
       
  4898 // CSysApAppUi::CancelWaitNote()
       
  4899 // ----------------------------------------------------------------------------
       
  4900 
       
  4901 void CSysApAppUi::CancelWaitNote()
       
  4902     {
       
  4903     TRACES( RDebug::Print( _L("CSysApAppUi::CancelWaitNote" ) ) );
       
  4904     if ( iSysApWaitNote )
       
  4905         {
       
  4906         iSysApWaitNote->Cancel();
       
  4907         delete iSysApWaitNote;
       
  4908         iSysApWaitNote = NULL;
       
  4909         }
       
  4910     }
       
  4911 
       
  4912 // ----------------------------------------------------------------------------
       
  4913 // CSysApAppUi::CancelGlobalListQuery()
       
  4914 // ----------------------------------------------------------------------------
       
  4915 
       
  4916 void CSysApAppUi::CancelGlobalListQuery()
       
  4917     {
       
  4918     TRACES( RDebug::Print( _L("CSysApAppUi::CancelGlobalListQuery" ) ) );
       
  4919     if ( iGlobalListQuery )
       
  4920         {
       
  4921         iGlobalListQuery->CancelListQuery();
       
  4922         delete iGlobalListQuery;
       
  4923         iGlobalListQuery = NULL;
       
  4924         }
       
  4925     }
       
  4926 
       
  4927 #ifndef RD_MULTIPLE_DRIVE
       
  4928 // ----------------------------------------------------------------------------
       
  4929 // CSysApAppUi::MountMMC()
       
  4930 // ----------------------------------------------------------------------------
       
  4931 
       
  4932 TInt CSysApAppUi::MountMMC()
       
  4933     {
       
  4934     TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC") ) );
       
  4935     TInt err ( KErrNotSupported );
       
  4936     if ( iSysApFeatureManager->MmcSupported() )
       
  4937         {
       
  4938 #ifdef __WINS__ // Let's sleep a second in WINS
       
  4939         User::After( 1000000 );
       
  4940 #endif
       
  4941         err = iEikonEnv->FsSession().MountFileSystem( KFSName, KMMCDrive );
       
  4942         TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC: RFs::MountFileSystem() returned: %d"), err ) );
       
  4943         if ( err == KErrInUse )
       
  4944             {
       
  4945             User::After( 1000000 );
       
  4946             err = iEikonEnv->FsSession().MountFileSystem( KFSName, KMMCDrive );
       
  4947             TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC: RFs::MountFileSystem() returned: %d"), err ) );
       
  4948             }
       
  4949         }
       
  4950     return err;
       
  4951     }
       
  4952 
       
  4953 // ----------------------------------------------------------------------------
       
  4954 // CSysApAppUi::DismountMMC()
       
  4955 // ----------------------------------------------------------------------------
       
  4956 
       
  4957 TInt CSysApAppUi::DismountMMC()
       
  4958     {
       
  4959     TRACES( RDebug::Print( _L("CSysApAppUi::DismountMMC") ) );
       
  4960 #ifdef __WINS__ // Let's sleep a second in WINS
       
  4961         User::After( 1000000 );
       
  4962 #endif
       
  4963 
       
  4964     TInt err ( KErrNotSupported );
       
  4965     if ( iSysApFeatureManager->MmcSupported() )
       
  4966         {
       
  4967         err = iEikonEnv->FsSession().DismountFileSystem( KFSName, KMMCDrive );
       
  4968         TRACES( RDebug::Print( _L("CSysApAppUi::DismountMMC: RFs::DismountFileSystem() returned: %d"), err ) );
       
  4969         }
       
  4970     return err;
       
  4971     }
       
  4972 
       
  4973 // ----------------------------------------------------------------------------
       
  4974 // CSysApAppUi::EjectMMCL()
       
  4975 // ----------------------------------------------------------------------------
       
  4976 
       
  4977 void CSysApAppUi::EjectMMCL()
       
  4978     {
       
  4979     TRACES( RDebug::Print( _L("CSysApAppUi::EjectMMCL") ) );
       
  4980     iMMCEjectUsed = ETrue;
       
  4981     iMMCPowerMenuEjectUsed = ETrue;
       
  4982     iTimeToKill = EFalse;
       
  4983     iApplicationScanningRoundNumber = 0;
       
  4984     CloseUIAppsInHotSwapL();
       
  4985     }
       
  4986 
       
  4987 #else // RD_MULTIPLE_DRIVE
       
  4988 
       
  4989 // ----------------------------------------------------------------------------
       
  4990 // CSysApAppUi::EjectMMCL()
       
  4991 // ----------------------------------------------------------------------------
       
  4992 
       
  4993 void CSysApAppUi::EjectMMCL()
       
  4994     {
       
  4995     // Called from eject confirm query, check drive inserted before start
       
  4996     TInt insertedIndex( CSysApDriveList::Find(
       
  4997         iInsertedMemoryCards, iDriveToEject ) );
       
  4998 
       
  4999     TRACES( RDebug::Print(
       
  5000         _L( "CSysApAppUi::EjectMMCL: iMMCEjectUsed: %d, drive: %d, index: %d "),
       
  5001         iMMCEjectUsed, iDriveToEject, insertedIndex ) );
       
  5002 
       
  5003     if ( insertedIndex != KErrNotFound )
       
  5004         {
       
  5005         iSysApDriveList->MarkDriveToEject(
       
  5006             iDriveToEject, CSysApDriveList::EEjectFromMenu );
       
  5007         iSysApDriveEjectHandler->StartEject();
       
  5008         }
       
  5009     iMMCEjectUsed = EFalse;
       
  5010     }
       
  5011 
       
  5012 #endif // RD_MULTIPLE_DRIVE
       
  5013 
       
  5014 // ----------------------------------------------------------------------------
       
  5015 // CSysApAppUi::DisconnectBtSap()
       
  5016 // ----------------------------------------------------------------------------
       
  5017 
       
  5018 void CSysApAppUi::DisconnectBtSap()
       
  5019     {
       
  5020     TRACES( RDebug::Print( _L("CSysApAppUi::DisconnectBtSap") ) );
       
  5021     iSysApBtSapController->Disconnect();
       
  5022     }
       
  5023 
       
  5024 #ifndef RD_MULTIPLE_DRIVE
       
  5025 // ----------------------------------------------------------------------------
       
  5026 // CSysApAppUi::RunUnlockNotifierL()
       
  5027 // ----------------------------------------------------------------------------
       
  5028 
       
  5029 void CSysApAppUi::RunUnlockNotifierL( TSysApMemoryCardStatus aMemoryCardStatus )
       
  5030     {
       
  5031     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: START") ) );
       
  5032     if ( iSysApFeatureManager->MmcSupported() )
       
  5033         {
       
  5034         if ( UiReady() )
       
  5035             {
       
  5036             TSysApMemoryCardStatus memoryCardStatus;
       
  5037             if ( aMemoryCardStatus == ESysApMemoryCardStatusNotKnown )
       
  5038                 {
       
  5039                 memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
       
  5040                 }
  1183                 }
  5041             else
  1184             else
  5042                 {
  1185                 {
  5043                 memoryCardStatus = aMemoryCardStatus;
  1186                 iKeyguardController->EnableKeyguard(EFalse);
  5044                 }
  1187                 }
  5045 
  1188             }
  5046             TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: memoryCardStatus=%d"), memoryCardStatus ) );
  1189         }
  5047 
  1190     }
  5048             switch ( memoryCardStatus )
  1191 
  5049                 {
  1192 
  5050                 case ESysApMemoryCardInserted:
  1193 // ----------------------------------------------------------------------------
  5051                     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC inserted") ) );
  1194 // CSysApAppUi::HandleAccessoryConnectedL()
  5052                     if ( aMemoryCardStatus == ESysApMemoryCardInserted )
  1195 // ----------------------------------------------------------------------------
  5053                         {
  1196 
  5054                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
  1197 void CSysApAppUi::HandleAccessoryConnectedL( TAccMode aAccessoryState )
  5055                         }
  1198     {
  5056                     break;
  1199     TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL( aAccessoryState: %d ) "), aAccessoryState ) );
  5057                 case ESysApMemoryCardLocked:
  1200 
  5058                     {
  1201     if ( aAccessoryState == EAccModeWirelessHeadset ||
  5059                     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC locked") ) );
  1202          aAccessoryState == EAccModeWiredHeadset ||
  5060                     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
  1203          aAccessoryState == EAccModeHeadphones )
  5061                     TInt callState = StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState );
  1204         {
  5062 
  1205         }
  5063                     if (  (! ( iDeviceLockEnabled || iKeyLockEnabled ) ) &&
  1206     else if ( aAccessoryState == EAccModeLoopset )
  5064                           callState != EPSCTsyCallStateRinging && // We don't want to see the MMC passwd query
  1207         {
  5065                           callState != EPSCTsyCallStateAlerting ) // when the user is e.g. making an emergency call
  1208         }
  5066                         {
  1209     else if ( aAccessoryState == EAccModeTextDevice )
  5067                         if ( iSysApFeatureManager->MemoryCardLockSupported() )
  1210         {
  5068                             {
  1211         }
  5069                             if ( ! iMemoryCardDialog )
  1212     else if ( aAccessoryState == EAccModeWirelessCarKit || aAccessoryState == EAccModeWiredCarKit )
  5070                                 {
  1213         {
  5071                                 TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: ACTIVATE MMC passwd query") ) );
  1214         }
  5072                                 CAknMemoryCardDialog* mmcDialog = CAknMemoryCardDialog::NewLC( this );
  1215     else if ( aAccessoryState == EAccModeTVOut )
  5073                                 iMemoryCardDialog = mmcDialog; // temporary variable used for hiding codescanner error 
  1216         {
  5074                                 iMemoryCardDialog->SetSelfPointer( &iMemoryCardDialog );
  1217         }
  5075                                 iMemoryCardDialog->UnlockCardLD(); // when UnlockCardLD completes it calls UnlockComplete()
  1218     else if (aAccessoryState == EAccModeHDMI )
  5076                                 }
  1219             {
  5077                             }
  1220             }
  5078                         else
  1221 
  5079                             {
  1222     TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
  5080                             // Since locked cards are not supported, notify user that card is locked.
  1223     TRACES( RDebug::Print( _L("CSysApAppUi::HandleAccessoryConnectedL: swState: %d"), swState ) );
  5081                             ShowQueryL( ESysApMemoryCardLockedNote );
  1224 
  5082                             }
  1225     if( UiReady() || swState == ESwStateSecurityCheck )
  5083                         }
  1226         {
  5084                     }
  1227         iSysApLightsController->AccessoryConnectedL( ETrue );
  5085                     break;
  1228         }
  5086 
  1229 
  5087                 case ESysApMemoryCardNotInserted:
  1230     if ( ( ! iSysApOfflineModeController->OfflineModeActive() ))
  5088                 default:
  1231         {
  5089                     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC not inserted") ) );
  1232         if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) < 1 )
  5090                     if ( aMemoryCardStatus == ESysApMemoryCardNotInserted )
  1233             // accessory not connected already
  5091                         {
  1234              {
  5092                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
  1235             iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected, 1 );
  5093                         }
  1236            }
  5094                 }
  1237         }
  5095             }
  1238     
  5096         }
  1239     // Carkit and music stand have also light on permanently option that needs to be checked
  5097     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: END") ) );
  1240     if( aAccessoryState == EAccModeWiredCarKit || aAccessoryState == EAccModeMusicStand )
  5098     }
  1241         {
  5099 
  1242         // When device is placed on a handsfree cradle, keyguard must be disabled (unless device is locked)
  5100 // ----------------------------------------------------------------------------
  1243         // Note: It is assumed that if carkit/music stand is connected, the phone is in the cradle.
  5101 // CSysApAppUi::UnlockComplete() from MAknMemoryCardDialogObserver
  1244         if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCall || iKeyLockOnBeforeAlarm )
  5102 // ----------------------------------------------------------------------------
  1245             {
  5103 
  1246             iKeyLockOnBeforeCradle = ETrue;
  5104 void CSysApAppUi::UnlockComplete( TInt aResult )
  1247 
  5105     {
  1248             if ( iKeyLockEnabled && !iDeviceLockEnabled )
  5106     TRACES( RDebug::Print( _L("CSysApAppUi::UnlockComplete result: %d"), aResult ) );
  1249                 {
  5107     if ( aResult == KErrNone )
  1250                 iKeyguardController->DisableKeyguard(EFalse);
  5108         {
  1251                 }
  5109         RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
  1252             }
  5110         }
  1253         }
  5111     }
  1254     SetIhfIndicatorL();
  5112 
  1255     SetHacIndicatorL();
  5113 // ----------------------------------------------------------------------------
  1256     }
  5114 // CSysApAppUi::MMCStatusChangedL() from MSysApMemoryCardObserver
  1257 
  5115 // ----------------------------------------------------------------------------
       
  5116 
       
  5117 void CSysApAppUi::MMCStatusChangedL()
       
  5118     {
       
  5119     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL START: iMMCInserted: %d, iMMCEjectUsed: %d, iHideFirstBeep: %d, iHideNextBeep: %d" ), iMMCInserted, iMMCEjectUsed, iHideFirstBeep, iHideNextBeep ) );
       
  5120 
       
  5121     if ( iSysApFeatureManager->MmcSupported() && !iShutdownStarted )
       
  5122         {
       
  5123         TSysApMemoryCardStatus memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
       
  5124         TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL memoryCardStatus=%d" ), memoryCardStatus ) );
       
  5125 
       
  5126         switch ( memoryCardStatus )
       
  5127             {
       
  5128             case ESysApMemoryCardInserted:
       
  5129             case ESysApMemoryCardLocked:
       
  5130                 TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC drive mounted" ) ) );
       
  5131                 if ( ! iMMCInserted ) // MMC was not inserted before
       
  5132                     {
       
  5133                     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC newly inserted" ) ) );
       
  5134                     CancelWaitNote(); // just to be sure, the user might keep on closing and opening the MMC latch
       
  5135                     // An MMC has been newly inserted, so play a sound and check if its password protected
       
  5136 
       
  5137                     if ( UiReady() )
       
  5138                         {
       
  5139                         if ( !iHideFirstBeep && !iHideNextBeep ) // starting up
       
  5140                             {
       
  5141                             Beep();
       
  5142                             // Switch lights on
       
  5143                             iSysApLightsController->MemoryCardInsertedL();
       
  5144                             }
       
  5145                         iHideNextBeep = EFalse;
       
  5146                         }
       
  5147 
       
  5148                     iMMCPowerMenuEjectUsed = EFalse;
       
  5149                     iMMCEjectUsed = EFalse;
       
  5150                     iMMCInserted = ETrue;
       
  5151 
       
  5152                     // No need to show ESysApRemoveMmcNote after MMC already mounted
       
  5153                     if ( iSysApConfirmationQuery )
       
  5154                         {
       
  5155                         if ( iSysApConfirmationQuery->CurrentQuery() == ESysApRemoveMmcNote )
       
  5156                             {
       
  5157                             iSysApConfirmationQuery->Cancel();
       
  5158                             }
       
  5159                         }
       
  5160 
       
  5161                     // Check if the MMC is locked and unlock it if necessary
       
  5162                     RunUnlockNotifierL( memoryCardStatus );
       
  5163                     }
       
  5164                 break;
       
  5165             default:
       
  5166                 TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC drive not mounted" ) ) );
       
  5167                 delete iMemoryCardDialog; // sets itself to null
       
  5168                 RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  5169                 if ( iMMCInserted )
       
  5170                     {
       
  5171                     // No need to show ESysApEjectMmcQuery after MMC already removed
       
  5172                     if ( iSysApConfirmationQuery )
       
  5173                         {
       
  5174                         if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
       
  5175                             {
       
  5176                             iSysApConfirmationQuery->Cancel();
       
  5177                             }
       
  5178                         }
       
  5179 
       
  5180                     iMMCInserted = EFalse;
       
  5181 
       
  5182                     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  5183                     if ( !iMMCEjectUsed && propertyValue != KUsbPersonalityIdMS )
       
  5184                         {
       
  5185                         // if USB file transfer active, do not close applications
       
  5186                         // if eject selected in MMC App, MMC App takes care of the following and
       
  5187                         // if eject selected from powerkeymenu, applications have already been shutdown
       
  5188                         iTimeToKill = EFalse;
       
  5189                         iApplicationScanningRoundNumber = 0;
       
  5190                         CloseUIAppsInHotSwapL();
       
  5191                         }
       
  5192                     }
       
  5193                 else
       
  5194                     {
       
  5195                     // If MMC was not previously inserted and eject was chosed from power key menu, attempt to remount.
       
  5196                     if ( iMMCPowerMenuEjectUsed )
       
  5197                         {
       
  5198                         TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: Attempt to remount" ) ) );
       
  5199                         MountMMC();
       
  5200                         // If mount was successful, unnecessary note will be canceled in insert notification handling.
       
  5201                         }
       
  5202                     }
       
  5203                 break;
       
  5204             }
       
  5205 
       
  5206         // Update memory card indicator status
       
  5207         SetMemoryCardIndicatorL();
       
  5208         }
       
  5209     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL   END: iMMCInserted: %d, iMMCEjectUsed: %d, iHideFirstBeep: %d, iHideNextBeep: %d" ), iMMCInserted, iMMCEjectUsed, iHideFirstBeep, iHideNextBeep ) );
       
  5210     }
       
  5211 
       
  5212 // ----------------------------------------------------------------------------
       
  5213 // CSysApAppUi::ShowMMCDismountedDialogL()
       
  5214 // ----------------------------------------------------------------------------
       
  5215 
       
  5216 void CSysApAppUi::ShowMMCDismountedDialogL()
       
  5217     {
       
  5218     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  5219 
       
  5220     // Do not show any note if USB file transfer is active.
       
  5221     if ( propertyValue != KUsbPersonalityIdMS )
       
  5222         {
       
  5223         if ( iSysApFeatureManager->MemoryCardHatchSupported() )
       
  5224             { // MMC hatch has been opened and MMC has been dismounted
       
  5225             TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK." ) ) );
       
  5226             ShowQueryL( ESysApRemoveMmcNote );
       
  5227             }
       
  5228         else
       
  5229             {
       
  5230             // MMC has been removed and dismounted
       
  5231             TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: You might have lost some data." ) ) );
       
  5232             // No confirmation but let's set this true to enable MMC passwd query
       
  5233             ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
       
  5234             }
       
  5235         }
       
  5236     else
       
  5237         {
       
  5238         TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: No note shown, USB file transfer caused dismount." ) ) );
       
  5239         }
       
  5240     }
       
  5241 
       
  5242 // ----------------------------------------------------------------------------
       
  5243 // CSysApAppUi::MMCDismountedDialogConfirmed
       
  5244 // ----------------------------------------------------------------------------
       
  5245 
       
  5246 void CSysApAppUi::MMCDismountedDialogConfirmed()
       
  5247     {
       
  5248     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCDismountedDialogConfirmed") ) );
       
  5249 
       
  5250     // Try to remount just in case when eject was chosen from power key menu
       
  5251     if ( iMMCPowerMenuEjectUsed )
       
  5252         {
       
  5253         iMMCPowerMenuEjectUsed = EFalse;
       
  5254 
       
  5255         if ( MountMMC() == KErrLocked ) // In case a locked card was not removed after all
       
  5256             {
       
  5257             TRAPD( err, MMCStatusChangedL() ); // This will update power menu and memory card icon. Also memory card password is requeried.
       
  5258             if ( err != KErrNone )
       
  5259                 {
       
  5260                 TRACES( RDebug::Print( _L( "CSysApAppUi::MMCDismountedDialogConfirmed: MMCStatusChangedL failed, err=%d"), err ) );
       
  5261                 }
       
  5262             }
       
  5263         }
       
  5264 
       
  5265     }
       
  5266 
       
  5267 #else // RD_MULTIPLE_DRIVE
       
  5268 
       
  5269 // ----------------------------------------------------------------------------
       
  5270 // CSysApAppUi::MMCInsertedL
       
  5271 // ----------------------------------------------------------------------------
       
  5272 
       
  5273 void CSysApAppUi::MMCInsertedL()
       
  5274     {
       
  5275     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCInsertedL") ) );
       
  5276 
       
  5277     if ( iSysApFeatureManager->MmcSupported() && !iShutdownStarted )
       
  5278 		{
       
  5279 		TBool normalState( UiReady() );
       
  5280 
       
  5281 		if ( normalState )
       
  5282 			{
       
  5283 			TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
       
  5284 			TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( defaultMemoryCard ) );
       
  5285 
       
  5286 			TRACES( RDebug::Print(
       
  5287 				_L( "CSysApAppUi::MMCInsertedL: drive: %d, memoryCardStatus: %d" ), defaultMemoryCard, memoryCardStatus ) );
       
  5288 
       
  5289 			switch ( memoryCardStatus )
       
  5290 				{
       
  5291 				case ESysApMemoryCardInserted: // Fall through
       
  5292 				case ESysApMemoryCardLocked:
       
  5293 					{
       
  5294 					// Reset eject and unlock of inserted memory card
       
  5295 					iSysApDriveList->ResetDriveToEject( defaultMemoryCard );
       
  5296 					iSysApDriveList->ResetDriveUnlockQueryShown( defaultMemoryCard );
       
  5297 
       
  5298 					CancelWaitNote();
       
  5299 
       
  5300 					if ( memoryCardStatus == ESysApMemoryCardInserted )
       
  5301 						{
       
  5302 						TRACES( RDebug::Print(
       
  5303 							_L( "CSysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardInserted: %d" ), memoryCardStatus ) );
       
  5304 						RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
       
  5305 						}
       
  5306 					else
       
  5307 						{
       
  5308 						TRACES( RDebug::Print(
       
  5309 							_L( "CSysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardLocked: %d" ), memoryCardStatus ) );
       
  5310 						RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  5311 						}
       
  5312 					break;
       
  5313 					}
       
  5314 				case ESysApMemoryCardNotInserted:
       
  5315 					{
       
  5316 					// Always reset eject and unlock of removed memory card
       
  5317 					TBool isEject( iSysApDriveList->IsDriveToEject( defaultMemoryCard ) );
       
  5318 
       
  5319 					TRACES( RDebug::Print(
       
  5320 						_L( "CSysApAppUi::MMCInsertedL: isEject: %d, drive: %d" ),
       
  5321 						isEject, defaultMemoryCard ) );
       
  5322 
       
  5323 					iSysApDriveList->ResetDriveToEject( defaultMemoryCard );
       
  5324 					iSysApDriveList->ResetDriveUnlockQueryShown( defaultMemoryCard );
       
  5325 
       
  5326 					TRACES( RDebug::Print(
       
  5327 						_L( "SysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardNotInserted: %d" ), memoryCardStatus ) );
       
  5328 
       
  5329 					RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  5330 					break;
       
  5331 					}
       
  5332 				case ESysApMemoryCardStatusNotKnown: // Fall through
       
  5333 				default:
       
  5334 					{
       
  5335 					break;
       
  5336 					}
       
  5337 				}
       
  5338 				RunUnlockNotifierL();
       
  5339 			}
       
  5340 		}
       
  5341 	}
       
  5342 
       
  5343 
       
  5344 // ----------------------------------------------------------------------------
       
  5345 // CSysApAppUi::RunUnlockNotifierL()
       
  5346 // ----------------------------------------------------------------------------
       
  5347 
       
  5348 void CSysApAppUi::RunUnlockNotifierL()
       
  5349     {
       
  5350     TRACES( RDebug::Print(
       
  5351         _L("CSysApAppUi::RunUnlockNotifierL: START iDeviceLockEnabled: %d, iKeyLockEnabled: %d" ),
       
  5352          iDeviceLockEnabled, iKeyLockEnabled ) );
       
  5353 
       
  5354     if ( !iSysApFeatureManager->MmcSupported() ||
       
  5355          iDeviceLockEnabled ||
       
  5356          iKeyLockEnabled ||
       
  5357          !UiReady() )
       
  5358         {
       
  5359         TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: END") ) );
       
  5360         return;
       
  5361         }
       
  5362 
       
  5363     // We don't want to see the MMC passwd query
       
  5364     // when the user is e.g. making an emergency call
       
  5365     TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  5366     if ( callState != EPSCTsyCallStateRinging &&
       
  5367         callState != EPSCTsyCallStateAlerting )
       
  5368         {
       
  5369         iSysApDriveUnlockHandler->StartUnlock();
       
  5370         }
       
  5371 
       
  5372     TRACES( RDebug::Print(
       
  5373         _L("CSysApAppUi::RunUnlockNotifierL: END callState: %d"), callState ) );
       
  5374     }
       
  5375 
       
  5376 // ----------------------------------------------------------------------------
       
  5377 // CSysApAppUi::MMCStatusChangedL() from MSysApMemoryCardObserver
       
  5378 // ----------------------------------------------------------------------------
       
  5379 
       
  5380 void CSysApAppUi::MMCStatusChangedL( TInt aDrive )
       
  5381     {
       
  5382     TRACES( RDebug::Print(
       
  5383         _L( "CSysApAppUi::MMCStatusChangedL START: MMCCount: %d, iMMCEjectUsed: %d" ),
       
  5384         iInsertedMemoryCards.Count(), iMMCEjectUsed ) );
       
  5385 
       
  5386     if ( iShutdownStarted || !iSysApFeatureManager->MmcSupported() )
       
  5387         {
       
  5388         TRACES( RDebug::Print(
       
  5389             _L( "CSysApAppUi::MMCStatusChangedL iShutdownStarted: %d END" ),
       
  5390             iShutdownStarted ) );
       
  5391         return;
       
  5392         }
       
  5393 
       
  5394     TBool normalState( UiReady() );
       
  5395 
       
  5396     TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
       
  5397     TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( aDrive ) );
       
  5398     TInt insertedIndex( CSysApDriveList::Find( iInsertedMemoryCards, aDrive ) );
       
  5399 
       
  5400     TRACES( RDebug::Print(
       
  5401         _L( "CSysApAppUi::MMCStatusChangedL: normalState: %d, index: %d, drive: %d, memoryCardStatus: %d" ),
       
  5402         normalState, insertedIndex, aDrive, memoryCardStatus ) );
       
  5403 
       
  5404     switch ( memoryCardStatus )
       
  5405         {
       
  5406         case ESysApMemoryCardInserted: // Fall through
       
  5407         case ESysApMemoryCardLocked:
       
  5408             {
       
  5409             if ( insertedIndex == KErrNotFound ) // Not inserted before
       
  5410                 {
       
  5411                 // Reset eject and unlock of inserted memory card
       
  5412                 iSysApDriveList->ResetDriveToEject( aDrive );
       
  5413                 iSysApDriveList->ResetDriveUnlockQueryShown( aDrive );
       
  5414 
       
  5415                 CancelWaitNote();
       
  5416 
       
  5417                 if ( aDrive == defaultMemoryCard )
       
  5418                     {
       
  5419                     if ( memoryCardStatus == ESysApMemoryCardInserted )
       
  5420                         {
       
  5421                          RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
       
  5422                       	}
       
  5423                     else
       
  5424                         {
       
  5425                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  5426                         }
       
  5427                     }
       
  5428 
       
  5429                 if ( normalState )
       
  5430                     {
       
  5431                     // Ignore extra beep from USB file transfer
       
  5432                     TBool ignoreBeep(
       
  5433                         iSysApDriveList->IsDriveInsertBeepIgnored( aDrive ) );
       
  5434 
       
  5435                     TRACES( RDebug::Print(
       
  5436                         _L( "CSysApAppUi::MMCStatusChangedL: ignoreBeep: %d, drive: %d" ),
       
  5437                         ignoreBeep, aDrive ) );
       
  5438 
       
  5439                     if ( !ignoreBeep )
       
  5440                         {
       
  5441                         Beep();
       
  5442                         iSysApLightsController->MemoryCardInsertedL();
       
  5443                         }
       
  5444 
       
  5445                     iSysApDriveList->ResetDriveInsertBeepIgnored( aDrive );
       
  5446 
       
  5447                     // Keep ignoring extra beep if USB file transfer is active
       
  5448                     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  5449 
       
  5450                     TRACES( RDebug::Print(
       
  5451                         _L( "CSysApAppUi::MMCStatusChangedL: usbState: %d" ), propertyValue ) );
       
  5452 
       
  5453                     if ( propertyValue == KUsbPersonalityIdMS )
       
  5454                         {
       
  5455                         iSysApDriveList->MarkDriveInsertBeepIgnored( aDrive );
       
  5456                         }
       
  5457                     }
       
  5458 
       
  5459                 if ( iDriveToDismount == aDrive && iSysApConfirmationQuery )
       
  5460                     {
       
  5461                     if ( iSysApConfirmationQuery->CurrentQuery() == ESysApRemoveMmcNote )
       
  5462                         {
       
  5463                         // User put back ejected memory card or did not remove it
       
  5464                         iSysApConfirmationQuery->Cancel();
       
  5465                         }
       
  5466                     }
       
  5467                 RunUnlockNotifierL();
       
  5468                 }
       
  5469             break;
       
  5470             }
       
  5471         case ESysApMemoryCardNotInserted:
       
  5472             {
       
  5473             // Always reset eject and unlock of removed memory card
       
  5474             TBool isEject( iSysApDriveList->IsDriveToEject( aDrive ) );
       
  5475 
       
  5476             TRACES( RDebug::Print(
       
  5477                 _L( "CSysApAppUi::MMCStatusChangedL: isEject: %d, drive: %d" ),
       
  5478                 isEject, aDrive ) );
       
  5479 
       
  5480             iSysApDriveList->ResetDriveToEject( aDrive );
       
  5481             iSysApDriveList->ResetDriveUnlockQueryShown( aDrive );
       
  5482 
       
  5483             if ( insertedIndex != KErrNotFound ) // Inserted before
       
  5484                 {
       
  5485                 if ( memoryCardStatus == ESysApMemoryCardNotInserted )
       
  5486                     {
       
  5487                     // Reset extra beep ignore if memory card was removed without eject
       
  5488                     iSysApDriveList->ResetDriveInsertBeepIgnored( aDrive );
       
  5489                     }
       
  5490 
       
  5491                 CancelGlobalListQuery(); // Cancel power menu
       
  5492 
       
  5493                 if ( aDrive == defaultMemoryCard )
       
  5494                     {
       
  5495                     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  5496                     }
       
  5497 
       
  5498                 if ( iSysApConfirmationQuery )
       
  5499                     {
       
  5500                     if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
       
  5501                         {
       
  5502                         // User removed memory card too early
       
  5503                         iSysApConfirmationQuery->Cancel();
       
  5504                         // Allow application closing to execute.
       
  5505                         // Also FileManager is closed in this case, regardless where the eject was initiated from.
       
  5506                         iMMCEjectUsed = EFalse;
       
  5507                         }
       
  5508                     }
       
  5509 
       
  5510                 // Stop unlock of removed memory card
       
  5511                 iSysApDriveUnlockHandler->StopUnlock( aDrive );
       
  5512 
       
  5513                 if ( !iMMCEjectUsed && !isEject )
       
  5514                     {
       
  5515                     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  5516 
       
  5517                     TRACES( RDebug::Print(
       
  5518                         _L( "CSysApAppUi::MMCStatusChangedL: usbState: %d" ), propertyValue ) );
       
  5519 
       
  5520                     if ( propertyValue != KUsbPersonalityIdMS )
       
  5521                         {
       
  5522                         if ( iSysApFeatureManager->MemoryCardHatchSupported() )
       
  5523                             {
       
  5524                             // Store drive removed without eject and start eject handling
       
  5525                             iSysApDriveList->MarkDriveToEject(
       
  5526                                 aDrive, CSysApDriveList::EEjectRemovedWithoutEject );
       
  5527                             iSysApDriveEjectHandler->StartEject();
       
  5528                             }
       
  5529                         else
       
  5530                             {
       
  5531                             // Just show the note
       
  5532                             ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
       
  5533                             }
       
  5534                         }
       
  5535                     }
       
  5536                 iMMCEjectUsed = EFalse;
       
  5537                 }
       
  5538             break;
       
  5539             }
       
  5540         case ESysApMemoryCardStatusNotKnown: // Fall through
       
  5541         default:
       
  5542             {
       
  5543             break;
       
  5544             }
       
  5545         }
       
  5546 
       
  5547     // Update inserted memory cards
       
  5548     iSysApDriveList->GetMemoryCardsL(
       
  5549         iInsertedMemoryCards, CSysApDriveList::EIncludeInserted );
       
  5550 
       
  5551     // Update memory card indicator status
       
  5552     SetMemoryCardIndicatorL();
       
  5553 
       
  5554     TRACES( RDebug::Print(
       
  5555         _L( "CSysApAppUi::MMCStatusChangedL END: MMCCount: %d, iMMCEjectUsed: %d" ),
       
  5556         iInsertedMemoryCards.Count(), iMMCEjectUsed ) );
       
  5557     }
       
  5558 
       
  5559 // ----------------------------------------------------------------------------
       
  5560 // CSysApAppUi::ShowMMCDismountedDialogL()
       
  5561 // ----------------------------------------------------------------------------
       
  5562 
       
  5563 TBool CSysApAppUi::ShowMMCDismountedDialogL(
       
  5564         TInt aDrive, CSysApDriveList::TDriveEjectType aEjectType )
       
  5565     {
       
  5566     TRACES( RDebug::Print(
       
  5567         _L( "CSysApAppUi::ShowMMCDismountedDialogL: aDrive: %d, aEjectType: %d" ),
       
  5568         aDrive, aEjectType ) );
       
  5569 
       
  5570     TBool ret( EFalse );
       
  5571     iDriveToDismount = aDrive;
       
  5572     HBufC* driveName = iSysApDriveList->GetFormattedDriveNameLC(
       
  5573         aDrive,
       
  5574         R_QTN_EJECT_REMOVE_MEMORY_INFO );
       
  5575 
       
  5576     if ( aEjectType == CSysApDriveList::EEjectFromMenu )
       
  5577         {
       
  5578         TRACES( RDebug::Print(
       
  5579             _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK...." ) ) );
       
  5580         ShowQueryL( ESysApRemoveMmcNote, *driveName );
       
  5581         ret = ETrue;
       
  5582         }
       
  5583     else
       
  5584         {
       
  5585         // Memory card was removed without eject
       
  5586         TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  5587 
       
  5588         // Do not show any note if USB file transfer is active.
       
  5589         if ( propertyValue != KUsbPersonalityIdMS )
       
  5590             {
       
  5591             if ( iSysApFeatureManager->MemoryCardHatchSupported() )
       
  5592                 {
       
  5593                 // MMC hatch has been opened and MMC has been dismounted
       
  5594                 TRACES( RDebug::Print(
       
  5595                     _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK." ) ) );
       
  5596                 ShowQueryL( ESysApRemoveMmcNote, *driveName );
       
  5597                 ret = ETrue;
       
  5598                 }
       
  5599             else
       
  5600                 {
       
  5601                 iSysApDriveList->ResetDrivesToEject();
       
  5602 
       
  5603                 // MMC has been removed and dismounted
       
  5604                 TRACES( RDebug::Print( _L(
       
  5605                     "CSysApAppUi::ShowMMCDismountedDialogL: Show note: You might have lost some data." ) ) );
       
  5606 
       
  5607                 // No confirmation but let's set this true to enable MMC passwd query
       
  5608                 ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
       
  5609                 }
       
  5610             }
       
  5611         else
       
  5612             {
       
  5613             iSysApDriveList->ResetDrivesToEject();
       
  5614             TRACES( RDebug::Print(
       
  5615                 _L( "CSysApAppUi::ShowMMCDismountedDialogL: No note shown, USB file transfer caused dismount." ) ) );
       
  5616             }
       
  5617         }
       
  5618 
       
  5619     CleanupStack::PopAndDestroy( driveName );
       
  5620 
       
  5621     TRACES( RDebug::Print(
       
  5622         _L( "CSysApAppUi::ShowMMCDismountedDialogL: ret: %d" ), ret ) );
       
  5623 
       
  5624     return ret;
       
  5625     }
       
  5626 
       
  5627 // ----------------------------------------------------------------------------
       
  5628 // CSysApAppUi::MMCDismountedDialogConfirmed
       
  5629 // ----------------------------------------------------------------------------
       
  5630 
       
  5631 void CSysApAppUi::MMCDismountedDialogConfirmed()
       
  5632     {
       
  5633     TRACES( RDebug::Print(
       
  5634         _L( "CSysApAppUi::MMCDismountedDialogConfirmed: iDriveToDismount: %d" ),
       
  5635         iDriveToDismount ) );
       
  5636 
       
  5637     // Try remount to check if drive was put back
       
  5638     iSysApDriveList->MountDrive( iDriveToDismount );
       
  5639     if ( !iSysApDriveEjectHandler->CompleteDismount( iDriveToDismount ) )
       
  5640         {
       
  5641         // When ready, check for locked memory cards and update indicators
       
  5642         TRAP_IGNORE( SetMemoryCardIndicatorL() );
       
  5643         TRAP_IGNORE( RunUnlockNotifierL() );
       
  5644         }
       
  5645     }
       
  5646 
       
  5647 #endif // RD_MULTIPLE_DRIVE
       
  5648 
       
  5649 // ----------------------------------------------------------------------------
       
  5650 // CSysApAppUi::EjectStarted()
       
  5651 // ----------------------------------------------------------------------------
       
  5652 
       
  5653 void CSysApAppUi::EjectStarted( TBool ejectStarted )
       
  5654     {
       
  5655     TRACES( RDebug::Print( _L( "CSysApAppUi::EjectStarted" ) ) );
       
  5656     iMMCEjectUsed = ejectStarted;
       
  5657     
       
  5658 #ifndef RD_MULTIPLE_DRIVE
       
  5659     iFileManagerCloseDisabled = ejectStarted;
       
  5660 #endif // RD_MULTIPLE_DRIVE
       
  5661 }
       
  5662 
       
  5663 // ----------------------------------------------------------------------------
       
  5664 // CSysApAppUi::DoLightsTimeoutChangedL
       
  5665 // ----------------------------------------------------------------------------
       
  5666 void CSysApAppUi::DoLightsTimeoutChangedL( const TInt aTimeout )
       
  5667     {
       
  5668     iSysApLightsController->DoLightsTimeoutChangedL( aTimeout );
       
  5669     }
       
  5670 
       
  5671 #ifdef __SYSAP_MODULE_TEST
       
  5672 
       
  5673 // ----------------------------------------------------------------------------
       
  5674 // CSysApAppUi::ModuleTestShowUiNoteL()
       
  5675 // ----------------------------------------------------------------------------
       
  5676 
       
  5677 void CSysApAppUi::ModuleTestShowUiNoteL( const TDesC& noteText ) const
       
  5678     {
       
  5679     CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
  5680     note->SetTone( EAvkonSIDNoSound );
       
  5681     note->ShowNoteL( EAknGlobalInformationNote, noteText );
       
  5682     CleanupStack::PopAndDestroy(); // note
       
  5683     }
       
  5684 
       
  5685 #endif
       
  5686 
       
  5687 // ----------------------------------------------------------------------------
       
  5688 // CSysApAppUi::ShowShutdownNoteL()
       
  5689 // ----------------------------------------------------------------------------
       
  5690 void CSysApAppUi::ShowShutdownNoteL()
       
  5691     {
       
  5692     TRACES( RDebug::Print( _L( "CSysApAppUi::ShowShutdownNoteL") ) );
       
  5693     ShowUiNoteL( EShutdownNote );
       
  5694     User::After( KTimeToShowShutdownNote );
       
  5695     }
       
  5696 
       
  5697 // ----------------------------------------------------------------------------
       
  5698 // CSysApAppUi::Beep()
       
  5699 // ----------------------------------------------------------------------------
       
  5700 void CSysApAppUi::Beep()
       
  5701     {
       
  5702     static_cast<CAknAppUi*>(iEikonEnv->EikAppUi())->KeySounds()->PlaySound( EAvkonSIDInformationTone );
       
  5703     }
       
  5704 
       
  5705 // ----------------------------------------------------------------------------
       
  5706 // CSysApAppUi::SimSupported()
       
  5707 // ----------------------------------------------------------------------------
       
  5708 TBool CSysApAppUi::SimSupported()
       
  5709     {
       
  5710     return iSysApFeatureManager->SimSupported();
       
  5711     }
       
  5712 
       
  5713 // ----------------------------------------------------------------------------
       
  5714 // CSysApAppUi::IsStateNormal()
       
  5715 //
       
  5716 // ----------------------------------------------------------------------------
       
  5717 TBool CSysApAppUi::IsStateNormal() const
       
  5718     {
       
  5719     TInt state;
       
  5720     TInt errorCode =
       
  5721         RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
       
  5722     if ( errorCode == KErrNone )
       
  5723         {
       
  5724         return state == ESwStateNormalRfOn ||
       
  5725                state == ESwStateNormalRfOff ||
       
  5726                state == ESwStateNormalBTSap;
       
  5727         }
       
  5728     else
       
  5729         {
       
  5730         TRACES( RDebug::Print( _L( "CSysApAppUi::IsStateNormal: Failed to read global system state, error code %d." ), errorCode ) );
       
  5731         return EFalse;
       
  5732         }
       
  5733     }
       
  5734 
       
  5735 // ----------------------------------------------------------------------------
       
  5736 // CSysApAppUi::BatteryEmptyL()
       
  5737 // ----------------------------------------------------------------------------
       
  5738 
       
  5739 void CSysApAppUi::BatteryEmptyL()
       
  5740     {
       
  5741     iSysApLightsController->BatteryEmptyL( ETrue );
       
  5742     // Do not reactivate keyguard in the next startup
       
  5743     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
       
  5744     }
       
  5745 
       
  5746 // ----------------------------------------------------------------------------
       
  5747 // CSysApAppUi::Max()
       
  5748 // ----------------------------------------------------------------------------
       
  5749 
       
  5750 TInt CSysApAppUi::Max( const TInt aA, const TInt aB, const TInt aC )
       
  5751      {
       
  5752      TInt max( aA );
       
  5753      if ( aB > max )
       
  5754          {
       
  5755          max = aB;
       
  5756          }
       
  5757      if ( aC > max )
       
  5758          {
       
  5759          max = aC;
       
  5760          }
       
  5761      return max;
       
  5762      }
       
  5763 
       
  5764 // ----------------------------------------------------------------------------
       
  5765 // CSysApAppUi::SetStarterState()
       
  5766 // ----------------------------------------------------------------------------
       
  5767 
       
  5768 TInt CSysApAppUi::SetStarterState( const RStarterSession::TGlobalState aState )
       
  5769     {
       
  5770     if ( iSysApStartupController->GlobalStateChangeAllowed( aState ) )
       
  5771         {
       
  5772         TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d" ), aState ) );
       
  5773         return StarterSession().SetState( aState );
       
  5774         }
       
  5775     else
       
  5776         {
       
  5777         TRACES( RDebug::Print( _L("CSysApAppUi::SetStarterState: aState=%d - not allowed" ), aState ) );
       
  5778         return KErrNone;
       
  5779         }
       
  5780     }
       
  5781 
       
  5782 // ----------------------------------------------------------------------------
       
  5783 // CSysApAppUi::GetBtSapDeviceNameL()
       
  5784 // ----------------------------------------------------------------------------
       
  5785 
       
  5786 HBufC* CSysApAppUi::GetBtSapDeviceNameL()
       
  5787     {
       
  5788     return iSysApBtSapController->GetBtSapDeviceNameL();
       
  5789     }
       
  5790 
       
  5791 // ----------------------------------------------------------------------------
       
  5792 // CSysApAppUi::ShowAlarmIndicatorL()
       
  5793 // ----------------------------------------------------------------------------
       
  5794 
       
  5795 void CSysApAppUi::ShowAlarmIndicatorL( TBool aShowIndicator )
       
  5796     {
       
  5797     if ( aShowIndicator)
       
  5798         {
       
  5799         SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOn );
       
  5800         }
       
  5801     else
       
  5802         {
       
  5803         SetIndicatorStateL( EAknIndicatorAlarmClock, EAknIndicatorStateOff );
       
  5804         }
       
  5805     }
       
  5806 
       
  5807 // ----------------------------------------------------------------------------
       
  5808 // CSysApAppUi::SimulateFlipKeyEventL()
       
  5809 // ----------------------------------------------------------------------------
       
  5810 
       
  5811 void CSysApAppUi::SimulateFlipKeyEventL( TBool aFlipOpen )
       
  5812     {
       
  5813     TRACES( RDebug::Print( _L("CSysApAppUi::SimulateFlipKeyEventL: aFlipOpen: %d" ), aFlipOpen ) );
       
  5814 
       
  5815     /*
       
  5816        Flip key is constructed when a flip notification via Pub&Sub is received. The reason behind
       
  5817        providing this as a key event is to enable unified handling of keys also with flip, and because
       
  5818        flip is captured&consumed by Avkon it is not possible to capture flip key events directly
       
  5819        from default handler/plugins.
       
  5820     */
       
  5821 
       
  5822     TKeyEvent flipEvent;
       
  5823     flipEvent.iCode = aFlipOpen ? EKeyFlipOpen : EKeyFlipClose;
       
  5824     flipEvent.iScanCode = 0;
       
  5825     flipEvent.iModifiers = 0;
       
  5826 	flipEvent.iRepeats = 0;
       
  5827 
       
  5828     HandleKeyEventL( flipEvent, EEventKey );
       
  5829     }
       
  5830 
       
  5831 // ----------------------------------------------------------------------------
       
  5832 // CSysApAppUi::SetFlipOpenL()
       
  5833 // ----------------------------------------------------------------------------
       
  5834 
       
  5835 void CSysApAppUi::SetFlipOpenL( TBool aFlipOpen )
       
  5836     {
       
  5837     iSysApLightsController->SetFlipOpenL( aFlipOpen );
       
  5838     }
       
  5839 
       
  5840 // ----------------------------------------------------------------------------
       
  5841 // CSysApAppUi::SetGripOpenL()
       
  5842 // ----------------------------------------------------------------------------
       
  5843 void CSysApAppUi::SetGripOpenL( TBool aGripOpen )
       
  5844     {
       
  5845     iSysApLightsController->SetGripOpenL( aGripOpen );
       
  5846     }
       
  5847 
       
  5848 // ----------------------------------------------------------------------------
       
  5849 // CSysApAppUi::SetNetworkConnectionAllowed()
       
  5850 // ----------------------------------------------------------------------------
       
  5851 
       
  5852 void CSysApAppUi::SetNetworkConnectionAllowed( TCoreAppUIsNetworkConnectionAllowed aNetworkConnectionAllowed )
       
  5853     {
       
  5854     TRACES( RDebug::Print( _L("CSysApAppUi::SetNetworkConnectionAllowed: status: %d" ), aNetworkConnectionAllowed ) );
       
  5855 
       
  5856     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIs, KCoreAppUIsNetworkConnectionAllowed, (TInt) aNetworkConnectionAllowed );
       
  5857 
       
  5858     // Also set the Symbian PS key used for the same purpose:
       
  5859     RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid, aNetworkConnectionAllowed ? ESAPhoneOn : ESAPhoneOff);
       
  5860     }
       
  5861 
       
  5862 // ----------------------------------------------------------------------------
       
  5863 // CSysApAppUi::GetTelServerL()
       
  5864 // ----------------------------------------------------------------------------
       
  5865 
       
  5866 RTelServer* CSysApAppUi::GetTelServer()
       
  5867     {
       
  5868     if ( iSysApEtelConnector )
       
  5869         {
       
  5870         return iSysApEtelConnector->GetTelServer();
       
  5871         }
       
  5872     else
       
  5873         {
       
  5874         return NULL;
       
  5875         }
       
  5876     }
       
  5877 
       
  5878 // ----------------------------------------------------------------------------
       
  5879 // CSysApAppUi::CoverDisplaySupported()
       
  5880 // ----------------------------------------------------------------------------
       
  5881 
       
  5882 TBool CSysApAppUi::CoverDisplaySupported()
       
  5883     {
       
  5884     return iSysApFeatureManager->CoverDisplaySupported();
       
  5885     }
       
  5886 
       
  5887 // ----------------------------------------------------------------------------
       
  5888 // CSysApAppUi::StarterSession()
       
  5889 // ----------------------------------------------------------------------------
       
  5890 
       
  5891 RStarterSession& CSysApAppUi::StarterSession()
       
  5892     {
       
  5893     if ( !iStarterSession.Handle() )
       
  5894         {
       
  5895         // All server connections are tried to be made KTriesToConnectServer times because occasional
       
  5896         // fails on connections are possible at least on some servers
       
  5897         TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: trying RStarterSession::Connect()") ) );
       
  5898         TInt thisTry = 0;
       
  5899         TInt err;
       
  5900         while ( ( err = iStarterSession.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
       
  5901             {
       
  5902             User::After( KTimeBeforeRetryingServerConnection );
       
  5903             }
       
  5904 
       
  5905         if ( err != KErrNone )
       
  5906             {
       
  5907             // What do in error case?
       
  5908             TRACES( RDebug::Print( _L("CSysApAppUi::StarterSession: RStarterSession::Connect() failed with %d"), err ) );
       
  5909             }
       
  5910         }
       
  5911 
       
  5912     return iStarterSession;
       
  5913     }
       
  5914 
       
  5915 // ----------------------------------------------------------------------------
       
  5916 // CSysApAppUi::KeyLock()
       
  5917 // ----------------------------------------------------------------------------
       
  5918 
       
  5919 RAknKeylock2& CSysApAppUi::KeyLock()
       
  5920     {
       
  5921     if ( !iKeyLock.Handle() )
       
  5922         {
       
  5923         // All server connections are tried to be made KTriesToConnectServer times because occasional
       
  5924         // fails on connections are possible at least on some servers
       
  5925         TInt thisTry = 0;
       
  5926         TInt err;
       
  5927 
       
  5928         TRACES( RDebug::Print( _L("CSysApAppUi::KeyLock: trying RAknKeylock2::Connect()") ) );
       
  5929         thisTry = 0;
       
  5930         while ( ( err = iKeyLock.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
       
  5931             {
       
  5932             User::After( KTimeBeforeRetryingServerConnection );
       
  5933             }
       
  5934 
       
  5935         if ( err != KErrNone )
       
  5936             {
       
  5937             // What do in error case?
       
  5938             TRACES( RDebug::Print( _L("CSysApAppUi::KeyLock: RAknKeylock2::Connect() failed with %d"), err ) );
       
  5939             }
       
  5940         }
       
  5941 
       
  5942     return iKeyLock;
       
  5943     }
       
  5944 
       
  5945 // ----------------------------------------------------------------------------
       
  5946 // CSysApAppUi::CenRepController()
       
  5947 // ----------------------------------------------------------------------------
       
  5948 
       
  5949 CSysApCenRepController& CSysApAppUi::CenRepController()
       
  5950     {
       
  5951     __ASSERT_ALWAYS( iSysApCenRepController, User::Panic( _L("CSysApAppUi::CenRepController"), KErrBadHandle ) );
       
  5952 
       
  5953     return *iSysApCenRepController;
       
  5954     }
       
  5955 
       
  5956 // ----------------------------------------------------------------------------
       
  5957 // CSysApAppUi::ExecCommandL
       
  5958 // ----------------------------------------------------------------------------
       
  5959 //
       
  5960 void CSysApAppUi::ExecCommandL( TSysapCommand aCommand )
       
  5961     {
       
  5962     ExecCommandL( aCommand, KNullDesC8 );
       
  5963     }
       
  5964 
       
  5965 // ----------------------------------------------------------------------------
       
  5966 // CSysApAppUi::ExecCommandL
       
  5967 // ----------------------------------------------------------------------------
       
  5968 //
       
  5969 void CSysApAppUi::ExecCommandL( TSysapCommand aCommand, const TDesC8& aParam )
       
  5970     {
       
  5971     TRACES( RDebug::Print(_L("CSysApAppUi::ExecCommandL: aCommand=%d"), aCommand ) );
       
  5972 
       
  5973     switch ( aCommand )
       
  5974         {
       
  5975         case EResetKeyguardState: // reset the internal keyguard flags of the SysAp, except for iKeyLockOnBeforeCradle
       
  5976             iKeyLockOnBeforeCall = EFalse;
       
  5977             iKeyLockOnBeforeAlarm = EFalse;
       
  5978             break;
       
  5979 
       
  5980         case ECancelPowermenu: // hide power menu if it is visible
       
  5981             if( iPowerKeyPopupMenuActive )
       
  5982                 {
       
  5983                 CancelGlobalListQuery();
       
  5984                 }
       
  5985             break;
       
  5986 
       
  5987         case EUpdateLights: // apply key specific light handling
       
  5988             {
       
  5989             TUpdateLightsBuf lightBuf;
       
  5990             lightBuf.Copy( aParam );
       
  5991 
       
  5992             switch ( lightBuf() )
       
  5993                 {
       
  5994                 case EKeyGripClose:
       
  5995                     SetGripOpenL( EFalse );
       
  5996                     break;
       
  5997 
       
  5998                 case EKeyGripOpen:
       
  5999                     SetGripOpenL( ETrue );
       
  6000                     break;
       
  6001 
       
  6002                 case EKeyFlipClose:
       
  6003                     SetFlipOpenL( EFalse );
       
  6004                     break;
       
  6005 
       
  6006                 case EKeyFlipOpen:
       
  6007                     SetFlipOpenL( ETrue );
       
  6008                     break;
       
  6009 
       
  6010                 default:
       
  6011                     // No specific light handling for other keys.
       
  6012                     break;
       
  6013                 }
       
  6014             }
       
  6015             break;
       
  6016 
       
  6017         default:
       
  6018             // do nothing in release builds since no harm is done
       
  6019             __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecCommandL: Invalid command"), KErrArgument ) );
       
  6020             break;
       
  6021         }
       
  6022     }
       
  6023 
       
  6024 // ----------------------------------------------------------------------------
       
  6025 // CSysApAppUi::ExecQueryL
       
  6026 // ----------------------------------------------------------------------------
       
  6027 //
       
  6028 void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn )
       
  6029     {
       
  6030     ExecQueryL( aQuery, aReturn, KNullDesC8 );
       
  6031     }
       
  6032 
       
  6033 // ----------------------------------------------------------------------------
       
  6034 // CSysApAppUi::ExecQueryL
       
  6035 // ----------------------------------------------------------------------------
       
  6036 //
       
  6037 void CSysApAppUi::ExecQueryL( TSysapQuery aQuery, TDes8& aReturn, const TDesC8& /*aParam*/ )
       
  6038     {
       
  6039     TRACES( RDebug::Print(_L("CSysApAppUi::ExecQueryL: aQuery=%d"), aQuery ) );
       
  6040 
       
  6041     switch ( aQuery )
       
  6042         {
       
  6043         case EGetHwrmLight: // get handle to HWRM client session. Returns CHWRMLight*.
       
  6044             {
       
  6045             THwrmLightBuf retBuf( iSysApLightsController->GetHwrmLight() );
       
  6046             aReturn.Copy( retBuf );
       
  6047             }
       
  6048             break;
       
  6049 
       
  6050         case EGetKeylock: // get handle to keylock client session. Returns RAknKeylock2*.
       
  6051             {
       
  6052             TKeyLockBuf retBuf( &(KeyLock()) );
       
  6053             aReturn.Copy( retBuf );
       
  6054             }
       
  6055             break;
       
  6056 
       
  6057         default:
       
  6058             __ASSERT_DEBUG( EFalse, User::Panic( _L("CSysApAppUi::ExecQueryL: Invalid query"), KErrArgument ) );
       
  6059             User::Leave( KErrArgument );
       
  6060             break;
       
  6061         }
       
  6062     }
       
  6063 
       
  6064 // ----------------------------------------------------------------------------
       
  6065 // CSysApAppUi::ShowShutdownImage
       
  6066 // ----------------------------------------------------------------------------
       
  6067 //
       
  6068 TInt CSysApAppUi::ShowShutdownImage( TInt aBitmapId )
       
  6069     {
       
  6070     TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImage") ) );
       
  6071 
       
  6072     TRAPD( err, ShowShutdownImageL( aBitmapId ) );
       
  6073 
       
  6074     if ( err != KErrNone )
       
  6075         {
       
  6076         TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL failed, err=%d"), err ) );
       
  6077         }
       
  6078 
       
  6079     return err;
       
  6080     }
       
  6081 
       
  6082 // ----------------------------------------------------------------------------
       
  6083 // CSysApAppUi::ShowShutdownImageL
       
  6084 // ----------------------------------------------------------------------------
       
  6085 //
       
  6086 void CSysApAppUi::ShowShutdownImageL( TInt aBitmapId )
       
  6087     {
       
  6088     TRACES( RDebug::Print(_L("CSysApAppUi::ShowShutdownImageL") ) );
       
  6089 
       
  6090     if ( !iSysApShutdownImage ) // Shutdown image may be shown without entering normal state (e.g. charging), so construct here
       
  6091         {
       
  6092         TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::NewL()") ) );
       
  6093         iSysApShutdownImage = CSysApShutdownImage::NewL();
       
  6094         }
       
  6095 
       
  6096     TRACES( RDebug::Print( _L("CSysApAppUi::ShowShutdownImageL: trying CSysApShutdownImage::ShowShutdownImageL()") ) );
       
  6097     iSysApShutdownImage->ShowShutdownImageL( aBitmapId );
       
  6098     }
       
  6099 
       
  6100 // ----------------------------------------------------------------------------
       
  6101 // CSysApAppUi::IgnoreZeroNetworkBarNotifications
       
  6102 // ----------------------------------------------------------------------------
       
  6103 //
       
  6104 void CSysApAppUi::IgnoreZeroNetworkBarNotifications(TBool aIgnore)
       
  6105     {
       
  6106     iIgnoreZeroNetworkBarNotifications = aIgnore;
       
  6107     }
       
  6108 
       
  6109 // ----------------------------------------------------------------------------
       
  6110 // CSysApAppUi::BtSapEnabled()
       
  6111 // ----------------------------------------------------------------------------
       
  6112 
       
  6113 TBool CSysApAppUi::BtSapEnabled()
       
  6114     {
       
  6115     if ( iSysApBtSapController )
       
  6116         {
       
  6117         return iSysApBtSapController->BtSapEnabled();    
       
  6118         }
       
  6119     
       
  6120     return EFalse;
       
  6121     }
       
  6122 
       
  6123 // ----------------------------------------------------------------------------
       
  6124 // CSysApAppUi::DeactivateBT
       
  6125 // ----------------------------------------------------------------------------
       
  6126 //
       
  6127 void CSysApAppUi::DeactivateBT()
       
  6128     {
       
  6129     // Will deactivate BT when changing to normal mode
       
  6130     iDeactivateBt = ETrue;
       
  6131     }
       
  6132 
  1258 
  6133 // ----------------------------------------------------------------------------
  1259 // ----------------------------------------------------------------------------
  6134 // CSysApAppUi::SetHacIndicatorL()
  1260 // CSysApAppUi::SetHacIndicatorL()
  6135 // ----------------------------------------------------------------------------
  1261 // ----------------------------------------------------------------------------
  6136 void CSysApAppUi::SetHacIndicatorL()
  1262 void CSysApAppUi::SetHacIndicatorL()
  6159                 {
  1285                 {
  6160                 accessoryConnected = ETrue;
  1286                 accessoryConnected = ETrue;
  6161                 }
  1287                 }
  6162             }
  1288             }
  6163 
  1289 
  6164         TInt indicatorState = EAknIndicatorStateOn;
  1290 //        TInt indicatorState = EAknIndicatorStateOn;
  6165 
  1291 
  6166         if ( !accessoryConnected ) // When accessory is not connected, check offline and call state
  1292         if ( !accessoryConnected ) // When accessory is not connected, check offline and call state
  6167             {
  1293             {
  6168             if ( OfflineModeActive() ) // HAC indicator is not shown in offline mode
  1294             if ( OfflineModeActive() ) // HAC indicator is not shown in offline mode
  6169                 {
  1295                 {
  6170                 indicatorState = EAknIndicatorStateOff;
  1296  //               indicatorState = EAknIndicatorStateOff;
  6171                 }
  1297                 }
  6172             else
  1298             else
  6173                 {
  1299                 {
  6174                 // during active call with IHF activated HAC indicator is not shown
  1300                 // during active call with IHF activated HAC indicator is not shown
  6175                 TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
  1301                 TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
  6178                     callState = EPSCTsyCallStateNone;
  1304                     callState = EPSCTsyCallStateNone;
  6179                     }
  1305                     }
  6180 
  1306 
  6181                 if ( callState != EPSCTsyCallStateNone && IhfEnabledL() )
  1307                 if ( callState != EPSCTsyCallStateNone && IhfEnabledL() )
  6182                     {
  1308                     {
  6183                     indicatorState = EAknIndicatorStateOff;
  1309  //                   indicatorState = EAknIndicatorStateOff;
  6184                     }
  1310                     }
  6185                 }
  1311                 }
  6186 
  1312 
  6187             }
  1313             }
  6188         else
  1314         else
  6189             {
  1315             {
  6190             // If an accessory is connected, HAC indicator should not be shown
  1316             // If an accessory is connected, HAC indicator should not be shown
  6191             indicatorState = EAknIndicatorStateOff;
  1317 //            indicatorState = EAknIndicatorStateOff;
  6192             }
  1318             }
  6193 
  1319 
  6194         SetIndicatorStateL( EAknIndicatorHAC, indicatorState );
  1320  //       SetIndicatorStateL( EAknIndicatorHAC, indicatorState );
  6195 
  1321 
  6196         }
  1322         }
  6197     else
  1323     else
  6198         {
  1324         {
  6199         // If HAC is not active, always disable indicator regardless of accessory state
  1325         // If HAC is not active, always disable indicator regardless of accessory state
  6200         SetIndicatorStateL( EAknIndicatorHAC, EAknIndicatorStateOff );
  1326  //       SetIndicatorStateL( EAknIndicatorHAC, EAknIndicatorStateOff );
  6201         }
  1327         }
  6202 
  1328 
  6203 
  1329 
  6204     }
  1330     }
  6205 
  1331 
  6206 // ----------------------------------------------------------------------------
  1332 
  6207 // CSysApAppUi::HandleResourceChangeL()
  1333 // ----------------------------------------------------------------------------
  6208 // ----------------------------------------------------------------------------
  1334 // CSysApAppUi::DoNotActivateBt()
  6209 
  1335 // ----------------------------------------------------------------------------
  6210 void CSysApAppUi::HandleResourceChangeL( TInt aType )
  1336 void CSysApAppUi::DoNotActivateBt()
  6211     {
  1337     {
  6212     TRACES( RDebug::Print( _L("CSysApAppUi::HandleResourceChangeL aType: %d"), aType ) );
  1338     iSysApOfflineModeController->DoNotActivateBt();
  6213     CAknAppUi::HandleResourceChangeL(aType);
  1339     }
  6214 
  1340 
  6215     if ( aType == KEikDynamicLayoutVariantSwitch )
       
  6216         {
       
  6217 #ifdef RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  6218         iSysApShutdownImage->SetRect( ApplicationRect() );
       
  6219 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
       
  6220 
       
  6221         TInt mode;
       
  6222         User::LeaveIfError( RProperty::Get( KPSUidStartup, KPSGlobalStartupMode, mode ) );
       
  6223 
       
  6224         if ( mode == EStartupModeAlarm )
       
  6225             {
       
  6226             SetStatusPaneLayoutL( ESysApAlarm );
       
  6227             }
       
  6228         }
       
  6229     }
       
  6230 
       
  6231 // ----------------------------------------------------------------------------
       
  6232 // CSysApAppUi::SetMemoryCardIndicatorL
       
  6233 // ----------------------------------------------------------------------------
       
  6234 
       
  6235 void CSysApAppUi::SetMemoryCardIndicatorL()
       
  6236     {
       
  6237     if ( iSysApFeatureManager->Supported( KSysApFeatureIdMemoryCardIcon ) )
       
  6238         {
       
  6239 #ifndef RD_MULTIPLE_DRIVE
       
  6240         TSysApMemoryCardStatus memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
       
  6241 
       
  6242         TRACES( RDebug::Print( _L("CSysApAppUi::SetMemoryCardIndicatorL: memoryCardStatus=%d"), memoryCardStatus ) );
       
  6243 
       
  6244         if ( memoryCardStatus == ESysApMemoryCardInserted || memoryCardStatus == ESysApMemoryCardLocked )
       
  6245 #else // RD_MULTIPLE_DRIVE
       
  6246         TInt insertedCount( CSysApDriveList::NonUsbDriveCount( iInsertedMemoryCards ) );
       
  6247 
       
  6248         TRACES( RDebug::Print( _L("CSysApAppUi::SetMemoryCardIndicatorL: insertedCount=%d"), insertedCount ) );
       
  6249 
       
  6250         if ( insertedCount > 0 )
       
  6251 #endif // RD_MULTIPLE_DRIVE
       
  6252             {
       
  6253             SetIndicatorStateL( EAknIndicatorMemoryCard, EAknIndicatorStateOn );
       
  6254             }
       
  6255         else
       
  6256             {
       
  6257             SetIndicatorStateL( EAknIndicatorMemoryCard, EAknIndicatorStateOff );
       
  6258             }
       
  6259         }
       
  6260     }
       
  6261 
       
  6262 // ----------------------------------------------------------------------------
       
  6263 // CSysApAppUi::SysApFeatureManager
       
  6264 // ----------------------------------------------------------------------------
       
  6265 
       
  6266 CSysApFeatureManager& CSysApAppUi::SysApFeatureManager()
       
  6267     {
       
  6268     __ASSERT_DEBUG( iSysApFeatureManager, User::Panic( _L("iSysApFeatureManager == NULL"), KErrBadHandle ) );
       
  6269 
       
  6270     return *iSysApFeatureManager;
       
  6271     }
       
  6272 
       
  6273 // ----------------------------------------------------------------------------
       
  6274 // CSysApAppUi::SetUsbAttachStatus
       
  6275 // ----------------------------------------------------------------------------
       
  6276 #ifndef RD_MULTIPLE_DRIVE
       
  6277 void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
       
  6278     {
       
  6279     // Prevent double beep when USB file transfer gets activated but
       
  6280     // allow MMC inserted beep when:
       
  6281     // a) USB file transfer is active
       
  6282     // b) MMC is not inserted when USB cable is attached
       
  6283     iHideNextBeep = ( iMMCInserted && aUsbAttached );
       
  6284     }
       
  6285 #else // RD_MULTIPLE_DRIVE
       
  6286 void CSysApAppUi::SetUsbAttachStatus( const TBool aUsbAttached )
       
  6287     {
       
  6288     TRACES( RDebug::Print(
       
  6289         _L( "CSysApAppUi::SetUsbAttachStatus: aUsbAttached: %d" ),
       
  6290         aUsbAttached ) );
       
  6291 
       
  6292     if ( aUsbAttached )
       
  6293         {
       
  6294         // For ignoring extra beeps caused by USB file transfer
       
  6295         iSysApDriveList->ResetDrivesInsertBeepIgnored();
       
  6296         iSysApDriveList->MarkDrivesInsertBeepIgnored( iInsertedMemoryCards );
       
  6297         }
       
  6298     }
       
  6299 #endif // RD_MULTIPLE_DRIVE
       
  6300 
  1341 
  6301 // ----------------------------------------------------------------------------
  1342 // ----------------------------------------------------------------------------
  6302 // CSysApAppUi::IhfEnabledL
  1343 // CSysApAppUi::IhfEnabledL
  6303 // ----------------------------------------------------------------------------
  1344 // ----------------------------------------------------------------------------
  6304 
  1345 
  6312         }
  1353         }
  6313 
  1354 
  6314     return iSysApAudioRoutingObserver->IhfEnabled();
  1355     return iSysApAudioRoutingObserver->IhfEnabled();
  6315     }
  1356     }
  6316 
  1357 
  6317 // ----------------------------------------------------------------------------
  1358 
  6318 // CSysApAppUi::IsDeviceModeKey
  1359 // ----------------------------------------------------------------------------
  6319 // ----------------------------------------------------------------------------
  1360 // CSysApAppUi::SetIhfIndicatorL()
  6320 
  1361 // ----------------------------------------------------------------------------
  6321 TBool CSysApAppUi::IsDeviceModeKey( const TKeyEvent& aKeyEvent ) const
  1362 void CSysApAppUi::SetIhfIndicatorL()
  6322     {
  1363     {
  6323     return CSysApDefaultKeyHandler::IsDeviceModeKey( aKeyEvent );
  1364     TBool accessoryConnected ( EFalse );
  6324     }
  1365 
  6325 
  1366     TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
  6326 // ----------------------------------------------------------------------------
  1367 
  6327 // CSysApAppUi::ResourcesFreed
  1368     TAccMode accMode(EAccModeHandPortable);
  6328 // ----------------------------------------------------------------------------
  1369 
  6329 
  1370     if ( iSysApAccessoryObserver )
  6330 TBool CSysApAppUi::ResourcesFreed() const
  1371         {
  6331     {
  1372         accMode = iSysApAccessoryObserver->GetAccessoryMode();
  6332     return iResourcesFreed;
  1373 
  6333     }
  1374         if ( accMode != EAccModeHandPortable )
  6334 
  1375             {
  6335 /* 
  1376             accessoryConnected = ETrue;
  6336 ----------------------------------------------------------------------------
  1377             }
  6337 CSysApAppUi::IsEncryptionOperationOngoingL()
  1378         }
  6338 Introduced the code as a part of Sub : 405-3362 - Power Management SUB for ES 
  1379 
  6339 recapture functionalities in platform which support multidrive as well. 
  1380     if( (callState != EPSCTsyCallStateNone && IhfEnabledL() && !accessoryConnected)
  6340 -------------------------------------------------------------------------------
  1381         || accMode == EAccModeMusicStand )  // Music stand always shows IHF indicator
  6341 */
  1382         {
  6342 TBool CSysApAppUi::IsEncryptionOperationOngoingL() const
  1383         if ( accMode == EAccModeMusicStand )
  6343     {
  1384             {
  6344 		TBool deFeatureSupported(EFalse);
  1385             // do nothing
  6345 		FeatureManager::InitializeLibL();
  1386             }
  6346 		deFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdFfDeviceEncryptionFeature);
  1387         }
  6347 		FeatureManager::UnInitializeLib();
  1388     else
  6348 
  1389         {
  6349 		if(deFeatureSupported)
  1390         // do nothing
  6350 			{         
  1391         }
  6351 			/**
  1392     }
  6352 			 * Store the last memory status changed
  1393 
  6353 			 * 0: Idle. It can be Encrypted or Decrypted
  1394 // ----------------------------------------------------------------------------
  6354 			 * 1: Encrypting
  1395 // CSysApAppUi::DoLightsTimeoutChangedL
  6355 			 * 2: Decrypting
  1396 // ----------------------------------------------------------------------------
  6356 			 **/
  1397 void CSysApAppUi::DoLightsTimeoutChangedL( const TInt aTimeout )
  6357 			 
  1398     {
  6358 			RProperty deProperty;
  1399     iSysApLightsController->DoLightsTimeoutChangedL( aTimeout );
  6359 			User::LeaveIfError(deProperty.Attach(KDevEncProtectedUid, KDevEncOperationKey,EOwnerThread));
  1400     }
  6360 			TInt deValue = 0;
  1401 
  6361 			if((deProperty.Get(deValue)== KErrNone)&&( deValue == EOpEncrypting || deValue == EOpDecrypting))
  1402 
  6362 				{
  1403 // ----------------------------------------------------------------------------
  6363 				deProperty.Close();
  1404 // CSysApAppUi::DoSwStateNormalConstructionL()
  6364 				return ETrue;
  1405 // ----------------------------------------------------------------------------
  6365 				}
  1406 
  6366 			else
  1407 void CSysApAppUi::DoSwStateNormalConstructionL()
  6367 				{
  1408     {
  6368 				deProperty.Close();
  1409     // Let's ensure that the lights will remain on for 15 secs after sw state normal
  6369 				return EFalse;
  1410     User::ResetInactivityTime();
  6370 				}
  1411 
  6371 			}
  1412     TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : START" ) ) );
  6372 		else
  1413 
  6373 			{
  1414     // In case of unexpected reset (e.g. hidden boot) the keylock must be enabled silently. Locking is done
  6374 			return EFalse;
  1415     // prior to time-consuming initializations, because otherwise UI is in unlocked state for a few seconds.
  6375 			}
  1416     if ( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive ) == 1  )
  6376     }
  1417         {
  6377 // ----------------------------------------------------------------------------
  1418         TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL: enabling keylock") ) );
  6378 // CSysApAppUi::EtelConnector
  1419         iKeyguardController->EnableKeyguard(ETrue);
  6379 // ----------------------------------------------------------------------------
  1420         }
  6380 
  1421 
  6381 CSysApEtelConnector* CSysApAppUi::EtelConnector() const
  1422     // Initiate bearer change observation
  6382     {
  1423 //    iSysApConnectionMonitorObserver = CSysApConnectionMonitorObserver::NewL( *this );
  6383     return iSysApEtelConnector;
  1424 
  6384     }
  1425     TRACES( RDebug::Print( _L("SysAp: trying CSystemLock::NewL" ) ) );
  6385 
  1426     iSysApSystemLock = CSystemLock::NewL();
  6386 #ifndef RD_MULTIPLE_DRIVE
  1427 
  6387 
  1428     
  6388 // ----------------------------------------------------------------------------
  1429     if ( iSysApFeatureManager->Supported( KSysApFeatureIdBatteryInfoPopup ) )
  6389 // CSysApAppUi::EjectUsed
  1430         {
  6390 // ----------------------------------------------------------------------------
  1431         iSysApBatteryInfoController = CSysApBatteryInfoController::NewL( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsConf, 
  6391 
  1432                                                                                                      KCoreAppUIsBatteryInformationLowThreshold ) );    
  6392 void CSysApAppUi::EjectUsed( TInt /*aDrive*/ )
  1433         }
  6393     {
  1434     TRACES( RDebug::Print( _L("CSysApAppUi::DoSwStateNormalConstructionL : END" ) ) );
  6394     }
  1435     }
  6395 
  1436 
  6396 #else // RD_MULTIPLE_DRIVE
  1437 
  6397 
  1438 
  6398 // ----------------------------------------------------------------------------
  1439 // ----------------------------------------------------------------------------
  6399 // CSysApAppUi::ShowEjectWaitNoteL
  1440 // CSysApAppUi::DoSimChangedFromPreviousBootL()
  6400 // ----------------------------------------------------------------------------
  1441 // ----------------------------------------------------------------------------
  6401 
  1442 
  6402 void CSysApAppUi::ShowEjectWaitNoteL( TInt aDriveToEject )
  1443 void CSysApAppUi::DoSimChangedFromPreviousBootL()
  6403     {
  1444     {
  6404     if ( iSysApWaitNote )
  1445     TRACES( RDebug::Print( _L("CSysApAppUi::DoSimChangedFromPreviousBootL: iSimChangedDone=%d" ), iSimChangedDone ) );
  6405         {
  1446 
  6406         return;
  1447     if ( !iSimChangedDone  )
  6407         }
  1448         {
  6408     HBufC* text = iSysApDriveList->GetFormattedDriveNameLC(
  1449         iSimChangedDone = ETrue;
  6409         aDriveToEject,
  1450         CSysApSimChanged* simChanged = CSysApSimChanged::NewL( *this, iEikonEnv->FsSession() );
  6410         0, // Not used
  1451         CleanupStack::PushL( simChanged );
  6411         R_QTN_EJECTING_MEMORY_NAME_WAIT );
  1452         simChanged->HandleSimChangedL();
  6412     iSysApWaitNote = CSysApWaitNote::NewL(
  1453         CleanupStack::PopAndDestroy( simChanged );
  6413         iSysApFeatureManager->CoverDisplaySupported() );
  1454         }
  6414     iSysApWaitNote->ShowNoteL( EClosingApplicationsNote, text );
  1455     }
  6415     CleanupStack::PopAndDestroy( text );
  1456 
  6416     }
  1457 
  6417 
  1458 // ----------------------------------------------------------------------------
  6418 // ----------------------------------------------------------------------------
  1459 // CSysApAppUi::IgnoreZeroNetworkBarNotifications
  6419 // CSysApAppUi::IsEjectQueryVisible
       
  6420 // ----------------------------------------------------------------------------
       
  6421 
       
  6422 TBool CSysApAppUi::IsEjectQueryVisible()
       
  6423     {
       
  6424     if ( !iSysApConfirmationQuery )
       
  6425         {
       
  6426         return EFalse;
       
  6427         }
       
  6428     TInt queryId( iSysApConfirmationQuery->CurrentQuery() );
       
  6429     return ( queryId == ESysApEjectMmcQuery || queryId == ESysApRemoveMmcNote );
       
  6430     }
       
  6431 
       
  6432 // ----------------------------------------------------------------------------
       
  6433 // CSysApAppUi::UpdateInsertedMemoryCardsL
       
  6434 // ----------------------------------------------------------------------------
       
  6435 
       
  6436 void CSysApAppUi::UpdateInsertedMemoryCardsL()
       
  6437     {
       
  6438     // Update inserted memory cards
       
  6439     iSysApDriveList->GetMemoryCardsL(
       
  6440         iInsertedMemoryCards, CSysApDriveList::EIncludeInserted );
       
  6441 
       
  6442     // Update memory card indicator status
       
  6443     SetMemoryCardIndicatorL();
       
  6444 
       
  6445     // Handle unlock
       
  6446     RunUnlockNotifierL();
       
  6447     }
       
  6448 
       
  6449 // ----------------------------------------------------------------------------
       
  6450 // CSysApAppUi::EjectUsed
       
  6451 // ----------------------------------------------------------------------------
       
  6452 
       
  6453 void CSysApAppUi::EjectUsed( TInt aDrive )
       
  6454     {
       
  6455     // Check drive inserted before starting eject confirm query
       
  6456     TInt insertedIndex( CSysApDriveList::Find( iInsertedMemoryCards, aDrive ) );
       
  6457 
       
  6458     TRACES( RDebug::Print(
       
  6459         _L( "CSysApAppUi::EjectUsed: drive: %d, index: %d" ),
       
  6460         aDrive, insertedIndex ) );
       
  6461 
       
  6462     if ( insertedIndex == KErrNotFound )
       
  6463         {
       
  6464         return;
       
  6465         }
       
  6466 
       
  6467     iMMCEjectUsed = ETrue;
       
  6468     iDriveToEject = aDrive;
       
  6469     iSysApDriveList->ResetDrivesToEject();
       
  6470     TRAPD( err, EjectMMCL() );
       
  6471     if ( err != KErrNone )
       
  6472         {
       
  6473         TRACES( RDebug::Print(
       
  6474             _L( "CSysApAppUi::EjectUsed: err: %d" ), err ) );
       
  6475         iMMCEjectUsed = EFalse;
       
  6476         }
       
  6477     }
       
  6478 
       
  6479 #endif // RD_MULTIPLE_DRIVE
       
  6480 
       
  6481 // ----------------------------------------------------------------------------
       
  6482 // CSysApAppUi::EjectMMCCanceled
       
  6483 // ----------------------------------------------------------------------------
       
  6484 
       
  6485 void CSysApAppUi::EjectMMCCanceled()
       
  6486     {
       
  6487     // Called from eject confirm query, reset eject status
       
  6488 #ifdef RD_MULTIPLE_DRIVE
       
  6489     iMMCEjectUsed = EFalse;
       
  6490 #endif // RD_MULTIPLE_DRIVE
       
  6491     }
       
  6492 
       
  6493 // ----------------------------------------------------------------------------
       
  6494 // CSysApAppUi::UsbChargerDetector
       
  6495 // ----------------------------------------------------------------------------
  1460 // ----------------------------------------------------------------------------
  6496 //
  1461 //
  6497 TSysApUsbChargerDetector& CSysApAppUi::UsbChargerDetector()
  1462 void CSysApAppUi::IgnoreZeroNetworkBarNotifications(TBool aIgnore)
  6498     {
  1463     {
  6499     return iSysApUsbChargerDetector;
  1464     iIgnoreZeroNetworkBarNotifications = aIgnore;
  6500     }
  1465     }
  6501 
  1466 
  6502 // ----------------------------------------------------------------------------
  1467 
  6503 // CSysApAppUi::HandleUsbCharger
  1468 
  6504 // ----------------------------------------------------------------------------
  1469 // ----------------------------------------------------------------------------
  6505 //
  1470 // CSysApAppUi::SwitchFromOnlineToOfflineModeL()
  6506 void CSysApAppUi::HandleUsbCharger( const TInt aValue )
  1471 // ----------------------------------------------------------------------------
  6507     {        
  1472 void CSysApAppUi::SwitchFromOnlineToOfflineModeL()
  6508     if ( aValue == EChargingStatusCharging ||
  1473     {
  6509          aValue == EChargingStatusChargingContinued ||
  1474    iSysApOfflineModeController->SwitchFromOnlineToOfflineModeL();
  6510          aValue == EChargingStatusAlmostComplete )
  1475     }
  6511         {
  1476 
  6512         iSysApUsbChargerDetector.SetChargingUsed( ETrue );
  1477 
  6513         if ( !iSysApUsbIndicatorController &&
  1478 // ----------------------------------------------------------------------------
  6514              iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) &&
  1479 // CSysApAppUi::InitCloseSimApplicationsL()
  6515              iSysApFeatureManager->Supported( KSysApFeatureIdUsbChargingWithoutReminderNotes ) )
  1480 // ----------------------------------------------------------------------------
  6516             {
  1481 void CSysApAppUi::InitCloseSimApplicationsL()
  6517             // Start observing USB state for the reminder note
  1482     {
  6518             TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
  1483     iApplicationScanningRoundNumberInBtSap = 0;
  6519             if ( usbErr )
  1484     iTimeToKillInBtSap = EFalse;
  6520                 {
  1485     CloseSimApplicationsL();
  6521                 TRACES( RDebug::Print(
  1486     }
  6522                     _L("CSysApAppUi::HandleUsbCharger: error in constructing USB ind. controller %d" ),
  1487 
  6523                     usbErr ) );
  1488 
  6524                 }
  1489 // ----------------------------------------------------------------------------
  6525             }
  1490 // CSysApAppUi::CloseSimApplicationsL()
  6526         }
  1491 // ----------------------------------------------------------------------------
  6527     }
  1492 void CSysApAppUi::CloseSimApplicationsL()
  6528 
  1493     {
  6529 // ----------------------------------------------------------------------------
  1494     iApplicationScanningRoundNumberInBtSap++;
  6530 // CSysApAppUi::SetEnvelopeIndicatorL
  1495     TRACES( RDebug::Print( _L("CSysApAppUi::CloseSimApplicationsL: scanning round = %d"),
  6531 // ----------------------------------------------------------------------------
  1496                            iApplicationScanningRoundNumberInBtSap ) );
  6532 //
  1497 
  6533 void CSysApAppUi::SetEnvelopeIndicatorL()
  1498     if ( iApplicationScanningRoundNumberInBtSap == KMaxExitTimeInBtSap )
  6534     {
  1499         {
  6535     TInt phoneStoreStatus( StateOfProperty( KUidPSSMSStackCategory, KUidPSSMSStackDiskSpaceMonitorKey ) );
  1500         iTimeToKillInBtSap = ETrue;
  6536     TInt inboxStatus( StateOfProperty( KUidSystemCategory, KUidInboxStatusValue ) );
  1501         }
  6537     TBool simStoreFull( iSysApEtelConnector && iSysApEtelConnector->IsSimSmsStoreFull() );
  1502 
  6538 
  1503     const TInt KNumberOfSimDependantApps( 7 );
  6539     TRACES( RDebug::Print(
  1504     TUid simDependantAppUid[ KNumberOfSimDependantApps ];
  6540         _L("CSysApAppUi::SetEnvelopeIndicatorL() phoneStoreStatus %d, simStoreFull %d, inboxStatus %d"),
  1505     simDependantAppUid[ 0 ] = KSysApGSUid;
  6541         phoneStoreStatus, simStoreFull, inboxStatus ) );
  1506     simDependantAppUid[ 1 ] = KSysApSATUid;
  6542 
  1507     simDependantAppUid[ 2 ] = KSysApMailboxUid;
  6543     if ( phoneStoreStatus == ESmsDiskSpaceFull || simStoreFull )
  1508     simDependantAppUid[ 3 ] = KSysApSpeedDialingUid;
  6544         {
  1509     simDependantAppUid[ 4 ] = KSysApSimDirectoryUid;
  6545         // Blink the Envelope indicator
  1510     simDependantAppUid[ 5 ] = KSysApMCEUid;
  6546         SetIndicatorStateL( EAknIndicatorEnvelope, EAknIndicatorStateAnimate );
  1511     simDependantAppUid[ 6 ] = KSysApCellBroadcastMessagesUid;
  6547         }
  1512 
  6548     else if ( inboxStatus == ESADocumentsInInbox )
  1513     TBool appsExiting( EFalse );
  6549         {
  1514     TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
  6550         // Show the Envelope indicator.
  1515 
  6551         SetIndicatorStateL( EAknIndicatorEnvelope, EAknIndicatorStateOn );
  1516     for ( TInt i = 0; i < KNumberOfSimDependantApps; i++ )
       
  1517         {
       
  1518         TApaTask apaTask = apaTaskList.FindApp( simDependantAppUid[ i ] );
       
  1519         if ( apaTask.Exists() )
       
  1520             {
       
  1521             appsExiting = ETrue;
       
  1522             if ( iApplicationScanningRoundNumberInBtSap == 1 )
       
  1523                 {
       
  1524                 apaTask.EndTask();  // applications are kindly requested to close themselves on the first round
       
  1525                 }
       
  1526             else if ( iTimeToKillInBtSap )
       
  1527                 {
       
  1528                 apaTask.KillTask(); // used after timeout on the last round
       
  1529                 }
       
  1530             }
       
  1531         }
       
  1532 
       
  1533     if ( !appsExiting || iTimeToKillInBtSap )
       
  1534         {
       
  1535         iSysApBtSapController->SimApplicationsClosed();
  6552         }
  1536         }
  6553     else
  1537     else
  6554         {
  1538         {
  6555         // Hide the Envelope indicator.
  1539         if ( !iSapTimer )
  6556         SetIndicatorStateL( EAknIndicatorEnvelope, EAknIndicatorStateOff );
  1540             {
  6557         }
  1541             iSapTimer = CPeriodic::NewL( EPriorityNormal );
  6558     }
  1542             }
  6559     
  1543         iSapTimer->Cancel();
  6560 // ----------------------------------------------------------------------------
  1544         iSapTimer->Start( KDelayBeforeNextScanningRound,
  6561 // CSysApAppUi::LogsObserverL
  1545                           KDelayBeforeNextScanningRound,
  6562 // ----------------------------------------------------------------------------
  1546                           TCallBack( DoCloseSimApplicationsAfterCallBack, this ) );
  6563 //
  1547         }
  6564 CSysApCenRepLogsObserver& CSysApAppUi::LogsObserverL()
  1548     }
  6565     {
  1549 
  6566     TRACES( RDebug::Print( _L("CSysApAppUi::LogsObserverL()") ) );
  1550 
  6567     
  1551 // ----------------------------------------------------------------------------
  6568     // Create Logs observer when it is needed for the first time
  1552 // CSysApAppUi::DoCloseSimApplicationsAfterCallBack
  6569     if ( !iSysApCenRepLogsObserver )
  1553 // ----------------------------------------------------------------------------
  6570         {
  1554 TInt CSysApAppUi::DoCloseSimApplicationsAfterCallBack( TAny* aObject )
  6571         iSysApCenRepLogsObserver = CSysApCenRepLogsObserver::NewL( *this );
  1555     {
  6572         }
  1556     CSysApAppUi* appUi = STATIC_CAST( CSysApAppUi*, aObject );
  6573     
  1557 
  6574     return *iSysApCenRepLogsObserver;
  1558     if ( appUi->iSapTimer )
  6575     }
  1559         {
  6576     
  1560         appUi->iSapTimer->Cancel();
       
  1561         }
       
  1562 
       
  1563     TRAP_IGNORE( appUi->CloseSimApplicationsL() );
       
  1564 
       
  1565     return KErrNone;
       
  1566     }
       
  1567 
       
  1568 
  6577 // ----------------------------------------------------------------------------
  1569 // ----------------------------------------------------------------------------
  6578 // CSysApAppUi::NotifyPowerSaveModeL
  1570 // CSysApAppUi::NotifyPowerSaveModeL
  6579 // ----------------------------------------------------------------------------
  1571 // ----------------------------------------------------------------------------
  6580 //
  1572 //
  6581 void CSysApAppUi::NotifyPowerSaveModeL( TSysApPsmStatus aStatus )
  1573 void CSysApAppUi::NotifyPowerSaveModeL( TSysApPsmStatus aStatus )
  6582     {
  1574     {
  6583     TRACES( RDebug::Print( _L("CSysApAppUi::NotifyPowerSaveModeL aStatus: %d"), aStatus ) );
  1575     TRACES( RDebug::Print( _L("CSysApAppUi::NotifyPowerSaveModeL aStatus: %d"), aStatus ) );
  6584 
  1576 
  6585     // cancel any active power saving query because user has changed the state manually
  1577     // cancel any active power saving query because user has changed the state manually
  6586     CancelQuery( ESysApBattChargingPowerSavingQuery );
  1578     // CancelQuery( ESysApBattChargingPowerSavingQuery );
  6587     CancelQuery( ESysApBattLowPowerSavingQuery );
  1579     // CancelQuery( ESysApBattLowPowerSavingQuery );
       
  1580     // will take care in next sub
  6588     
  1581     
  6589     switch ( aStatus )
  1582     switch ( aStatus )
  6590         {
  1583         {
  6591         case MSysApPsmControllerNotifyCallback::EPsmActivationComplete:
  1584         case MSysApPsmControllerNotifyCallback::EPsmActivationComplete:
  6592             UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
  1585             UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
  6609         default:
  1602         default:
  6610             break;   
  1603             break;   
  6611         }
  1604         }
  6612     }
  1605     }
  6613 
  1606 
       
  1607 
       
  1608 // ----------------------------------------------------------------------------
       
  1609 // CSysApAppUi::ShowAlarmIndicatorL()
       
  1610 // ----------------------------------------------------------------------------
       
  1611 
       
  1612 void CSysApAppUi::ShowAlarmIndicatorL( TBool aShowIndicator )
       
  1613     {
       
  1614     if ( aShowIndicator)
       
  1615         {
       
  1616         // do nothing
       
  1617         }
       
  1618     else
       
  1619         {
       
  1620         // do nothing
       
  1621         }
       
  1622     }
       
  1623 
       
  1624 
       
  1625 // ----------------------------------------------------------------------------
       
  1626 // CSysApAppUi::AlertUiAlertingL( const TBool aAlerting )
       
  1627 // ----------------------------------------------------------------------------
       
  1628 void CSysApAppUi::AlertUiAlertingL( const TBool aAlerting )
       
  1629     {
       
  1630     TRACES( RDebug::Print( _L("CSysApAppUi::AlertUiAlerting aAlerting:%d"), aAlerting ) );
       
  1631 
       
  1632     if ( aAlerting )
       
  1633         {
       
  1634         TInt swState;
       
  1635         RProperty::Get( KPSUidStartup, KPSGlobalSystemState, swState );
       
  1636 
       
  1637         if( swState == ESwStateCharging )
       
  1638             {
       
  1639             SetStarterState( RStarterSession::EAlarm );
       
  1640             }
       
  1641         }
       
  1642 
       
  1643     iSysApLightsController->AlarmOccuredL( aAlerting );
       
  1644     }
       
  1645 
       
  1646 
       
  1647 // ----------------------------------------------------------------------------
       
  1648 // CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightParameter )
       
  1649 // ----------------------------------------------------------------------------
       
  1650 
       
  1651 void CSysApAppUi::HandleForcedLightsVTRequireL( const TInt aLightsParameter ) const
       
  1652     {
       
  1653     iSysApLightsController->HandleForcedLightsVTRequireL( aLightsParameter );
       
  1654     }
       
  1655 
       
  1656 
       
  1657 // ----------------------------------------------------------------------------
       
  1658 // CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightParameter )
       
  1659 // ----------------------------------------------------------------------------
       
  1660 
       
  1661 void CSysApAppUi::HandleForcedLightsSSRequireL( const TInt aLightsParameter ) const
       
  1662     {
       
  1663     iSysApLightsController->HandleForcedLightsSSRequireL( aLightsParameter );
       
  1664     }
       
  1665 
       
  1666 // ---------------------------------------------------------------------------- 
       
  1667 // CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightParameter ) 
       
  1668 // ---------------------------------------------------------------------------- 
       
  1669 void CSysApAppUi::HandleForcedLightsATCRequireL( const TInt aLightsParameter ) const 
       
  1670     { 
       
  1671     iSysApLightsController->HandleForcedLightsATCRequireL( aLightsParameter ); 
       
  1672     } 
       
  1673 
       
  1674 
       
  1675 // ----------------------------------------------------------------------------
       
  1676 // CSysApAppUi::HandleLightsRequireL()
       
  1677 // ----------------------------------------------------------------------------
       
  1678 
       
  1679 void CSysApAppUi::HandleLightsRequireL() const
       
  1680     {
       
  1681     iSysApLightsController->HandleLightsRequireL();
       
  1682     }
       
  1683 
       
  1684 
       
  1685 // ----------------------------------------------------------------------------
       
  1686 // CSysApAppUi::AlertUiKeyLockOff( const TBool aKeyLockOff )
       
  1687 // ----------------------------------------------------------------------------
       
  1688 
       
  1689 void CSysApAppUi::AlertUiKeyLockOff( const TBool aKeyLockOff )
       
  1690     {
       
  1691     TRACES( RDebug::Print( _L("CSysApAppUi::AlertUiKeyLockOff aKeyLockOff:%d, devicelock:%d"), 
       
  1692         aKeyLockOff, iDeviceLockEnabled ) );
       
  1693     
       
  1694     if( aKeyLockOff )
       
  1695         {
       
  1696         // Notification to release keypad might come several times if e.g. calls are received
       
  1697         if ( !iKeyLockOnBeforeAlarm )
       
  1698             {
       
  1699             if ( iKeyLockEnabled || iKeyLockOnBeforeCradle || iKeyLockOnBeforeCall )
       
  1700                 {
       
  1701                 iKeyLockOnBeforeAlarm = ETrue;
       
  1702                 }
       
  1703             }
       
  1704         iKeyguardController->DisableKeyguard(EFalse);
       
  1705         }
       
  1706     else
       
  1707         {
       
  1708         if (iDeviceLockEnabled)
       
  1709             {
       
  1710             // Re-enable keylock in devicelock case only if phone call is not ongoing or is 
       
  1711             // connected. Otherwise e.g. messages can be read using softkeys during ongoing call.
       
  1712             TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  1713             if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateConnected )
       
  1714                 {
       
  1715                 iKeyguardController->EnableKeyguard(EFalse);
       
  1716                 }
       
  1717             }
       
  1718         else if ( iKeyLockOnBeforeAlarm && !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeCall )
       
  1719             {
       
  1720             iKeyguardController->EnableKeyguard(ETrue);
       
  1721             }
       
  1722         iKeyLockOnBeforeAlarm = EFalse;
       
  1723         }
       
  1724     }
       
  1725 
       
  1726 
       
  1727 // ----------------------------------------------------------------------------
       
  1728 // CSysApAppUi::DoNotEnableKeylock()
       
  1729 // ----------------------------------------------------------------------------
       
  1730 
       
  1731 void CSysApAppUi::DoNotEnableKeylock()
       
  1732     {
       
  1733     if ( !iKeyLockOnBeforeCradle )
       
  1734         {
       
  1735         iShowkeypadActivatedNoteAfterSoftReject = iKeyLockOnBeforeCall;
       
  1736         }
       
  1737 
       
  1738     iKeyLockOnBeforeCall = EFalse;
       
  1739     }
       
  1740 
       
  1741 
       
  1742 // ----------------------------------------------------------------------------
       
  1743 // CSysApAppUi::SwitchLightsOnSoftRejectL()
       
  1744 // ----------------------------------------------------------------------------
       
  1745 void CSysApAppUi::SwitchLightsOnSoftRejectL()
       
  1746     {
       
  1747     iSysApLightsController->SwitchLightsOnSoftRejectL();
       
  1748     }
       
  1749 
       
  1750 
       
  1751 // ----------------------------------------------------------------------------
       
  1752 // CSysApAppUi::SetDeviceLockEnabledL( const TBool aLockEnabled )
       
  1753 // ----------------------------------------------------------------------------
       
  1754 
       
  1755 void CSysApAppUi::SetDeviceLockEnabledL( const TBool aLockEnabled )
       
  1756     {
       
  1757     TRACES( RDebug::Print(_L("CSysApAppUi::SetDeviceLockEnabledL aLockEnabled:%d" ), aLockEnabled ) );
       
  1758     TBool currentState( iDeviceLockEnabled );
       
  1759     
       
  1760     iDeviceLockEnabled = aLockEnabled;
       
  1761     
       
  1762     if ( currentState != iDeviceLockEnabled ) // filter out unnecessary light status modifications
       
  1763         {
       
  1764         iSysApLightsController->DeviceLockStateChangedL( iDeviceLockEnabled );
       
  1765         }
       
  1766     
       
  1767     if( iDeviceLockEnabled )
       
  1768         {
       
  1769         if( iKeyLockEnabled )
       
  1770             {
       
  1771             iKeyguardController->DisableKeyguard(EFalse);
       
  1772             }
       
  1773         }
       
  1774     else
       
  1775         {
       
  1776         // let's not activate keylock in case device lock was disabled during call or in cradle
       
  1777         iKeyLockOnBeforeCall = EFalse;
       
  1778         iKeyLockOnBeforeCradle = EFalse;
       
  1779 
       
  1780         // Memory card needs to be unlocked when device is unlocked
       
  1781         if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
  1782             {
       
  1783             // RunUnlockNotifierL();
       
  1784             // Need to handle feature for unlocking the MMC card
       
  1785             }
       
  1786         }
       
  1787     }
       
  1788 
       
  1789 
  6614 // ----------------------------------------------------------------------------
  1790 // ----------------------------------------------------------------------------
  6615 // CSysApAppUi::HandleBatteryStatusL
  1791 // CSysApAppUi::HandleBatteryStatusL
  6616 // ----------------------------------------------------------------------------
  1792 // ----------------------------------------------------------------------------
  6617 //
  1793 //
  6618 void CSysApAppUi::HandleBatteryStatusL( const TInt aValue )
  1794 void CSysApAppUi::HandleBatteryStatusL( const TInt aValue )
  6657         }
  1833         }
  6658             
  1834             
  6659     }
  1835     }
  6660 
  1836 
  6661 // ----------------------------------------------------------------------------
  1837 // ----------------------------------------------------------------------------
       
  1838 // CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
       
  1839 // ----------------------------------------------------------------------------
       
  1840 
       
  1841 void CSysApAppUi::ShowUiNoteL( const TSysApNoteIds aNote ) const
       
  1842     {
       
  1843     TRACES( RDebug::Print( _L("CSysApAppUi::ShowUiNoteL aNote: %d"), aNote ) );
       
  1844     
       
  1845     TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
       
  1846 
       
  1847     if( UiReady() || swState == ESwStateSecurityCheck)
       
  1848       {
       
  1849           switch ( aNote )
       
  1850             {
       
  1851             case EBatteryLowNote:
       
  1852                 {
       
  1853                  _LIT(KPowerPressKey,"Battery low");
       
  1854                  HBufC* aString = HBufC16::NewLC(100);
       
  1855                  TPtrC aStringPointer = aString->Des();
       
  1856                  aStringPointer.Set(KPowerPressKey);
       
  1857                  TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  1858                  ShowExampleUiNoteL( aStringPointer );
       
  1859                  CleanupStack::PopAndDestroy(); // aString
       
  1860                 }
       
  1861                 break;
       
  1862             case EBatteryFullNote:
       
  1863                 {
       
  1864                 _LIT(KPowerPressKey,"Battery full");
       
  1865                 HBufC* aString = HBufC16::NewLC(100);
       
  1866                 TPtrC aStringPointer = aString->Des();
       
  1867                 aStringPointer.Set(KPowerPressKey);
       
  1868                 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  1869                 ShowExampleUiNoteL( aStringPointer );
       
  1870                 CleanupStack::PopAndDestroy(); // aString
       
  1871                 }
       
  1872                 break;
       
  1873             case ERechargeBatteryNote:
       
  1874                 {
       
  1875                 iSysApLightsController->BatteryEmptyL( ETrue );
       
  1876                 _LIT(KPowerPressKey,"Battery empty. Recharge");
       
  1877                 HBufC* aString = HBufC16::NewLC(100);
       
  1878                 TPtrC aStringPointer = aString->Des();
       
  1879                 aStringPointer.Set(KPowerPressKey);
       
  1880                 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  1881                 ShowExampleUiNoteL( aStringPointer );
       
  1882                 CleanupStack::PopAndDestroy(); // aString
       
  1883                 }
       
  1884                 break;
       
  1885             case ENotChargingNote:
       
  1886                 {
       
  1887                 _LIT(KPowerPressKey,"Not charging");
       
  1888                 HBufC* aString = HBufC16::NewLC(100);
       
  1889                 TPtrC aStringPointer = aString->Des();
       
  1890                 aStringPointer.Set(KPowerPressKey);
       
  1891                 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  1892                 ShowExampleUiNoteL( aStringPointer );
       
  1893                 CleanupStack::PopAndDestroy(); // aString
       
  1894                 }
       
  1895                 break;
       
  1896             case EBatteryFullUnplugChargerNote:
       
  1897                 {
       
  1898                   iSysApLightsController->BatteryEmptyL( ETrue );
       
  1899                   _LIT(KPowerPressKey,"Charging complete. Unplug charger to save energy.");
       
  1900                   HBufC* aString = HBufC16::NewLC(200);
       
  1901                  TPtrC aStringPointer = aString->Des();
       
  1902                   aStringPointer.Set(KPowerPressKey);
       
  1903                  TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  1904                  ShowExampleUiNoteL( aStringPointer );
       
  1905                  CleanupStack::PopAndDestroy(); // aString
       
  1906                  }
       
  1907                 break;
       
  1908             case EUnplugChargerNote:
       
  1909                 {
       
  1910                 _LIT(KPowerPressKey,"Unplug charger from power supply to save energy");
       
  1911                 HBufC* aString = HBufC16::NewLC(250);
       
  1912                 TPtrC aStringPointer = aString->Des();
       
  1913                 aStringPointer.Set(KPowerPressKey);
       
  1914                 TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  1915                 ShowExampleUiNoteL( aStringPointer );
       
  1916                 CleanupStack::PopAndDestroy(); // aString
       
  1917                 }
       
  1918                 break;
       
  1919             default:
       
  1920                 break;
       
  1921             }
       
  1922         }
       
  1923     }
       
  1924 
       
  1925 
       
  1926 // ----------------------------------------------------------------------------
       
  1927 // CSysApAppUi::BatteryEmptyL()
       
  1928 // ----------------------------------------------------------------------------
       
  1929 
       
  1930 void CSysApAppUi::BatteryEmptyL()
       
  1931     {
       
  1932     iSysApLightsController->BatteryEmptyL( ETrue );
       
  1933     // Do not reactivate keyguard in the next startup
       
  1934     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
       
  1935     }
       
  1936 
       
  1937 
       
  1938 // ----------------------------------------------------------------------------
       
  1939 // CSysApAppUi::ShowQueryL()
       
  1940 // ----------------------------------------------------------------------------
       
  1941 
       
  1942 void CSysApAppUi::ShowQueryL( const TSysApConfirmationQueryIds /* aQueryId */, const TDesC& /* aValue */)
       
  1943     {
       
  1944     // do nothing
       
  1945     }
       
  1946 
       
  1947 
       
  1948 
       
  1949 // ----------------------------------------------------------------------------
  6662 // CSysApAppUi::HandleChargingStatusL
  1950 // CSysApAppUi::HandleChargingStatusL
  6663 // ----------------------------------------------------------------------------
  1951 // ----------------------------------------------------------------------------
  6664 //
  1952 //
  6665 void CSysApAppUi::HandleChargingStatusL( const TInt aValue )
  1953 void CSysApAppUi::HandleChargingStatusL( const TInt aValue )
  6666     {
  1954     {
  6669     TBool showNote( ETrue );
  1957     TBool showNote( ETrue );
  6670     
  1958     
  6671     UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
  1959     UpdateBatteryBarsL( StateOfProperty( KPSUidHWRMPowerState, KHWRMBatteryLevel ) );
  6672 
  1960 
  6673     if ( iSysApPsmController && UiReady() ) 
  1961     if ( iSysApPsmController && UiReady() ) 
  6674         {
  1962         {             
  6675         if ( iCharging ) // iCharging updated in UpdateBatteryBarsL
       
  6676             {
       
  6677             // cancel activation query if charger is connected while query is on display
       
  6678             CancelQuery( ESysApBattLowPowerSavingQuery );
       
  6679             }
       
  6680              
       
  6681         if ( iCharging && !iSysApPsmController->ChargerConnected() ) // first time after charger connection
  1963         if ( iCharging && !iSysApPsmController->ChargerConnected() ) // first time after charger connection
  6682             {
  1964             {
  6683             iSysApPsmController->ConnectCharger( ETrue );
  1965             iSysApPsmController->ConnectCharger( ETrue );
  6684             
  1966             
  6685             if ( iSysApPsmController->ShowDeactivateQuery() )
  1967             if ( iSysApPsmController->ShowDeactivateQuery() )
  6694                 }                
  1976                 }                
  6695             }
  1977             }
  6696         else if ( aValue == EChargingStatusNotConnected )
  1978         else if ( aValue == EChargingStatusNotConnected )
  6697             {
  1979             {
  6698             iSysApPsmController->ConnectCharger( EFalse );
  1980             iSysApPsmController->ConnectCharger( EFalse );
       
  1981             }            
       
  1982         }
       
  1983     if( showNote )
       
  1984         {
       
  1985         HandleChargerNotesL( aValue );    
       
  1986         }
       
  1987     }
       
  1988 
       
  1989 
       
  1990 // ----------------------------------------------------------------------------
       
  1991 // CSysApAppUi::HandleChargerNotesL()
       
  1992 // ----------------------------------------------------------------------------
       
  1993 void CSysApAppUi::HandleChargerNotesL( const TInt aValue )
       
  1994     {
       
  1995     TBool showNote(StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging);
       
  1996     if ( aValue == EChargingStatusCharging )
       
  1997         {
       
  1998         iSysApLightsController->BatteryEmptyL( EFalse );
       
  1999         TRACES( RDebug::Print( _L("SysAp: charger connected") ) );
       
  2000         iSysApLightsController->ChargerConnectedL( ETrue );
       
  2001         ShowChargingNoteL();
       
  2002         }
       
  2003     //Display Not Charging note
       
  2004     else if ( aValue == EChargingStatusError )
       
  2005         {
       
  2006         if(showNote)
       
  2007             {
       
  2008             ShowUiNoteL( ENotChargingNote );
       
  2009             }
       
  2010         }
       
  2011     else if ( aValue == EChargingStatusChargingComplete )
       
  2012         {
       
  2013         iSysApLightsController->ChargingCompleteL();
       
  2014         
       
  2015         TSysApNoteIds note( EBatteryFullNote );
       
  2016         
       
  2017         if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
       
  2018              iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
       
  2019             {
       
  2020             note = EBatteryFullUnplugChargerNote;
       
  2021             }
       
  2022         iSysApUsbChargerDetector.Reset();
       
  2023         if(showNote)
       
  2024             {
       
  2025             ShowUiNoteL( note );
       
  2026             }
       
  2027         }
       
  2028     else if ( aValue == EChargingStatusNotConnected )
       
  2029         {
       
  2030         TRACES( RDebug::Print( _L("SysAp: charger removed") ) );
       
  2031         iSysApLightsController->ChargerConnectedL( EFalse );
       
  2032         
       
  2033         if ( !iSysApUsbChargerDetector.HostOnlyUsbChargingUsed() &&
       
  2034              iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) )
       
  2035             {
       
  2036         if(showNote)
       
  2037                 {
       
  2038                 ShowUiNoteL( EUnplugChargerNote );
       
  2039                 }
       
  2040             }
       
  2041         iSysApUsbChargerDetector.Reset();
       
  2042         }
       
  2043     else if ( aValue == EChargingStatusNotCharging )
       
  2044         {
       
  2045         TRACES( RDebug::Print( _L("SysAp: Not charging") ) );
       
  2046         }
       
  2047     else if ( aValue == EChargingStatusAlmostComplete )
       
  2048         {
       
  2049         TRACES( RDebug::Print( _L("SysAp: Charging almost complete") ) );
       
  2050         }
       
  2051     else if ( aValue == EChargingStatusChargingContinued )
       
  2052         {
       
  2053         //in this case we simply want to scroll the battery bars and not turn light on or show ui note
       
  2054         // set lights controller iBatteryEmpty to EFalse
       
  2055         iSysApLightsController->BatteryEmptyL( EFalse );
       
  2056         TRACES( RDebug::Print( _L("SysAp: charging continues") ) );
       
  2057         }
       
  2058     }
       
  2059 
       
  2060 
       
  2061 // ----------------------------------------------------------------------------
       
  2062 // CSysApAppUi::UpdateBatteryBarsL( const TInt aState )
       
  2063 // ----------------------------------------------------------------------------
       
  2064 
       
  2065 void CSysApAppUi::UpdateBatteryBarsL( const TInt  /* aState */)
       
  2066     {
       
  2067     TInt state( StateOfProperty( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
       
  2068 //    TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL aState: %d, chargerState:%d"), aState, state ) );
       
  2069     HandleUsbCharger( state );
       
  2070     if( state == EChargingStatusCharging ||
       
  2071         state == EChargingStatusChargingContinued ||
       
  2072         state == EChargingStatusAlmostComplete )
       
  2073         {
       
  2074         if ( !iCharging )
       
  2075             {
       
  2076             TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Starting Charging") ) );
       
  2077             iCharging = ETrue;
       
  2078             }
       
  2079         }
       
  2080     else
       
  2081         {
       
  2082         if ( iCharging )
       
  2083             {
       
  2084             TRACES( RDebug::Print( _L("CSysApAppUi::UpdateBatteryBarsL: Stopping Charging") ) );
       
  2085             iCharging = EFalse;
       
  2086             }
       
  2087         }
       
  2088     
       
  2089     if ( !iSysApPsmController ) // created here if first state change has not occurred yet
       
  2090         {
       
  2091         iSysApPsmController = CSysApPsmController::NewL( *this );        
       
  2092         }
       
  2093 
       
  2094     if ( iSysApPsmController )
       
  2095         {
       
  2096         if ( iSysApPsmController->FullPsmEnabled() )
       
  2097             {
       
  2098              // activate psm indicator 
       
  2099             }
       
  2100         else
       
  2101             {
       
  2102             // deactivate psm indicator
       
  2103             }            
       
  2104         }
       
  2105         
       
  2106     if ( iSysApBatteryInfoController )        
       
  2107         {
       
  2108         iSysApBatteryInfoController->BatteryLevelUpdatedL();
       
  2109         }
       
  2110     }
       
  2111 
       
  2112 
       
  2113 
       
  2114 // ----------------------------------------------------------------------------
       
  2115 // CSysApAppUi::ShowChargingNoteL()
       
  2116 // ----------------------------------------------------------------------------
       
  2117 
       
  2118 void CSysApAppUi::ShowChargingNoteL()
       
  2119     {
       
  2120     TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL") ) );
       
  2121     TBool showNote( ETrue );
       
  2122 
       
  2123     TInt swState( StateOfProperty( KPSUidStartup, KPSGlobalSystemState ) );
       
  2124     TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL: swState: %d"), swState ) );
       
  2125 
       
  2126     if( UiReady() || swState == ESwStateSecurityCheck )
       
  2127         {
       
  2128         if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ==  EPSCTsyCallStateRinging )
       
  2129             {
       
  2130             showNote = EFalse;
       
  2131             }
       
  2132         TRACES( RDebug::Print( _L("CSysApAppUi::ShowChargingNoteL KCTsyCallState=%d"), StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) ) );
       
  2133         if ( showNote ) // Power Mgmt UI spec defines that no Charging note is shown while the phone is ringing/alerting
       
  2134             {
       
  2135             _LIT(KChargingNote,"Charging");
       
  2136             HBufC* aString = HBufC16::NewLC(50);
       
  2137             TPtrC aStringPointer = aString->Des();
       
  2138             aStringPointer.Set(KChargingNote);
       
  2139             TRACES( RDebug::Print( _L("CSysApWsClient::RunL(): Key EEventKeyUp 01") ) );   
       
  2140             ShowExampleUiNoteL( aStringPointer );
       
  2141             CleanupStack::PopAndDestroy(); // aString            
       
  2142             }
       
  2143         }
       
  2144     }
       
  2145 
       
  2146 
       
  2147 // ----------------------------------------------------------------------------
       
  2148 // CSysApAppUi::HandleUsbCharger
       
  2149 // ----------------------------------------------------------------------------
       
  2150 //
       
  2151 void CSysApAppUi::HandleUsbCharger( const TInt aValue )
       
  2152     {        
       
  2153     if ( aValue == EChargingStatusCharging ||
       
  2154          aValue == EChargingStatusChargingContinued ||
       
  2155          aValue == EChargingStatusAlmostComplete )
       
  2156         {
       
  2157         iSysApUsbChargerDetector.SetChargingUsed( ETrue );
       
  2158         if ( !iSysApUsbIndicatorController &&
       
  2159              iSysApFeatureManager->Supported( KSysApFeatureIdChargerReminderNotes ) &&
       
  2160              iSysApFeatureManager->Supported( KSysApFeatureIdUsbChargingWithoutReminderNotes ) )
       
  2161             {
       
  2162             // Start observing USB state for the reminder note
       
  2163             TRAPD ( usbErr, iSysApUsbIndicatorController = CreateSysApUsbIndicatorL( *this ) );
       
  2164             if ( usbErr )
       
  2165                 {
       
  2166                 TRACES( RDebug::Print(
       
  2167                     _L("CSysApAppUi::HandleUsbCharger: error in constructing USB ind. controller %d" ),
       
  2168                     usbErr ) );
       
  2169                 }
       
  2170             }
       
  2171         }
       
  2172     }
       
  2173 
       
  2174 // ----------------------------------------------------------------------------
       
  2175 // CSysApAppUi::HandleCurrentCallStateChangeL()
       
  2176 // ----------------------------------------------------------------------------
       
  2177 
       
  2178 void CSysApAppUi::HandleCurrentCallStateChangeL( TInt aCurrentCallState )
       
  2179     {
       
  2180     TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: KUidCurrentCall: %d" ), aCurrentCallState ) );
       
  2181 
       
  2182     switch ( aCurrentCallState )
       
  2183         {
       
  2184         case EPSCTsyCallStateRinging:
       
  2185             {
       
  2186             iSysApLightsController->CallComingInL( ETrue );
       
  2187             // Disable keylock when a call is coming in
       
  2188             if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle || iKeyLockOnBeforeAlarm )
       
  2189                 {
       
  2190                 TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateRinging: disable keylock") ) );
       
  2191                 iKeyLockOnBeforeCall = ETrue;
       
  2192 
       
  2193                 if ( iKeyLockEnabled || iDeviceLockEnabled )
       
  2194                     {
       
  2195                     if ( !iSysApFeatureManager->TouchUnlockStrokeSupported() )
       
  2196                         {
       
  2197                         iKeyguardController->DisableKeyguard(EFalse);
       
  2198                         }
       
  2199                     }
       
  2200                 }
       
  2201             break;
       
  2202             }
  6699             
  2203             
  6700             // cancel deactivation query if charger is disconnected while query is on display 
  2204         case EPSCTsyCallStateDialling:
  6701             CancelQuery( ESysApBattChargingPowerSavingQuery );
  2205             {
  6702             }            
  2206             // Disable keypad lock during an emergency call
  6703         }
  2207             // no need to disable the key lock when a call is made using the wireless car-kit
  6704     if( showNote )
  2208             // but if the call is an emergency one then we will disable the keypad lock
  6705         {
  2209             if ( iKeyLockEnabled || iDeviceLockEnabled || iKeyLockOnBeforeCradle )
  6706         HandleChargerNotesL( aValue );    
  2210                 {
  6707         }
  2211                 TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateDialling: disable keylock") ) );
  6708     }
  2212                 iKeyLockOnBeforeCall = ETrue;
  6709 
  2213 
  6710 // ----------------------------------------------------------------------------
  2214                 if ( IsEmergencyCall() && (iKeyLockEnabled || iDeviceLockEnabled ))
  6711 // CSysApAppUi::HandleActivatePsmQueryResponse
  2215                     {
  6712 // ----------------------------------------------------------------------------
  2216                     iKeyguardController->DisableKeyguard(EFalse);
       
  2217                     }
       
  2218                 }
       
  2219 
       
  2220             // Enable signal & network indicators when an emergency call is made in Offline Mode
       
  2221             if( iSysApOfflineModeController->OfflineModeActive() )
       
  2222                     {
       
  2223                     // Signal indicators not updated with VoIP call
       
  2224                     if ( StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) != EPSCTsyCallTypeVoIP) 
       
  2225                         {
       
  2226                         iEmergencyCallActive = ETrue;
       
  2227                         // not supporting this
       
  2228                         // UpdateSignalBarsL();
       
  2229                         // SetSignalIndicatorL();
       
  2230                         }
       
  2231                     }
       
  2232             break;
       
  2233             }
       
  2234             
       
  2235         case EPSCTsyCallStateConnected:
       
  2236             {
       
  2237             if (StateOfProperty(KPSUidCtsyCallInformation, KCTsyCallType) == EPSCTsyCallTypeCSVoice)
       
  2238                 {
       
  2239                 // Check if GPRS suspended note is required
       
  2240                 iCallActivated = ETrue;
       
  2241                 // not supporting this
       
  2242                 // HandleGprsNotesL();
       
  2243                 }
       
  2244             if ( iDeviceLockEnabled )
       
  2245                 {
       
  2246                 // Enable keylock via autolock emulation if device lock enabled. 
       
  2247                 // Otherwise e.g. messages can be read using softkeys during ongoing call.
       
  2248                 iKeyguardController->EnableKeyguard(EFalse);
       
  2249                 }
       
  2250             break;
       
  2251             }
       
  2252 
       
  2253         case EPSCTsyCallStateNone:
       
  2254             {
       
  2255             // Reset timers in ScreenSaver and Autolock
       
  2256             User::ResetInactivityTime();
       
  2257 
       
  2258             if ( iEmergencyCallActive )
       
  2259                 {
       
  2260                 iEmergencyCallActive = EFalse;
       
  2261                 // not supporting this
       
  2262                 // UpdateSignalBarsL( 0 );
       
  2263                 // SetSignalIndicatorL();
       
  2264                 }
       
  2265             if ( iKeyLockOnBeforeCall )
       
  2266                 {
       
  2267                 TRACES( RDebug::Print( _L("CSysApAppUi::HandleCurrentCallStateChangeL: EPSCTsyCallStateNone: enable keylock") ) );
       
  2268                 iKeyLockOnBeforeCall = EFalse;
       
  2269                 if ( !iDeviceLockEnabled )
       
  2270                     {
       
  2271                     if ( !iKeyLockOnBeforeCradle && !iKeyLockOnBeforeAlarm &&
       
  2272                           !iSysApFeatureManager->TouchUnlockStrokeSupported() )
       
  2273                         {
       
  2274                         if ( iSysApCenRepController->GetInt( KCRUidCommonTelephonySettings, KSettingsSummaryAfterCall ) == 1 )
       
  2275                             {
       
  2276                             // Let's not hide "Summary After Call" dialog
       
  2277                             iKeyguardController->EnableKeyguard(EFalse);
       
  2278                             }
       
  2279                         else
       
  2280                             {
       
  2281                             iKeyguardController->EnableKeyguard(ETrue);
       
  2282                             }
       
  2283                         }
       
  2284                     }
       
  2285                 else
       
  2286                     {
       
  2287                     iKeyguardController->EnableKeyguard(EFalse);
       
  2288                     }
       
  2289                 }
       
  2290             if ( iShowkeypadActivatedNoteAfterSoftReject )
       
  2291                 {
       
  2292                 ShowUiNoteL( EKeypadActiveNote );
       
  2293                 iShowkeypadActivatedNoteAfterSoftReject = EFalse;
       
  2294                 }
       
  2295             iCallActivated = EFalse;
       
  2296             break;
       
  2297             }
       
  2298             
       
  2299         default:
       
  2300             break;
       
  2301         }
       
  2302 
       
  2303     if ( aCurrentCallState != EPSCTsyCallStateRinging )
       
  2304         {
       
  2305         iSysApLightsController->CallComingInL( EFalse );
       
  2306         }
       
  2307 
       
  2308     SetIhfIndicatorL();
       
  2309     SetHacIndicatorL();
       
  2310     }
       
  2311 
       
  2312 
       
  2313 
       
  2314 /**
       
  2315  * To check the for an emergency call. 
       
  2316  * 
       
  2317  * @return ETrue if there is an emergency call active otherwise, EFalse.
       
  2318  */
       
  2319 TBool CSysApAppUi::IsEmergencyCall()
       
  2320         {
       
  2321         TBool retVal( EFalse );
       
  2322         TInt err( KErrNone );
       
  2323         TInt state( 0 );
       
  2324      
       
  2325         err = RProperty::Get(KPSUidCtsyEmergencyCallInfo, KCTSYEmergencyCallInfo, state );
       
  2326         if ( err == KErrNone && state )
       
  2327             {
       
  2328             retVal = ETrue;            
       
  2329             }
       
  2330         return retVal;
       
  2331         }
       
  2332 
       
  2333 
       
  2334 
       
  2335 // ----------------------------------------------------------------------------
       
  2336 // CSysApAppUi::IsStateNormal()
  6713 //
  2337 //
  6714 void CSysApAppUi::HandleActivatePsmQueryResponse( TBool aEnable )
  2338 // ----------------------------------------------------------------------------
  6715     {
  2339 TBool CSysApAppUi::IsStateNormal() const
  6716     TRACES( RDebug::Print( _L("CSysApAppUi::HandleActivatePsmQueryResponse aEnable: %d"), 
  2340     {
  6717         aEnable ) );
  2341     TInt state;
  6718     
  2342     TInt errorCode =
  6719     __ASSERT_DEBUG( iSysApPsmController, User::Invariant() );
  2343         RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state );
  6720     
  2344     if ( errorCode == KErrNone )
  6721     if ( aEnable )
  2345         {
  6722         {
  2346         return state == ESwStateNormalRfOn ||
  6723         iSysApPsmController->DoEnableFullPsm( ETrue );    
  2347                state == ESwStateNormalRfOff ||
       
  2348                state == ESwStateNormalBTSap;
  6724         }
  2349         }
  6725     else
  2350     else
  6726         {
  2351         {
  6727         iSysApPsmController->DoEnablePartialPsm( ETrue );     
  2352         TRACES( RDebug::Print( _L( "CSysApAppUi::IsStateNormal: Failed to read global system state, error code %d." ), errorCode ) );
  6728         }        
  2353         return EFalse;
  6729     }
  2354         }
  6730 
  2355     }
  6731 // ----------------------------------------------------------------------------
  2356 
  6732 // CSysApAppUi::HandleDeactivatePsmQueryResponse
  2357 
       
  2358 // ----------------------------------------------------------------------------
       
  2359 // CSysApAppUi::HandleAccessoryProfileInStartupL()
       
  2360 // ----------------------------------------------------------------------------
       
  2361 
       
  2362 void CSysApAppUi::HandleAccessoryProfileInStartupL()
       
  2363     {
       
  2364     TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL" ) ) );
       
  2365 
       
  2366     if ( !iSysApOfflineModeController->OfflineModeActive() )
       
  2367         {
       
  2368         iIgnoreAccessorySpecificProfileChanges = EFalse;
       
  2369         TBool accessoryConnectedInShutdown( EFalse );
       
  2370         TInt accessoryTemp( iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApAccessoryConnected ) );
       
  2371         if ( accessoryTemp == 1 )
       
  2372             {
       
  2373             accessoryConnectedInShutdown = ETrue;
       
  2374             }
       
  2375 
       
  2376         TBool accessoryConnectedNow ( EFalse );
       
  2377 
       
  2378         TAccMode accessoryState(EAccModeHandPortable);
       
  2379         if ( iSysApAccessoryObserver )
       
  2380             {
       
  2381             accessoryState = iSysApAccessoryObserver->GetAccessoryMode();
       
  2382             }
       
  2383 
       
  2384         if ( accessoryState != EAccModeHandPortable )
       
  2385             {
       
  2386             accessoryConnectedNow = ETrue;
       
  2387             }
       
  2388         TRACES( RDebug::Print( _L( "CSysApAppUi::HandleAccessoryProfileInStartupL: accessoryConnectedInShutdown: %d, accessoryConnectedNow: %d" ),
       
  2389                               accessoryConnectedInShutdown, accessoryConnectedNow ) );
       
  2390 
       
  2391         if ( accessoryConnectedInShutdown && !accessoryConnectedNow )
       
  2392             {
       
  2393             HandleAccessoryDisconnectedL();
       
  2394             }
       
  2395         else if ( !accessoryConnectedInShutdown && accessoryConnectedNow )
       
  2396             {
       
  2397             HandleAccessoryConnectedL( accessoryState );
       
  2398             }
       
  2399         else if ( !accessoryConnectedNow )
       
  2400             {
       
  2401             // not supporting this 
       
  2402             // TInt activeProfile ( ActiveProfileId() );
       
  2403             // SysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApActiveProfileBeforeAccessoryConnected, activeProfile );
       
  2404             }
       
  2405         }
       
  2406     }
       
  2407 
       
  2408 
       
  2409 // ----------------------------------------------------------------------------
       
  2410 // CSysApAppUi::CenRepController()
       
  2411 // ----------------------------------------------------------------------------
       
  2412 
       
  2413 CSysApCenRepController& CSysApAppUi::CenRepController()
       
  2414     {
       
  2415     __ASSERT_ALWAYS( iSysApCenRepController, User::Panic( _L("CSysApAppUi::CenRepController"), KErrBadHandle ) );
       
  2416 
       
  2417     return *iSysApCenRepController;
       
  2418     }
       
  2419 
       
  2420 
       
  2421 // ----------------------------------------------------------------------------
       
  2422 // CSysApAppUi::LogsObserverL
  6733 // ----------------------------------------------------------------------------
  2423 // ----------------------------------------------------------------------------
  6734 //
  2424 //
  6735 void CSysApAppUi::HandleDeactivatePsmQueryResponse( TBool aDisable )
  2425 CSysApCenRepLogsObserver& CSysApAppUi::LogsObserverL()
  6736     {
  2426     {
  6737     TRACES( RDebug::Print( _L("CSysApAppUi::HandleDeactivatePsmQueryResponse aDisable: %d"), 
  2427     TRACES( RDebug::Print( _L("CSysApAppUi::LogsObserverL()") ) );
  6738         aDisable ) );
  2428     
  6739 
  2429     // Create Logs observer when it is needed for the first time
  6740     __ASSERT_DEBUG( iSysApPsmController, User::Invariant() );
  2430     if ( !iSysApCenRepLogsObserver )
  6741     
  2431         {
  6742     if ( aDisable )
  2432         iSysApCenRepLogsObserver = CSysApCenRepLogsObserver::NewL( *this );
  6743         {
  2433         }
  6744         iSysApPsmController->DoEnableFullPsm( EFalse );        
  2434     
  6745         }
  2435     return *iSysApCenRepLogsObserver;
  6746     }
  2436     }
  6747     
  2437 
  6748 // ----------------------------------------------------------------------------
  2438 
  6749 // CSysApAppUi::CancelQuery
  2439 // ----------------------------------------------------------------------------
  6750 // ----------------------------------------------------------------------------
  2440 // CSysApAppUi::HandleWlanIndicator()
  6751 //
  2441 // ----------------------------------------------------------------------------
  6752 void CSysApAppUi::CancelQuery( TSysApConfirmationQueryIds aQueryId )
  2442 void CSysApAppUi::HandleWlanIndicatorL( TInt aValue )
  6753     {
  2443     {
  6754     TRACES( RDebug::Print( _L("CSysApAppUi::CancelQuery aQueryId: %d"), aQueryId ) );
  2444     if ( aValue == EPSWlanIndicatorAvailable )
  6755 
  2445         {
  6756     if ( iSysApConfirmationQuery )
  2446         // do nothing
  6757         {
  2447         }
  6758         if ( aQueryId == iSysApConfirmationQuery->CurrentQuery() || aQueryId == ESysApNoQuery )
  2448     else if ( aValue == EPSWlanIndicatorActive )
  6759             {
  2449         {
  6760             iSysApConfirmationQuery->Cancel();
  2450         // do nothing
  6761             }
  2451         }
  6762         }
  2452     else if ( aValue == EPSWlanIndicatorActiveSecure )
  6763     }
  2453         {
  6764 // End of File
  2454         // do nothing
       
  2455         }
       
  2456     else // No indication required
       
  2457         {
       
  2458         // do nothing
       
  2459         }
       
  2460     }
       
  2461 
       
  2462 void CSysApAppUi::ShowNotificationDialog(const TDesC& noteText)const
       
  2463 {
       
  2464     //Todo:4.Notification--Just Popup message
       
  2465     //Todo: #include <HbDeviceNotificationDialogSymbian.h>
       
  2466     CHbDeviceNotificationDialogSymbian *notificationDialog =  CHbDeviceNotificationDialogSymbian::NewL();
       
  2467     CleanupStack::PushL(notificationDialog);
       
  2468     notificationDialog->SetTextL(noteText);//noteText with Qm file input
       
  2469     notificationDialog->SetTimeout(100);
       
  2470     notificationDialog->ShowL();
       
  2471     CleanupStack::PopAndDestroy(notificationDialog);
       
  2472 }
       
  2473 
       
  2474 void CSysApAppUi::SetKeyLockEnabledL()
       
  2475     {
       
  2476     iKeyLockEnabled = ETrue;
       
  2477     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 1 );
       
  2478     // not supporting indicator 
       
  2479 //    SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOn );
       
  2480     iSysApLightsController->KeylockStateChangedL( ETrue );
       
  2481     }
       
  2482 
       
  2483 void CSysApAppUi::SetKeyLockDisabledL()
       
  2484     {
       
  2485     iKeyLockEnabled = EFalse;
       
  2486     iSysApCenRepController->SetInt( KCRUidCoreApplicationUIsSysAp, KSysApKeyguardActive, 0 );
       
  2487     // SetIndicatorStateL( EAknIndicatorKeyguard, EAknIndicatorStateOff );
       
  2488     if (! iDeviceLockEnabled )
       
  2489         {
       
  2490         iSysApLightsController->KeylockStateChangedL( EFalse );
       
  2491         if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
  2492             {
       
  2493             if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
       
  2494                 {
       
  2495                 // RunUnlockNotifierL();
       
  2496                 // need to handle MMC unlock query in next sub
       
  2497                 }
       
  2498             }
       
  2499         }
       
  2500     }
       
  2501 
       
  2502 void CSysApAppUi::SetLightsOnUnlockNoteL()
       
  2503     {
       
  2504     iSysApLightsController->SetLightsOnUnlockNoteL();
       
  2505     }
       
  2506 
       
  2507 void CSysApAppUi::SetLightsOnEcsQueryL()
       
  2508     {
       
  2509     iSysApLightsController->SetLightsOnEcsQueryL();
       
  2510     }
       
  2511 
       
  2512 void CSysApAppUi::SetLightsOnSecurityQueryL()
       
  2513     {
       
  2514     iSysApLightsController->SetLightsOnSecurityQueryL();
       
  2515     }
       
  2516 
       
  2517 TBool CSysApAppUi::CheckLongPowerKeyPressed()
       
  2518     {
       
  2519     return iCheckLongPowerKeyEvent;
       
  2520     }
       
  2521 
       
  2522 
       
  2523 // ----------------------------------------------------------------------------
       
  2524 // CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
       
  2525 // ----------------------------------------------------------------------------
       
  2526 
       
  2527 TKeyResponse CSysApAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
       
  2528     {
       
  2529     if ( ! iShutdownStarted )
       
  2530         {
       
  2531         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
       
  2532                                aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
       
  2533 
       
  2534 #ifdef _DEBUG
       
  2535         // camery latency measurement environment instrumentation, don't remove
       
  2536         if ( aType == EEventKey && aKeyEvent.iCode == EKeyCamera )
       
  2537             {
       
  2538             TRACES( RDebug::Print( _L("e_KEY_EVENT_SENDING 0") ) );
       
  2539             }
       
  2540 #endif // _DEBUG
       
  2541 
       
  2542         TKeyResponse response( EKeyWasNotConsumed );
       
  2543         if (iSysApKeyManagement && aKeyEvent.iCode != EKeyPowerOff && aKeyEvent.iCode != 'E')
       
  2544             {
       
  2545             response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
       
  2546             }
       
  2547         
       
  2548         if( aType == EEventKey )
       
  2549             {
       
  2550             switch ( aKeyEvent.iCode )
       
  2551                 {
       
  2552 #ifdef _DEBUG
       
  2553                 case 'E': //For testing
       
  2554                     Exit();
       
  2555                     break;
       
  2556 #endif
       
  2557                 case EKeyPowerOff:
       
  2558                     //Short power key press
       
  2559                     iKeyBoardRepeatCount++;
       
  2560                     if( aKeyEvent.iRepeats == 0 )
       
  2561                         {
       
  2562                         TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Short powerkey") ) );
       
  2563                         iLastPowerKeyWasShort = ETrue;
       
  2564                         TRACES( RDebug::Print( _L("CSysApAppUi::Key was consumed by pressing short power") ) );          
       
  2565                         //Powermenu
       
  2566                         if (iPowerMenuDialog != NULL)
       
  2567                             {
       
  2568                             //PowerMenu already exist
       
  2569                             delete iPowerMenuDialog;
       
  2570                             iPowerMenuDialog = NULL;
       
  2571                             } 
       
  2572                             
       
  2573                         iPowerMenuDialog = CHbDevicePowerMenuSymbian::NewL(*this);
       
  2574                         iPowerMenuDialog->ShowL();                        
       
  2575                         iIgnoreNextPowerKeyRepeats = EFalse;
       
  2576                         }
       
  2577                     //Long power key press
       
  2578                     else if( aKeyEvent.iRepeats > 0 && iKeyBoardRepeatCount >= iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApPowerkeyRepeatcount ))
       
  2579                         {
       
  2580                         iKeyBoardRepeatCount = -1;
       
  2581                         TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Long powerkey") ) );
       
  2582                         iLastPowerKeyWasShort = EFalse;
       
  2583                         HandleLongPowerKeyPressedL();
       
  2584                         }
       
  2585                     break;
       
  2586 
       
  2587                 default:
       
  2588                     {
       
  2589                     TKeyResponse response = EKeyWasNotConsumed;
       
  2590                     if (iSysApKeyManagement)
       
  2591                         {
       
  2592                         response = iSysApKeyManagement->HandleKeyEventL(aKeyEvent, aType );
       
  2593                         }
       
  2594 
       
  2595                     if ( response == EKeyWasNotConsumed ) // none of the plugins consumed the key, offer it to default handling
       
  2596                         {
       
  2597                         iSysApDefaultKeyHandler->HandleKeyEventL( aKeyEvent, aType );
       
  2598                         }
       
  2599                     }
       
  2600                     break;
       
  2601                 }
       
  2602             }
       
  2603         else if( aType == EEventKeyUp )
       
  2604             {
       
  2605             if( aKeyEvent.iScanCode == EStdKeyDevice2 )
       
  2606                 {
       
  2607                 if ( iIgnoreNextPowerKeyUpEvent )
       
  2608                     {
       
  2609                     if ( !iPowerKeyPopupMenuDismissed ) // If the popup menu has been dismissed, do nothing
       
  2610                         {
       
  2611                         iPowerKeyPopupMenuActive = ETrue;
       
  2612                         iIgnoreNextPowerKeyUpEvent = EFalse;
       
  2613                         }
       
  2614                     }
       
  2615                 else if( iLastPowerKeyWasShort )
       
  2616                     {
       
  2617                     if ( iPowerKeyPopupMenuActive )
       
  2618                         {
       
  2619                         }
       
  2620                     }
       
  2621 
       
  2622                 }
       
  2623             }
       
  2624 
       
  2625         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL:ended, aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d, iIgnoreNextPowerKeyUpEvent:%d, iPowerKeyPopupMenuActive:%d, iLastPowerKeyWasShort:%d, iPowerKeyPopupMenuDismissed:%d"),
       
  2626                                aKeyEvent.iCode, aKeyEvent.iScanCode, aType, iIgnoreNextPowerKeyUpEvent, iPowerKeyPopupMenuActive, iLastPowerKeyWasShort, iPowerKeyPopupMenuDismissed ) );
       
  2627         }
       
  2628     else // shutdown started
       
  2629         {
       
  2630         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: aKeyEvent.iCode:%d, aKeyEvent.iScanCode:%d, aType:%d"),
       
  2631                                aKeyEvent.iCode, aKeyEvent.iScanCode, aType ) );
       
  2632 
       
  2633         // When shutdown has been started, only device mode key events are passed to plug-in framework
       
  2634         // This for enabling plug-in activities during shutdown animation
       
  2635         if ( IsDeviceModeKey( aKeyEvent ) ) // Other key events are not passed, because they must cancel the shutdown animation as stated in UI spefication
       
  2636             {
       
  2637             if ( aType == EEventKey && iSysApKeyManagement )
       
  2638                 {
       
  2639                 iSysApKeyManagement->HandleKeyEventL( aKeyEvent, aType );
       
  2640                 }
       
  2641             }
       
  2642         TRACES( RDebug::Print( _L("CSysApAppUi::HandleKeyEventL: ended") ) );
       
  2643         }
       
  2644     return EKeyWasConsumed;
       
  2645     }
       
  2646 
       
  2647 
       
  2648 // ----------------------------------------------------------------------------
       
  2649 // CSysApAppUi::HandleCommandL( TInt aCommand)
       
  2650 // ----------------------------------------------------------------------------
       
  2651 
       
  2652 void CSysApAppUi::HandleCommandL( TInt aCommand )
       
  2653     {
       
  2654     TRACES( RDebug::Print( _L("CSysApAppUi::HandleCommandL aCommend: %d"), aCommand ) );
       
  2655     switch ( aCommand )
       
  2656         {
       
  2657         case EEikCmdExit:   // EAknCmdExit
       
  2658             Exit();
       
  2659             break;
       
  2660         default:
       
  2661             break;
       
  2662         }
       
  2663     }
       
  2664 
       
  2665 TBool CSysApAppUi::ReleasePowerMenuCustomDialogMemory()
       
  2666     {
       
  2667     if (iPowerMenuDialog!=NULL)
       
  2668         {
       
  2669         //PowerMenu already exist
       
  2670         delete iPowerMenuDialog;
       
  2671         iPowerMenuDialog = NULL;
       
  2672         return ETrue;
       
  2673         }
       
  2674     return EFalse;
       
  2675     }
       
  2676 
       
  2677 
       
  2678 //end of file