diff -r 5cc91383ab1e -r 7333d7932ef7 appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp --- a/appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp Thu Aug 19 10:02:49 2010 +0300 +++ b/appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp Tue Aug 31 15:21:33 2010 +0300 @@ -18,18 +18,26 @@ // INCLUDE FILES -#include -#include -#include -#include -#include - +#include +#include +#include +#include +//#include // For system state +//#include +//#include // KUIFrameworkDomain #include "DialogWrapper.h" #include "SWInstDebug.h" -_LIT( KDaemonResourceFile, "swidaemon.rsc" ); +using namespace Swi; -using namespace Swi; +// Time interval for progress dialog. +const TUint KDialogTimeOut = 5000000; +// Indicator type +_LIT( KIndicatorTypeSWIDaemon, + "com.nokia.sisxsilentinstall.indicatorplugin/1.0" ); + +//TODO: remove when HB dialogs do not crash in HW/WINS +//#define _SWIDAEMON_DISABLE_NOTES_ // ============================ MEMBER FUNCTIONS =============================== @@ -51,23 +59,17 @@ // void CDialogWrapper::ConstructL() { - // Get resource file path - TFileName fileName; - fileName.Copy( TParsePtrC( RProcess().FileName() ).Drive() ); - fileName.Append( KDC_RESOURCE_FILES_DIR ); - fileName.Append( KDaemonResourceFile ); - - // Get language of resource file - BaflUtils::NearestLanguageFile( iFs, fileName ); - - // Open resource file - iResourceFile.OpenL( iFs, fileName ); - iResourceFile.ConfirmSignatureL(); - + iIsProgressDialog = EFalse; + iHbProgressDialog = NULL; + iIsUninstallerProgressDialog = EFalse; + iHbProgressDialogForUninstaller = NULL; + iIsIndicator = EFalse; + iHbIndicator = NULL; // By default Daemon will show all notes. - iDisableAllNotes = EFalse; + iDisableAllNotes = EFalse; + iTimeOffDisableProgress = EFalse; // Create watcher AO for PS Key. - iWatcher = CDialogWatcher::NewL( this ); + iWatcher = CDialogWatcher::NewL( this ); // Get current PS Key TInt err = iWatcher->GetPSKeyForUI( iDisableAllNotes ); if ( err ) @@ -76,7 +78,9 @@ iDisableAllNotes = ETrue; } // Start AO - iWatcher->StartWatcher(); + iWatcher->StartWatcher(); + // Create dialog timer for progress dialog. + iTimer = CDialogTimer::NewL( this ); } // ----------------------------------------------------------------------------- @@ -92,16 +96,42 @@ CleanupStack::Pop( self ); return self; } - + +// ----------------------------------------------------------------------------- +// CDialogWrapper::~CDialogWrapper // Destructor +// ----------------------------------------------------------------------------- +// CDialogWrapper::~CDialogWrapper() { - iResourceFile.Close(); + FLOG( _L("Daemon: CDialogWrapper::~CDialogWrapper") ); + delete iTimer; + + // If installer's RunL leaves make sure that dialogs are closed. + if ( iIsProgressDialog && iHbProgressDialog ) + { + iHbProgressDialog->Close(); + } + delete iHbProgressDialog; + + // If uninstaller's RunL leaves make sure that dialogs are closed. + if ( iIsUninstallerProgressDialog && iHbProgressDialogForUninstaller ) + { + iHbProgressDialogForUninstaller->Close(); + } + delete iHbProgressDialogForUninstaller; + + if ( iIsIndicator && iHbIndicator ) + { + iHbIndicator->Deactivate( KIndicatorTypeSWIDaemon ); + } + delete iHbIndicator; + if ( iWatcher ) { - iWatcher->StopWatcher(); - delete iWatcher; - } + iWatcher->StopWatcher(); + } + delete iWatcher; } // ----------------------------------------------------------------------------- @@ -111,17 +141,38 @@ // ----------------------------------------------------------------------------- // void CDialogWrapper::ShowUntrustedResultL() - { + { + FLOG( _L("Daemon: CDialogWrapper::ShowUntrustedResultL") ); + +#ifdef _SWIDAEMON_DISABLE_NOTES_ + FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") ); + iDisableAllNotes = ETrue; +#endif + // Let watcher to know that waiting note is canceled. - iWatcher->CancelNoteRequest(); - - if ( iDisableAllNotes == EFalse ) + iWatcher->CancelNoteRequest(); + + // Inform watcher that we have request to show note. + iWatcher->CancelNoteRequest(); + + if ( !iDisableAllNotes ) { - HBufC* string = ReadResourceLC( R_DAEMON_UNTRUSTED_FOUND ); - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - note->ShowNoteL( EAknGlobalInformationNote, *string ); - CleanupStack::PopAndDestroy( 2, string ); - } + CHbDeviceNotificationDialogSymbian* notificationDialog = + CHbDeviceNotificationDialogSymbian::NewL( NULL ); + + CleanupStack::PushL( notificationDialog ); + +//TODO get string from log file. + _LIT( KTempIconText,"note_info"); + _LIT( KTempTextTitle,"SW Silent Installer" ); + _LIT( KTempTextForErrorMessage,"Untrusted software was found." ); + + notificationDialog->NotificationL( KTempIconText, + KTempTextTitle , + KTempTextForErrorMessage ); + + CleanupStack::PopAndDestroy( notificationDialog ); + } } // ----------------------------------------------------------------------------- @@ -132,15 +183,33 @@ // void CDialogWrapper::ShowErrorResultL() { - // Let watcher to know that waiting note is canceled. - iWatcher->CancelNoteRequest(); + FLOG( _L("Daemon: CDialogWrapper::ShowErrorResultL") ); + +#ifdef _SWIDAEMON_DISABLE_NOTES_ + FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") ); + iDisableAllNotes = ETrue; +#endif - if ( iDisableAllNotes == EFalse ) - { - HBufC* string = ReadResourceLC( R_DAEMON_INSTALLATION_ERROR ); - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - note->ShowNoteL( EAknGlobalInformationNote, *string ); - CleanupStack::PopAndDestroy( 2, string ); + // Inform watcher that we have request to show note. + iWatcher->CancelNoteRequest(); + + if ( !iDisableAllNotes ) + { + CHbDeviceNotificationDialogSymbian* notificationDialog = + CHbDeviceNotificationDialogSymbian::NewL( NULL ); + + CleanupStack::PushL( notificationDialog ); + +//TODO get string from log file. + _LIT( KTempIconText,"note_info"); + _LIT( KTempTextTitle,"SW Silent Installer" ); + _LIT( KTempTextForErrorMessage,"Installation was not completed." ); + + notificationDialog->NotificationL( KTempIconText, + KTempTextTitle , + KTempTextForErrorMessage ); + + CleanupStack::PopAndDestroy( notificationDialog ); } } @@ -152,15 +221,33 @@ // void CDialogWrapper::ShowWaitingNoteL() { - if ( iDisableAllNotes == EFalse ) - { - if ( iNoteId == 0 ) - { - HBufC* string = ReadResourceLC( R_DAEMON_INSTALLING ); - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY ); - iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string ); - CleanupStack::PopAndDestroy( 2, string ); + FLOG( _L("Daemon: CDialogWrapper::ShowWaitingNoteL") ); + +#ifdef _SWIDAEMON_DISABLE_NOTES_ + FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") ); + iDisableAllNotes = ETrue; +#endif + + FLOG_1( _L("Daemon: iDisableAllNotes: %d"), iDisableAllNotes ); + FLOG_1( _L("Daemon: iIsProgressDialog: %d"), iIsProgressDialog ); + FLOG_1( _L("Daemon: iTimeOffDisableProgress: %d"), iTimeOffDisableProgress ); + + if ( !iDisableAllNotes ) + { + if ( !iIsProgressDialog && !iTimeOffDisableProgress ) + { + iHbProgressDialog = CHbDeviceProgressDialogSymbian::NewL( + CHbDeviceProgressDialogSymbian::EWaitDialog, + NULL ); + iIsProgressDialog = ETrue; + + _LIT( KTempTextForProgressDialog,"Installing" ); + + iHbProgressDialog->SetTextL( KTempTextForProgressDialog ); + FLOG( _L("Daemon: ShowWaitingNoteL: ShowL") ); + iHbProgressDialog->ShowL(); + FLOG( _L("Daemon: ShowWaitingNoteL: StartDialogTimer") ); + iTimer->StartDialogTimer( KDialogTimeOut ); } } else if ( iDisableAllNotes ) @@ -177,32 +264,35 @@ // (other items were commented in a header). // ----------------------------------------------------------------------------- // -void CDialogWrapper::CancelWaitingNoteL() - { - if ( iNoteId ) +void CDialogWrapper::CancelWaitingNote() + { + FLOG( _L("Daemon: CDialogWrapper::CancelWaitingNoteL") ); + + if ( iIsProgressDialog ) { - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - note->CancelNoteL( iNoteId ); - iNoteId = 0; - CleanupStack::PopAndDestroy(); + iHbProgressDialog->Close(); + delete iHbProgressDialog; + //Make sure not to delete twice in destructor. + iHbProgressDialog = NULL; + iIsProgressDialog = EFalse; + + iTimeOffDisableProgress = ETrue; } + // Let watcher to know that waiting note is canceled. iWatcher->CancelNoteRequest(); } -// CDialogWrapper::LoadResourceLC + +// ----------------------------------------------------------------------------- +// CDialogWrapper::LoadResourceLC // Read resource string. // (other items were commented in a header). // ----------------------------------------------------------------------------- // -HBufC* CDialogWrapper::ReadResourceLC( TInt aResourceId ) +HBufC* CDialogWrapper::ReadResourceLC( TInt /*aResourceId*/ ) { - TResourceReader reader; - HBufC8* buff = iResourceFile.AllocReadLC( aResourceId ); - reader.SetBuffer( buff ); - HBufC* text = reader.ReadHBufCL(); - CleanupStack::PopAndDestroy( buff ); - CleanupStack::PushL( text ); - return text; + //TODO: All resoureces nees to be rewriten for device dialogs (QT) + return NULL; } // ----------------------------------------------------------------------------- @@ -222,15 +312,33 @@ // void CDialogWrapper::ShowWaitingNoteForUninstallerL() { - if ( iDisableAllNotes == EFalse ) + FLOG( _L("Daemon: CDialogWrapper::ShowWaitingNoteForUninstallerL") ); + +#ifdef _SWIDAEMON_DISABLE_NOTES_ + FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") ); + iDisableAllNotes = ETrue; +#endif + + FLOG_1( _L("Daemon: iDisableAllNotes: %d"), iDisableAllNotes ); + FLOG_1( _L("Daemon: iIsProgressDialog: %d"), iIsProgressDialog ); + FLOG_1( _L("Daemon: iTimeOffDisableProgress: %d"), iTimeOffDisableProgress ); + + if ( !iDisableAllNotes ) { - if ( iNoteId == 0 ) - { - HBufC* string = ReadResourceLC( R_UNINSTALLER_INSTALL ); - CAknGlobalNote* note = CAknGlobalNote::NewLC(); - note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY ); - iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string ); - CleanupStack::PopAndDestroy( 2, string ); + if ( !iIsUninstallerProgressDialog && !iTimeOffDisableProgress ) + { + iHbProgressDialogForUninstaller = + CHbDeviceProgressDialogSymbian::NewL( + CHbDeviceProgressDialogSymbian::EWaitDialog, + NULL ); + iIsUninstallerProgressDialog = ETrue; + //TODO get string from log file. + _LIT( KTempTextForProgressDialog,"Uninstalling" ); + iHbProgressDialogForUninstaller->SetTextL( KTempTextForProgressDialog ); + FLOG( _L("Daemon: ShowWaitingNoteForUninstallerL: ShowL") ); + iHbProgressDialogForUninstaller->ShowL(); + FLOG( _L("Daemon: ShowWaitingNoteForUninstallerL: StartDialogTimer") ); + iTimer->StartDialogTimer( KDialogTimeOut ); } } else if ( iDisableAllNotes ) @@ -240,4 +348,275 @@ iWatcher->RequestToDisplayNote(); } } + +// ----------------------------------------------------------------------------- +// CDialogWrapper::CancelWaitingNoteL +// Cancel global waiting note after installing. +// (other items were commented in a header). +// ----------------------------------------------------------------------------- +// +void CDialogWrapper::CancelWaitingNoteForUninstaller() + { + FLOG( _L("Daemon: CDialogWrapper::CancelWaitingNoteForUninstallerL") ); + + if ( iIsUninstallerProgressDialog ) + { + iHbProgressDialogForUninstaller->Close(); + delete iHbProgressDialogForUninstaller; + //Make sure not to delete twice in destructor. + iHbProgressDialogForUninstaller = NULL; + iIsUninstallerProgressDialog = EFalse; + + iTimeOffDisableProgress = ETrue; + } + + // Let watcher to know that waiting note is canceled. + iWatcher->CancelNoteRequest(); + } + +// ----------------------------------------------------------------------------- +// CDialogWrapper::ActivateIndicatorL() +// +// ----------------------------------------------------------------------------- +// +void CDialogWrapper::ActivateIndicatorL( TReal aProcessValue ) + { + FLOG( _L("Daemon: CDialogWrapper::ActivateIndicatorL") ); + + if ( !iIsIndicator ) + { + FLOG( _L("Daemon: CHbIndicatorSymbian::NewL") ); + iHbIndicator = CHbIndicatorSymbian::NewL(); + iIsIndicator = ETrue; + } + + TInt value = static_cast( aProcessValue ); + FLOG_1( _L("Daemon: ActivateIndicatorL: precent value: %d"), value ); + + CHbSymbianVariant* hbParam = CHbSymbianVariant::NewL( + &value, + CHbSymbianVariant::EInt ); + CleanupStack::PushL( hbParam ); + + FLOG( _L("Daemon: ActivateIndicatorL: Activate") ); + iHbIndicator->Activate( KIndicatorTypeSWIDaemon, hbParam ); + + CleanupStack::PopAndDestroy( hbParam ); + } + +// ----------------------------------------------------------------------------- +// CDialogWrapper::SetModeToIndicatorL() +// +// ----------------------------------------------------------------------------- +// +void CDialogWrapper::SetModeToIndicatorL( TInt aMode ) + { + FLOG_1( _L("Daemon: CDialogWrapper::SetModeToIndicatorL: aMode: %d"), + aMode ); + + if ( !iIsIndicator ) + { + FLOG( _L("Daemon: CHbIndicatorSymbian::NewL") ); + iHbIndicator = CHbIndicatorSymbian::NewL(); + iIsIndicator = ETrue; + } + // Set mode. + TReal mode = aMode; + CHbSymbianVariant* hbParam = CHbSymbianVariant::NewL( + &mode, + CHbSymbianVariant::EReal ); + CleanupStack::PushL( hbParam ); + FLOG( _L("Daemon: SetModeToIndicatorL: Activate") ); + iHbIndicator->Activate( KIndicatorTypeSWIDaemon, hbParam ); + + CleanupStack::PopAndDestroy( hbParam ); + } + + +// ----------------------------------------------------------------------------- +// CDialogWrapper::CancelIndicatorL +// +// ----------------------------------------------------------------------------- +// +void CDialogWrapper::CancelIndicatorL() + { + FLOG( _L("Daemon: CDialogWrapper::CancelIndicatorL") ); + + if ( iIsIndicator ) + { + FLOG( _L("Daemon: CancelIndicatorL: Deactivate") ); + iHbIndicator->Deactivate( KIndicatorTypeSWIDaemon ); + delete iHbIndicator; + iHbIndicator = NULL; //Make sure not to delete twice in destructor. + iIsIndicator = EFalse; + } + } + +// ----------------------------------------------------------------------------- +// CDialogWrapper::CheckSystemState() +// +// ----------------------------------------------------------------------------- +// +/* +void CDialogWrapper::CheckSystemState() + { + FLOG( _L("Daemon: CDialogWrapper::CheckSystemState TEST") ); + + // We need to check this only if system is not ready to show + // dialogs e.g. UI is not up. + if ( !iSystemReadyToShowDialogs ) + { + RSsmStateAwareSession systemStateSession; + + TInt err = systemStateSession.Connect( KUIFrameworkDomain3 ); + FLOG_1( _L("Daemon: systemStateSession.Connect err = %d"), err ); + + if ( err == KErrNone ) + { + TSsmState currentState = systemStateSession.State(); + systemStateSession.Close(); + + FLOG_1( _L("Daemon: System main state = %d"), currentState.MainState() ); + FLOG_1( _L("Daemon: System sub state = %d"), currentState.SubState() ); + + + if ( currentState.MainState() == ESsmNormal ) + { + iSystemReadyToShowDialogs = ETrue; + } + else + { + iSystemReadyToShowDialogs = EFalse; + } + } + else + { + iSystemReadyToShowDialogs = EFalse; + } + } + FLOG_1( _L("Daemon: iSystemReadyToShowDialogs = %d"), + iSystemReadyToShowDialogs ); + } +*/ + +//------------------------------------------------------------------------------- + +// ----------------------------------------------------------------------------- +// CDialogTimer::CDialogTimer() +// +// ----------------------------------------------------------------------------- +// +CDialogTimer::CDialogTimer() : CActive( EPriorityNormal ) + { + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::~CDialogTimer() +// +// ----------------------------------------------------------------------------- +// +CDialogTimer::~CDialogTimer() + { + FLOG( _L("Daemon: CDialogTimer::~CDialogTimer") ); + // Cancel the outstanding request. Calls the active object’s + // DoCancel function if request is outstanding. + Cancel(); + // Delete RTimer + iRTimer.Close(); + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::NewL() +// +// ----------------------------------------------------------------------------- +// +CDialogTimer* CDialogTimer::NewL( CDialogWrapper* aDialog ) + { + CDialogTimer* activeTimer = new (ELeave) CDialogTimer(); + CleanupStack::PushL( activeTimer ); + activeTimer->ConstructL( aDialog ); + CleanupStack::Pop(); + return activeTimer; + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::ConstructL() +// +// ----------------------------------------------------------------------------- +// +void CDialogTimer::ConstructL( CDialogWrapper* aDialog ) + { + if ( aDialog == NULL ) + { + User::Leave( KErrArgument ); + } + iDialog = aDialog; + CActiveScheduler::Add( this ); + iRTimer.CreateLocal(); + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::StartDialogTimer() +// +// ----------------------------------------------------------------------------- +// +void CDialogTimer::StartDialogTimer( TUint32 aRefreshTime ) + { + FLOG( _L("Daemon: CDialogTimer::StartDialogTimer") ); + // Check first that we do not have request outstanding. + if ( !IsActive() ) + { + // Set time interval for dialog. + TimerSet( aRefreshTime ); + } + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::TimerSet() +// +// ----------------------------------------------------------------------------- +// +void CDialogTimer::TimerSet( TUint32 aRefreshTime ) + { + FLOG_1( _L("Daemon: CDialogTimer::TimerSet time: %d"), aRefreshTime ); + // Set timer interval. + iRTimer.After( iStatus, aRefreshTime ); + // Set active. Start wait for timer. + SetActive(); + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::RunL() +// +// ----------------------------------------------------------------------------- +// +void CDialogTimer::RunL() + { + FLOG( _L("Daemon: CDialogTimer::RunL: Cancel waiting note") ); + iDialog->CancelWaitingNote(); + iDialog->CancelWaitingNoteForUninstaller(); + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::DoCancel() +// +// ----------------------------------------------------------------------------- +// +void CDialogTimer::DoCancel() + { + // Cancel outstanding request for a timer event. + iRTimer.Cancel(); + } + +// ----------------------------------------------------------------------------- +// CDialogTimer::RunError() +// +// ----------------------------------------------------------------------------- +// +TInt CDialogTimer::RunError( TInt aError ) + { + return aError; + } + + // End of File