coreapplicationuis/SysAp/Src/SysApAppUi.cpp
changeset 65 8a530a83576a
parent 56 11a052f4b02e
child 69 dcd4152cfe55
equal deleted inserted replaced
56:11a052f4b02e 65:8a530a83576a
    28 #include <secuisystemlock.h>
    28 #include <secuisystemlock.h>
    29 #include <apgtask.h>
    29 #include <apgtask.h>
    30 #include <hwrmpowerstatesdkpskeys.h>
    30 #include <hwrmpowerstatesdkpskeys.h>
    31 #include <wlaninternalpskeys.h> 
    31 #include <wlaninternalpskeys.h> 
    32 #include <HbDeviceNotificationDialogSymbian.h>
    32 #include <HbDeviceNotificationDialogSymbian.h>
    33 //#include <HbDeviceInputDialogSymbian.h>
       
    34 #include <hbsymbianvariant.h>
    33 #include <hbsymbianvariant.h>
    35 #include <hbtextresolversymbian.h>
    34 #include <hbtextresolversymbian.h>
    36 #include <UikonInternalPSKeys.h>
    35 #include <UikonInternalPSKeys.h>
    37 
    36 
    38 //#include "SysApWsClient.h"
    37 //#include "SysApWsClient.h"
    51 #include "sysapbatteryinfocontroller.h"
    50 #include "sysapbatteryinfocontroller.h"
    52 #include "SysApSimChanged.h"
    51 #include "SysApSimChanged.h"
    53 #include "MSysApBtSapController.h"
    52 #include "MSysApBtSapController.h"
    54 #include "MSysApBtController.h"
    53 #include "MSysApBtController.h"
    55 #include "MSysApUsbIndicator.h"
    54 #include "MSysApUsbIndicator.h"
    56 
       
    57 #include "sysapkeymanagement.h"
    55 #include "sysapkeymanagement.h"
    58 #include "SysApShutdownImage.h"
    56 #include "SysApShutdownImage.h"
    59 #include "SysApKeySndHandler.h"
    57 #include "SysApKeySndHandler.h"
    60 
    58 
    61 #include "SysApShutdownAnimation.h"
    59 #include "SysApShutdownAnimation.h"
    62 #include "SysApEtelConnector.h"
    60 #include "SysApEtelConnector.h"
    63 
    61 
    64 
    62 #ifdef RD_MULTIPLE_DRIVE
       
    63 #include "sysapdrivelist.h"
       
    64 #include "sysapdriveunlockhandler.h"
       
    65 #include "sysapdriveejecthandler.h"
       
    66 #include "hbdeviceinputdialogsymbian.h"
       
    67 #endif // RD_MULTIPLE_DRIVE
    65 
    68 
    66 #include <settingsinternalcrkeys.h>
    69 #include <settingsinternalcrkeys.h>
    67 #include <keyguardaccessapi.h>
    70 #include <keyguardaccessapi.h>
    68 #include <eikdef.h>
    71 #include <eikdef.h>
    69 #include <eikenv.h>
    72 #include <eikenv.h>
   118      iSapTimer (NULL),
   121      iSapTimer (NULL),
   119      iSysApCenRepLogsObserver (NULL),
   122      iSysApCenRepLogsObserver (NULL),
   120      iSysApUsbIndicatorController(NULL),
   123      iSysApUsbIndicatorController(NULL),
   121      iKeyguardController (NULL),
   124      iKeyguardController (NULL),
   122      iKeyLockOnBeforeCall (EFalse),
   125      iKeyLockOnBeforeCall (EFalse),
   123      iCheckLongPowerKeyEvent (EFalse)
   126      iCheckLongPowerKeyEvent (EFalse),
       
   127      iMMCEjectUsed( EFalse ),               
       
   128      iMemCardPwdDialog(NULL)
   124 	{
   129 	{
   125 	TRACES( RDebug::Print( _L("CSysApAppUi::CSysApAppUi()") ) );
   130 	TRACES( RDebug::Print( _L("CSysApAppUi::CSysApAppUi()") ) );
   126     }
   131     }
   127 
   132 
   128 // ----------------------------------------------------------------------------
   133 // ----------------------------------------------------------------------------
   249     iSysApStartupController->DoInitialSwStateCheckL();
   254     iSysApStartupController->DoInitialSwStateCheckL();
   250     
   255     
   251     TRACES( RDebug::Print( _L("CCSysApAppUi::ConstructL  trying CSysApCenRepHacSettingObserver::NewL") ) );
   256     TRACES( RDebug::Print( _L("CCSysApAppUi::ConstructL  trying CSysApCenRepHacSettingObserver::NewL") ) );
   252     iSysApCenRepHacSettingObserver = CSysApCenRepHacSettingObserver::NewL( *this ); 
   257     iSysApCenRepHacSettingObserver = CSysApCenRepHacSettingObserver::NewL( *this ); 
   253     
   258     
       
   259 #ifndef RD_MULTIPLE_DRIVE
       
   260     if ( iSysApFeatureManager->MmcSupported() )
       
   261         {
       
   262         iSysApMMCObserver = CSysApMMCObserver::NewL( this, &iEikonEnv->FsSession(), iSysApFeatureManager->MmcHotSwapSupported() );
       
   263         }
       
   264 #else // RD_MULTIPLE_DRIVE
       
   265     iSysApDriveList = CSysApDriveList::NewL( iEikonEnv->FsSession() );
       
   266     if ( iSysApFeatureManager->MmcSupported() )
       
   267         {
       
   268         iSysApMMCObserver = CSysApMMCObserver::NewL(
       
   269             iEikonEnv->FsSession(), *iSysApDriveList, *this, iSysApFeatureManager->MmcHotSwapSupported() );
       
   270         iSysApDriveUnlockHandler = CSysApDriveUnlockHandler::NewL(
       
   271             *iSysApDriveList, *this, iSysApFeatureManager->MemoryCardLockSupported() );
       
   272         iSysApDriveEjectHandler = CSysApDriveEjectHandler::NewL(
       
   273             *iSysApDriveList, *this, iEikonEnv->FsSession() );
       
   274         }
       
   275 #endif // RD_MULTIPLE_DRIVE
       
   276     
   254     //Instantiate the KEF plugin manager
   277     //Instantiate the KEF plugin manager
   255     //Trap constuction, since Sysap may live without iSysApKeyManagement
   278     //Trap constuction, since Sysap may live without iSysApKeyManagement
   256     TRAPD(keyManagementErr, iSysApKeyManagement=CSysApKeyManagement::NewL(CCoeEnv::Static()->RootWin(), *this));
   279     TRAPD(keyManagementErr, iSysApKeyManagement=CSysApKeyManagement::NewL(CCoeEnv::Static()->RootWin(), *this));
   257 
   280 
   258     if (keyManagementErr)
   281     if (keyManagementErr)
   295     delete iSysApBatteryInfoController;
   318     delete iSysApBatteryInfoController;
   296     delete iSysApPsmController;
   319     delete iSysApPsmController;
   297     delete iVariantAccState; 
   320     delete iVariantAccState; 
   298 
   321 
   299     delete iSysApAudioRoutingObserver;
   322     delete iSysApAudioRoutingObserver;
   300 
   323     
       
   324     if (iMemCardPwdDialog!=NULL)
       
   325         {
       
   326         //PowerMenu already exist
       
   327         delete iMemCardPwdDialog;
       
   328         iMemCardPwdDialog = NULL;
       
   329         }
       
   330     
   301     if ( iSapTimer )
   331     if ( iSapTimer )
   302         {
   332         {
   303         iSapTimer->Cancel();
   333         iSapTimer->Cancel();
   304         delete iSapTimer;
   334         delete iSapTimer;
   305         }
   335         }
   426 
   456 
   427     UpdateBatteryBarsL( state );   
   457     UpdateBatteryBarsL( state );   
   428     DoSwStateNormalConstructionL();
   458     DoSwStateNormalConstructionL();
   429     HandleAccessoryProfileInStartupL();
   459     HandleAccessoryProfileInStartupL();
   430           
   460           
   431 
   461     if ( iSysApFeatureManager->MmcSupported() )
   432       
   462         {
   433        
   463 #ifndef RD_MULTIPLE_DRIVE
       
   464         MountMMC();
       
   465         MMCStatusChangedL();
       
   466         iHideFirstBeep = EFalse;
       
   467 #else // RD_MULTIPLE_DRIVE
       
   468         iSysApDriveList->MountDrive( iSysApDriveList->DefaultMemoryCard() );
       
   469         UpdateInsertedMemoryCardsL();
       
   470 #endif // RD_MULTIPLE_DRIVE
       
   471         }
       
   472 		
       
   473 	if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
   474         {
       
   475         iSysApMMCObserver->StartMountObserver();
       
   476         }    
   434    
   477    
   435     if ( !iSysApPsmController ) // created here if first state change has not occurred yet
   478     if ( !iSysApPsmController ) // created here if first state change has not occurred yet
   436        {
   479        {
   437        iSysApPsmController = CSysApPsmController::NewL( *this );        
   480        iSysApPsmController = CSysApPsmController::NewL( *this );        
   438        }
   481        }
   520         }
   563         }
   521         
   564         
   522     if( IsStateNormal() )
   565     if( IsStateNormal() )
   523         {
   566         {
   524         TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
   567         TRACES( RDebug::Print(_L("CSysApAppUi::DoStateChangedL to normal state.") ) );
   525 
   568         
       
   569         if ( iSysApFeatureManager->MmcSupported() )
       
   570             {
       
   571 #ifndef RD_MULTIPLE_DRIVE
       
   572             MountMMC();
       
   573             MMCStatusChangedL();
       
   574             iHideFirstBeep = EFalse;
       
   575 #else // RD_MULTIPLE_DRIVE
       
   576             iSysApDriveList->MountDrive( iSysApDriveList->DefaultMemoryCard() );
       
   577             UpdateInsertedMemoryCardsL();
       
   578 #endif // RD_MULTIPLE_DRIVE
       
   579             }
       
   580         if ( iSysApFeatureManager->MmcHotSwapSupported() )
       
   581             {
       
   582             iSysApMMCObserver->StartMountObserver();
       
   583             }
       
   584         
   526         iSysApBtController = CreateSysApBtControllerL( *this );
   585         iSysApBtController = CreateSysApBtControllerL( *this );
   527         iSysApBtSapController = CreateSysApBtSapControllerL( *this );
   586         iSysApBtSapController = CreateSysApBtSapControllerL( *this );
   528 
   587 
   529         if ( iActivateBt )
   588         if ( iActivateBt )
   530             {
   589             {
   557     iSysApLightsController->AllowLightsOn();
   616     iSysApLightsController->AllowLightsOn();
   558     }
   617     }
   559 
   618 
   560 #endif // SYSAP_USE_STARTUP_UI_PHASE
   619 #endif // SYSAP_USE_STARTUP_UI_PHASE
   561 
   620 
       
   621 // ----------------------------------------------------------------------------
       
   622 // CSysApAppUi::~CSysApAppUi()
       
   623 // ----------------------------------------------------------------------------
       
   624 
   562 CSysApAppUi::~CSysApAppUi()
   625 CSysApAppUi::~CSysApAppUi()
   563     {
   626     {
   564     TRACES( RDebug::Print( _L("~CSysApAppUi() started") ) );
   627     TRACES( RDebug::Print( _L("~CSysApAppUi() started") ) );
   565     if( !iResourcesFreed )
   628     if( !iResourcesFreed )
   566       {
   629       {
   591         }
   654         }
   592     delete iAnimTimer;
   655     delete iAnimTimer;
   593 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   656 #endif // RD_STARTUP_ANIMATION_CUSTOMIZATION
   594 
   657 
   595     delete iSysApStartupController;
   658     delete iSysApStartupController;
       
   659 
       
   660 #ifdef RD_MULTIPLE_DRIVE
       
   661     iInsertedMemoryCards.Close();
       
   662     delete  iSysApDriveEjectHandler;
       
   663     delete iSysApDriveUnlockHandler;
       
   664     delete iSysApDriveList;
       
   665 #endif // RD_MULTIPLE_DRIVE
       
   666 
   596     TRACES( RDebug::Print( _L("~CSysApAppUi() completed") ) );
   667     TRACES( RDebug::Print( _L("~CSysApAppUi() completed") ) );
   597     }
   668     }
   598         
   669         
   599 TBool CSysApAppUi::ResourcesFreed() const
   670 TBool CSysApAppUi::ResourcesFreed() const
   600     {
   671     {
   601     return iResourcesFreed;
   672     return iResourcesFreed;
   602     }
   673     }
   603 
   674 
   604 void CSysApAppUi::ShowExampleUiNoteL( const TDesC& noteText )const
   675 void CSysApAppUi::ShowExampleUiNoteL( const TDesC& noteText )const
   605     {          
   676     {          
   606     //   QString msg  = QString::fromUtf16(aStringPointer.Ptr(),aStringPointer.Length());
       
   607  	TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: constructing CHbDeviceMessageBoxSymbian:BeGIN") ) );    
   677  	TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: constructing CHbDeviceMessageBoxSymbian:BeGIN") ) );    
   608     CHbDeviceMessageBoxSymbian *note = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EInformation);
   678     CHbDeviceMessageBoxSymbian *note = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EInformation);
   609  	CleanupStack::PushL(note);
   679  	CleanupStack::PushL(note);
   610     TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: construction of CHbDeviceMessageBoxSymbian:END") ) ); 
   680     TRACES( RDebug::Print( _L("CSysApAppUi::ShowExampleUiNoteL:: construction of CHbDeviceMessageBoxSymbian:END") ) ); 
   611 	//	HbMessageBox *note = new HbMessageBox (HbMessageBox ::MessageTypeInformation);
       
   612     note->SetTextL(noteText);
   681     note->SetTextL(noteText);
   613     //  note->SetTimeout(HbPopup::NoTimeout);
   682 	note->SetTimeout(300);
   614 	note->SetTimeout(5);
       
   615  	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::Begin") ) );    
   683  	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::Begin") ) );    
   616     note->ShowL();
   684     note->ShowL();
   617 	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::End") ) );
   685 	TRACES( RDebug::Print( _L("CSysApAppUi:: Display of  CHbDeviceMessageBoxSymbian::End") ) );
   618 	CleanupStack::PopAndDestroy(note);
   686 	CleanupStack::PopAndDestroy(note);
   619     }
   687     }
  1227         aUsbAttached ) );
  1295         aUsbAttached ) );
  1228 
  1296 
  1229     if ( aUsbAttached )
  1297     if ( aUsbAttached )
  1230         {
  1298         {
  1231           // For ignoring extra beeps caused by USB file transfer
  1299           // For ignoring extra beeps caused by USB file transfer
  1232 /*        iSysApDriveList->ResetDrivesInsertBeepIgnored();
  1300         iSysApDriveList->ResetDrivesInsertBeepIgnored();
  1233         iSysApDriveList->MarkDrivesInsertBeepIgnored( iInsertedMemoryCards );
  1301         iSysApDriveList->MarkDrivesInsertBeepIgnored( iInsertedMemoryCards );
  1234         // Will take care in next sub
  1302         }
  1235 */        }
       
  1236     }
  1303     }
  1237 #endif // RD_MULTIPLE_DRIVE
  1304 #endif // RD_MULTIPLE_DRIVE
  1238 
  1305 
  1239 
  1306 
  1240 // ----------------------------------------------------------------------------
  1307 // ----------------------------------------------------------------------------
  1484     else
  1551     else
  1485         {
  1552         {
  1486         // do nothing
  1553         // do nothing
  1487         }
  1554         }
  1488     }
  1555     }
       
  1556 
       
  1557 // ----------------------------------------------------------------------------
       
  1558 // CSysApAppUi::EjectStarted()
       
  1559 // ----------------------------------------------------------------------------
       
  1560 
       
  1561 void CSysApAppUi::EjectStarted( TBool ejectStarted )
       
  1562     {
       
  1563     TRACES( RDebug::Print( _L( "CSysApAppUi::EjectStarted" ) ) );
       
  1564     iMMCEjectUsed = ejectStarted;
       
  1565     
       
  1566 #ifndef RD_MULTIPLE_DRIVE
       
  1567     iFileManagerCloseDisabled = ejectStarted;
       
  1568 #endif // RD_MULTIPLE_DRIVE
       
  1569 }
  1489 
  1570 
  1490 // ----------------------------------------------------------------------------
  1571 // ----------------------------------------------------------------------------
  1491 // CSysApAppUi::DoLightsTimeoutChangedL
  1572 // CSysApAppUi::DoLightsTimeoutChangedL
  1492 // ----------------------------------------------------------------------------
  1573 // ----------------------------------------------------------------------------
  1493 void CSysApAppUi::DoLightsTimeoutChangedL( const TInt aTimeout )
  1574 void CSysApAppUi::DoLightsTimeoutChangedL( const TInt aTimeout )
  1893         iKeyLockOnBeforeCradle = EFalse;
  1974         iKeyLockOnBeforeCradle = EFalse;
  1894 
  1975 
  1895         // Memory card needs to be unlocked when device is unlocked
  1976         // Memory card needs to be unlocked when device is unlocked
  1896         if ( iSysApFeatureManager->MmcHotSwapSupported() )
  1977         if ( iSysApFeatureManager->MmcHotSwapSupported() )
  1897             {
  1978             {
  1898             // RunUnlockNotifierL();
  1979              RunUnlockNotifierL();
  1899             // Need to handle feature for unlocking the MMC card
  1980             // Need to handle feature for unlocking the MMC card
  1900             }
  1981             }
  1901         }
  1982         }
  1902     }
  1983     }
  1903 
  1984 
  2638         iSysApLightsController->KeylockStateChangedL( EFalse );
  2719         iSysApLightsController->KeylockStateChangedL( EFalse );
  2639         if ( iSysApFeatureManager->MmcHotSwapSupported() )
  2720         if ( iSysApFeatureManager->MmcHotSwapSupported() )
  2640             {
  2721             {
  2641             if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
  2722             if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
  2642                 {
  2723                 {
  2643                 // RunUnlockNotifierL();
  2724                  RunUnlockNotifierL();
  2644                 // need to handle MMC unlock query in next sub
  2725                 // need to handle MMC unlock query in next sub
  2645                 }
  2726                 }
  2646             }
  2727             }
  2647         }
  2728         }
  2648     }
  2729     }
  2713                         {
  2794                         {
  2714                         TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Short powerkey") ) );
  2795                         TRACES( RDebug::Print(_L("CSysApAppUi::HandleKeyEventL, Short powerkey") ) );
  2715                         iLastPowerKeyWasShort = ETrue;
  2796                         iLastPowerKeyWasShort = ETrue;
  2716                         TRACES( RDebug::Print( _L("CSysApAppUi::Key was consumed by pressing short power") ) );          
  2797                         TRACES( RDebug::Print( _L("CSysApAppUi::Key was consumed by pressing short power") ) );          
  2717                         //Powermenu
  2798                         //Powermenu
  2718                         if (iPowerMenuDialog != NULL)
  2799                         if (iPowerMenuDialog!=NULL)
  2719                             {
  2800                             {
  2720                             //PowerMenu already exist
  2801                             //PowerMenu already exist
  2721                             delete iPowerMenuDialog;
  2802                             delete iPowerMenuDialog;
  2722                             iPowerMenuDialog = NULL;
  2803                             iPowerMenuDialog = NULL;
  2723                             } 
  2804                             }                                               
  2724                             
  2805                         iPowerMenuDialog = CHbDevicePowerMenuSymbian::NewL(*this);  
  2725                         iPowerMenuDialog = CHbDevicePowerMenuSymbian::NewL(*this);
  2806                         iPowerMenuDialog->ShowL();           
  2726                         iPowerMenuDialog->ShowL();                        
  2807                                          
  2727                         iIgnoreNextPowerKeyRepeats = EFalse;
  2808                         iIgnoreNextPowerKeyRepeats = EFalse;
  2728                         }
  2809                         }
  2729                     //Long power key press
  2810                     //Long power key press
  2730                     else if( aKeyEvent.iRepeats > 0 && iKeyBoardRepeatCount >= iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApPowerkeyRepeatcount ))
  2811                     else if( aKeyEvent.iRepeats > 0 && iKeyBoardRepeatCount >= iSysApCenRepController->GetInt( KCRUidCoreApplicationUIsSysAp, KSysApPowerkeyRepeatcount ))
  2731                         {
  2812                         {
  2826         }
  2907         }
  2827     TRACES( RDebug::Print(_L("CSysApAppUi::ReleasePowerMenuCustomDialogMemory false") ) );                            
  2908     TRACES( RDebug::Print(_L("CSysApAppUi::ReleasePowerMenuCustomDialogMemory false") ) );                            
  2828     return EFalse;
  2909     return EFalse;
  2829     }
  2910     }
  2830 
  2911 
       
  2912 TBool CSysApAppUi::NotifiedDialogIfRequiredAndReleaseMemory()
       
  2913     {
       
  2914     TRACES( RDebug::Print(_L("CSysApAppUi::NotifiedDialogIfRequiredAndReleaseMemory(): Begin") ) );
       
  2915     TRACES( RDebug::Print(_L("CSysApAppUi::NotifiedDialogIfRequiredAndReleaseMemory(): Enter for popping another dialog") ) );
       
  2916     TInt popUpError = iSysApDriveUnlockHandler->CheckMemoryDialogIfNeeded();
       
  2917     
       
  2918     //Deside if dialog required again !!    
       
  2919     if(popUpError)
       
  2920         {
       
  2921         iSysApDriveUnlockHandler->ReleaseMemoryForInputCardDialog();  // check memory has released.
       
  2922         iSysApDriveUnlockHandler->UnlockComplete(KErrNone);
       
  2923         }
       
  2924     else
       
  2925         {
       
  2926         iSysApDriveUnlockHandler->StartUnlock();// pop up the dialog again !!        
       
  2927         }
       
  2928     
       
  2929     TRACES( RDebug::Print(_L("CSysApAppUi::NotifiedDialogIfRequiredAndReleaseMemory(): End")) );    
       
  2930     return popUpError;
       
  2931     }
       
  2932 
       
  2933 void CSysApAppUi::ReleaseMemoryForMemoryCardDialog()
       
  2934     {
       
  2935     TRACES( RDebug::Print(_L("CSysApAppUi::CSysApAppUi::ReleaseMemoryForMemoryCardDialog()")) );                                    
       
  2936     iSysApDriveUnlockHandler->ReleaseMemoryForInputCardDialog();
       
  2937     }
  2831 
  2938 
  2832 // ----------------------------------------------------------------------------
  2939 // ----------------------------------------------------------------------------
  2833 // CSysApAppUi::ShowAnimationL()
  2940 // CSysApAppUi::ShowAnimationL()
  2834 // ----------------------------------------------------------------------------
  2941 // ----------------------------------------------------------------------------
  2835 
  2942 
  2988 {
  3095 {
  2989 return iEikonEnv->AppUiFactory()->StatusPane();
  3096 return iEikonEnv->AppUiFactory()->StatusPane();
  2990 }
  3097 }
  2991  
  3098  
  2992 
  3099 
       
  3100 #ifndef RD_MULTIPLE_DRIVE
       
  3101 
       
  3102 // ----------------------------------------------------------------------------
       
  3103 // CSysApAppUi::EjectUsed
       
  3104 // ----------------------------------------------------------------------------
       
  3105 
       
  3106 void CSysApAppUi::EjectUsed( TInt /*aDrive*/ )
       
  3107     {
       
  3108     }
       
  3109 
       
  3110 #else // RD_MULTIPLE_DRIVE
  2993 
  3111 
  2994 // ----------------------------------------------------------------------------
  3112 // ----------------------------------------------------------------------------
  2995 // CSysApAppUi::ShowEjectWaitNoteL
  3113 // CSysApAppUi::ShowEjectWaitNoteL
  2996 // ----------------------------------------------------------------------------
  3114 // ----------------------------------------------------------------------------
  2997 
  3115 
  2998 //void CSysApAppUi::ShowEjectWaitNoteL( TInt /* aDriveToEject */ )
  3116 void CSysApAppUi::ShowEjectWaitNoteL( TInt /* aDriveToEject */ )
  2999  /*{
  3117     {
  3000    if ( iSysApWaitNote )
  3118  /*   if ( iSysApWaitNote )
  3001         {
  3119         {
  3002         return;
  3120         return;
  3003         }
  3121         }
  3004     HBufC* text = iSysApDriveList->GetFormattedDriveNameLC(
  3122     HBufC* text = iSysApDriveList->GetFormattedDriveNameLC(
  3005         aDriveToEject,
  3123         aDriveToEject,
  3007         R_QTN_EJECTING_MEMORY_NAME_WAIT );
  3125         R_QTN_EJECTING_MEMORY_NAME_WAIT );
  3008     iSysApWaitNote = CSysApWaitNote::NewL(
  3126     iSysApWaitNote = CSysApWaitNote::NewL(
  3009         iSysApFeatureManager->CoverDisplaySupported() );
  3127         iSysApFeatureManager->CoverDisplaySupported() );
  3010     iSysApWaitNote->ShowNoteL( EClosingApplicationsNote, text );
  3128     iSysApWaitNote->ShowNoteL( EClosingApplicationsNote, text );
  3011     CleanupStack::PopAndDestroy( text );
  3129     CleanupStack::PopAndDestroy( text );
  3012     }*/
  3130  */   }
       
  3131 
       
  3132 // ----------------------------------------------------------------------------
       
  3133 // CSysApAppUi::IsEjectQueryVisible
       
  3134 // ----------------------------------------------------------------------------
       
  3135 
       
  3136 TBool CSysApAppUi::IsEjectQueryVisible()
       
  3137     {
       
  3138 //    if ( !iSysApConfirmationQuery )
       
  3139         {
       
  3140         return EFalse;
       
  3141         }
       
  3142 //    TInt queryId( iSysApConfirmationQuery->CurrentQuery() );
       
  3143 //    return ( queryId == ESysApEjectMmcQuery || queryId == ESysApRemoveMmcNote );
       
  3144     }
       
  3145 
       
  3146 // ----------------------------------------------------------------------------
       
  3147 // CSysApAppUi::UpdateInsertedMemoryCardsL
       
  3148 // ----------------------------------------------------------------------------
       
  3149 
       
  3150 void CSysApAppUi::UpdateInsertedMemoryCardsL()
       
  3151     {
       
  3152     // Update inserted memory cards
       
  3153     iSysApDriveList->GetMemoryCardsL(
       
  3154         iInsertedMemoryCards, CSysApDriveList::EIncludeInserted );
       
  3155 
       
  3156     // Update memory card indicator status
       
  3157 //    SetMemoryCardIndicatorL();
       
  3158 
       
  3159     // Handle unlock
       
  3160     RunUnlockNotifierL();
       
  3161     }
       
  3162 
       
  3163 // ----------------------------------------------------------------------------
       
  3164 // CSysApAppUi::EjectUsed
       
  3165 // ----------------------------------------------------------------------------
       
  3166 
       
  3167 void CSysApAppUi::EjectUsed( TInt aDrive )
       
  3168     {
       
  3169     // Check drive inserted before starting eject confirm query
       
  3170     TInt insertedIndex( CSysApDriveList::Find( iInsertedMemoryCards, aDrive ) );
       
  3171 
       
  3172     TRACES( RDebug::Print(
       
  3173         _L( "CSysApAppUi::EjectUsed: drive: %d, index: %d" ),
       
  3174         aDrive, insertedIndex ) );
       
  3175 
       
  3176     if ( insertedIndex == KErrNotFound )
       
  3177         {
       
  3178         return;
       
  3179         }
       
  3180 
       
  3181     iMMCEjectUsed = ETrue;
       
  3182     iDriveToEject = aDrive;
       
  3183     iSysApDriveList->ResetDrivesToEject();
       
  3184     TRAPD( err, EjectMMCL() );
       
  3185     if ( err != KErrNone )
       
  3186         {
       
  3187         TRACES( RDebug::Print(
       
  3188             _L( "CSysApAppUi::EjectUsed: err: %d" ), err ) );
       
  3189         iMMCEjectUsed = EFalse;
       
  3190         }
       
  3191     }
       
  3192 #endif // RD_MULTIPLE_DRIVE
       
  3193 
       
  3194 
       
  3195 // ----------------------------------------------------------------------------
       
  3196 // CSysApAppUi::EjectMMCCanceled
       
  3197 // ----------------------------------------------------------------------------
       
  3198 
       
  3199 void CSysApAppUi::EjectMMCCanceled()
       
  3200     {
       
  3201     // Called from eject confirm query, reset eject status
       
  3202 #ifdef RD_MULTIPLE_DRIVE
       
  3203     iMMCEjectUsed = EFalse;
       
  3204 #endif // RD_MULTIPLE_DRIVE
       
  3205     }
       
  3206 
       
  3207 
       
  3208 
       
  3209 #ifndef RD_MULTIPLE_DRIVE
       
  3210 // ----------------------------------------------------------------------------
       
  3211 // CSysApAppUi::MountMMC()
       
  3212 // ----------------------------------------------------------------------------
       
  3213 
       
  3214 TInt CSysApAppUi::MountMMC()
       
  3215     {
       
  3216     TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC") ) );
       
  3217     TInt err ( KErrNotSupported );
       
  3218     if ( iSysApFeatureManager->MmcSupported() )
       
  3219         {
       
  3220 #ifdef __WINS__ // Let's sleep a second in WINS
       
  3221         User::After( 1000000 );
       
  3222 #endif
       
  3223         err = iEikonEnv->FsSession().MountFileSystem( KFSName, KMMCDrive );
       
  3224         TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC: RFs::MountFileSystem() returned: %d"), err ) );
       
  3225         if ( err == KErrInUse )
       
  3226             {
       
  3227             User::After( 1000000 );
       
  3228             err = iEikonEnv->FsSession().MountFileSystem( KFSName, KMMCDrive );
       
  3229             TRACES( RDebug::Print( _L("CSysApAppUi::MountMMC: RFs::MountFileSystem() returned: %d"), err ) );
       
  3230             }
       
  3231         }
       
  3232     return err;
       
  3233     }
       
  3234 
       
  3235 // ----------------------------------------------------------------------------
       
  3236 // CSysApAppUi::DismountMMC()
       
  3237 // ----------------------------------------------------------------------------
       
  3238 
       
  3239 TInt CSysApAppUi::DismountMMC()
       
  3240     {
       
  3241     TRACES( RDebug::Print( _L("CSysApAppUi::DismountMMC") ) );
       
  3242 #ifdef __WINS__ // Let's sleep a second in WINS
       
  3243         User::After( 1000000 );
       
  3244 #endif
       
  3245 
       
  3246     TInt err ( KErrNotSupported );
       
  3247     if ( iSysApFeatureManager->MmcSupported() )
       
  3248         {
       
  3249         err = iEikonEnv->FsSession().DismountFileSystem( KFSName, KMMCDrive );
       
  3250         TRACES( RDebug::Print( _L("CSysApAppUi::DismountMMC: RFs::DismountFileSystem() returned: %d"), err ) );
       
  3251         }
       
  3252     return err;
       
  3253     }
       
  3254 
       
  3255 // ----------------------------------------------------------------------------
       
  3256 // CSysApAppUi::EjectMMCL()
       
  3257 // ----------------------------------------------------------------------------
       
  3258 
       
  3259 void CSysApAppUi::EjectMMCL()
       
  3260     {
       
  3261     TRACES( RDebug::Print( _L("CSysApAppUi::EjectMMCL") ) );
       
  3262     iMMCEjectUsed = ETrue;
       
  3263     iMMCPowerMenuEjectUsed = ETrue;
       
  3264     iTimeToKill = EFalse;
       
  3265     iApplicationScanningRoundNumber = 0;
       
  3266     CloseUIAppsInHotSwapL();
       
  3267     }
       
  3268 
       
  3269 #else // RD_MULTIPLE_DRIVE
       
  3270 
       
  3271 // ----------------------------------------------------------------------------
       
  3272 // CSysApAppUi::EjectMMCL()
       
  3273 // ----------------------------------------------------------------------------
       
  3274 
       
  3275 void CSysApAppUi::EjectMMCL()
       
  3276     {
       
  3277     // Called from eject confirm query, check drive inserted before start
       
  3278     TInt insertedIndex( CSysApDriveList::Find(
       
  3279         iInsertedMemoryCards, iDriveToEject ) );
       
  3280 
       
  3281     TRACES( RDebug::Print(
       
  3282         _L( "CSysApAppUi::EjectMMCL: iMMCEjectUsed: %d, drive: %d, index: %d "),
       
  3283         iMMCEjectUsed, iDriveToEject, insertedIndex ) );
       
  3284 
       
  3285     if ( insertedIndex != KErrNotFound )
       
  3286         {
       
  3287         iSysApDriveList->MarkDriveToEject(
       
  3288             iDriveToEject, CSysApDriveList::EEjectFromMenu );
       
  3289         iSysApDriveEjectHandler->StartEject();
       
  3290         }
       
  3291     iMMCEjectUsed = EFalse;
       
  3292     }
       
  3293 
       
  3294 #endif // RD_MULTIPLE_DRIVE
       
  3295 
       
  3296 #ifndef RD_MULTIPLE_DRIVE
       
  3297 // ----------------------------------------------------------------------------
       
  3298 // CSysApAppUi::RunUnlockNotifierL()
       
  3299 // ----------------------------------------------------------------------------
       
  3300 
       
  3301 void CSysApAppUi::RunUnlockNotifierL( TSysApMemoryCardStatus aMemoryCardStatus )
       
  3302     {
       
  3303     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: START") ) );
       
  3304     if ( iSysApFeatureManager->MmcSupported() )
       
  3305         {
       
  3306         if ( UiReady() )
       
  3307             {
       
  3308             TSysApMemoryCardStatus memoryCardStatus;
       
  3309             if ( aMemoryCardStatus == ESysApMemoryCardStatusNotKnown )
       
  3310                 {
       
  3311                 memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
       
  3312                 }
       
  3313             else
       
  3314                 {
       
  3315                 memoryCardStatus = aMemoryCardStatus;
       
  3316                 }
       
  3317 
       
  3318             TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: memoryCardStatus=%d"), memoryCardStatus ) );
       
  3319 
       
  3320             switch ( memoryCardStatus )
       
  3321                 {
       
  3322                 case ESysApMemoryCardInserted:
       
  3323                     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC inserted") ) );
       
  3324                     if ( aMemoryCardStatus == ESysApMemoryCardInserted )
       
  3325                         {
       
  3326                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
       
  3327                         }
       
  3328                     break;
       
  3329                 case ESysApMemoryCardLocked:
       
  3330                     {
       
  3331                     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC locked") ) );
       
  3332                     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3333                     TInt callState = StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState );
       
  3334 
       
  3335                     if (  (! ( iDeviceLockEnabled || iKeyLockEnabled ) ) &&
       
  3336                           callState != EPSCTsyCallStateRinging && // We don't want to see the MMC passwd query
       
  3337                           callState != EPSCTsyCallStateAlerting ) // when the user is e.g. making an emergency call
       
  3338                         {
       
  3339                         if ( iSysApFeatureManager->MemoryCardLockSupported() )
       
  3340                             {
       
  3341                             if ( ! iMemoryCardDialog )
       
  3342                                 {
       
  3343                                 TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: ACTIVATE MMC passwd query") ) );
       
  3344                                 CAknMemoryCardDialog* mmcDialog = CAknMemoryCardDialog::NewLC( this );
       
  3345                                 iMemoryCardDialog = mmcDialog; // temporary variable used for hiding codescanner error 
       
  3346                                 iMemoryCardDialog->SetSelfPointer( &iMemoryCardDialog );
       
  3347                                 iMemoryCardDialog->UnlockCardLD(); // when UnlockCardLD completes it calls UnlockComplete()
       
  3348                                 }
       
  3349                             }
       
  3350                         else
       
  3351                             {
       
  3352                             // Since locked cards are not supported, notify user that card is locked.
       
  3353                             ShowQueryL( ESysApMemoryCardLockedNote );
       
  3354                             }
       
  3355                         }
       
  3356                     }
       
  3357                     break;
       
  3358 
       
  3359                 case ESysApMemoryCardNotInserted:
       
  3360                 default:
       
  3361                     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL MMC not inserted") ) );
       
  3362                     if ( aMemoryCardStatus == ESysApMemoryCardNotInserted )
       
  3363                         {
       
  3364                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3365                         }
       
  3366                 }
       
  3367             }
       
  3368         }
       
  3369     TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: END") ) );
       
  3370     }
       
  3371 
       
  3372 // ----------------------------------------------------------------------------
       
  3373 // CSysApAppUi::UnlockComplete() from MAknMemoryCardDialogObserver
       
  3374 // ----------------------------------------------------------------------------
       
  3375 
       
  3376 void CSysApAppUi::UnlockComplete( TInt aResult )
       
  3377     {
       
  3378     TRACES( RDebug::Print( _L("CSysApAppUi::UnlockComplete result: %d"), aResult ) );
       
  3379     if ( aResult == KErrNone )
       
  3380         {
       
  3381         RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
       
  3382         }
       
  3383     }
       
  3384 
       
  3385 // ----------------------------------------------------------------------------
       
  3386 // CSysApAppUi::MMCStatusChangedL() from MSysApMemoryCardObserver
       
  3387 // ----------------------------------------------------------------------------
       
  3388 
       
  3389 void CSysApAppUi::MMCStatusChangedL()
       
  3390     {
       
  3391     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL START: iMMCInserted: %d, iMMCEjectUsed: %d, iHideFirstBeep: %d, iHideNextBeep: %d" ), iMMCInserted, iMMCEjectUsed, iHideFirstBeep, iHideNextBeep ) );
       
  3392 
       
  3393     if ( iSysApFeatureManager->MmcSupported() && !iShutdownStarted )
       
  3394         {
       
  3395         TSysApMemoryCardStatus memoryCardStatus = iSysApMMCObserver->MemoryCardStatus();
       
  3396         TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL memoryCardStatus=%d" ), memoryCardStatus ) );
       
  3397 
       
  3398         switch ( memoryCardStatus )
       
  3399             {
       
  3400             case ESysApMemoryCardInserted:
       
  3401             case ESysApMemoryCardLocked:
       
  3402                 TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC drive mounted" ) ) );
       
  3403                 if ( ! iMMCInserted ) // MMC was not inserted before
       
  3404                     {
       
  3405                     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC newly inserted" ) ) );
       
  3406                     CancelWaitNote(); // just to be sure, the user might keep on closing and opening the MMC latch
       
  3407                     // An MMC has been newly inserted, so play a sound and check if its password protected
       
  3408 
       
  3409                     if ( UiReady() )
       
  3410                         {
       
  3411                         if ( !iHideFirstBeep && !iHideNextBeep ) // starting up
       
  3412                             {
       
  3413                             Beep();
       
  3414                             // Switch lights on
       
  3415                             iSysApLightsController->MemoryCardInsertedL();
       
  3416                             }
       
  3417                         iHideNextBeep = EFalse;
       
  3418                         }
       
  3419 
       
  3420                     iMMCPowerMenuEjectUsed = EFalse;
       
  3421                     iMMCEjectUsed = EFalse;
       
  3422                     iMMCInserted = ETrue;
       
  3423 
       
  3424                     // No need to show ESysApRemoveMmcNote after MMC already mounted
       
  3425                     if ( iSysApConfirmationQuery )
       
  3426                         {
       
  3427                         if ( iSysApConfirmationQuery->CurrentQuery() == ESysApRemoveMmcNote )
       
  3428                             {
       
  3429                             iSysApConfirmationQuery->Cancel();
       
  3430                             }
       
  3431                         }
       
  3432 
       
  3433                     // Check if the MMC is locked and unlock it if necessary
       
  3434                     RunUnlockNotifierL( memoryCardStatus );
       
  3435                     }
       
  3436                 break;
       
  3437             default:
       
  3438                 TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: MMC drive not mounted" ) ) );
       
  3439                 delete iMemoryCardDialog; // sets itself to null
       
  3440                 RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3441                 if ( iMMCInserted )
       
  3442                     {
       
  3443                     // No need to show ESysApEjectMmcQuery after MMC already removed
       
  3444                     if ( iSysApConfirmationQuery )
       
  3445                         {
       
  3446                         if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
       
  3447                             {
       
  3448                             iSysApConfirmationQuery->Cancel();
       
  3449                             }
       
  3450                         }
       
  3451 
       
  3452                     iMMCInserted = EFalse;
       
  3453 
       
  3454                     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  3455                     if ( !iMMCEjectUsed && propertyValue != KUsbPersonalityIdMS )
       
  3456                         {
       
  3457                         // if USB file transfer active, do not close applications
       
  3458                         // if eject selected in MMC App, MMC App takes care of the following and
       
  3459                         // if eject selected from powerkeymenu, applications have already been shutdown
       
  3460                         iTimeToKill = EFalse;
       
  3461                         iApplicationScanningRoundNumber = 0;
       
  3462                         CloseUIAppsInHotSwapL();
       
  3463                         }
       
  3464                     }
       
  3465                 else
       
  3466                     {
       
  3467                     // If MMC was not previously inserted and eject was chosed from power key menu, attempt to remount.
       
  3468                     if ( iMMCPowerMenuEjectUsed )
       
  3469                         {
       
  3470                         TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL: Attempt to remount" ) ) );
       
  3471                         MountMMC();
       
  3472                         // If mount was successful, unnecessary note will be canceled in insert notification handling.
       
  3473                         }
       
  3474                     }
       
  3475                 break;
       
  3476             }
       
  3477 
       
  3478         // Update memory card indicator status
       
  3479         SetMemoryCardIndicatorL();
       
  3480         }
       
  3481     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCStatusChangedL   END: iMMCInserted: %d, iMMCEjectUsed: %d, iHideFirstBeep: %d, iHideNextBeep: %d" ), iMMCInserted, iMMCEjectUsed, iHideFirstBeep, iHideNextBeep ) );
       
  3482     }
       
  3483 
       
  3484 // ----------------------------------------------------------------------------
       
  3485 // CSysApAppUi::ShowMMCDismountedDialogL()
       
  3486 // ----------------------------------------------------------------------------
       
  3487 
       
  3488 void CSysApAppUi::ShowMMCDismountedDialogL()
       
  3489     {
       
  3490     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  3491 
       
  3492     // Do not show any note if USB file transfer is active.
       
  3493     if ( propertyValue != KUsbPersonalityIdMS )
       
  3494         {
       
  3495         if ( iSysApFeatureManager->MemoryCardHatchSupported() )
       
  3496             { // MMC hatch has been opened and MMC has been dismounted
       
  3497             TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK." ) ) );
       
  3498             ShowQueryL( ESysApRemoveMmcNote );
       
  3499             }
       
  3500         else
       
  3501             {
       
  3502             // MMC has been removed and dismounted
       
  3503             TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: You might have lost some data." ) ) );
       
  3504             // No confirmation but let's set this true to enable MMC passwd query
       
  3505             ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
       
  3506             }
       
  3507         }
       
  3508     else
       
  3509         {
       
  3510         TRACES( RDebug::Print( _L( "CSysApAppUi::ShowMMCDismountedDialogL: No note shown, USB file transfer caused dismount." ) ) );
       
  3511         }
       
  3512     }
       
  3513 
       
  3514 // ----------------------------------------------------------------------------
       
  3515 // CSysApAppUi::MMCDismountedDialogConfirmed
       
  3516 // ----------------------------------------------------------------------------
       
  3517 
       
  3518 void CSysApAppUi::MMCDismountedDialogConfirmed()
       
  3519     {
       
  3520     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCDismountedDialogConfirmed") ) );
       
  3521 
       
  3522     // Try to remount just in case when eject was chosen from power key menu
       
  3523     if ( iMMCPowerMenuEjectUsed )
       
  3524         {
       
  3525         iMMCPowerMenuEjectUsed = EFalse;
       
  3526 
       
  3527         if ( MountMMC() == KErrLocked ) // In case a locked card was not removed after all
       
  3528             {
       
  3529             TRAPD( err, MMCStatusChangedL() ); // This will update power menu and memory card icon. Also memory card password is requeried.
       
  3530             if ( err != KErrNone )
       
  3531                 {
       
  3532                 TRACES( RDebug::Print( _L( "CSysApAppUi::MMCDismountedDialogConfirmed: MMCStatusChangedL failed, err=%d"), err ) );
       
  3533                 }
       
  3534             }
       
  3535         }
       
  3536 
       
  3537     }
       
  3538 
       
  3539 #else // RD_MULTIPLE_DRIVE
       
  3540 
       
  3541 // ----------------------------------------------------------------------------
       
  3542 // CSysApAppUi::MMCInsertedL
       
  3543 // ----------------------------------------------------------------------------
       
  3544 
       
  3545 void CSysApAppUi::MMCInsertedL()
       
  3546     {
       
  3547     TRACES( RDebug::Print( _L( "CSysApAppUi::MMCInsertedL") ) );
       
  3548 
       
  3549     if ( iSysApFeatureManager->MmcSupported() && !iShutdownStarted )
       
  3550         {
       
  3551         TBool normalState( UiReady() );
       
  3552 
       
  3553         if ( normalState )
       
  3554             {
       
  3555             TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
       
  3556             TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( defaultMemoryCard ) );
       
  3557 
       
  3558             TRACES( RDebug::Print(
       
  3559                 _L( "CSysApAppUi::MMCInsertedL: drive: %d, memoryCardStatus: %d" ), defaultMemoryCard, memoryCardStatus ) );
       
  3560 
       
  3561             switch ( memoryCardStatus )
       
  3562                 {
       
  3563                 case ESysApMemoryCardInserted: // Fall through
       
  3564                 case ESysApMemoryCardLocked:
       
  3565                     {
       
  3566                     // Reset eject and unlock of inserted memory card
       
  3567                     iSysApDriveList->ResetDriveToEject( defaultMemoryCard );
       
  3568                     iSysApDriveList->ResetDriveUnlockQueryShown( defaultMemoryCard );
       
  3569 
       
  3570 //                    CancelWaitNote();
       
  3571 
       
  3572                     if ( memoryCardStatus == ESysApMemoryCardInserted )
       
  3573                         {
       
  3574                         TRACES( RDebug::Print(
       
  3575                             _L( "CSysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardInserted: %d" ), memoryCardStatus ) );
       
  3576                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
       
  3577                         }
       
  3578                     else
       
  3579                         {
       
  3580                         TRACES( RDebug::Print(
       
  3581                             _L( "CSysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardLocked: %d" ), memoryCardStatus ) );
       
  3582                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3583                         }
       
  3584                     break;
       
  3585                     }
       
  3586                 case ESysApMemoryCardNotInserted:
       
  3587                     {
       
  3588                     // Always reset eject and unlock of removed memory card
       
  3589                     TBool isEject( iSysApDriveList->IsDriveToEject( defaultMemoryCard ) );
       
  3590 
       
  3591                     TRACES( RDebug::Print(
       
  3592                         _L( "CSysApAppUi::MMCInsertedL: isEject: %d, drive: %d" ),
       
  3593                         isEject, defaultMemoryCard ) );
       
  3594 
       
  3595                     iSysApDriveList->ResetDriveToEject( defaultMemoryCard );
       
  3596                     iSysApDriveList->ResetDriveUnlockQueryShown( defaultMemoryCard );
       
  3597 
       
  3598                     TRACES( RDebug::Print(
       
  3599                         _L( "SysApAppUi::MMCInsertedL: memoryCardStatus ESysApMemoryCardNotInserted: %d" ), memoryCardStatus ) );
       
  3600 
       
  3601                     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3602                     break;
       
  3603                     }
       
  3604                 case ESysApMemoryCardStatusNotKnown: // Fall through
       
  3605                 default:
       
  3606                     {
       
  3607                     break;
       
  3608                     }
       
  3609                 }
       
  3610                 RunUnlockNotifierL();
       
  3611             }
       
  3612         }
       
  3613     }
       
  3614 
       
  3615 
       
  3616 // ----------------------------------------------------------------------------
       
  3617 // CSysApAppUi::RunUnlockNotifierL()
       
  3618 // ----------------------------------------------------------------------------
       
  3619 
       
  3620 void CSysApAppUi::RunUnlockNotifierL()
       
  3621     {
       
  3622     TRACES( RDebug::Print(
       
  3623         _L("CSysApAppUi::RunUnlockNotifierL: START iDeviceLockEnabled: %d, iKeyLockEnabled: %d" ),
       
  3624          iDeviceLockEnabled, iKeyLockEnabled ) );
       
  3625 
       
  3626     if ( !iSysApFeatureManager->MmcSupported() ||
       
  3627          iDeviceLockEnabled ||
       
  3628          iKeyLockEnabled ||
       
  3629          !UiReady() )
       
  3630         {
       
  3631         TRACES( RDebug::Print( _L("CSysApAppUi::RunUnlockNotifierL: END") ) );
       
  3632         return;
       
  3633         }
       
  3634 
       
  3635     // We don't want to see the MMC passwd query
       
  3636     // when the user is e.g. making an emergency call
       
  3637     TInt callState( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) );
       
  3638     if ( callState != EPSCTsyCallStateRinging &&
       
  3639         callState != EPSCTsyCallStateAlerting )
       
  3640         {
       
  3641         TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
       
  3642         TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( defaultMemoryCard ) );
       
  3643         if ( memoryCardStatus == ESysApMemoryCardLocked)
       
  3644             {
       
  3645             iSysApDriveUnlockHandler->StartUnlock();
       
  3646             }
       
  3647         }
       
  3648 
       
  3649     TRACES( RDebug::Print(
       
  3650         _L("CSysApAppUi::RunUnlockNotifierL: END callState: %d"), callState ) );
       
  3651     }
       
  3652 
       
  3653 // ----------------------------------------------------------------------------
       
  3654 // CSysApAppUi::MMCStatusChangedL() from MSysApMemoryCardObserver
       
  3655 // ----------------------------------------------------------------------------
       
  3656 
       
  3657 void CSysApAppUi::MMCStatusChangedL( TInt aDrive )
       
  3658     {
       
  3659     TRACES( RDebug::Print(
       
  3660         _L( "CSysApAppUi::MMCStatusChangedL START: MMCCount: %d, iMMCEjectUsed: %d" ),
       
  3661         iInsertedMemoryCards.Count(), iMMCEjectUsed ) );
       
  3662 
       
  3663     if ( iShutdownStarted || !iSysApFeatureManager->MmcSupported() )
       
  3664         {
       
  3665         TRACES( RDebug::Print(
       
  3666             _L( "CSysApAppUi::MMCStatusChangedL iShutdownStarted: %d END" ),
       
  3667             iShutdownStarted ) );
       
  3668         return;
       
  3669         }
       
  3670 
       
  3671     TBool normalState( UiReady() );
       
  3672 
       
  3673     TInt defaultMemoryCard( iSysApDriveList->DefaultMemoryCard() );
       
  3674     TSysApMemoryCardStatus memoryCardStatus( iSysApDriveList->MemoryCardStatus( aDrive ) );
       
  3675     TInt insertedIndex( CSysApDriveList::Find( iInsertedMemoryCards, aDrive ) );
       
  3676 
       
  3677     TRACES( RDebug::Print(
       
  3678         _L( "CSysApAppUi::MMCStatusChangedL: normalState: %d, index: %d, drive: %d, memoryCardStatus: %d" ),
       
  3679         normalState, insertedIndex, aDrive, memoryCardStatus ) );
       
  3680 
       
  3681     switch ( memoryCardStatus )
       
  3682         {
       
  3683         case ESysApMemoryCardInserted: // Fall through
       
  3684         case ESysApMemoryCardLocked:
       
  3685             {
       
  3686             if ( insertedIndex == KErrNotFound ) // Not inserted before
       
  3687                 {
       
  3688                 // Reset eject and unlock of inserted memory card
       
  3689                 iSysApDriveList->ResetDriveToEject( aDrive );
       
  3690                 iSysApDriveList->ResetDriveUnlockQueryShown( aDrive );
       
  3691 
       
  3692 //                CancelWaitNote();
       
  3693 
       
  3694                 if ( aDrive == defaultMemoryCard )
       
  3695                     {
       
  3696                     if ( memoryCardStatus == ESysApMemoryCardInserted )
       
  3697                         {
       
  3698                          RProperty::Set( KPSUidUikon, KUikMMCInserted, 1 );
       
  3699                         }
       
  3700                     else
       
  3701                         {
       
  3702                         RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3703                         }
       
  3704                     }
       
  3705 
       
  3706                 if ( normalState )
       
  3707                     {
       
  3708                     // Ignore extra beep from USB file transfer
       
  3709                     TBool ignoreBeep(
       
  3710                         iSysApDriveList->IsDriveInsertBeepIgnored( aDrive ) );
       
  3711 
       
  3712                     TRACES( RDebug::Print(
       
  3713                         _L( "CSysApAppUi::MMCStatusChangedL: ignoreBeep: %d, drive: %d" ),
       
  3714                         ignoreBeep, aDrive ) );
       
  3715 
       
  3716                     if ( !ignoreBeep )
       
  3717                         {
       
  3718 //                        Beep();
       
  3719                         iSysApLightsController->MemoryCardInsertedL();
       
  3720                         }
       
  3721 
       
  3722                     iSysApDriveList->ResetDriveInsertBeepIgnored( aDrive );
       
  3723 
       
  3724                     // Keep ignoring extra beep if USB file transfer is active
       
  3725                     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  3726 
       
  3727                     TRACES( RDebug::Print(
       
  3728                         _L( "CSysApAppUi::MMCStatusChangedL: usbState: %d" ), propertyValue ) );
       
  3729 
       
  3730                     if ( propertyValue == KUsbPersonalityIdMS )
       
  3731                         {
       
  3732                         iSysApDriveList->MarkDriveInsertBeepIgnored( aDrive );
       
  3733                         }
       
  3734                     }
       
  3735 
       
  3736 //                if ( iDriveToDismount == aDrive && iSysApConfirmationQuery )
       
  3737                     {
       
  3738 //                    if ( iSysApConfirmationQuery->CurrentQuery() == ESysApRemoveMmcNote )
       
  3739                         {
       
  3740                         // User put back ejected memory card or did not remove it
       
  3741 //                        iSysApConfirmationQuery->Cancel();
       
  3742                         }
       
  3743                     }
       
  3744                 RunUnlockNotifierL();
       
  3745                 }
       
  3746             break;
       
  3747             }
       
  3748         case ESysApMemoryCardNotInserted:
       
  3749             {
       
  3750             // Always reset eject and unlock of removed memory card
       
  3751             TBool isEject( iSysApDriveList->IsDriveToEject( aDrive ) );
       
  3752 
       
  3753             TRACES( RDebug::Print(
       
  3754                 _L( "CSysApAppUi::MMCStatusChangedL: isEject: %d, drive: %d" ),
       
  3755                 isEject, aDrive ) );
       
  3756 
       
  3757             iSysApDriveList->ResetDriveToEject( aDrive );
       
  3758             iSysApDriveList->ResetDriveUnlockQueryShown( aDrive );
       
  3759 
       
  3760             if ( insertedIndex != KErrNotFound ) // Inserted before
       
  3761                 {
       
  3762                 if ( memoryCardStatus == ESysApMemoryCardNotInserted )
       
  3763                     {
       
  3764                     // Reset extra beep ignore if memory card was removed without eject
       
  3765                     iSysApDriveList->ResetDriveInsertBeepIgnored( aDrive );
       
  3766                     }
       
  3767 
       
  3768 //                CancelGlobalListQuery(); // Cancel power menu
       
  3769 
       
  3770                 if ( aDrive == defaultMemoryCard )
       
  3771                     {
       
  3772                     RProperty::Set( KPSUidUikon, KUikMMCInserted, 0 );
       
  3773                     }
       
  3774 
       
  3775 //                if ( iSysApConfirmationQuery )
       
  3776                     {
       
  3777 //                    if ( iSysApConfirmationQuery->CurrentQuery() == ESysApEjectMmcQuery )
       
  3778                         {
       
  3779                         // User removed memory card too early
       
  3780 //                        iSysApConfirmationQuery->Cancel();
       
  3781                         // Allow application closing to execute.
       
  3782                         // Also FileManager is closed in this case, regardless where the eject was initiated from.
       
  3783                         iMMCEjectUsed = EFalse;
       
  3784                         }
       
  3785                     }
       
  3786 
       
  3787                 // Stop unlock of removed memory card
       
  3788                 iSysApDriveUnlockHandler->StopUnlock( aDrive );
       
  3789 
       
  3790                 if ( !iMMCEjectUsed && !isEject )
       
  3791                     {
       
  3792                     TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  3793 
       
  3794                     TRACES( RDebug::Print(
       
  3795                         _L( "CSysApAppUi::MMCStatusChangedL: usbState: %d" ), propertyValue ) );
       
  3796 
       
  3797                     if ( propertyValue != KUsbPersonalityIdMS )
       
  3798                         {
       
  3799                         if ( iSysApFeatureManager->MemoryCardHatchSupported() )
       
  3800                             {
       
  3801                             // Store drive removed without eject and start eject handling
       
  3802                             iSysApDriveList->MarkDriveToEject(
       
  3803                                 aDrive, CSysApDriveList::EEjectRemovedWithoutEject );
       
  3804                             iSysApDriveEjectHandler->StartEject();
       
  3805                             }
       
  3806                         else
       
  3807                             {
       
  3808                             // Just show the note
       
  3809                             ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
       
  3810                             }
       
  3811                         }
       
  3812                     }
       
  3813                 iMMCEjectUsed = EFalse;
       
  3814                 }
       
  3815             break;
       
  3816             }
       
  3817         case ESysApMemoryCardStatusNotKnown: // Fall through
       
  3818         default:
       
  3819             {
       
  3820             break;
       
  3821             }
       
  3822         }
       
  3823 
       
  3824     // Update inserted memory cards
       
  3825     iSysApDriveList->GetMemoryCardsL(
       
  3826         iInsertedMemoryCards, CSysApDriveList::EIncludeInserted );
       
  3827 
       
  3828     // Update memory card indicator status
       
  3829 //    SetMemoryCardIndicatorL();
       
  3830 
       
  3831     TRACES( RDebug::Print(
       
  3832         _L( "CSysApAppUi::MMCStatusChangedL END: MMCCount: %d, iMMCEjectUsed: %d" ),
       
  3833         iInsertedMemoryCards.Count(), iMMCEjectUsed ) );
       
  3834     }
       
  3835 
       
  3836 // ----------------------------------------------------------------------------
       
  3837 // CSysApAppUi::ShowMMCDismountedDialogL()
       
  3838 // ----------------------------------------------------------------------------
       
  3839 
       
  3840 TBool CSysApAppUi::ShowMMCDismountedDialogL(
       
  3841         TInt aDrive, CSysApDriveList::TDriveEjectType aEjectType )
       
  3842     {
       
  3843     TRACES( RDebug::Print(
       
  3844         _L( "CSysApAppUi::ShowMMCDismountedDialogL: aDrive: %d, aEjectType: %d" ),
       
  3845         aDrive, aEjectType ) );
       
  3846 
       
  3847     TBool ret( EFalse );
       
  3848     iDriveToDismount = aDrive;
       
  3849     HBufC* driveName = iSysApDriveList->GetFormattedDriveNameLC(
       
  3850         aDrive,
       
  3851         R_QTN_EJECT_REMOVE_MEMORY_INFO );
       
  3852 
       
  3853     if ( aEjectType == CSysApDriveList::EEjectFromMenu )
       
  3854         {
       
  3855         TRACES( RDebug::Print(
       
  3856             _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK...." ) ) );
       
  3857         ShowQueryL( ESysApRemoveMmcNote, *driveName );
       
  3858         ret = ETrue;
       
  3859         }
       
  3860     else
       
  3861         {
       
  3862         // Memory card was removed without eject
       
  3863         TInt propertyValue( StateOfProperty( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality ) );
       
  3864 
       
  3865         // Do not show any note if USB file transfer is active.
       
  3866         if ( propertyValue != KUsbPersonalityIdMS )
       
  3867             {
       
  3868             if ( iSysApFeatureManager->MemoryCardHatchSupported() )
       
  3869                 {
       
  3870                 // MMC hatch has been opened and MMC has been dismounted
       
  3871                 TRACES( RDebug::Print(
       
  3872                     _L( "CSysApAppUi::ShowMMCDismountedDialogL: Show note: Remove MMC and press OK." ) ) );
       
  3873                 ShowQueryL( ESysApRemoveMmcNote, *driveName );
       
  3874                 ret = ETrue;
       
  3875                 }
       
  3876             else
       
  3877                 {
       
  3878                 iSysApDriveList->ResetDrivesToEject();
       
  3879 
       
  3880                 // MMC has been removed and dismounted
       
  3881                 TRACES( RDebug::Print( _L(
       
  3882                     "CSysApAppUi::ShowMMCDismountedDialogL: Show note: You might have lost some data." ) ) );
       
  3883 
       
  3884                 // No confirmation but let's set this true to enable MMC passwd query
       
  3885                 ShowUiNoteL( EMemoryCardRemovedWithoutEjectNote );
       
  3886                 }
       
  3887             }
       
  3888         else
       
  3889             {
       
  3890             iSysApDriveList->ResetDrivesToEject();
       
  3891             TRACES( RDebug::Print(
       
  3892                 _L( "CSysApAppUi::ShowMMCDismountedDialogL: No note shown, USB file transfer caused dismount." ) ) );
       
  3893             }
       
  3894         }
       
  3895 
       
  3896     CleanupStack::PopAndDestroy( driveName );
       
  3897 
       
  3898     TRACES( RDebug::Print(
       
  3899         _L( "CSysApAppUi::ShowMMCDismountedDialogL: ret: %d" ), ret ) );
       
  3900 
       
  3901     return ret;
       
  3902     }
       
  3903 
       
  3904 // ----------------------------------------------------------------------------
       
  3905 // CSysApAppUi::MMCDismountedDialogConfirmed
       
  3906 // ----------------------------------------------------------------------------
       
  3907 
       
  3908 void CSysApAppUi::MMCDismountedDialogConfirmed()
       
  3909     {
       
  3910     TRACES( RDebug::Print(
       
  3911         _L( "CSysApAppUi::MMCDismountedDialogConfirmed: iDriveToDismount: %d" ),
       
  3912         iDriveToDismount ) );
       
  3913 
       
  3914     // Try remount to check if drive was put back
       
  3915     iSysApDriveList->MountDrive( iDriveToDismount );
       
  3916     if ( !iSysApDriveEjectHandler->CompleteDismount( iDriveToDismount ) )
       
  3917         {
       
  3918         // When ready, check for locked memory cards and update indicators
       
  3919  //       TRAP_IGNORE( SetMemoryCardIndicatorL() );
       
  3920         TRAP_IGNORE( RunUnlockNotifierL() );
       
  3921         }
       
  3922     }
       
  3923 
       
  3924 #endif // RD_MULTIPLE_DRIVE
  3013 
  3925 
  3014 
  3926 
  3015 // ----------------------------------------------------------------------------
  3927 // ----------------------------------------------------------------------------
  3016 // CSysApAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
  3928 // CSysApAppUi::HandleApplicationSpecificEventL(TInt aType,const TWsEvent& aEvent)
  3017 // ----------------------------------------------------------------------------
  3929 // ----------------------------------------------------------------------------
  3045                 iSysApLightsController->KeylockStateChangedL( EFalse );
  3957                 iSysApLightsController->KeylockStateChangedL( EFalse );
  3046                 if ( iSysApFeatureManager->MmcHotSwapSupported() )
  3958                 if ( iSysApFeatureManager->MmcHotSwapSupported() )
  3047                     {
  3959                     {
  3048                     if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
  3960                     if ( StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateRinging && StateOfProperty( KPSUidCtsyCallInformation, KCTsyCallState ) !=  EPSCTsyCallStateAlerting )
  3049                         {
  3961                         {
  3050                         //RunUnlockNotifierL();
  3962                         RunUnlockNotifierL();
  3051                         }
  3963                         }
  3052                     }
  3964                     }
  3053                 }
  3965                 }
  3054             break;
  3966             break;
  3055         case EEikKeyLockPowerKeyPressed: //sent when power key is captured by keylockserver
  3967         case EEikKeyLockPowerKeyPressed: //sent when power key is captured by keylockserver