appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginuihandlerbase.cpp
changeset 60 245df5276b97
parent 52 92f864ef0288
child 72 a0dc14075813
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
    17 
    17 
    18 #include "sisxsifpluginuihandlerbase.h"     // CSisxSifPluginUiHandlerBase
    18 #include "sisxsifpluginuihandlerbase.h"     // CSisxSifPluginUiHandlerBase
    19 #include "sisxsifplugininstallparams.h"     // CSisxSifPluginInstallParams
    19 #include "sisxsifplugininstallparams.h"     // CSisxSifPluginInstallParams
    20 #include "sisxsifpluginerrorhandler.h"      // CSisxSifPluginErrorHandler
    20 #include "sisxsifpluginerrorhandler.h"      // CSisxSifPluginErrorHandler
    21 #include "sisxsifcleanuputils.h"            // CleanupResetAndDestroyPushL
    21 #include "sisxsifcleanuputils.h"            // CleanupResetAndDestroyPushL
       
    22 #include <centralrepository.h>              // CRepository
       
    23 #include <SWInstallerInternalCRKeys.h>      // KCRUidSWInstallerSettings
       
    24 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h> // CHbDeviceMessageBoxSymbian
       
    25 #include <usif/scr/screntries.h>            // CComponentEntry
    22 
    26 
    23 using namespace Usif;
    27 using namespace Usif;
    24 
    28 
    25 
    29 
    26 // ======== MEMBER FUNCTIONS ========
    30 // ======== MEMBER FUNCTIONS ========
    40 // ---------------------------------------------------------------------------
    44 // ---------------------------------------------------------------------------
    41 //
    45 //
    42 CSisxSifPluginUiHandlerBase::~CSisxSifPluginUiHandlerBase()
    46 CSisxSifPluginUiHandlerBase::~CSisxSifPluginUiHandlerBase()
    43     {
    47     {
    44     delete iInstallParams;
    48     delete iInstallParams;
       
    49     delete iPublishSifOperationInfo;
    45     delete iGlobalComponentId;
    50     delete iGlobalComponentId;
    46     delete iPublishSifOperationInfo;
       
    47     }
    51     }
    48 
    52 
    49 // ---------------------------------------------------------------------------
    53 // ---------------------------------------------------------------------------
    50 // CSisxSifPluginUiHandlerBase::SetInstallParamsL()
    54 // CSisxSifPluginUiHandlerBase::SetInstallParamsL()
    51 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    76 //
    80 //
    77 void CSisxSifPluginUiHandlerBase::SetDriveSelectionRequired( TBool aIsRequired )
    81 void CSisxSifPluginUiHandlerBase::SetDriveSelectionRequired( TBool aIsRequired )
    78     {
    82     {
    79     iIsDriveSelectionRequired = aIsRequired;
    83     iIsDriveSelectionRequired = aIsRequired;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CSisxSifPluginUiHandlerBase::IsOcspMandatoryL()
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 TBool CSisxSifPluginUiHandlerBase::IsOcspMandatoryL() const
       
    91     {
       
    92     CRepository* cenRep = CRepository::NewLC( KCRUidSWInstallerSettings );
       
    93     TInt ocspProcedure = ESWInstallerOcspProcedureOff;
       
    94     User::LeaveIfError( cenRep->Get( KSWInstallerOcspProcedure, ocspProcedure ) );
       
    95     CleanupStack::PopAndDestroy( cenRep );
       
    96     return ( ocspProcedure == ESWInstallerOcspProcedureMust );
    80     }
    97     }
    81 
    98 
    82 // ---------------------------------------------------------------------------
    99 // ---------------------------------------------------------------------------
    83 // CSisxSifPluginUiHandlerBase::PublishStartL()
   100 // CSisxSifPluginUiHandlerBase::PublishStartL()
    84 // ---------------------------------------------------------------------------
   101 // ---------------------------------------------------------------------------
   108         }
   125         }
   109     iGlobalComponentId = aRootNode.GlobalComponentId().AllocL();
   126     iGlobalComponentId = aRootNode.GlobalComponentId().AllocL();
   110 
   127 
   111     CSifOperationStartData* data = CSifOperationStartData::NewLC( *iGlobalComponentId,
   128     CSifOperationStartData* data = CSifOperationStartData::NewLC( *iGlobalComponentId,
   112             aRootNode.ComponentName(), appNames, appIcons, aRootNode.MaxInstalledSize(),
   129             aRootNode.ComponentName(), appNames, appIcons, aRootNode.MaxInstalledSize(),
   113             KNullDesC, KNullDesC, aRootNode.SoftwareTypeName() );
   130             KNullDesC, KNullDesC, aRootNode.SoftwareTypeName(), iOperationPhase );
   114 
   131 
   115     if( !iPublishSifOperationInfo )
   132     if( !iPublishSifOperationInfo )
   116         {
   133         {
   117         iPublishSifOperationInfo = CPublishSifOperationInfo::NewL();
   134         iPublishSifOperationInfo = CPublishSifOperationInfo::NewL();
   118         }
   135         }
   120 
   137 
   121     CleanupStack::PopAndDestroy( 3, &appNames );    // data, appIcons, appNames
   138     CleanupStack::PopAndDestroy( 3, &appNames );    // data, appIcons, appNames
   122     }
   139     }
   123 
   140 
   124 // ---------------------------------------------------------------------------
   141 // ---------------------------------------------------------------------------
       
   142 // CSisxSifPluginUiHandlerBase::PublishStartL()
       
   143 // ---------------------------------------------------------------------------
       
   144 //
       
   145 void CSisxSifPluginUiHandlerBase::PublishStartL( const CComponentEntry& aEntry )
       
   146     {
       
   147     RPointerArray<HBufC> appNames;
       
   148     CleanupResetAndDestroyPushL( appNames );
       
   149     RPointerArray<HBufC> appIcons;
       
   150     CleanupResetAndDestroyPushL( appIcons );
       
   151 
       
   152     if( iGlobalComponentId )
       
   153         {
       
   154         delete iGlobalComponentId;
       
   155         iGlobalComponentId = NULL;
       
   156         }
       
   157     iGlobalComponentId = aEntry.GlobalId().AllocL();
       
   158 
       
   159     CSifOperationStartData* data = CSifOperationStartData::NewLC( *iGlobalComponentId,
       
   160             aEntry.Name(), appNames, appIcons, aEntry.ComponentSize(),
       
   161             KNullDesC, KNullDesC, aEntry.SoftwareType(), iOperationPhase );
       
   162 
       
   163     if( !iPublishSifOperationInfo )
       
   164         {
       
   165         iPublishSifOperationInfo = CPublishSifOperationInfo::NewL();
       
   166         }
       
   167     iPublishSifOperationInfo->PublishStartL( *data );
       
   168 
       
   169     CleanupStack::PopAndDestroy( 3, &appNames );    // data, appIcons, appNames
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
   125 // CSisxSifPluginUiHandlerBase::PublishProgressL()
   173 // CSisxSifPluginUiHandlerBase::PublishProgressL()
   126 // ---------------------------------------------------------------------------
   174 // ---------------------------------------------------------------------------
   127 //
   175 //
   128 void CSisxSifPluginUiHandlerBase::PublishProgressL( TSifOperationPhase aPhase,
   176 void CSisxSifPluginUiHandlerBase::PublishProgressL( TSifOperationSubPhase aSubPhase )
   129         TSifOperationSubPhase aSubPhase, TInt aCurrentProgress, TInt aTotal )
       
   130     {
   177     {
   131     User::LeaveIfNull( iPublishSifOperationInfo );
   178     User::LeaveIfNull( iPublishSifOperationInfo );
   132     CSifOperationProgressData* data = CSifOperationProgressData::NewLC( *iGlobalComponentId,
   179     CSifOperationProgressData* data = CSifOperationProgressData::NewLC( *iGlobalComponentId,
   133             aPhase, aSubPhase, aCurrentProgress, aTotal );
   180             iOperationPhase, aSubPhase, iProgressBarCurrentValue, iProgressBarFinalValue );
   134     iPublishSifOperationInfo->PublishProgressL( *data );
   181     iPublishSifOperationInfo->PublishProgressL( *data );
   135     CleanupStack::PopAndDestroy( data );
   182     CleanupStack::PopAndDestroy( data );
   136     }
   183     }
   137 
   184 
   138 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
   139 // CSisxSifPluginUiHandlerBase::PublishCompletionL()
   186 // CSisxSifPluginUiHandlerBase::PublishCompletionL()
   140 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   141 //
   188 //
   142 void CSisxSifPluginUiHandlerBase::PublishCompletionL( const CSisxSifPluginErrorHandler& aError )
   189 void CSisxSifPluginUiHandlerBase::PublishCompletionL()
   143     {
   190     {
   144     User::LeaveIfNull( iPublishSifOperationInfo );
   191     User::LeaveIfNull( iPublishSifOperationInfo );
   145     CSifOperationEndData* data = CSifOperationEndData::NewLC( *iGlobalComponentId,
   192     CSifOperationEndData* data = CSifOperationEndData::NewLC( *iGlobalComponentId,
   146             aError.ErrorCategory(), aError.ErrorCode(), aError.ErrorMessage(),
   193             iErrorHandler.ErrorCategory(), iErrorHandler.ErrorCode(),
   147             aError.ErrorMessageDetails() );
   194             iErrorHandler.ErrorMessage(), iErrorHandler.ErrorMessageDetails() );
   148     iPublishSifOperationInfo->PublishCompletionL( *data );
   195     iPublishSifOperationInfo->PublishCompletionL( *data );
   149     CleanupStack::PopAndDestroy( data );
   196     CleanupStack::PopAndDestroy( data );
   150     }
   197     }
   151 
   198 
   152 // ---------------------------------------------------------------------------
   199 // ---------------------------------------------------------------------------
   153 // CSisxSifPluginUiHandlerBase::SetDisplayErrorL()
   200 // CSisxSifPluginUiHandlerBase::SetErrorL()
   154 // ---------------------------------------------------------------------------
   201 // ---------------------------------------------------------------------------
   155 //
   202 //
   156 void CSisxSifPluginUiHandlerBase::SetDisplayErrorL( Swi::TErrorDialog aType, const TDesC& aParam )
   203 void CSisxSifPluginUiHandlerBase::SetErrorL( TInt aErrorCode, TInt aExtErrorCode )
   157     {
   204     {
   158     iErrorHandler.SetExtendedErrorCode( aType );
   205     iErrorHandler.SetErrorCode( aErrorCode );
   159 
   206     iErrorHandler.SetExtendedErrorCode( aExtErrorCode );
       
   207 
       
   208     // TODO: localized UI strings needed
       
   209     switch( iErrorHandler.ErrorCategory() )
       
   210         {
       
   211         case ELowMemory:
       
   212             // txt_error_info_there_is_not_enough_memory_currentl
       
   213             iErrorHandler.SetErrorMessage( _L("There is not enough memory currently.") );
       
   214             break;
       
   215         case ELowDiskSpace:
       
   216             // txt_error_info_there_is_not_enough_space_currently
       
   217             iErrorHandler.SetErrorMessage( _L("There is not enough space currently in this drive.") );
       
   218             break;
       
   219         case ENetworkUnavailable:
       
   220             // txt_error_info_network_is_unavailable_currently
       
   221             iErrorHandler.SetErrorMessage( _L("Network  is unavailable currently.") );
       
   222             break;
       
   223         case EInstallerBusy:
       
   224             // txt_error_info_installer_is_busy_currently
       
   225             iErrorHandler.SetErrorMessage( _L("Installer is busy currently.") );
       
   226             break;
       
   227         case ECorruptedPackage:
       
   228             // txt_error_info_installation_package_is_corrupted
       
   229             iErrorHandler.SetErrorMessage( _L("Installation package is corrupted. You may want to try again.") );
       
   230             break;
       
   231         case EApplicationNotCompatible:
       
   232             // txt_error_info_application_is_not_compatible_with
       
   233             iErrorHandler.SetErrorMessage( _L("Application is not compatible with this device.") );
       
   234             break;
       
   235         case ESecurityError:
       
   236             // txt_error_info_there_is_a_security_issue_with_this
       
   237             iErrorHandler.SetErrorMessage( _L("There is a security issue with this application.") );
       
   238             break;
       
   239         case EUnexpectedError:
       
   240         case EUnknown:
       
   241             // txt_error_info_an_unexpected_error_occurred
       
   242             iErrorHandler.SetErrorMessage( _L("An unexpected error occurred.") );
       
   243             break;
       
   244         case EUserCancelled:
       
   245             if( iOperationPhase == EInstalling )
       
   246                 {
       
   247                 // txt_error_info_application_not_installed
       
   248                 iErrorHandler.SetErrorMessage( _L("Application not installed.") );
       
   249                 }
       
   250             else
       
   251                 {
       
   252                 // txt_error_info_application_not_deleted
       
   253                 iErrorHandler.SetErrorMessage( _L("Application not deleted. ") );
       
   254                 }
       
   255             break;
       
   256         case EUninstallationBlocked:
       
   257             // txt_error_info_application_cannot_be_deleted
       
   258             iErrorHandler.SetErrorMessage( _L("Application cannot be deleted.") );
       
   259             break;
       
   260         case ENone:
       
   261         default:
       
   262             break;
       
   263         }
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------------------------
       
   267 // CSisxSifPluginUiHandlerBase::SetErrorL()
       
   268 // ---------------------------------------------------------------------------
       
   269 //
       
   270 void CSisxSifPluginUiHandlerBase::SetErrorL( TInt aErrorCode, TInt aExtErrorCode,
       
   271     const TDesC& aErrMsgDetails )
       
   272     {
       
   273     SetErrorL( aErrorCode, aExtErrorCode );
       
   274     iErrorHandler.SetErrorMessageDetails( aErrMsgDetails );
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CSisxSifPluginUiHandlerBase::SetErrorSwiErrorL()
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 void CSisxSifPluginUiHandlerBase::SetErrorSwiErrorL( Swi::TErrorDialog aType,
       
   282         const TDesC& /*aParam*/ )
       
   283     {
   160     // TODO: localised detailed error messages
   284     // TODO: localised detailed error messages
       
   285     // TODO: append aParam when message supports parameters
   161     TBuf<512> details;
   286     TBuf<512> details;
   162     switch( aType )
   287     switch( aType )
   163         {
   288         {
   164         case Swi::EUiAlreadyInRom:
   289         case Swi::EUiAlreadyInRom:
   165             details.Copy(_L("EUiAlreadyInRom"));
   290             details.Copy(_L("EUiAlreadyInRom"));
   193             break;
   318             break;
   194         case Swi::EUiInsufficientSpaceOnDrive:
   319         case Swi::EUiInsufficientSpaceOnDrive:
   195             details.Copy(_L("EUiInsufficientSpaceOnDrive"));
   320             details.Copy(_L("EUiInsufficientSpaceOnDrive"));
   196             break;
   321             break;
   197         case Swi::EUiCapabilitiesCannotBeGranted:
   322         case Swi::EUiCapabilitiesCannotBeGranted:
   198             details.Copy(_L("EUiCapabilitiesCannotBeGranted"));
   323             // aParam contains list of capability names
       
   324             details.Copy(_L("Cannot grant capabilities requested by the application."));
   199             break;
   325             break;
   200         case Swi::EUiUnknownFile:
   326         case Swi::EUiUnknownFile:
   201             details.Copy(_L("EUiUnknownFile"));
   327             details.Copy(_L("EUiUnknownFile"));
   202             break;
   328             break;
   203         case Swi::EUiMissingBasePackage:
   329         case Swi::EUiMissingBasePackage:
   229             break;
   355             break;
   230         default:
   356         default:
   231             break;
   357             break;
   232         }
   358         }
   233 
   359 
   234     if( aParam.Length() )
   360     SetErrorL( KErrGeneral, aType, details );
   235         {
   361     }
   236         details.Append( _L("\n") );
   362 
   237         details.Append( aParam );
   363 // ---------------------------------------------------------------------------
   238         }
   364 // CSisxSifPluginUiHandlerBase::SetOcspErrorL()
   239     }
   365 // ---------------------------------------------------------------------------
   240 
   366 //
       
   367 void CSisxSifPluginUiHandlerBase::SetOcspErrorL( Swi::TRevocationDialogMessage aMessage )
       
   368     {
       
   369     // TODO: localised error strings needed
       
   370     iErrorHandler.SetErrorMessage( _L("Unable to check certificate validity online." ) );
       
   371     iErrorHandler.SetExtendedErrorCode( aMessage );
       
   372     switch( aMessage )
       
   373         {
       
   374         case Swi::EInvalidRevocationServerUrl:
       
   375             iErrorHandler.SetErrorCode( KErrGeneral );
       
   376             iErrorHandler.SetErrorMessageDetails( _L("Invalid server URL. Check settings.") );
       
   377             break;
       
   378         case Swi::EUnableToObtainCertificateStatus:
       
   379             iErrorHandler.SetErrorCode( KErrGeneral );
       
   380             iErrorHandler.SetErrorMessageDetails( _L("Unable to obtain certificate status. Try again later.") );
       
   381             break;
       
   382         case Swi::EResponseSignatureValidationFailure:
       
   383             iErrorHandler.SetErrorCode( KErrGeneral );
       
   384             iErrorHandler.SetErrorMessageDetails( _L("Response signature validation failure. Check settings.") );
       
   385             break;
       
   386         case Swi::EInvalidRevocationServerResponse:
       
   387             iErrorHandler.SetErrorCode( KErrGeneral );
       
   388             iErrorHandler.SetErrorMessageDetails( _L("The OCSP server reply is invalid. Check settings.") );
       
   389             break;
       
   390         case Swi::EInvalidCertificateStatusInformation:
       
   391         case Swi::ECertificateStatusIsUnknownSelfSigned:
       
   392             iErrorHandler.SetErrorCode( KErrGeneral );
       
   393             iErrorHandler.SetErrorMessageDetails( _L("Invalid certificate status information. Try again later.") );
       
   394             break;
       
   395         case Swi::ECertificateStatusIsUnknown:
       
   396             iErrorHandler.SetErrorCode( KErrGeneral );
       
   397             iErrorHandler.SetErrorMessageDetails( _L("Unknown certificate. Try again later.") );
       
   398             break;
       
   399         case Swi::ECertificateStatusIsRevoked:
       
   400             iErrorHandler.SetErrorCode( KErrAccessDenied );
       
   401             iErrorHandler.SetErrorMessageDetails( _L("The certificate has been revoked.") );
       
   402             break;
       
   403         default:
       
   404             break;
       
   405         }
       
   406     }
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // CSisxSifPluginUiHandlerBase::ShowQuestionL()
       
   410 // ---------------------------------------------------------------------------
       
   411 //
       
   412 TBool CSisxSifPluginUiHandlerBase::ShowQuestionL( const TDesC& aText ) const
       
   413     {
       
   414     TBool questionAccepted = EFalse;
       
   415 
       
   416     CHbDeviceMessageBoxSymbian *note = NULL;
       
   417     note = CHbDeviceMessageBoxSymbian::NewL( CHbDeviceMessageBoxSymbian::EQuestion );
       
   418     CleanupStack::PushL( note );
       
   419 
       
   420     note->SetTextL( aText );
       
   421     note->SetTimeout( 0 );
       
   422     if( note->ExecL() == CHbDeviceMessageBoxSymbian::EAcceptButton )
       
   423         {
       
   424         questionAccepted = ETrue;
       
   425         }
       
   426 
       
   427     CleanupStack::PopAndDestroy( note );
       
   428     return questionAccepted;
       
   429     }
       
   430 
       
   431 // ---------------------------------------------------------------------------
       
   432 // CSisxSifPluginUiHandlerBase::ShowQuestionWithContinueL()
       
   433 // ---------------------------------------------------------------------------
       
   434 //
       
   435 void CSisxSifPluginUiHandlerBase::ShowQuestionWithContinueL( const TDesC& aText ) const
       
   436     {
       
   437     CHbDeviceMessageBoxSymbian *note = NULL;
       
   438     note = CHbDeviceMessageBoxSymbian::NewL( CHbDeviceMessageBoxSymbian::EQuestion );
       
   439     CleanupStack::PushL( note );
       
   440 
       
   441     note->SetTextL( aText );
       
   442     note->SetTimeout( 0 );
       
   443     note->SetButton( CHbDeviceMessageBoxSymbian::EAcceptButton, EFalse );
       
   444     note->SetButton( CHbDeviceMessageBoxSymbian::ERejectButton, ETrue );
       
   445     // TODO: localized UI string needed
       
   446     note->SetButtonTextL( CHbDeviceMessageBoxSymbian::ERejectButton, _L("Continue") );
       
   447     (void)note->ExecL();
       
   448 
       
   449     CleanupStack::PopAndDestroy( note );
       
   450     }
       
   451