appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginuihandler.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
    17 
    17 
    18 #include "sisxsifpluginuihandler.h"     // CSisxSifPluginUiHandler
    18 #include "sisxsifpluginuihandler.h"     // CSisxSifPluginUiHandler
    19 #include "sisxsifplugin.pan"            // Panic codes
    19 #include "sisxsifplugin.pan"            // Panic codes
    20 #include "sisxsifcleanuputils.h"        // CleanupResetAndDestroyPushL
    20 #include "sisxsifcleanuputils.h"        // CleanupResetAndDestroyPushL
    21 #include "sisxsifuiselectioncache.h"    // CSisxUISelectionCache
    21 #include "sisxsifuiselectioncache.h"    // CSisxUISelectionCache
    22 #include "sisxsifuilangname.h"          // CLangName
       
    23 #include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
       
    24 #include <sisxsifuidata.rsg>            // Resource IDs
       
    25 #include <sifui.h>                      // CSifUi
    22 #include <sifui.h>                      // CSifUi
    26 #include <bautils.h>                    // BaflUtils
    23 #include <bautils.h>                    // BaflUtils
       
    24 #include <driveinfo.h>                  // DriveInfo
    27 #include <featmgr.h>                    // FeatureManager
    25 #include <featmgr.h>                    // FeatureManager
    28 //#include <csxhelp/am.hlp.hrh>           // Help IDs
    26 //#include <csxhelp/am.hlp.hrh>           // Help IDs
    29 #include <hb/hbcore/hbsymbiandevicedialog.h> // CHbDeviceDialog
    27 #include <hb/hbcore/hbsymbiandevicedialog.h> // CHbDeviceDialog
    30 #include <hb/hbcore/hbsymbianvariant.h> // CHbSymbianVariantMap
    28 #include <hb/hbcore/hbsymbianvariant.h> // CHbSymbianVariantMap
    31 
    29 
    32 using namespace Usif;
    30 using namespace Usif;
    33 
       
    34 _LIT( KSisxUIResourceFileName, "sisxsifuidata.rsc" );
       
    35 
    31 
    36 // TODO: replace with proper tracing support
    32 // TODO: replace with proper tracing support
    37 #ifdef _DEBUG
    33 #ifdef _DEBUG
    38 #define FLOG(x)         RDebug::Print(x);
    34 #define FLOG(x)         RDebug::Print(x);
    39 #define FLOG_1(x,y)     RDebug::Print(x, y);
    35 #define FLOG_1(x,y)     RDebug::Print(x, y);
    43 #define FLOG_1(x,y)
    39 #define FLOG_1(x,y)
    44 #define FLOG_2(x,y,z)
    40 #define FLOG_2(x,y,z)
    45 #endif
    41 #endif
    46 
    42 
    47 
    43 
    48 // ======== LOCAL FUNCTIONS =========
       
    49 
       
    50 TBool HasLangId( const TLanguage* aId, const CLangName& aLang )
       
    51     {
       
    52     return( *aId == aLang.Id() );
       
    53     }
       
    54 
       
    55 
       
    56 // ======== MEMBER FUNCTIONS ========
    44 // ======== MEMBER FUNCTIONS ========
    57 
    45 
    58 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    59 // CSisxSifPluginUiHandler::NewL()
    47 // CSisxSifPluginUiHandler::NewL()
    60 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    61 //
    49 //
    62 CSisxSifPluginUiHandler* CSisxSifPluginUiHandler::NewL( RFs& aFs )
    50 CSisxSifPluginUiHandler* CSisxSifPluginUiHandler::NewL( RFs& aFs )
    63 	{
    51     {
    64     FLOG( _L("CSisxSifPluginUiHandler::NewL") );
    52     FLOG( _L("CSisxSifPluginUiHandler::NewL") );
    65 	CSisxSifPluginUiHandler *self = new( ELeave ) CSisxSifPluginUiHandler( aFs );
    53     CSisxSifPluginUiHandler *self = new( ELeave ) CSisxSifPluginUiHandler( aFs );
    66 	CleanupStack::PushL( self );
    54     CleanupStack::PushL( self );
    67 	self->ConstructL();
    55     self->ConstructL();
    68 	CleanupStack::Pop( self );
    56     CleanupStack::Pop( self );
    69 	return self;
    57     return self;
    70 	}
    58     }
    71 
    59 
    72 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    73 // CSisxSifPluginUiHandler::~CSisxSifPluginUiHandler()
    61 // CSisxSifPluginUiHandler::~CSisxSifPluginUiHandler()
    74 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    75 //
    63 //
    76 CSisxSifPluginUiHandler::~CSisxSifPluginUiHandler()
    64 CSisxSifPluginUiHandler::~CSisxSifPluginUiHandler()
    77 	{
    65     {
    78     FLOG( _L("CSisxSifPluginUiHandler::~CSisxSifPluginUiHandler") );
    66     FLOG( _L("CSisxSifPluginUiHandler::~CSisxSifPluginUiHandler") );
    79     delete iSelectionCache;
    67     delete iSelectionCache;
    80     delete iSifUi;
    68     delete iSifUi;
    81     CloseResourceFile();
    69     iSelectableDrives.Close();
    82 	}
    70     }
    83 
    71 
    84 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    85 // CSisxSifPluginUiHandler::DisplayTextL()
    73 // CSisxSifPluginUiHandler::DisplayTextL()
    86 // ---------------------------------------------------------------------------
    74 // ---------------------------------------------------------------------------
    87 //
    75 //
   162         const CApaMaskedBitmap* /*aLogo*/,
   150         const CApaMaskedBitmap* /*aLogo*/,
   163         const RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/ )
   151         const RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/ )
   164     {
   152     {
   165     FLOG( _L("CSisxSifPluginUiHandler::DisplayInstallL") );
   153     FLOG( _L("CSisxSifPluginUiHandler::DisplayInstallL") );
   166 
   154 
   167     iSifUi->SetMode( CSifUi::EInstalling );
       
   168 
       
   169     // TODO: show preparing note -- unless it can be displayed already earlier.
   155     // TODO: show preparing note -- unless it can be displayed already earlier.
   170     // Preparing note should not have any buttons yet, but it might display some
   156     // Preparing note should not have any buttons yet, but it might display some
   171     // application details already.
   157     // application details already.
       
   158 
       
   159     // TODO: SISX SIF plugin needs to set memory selection when needed
       
   160     MemorySelectionL();
   172 
   161 
   173     return ETrue;
   162     return ETrue;
   174     }
   163     }
   175 
   164 
   176 // ---------------------------------------------------------------------------
   165 // ---------------------------------------------------------------------------
   295 // ---------------------------------------------------------------------------
   284 // ---------------------------------------------------------------------------
   296 //
   285 //
   297 TBool CSisxSifPluginUiHandler::DisplaySecurityWarningL( const Swi::CAppInfo& aAppInfo,
   286 TBool CSisxSifPluginUiHandler::DisplaySecurityWarningL( const Swi::CAppInfo& aAppInfo,
   298         Swi::TSignatureValidationResult aSigValidationResult,
   287         Swi::TSignatureValidationResult aSigValidationResult,
   299         RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/,
   288         RPointerArray<CPKIXValidationResultBase>& /*aPkixResults*/,
   300         RPointerArray<Swi::CCertificateInfo>& aCertificates,
   289         RPointerArray<Swi::CCertificateInfo>& /*aCertificates*/,
   301         TBool aInstallAnyway )
   290         TBool aInstallAnyway )
   302     {
   291     {
   303     FLOG( _L("CSisxSifPluginUiHandler::DisplaySecurityWarningL") );
   292     FLOG( _L("CSisxSifPluginUiHandler::DisplaySecurityWarningL") );
   304     TBool result = EFalse;
   293     TBool result = EFalse;
   305 
   294 
   307     TInt appSize = 0;
   296     TInt appSize = 0;
   308 
   297 
   309     switch( aSigValidationResult )
   298     switch( aSigValidationResult )
   310         {
   299         {
   311         case Swi::EValidationSucceeded:
   300         case Swi::EValidationSucceeded:
   312             result = iSifUi->ShowConfirmationL( aAppInfo, appSize, iLogo, aCertificates );
   301             result = iSifUi->ShowConfirmationL( aAppInfo, appSize, iLogo );
   313             break;
   302             break;
   314 
   303 
   315         case Swi::ESignatureSelfSigned:
   304         case Swi::ESignatureSelfSigned:
   316         case Swi::ENoCertificate:
   305         case Swi::ENoCertificate:
   317         case Swi::ECertificateValidationError:
   306         case Swi::ECertificateValidationError:
   320         case Swi::ENoCodeSigningExtension:
   309         case Swi::ENoCodeSigningExtension:
   321         case Swi::ENoSupportedPolicyExtension:
   310         case Swi::ENoSupportedPolicyExtension:
   322         case Swi::EMandatorySignatureMissing:
   311         case Swi::EMandatorySignatureMissing:
   323             if( aInstallAnyway )
   312             if( aInstallAnyway )
   324                 {
   313                 {
   325                 result = iSifUi->ShowConfirmationL( aAppInfo, appSize, iLogo, aCertificates );
   314                 result = iSifUi->ShowConfirmationL( aAppInfo, appSize, iLogo );
   326                 }
   315                 }
   327             break;
   316             break;
   328 
   317 
   329         default:
   318         default:
   330             break;
   319             break;
   372 
   361 
   373 // ---------------------------------------------------------------------------
   362 // ---------------------------------------------------------------------------
   374 // CSisxSifPluginUiHandler::DisplayUninstallL()
   363 // CSisxSifPluginUiHandler::DisplayUninstallL()
   375 // ---------------------------------------------------------------------------
   364 // ---------------------------------------------------------------------------
   376 //
   365 //
   377 TBool CSisxSifPluginUiHandler::DisplayUninstallL( const Swi::CAppInfo& /*aAppInfo*/ )
   366 TBool CSisxSifPluginUiHandler::DisplayUninstallL( const Swi::CAppInfo& aAppInfo )
   378     {
   367     {
   379     FLOG( _L("CSisxSifPluginUiHandler::DisplayUninstallL") );
   368     FLOG( _L("CSisxSifPluginUiHandler::DisplayUninstallL") );
   380 
   369 
   381     iSifUi->SetMode( CSifUi::EUninstalling );
   370     return iSifUi->ShowConfirmationL( aAppInfo );
   382 
       
   383     return ETrue;
       
   384     }
   371     }
   385 
   372 
   386 // ---------------------------------------------------------------------------
   373 // ---------------------------------------------------------------------------
   387 // CSisxSifPluginUiHandler::DisplayCompleteL()
   374 // CSisxSifPluginUiHandler::DisplayCompleteL()
   388 // ---------------------------------------------------------------------------
   375 // ---------------------------------------------------------------------------
   401 //
   388 //
   402 void CSisxSifPluginUiHandler::DisplayFailedL( TInt aErrorCode )
   389 void CSisxSifPluginUiHandler::DisplayFailedL( TInt aErrorCode )
   403     {
   390     {
   404     if( iSifUi )
   391     if( iSifUi )
   405         {
   392         {
   406         iSifUi->ShowFailedL( aErrorCode );
   393         _LIT( KErrorMessage, "Error" );
       
   394         iSifUi->ShowFailedL( aErrorCode, KErrorMessage );
   407         }
   395         }
   408     }
   396     }
   409 
   397 
   410 // ---------------------------------------------------------------------------
   398 // ---------------------------------------------------------------------------
   411 // CSisxSifPluginUiHandler::CSisxSifPluginUiHandler()
   399 // CSisxSifPluginUiHandler::CSisxSifPluginUiHandler()
   419 // CSisxSifPluginUiHandler::ConstructL()
   407 // CSisxSifPluginUiHandler::ConstructL()
   420 // ---------------------------------------------------------------------------
   408 // ---------------------------------------------------------------------------
   421 //
   409 //
   422 void CSisxSifPluginUiHandler::ConstructL()
   410 void CSisxSifPluginUiHandler::ConstructL()
   423     {
   411     {
   424     OpenResourceFileL();
       
   425     iSifUi = CSifUi::NewL();
   412     iSifUi = CSifUi::NewL();
   426     iSelectionCache = CSisxSifUiSelectionCache::NewL();
   413     iSelectionCache = CSisxSifUiSelectionCache::NewL();
   427     }
   414     }
   428 
   415 
   429 // ---------------------------------------------------------------------------
   416 // ---------------------------------------------------------------------------
   430 // CSisxSifPluginUiHandler::OpenResourceFileL()
   417 // CSisxSifPluginUiHandler::MemorySelectionL()
   431 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   432 //
   419 //
   433 void CSisxSifPluginUiHandler::OpenResourceFileL()
   420 void CSisxSifPluginUiHandler::MemorySelectionL()
   434     {
   421     {
   435     TFileName fileName;
   422     TDriveList driveList;
   436     fileName.Copy( KDC_RESOURCE_FILES_DIR );
   423     TInt driveCount = 0;
   437     fileName.Append( KSisxUIResourceFileName );
   424     TInt err = DriveInfo::GetUserVisibleDrives( iFs, driveList, driveCount );
   438     BaflUtils::NearestLanguageFile( iFs, fileName );
   425     User::LeaveIfError( err );
   439     iResourceFile.OpenL( iFs, fileName );
   426 
   440     iResourceFile.ConfirmSignatureL();
   427     iSelectableDrives.Reset();
   441     }
   428     TInt driveListLength = driveList.Length();
   442 
   429     for( TInt driveNumber = 0; driveNumber < driveListLength; driveNumber++ )
   443 // ---------------------------------------------------------------------------
   430         {
   444 // CSisxSifPluginUiHandler::ReadStringResourceL()
   431         if( driveList[ driveNumber ] )
   445 // ---------------------------------------------------------------------------
   432             {
   446 //
   433             TUint driveStatus = 0;
   447 HBufC* CSisxSifPluginUiHandler::ReadStringResourceL( TInt aResourceId )
   434             err = DriveInfo::GetDriveStatus( iFs, driveNumber, driveStatus );
   448     {
   435             if( !err && !( driveStatus & DriveInfo::EDriveRemote ) )
   449     HBufC8* buffer = iResourceFile.AllocReadLC( aResourceId );
   436                 {
   450     TResourceReader reader;
   437                 iSelectableDrives.Append( driveNumber );
   451     reader.SetBuffer( buffer );
   438                 }
   452     const TPtrC ptr( reader.ReadTPtrC() );
   439             }
   453     HBufC* string = ptr.AllocL();
   440         }
   454     CleanupStack::PopAndDestroy( buffer );
   441     iSifUi->SetMemorySelectionL( iSelectableDrives );
   455     return string;
   442     }
   456     }
   443 
   457 
       
   458 // ---------------------------------------------------------------------------
       
   459 // CSisxSifPluginUiHandler::CloseResourceFile()
       
   460 // ---------------------------------------------------------------------------
       
   461 //
       
   462 void CSisxSifPluginUiHandler::CloseResourceFile()
       
   463     {
       
   464     iResourceFile.Close();
       
   465     }
       
   466