appinstaller/AppinstUi/Plugin/SisxUI/Src/SisxUIHandler.cpp
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2002-2009 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 CSisxUIHandler
       
    15 *                class member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <StringLoader.h>
       
    22 #include <barsread.h>
       
    23 #include <eikenv.h>
       
    24 #include <aknlistquerydialog.h>
       
    25 #include <aknmessagequerydialog.h>
       
    26 #include <aknnotewrappers.h>
       
    27 #include <SisxUIData.rsg>
       
    28 #include <SWInstCommonUI.rsg>
       
    29 #include <SWInstDefs.h>
       
    30 #include <featmgr.h>
       
    31 //#include <csxhelp/am.hlp.hrh>
       
    32 #include <swi/sisinstallerrors.h>
       
    33 #include <AknUtils.h>
       
    34 #include <eikfrlb.h> //for the marquee effect
       
    35 #include <eikfrlbd.h> //for the marquee effect
       
    36 
       
    37 #include "SisxUIHandler.h"
       
    38 #include "SisxUICertificateInfo.h"
       
    39 #include "SisxUIAppInfo.h"
       
    40 #include "SisxUISelectionCache.h"
       
    41 #include "SisxUIResult.h"
       
    42 #include "SisxUILangName.h"             // CLangName
       
    43 #include "SisxUICleanupUtils.h"         // CleanupResetAndDestroyPushL
       
    44 #include "CUIUtils.h"
       
    45 #include "SWInstDebug.h"
       
    46 
       
    47 using namespace SwiUI;
       
    48 
       
    49 _LIT( KDetailedError,"%S (%d)" );
       
    50 _LIT( KSwiTempFile,"c:\\temp\\swierrors.txt" );
       
    51 _LIT( KNextLine, "\n" );
       
    52 _LIT( KLeftParenthes, "(" );
       
    53 //directional marks needed for Arabic language
       
    54 _LIT( KLRE, "\x202A" );
       
    55 _LIT( KPDF, "\x202C" );
       
    56 
       
    57 const TInt KSpaceForErrorCode = 12;     // space for " (-12345678)"
       
    58 
       
    59 // ============================ LOCAL FUNCTIONS ================================
       
    60 
       
    61 TBool HasLangId( const TLanguage* aId, const CLangName& aLang )
       
    62     {
       
    63     return( *aId == aLang.Id() );
       
    64     }
       
    65 
       
    66 // ============================ MEMBER FUNCTIONS ===============================
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CSisxUIHandler::CSisxUIHandler
       
    70 // C++ default constructor can NOT contain any code, that
       
    71 // might leave.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CSisxUIHandler::CSisxUIHandler( TInstallMode aMode, MSisxUICancelObserver* aCancelObserver )
       
    75     : iMode( aMode ), 
       
    76       iCancelObserver( aCancelObserver ), 
       
    77       iAllowUntrusted( ETrue )
       
    78     {    
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CSisxUIHandler::ConstructL
       
    83 // Symbian 2nd phase constructor can leave.
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 void CSisxUIHandler::ConstructL()
       
    87     {
       
    88     iCommonDialogs = CommonUI::CCUIDialogs::NewL();
       
    89     iCache = CSisxUISelectionCache::NewL();
       
    90     if ( iMode == EModeInstall )
       
    91         {        
       
    92         iCommonDialogs->ShowWaitDialogL( R_SISXUI_PREPARING, this, R_AVKON_SOFTKEYS_EMPTY );
       
    93         }    
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CSisxUIHandler::NewL
       
    98 // Two-phased constructor.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CSisxUIHandler* CSisxUIHandler::NewL( TInstallMode aMode, MSisxUICancelObserver* aCancelObserver )
       
   102     {
       
   103     CSisxUIHandler* self = new( ELeave ) CSisxUIHandler( aMode, aCancelObserver );
       
   104     CleanupStack::PushL( self );
       
   105     self->ConstructL();
       
   106     CleanupStack::Pop( self );
       
   107     return self;    
       
   108     }
       
   109     
       
   110 // Destructor
       
   111 CSisxUIHandler::~CSisxUIHandler()
       
   112     {
       
   113     // If wait dialog is showing close it.  	
       
   114     if ( iShowingWaitDialog )
       
   115         {        
       
   116         if ( iCommonDialogs )
       
   117             {
       
   118         	TRAP_IGNORE( iCommonDialogs->CloseWaitDialogL() );	
       
   119             }
       
   120         }    	    	
       
   121     delete iCommonDialogs;
       
   122     iCertificateArray.ResetAndDestroy();
       
   123     delete iCache;    
       
   124     iPackages.ResetAndDestroy();  
       
   125     iDrmFile.Close();
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CSisxUIHandler::DisplayInstallL
       
   130 // Displays a dialog at the beginning of an installation with details about the 
       
   131 // SISX package being installed. This dialog must be shown in TrustedUI mode.
       
   132 // (other items were commented in a header).
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 TBool CSisxUIHandler::DisplayInstallL( 
       
   136 #ifdef RD_COMBINE_INSTALLATION_QUERIES
       
   137                               const Swi::CAppInfo& /*aAppInfo*/,
       
   138 #else
       
   139                               const Swi::CAppInfo& aAppInfo,
       
   140 #endif //RD_COMBINE_INSTALLATION_QUERIES
       
   141                               const CApaMaskedBitmap* /*aLogo*/,
       
   142                               const RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/ )  
       
   143     {
       
   144 #ifdef RD_COMBINE_INSTALLATION_QUERIES //with new dialog sequence
       
   145     
       
   146     TBool result( ETrue );
       
   147     // Mark the integrity as done
       
   148     iIntegrityCheckDone = ETrue;
       
   149     iShowingDialog = EFalse;
       
   150 
       
   151 #else  // show using old dialog sequence 
       
   152     iShowingDialog = ETrue;
       
   153     
       
   154     // Close the preparing wait dialog
       
   155     iCommonDialogs->CloseWaitDialogL();
       
   156 
       
   157     TBool result( EFalse );
       
   158 
       
   159     HBufC* prompt = StringLoader::LoadLC( R_SISXUI_INSTALL_PROMPT, aAppInfo.AppName() );
       
   160     if ( iCommonDialogs->ShowConfirmationQueryL( *prompt, R_AVKON_SOFTKEYS_YES_NO__YES ) )
       
   161         {        
       
   162         result = ETrue;       
       
   163         }   
       
   164     else
       
   165         {
       
   166         iResult = TSisxUIResult( EUiResultCancelled );
       
   167         // Make sure no notes are shown after this        
       
   168         iShownFinalNote = ETrue;        
       
   169         }
       
   170    
       
   171     CleanupStack::PopAndDestroy( prompt );
       
   172 
       
   173     // Mark the integrity as done
       
   174     iIntegrityCheckDone = ETrue;
       
   175 
       
   176     iShowingDialog = EFalse;    
       
   177 #endif //RD_COMBINE_INSTALLATION_QUERIES    
       
   178     return result;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CSisxUIHandler::DisplayGrantCapabilitiesL
       
   183 // displays a dialog requesting that the user grants these capabilities to the 
       
   184 // SISX package being installed. This dialog must be shown in TrustedUI mode.
       
   185 // (other items were commented in a header).
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 TBool CSisxUIHandler::DisplayGrantCapabilitiesL( const Swi::CAppInfo& /*aAppInfo*/, 
       
   189                                                  const TCapabilitySet& aCapabilitySet ) 
       
   190     {
       
   191     iShowingDialog = ETrue;
       
   192 
       
   193     TBool result( ETrue );
       
   194 
       
   195     // Add the text heading
       
   196     HBufC* messageString = StringLoader::LoadLC( R_SISXUI_CAPAB_HEADING );
       
   197 
       
   198     if ( aCapabilitySet.HasCapability( ECapabilityLocalServices ) )
       
   199         {
       
   200         AddCapabilityL( messageString, R_SISXUI_CAPAB_LOCAL );
       
   201         }
       
   202 
       
   203     if ( aCapabilitySet.HasCapability( ECapabilityReadUserData ) )
       
   204         {
       
   205         AddCapabilityL( messageString, R_SISXUI_CAPAB_READ_USER );
       
   206         }
       
   207 
       
   208     if ( aCapabilitySet.HasCapability( ECapabilityWriteUserData ) )
       
   209         {
       
   210         AddCapabilityL( messageString, R_SISXUI_CAPAB_WRITE_USER );
       
   211         }
       
   212 
       
   213     if ( aCapabilitySet.HasCapability( ECapabilityUserEnvironment ) )
       
   214         {
       
   215         AddCapabilityL( messageString, R_SISXUI_CAPAB_USERENV );
       
   216         }
       
   217 
       
   218     if ( aCapabilitySet.HasCapability( ECapabilityNetworkServices ) )
       
   219         {
       
   220         AddCapabilityL( messageString, R_SISXUI_CAPAB_NETWORK );
       
   221         }
       
   222 
       
   223     if ( aCapabilitySet.HasCapability( ECapabilityLocation ) )
       
   224         {
       
   225         AddCapabilityL( messageString, R_SISXUI_CAPAB_LOCATION );
       
   226         }
       
   227 
       
   228     HBufC* linkText = NULL;    
       
   229     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   230         {        
       
   231         linkText = StringLoader::LoadLC( R_SISXUI_CAPAB_MORE_INFO );
       
   232         }
       
   233     else
       
   234         {
       
   235         linkText = KNullDesC().AllocLC();        
       
   236         }
       
   237     
       
   238     HBufC* finalMessage = HBufC::NewLC( messageString->Length() + linkText->Length() + 1);
       
   239     TPtr msgPtr( finalMessage->Des() );
       
   240     
       
   241     msgPtr += *messageString;
       
   242     msgPtr += KNextLine;
       
   243     msgPtr += *linkText;    
       
   244 
       
   245     // Show the dialog
       
   246     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *finalMessage );
       
   247     dlg->PrepareLC( R_SISXUI_CAPAB_DIALOG );
       
   248     if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   249         {        
       
   250         dlg->SetLinkTextL( *linkText );
       
   251         TCallBack callback( ShowCapabilitiesHelp, this );    
       
   252         dlg->SetLink( callback );
       
   253         }    
       
   254 
       
   255     if ( !dlg->RunLD() )
       
   256         {
       
   257         // User cancelled
       
   258         iResult = TSisxUIResult( EUiResultCancelled );
       
   259         result = EFalse;        
       
   260         }    
       
   261     
       
   262     CleanupStack::PopAndDestroy( 3, messageString ); // finalMessage, linkText, messageString
       
   263 
       
   264     iShowingDialog = EFalse;    
       
   265     return result;       
       
   266     }
       
   267 										
       
   268 // -----------------------------------------------------------------------------
       
   269 // CSisxUIHandler::DisplayLanguageL
       
   270 // requests preferred language and dialect information from the UI.
       
   271 // (other items were commented in a header).
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 TInt CSisxUIHandler::DisplayLanguageL( const Swi::CAppInfo& /*aAppInfo*/, 
       
   275                                        const RArray<TLanguage>& aLanguages ) 
       
   276     {
       
   277     TInt languageIndex( 0 );
       
   278     TInt index( 0 );
       
   279     TLanguage phoneLanguage( User::Language() );    
       
   280 
       
   281     // If phones default language is available in the file, do not query the user
       
   282     for ( index = 0; index < aLanguages.Count(); index++ )
       
   283         {
       
   284         // Check if this matches the phone language        
       
   285         if( aLanguages[ index ] == phoneLanguage )
       
   286             {
       
   287             return index;
       
   288             }
       
   289         
       
   290         // Check if user has already selected this language during installation        
       
   291         if( iCache->LanguageCached() && aLanguages[index] == iCache->Language() )
       
   292             {
       
   293             // Do not query user, we have a cached language    
       
   294             return index;            
       
   295             }        
       
   296         }
       
   297 
       
   298     // If there is only one language in the list, do not query the user
       
   299     if( aLanguages.Count() == 1 )
       
   300         {
       
   301         return 0;        
       
   302         }
       
   303 
       
   304     iShowingDialog = ETrue;
       
   305 
       
   306     // Prepare for showing the language selection dialog
       
   307     CDesCArray *itemArray = new( ELeave ) CDesCArrayFlat(4);
       
   308     CleanupStack::PushL( itemArray );
       
   309     
       
   310     // construct the array of available languages
       
   311     TResourceReader reader;
       
   312     CEikonEnv::Static()->CreateResourceReaderLC( reader, R_SISXUI_LANGUAGES_ARRAY );
       
   313     RPointerArray<CLangName> langNameArray;
       
   314     CleanupResetAndDestroyPushL( langNameArray );
       
   315     TInt count = reader.ReadInt16();
       
   316     while( --count >= 0 )
       
   317         {
       
   318         CLangName* langName = CLangName::NewL( reader );
       
   319         langNameArray.AppendL( langName );
       
   320         }
       
   321 
       
   322     for ( index = 0; index <= aLanguages.Count() - 1; index++ )
       
   323         {
       
   324         TLanguage language = aLanguages[ index ];
       
   325         TInt nameIndex = langNameArray.Find( language, HasLangId );
       
   326         if ( nameIndex == KErrNotFound ) 
       
   327             {
       
   328             nameIndex = TLanguage( 0 );     // produces qtn_swins_lqi_unknow
       
   329             }
       
   330         itemArray->AppendL( langNameArray[ nameIndex ]->Name() );
       
   331         }
       
   332     
       
   333     // show list query
       
   334     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &languageIndex );
       
   335     dlg->PrepareLC( R_SISXUI_LANGUAGE_QUERY );
       
   336     dlg->SetItemTextArray( itemArray );
       
   337     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   338 
       
   339     if( languageIndex != 0 )
       
   340         {
       
   341         dlg->ListBox()->SetCurrentItemIndex( languageIndex );
       
   342         }
       
   343 
       
   344     TInt queryOk = dlg->RunLD();
       
   345     
       
   346     CleanupStack::PopAndDestroy( 3, itemArray ); // langNameArray, reader, itemArray
       
   347     
       
   348     if ( !queryOk )
       
   349         {        
       
   350         languageIndex = -1;
       
   351         iResult = TSisxUIResult( EUiResultCancelled );       
       
   352         }
       
   353     
       
   354     // Cache only if no previous cache is found
       
   355     if( languageIndex != -1 && !iCache->LanguageCached() )
       
   356         {
       
   357         iCache->SetLanguage( aLanguages[languageIndex] );
       
   358         }     
       
   359     
       
   360     iShowingDialog = EFalse;
       
   361     return languageIndex;
       
   362     }
       
   363 	
       
   364 // -----------------------------------------------------------------------------
       
   365 // CSisxUIHandler::DisplayDriveL
       
   366 // Requests the drive to install the package on, from the UI.
       
   367 // (other items were commented in a header).
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 TInt CSisxUIHandler::DisplayDriveL( const Swi::CAppInfo& /*aAppInfo*/, 
       
   371                                     TInt64 aSize,
       
   372                                     const RArray<TChar>& aDriveLetters,
       
   373                                     const RArray<TInt64>& aDriveSpaces ) 
       
   374     {
       
   375     if ( aDriveLetters.Count() <= 0 )
       
   376         {
       
   377         iResult = TSisxUIResult( EUiResultInsufficientMemory );
       
   378         return -1;        
       
   379         }    
       
   380 
       
   381     iShowingDialog = ETrue;
       
   382 
       
   383     RArray<TDriveUnit> driveUnits;
       
   384     CleanupClosePushL( driveUnits );
       
   385 
       
   386     TInt index( 0 );
       
   387 
       
   388     // Convert drive letters to TDriveUnits
       
   389     for ( index = 0; index < aDriveLetters.Count(); index++ )
       
   390         {
       
   391         TBuf<2> tmp;
       
   392         tmp.Append( aDriveLetters[index] );
       
   393         driveUnits.Append( TDriveUnit( tmp ) );
       
   394         }
       
   395     
       
   396     TInt selection( -1 );
       
   397     TInt dlgResult( KErrNone );    
       
   398 
       
   399     // See if the selection has been cached
       
   400     if ( iCache->DriveCached() )
       
   401         {
       
   402         for ( index = 0; index < aDriveLetters.Count(); index++ )
       
   403             {
       
   404             if ( (TInt)iCache->Drive() == (TInt)driveUnits[index] )
       
   405                 {
       
   406                 // Make sure, we have enough size in the cached drive
       
   407                 if ( aSize < aDriveSpaces[index] )
       
   408                     {
       
   409                     selection = index;
       
   410                     break;                    
       
   411                     }  
       
   412                 else
       
   413                     {
       
   414                     // Cached drive has insufficient memory, ask user again
       
   415                     dlgResult = iCommonDialogs->ShowDriveSelectionDialogL( aSize, 
       
   416                                                                            driveUnits, 
       
   417                                                                            aDriveSpaces, 
       
   418                                                                            selection );
       
   419                                 
       
   420                     break;
       
   421                     }                
       
   422                 }
       
   423             }        
       
   424         }
       
   425     // Not cached
       
   426     else
       
   427         {
       
   428         dlgResult = iCommonDialogs->ShowDriveSelectionDialogL( aSize, 
       
   429                                                                driveUnits, 
       
   430                                                                aDriveSpaces, 
       
   431                                                                selection );
       
   432         }
       
   433 
       
   434     if ( dlgResult == KErrNoMemory )
       
   435         {                       
       
   436         // No memory
       
   437         iResult = TSisxUIResult( EUiResultInsufficientMemory );
       
   438         selection = -1;                        
       
   439         }  
       
   440 
       
   441     else if ( dlgResult == KErrCancel )
       
   442         {
       
   443         // User cancelled
       
   444         iResult = TSisxUIResult( EUiResultCancelled );
       
   445         selection = -1;                        
       
   446         }    
       
   447 
       
   448     // If the result is valid, put it to the cache
       
   449     else if ( selection >= 0 )
       
   450         {            
       
   451         iCache->SetDrive( driveUnits[selection] );
       
   452         }
       
   453 
       
   454     CleanupStack::PopAndDestroy(); // driveUnits
       
   455 
       
   456     iShowingDialog = EFalse;
       
   457     return selection;    
       
   458     }
       
   459 	
       
   460 // -----------------------------------------------------------------------------
       
   461 // CSisxUIHandler::DisplayUpgradeL
       
   462 // Displays a dialog asking whether we want to upgrade an application present 
       
   463 // on the device.
       
   464 // (other items were commented in a header).
       
   465 // -----------------------------------------------------------------------------
       
   466 //
       
   467 TBool CSisxUIHandler::DisplayUpgradeL( const Swi::CAppInfo& aAppInfo, 
       
   468                                        const Swi::CAppInfo& aExistingAppInfo ) 
       
   469     {
       
   470     iShowingDialog = ETrue;
       
   471 
       
   472     TBool result( EFalse );
       
   473 
       
   474     TVersion newVersion = aAppInfo.AppVersion();
       
   475     TVersion oldVersion = aExistingAppInfo.AppVersion();
       
   476 
       
   477     // Display "Replace?" confirmation query only if the new version is older
       
   478     // than the currently installed old version (i.e. when downgrading). See
       
   479     // also User::QueryVersionSupported() although it has bit different meaning.
       
   480     TBool downgrading = ( newVersion.iMajor < oldVersion.iMajor ||
       
   481             ( newVersion.iMajor == oldVersion.iMajor && newVersion.iMinor < oldVersion.iMinor ) );
       
   482     if( !downgrading )
       
   483         {
       
   484         iShowingDialog = EFalse;
       
   485         return ETrue;
       
   486         }
       
   487 
       
   488     // Create strings from the version numbers
       
   489     //
       
   490     HBufC* tempBuf = 
       
   491         CommonUI::CUIUtils::ConstructVersionStringLC( oldVersion.iMajor, 
       
   492                                                       oldVersion.iMinor, 
       
   493                                                       oldVersion.iBuild );
       
   494                                                       
       
   495     HBufC* oldVersionBuf = HBufC::NewLC( KLRE().Length() + tempBuf->Length() + KPDF().Length() ); 
       
   496     TInt position = tempBuf->Find( KLeftParenthes() );
       
   497     if ( position >= 0 )
       
   498         {
       
   499         oldVersionBuf->Des() = tempBuf->Mid( 0, position );
       
   500         oldVersionBuf->Des() += KLRE();
       
   501         oldVersionBuf->Des() += tempBuf->Mid( position, tempBuf->Length() - position );
       
   502         oldVersionBuf->Des() += KPDF();
       
   503         }
       
   504     else
       
   505         {
       
   506         oldVersionBuf->Des() = *tempBuf;	
       
   507         }
       
   508     CleanupStack::Pop( oldVersionBuf );    
       
   509     CleanupStack::PopAndDestroy( tempBuf );
       
   510     CleanupStack::PushL( oldVersionBuf );
       
   511     tempBuf = NULL;
       
   512   
       
   513     tempBuf = CommonUI::CUIUtils::ConstructVersionStringLC( newVersion.iMajor, 
       
   514                                                             newVersion.iMinor, 
       
   515                                                             newVersion.iBuild );
       
   516     
       
   517     HBufC* newVersionBuf = HBufC::NewLC( KLRE().Length() + tempBuf->Length() + KPDF().Length() );
       
   518 
       
   519     position = tempBuf->Find( KLeftParenthes() );
       
   520     if ( position >= 0 )
       
   521         {
       
   522         newVersionBuf->Des() = tempBuf->Mid( 0, position );
       
   523         newVersionBuf->Des() += KLRE();
       
   524         newVersionBuf->Des() += tempBuf->Mid( position, tempBuf->Length() - position );
       
   525         newVersionBuf->Des() += KPDF();
       
   526         }
       
   527     else
       
   528         {
       
   529         newVersionBuf->Des() = *tempBuf;	
       
   530         }
       
   531     CleanupStack::Pop( newVersionBuf );
       
   532     CleanupStack::PopAndDestroy( tempBuf );
       
   533     CleanupStack::PushL( newVersionBuf );
       
   534 
       
   535     CDesCArray* stringArray = new ( ELeave ) CDesCArrayFlat( 4 );
       
   536     CleanupStack::PushL( stringArray );
       
   537     
       
   538     stringArray->AppendL( aAppInfo.AppName() );    
       
   539     stringArray->AppendL( *oldVersionBuf );    
       
   540     stringArray->AppendL( *newVersionBuf );    
       
   541 
       
   542     HBufC* upgradeString = 
       
   543         StringLoader::LoadLC( R_SISXUI_UPGRADE_PROMPT, *stringArray );
       
   544     TPtr ptr = upgradeString->Des();
       
   545     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
       
   546 
       
   547 
       
   548     if ( iCommonDialogs->ShowConfirmationQueryL( *upgradeString ) )
       
   549         {
       
   550         result = ETrue;        
       
   551         }   
       
   552     else
       
   553         {
       
   554         // User selected cancel. 
       
   555         iResult = TSisxUIResult( EUiResultCancelled );
       
   556         }
       
   557     
       
   558     CleanupStack::PopAndDestroy( 4 ); // upgradeString, stringArray, newVersionBuf, oldVersionBuf
       
   559     
       
   560     iShowingDialog = EFalse;
       
   561     return result;
       
   562     }
       
   563 
       
   564 // -----------------------------------------------------------------------------
       
   565 // CSisxUIHandler::DisplayOptionsL
       
   566 // Displays a dialog box asking which options the user wishes to install.
       
   567 // (other items were commented in a header).
       
   568 // -----------------------------------------------------------------------------
       
   569 //
       
   570 TBool CSisxUIHandler::DisplayOptionsL( const Swi::CAppInfo& /*aAppInfo*/,
       
   571                                        const RPointerArray<TDesC>& aOptions,
       
   572                                        RArray<TBool>& aSelections ) 
       
   573     {
       
   574     iShowingDialog = ETrue;
       
   575 
       
   576     TBool response;
       
   577     TInt index = 0;    
       
   578 
       
   579     if ( aOptions.Count() < 1 )
       
   580         {
       
   581         User::Leave( KErrArgument );        
       
   582         }
       
   583     
       
   584     CDesCArray* itemArray = new ( ELeave ) CDesCArrayFlat( 4 );
       
   585     CleanupStack::PushL( itemArray );
       
   586 
       
   587     // Construct text array for the dialog
       
   588     for( index = 0; index < aOptions.Count(); index++ )
       
   589         {
       
   590         TPtrC itemLabel( *( aOptions[index] ) ) ;        
       
   591         HBufC *itemLine = HBufC::NewLC( itemLabel.Length() + 2 ); // Add 2 for "1\t"
       
   592         TPtr itemPtr = itemLine->Des();
       
   593         itemPtr.Copy( _L("1\t") );
       
   594         itemPtr.Append( itemLabel );
       
   595         
       
   596         itemArray->AppendL( itemPtr );
       
   597 
       
   598         CleanupStack::PopAndDestroy( itemLine );
       
   599         }    
       
   600 
       
   601     // Create and selection index array for multiselection list
       
   602     CListBoxView::CSelectionIndexArray* selections = 
       
   603         new ( ELeave ) CArrayFixFlat<TInt>( aSelections.Count() );
       
   604     CleanupStack::PushL( selections );    
       
   605     // Set all selections marked by default.
       
   606     for ( index = 0; index < aSelections.Count(); index++ )
       
   607         {
       
   608         selections->AppendL( index );        
       
   609         }
       
   610 
       
   611     // Create multiselection list query
       
   612     CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( selections );
       
   613 
       
   614     dlg->PrepareLC( R_SISXUI_OPTIONS_QUERY );
       
   615     dlg->SetItemTextArray( itemArray );
       
   616     // Set all selections marked by default.
       
   617     dlg->ListBox()->SetSelectionIndexesL( selections );    
       
   618     
       
   619     dlg->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   620     ((CEikFormattedCellListBox*)(dlg->ListBox()))->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
       
   621     TInt queryOk = dlg->RunLD();
       
   622     
       
   623     if( !queryOk )
       
   624         {
       
   625         response = EFalse;
       
   626         iResult = TSisxUIResult( EUiResultCancelled );
       
   627         }
       
   628     else
       
   629         {
       
   630         response = ETrue;
       
   631 
       
   632         // First set all items in aSelections to EFalse
       
   633         for( index = 0; index < aSelections.Count(); index++ )
       
   634             {
       
   635             aSelections[index] = EFalse;
       
   636             }
       
   637         // Then copy selections to aSelections
       
   638         for( index = 0; index < selections->Count(); index++ )
       
   639             {
       
   640             TInt selectedItem = selections->At( index );
       
   641             aSelections[selectedItem] = ETrue;
       
   642             }
       
   643         
       
   644         }
       
   645 
       
   646     CleanupStack::PopAndDestroy( 2 ); // itemArray, selections
       
   647  
       
   648     iShowingDialog = EFalse;
       
   649     return response;
       
   650     }
       
   651 
       
   652 // -----------------------------------------------------------------------------
       
   653 // CSisxUIHandler::HandleInstallEventL
       
   654 // Informs the UI of events occurring during installation.
       
   655 // (other items were commented in a header).
       
   656 // -----------------------------------------------------------------------------
       
   657 //
       
   658 TBool CSisxUIHandler::HandleInstallEventL( const Swi::CAppInfo& aAppInfo,
       
   659                                           Swi::TInstallEvent aEvent, 
       
   660                                           TInt aValue, 
       
   661                                           const TDesC& /*aDesC*/ )
       
   662     {
       
   663     TBool result( ETrue );    
       
   664     iShowingDialog = ETrue;
       
   665 
       
   666     switch ( aEvent )
       
   667         {
       
   668         case Swi::EEventSetProgressBarFinalValue:
       
   669             if ( iMode == EModeInstall )
       
   670                 {                
       
   671                 // Show installing progress dialog.
       
   672                 iCommonDialogs->ShowProgressDialogL( R_SISXUI_INSTALLING, this );
       
   673 
       
   674                 // Here we need to update the name and vendor of the main package.
       
   675                 // They might have changed when a language has been selected.
       
   676                 if ( iPackages.Count() > 0 )
       
   677                     {                    
       
   678                     iPackages[0]->SetNameL( aAppInfo.AppName() );
       
   679                     iPackages[0]->SetVendorL( aAppInfo.AppVendor() );
       
   680                     }                
       
   681                 }
       
   682             else
       
   683                 {               
       
   684                 // Show uninstalling progress dialog.
       
   685                 iCommonDialogs->ShowProgressDialogL( R_SISXUI_UNINSTALLING, this, R_AVKON_SOFTKEYS_EMPTY );
       
   686                 }         
       
   687             iCommonDialogs->SetProgressDialogFinalValueL( aValue );
       
   688 
       
   689             break;  
       
   690             
       
   691         case Swi::EEventUpdateProgressBar:
       
   692             iCommonDialogs->UpdateProgressDialogValueL( aValue );
       
   693             break;  
       
   694        
       
   695         case Swi::EEventOcspCheckEnd:
       
   696             iCommonDialogs->CloseWaitDialogL();
       
   697             iOcspInProgress = EFalse;            
       
   698             break;
       
   699 
       
   700         case Swi::EEventDevCert:
       
   701             {        
       
   702             HBufC* messageString = StringLoader::LoadLC( R_SISXUI_DEVCERT_WARNING );
       
   703             CAknMessageQueryDialog* dlg = 
       
   704                 CAknMessageQueryDialog::NewL( *messageString, CAknQueryDialog::EWarningTone );
       
   705             if ( !dlg->ExecuteLD( R_SISXUI_DEVCERT_DIALOG ) )
       
   706                 {
       
   707                 // User cancelled
       
   708                 iResult = TSisxUIResult( EUiResultCancelled );
       
   709                 result = EFalse;                
       
   710                 }    
       
   711             CleanupStack::PopAndDestroy( messageString );
       
   712             }
       
   713             break;
       
   714 
       
   715             // Ignored
       
   716         case Swi::EEventCompletedUnInstall:            
       
   717         case Swi::EEventCompletedInstall:                        
       
   718         case Swi::EEventAbortedInstall:
       
   719         case Swi::EEventAbortedUnInstall:       
       
   720         case Swi::EEventLeave:
       
   721         default:
       
   722             break;
       
   723             
       
   724         }
       
   725 
       
   726     // See if user has requested an cancel and our state is cancellable
       
   727     if ( result && iCancelRequested &&  
       
   728          ( aEvent == Swi::EEventSetProgressBarFinalValue ||
       
   729            aEvent == Swi::EEventUpdateProgressBar ||
       
   730            aEvent == Swi::EEventOcspCheckEnd ) )
       
   731         {
       
   732         iCancelRequested = EFalse;        
       
   733         // Show the confirmation prompt
       
   734         if ( iCommonDialogs->ShowConfirmationQueryL( R_SWCOMMON_CANCEL_INSTALLATION, 
       
   735                                                      R_AVKON_SOFTKEYS_YES_NO__YES ) )
       
   736             {
       
   737             // Ok to cancel       
       
   738             iResult = TSisxUIResult( EUiResultCancelled );
       
   739             iCancelObserver->UserCancelL( ETrue );            
       
   740             }                
       
   741         }    
       
   742     
       
   743     iShowingDialog = EFalse;
       
   744     return result;
       
   745     }
       
   746 
       
   747 // -----------------------------------------------------------------------------
       
   748 // CSisxUIHandler::HandleCancellableInstallEventL
       
   749 // Informs the UI of cancellable events occurring during installation.  
       
   750 // (other items were commented in a header).
       
   751 // -----------------------------------------------------------------------------
       
   752 //
       
   753 void CSisxUIHandler::HandleCancellableInstallEventL( const Swi::CAppInfo& /*aAppInfo*/,
       
   754                                                      Swi::TInstallCancellableEvent aEvent, 
       
   755                                                      Swi::MCancelHandler& /*aCancelHandler*/,
       
   756                                                      TInt /*aValue*/, 
       
   757                                                      const TDesC& /*aDes*/ )
       
   758     {
       
   759     switch ( aEvent )
       
   760         {
       
   761         case Swi::EEventOcspCheckStart:
       
   762             {
       
   763             // Show ocsp wait dialog
       
   764             iCommonDialogs->ShowWaitDialogL( R_SISXUI_DOING_OCSP, this );
       
   765             iOcspInProgress = ETrue;            
       
   766             break;      
       
   767             }
       
   768 
       
   769             // These are ignored
       
   770         case Swi::EEventRemovingFiles:
       
   771         case Swi::EEventCopyingFiles:
       
   772         case Swi::EEventShuttingDownApps:
       
   773         default:
       
   774             break;            
       
   775         }    
       
   776     }
       
   777 
       
   778 // -----------------------------------------------------------------------------
       
   779 // CSisxUIHandler::DisplaySecurityWarningL
       
   780 // Displays a dialog indicating that the package is unsigned, or that signature 
       
   781 // validation has failed.
       
   782 // (other items were commented in a header).
       
   783 // -----------------------------------------------------------------------------
       
   784 //
       
   785 TBool CSisxUIHandler::DisplaySecurityWarningL( const Swi::CAppInfo& aAppInfo,
       
   786                                                Swi::TSignatureValidationResult aSigValidationResult,
       
   787                                                RPointerArray<CPKIXValidationResultBase>& aPkixResults,
       
   788                                                RPointerArray<Swi::CCertificateInfo>& aCertificates,
       
   789                                                TBool aInstallAnyway )
       
   790     {
       
   791 #ifdef RD_COMBINE_INSTALLATION_QUERIES //with new dialog sequence
       
   792     // Close the preparing wait dialog
       
   793     iCommonDialogs->CloseWaitDialogL();
       
   794 #endif //RD_COMBINE_INSTALLATION_QUERIES
       
   795     iShowingDialog = ETrue;
       
   796 
       
   797     FLOG_1( _L("CSisxUIHandler::DisplaySecurityWarningL: %d"), aSigValidationResult );    
       
   798     TBool result( ETrue );
       
   799     
       
   800     switch ( aSigValidationResult )
       
   801         {
       
   802         case Swi::EValidationSucceeded:       
       
   803             {
       
   804             CSisxUIAppInfo* appInfo = CSisxUIAppInfo::NewL( aAppInfo, ETrue );
       
   805             iPackages.Append( appInfo );
       
   806             
       
   807             for ( TInt index = 0; index < aCertificates.Count(); index++ )
       
   808                 {
       
   809                 TValidationStatus status = aPkixResults[index]->Error();
       
   810                 if ( status.iReason == EValidatedOK )
       
   811                     {                    
       
   812                     CSisxUICertificateInfo* certInfo = CSisxUICertificateInfo::NewL( *aCertificates[index] );
       
   813                     CleanupStack::PushL( certInfo );
       
   814                     User::LeaveIfError( iCertificateArray.Append( certInfo ));
       
   815                     CleanupStack::Pop( certInfo );
       
   816                     }                
       
   817                 }
       
   818 
       
   819             appInfo->PrepareIteratorL( aAppInfo );            
       
   820 #ifdef RD_COMBINE_INSTALLATION_QUERIES //with new dialog sequence
       
   821             CommonUI::CCUIDetailsDialog* details = 
       
   822                 CommonUI::CCUIDetailsDialog::NewL( R_AVKON_SOFTKEYS_OK_CANCEL__OK, ETrue );
       
   823 #else       //with old dialog sequence            
       
   824             CommonUI::CCUIDetailsDialog* details = 
       
   825                 CommonUI::CCUIDetailsDialog::NewL( R_SWCOMMON_SOFTKEYS_CONTINUE_CANCEL__CONTINUE, ETrue );
       
   826 #endif //RD_COMBINE_INSTALLATION_QUERIES
       
   827             if ( !iIsDrmFileSet )
       
   828                 {                
       
   829                 result = details->ExecuteLD( *appInfo, iCertificateArray );
       
   830                 }
       
   831             else
       
   832                 {
       
   833                 result = details->ExecuteLD( *appInfo, iCertificateArray, iDrmFile );
       
   834                 }
       
   835             appInfo->FreeIterator();            
       
   836 
       
   837             if ( !result )
       
   838                 {
       
   839                 // User cancelled
       
   840                 iResult = TSisxUIResult( EUiResultCancelled );
       
   841                 }            
       
   842             
       
   843             iCertificateArray.ResetAndDestroy();            
       
   844             
       
   845             break;
       
   846             }       
       
   847 
       
   848             // Non fatals
       
   849         case Swi::ESignatureSelfSigned:
       
   850         case Swi::ESignatureNotPresent:
       
   851         case Swi::ENoCertificate:
       
   852         case Swi::ECertificateValidationError:
       
   853         case Swi::ENoCodeSigningExtension:
       
   854         case Swi::ENoSupportedPolicyExtension:
       
   855             // Fatals with aInstallAnyway set as EFalse
       
   856         case Swi::ESignatureCouldNotBeValidated:
       
   857         case Swi::EMandatorySignatureMissing:
       
   858             {
       
   859             // Check if we are allowed to continue installation
       
   860             if ( aInstallAnyway && iAllowUntrusted )
       
   861                 {          
       
   862 #ifdef RD_COMBINE_INSTALLATION_QUERIES //with new dialog sequence
       
   863 
       
   864                 CSisxUIAppInfo* appInfo = CSisxUIAppInfo::NewL( aAppInfo, EFalse );
       
   865                 iPackages.Append( appInfo );
       
   866                 appInfo->PrepareIteratorL( aAppInfo );            
       
   867                 CommonUI::CCUIDetailsDialog* details = 
       
   868                 CommonUI::CCUIDetailsDialog::NewL( R_AVKON_SOFTKEYS_OK_CANCEL__OK, ETrue );
       
   869                 if ( !iIsDrmFileSet )
       
   870                     {                
       
   871                     result = details->ExecuteLD( *appInfo );
       
   872                     }
       
   873                 else
       
   874                     {
       
   875                     result = details->ExecuteLD( *appInfo, iDrmFile );
       
   876                     }
       
   877                 appInfo->FreeIterator();
       
   878                 if ( result )
       
   879                     {
       
   880                 	result = iCommonDialogs->ShowSecurityWarningDialogL();
       
   881                     }
       
   882                         
       
   883 #else           //with old dialog sequence   
       
   884       
       
   885                 result = iCommonDialogs->ShowSecurityWarningDialogL();
       
   886                 
       
   887                 if ( result )
       
   888                     {
       
   889                     CSisxUIAppInfo* appInfo = CSisxUIAppInfo::NewL( aAppInfo, EFalse );
       
   890                     iPackages.Append( appInfo );
       
   891                     appInfo->PrepareIteratorL( aAppInfo );            
       
   892                     CommonUI::CCUIDetailsDialog* details = 
       
   893                         CommonUI::CCUIDetailsDialog::NewL( R_SWCOMMON_SOFTKEYS_CONTINUE_CANCEL__CONTINUE );
       
   894                     if ( !iIsDrmFileSet )
       
   895                         {                
       
   896                         result = details->ExecuteLD( *appInfo );
       
   897                         }
       
   898                     else
       
   899                         {
       
   900                         result = details->ExecuteLD( *appInfo, iDrmFile );
       
   901                         }
       
   902                     appInfo->FreeIterator();
       
   903                     }
       
   904                     
       
   905 #endif //RD_COMBINE_INSTALLATION_QUERIES
       
   906 
       
   907                 if ( !result )
       
   908                     {
       
   909                     // User cancelled
       
   910                     iResult = TSisxUIResult( EUiResultCancelled );
       
   911                     }                
       
   912                 }
       
   913             else
       
   914                 {
       
   915                 iResult = TSisxUIResult( aSigValidationResult );
       
   916                 result = EFalse;
       
   917 
       
   918                 // Fatal error, not allowed to continue
       
   919                 // Try to see if the error was due to invalid date in the certificate
       
   920                 for ( TInt index = 0; index < aPkixResults.Count(); index++ )
       
   921                     {
       
   922                     TValidationStatus status = aPkixResults[index]->Error();
       
   923                     if ( status.iReason == EDateOutOfRange )
       
   924                         {
       
   925                         // Compare timestamps, use secure time if available
       
   926                         TTime now;
       
   927                         if( now.UniversalTimeSecure() != KErrNone )
       
   928                             {
       
   929                             // KErrNoSecureTime or other error
       
   930                             now.UniversalTime();
       
   931                             }
       
   932                         TTime validFrom( aCertificates[index]->ValidFrom() );
       
   933                         
       
   934                         if ( now < validFrom )
       
   935                             {
       
   936                             // Certificate valid in future
       
   937                             iResult = TSisxUIResult( EUiResultCertificateValidInFuture );
       
   938                             }
       
   939                         else
       
   940                             {
       
   941                             // Certificate expired
       
   942                             iResult = TSisxUIResult( EUiResultCertificateExpired );
       
   943                             }
       
   944 
       
   945                         break;                        
       
   946                         }                    
       
   947                     }
       
   948                 }            
       
   949             break;
       
   950             }
       
   951 
       
   952         default:
       
   953             iResult = TSisxUIResult( aSigValidationResult );
       
   954             result = EFalse;
       
   955             break;            
       
   956         }
       
   957     
       
   958     iShowingDialog = EFalse;
       
   959     return result;    
       
   960     }
       
   961 	
       
   962 // -----------------------------------------------------------------------------
       
   963 // CSisxUIHandler::DisplayOcspResultL
       
   964 // Displays a dialog indicating that there was an error carrying out online 
       
   965 // certificate status checking.
       
   966 // (other items were commented in a header).
       
   967 // -----------------------------------------------------------------------------
       
   968 //
       
   969 TBool CSisxUIHandler::DisplayOcspResultL( const Swi::CAppInfo& /*aAppInfo*/,
       
   970                                           Swi::TRevocationDialogMessage aMessage, 
       
   971                                           RPointerArray<TOCSPOutcome>& /*aOutcomes*/, 
       
   972                                           RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/,
       
   973                                           TBool aWarningOnly )
       
   974     {
       
   975     iShowingDialog = ETrue;
       
   976 
       
   977     FLOG_1( _L("CSisxUIHandler::DisplayOcspResultL: %d"), aMessage );    
       
   978     TBool result( ETrue );
       
   979 
       
   980     // This will be treated as warning if engine says it's a warning and
       
   981     // ocsp setting is on. In case it's must, we abort the installation.
       
   982     if ( aWarningOnly && iOcspProc == ESisxUIOcspProcOn )
       
   983         {
       
   984         result = iCommonDialogs->ShowConfirmationQueryL( R_SISXUI_OCSP_SECURITY_WARNING );
       
   985         if ( !result )
       
   986             {
       
   987             // User cancelled the installation
       
   988             iResult = TSisxUIResult( EUiResultCancelled );
       
   989             }                
       
   990         }
       
   991     // error or ocsp is set to must
       
   992     else
       
   993         {
       
   994         iResult = TSisxUIResult( aMessage );
       
   995         result = EFalse; 
       
   996         }            
       
   997 
       
   998     iShowingDialog = EFalse;
       
   999     return result;    
       
  1000     }
       
  1001 
       
  1002 // -----------------------------------------------------------------------------
       
  1003 // CSisxUIHandler::DisplayCannotOverwriteFileL
       
  1004 // Used to inform the user the installation they are attempting is trying to 
       
  1005 // overwrite a file that does not belong to it. Following this message 
       
  1006 // installation is aborted.
       
  1007 // (other items were commented in a header).
       
  1008 // -----------------------------------------------------------------------------
       
  1009 //
       
  1010 void CSisxUIHandler::DisplayCannotOverwriteFileL( const Swi::CAppInfo& /*aAppInfo*/,
       
  1011                                                   const Swi::CAppInfo& /*aInstalledAppInfo*/,
       
  1012                                                   const TDesC& aFileName )
       
  1013     {
       
  1014     FLOG_1( _L("CSisxUIHandler::DisplayCannotOverwriteFileL: %S"), &aFileName );    
       
  1015     iResult = TSisxUIResult( EUiResultUnableToOverwrite );
       
  1016     // Keep compiler happy
       
  1017     (void)aFileName;    
       
  1018     }
       
  1019  
       
  1020 // -----------------------------------------------------------------------------
       
  1021 // CSisxUIHandler::DisplayMissingDependencyL
       
  1022 // Used to inform the user of a missing dependency needed to install the 
       
  1023 // current package. It is up to the UI implementors and/or the user whether
       
  1024 // or not this warning can be overridden.
       
  1025 // (other items were commented in a header).
       
  1026 // -----------------------------------------------------------------------------
       
  1027 //
       
  1028 TBool CSisxUIHandler::DisplayMissingDependencyL( const Swi::CAppInfo& /*aAppInfo*/,
       
  1029                                                  const TDesC& aDependencyName,
       
  1030                                                  TVersion aWantedVersionFrom,
       
  1031                                                  TVersion aWantedVersionTo,
       
  1032                                                  TVersion aInstalledVersion )
       
  1033     {
       
  1034     iShowingDialog = ETrue;
       
  1035 
       
  1036     TBool result( EFalse );
       
  1037     
       
  1038     // Dependency component not installed    
       
  1039     if ( ( aInstalledVersion.iMajor == 0 && 
       
  1040            aInstalledVersion.iMinor == 0 &&
       
  1041            aInstalledVersion.iBuild == 0 ) || 
       
  1042          ( aWantedVersionFrom.iMajor == 0 && 
       
  1043            aWantedVersionFrom.iMinor == 0 &&
       
  1044            aWantedVersionFrom.iBuild == 0 ) )     
       
  1045         {
       
  1046         HBufC* prompt = 
       
  1047             StringLoader::LoadLC( R_SISXUI_COMPONENT_MISSING, aDependencyName );
       
  1048         
       
  1049         if ( iCommonDialogs->ShowConfirmationQueryL( *prompt ) )
       
  1050             {
       
  1051             result = ETrue;        
       
  1052             }
       
  1053 
       
  1054         CleanupStack::PopAndDestroy( prompt );        
       
  1055         }
       
  1056 
       
  1057     else
       
  1058         {
       
  1059         CDesCArray* stringArray = new ( ELeave ) CDesCArrayFlat( 2 );
       
  1060         CleanupStack::PushL( stringArray );
       
  1061         
       
  1062         stringArray->AppendL( aDependencyName );
       
  1063         stringArray->AppendL( aWantedVersionFrom.Name() );
       
  1064         
       
  1065         HBufC* string = NULL;
       
  1066         
       
  1067         // Specific version is needed        
       
  1068         if ( aWantedVersionTo.iMajor == aWantedVersionFrom.iMajor &&
       
  1069              aWantedVersionTo.iMinor == aWantedVersionFrom.iMinor &&
       
  1070              aWantedVersionTo.iBuild == aWantedVersionFrom.iBuild )          
       
  1071             {
       
  1072             string = StringLoader::LoadLC( R_SISXUI_REQUIRE_VER, *stringArray );
       
  1073             }
       
  1074 
       
  1075         // Version or greater is needed
       
  1076         else
       
  1077             {
       
  1078             string = StringLoader::LoadLC( R_SISXUI_REQUIRE_VER_OR_GREATER, *stringArray );
       
  1079             }       
       
  1080 
       
  1081         TPtr ptr = string->Des();
       
  1082         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); 
       
  1083 
       
  1084         ShowErrorL( *string );
       
  1085         
       
  1086         CleanupStack::PopAndDestroy( 2); // stringArray, string
       
  1087         }
       
  1088 
       
  1089     if ( !result )
       
  1090         {        
       
  1091         iResult = TSisxUIResult( EUiResultCancelled );
       
  1092         }
       
  1093 
       
  1094     iShowingDialog = EFalse;
       
  1095     return result;
       
  1096     }
       
  1097        
       
  1098 // -----------------------------------------------------------------------------
       
  1099 // CSisxUIHandler::DisplayUninstallL
       
  1100 // Displays a dialog at the start of the uninstallation with information about 
       
  1101 // the application to be uninstalled. The user may cancel the uninstallation at 
       
  1102 // this stage. This dialog must be shown in TrustedUI mode.
       
  1103 // (other items were commented in a header).
       
  1104 // -----------------------------------------------------------------------------
       
  1105 //
       
  1106 TBool CSisxUIHandler::DisplayUninstallL( const Swi::CAppInfo& aAppInfo )
       
  1107     {
       
  1108     iShowingDialog = ETrue;
       
  1109 
       
  1110     TBool result( EFalse );
       
  1111 
       
  1112     CSisxUIAppInfo* appInfo = CSisxUIAppInfo::NewL( aAppInfo, EFalse );
       
  1113     iPackages.Append( appInfo );
       
  1114 
       
  1115     HBufC* prompt = StringLoader::LoadLC( R_SISXUI_UNINSTALL_PROMPT, aAppInfo.AppName() );
       
  1116     if ( iCommonDialogs->ShowConfirmationQueryL( *prompt, R_AVKON_SOFTKEYS_YES_NO__YES ) )
       
  1117         {
       
  1118         result = ETrue;
       
  1119         }   
       
  1120     else
       
  1121         {
       
  1122         iResult = TSisxUIResult( EUiResultCancelled );        
       
  1123         // Make sure no notes are shown after this
       
  1124         iShownFinalNote = ETrue;       
       
  1125         }
       
  1126     CleanupStack::PopAndDestroy( prompt );
       
  1127 
       
  1128     iShowingDialog = EFalse;
       
  1129     return result;
       
  1130     }
       
  1131 
       
  1132 // -----------------------------------------------------------------------------
       
  1133 // CSisxUIHandler::DisplayTextL
       
  1134 // Displays a dialog containing text. This dialog has only a Continue button if 
       
  1135 // aOption is EInstFileTextOptionContinue, or Yes and No buttons otherwise.
       
  1136 // (other items were commented in a header).
       
  1137 // -----------------------------------------------------------------------------
       
  1138 //
       
  1139 TBool CSisxUIHandler::DisplayTextL( const Swi::CAppInfo& aAppInfo, 
       
  1140                                     Swi::TFileTextOption aOption,
       
  1141                                     const TDesC& aText ) 
       
  1142     {
       
  1143     iShowingDialog = ETrue;
       
  1144 
       
  1145     HBufC* text = aText.AllocLC();
       
  1146     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL( *text );
       
  1147     dlg->PrepareLC( R_SISXUI_TEXT_DIALOG );
       
  1148     CleanupStack::PushL( dlg );    
       
  1149 
       
  1150     switch ( aOption )
       
  1151         {
       
  1152         case Swi::EInstFileTextOptionContinue:
       
  1153             dlg->ButtonGroupContainer().SetCommandSetL( R_SISXUI_SOFTKEYS_CONTINUE_EMPTY__CONTINUE );
       
  1154             break;            
       
  1155             
       
  1156         case Swi::EInstFileTextOptionSkipOneIfNo:
       
  1157             dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_YES_NO__YES );
       
  1158             break;
       
  1159             
       
  1160         case Swi::EInstFileTextOptionAbortIfNo:
       
  1161             dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL__OK );
       
  1162             break;
       
  1163             
       
  1164         case Swi::EInstFileTextOptionExitIfNo:
       
  1165             dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OK_CANCEL__OK );
       
  1166             break;
       
  1167 
       
  1168         default:
       
  1169             dlg->ButtonGroupContainer().SetCommandSetL( R_AVKON_SOFTKEYS_OK_EMPTY__OK );
       
  1170             break;            
       
  1171         }
       
  1172     
       
  1173     dlg->QueryHeading()->SetTextL( aAppInfo.AppName() );        
       
  1174     CleanupStack::Pop( dlg );    
       
  1175     TBool result = dlg->RunLD();   
       
  1176     
       
  1177     CleanupStack::PopAndDestroy( text );    
       
  1178 
       
  1179     if ( !result )
       
  1180         {
       
  1181         iResult = TSisxUIResult( EUiResultCancelled );
       
  1182         }
       
  1183     
       
  1184     iShowingDialog = EFalse;
       
  1185     return result;    
       
  1186     }
       
  1187 
       
  1188 // -----------------------------------------------------------------------------
       
  1189 // CSisxUIHandler::DisplayErrorL
       
  1190 // Displays a dialog showing an error message.
       
  1191 // (other items were commented in a header).
       
  1192 // -----------------------------------------------------------------------------
       
  1193 //
       
  1194 void CSisxUIHandler::DisplayErrorL( const Swi::CAppInfo& /*aAppInfo*/,
       
  1195                                     Swi::TErrorDialog aType, 
       
  1196                                     const TDesC& aParam ) 
       
  1197     {
       
  1198     FLOG_2( _L("CSisxUIHandler::DisplayErrorL: %d, %S"), aType, &aParam );    
       
  1199     iResult = TSisxUIResult( aType );
       
  1200     // Keep compiler happy
       
  1201     (void)aParam;    
       
  1202     }
       
  1203 
       
  1204 // -----------------------------------------------------------------------------
       
  1205 // CSisxUIHandler::DisplayDependencyBreakL
       
  1206 // Displays a dialog indicating that a component which is being uninstalled is 
       
  1207 // a dependency of another component installed.
       
  1208 // (other items were commented in a header).
       
  1209 // -----------------------------------------------------------------------------
       
  1210 //
       
  1211 TBool CSisxUIHandler::DisplayDependencyBreakL( const Swi::CAppInfo& /*aAppInfo*/,
       
  1212                                                const RPointerArray<TDesC>& /*aComponents*/ )
       
  1213     {
       
  1214     iShowingDialog = ETrue;
       
  1215 
       
  1216     TBool result( ETrue );
       
  1217     
       
  1218     result = iCommonDialogs->ShowConfirmationQueryL( R_SISXUI_DEPENDENCY_BREAK );
       
  1219 
       
  1220     if ( !result )
       
  1221         {
       
  1222         iResult = TSisxUIResult( EUiResultCancelled );
       
  1223         }
       
  1224     
       
  1225     iShowingDialog = EFalse;
       
  1226     return result;
       
  1227     }
       
  1228 		
       
  1229 // -----------------------------------------------------------------------------
       
  1230 // CSisxUIHandler::DisplayApplicationsInUseL
       
  1231 // Informs user that the applications are in use during an (un)installation.
       
  1232 // (other items were commented in a header).
       
  1233 // -----------------------------------------------------------------------------
       
  1234 //
       
  1235 TBool CSisxUIHandler::DisplayApplicationsInUseL( const Swi::CAppInfo& /*aAppInfo*/, 
       
  1236                                                  const RPointerArray<TDesC>& /*aAppNames*/ )
       
  1237     {
       
  1238     iShowingDialog = ETrue;
       
  1239 
       
  1240     TBool result( ETrue );
       
  1241     
       
  1242     if ( iMode == EModeInstall )
       
  1243         {
       
  1244         result = iCommonDialogs->ShowConfirmationQueryL( R_SISXUI_CLOSE_MULTI_INST );        
       
  1245         }
       
  1246     else
       
  1247         {
       
  1248         result = iCommonDialogs->ShowConfirmationQueryL( R_SISXUI_CLOSE_MULTI_UNINST );        
       
  1249         }    
       
  1250     
       
  1251     if ( !result )
       
  1252         {
       
  1253         TRAP_IGNORE( iCommonDialogs->CloseProgressDialogL() );
       
  1254         iResult = TSisxUIResult( EUiResultCancelled );
       
  1255         if ( iMode == EModeUninstall )
       
  1256             {
       
  1257         	// Display Wait dialog while Symbian SWI is cancelling uninstall process.	
       
  1258             iCommonDialogs->ShowWaitDialogL( R_SISXUI_CANCELLING, 
       
  1259                                              this, 
       
  1260                                              R_AVKON_SOFTKEYS_EMPTY );
       
  1261             iShowingWaitDialog = ETrue;
       
  1262             }
       
  1263         
       
  1264         }
       
  1265 
       
  1266     iShowingDialog = EFalse;
       
  1267     return result;
       
  1268     }
       
  1269 	
       
  1270 // -----------------------------------------------------------------------------
       
  1271 // CSisxUIHandler::DisplayQuestionL
       
  1272 // Displays a generic question dialog with a Yes/No answer.
       
  1273 // (other items were commented in a header).
       
  1274 // -----------------------------------------------------------------------------
       
  1275 //
       
  1276 TBool CSisxUIHandler::DisplayQuestionL( const Swi::CAppInfo& /*aAppInfo*/, 
       
  1277                                         Swi::TQuestionDialog aQuestion, 
       
  1278                                         const TDesC& /*aDes*/ )
       
  1279     {
       
  1280     iShowingDialog = ETrue;
       
  1281 
       
  1282     TBool result( ETrue );
       
  1283     
       
  1284     if ( aQuestion == Swi::EQuestionIncompatible && !iIncompatibleShown )
       
  1285         {
       
  1286         // Incompatible application        
       
  1287         result = iCommonDialogs->ShowConfirmationQueryL( R_SISXUI_INCOMP_PACKAGE, R_AVKON_SOFTKEYS_YES_NO__YES );
       
  1288         // Make sure this question is not asked twice.
       
  1289         iIncompatibleShown = ETrue;        
       
  1290         }
       
  1291 
       
  1292     if ( !result )
       
  1293         {
       
  1294         iResult = TSisxUIResult( EUiResultCancelled );
       
  1295         }
       
  1296 
       
  1297     iShowingDialog = EFalse;
       
  1298     return result;    
       
  1299     }
       
  1300 
       
  1301 // -----------------------------------------------------------------------------
       
  1302 // CSisxUIHandler::HandleDialogExitL
       
  1303 // Called when wait/progress dialog is about to be cancelled.
       
  1304 // (other items were commented in a header).
       
  1305 // -----------------------------------------------------------------------------
       
  1306 //
       
  1307 TBool CSisxUIHandler::HandleDialogExitL( TInt aButtonId )
       
  1308     {
       
  1309     TBool result( EFalse );
       
  1310     
       
  1311     if ( aButtonId == EAknSoftkeyCancel )
       
  1312         {        
       
  1313         if ( iOcspInProgress )
       
  1314             {
       
  1315             result = ETrue;            
       
  1316             // We need to cancel immediately            
       
  1317             iResult = TSisxUIResult( EUiResultCancelled );
       
  1318             iCancelObserver->UserCancelL( EFalse ); 
       
  1319             }
       
  1320         else
       
  1321             {
       
  1322             // User will still get confirmation
       
  1323             iCancelRequested = ETrue;        
       
  1324             }
       
  1325         
       
  1326         }    
       
  1327 
       
  1328     return result;    
       
  1329     }
       
  1330 
       
  1331 // -----------------------------------------------------------------------------
       
  1332 // CSisxUIHandler::ProcessResult
       
  1333 // Process the result of the (un)installation.
       
  1334 // (other items were commented in a header).
       
  1335 // -----------------------------------------------------------------------------
       
  1336 //
       
  1337 void CSisxUIHandler::ProcessResult( TInt aResult )
       
  1338     {
       
  1339     // In case we havent got a result from callbacks, we need to use one
       
  1340     // from the engine complete code.
       
  1341     if ( iResult.iResult == EUiResultNoResult )
       
  1342         {
       
  1343         switch ( aResult )
       
  1344             {
       
  1345             case KErrNone:
       
  1346                  // This means that the result was ok
       
  1347                 iResult = TSisxUIResult( EUiResultOk );
       
  1348                 break;
       
  1349                 
       
  1350             case KErrAccessDenied:
       
  1351                 iResult = TSisxUIResult( EUiResultAccessDenied );
       
  1352                 break;
       
  1353 
       
  1354             case KSWInstErrUserCancel:
       
  1355                 iResult = TSisxUIResult( EUiResultCancelled );
       
  1356                 break;
       
  1357 
       
  1358             case KSWInstErrFileCorrupted:
       
  1359                 iResult = TSisxUIResult( EUiResultFileCorrupt );
       
  1360                 break;  
       
  1361 
       
  1362             case KErrInvalidUpgrade:
       
  1363                 iResult = TSisxUIResult( EUiResultInvalidUpgrade );
       
  1364                 break; 
       
  1365 
       
  1366             case KErrNoMemory:
       
  1367             case KErrDiskFull:
       
  1368                 iResult = TSisxUIResult( EUiResultInsufficientMemory );
       
  1369                 break;                
       
  1370 
       
  1371             case KErrCancel:
       
  1372                 iResult = TSisxUIResult( EUiResultCancelled );
       
  1373                 break;                
       
  1374                 
       
  1375             default:
       
  1376                 if ( iMode == EModeInstall && !iIntegrityCheckDone )
       
  1377                     {
       
  1378                     // Sisx integrity check has not been done, report file
       
  1379                     // corrupt
       
  1380                     iResult = TSisxUIResult( EUiResultFileCorrupt );                    
       
  1381                     }    
       
  1382                 else
       
  1383                     {
       
  1384                     // Report general error
       
  1385                     iResult = TSisxUIResult( EUiResultGeneralError );
       
  1386                     iResult.iDetailedErrorCode = aResult;
       
  1387                     }                
       
  1388                 break;                  
       
  1389             } 
       
  1390         }    
       
  1391     }
       
  1392 
       
  1393 // -----------------------------------------------------------------------------
       
  1394 // CSisxUIHandler::GetResult
       
  1395 // Return result of the installation.
       
  1396 // (other items were commented in a header).
       
  1397 // -----------------------------------------------------------------------------
       
  1398 //
       
  1399 TSisxUIResult CSisxUIHandler::GetResult() const
       
  1400     {
       
  1401     return iResult;    
       
  1402     }
       
  1403 
       
  1404 
       
  1405 // -----------------------------------------------------------------------------
       
  1406 // CSisxUIHandler::ShowFinalNoteL
       
  1407 // Show the final note.
       
  1408 // (other items were commented in a header).
       
  1409 // -----------------------------------------------------------------------------
       
  1410 //     
       
  1411 void CSisxUIHandler::ShowFinalNoteL()
       
  1412     {
       
  1413     switch ( iResult.iResult )
       
  1414         {      
       
  1415         case EUiResultOk:
       
  1416             DisplayCompleteL();
       
  1417             break;
       
  1418             
       
  1419         case EUiResultCancelled:
       
  1420             DisplayCancelL();
       
  1421             break;
       
  1422 
       
  1423         case EUiResultUnableToOverwrite:
       
  1424         case EUiResultInvalidUpgrade:
       
  1425         case EUiResultBlockingEclipsingFile:
       
  1426             ShowErrorL( R_SISXUI_UPDATE_ERROR );
       
  1427             break;
       
  1428             
       
  1429         case EUiResultAlreadyInRom:
       
  1430             ShowErrorL( R_SISXUI_ALREADY_IN_ROM );            
       
  1431             break;
       
  1432 
       
  1433         case EUiResultUnknownFile:
       
  1434         case EUiResultFileNotFound:
       
  1435         case EUiResultInvalidFileName:		
       
  1436         case EUiResultFileCorrupt:
       
  1437             ShowErrorL( R_SISXUI_FILE_CORRUPT );
       
  1438             break;
       
  1439             
       
  1440         case EUiResultDiskNotPresent:
       
  1441             ShowErrorL( R_SISXUI_DISK_NOT_PRESENT );
       
  1442             break;
       
  1443             
       
  1444         case EUiResultCannotRead:  
       
  1445             ShowErrorL( R_SISXUI_CANNOT_READ );
       
  1446             break;
       
  1447             
       
  1448         case EUiResultCannotDelete:          	
       
  1449             ShowErrorL( R_SISXUI_CANNOT_DELETE );
       
  1450             break;
       
  1451 
       
  1452         case EUiResultInsufficientMemory:
       
  1453         case EUiResultInsufficientSpaceOnDrive:
       
  1454             ShowErrorL( R_SISXUI_NOT_ENOUGH_MEMORY );
       
  1455             break;            
       
  1456             
       
  1457         case EUiResultCapabilitiesCannotBeGranted:
       
  1458             ShowErrorL( R_SISXUI_CAPABILITIES_CANNOT_BE_GRANTED );
       
  1459             break;            
       
  1460 
       
  1461         case EUiResultNoCertificate:
       
  1462         case EUiResultCertificateValidationError:
       
  1463         case EUiResultSignatureNotPresent:
       
  1464         case EUiResultSignatureCouldNotBeValidated:
       
  1465         case EUiResultNoCodeSigningExtension:
       
  1466         case EUiResultNoSupportedPolicyExtension:  
       
  1467         case EUiResultMandatorySignatureMissing:
       
  1468             ShowErrorL( R_SISXUI_CERTIFICATE_ERROR );
       
  1469             break;            
       
  1470         case EUiResultSignatureSelfSigned:    
       
  1471             ShowErrorL( R_SISXUI_SELFSIGNED_ERROR );              
       
  1472             break; 
       
  1473         case EUiResultCertificateExpired:
       
  1474             ShowErrorL( R_SISXUI_CERT_EXPIRED );
       
  1475             break;
       
  1476             
       
  1477         case EUiResultCertificateValidInFuture:
       
  1478             ShowErrorL( R_SISXUI_CERT_DATE_INVALID );
       
  1479             break;
       
  1480 
       
  1481         case EUiResultInvalidRevocationServerResponse:
       
  1482         case EUiResultInvalidRevocationServerUrl:
       
  1483         case EUiResultResponseSignatureValidationFailure:
       
  1484             ShowErrorL( R_SISXUI_OCSP_SETTINGS_ERROR );
       
  1485             break;
       
  1486 
       
  1487         case EUiResultUnableToObtainCertificateStatus:  
       
  1488         case EUiResultInvalidCertificateStatusInformation:
       
  1489         case EUiResultCertificateStatusIsUnknown:
       
  1490         case EUiResultCertificateStatusIsUnknownSelfSigned:
       
  1491             ShowErrorL( R_SISXUI_OCSP_GENERAL_ERROR );
       
  1492             break;            
       
  1493             
       
  1494         case EUiResultCertificateStatusIsRevoked:   
       
  1495             ShowErrorL( R_SISXUI_OCSP_REVOKED );
       
  1496             break;
       
  1497 
       
  1498         case EUiResultAccessDenied:
       
  1499         case EUiResultOSExeViolation:
       
  1500             ShowErrorL( R_SISXUI_ACCESS_DENIED );
       
  1501             break;            
       
  1502 
       
  1503         case EUiResultMissingBasePackage:
       
  1504             ShowErrorL( R_SISXUI_BASE_MISSING );
       
  1505             break;    
       
  1506 
       
  1507         case EUiResultCannotUninstallPartialUpgrade:
       
  1508             ShowErrorL( R_SISXUI_UNINSTALL_PARTIAL_ERROR );
       
  1509             break; 
       
  1510 
       
  1511         case EUiResultSIDViolation:
       
  1512         case EUiResultVIDViolation:
       
  1513         case EUiResultUIDPackageViolation:
       
  1514         case EUiResultSIDMismatch:
       
  1515             ShowErrorL( R_SISXUI_PROTECTED_ERROR );
       
  1516             break;            
       
  1517 
       
  1518         case EUiResultConstraintsExceeded:
       
  1519             ShowErrorL( R_SISXUI_CONSTRAINED_ERROR );
       
  1520             break;            
       
  1521             
       
  1522             //These should not come here
       
  1523         case EUiResultMissingDependency:			
       
  1524         case EUiResultRequireVer:		
       
  1525         case EUiResultRequireVerOrGreater:
       
  1526             //
       
  1527         case EUiResultGeneralError:
       
  1528         case EUiResultNoResult:
       
  1529         default:            
       
  1530             if ( iMode == EModeInstall )
       
  1531                 {                
       
  1532                 ShowErrorL( R_SISXUI_INSTALL_ERROR );
       
  1533                 }
       
  1534             else
       
  1535                 {
       
  1536                 ShowErrorL( R_SISXUI_UNINSTALL_ERROR );
       
  1537                 }         
       
  1538             break;            
       
  1539         }    
       
  1540     }
       
  1541 
       
  1542 // -----------------------------------------------------------------------------
       
  1543 // CSisxUIHandler::ProcessedPackages
       
  1544 // Return the package information about this install/uninstall.
       
  1545 // (other items were commented in a header).
       
  1546 // -----------------------------------------------------------------------------
       
  1547 //
       
  1548 void CSisxUIHandler::ProcessedPackages( RPointerArray<CSisxUIAppInfo>& aPackages )
       
  1549     {
       
  1550     for ( TInt index = 0; index < iPackages.Count(); index++ )
       
  1551         {
       
  1552         aPackages.Append( iPackages[index] );        
       
  1553         }    
       
  1554     }
       
  1555 
       
  1556 // -----------------------------------------------------------------------------
       
  1557 // CSisxUIHandler::InstallMode
       
  1558 // Return the install mode of this instance.
       
  1559 // (other items were commented in a header).
       
  1560 // -----------------------------------------------------------------------------
       
  1561 //
       
  1562 CSisxUIHandler::TInstallMode CSisxUIHandler::InstallMode() const
       
  1563     {
       
  1564     return iMode;    
       
  1565     }
       
  1566 
       
  1567 // -----------------------------------------------------------------------------
       
  1568 // CSisxUIHandler::SetOcspProcedure
       
  1569 // Sets the ocsp procedure for the installation.
       
  1570 // (other items were commented in a header).
       
  1571 // -----------------------------------------------------------------------------
       
  1572 //
       
  1573 void CSisxUIHandler::SetOcspProcedure( const TSisxUIOcspProc& aOcspProc )
       
  1574     {
       
  1575     iOcspProc = aOcspProc;
       
  1576     }
       
  1577 
       
  1578 // -----------------------------------------------------------------------------
       
  1579 // CSisxUIHandler::IsShowingDialog
       
  1580 // Indicates if a dialog is shown to user and expecting some user input.
       
  1581 // (other items were commented in a header).
       
  1582 // -----------------------------------------------------------------------------
       
  1583 //  
       
  1584 TBool CSisxUIHandler::IsShowingDialog()
       
  1585     {
       
  1586     return iShowingDialog;    
       
  1587     }
       
  1588 
       
  1589 // -----------------------------------------------------------------------------
       
  1590 // CSisxUIHandler::ShowCancellingL
       
  1591 // Shows a cancelling wait dialog.
       
  1592 // (other items were commented in a header).
       
  1593 // -----------------------------------------------------------------------------
       
  1594 //
       
  1595 void CSisxUIHandler::ShowCancellingL()
       
  1596     {
       
  1597     // We need to show this only in case of ocsp.
       
  1598     if ( iOcspInProgress )
       
  1599         {        
       
  1600         // Show cancelling wait dialog    
       
  1601         iCommonDialogs->ShowDelayedWaitDialogL( R_SISXUI_CANCELLING, 
       
  1602                                                 this, 
       
  1603                                                 R_AVKON_SOFTKEYS_EMPTY );
       
  1604         }    
       
  1605     }
       
  1606 
       
  1607 // -----------------------------------------------------------------------------
       
  1608 // CSisxUIHandler::DoNotShowFinalNote
       
  1609 // Sets the UI not to show final note.
       
  1610 // (other items were commented in a header).
       
  1611 // -----------------------------------------------------------------------------
       
  1612 //
       
  1613 void CSisxUIHandler::DoNotShowFinalNote()
       
  1614     {
       
  1615     iShownFinalNote = ETrue;    
       
  1616     }
       
  1617 
       
  1618 // -----------------------------------------------------------------------------
       
  1619 // CSisxUIHandler::ResetResult
       
  1620 // Resets the result to no result.
       
  1621 // (other items were commented in a header).
       
  1622 // -----------------------------------------------------------------------------
       
  1623 //
       
  1624 void CSisxUIHandler::ResetResult()
       
  1625     {
       
  1626     iResult.iResult = EUiResultNoResult;    
       
  1627     }
       
  1628 
       
  1629 // -----------------------------------------------------------------------------
       
  1630 // CSisxUIHandler::SetFileForDrm
       
  1631 // Sets the file handle for showing drm details.
       
  1632 // (other items were commented in a header).
       
  1633 // -----------------------------------------------------------------------------
       
  1634 //
       
  1635 void CSisxUIHandler::SetFileForDrm( RFile& aFile )  
       
  1636     {
       
  1637     iDrmFile.Duplicate( aFile );
       
  1638     iIsDrmFileSet = ETrue;    
       
  1639     }
       
  1640 
       
  1641 // -----------------------------------------------------------------------------
       
  1642 // CSisxUIHandler::SetAllowUntrusted
       
  1643 // Sets the policy for allowing the installation of untrusted packages.
       
  1644 // (other items were commented in a header).
       
  1645 // -----------------------------------------------------------------------------
       
  1646 //
       
  1647 void CSisxUIHandler::SetAllowUntrusted( TBool aAllowUntrusted )
       
  1648     {
       
  1649     iAllowUntrusted = aAllowUntrusted;    
       
  1650     }
       
  1651 
       
  1652 // -----------------------------------------------------------------------------
       
  1653 // CSisxUIHandler::DisplayCancelL
       
  1654 // Displays a cancel note.
       
  1655 // (other items were commented in a header).
       
  1656 // -----------------------------------------------------------------------------
       
  1657 //
       
  1658 void CSisxUIHandler::DisplayCancelL()
       
  1659     {
       
  1660     if ( !iShownFinalNote )
       
  1661         {  
       
  1662         // Make sure that no wait or progress dialog is running
       
  1663         Finalize();
       
  1664   
       
  1665         HBufC* string = NULL;        
       
  1666         if ( iMode == EModeInstall )
       
  1667             {            
       
  1668             string = StringLoader::LoadLC( R_SISXUI_INSTALL_CANCELLED );
       
  1669             }
       
  1670         else
       
  1671             {
       
  1672             string = StringLoader::LoadLC( R_SISXUI_UNINSTALL_CANCELLED );
       
  1673             }
       
  1674         
       
  1675         CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
       
  1676         note->ExecuteLD( *string );
       
  1677         CleanupStack::PopAndDestroy( string ); 
       
  1678         }
       
  1679 
       
  1680     iShownFinalNote = ETrue;    
       
  1681     }
       
  1682 
       
  1683 // -----------------------------------------------------------------------------
       
  1684 // CSisxUIHandler::DisplayCompleteL
       
  1685 // Displays a complete note.
       
  1686 // (other items were commented in a header).
       
  1687 // -----------------------------------------------------------------------------
       
  1688 //
       
  1689 void CSisxUIHandler::DisplayCompleteL()
       
  1690     {
       
  1691     if ( !iShownFinalNote )
       
  1692         {        
       
  1693         // Make sure that no wait or progress dialog is running
       
  1694         Finalize();        
       
  1695 
       
  1696         HBufC* string = NULL;        
       
  1697         if ( iMode == EModeInstall )
       
  1698             {            
       
  1699             string = StringLoader::LoadLC( R_SISXUI_INSTALL_COMPLETED );
       
  1700             }
       
  1701         else
       
  1702             {
       
  1703             string = StringLoader::LoadLC( R_SISXUI_UNINSTALL_COMPLETED );
       
  1704             }
       
  1705         
       
  1706         CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue );
       
  1707         note->ExecuteLD( *string );
       
  1708         CleanupStack::PopAndDestroy( string ); 
       
  1709         }   
       
  1710 
       
  1711     iShownFinalNote = ETrue;    
       
  1712     }
       
  1713 
       
  1714 // -----------------------------------------------------------------------------
       
  1715 // CSisxUIHandler::ShowErrorL
       
  1716 // Convenience function for showing a Sisx specific error.
       
  1717 // (other items were commented in a header).
       
  1718 // -----------------------------------------------------------------------------
       
  1719 //
       
  1720 void CSisxUIHandler::ShowErrorL( TInt aResourceString )
       
  1721     {
       
  1722     if ( !iShownFinalNote )
       
  1723         {
       
  1724         Finalize();
       
  1725 
       
  1726         HBufC* errorString = StringLoader::LoadLC( aResourceString );
       
  1727 
       
  1728         RFs fs;
       
  1729         User::LeaveIfError( fs.Connect() );
       
  1730         CleanupClosePushL( fs );
       
  1731 
       
  1732         CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue );
       
  1733 
       
  1734         TEntry entry;
       
  1735         TInt status = fs.Entry( KSwiTempFile, entry );
       
  1736 
       
  1737         if ( status == KErrNone )
       
  1738             {
       
  1739             // File exists. Status code will be appended to the message
       
  1740             HBufC* detailedMessage = HBufC::NewLC( errorString->Length() + KSpaceForErrorCode );
       
  1741             if( iResult.iResult != EUiResultGeneralError ) {
       
  1742                 detailedMessage->Des().Format( KDetailedError, errorString, iResult.iResult );
       
  1743             } else {
       
  1744                 detailedMessage->Des().Format( KDetailedError, errorString,
       
  1745                         iResult.iDetailedErrorCode );
       
  1746             }
       
  1747             note->ExecuteLD( *detailedMessage );
       
  1748             CleanupStack::PopAndDestroy( detailedMessage );
       
  1749             }
       
  1750         else
       
  1751             {
       
  1752             // File doesn't exist. Show the message without status code
       
  1753             note->ExecuteLD( *errorString );
       
  1754             }
       
  1755 
       
  1756         CleanupStack::PopAndDestroy( 2 );  // fs, errorString
       
  1757 
       
  1758         // No notes after error
       
  1759         iShownFinalNote = ETrue;
       
  1760         }
       
  1761     }
       
  1762 
       
  1763 // -----------------------------------------------------------------------------
       
  1764 // CSisxUIHandler::ShowErrorL
       
  1765 // Convenience function for showing a Sisx specific error.
       
  1766 // (other items were commented in a header).
       
  1767 // -----------------------------------------------------------------------------
       
  1768 //
       
  1769 void CSisxUIHandler::ShowErrorL( const TDesC& aDes )
       
  1770     {
       
  1771     if ( !iShownFinalNote )
       
  1772         { 
       
  1773         Finalize();    
       
  1774         
       
  1775         CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue );
       
  1776         note->ExecuteLD( aDes );
       
  1777         
       
  1778         // No notes after error
       
  1779         iShownFinalNote = ETrue;   
       
  1780         }    
       
  1781     }
       
  1782 
       
  1783 // -----------------------------------------------------------------------------
       
  1784 // CSisxUIHandler::AddCapabilityL
       
  1785 // Adds the given capability string to the descriptor.
       
  1786 // (other items were commented in a header).
       
  1787 // -----------------------------------------------------------------------------
       
  1788 //
       
  1789 void CSisxUIHandler::AddCapabilityL( HBufC*& aString, TInt aResourceId )
       
  1790     {
       
  1791     HBufC* tmpString = StringLoader::LoadLC( aResourceId );
       
  1792     HBufC* newString;
       
  1793     
       
  1794     if ( aString->Length() > 0 )
       
  1795         {
       
  1796         newString = HBufC::NewL( tmpString->Length() + aString->Length() + 1 ); // + \n
       
  1797         
       
  1798         TPtr ptr( newString->Des() );
       
  1799         ptr += *aString;        
       
  1800         ptr += KNextLine;        
       
  1801         ptr += *tmpString;
       
  1802         }
       
  1803     else
       
  1804         {
       
  1805         newString = HBufC::NewL( tmpString->Length() );
       
  1806 
       
  1807         TPtr ptr( newString->Des() );                
       
  1808         ptr += *tmpString;
       
  1809         }
       
  1810 
       
  1811     CleanupStack::PopAndDestroy( tmpString );
       
  1812     CleanupStack::PopAndDestroy( aString );  
       
  1813   
       
  1814     aString = newString;    
       
  1815     CleanupStack::PushL( aString );    
       
  1816     }
       
  1817 
       
  1818 // -----------------------------------------------------------------------------
       
  1819 // CSisxUIHandler::Finalize
       
  1820 // Finalizes the installation by closing all open dialogs.
       
  1821 // (other items were commented in a header).
       
  1822 // -----------------------------------------------------------------------------
       
  1823 //
       
  1824 void CSisxUIHandler::Finalize()
       
  1825     {
       
  1826     TRAP_IGNORE( iCommonDialogs->CloseWaitDialogL() );
       
  1827     TRAP_IGNORE( iCommonDialogs->CloseProgressDialogL() );   
       
  1828     // No notes after this
       
  1829     iShownFinalNote = ETrue;        
       
  1830     }
       
  1831 
       
  1832 // -----------------------------------------------------------------------------
       
  1833 // CSisxUIHandler::ShowCapabilitiesHelp
       
  1834 // Callback used in message query. 
       
  1835 // (other items were commented in a header).
       
  1836 // -----------------------------------------------------------------------------
       
  1837 //
       
  1838 TInt CSisxUIHandler::ShowCapabilitiesHelp( TAny* aPtr )
       
  1839     {
       
  1840     //TRAP_IGNORE( 
       
  1841     //    reinterpret_cast<CSisxUIHandler*>(aPtr)->iCommonDialogs->LaunchHelpL( KAM_HLP_INSTALL_CAPAB )    
       
  1842     //    );    
       
  1843 
       
  1844     return KErrNone;    
       
  1845     }
       
  1846 
       
  1847 
       
  1848 //  End of File