appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 // TODO needs to be removed in 10.1
    21 #include <hb/hbwidgets/hbdeviceprogressdialogsymbian.h>
    22 //#include <AknGlobalNote.h> 
    22 #include <hb/hbwidgets/hbdevicenotificationdialogsymbian.h>
    23 //#include <avkon.rsg>
       
    24 // TODO maybe removed 10.1
       
    25 //#include <bautils.h>  // file operations like FileMan
       
    26 //#include <data_caging_path_literals.hrh> // resource paths
       
    27 // TODO probably not needed in QT.
       
    28 //#include <swidaemon.rsg>
       
    29 
       
    30 #include "DialogWrapper.h"
    23 #include "DialogWrapper.h"
    31 #include "SWInstDebug.h"
    24 #include "SWInstDebug.h"
    32 
    25 
    33 //_LIT( KDaemonResourceFile, "swidaemon.rsc" );
       
    34 
       
    35 using namespace Swi;
    26 using namespace Swi;
       
    27 
       
    28 //TODO: remove when HB dialogs do not crash in HW/WINS
       
    29 #define _SWIDAEMON_DISABLE_NOTES_
    36 
    30 
    37 // ============================ MEMBER FUNCTIONS ===============================
    31 // ============================ MEMBER FUNCTIONS ===============================
    38 
    32 
    39 // -----------------------------------------------------------------------------
    33 // -----------------------------------------------------------------------------
    40 // CDialogWrapper::CDialogWrapper
    34 // CDialogWrapper::CDialogWrapper
    52 // Symbian 2nd phase constructor can leave.
    46 // Symbian 2nd phase constructor can leave.
    53 // -----------------------------------------------------------------------------
    47 // -----------------------------------------------------------------------------
    54 //
    48 //
    55 void CDialogWrapper::ConstructL()
    49 void CDialogWrapper::ConstructL()
    56     {
    50     {
    57 //TODO: All resoureces nees to be rewriten for device dialogs (QT)    
    51     iIsProgressDialog = EFalse;
    58     // Get resource file path
    52     iHbProgressDialog = NULL;
    59     //TFileName fileName;
    53     iIsUninstallerProgressDialog = EFalse;
    60     //fileName.Copy( TParsePtrC( RProcess().FileName() ).Drive() );
    54     iHbProgressDialogForUninstaller = NULL;
    61     //fileName.Append( KDC_RESOURCE_FILES_DIR );
    55                   
    62     //fileName.Append( KDaemonResourceFile );
       
    63     
       
    64     // Get language of resource file        
       
    65     //BaflUtils::NearestLanguageFile( iFs, fileName );
       
    66 
       
    67     // Open resource file
       
    68     //iResourceFile.OpenL( iFs, fileName );
       
    69     //iResourceFile.ConfirmSignatureL();
       
    70   
       
    71     // By default Daemon will show all notes.
    56     // By default Daemon will show all notes.
    72     iDisableAllNotes = EFalse;
    57     iDisableAllNotes = EFalse;
       
    58     
    73     // Create watcher AO for PS Key.
    59     // Create watcher AO for PS Key.
    74     iWatcher = CDialogWatcher::NewL( this );   
    60     iWatcher = CDialogWatcher::NewL( this );   
    75     // Get current PS Key 
    61     // Get current PS Key 
    76     TInt err = iWatcher->GetPSKeyForUI( iDisableAllNotes );
    62     TInt err = iWatcher->GetPSKeyForUI( iDisableAllNotes );
    77     if ( err )
    63     if ( err )
   102 // Destructor
    88 // Destructor
   103 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
   104 //    
    90 //    
   105 CDialogWrapper::~CDialogWrapper()
    91 CDialogWrapper::~CDialogWrapper()
   106     {
    92     {
   107     //iResourceFile.Close();
    93     delete iHbProgressDialog;
   108     
    94     delete iHbProgressDialogForUninstaller;                          
   109     if ( iWatcher )
    95     if ( iWatcher )
   110         {
    96         {
   111         iWatcher->StopWatcher();
    97         iWatcher->StopWatcher();
   112         delete iWatcher;
    98         delete iWatcher;
   113         }
    99         }
   119 // (other items were commented in a header).
   105 // (other items were commented in a header).
   120 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   121 // 
   107 // 
   122 void CDialogWrapper::ShowUntrustedResultL()
   108 void CDialogWrapper::ShowUntrustedResultL()
   123     {
   109     {
   124     //TODO: All resoureces nees to be rewriten for device dialogs (QT)    
   110     FLOG( _L("Daemon: CDialogWrapper::ShowUntrustedResultL") );
       
   111 
       
   112 #ifdef _SWIDAEMON_DISABLE_NOTES_
       
   113     FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
       
   114     iDisableAllNotes = ETrue;
       
   115 #endif      
       
   116       
   125     // Let watcher to know that waiting note is canceled.
   117     // Let watcher to know that waiting note is canceled.
   126     //iWatcher->CancelNoteRequest();
   118     iWatcher->CancelNoteRequest();            
   127     
   119         
   128     //if ( iDisableAllNotes == EFalse )
   120     // Inform watcher that we have request to show note. 
   129     //    {    
   121     iWatcher->CancelNoteRequest();   
   130     //    HBufC* string = ReadResourceLC( R_DAEMON_UNTRUSTED_FOUND );    
   122     
   131     //    CAknGlobalNote* note = CAknGlobalNote::NewLC();
   123     if ( iDisableAllNotes == EFalse )
   132     //    note->ShowNoteL( EAknGlobalInformationNote, *string );   
   124         {    
   133     //    CleanupStack::PopAndDestroy( 2, string ); 
   125         CHbDeviceNotificationDialogSymbian* notificationDialog = 
   134     //    }
   126                 CHbDeviceNotificationDialogSymbian::NewL( NULL );
       
   127         
       
   128         CleanupStack::PushL( notificationDialog );
       
   129         
       
   130 //TODO get string from log file.  
       
   131         _LIT( KTempIconText,"note_info");
       
   132         _LIT( KTempTextTitle,"SW Silent Installer" );
       
   133         _LIT( KTempTextForErrorMessage,"Untrusted software was found." ); 
       
   134                      
       
   135         //notificationDialog->SetTimeout( KHbLongNotificationDialogTimeout );        
       
   136         
       
   137         notificationDialog->NotificationL( KTempIconText, 
       
   138                                            KTempTextTitle , 
       
   139                                            KTempTextForErrorMessage );
       
   140                     
       
   141         CleanupStack::PopAndDestroy( notificationDialog );        
       
   142         }   
   135     }
   143     }
   136 
   144 
   137 // -----------------------------------------------------------------------------
   145 // -----------------------------------------------------------------------------
   138 // CDialogWrapper::ShowErrorResultL
   146 // CDialogWrapper::ShowErrorResultL
   139 // Show global result dialog.
   147 // Show global result dialog.
   140 // (other items were commented in a header).
   148 // (other items were commented in a header).
   141 // -----------------------------------------------------------------------------
   149 // -----------------------------------------------------------------------------
   142 // 
   150 // 
   143 void CDialogWrapper::ShowErrorResultL()
   151 void CDialogWrapper::ShowErrorResultL()
   144     { 
   152     { 
   145     //TODO: All resoureces nees to be rewriten for device dialogs (QT)   
   153     FLOG( _L("Daemon: CDialogWrapper::ShowErrorResultL") );
   146     // Let watcher to know that waiting note is canceled.
   154     
       
   155 #ifdef _SWIDAEMON_DISABLE_NOTES_
       
   156     FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
       
   157     iDisableAllNotes = ETrue;
       
   158 #endif  
       
   159     
       
   160     // Inform watcher that we have request to show note. 
   147     iWatcher->CancelNoteRequest();   
   161     iWatcher->CancelNoteRequest();   
   148     
   162     
   149     if ( iDisableAllNotes == EFalse )
   163     if ( iDisableAllNotes == EFalse )
   150         {
   164         {    
   151         /*
   165         CHbDeviceNotificationDialogSymbian* notificationDialog = 
   152         HBufC* string = ReadResourceLC( R_DAEMON_INSTALLATION_ERROR );    
   166                 CHbDeviceNotificationDialogSymbian::NewL( NULL );
   153         CAknGlobalNote* note = CAknGlobalNote::NewLC();
   167         
   154         note->ShowNoteL( EAknGlobalInformationNote, *string );   
   168         CleanupStack::PushL( notificationDialog );
   155         CleanupStack::PopAndDestroy( 2, string );
   169         
   156         */  
   170 //TODO get string from log file.  
       
   171         _LIT( KTempIconText,"note_info");
       
   172         _LIT( KTempTextTitle,"SW Silent Installer" );
       
   173         _LIT( KTempTextForErrorMessage,"Installation was not completed." ); 
       
   174                    
       
   175         //notificationDialog->SetTimeout( KHbLongNotificationDialogTimeout );        
       
   176         
       
   177         notificationDialog->NotificationL( KTempIconText, 
       
   178                                            KTempTextTitle , 
       
   179                                            KTempTextForErrorMessage );
       
   180                
       
   181         CleanupStack::PopAndDestroy( notificationDialog ); 
   157         }
   182         }
   158     }
   183     }
   159 
   184 
   160 // -----------------------------------------------------------------------------
   185 // -----------------------------------------------------------------------------
   161 // CDialogWrapper::ShowWaitingNoteL  
   186 // CDialogWrapper::ShowWaitingNoteL  
   163 // (other items were commented in a header).
   188 // (other items were commented in a header).
   164 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   165 // 
   190 // 
   166 void CDialogWrapper::ShowWaitingNoteL()
   191 void CDialogWrapper::ShowWaitingNoteL()
   167 	{
   192 	{
   168     //TODO: All resoureces nees to be rewriten for device dialogs (QT)   
   193     FLOG( _L("Daemon: CDialogWrapper::ShowWaitingNoteL") );
       
   194     
       
   195 #ifdef _SWIDAEMON_DISABLE_NOTES_
       
   196     FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
       
   197     iDisableAllNotes = ETrue;
       
   198 #endif
       
   199     
   169     if ( iDisableAllNotes == EFalse )
   200     if ( iDisableAllNotes == EFalse )
   170         {
   201         {          
   171         /*
   202         if ( !iIsProgressDialog )
   172         if ( iNoteId == 0 )
   203             {    
   173             {            
   204             iHbProgressDialog = CHbDeviceProgressDialogSymbian::NewL( 
   174             HBufC* string = ReadResourceLC( R_DAEMON_INSTALLING );   
   205                                    CHbDeviceProgressDialogSymbian::EWaitDialog, 
   175             CAknGlobalNote* note = CAknGlobalNote::NewLC();
   206                                    NULL );
   176             note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
   207             iIsProgressDialog = ETrue;
   177             iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string );
   208             
   178             CleanupStack::PopAndDestroy( 2, string );           
   209 //TODO get string from log file.            
       
   210             _LIT( KTempTextForProgressDialog,"Installing" );
       
   211             
       
   212             iHbProgressDialog->SetTextL( KTempTextForProgressDialog );            
       
   213             iHbProgressDialog->ShowL();
   179             }
   214             }
   180         */    
       
   181         }
   215         }
   182     else if ( iDisableAllNotes )
   216     else if ( iDisableAllNotes )
   183         {
   217         {
   184         // Let watcher to know that waiting note should be shown 
   218         // Let watcher to know that waiting note should be shown 
   185         // after dialogs are enabled.
   219         // after dialogs are enabled.
   192 // Cancel global waiting note after installing.
   226 // Cancel global waiting note after installing.
   193 // (other items were commented in a header).
   227 // (other items were commented in a header).
   194 // -----------------------------------------------------------------------------
   228 // -----------------------------------------------------------------------------
   195 // 
   229 // 
   196 void CDialogWrapper::CancelWaitingNoteL()
   230 void CDialogWrapper::CancelWaitingNoteL()
   197 	{
   231 	{ 
   198     //TODO: All resoureces nees to be rewriten for device dialogs (QT)   
   232     FLOG( _L("Daemon: CDialogWrapper::CancelWaitingNoteL") );
   199     /*
   233     
   200 	if ( iNoteId )
   234 	if ( iIsProgressDialog )
   201 		{
   235 		{
   202 		CAknGlobalNote* note = CAknGlobalNote::NewLC();
   236 		iHbProgressDialog->Cancel();
   203 		note->CancelNoteL( iNoteId );
   237 		delete iHbProgressDialog;
   204 		iNoteId = 0;
   238 		iHbProgressDialog = NULL;
   205 		CleanupStack::PopAndDestroy();
   239 		iIsProgressDialog = EFalse;
   206 		}
   240 		}
   207 	*/	
   241 		
   208     // Let watcher to know that waiting note is canceled.
   242     // Let watcher to know that waiting note is canceled.
   209 	iWatcher->CancelNoteRequest();
   243 	iWatcher->CancelNoteRequest();
   210  	}
   244  	}
   211 
   245 
   212 // -----------------------------------------------------------------------------
   246 // -----------------------------------------------------------------------------
   213 // CDialogWrapper::LoadResourceLC  
   247 // CDialogWrapper::LoadResourceLC  
   214 // Read resource string.
   248 // Read resource string.
   215 // (other items were commented in a header).
   249 // (other items were commented in a header).
   216 // -----------------------------------------------------------------------------
   250 // -----------------------------------------------------------------------------
   217 // 
   251 // 
   218 HBufC* CDialogWrapper::ReadResourceLC( TInt aResourceId )
   252 HBufC* CDialogWrapper::ReadResourceLC( TInt /*aResourceId*/ )
   219     {
   253     {
   220     //TODO: All resoureces nees to be rewriten for device dialogs (QT)   
   254     //TODO: All resoureces nees to be rewriten for device dialogs (QT)    
   221     /*
       
   222     TResourceReader reader;
       
   223     HBufC8* buff = iResourceFile.AllocReadLC( aResourceId );    
       
   224     reader.SetBuffer( buff );
       
   225     HBufC* text = reader.ReadHBufCL();
       
   226     CleanupStack::PopAndDestroy( buff );
       
   227     CleanupStack::PushL( text );
       
   228     return text;
       
   229     */
       
   230     return NULL;
   255     return NULL;
   231     }
   256     }
   232 
   257 
   233 // -----------------------------------------------------------------------------
   258 // -----------------------------------------------------------------------------
   234 // CDialogWrapper::SetUIFlag  
   259 // CDialogWrapper::SetUIFlag  
   245 // Show global waiting note during uninstall.
   270 // Show global waiting note during uninstall.
   246 // -----------------------------------------------------------------------------
   271 // -----------------------------------------------------------------------------
   247 // 
   272 // 
   248 void CDialogWrapper::ShowWaitingNoteForUninstallerL()
   273 void CDialogWrapper::ShowWaitingNoteForUninstallerL()
   249     {
   274     {
       
   275     FLOG( _L("Daemon: CDialogWrapper::ShowWaitingNoteForUninstallerL") );
       
   276     
       
   277 #ifdef _SWIDAEMON_DISABLE_NOTES_
       
   278     FLOG( _L("Daemon: CDialogWrapper: iDisableAllNotes = ETrue") );
       
   279     iDisableAllNotes = ETrue;
       
   280 #endif
       
   281     
   250     //TODO: All resoureces nees to be rewriten for device dialogs (QT)   
   282     //TODO: All resoureces nees to be rewriten for device dialogs (QT)   
   251     if ( iDisableAllNotes == EFalse )
   283     if ( iDisableAllNotes == EFalse )
   252         {
   284         {
   253         /*
   285         if ( !iIsUninstallerProgressDialog )
   254         if ( iNoteId == 0 )
   286             {    
   255             {
   287             iHbProgressDialogForUninstaller = 
   256             HBufC* string = ReadResourceLC( R_UNINSTALLER_INSTALL );   
   288                     CHbDeviceProgressDialogSymbian::NewL( 
   257             CAknGlobalNote* note = CAknGlobalNote::NewLC();
   289                                    CHbDeviceProgressDialogSymbian::EWaitDialog, 
   258             note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
   290                                    NULL );
   259             iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string );
   291             iIsUninstallerProgressDialog = ETrue;
   260             CleanupStack::PopAndDestroy( 2, string );
   292     //TODO get string from log file.            
       
   293             _LIT( KTempTextForProgressDialog,"Uninstalling" );            
       
   294             iHbProgressDialogForUninstaller->SetTextL( KTempTextForProgressDialog );            
       
   295             iHbProgressDialogForUninstaller->ShowL();
   261             }
   296             }
   262         */    
       
   263         }
   297         }
   264     else if ( iDisableAllNotes )
   298     else if ( iDisableAllNotes )
   265         {
   299         {
   266         // Let watcher to know that waiting note should be shown 
   300         // Let watcher to know that waiting note should be shown 
   267         // after dialogs are enabled.
   301         // after dialogs are enabled.