appinstaller/AppinstUi/Daemon/Src/DialogWrapper.cpp
changeset 0 ba25891c3a9e
child 25 7333d7932ef7
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This file contains the implementation of CDialogWrapper
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <AknGlobalNote.h>
       
    22 #include <avkon.rsg>
       
    23 #include <bautils.h>
       
    24 #include <data_caging_path_literals.hrh> 
       
    25 #include <swidaemon.rsg>
       
    26 
       
    27 #include "DialogWrapper.h"
       
    28 #include "SWInstDebug.h"
       
    29 
       
    30 _LIT( KDaemonResourceFile, "swidaemon.rsc" );
       
    31 
       
    32 using namespace Swi;
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CDialogWrapper::CDialogWrapper
       
    38 // C++ default constructor can NOT contain any code, that
       
    39 // might leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CDialogWrapper::CDialogWrapper( RFs& aFs )
       
    43     : iFs( aFs )
       
    44     {
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CDialogWrapper::ConstructL
       
    49 // Symbian 2nd phase constructor can leave.
       
    50 // -----------------------------------------------------------------------------
       
    51 //
       
    52 void CDialogWrapper::ConstructL()
       
    53     {
       
    54     // Get resource file path
       
    55     TFileName fileName;
       
    56     fileName.Copy( TParsePtrC( RProcess().FileName() ).Drive() );
       
    57     fileName.Append( KDC_RESOURCE_FILES_DIR );
       
    58     fileName.Append( KDaemonResourceFile );
       
    59     
       
    60     // Get language of resource file        
       
    61     BaflUtils::NearestLanguageFile( iFs, fileName );
       
    62 
       
    63     // Open resource file
       
    64     iResourceFile.OpenL( iFs, fileName );
       
    65     iResourceFile.ConfirmSignatureL();
       
    66   
       
    67     // By default Daemon will show all notes.
       
    68     iDisableAllNotes = EFalse;
       
    69     // Create watcher AO for PS Key.
       
    70     iWatcher = CDialogWatcher::NewL( this );   
       
    71     // Get current PS Key 
       
    72     TInt err = iWatcher->GetPSKeyForUI( iDisableAllNotes );
       
    73     if ( err )
       
    74         {
       
    75         // If we can not get PS key, let's disable all notes.
       
    76         iDisableAllNotes = ETrue;
       
    77         }
       
    78     // Start AO
       
    79     iWatcher->StartWatcher();
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CDialogWrapper::NewL
       
    84 // Two-phased constructor.
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 CDialogWrapper* CDialogWrapper::NewL( RFs& aFs )
       
    88     {
       
    89     CDialogWrapper* self = new( ELeave ) CDialogWrapper( aFs );
       
    90     CleanupStack::PushL( self );
       
    91     self->ConstructL();
       
    92     CleanupStack::Pop( self );
       
    93     return self;    
       
    94     }
       
    95     
       
    96 // Destructor
       
    97 CDialogWrapper::~CDialogWrapper()
       
    98     {
       
    99     iResourceFile.Close();
       
   100     if ( iWatcher )
       
   101         {
       
   102         iWatcher->StopWatcher();
       
   103         delete iWatcher;
       
   104         }
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CDialogWrapper::ShowUntrustedResultL
       
   109 // Show global result dialog.
       
   110 // (other items were commented in a header).
       
   111 // -----------------------------------------------------------------------------
       
   112 // 
       
   113 void CDialogWrapper::ShowUntrustedResultL()
       
   114     {  
       
   115     // Let watcher to know that waiting note is canceled.
       
   116     iWatcher->CancelNoteRequest();
       
   117     
       
   118     if ( iDisableAllNotes == EFalse )
       
   119         {    
       
   120         HBufC* string = ReadResourceLC( R_DAEMON_UNTRUSTED_FOUND );    
       
   121         CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   122         note->ShowNoteL( EAknGlobalInformationNote, *string );   
       
   123         CleanupStack::PopAndDestroy( 2, string ); 
       
   124         }
       
   125     }
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CDialogWrapper::ShowErrorResultL
       
   129 // Show global result dialog.
       
   130 // (other items were commented in a header).
       
   131 // -----------------------------------------------------------------------------
       
   132 // 
       
   133 void CDialogWrapper::ShowErrorResultL()
       
   134     { 
       
   135     // Let watcher to know that waiting note is canceled.
       
   136     iWatcher->CancelNoteRequest();   
       
   137     
       
   138     if ( iDisableAllNotes == EFalse )
       
   139         {
       
   140         HBufC* string = ReadResourceLC( R_DAEMON_INSTALLATION_ERROR );    
       
   141         CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   142         note->ShowNoteL( EAknGlobalInformationNote, *string );   
       
   143         CleanupStack::PopAndDestroy( 2, string );  
       
   144         }
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CDialogWrapper::ShowWaitingNoteL  
       
   149 // Show global waiting note during installing.
       
   150 // (other items were commented in a header).
       
   151 // -----------------------------------------------------------------------------
       
   152 // 
       
   153 void CDialogWrapper::ShowWaitingNoteL()
       
   154 	{
       
   155     if ( iDisableAllNotes == EFalse )
       
   156         {
       
   157         if ( iNoteId == 0 )
       
   158             {
       
   159             HBufC* string = ReadResourceLC( R_DAEMON_INSTALLING );   
       
   160             CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   161             note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
       
   162             iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string );
       
   163             CleanupStack::PopAndDestroy( 2, string );
       
   164             }
       
   165         }
       
   166     else if ( iDisableAllNotes )
       
   167         {
       
   168         // Let watcher to know that waiting note should be shown 
       
   169         // after dialogs are enabled.
       
   170         iWatcher->RequestToDisplayNote();
       
   171         }
       
   172 	}
       
   173 	
       
   174 // -----------------------------------------------------------------------------
       
   175 // CDialogWrapper::CancelWaitingNoteL  
       
   176 // Cancel global waiting note after installing.
       
   177 // (other items were commented in a header).
       
   178 // -----------------------------------------------------------------------------
       
   179 // 
       
   180 void CDialogWrapper::CancelWaitingNoteL()
       
   181 	{
       
   182 	if ( iNoteId )
       
   183 		{
       
   184 		CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   185 		note->CancelNoteL( iNoteId );
       
   186 		iNoteId = 0;
       
   187 		CleanupStack::PopAndDestroy();
       
   188 		}
       
   189     // Let watcher to know that waiting note is canceled.
       
   190 	iWatcher->CancelNoteRequest();
       
   191  	}
       
   192 // CDialogWrapper::LoadResourceLC
       
   193 // Read resource string.
       
   194 // (other items were commented in a header).
       
   195 // -----------------------------------------------------------------------------
       
   196 // 
       
   197 HBufC* CDialogWrapper::ReadResourceLC( TInt aResourceId )
       
   198     {
       
   199     TResourceReader reader;
       
   200     HBufC8* buff = iResourceFile.AllocReadLC( aResourceId );    
       
   201     reader.SetBuffer( buff );
       
   202     HBufC* text = reader.ReadHBufCL();
       
   203     CleanupStack::PopAndDestroy( buff );
       
   204     CleanupStack::PushL( text );
       
   205     return text;
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CDialogWrapper::SetUIFlag  
       
   210 // Sets UI flag for dialog wrapper. If flag is ture, dialogs are disabled.
       
   211 // -----------------------------------------------------------------------------
       
   212 // 
       
   213 void CDialogWrapper::SetUIFlag( TInt aUIFlag )
       
   214     {
       
   215     iDisableAllNotes = aUIFlag;
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // CDialogWrapper::ShowWaitingNoteForUninstallerL  
       
   220 // Show global waiting note during uninstall.
       
   221 // -----------------------------------------------------------------------------
       
   222 // 
       
   223 void CDialogWrapper::ShowWaitingNoteForUninstallerL()
       
   224     {
       
   225     if ( iDisableAllNotes == EFalse )
       
   226         {
       
   227         if ( iNoteId == 0 )
       
   228             {
       
   229             HBufC* string = ReadResourceLC( R_UNINSTALLER_INSTALL );   
       
   230             CAknGlobalNote* note = CAknGlobalNote::NewLC();
       
   231             note->SetSoftkeys( R_AVKON_SOFTKEYS_EMPTY );
       
   232             iNoteId = note->ShowNoteL( EAknGlobalWaitNote, *string );
       
   233             CleanupStack::PopAndDestroy( 2, string );
       
   234             }
       
   235         }
       
   236     else if ( iDisableAllNotes )
       
   237         {
       
   238         // Let watcher to know that waiting note should be shown 
       
   239         // after dialogs are enabled.
       
   240         iWatcher->RequestToDisplayNote();
       
   241         }
       
   242     }
       
   243 //  End of File