--- a/appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp Fri May 14 15:58:48 2010 +0300
+++ b/appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp Thu May 27 12:58:35 2010 +0300
@@ -20,13 +20,24 @@
// INCLUDE FILES
#include <hb/hbwidgets/hbdeviceprogressdialogsymbian.h>
#include <hb/hbwidgets/hbdevicenotificationdialogsymbian.h>
+#include <hb/hbcore/hbindicatorsymbian.h>
+#include <hb/hbcore/hbsymbianvariant.h>
+//#include <ssm/ssmstateawaresession.h> // For system state
+//#include <ssm/ssmstate.h>
+//#include <ssm/ssmdomaindefs.h> // KUIFrameworkDomain
#include "DialogWrapper.h"
#include "SWInstDebug.h"
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_
+//#define _SWIDAEMON_DISABLE_NOTES_
// ============================ MEMBER FUNCTIONS ===============================
@@ -52,12 +63,13 @@
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 )
@@ -66,7 +78,9 @@
iDisableAllNotes = ETrue;
}
// Start AO
- iWatcher->StartWatcher();
+ iWatcher->StartWatcher();
+ // Create dialog timer for progress dialog.
+ iTimer = CDialogTimer::NewL( this );
}
// -----------------------------------------------------------------------------
@@ -90,13 +104,34 @@
//
CDialogWrapper::~CDialogWrapper()
{
+ 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;
- delete iHbProgressDialogForUninstaller;
+
+ // 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;
}
// -----------------------------------------------------------------------------
@@ -108,19 +143,19 @@
void CDialogWrapper::ShowUntrustedResultL()
{
FLOG( _L("Daemon: CDialogWrapper::ShowUntrustedResultL") );
-
+
#ifdef _SWIDAEMON_DISABLE_NOTES_
FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
iDisableAllNotes = ETrue;
-#endif
-
+#endif
+
// Let watcher to know that waiting note is canceled.
iWatcher->CancelNoteRequest();
// Inform watcher that we have request to show note.
- iWatcher->CancelNoteRequest();
-
- if ( iDisableAllNotes == EFalse )
+ iWatcher->CancelNoteRequest();
+
+ if ( !iDisableAllNotes )
{
CHbDeviceNotificationDialogSymbian* notificationDialog =
CHbDeviceNotificationDialogSymbian::NewL( NULL );
@@ -131,9 +166,7 @@
_LIT( KTempIconText,"note_info");
_LIT( KTempTextTitle,"SW Silent Installer" );
_LIT( KTempTextForErrorMessage,"Untrusted software was found." );
-
- //notificationDialog->SetTimeout( KHbLongNotificationDialogTimeout );
-
+
notificationDialog->NotificationL( KTempIconText,
KTempTextTitle ,
KTempTextForErrorMessage );
@@ -159,8 +192,8 @@
// Inform watcher that we have request to show note.
iWatcher->CancelNoteRequest();
-
- if ( iDisableAllNotes == EFalse )
+
+ if ( !iDisableAllNotes )
{
CHbDeviceNotificationDialogSymbian* notificationDialog =
CHbDeviceNotificationDialogSymbian::NewL( NULL );
@@ -171,9 +204,7 @@
_LIT( KTempIconText,"note_info");
_LIT( KTempTextTitle,"SW Silent Installer" );
_LIT( KTempTextForErrorMessage,"Installation was not completed." );
-
- //notificationDialog->SetTimeout( KHbLongNotificationDialogTimeout );
-
+
notificationDialog->NotificationL( KTempIconText,
KTempTextTitle ,
KTempTextForErrorMessage );
@@ -191,26 +222,32 @@
void CDialogWrapper::ShowWaitingNoteL()
{
FLOG( _L("Daemon: CDialogWrapper::ShowWaitingNoteL") );
-
+
#ifdef _SWIDAEMON_DISABLE_NOTES_
FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
iDisableAllNotes = ETrue;
#endif
- if ( iDisableAllNotes == EFalse )
+ 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 )
+ if ( !iIsProgressDialog && !iTimeOffDisableProgress )
{
iHbProgressDialog = CHbDeviceProgressDialogSymbian::NewL(
CHbDeviceProgressDialogSymbian::EWaitDialog,
NULL );
iIsProgressDialog = ETrue;
-
-//TODO get string from log file.
+
_LIT( KTempTextForProgressDialog,"Installing" );
- iHbProgressDialog->SetTextL( KTempTextForProgressDialog );
- iHbProgressDialog->ShowL();
+ iHbProgressDialog->SetTextL( KTempTextForProgressDialog );
+ FLOG( _L("Daemon: ShowWaitingNoteL: ShowL") );
+ iHbProgressDialog->ShowL();
+ FLOG( _L("Daemon: ShowWaitingNoteL: StartDialogTimer") );
+ iTimer->StartDialogTimer( KDialogTimeOut );
}
}
else if ( iDisableAllNotes )
@@ -227,7 +264,7 @@
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
-void CDialogWrapper::CancelWaitingNoteL()
+void CDialogWrapper::CancelWaitingNote()
{
FLOG( _L("Daemon: CDialogWrapper::CancelWaitingNoteL") );
@@ -235,8 +272,11 @@
{
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.
@@ -279,10 +319,13 @@
iDisableAllNotes = ETrue;
#endif
- //TODO: All resoureces nees to be rewriten for device dialogs (QT)
- if ( iDisableAllNotes == EFalse )
+ FLOG_1( _L("Daemon: iDisableAllNotes: %d"), iDisableAllNotes );
+ FLOG_1( _L("Daemon: iIsProgressDialog: %d"), iIsProgressDialog );
+ FLOG_1( _L("Daemon: iTimeOffDisableProgress: %d"), iTimeOffDisableProgress );
+
+ if ( !iDisableAllNotes )
{
- if ( !iIsUninstallerProgressDialog )
+ if ( !iIsUninstallerProgressDialog && !iTimeOffDisableProgress )
{
iHbProgressDialogForUninstaller =
CHbDeviceProgressDialogSymbian::NewL(
@@ -291,8 +334,11 @@
iIsUninstallerProgressDialog = ETrue;
//TODO get string from log file.
_LIT( KTempTextForProgressDialog,"Uninstalling" );
- iHbProgressDialogForUninstaller->SetTextL( KTempTextForProgressDialog );
+ iHbProgressDialogForUninstaller->SetTextL( KTempTextForProgressDialog );
+ FLOG( _L("Daemon: ShowWaitingNoteForUninstallerL: ShowL") );
iHbProgressDialogForUninstaller->ShowL();
+ FLOG( _L("Daemon: ShowWaitingNoteForUninstallerL: StartDialogTimer") );
+ iTimer->StartDialogTimer( KDialogTimeOut );
}
}
else if ( iDisableAllNotes )
@@ -302,4 +348,274 @@
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;
+ }
+
+ TReal processValue = aProcessValue;
+
+ CHbSymbianVariant* hbParam = CHbSymbianVariant::NewL(
+ &processValue,
+ CHbSymbianVariant::EReal );
+ 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