appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
--- a/appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp	Tue Aug 31 15:21:33 2010 +0300
+++ b/appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp	Wed Sep 01 12:22:02 2010 +0100
@@ -18,26 +18,18 @@
 
 
 // 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 <AknGlobalNote.h>
+#include <avkon.rsg>
+#include <bautils.h>
+#include <data_caging_path_literals.hrh> 
+#include <swidaemon.rsg>
+
 #include "DialogWrapper.h"
 #include "SWInstDebug.h"
 
-using namespace Swi;
+_LIT( KDaemonResourceFile, "swidaemon.rsc" );
 
-// 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_
+using namespace Swi;
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -59,17 +51,23 @@
 //
 void CDialogWrapper::ConstructL()
     {
-    iIsProgressDialog = EFalse;
-    iHbProgressDialog = NULL;
-    iIsUninstallerProgressDialog = EFalse;
-    iHbProgressDialogForUninstaller = NULL;
-    iIsIndicator = EFalse;
-    iHbIndicator = NULL;                        
+    // 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();
+  
     // By default Daemon will show all notes.
-    iDisableAllNotes = EFalse;    
-    iTimeOffDisableProgress = EFalse;    
+    iDisableAllNotes = 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 )
@@ -78,9 +76,7 @@
         iDisableAllNotes = ETrue;
         }
     // Start AO
-    iWatcher->StartWatcher();    
-    // Create dialog timer for progress dialog.
-    iTimer = CDialogTimer::NewL( this );
+    iWatcher->StartWatcher();
     }
 
 // -----------------------------------------------------------------------------
@@ -96,42 +92,16 @@
     CleanupStack::Pop( self );
     return self;    
     }
-
-// -----------------------------------------------------------------------------
-// CDialogWrapper::~CDialogWrapper
+    
 // Destructor
-// -----------------------------------------------------------------------------
-//    
 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;
-    
-    // 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;
-    
+    iResourceFile.Close();
     if ( iWatcher )
         {
-        iWatcher->StopWatcher();        
-        }       
-    delete iWatcher;
+        iWatcher->StopWatcher();
+        delete iWatcher;
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -141,38 +111,17 @@
 // -----------------------------------------------------------------------------
 // 
 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();
     
-    // Let watcher to know that waiting note is canceled.
-    iWatcher->CancelNoteRequest();            
-        
-    // Inform watcher that we have request to show note. 
-    iWatcher->CancelNoteRequest(); 
-            
-    if ( !iDisableAllNotes  )
+    if ( iDisableAllNotes == EFalse )
         {    
-        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 );        
-        }   
+        HBufC* string = ReadResourceLC( R_DAEMON_UNTRUSTED_FOUND );    
+        CAknGlobalNote* note = CAknGlobalNote::NewLC();
+        note->ShowNoteL( EAknGlobalInformationNote, *string );   
+        CleanupStack::PopAndDestroy( 2, string ); 
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -183,33 +132,15 @@
 // 
 void CDialogWrapper::ShowErrorResultL()
     { 
-    FLOG( _L("Daemon: CDialogWrapper::ShowErrorResultL") );
-    
-#ifdef _SWIDAEMON_DISABLE_NOTES_
-    FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
-    iDisableAllNotes = ETrue;
-#endif  
-    
-    // Inform watcher that we have request to show note. 
+    // Let watcher to know that waiting note is canceled.
     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 ); 
+    
+    if ( iDisableAllNotes == EFalse )
+        {
+        HBufC* string = ReadResourceLC( R_DAEMON_INSTALLATION_ERROR );    
+        CAknGlobalNote* note = CAknGlobalNote::NewLC();
+        note->ShowNoteL( EAknGlobalInformationNote, *string );   
+        CleanupStack::PopAndDestroy( 2, string );  
         }
     }
 
@@ -221,33 +152,15 @@
 // 
 void CDialogWrapper::ShowWaitingNoteL()
 	{
-    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 );
+    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 );
             }
         }
     else if ( iDisableAllNotes )
@@ -264,35 +177,32 @@
 // (other items were commented in a header).
 // -----------------------------------------------------------------------------
 // 
-void CDialogWrapper::CancelWaitingNote()
-	{ 
-    FLOG( _L("Daemon: CDialogWrapper::CancelWaitingNoteL") );
-    
-	if ( iIsProgressDialog )
+void CDialogWrapper::CancelWaitingNoteL()
+	{
+	if ( iNoteId )
 		{
-		iHbProgressDialog->Close();
-		delete iHbProgressDialog;
-		//Make sure not to delete twice in destructor.
-		iHbProgressDialog = NULL;
-		iIsProgressDialog = EFalse;
-		
-		iTimeOffDisableProgress = ETrue;
+		CAknGlobalNote* note = CAknGlobalNote::NewLC();
+		note->CancelNoteL( iNoteId );
+		iNoteId = 0;
+		CleanupStack::PopAndDestroy();
 		}
-		
     // 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 )
     {
-    //TODO: All resoureces nees to be rewriten for device dialogs (QT)    
-    return NULL;
+    TResourceReader reader;
+    HBufC8* buff = iResourceFile.AllocReadLC( aResourceId );    
+    reader.SetBuffer( buff );
+    HBufC* text = reader.ReadHBufCL();
+    CleanupStack::PopAndDestroy( buff );
+    CleanupStack::PushL( text );
+    return text;
     }
 
 // -----------------------------------------------------------------------------
@@ -312,33 +222,15 @@
 // 
 void CDialogWrapper::ShowWaitingNoteForUninstallerL()
     {
-    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 ( iDisableAllNotes == EFalse )
         {
-        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 );
+        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 );
             }
         }
     else if ( iDisableAllNotes )
@@ -348,275 +240,4 @@
         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<TInt>( 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