appinstaller/AppinstUi/sisxsifplugin/src/sisxsifpluginactiveimpl.cpp
changeset 29 26b6f0522fd8
parent 25 98b66e4fb0be
child 33 8110bf1194d1
equal deleted inserted replaced
25:98b66e4fb0be 29:26b6f0522fd8
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include "sisxsifpluginactiveimpl.h"    // CSisxSifPluginActiveImpl
    18 #include "sisxsifpluginactiveimpl.h"    // CSisxSifPluginActiveImpl
    19 #include "sisxsifpluginuihandler.h"     // CSisxSifPluginUiHandler
    19 #include "sisxsifpluginuihandler.h"     // CSisxSifPluginUiHandler
       
    20 #include "sisxsifpluginuihandlersilent.h" // CSisxSifPluginUiHandlerSilent
    20 #include "sisxsifcleanuputils.h"        // CleanupResetAndDestroyPushL
    21 #include "sisxsifcleanuputils.h"        // CleanupResetAndDestroyPushL
    21 #include "sisxsifplugin.pan"            // Panic codes
    22 #include "sisxsifplugin.pan"            // Panic codes
    22 #include <usif/sif/sifcommon.h>         // Usif::CComponentInfo
    23 #include <usif/sif/sifcommon.h>         // Usif::CComponentInfo
    23 #include <usif/scr/scr.h>               // RSoftwareComponentRegistry
    24 #include <usif/scr/scr.h>               // RSoftwareComponentRegistry
    24 #include <usif/usiferror.h>             // SIF error codes
    25 #include <usif/usiferror.h>             // SIF error codes
    71 	{
    72 	{
    72 	FLOG( _L("Destructing CSisxSifPluginActiveImpl") );
    73 	FLOG( _L("Destructing CSisxSifPluginActiveImpl") );
    73 	Cancel();
    74 	Cancel();
    74     delete iAsyncLauncher;
    75     delete iAsyncLauncher;
    75     delete iUiHandler;
    76     delete iUiHandler;
       
    77     delete iUiHandlerSilent;
    76     delete iInstallPrefs;
    78     delete iInstallPrefs;
    77     delete iComponentInfo;
    79     delete iComponentInfo;
    78     delete iFileName;
    80     delete iFileName;
    79     iFs.Close();
    81     iFs.Close();
    80 	}
    82 	}
    83 // CSisxSifPluginActiveImpl::DoCancel()
    85 // CSisxSifPluginActiveImpl::DoCancel()
    84 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    85 //
    87 //
    86 void CSisxSifPluginActiveImpl::DoCancel()
    88 void CSisxSifPluginActiveImpl::DoCancel()
    87     {
    89     {
       
    90     FLOG( _L("CSisxSifPluginActiveImpl::DoCancel") );
       
    91 
    88     if( iClientStatus )
    92     if( iClientStatus )
    89         {
    93         {
    90         if( iAsyncLauncher )
    94         if( iAsyncLauncher )
    91             {
    95             {
    92             iAsyncLauncher->CancelOperation();
    96             iAsyncLauncher->CancelOperation();
    93             delete iAsyncLauncher;
    97             delete iAsyncLauncher;
    94             iAsyncLauncher = NULL;
    98             iAsyncLauncher = NULL;
    95             }
    99             }
    96 
   100 
    97         User::RequestComplete( iClientStatus, KErrCancel );
   101         CompleteClientRequest( KErrCancel );
    98         iClientStatus = NULL;
       
    99         }
   102         }
   100     }
   103     }
   101 
   104 
   102 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
   103 // CSisxSifPluginActiveImpl::RunL()
   106 // CSisxSifPluginActiveImpl::RunL()
   104 // ---------------------------------------------------------------------------
   107 // ---------------------------------------------------------------------------
   105 //
   108 //
   106 void CSisxSifPluginActiveImpl::RunL()
   109 void CSisxSifPluginActiveImpl::RunL()
   107     {
   110     {
   108     TInt result = iStatus.Int();
   111     TInt result = iStatus.Int();
   109     FLOG_1( _L("CSisxSifPluginActiveImpl::RunL(), result %d"), result );
   112     FLOG_2( _L("CSisxSifPluginActiveImpl::RunL(), op %d, result %d"), iOperation, result );
   110 
   113 
   111     if( iSilentInstall )
   114     if( result == KErrNone && iOperation == EInstall &&
   112         {
   115             iUseSilentMode && !iIsPackageCheckedForSilentInstall )
   113         FLOG( _L("CSisxSifPluginActiveImpl::RunL, silent install") );
   116         {
   114         ProcessSilentInstallL();
   117         ProcessSilentInstallL();    // makes the real silent install request
       
   118         iIsPackageCheckedForSilentInstall = ETrue;
   115         }
   119         }
   116     else
   120     else
   117         {
   121         {
   118         if( iOutputParams )
   122         if( iOutputParams )
   119             {
   123             {
   120             iOutputParams->AddIntL( KSifOutParam_ExtendedErrCode, result );
   124             iOutputParams->AddIntL( KSifOutParam_ExtendedErrCode, result );
   121 
   125 
   122             if( iInstallRequest && result == KErrNone )
   126             if( iOperation == EInstall && result == KErrNone )
   123                 {
   127                 {
   124                 TComponentId resultComponentId = 0;
   128                 TComponentId resultComponentId = 0;
   125                 TRAPD( getLastIdErr, resultComponentId = GetLastInstalledComponentIdL() );
   129                 TRAPD( getLastIdErr, resultComponentId = GetLastInstalledComponentIdL() );
   126                 if( getLastIdErr == KErrNone )
   130                 if( getLastIdErr == KErrNone )
   127                     {
   131                     {
   129                     }
   133                     }
   130                 }
   134                 }
   131             }
   135             }
   132 
   136 
   133         TInt errorCode = ConvertToSifErrorCode( result );
   137         TInt errorCode = ConvertToSifErrorCode( result );
   134         if( !iSilentInstall )
   138         if( !iUseSilentMode )
   135             {
   139             {
   136             if( errorCode == KErrNone )
   140             if( errorCode == KErrNone )
   137                 {
   141                 {
   138                 iUiHandler->DisplayCompleteL();
   142                 iUiHandler->DisplayCompleteL();
   139                 }
   143                 }
   172         const TDesC& aFileName,
   176         const TDesC& aFileName,
   173         const TSecurityContext& /*aSecurityContext*/,
   177         const TSecurityContext& /*aSecurityContext*/,
   174         CComponentInfo& aComponentInfo,
   178         CComponentInfo& aComponentInfo,
   175         TRequestStatus& aStatus )
   179         TRequestStatus& aStatus )
   176 	{
   180 	{
       
   181     iOperation = EGetComponentInfo;
   177     aStatus = KRequestPending;
   182     aStatus = KRequestPending;
   178     iClientStatus = &aStatus;
   183     iClientStatus = &aStatus;
   179 
   184 
   180     TRAPD( err, iAsyncLauncher->GetComponentInfoL( *iUiHandler, aFileName,
   185     TRAPD( err, iAsyncLauncher->GetComponentInfoL( UiHandlerL(), aFileName,
   181             *iInstallPrefs, aComponentInfo, iStatus ) );
   186             *iInstallPrefs, aComponentInfo, iStatus ) );
   182     FLOG_1( _L("CSisxSifPluginActiveImpl::GetComponentInfo, err = %d"), err );
   187     FLOG_1( _L("CSisxSifPluginActiveImpl::GetComponentInfo, err = %d"), err );
   183     if( err != KErrNone )
   188     if( err != KErrNone )
   184         {
   189         {
   185         CompleteRequest( aStatus, err );
   190         CompleteClientRequest( err );
   186         return;
   191         return;
   187         }
   192         }
   188 
   193 
   189     SetActive();
   194     SetActive();
   190 	}
   195 	}
   197         RFile& aFileHandle,
   202         RFile& aFileHandle,
   198         const TSecurityContext& /*aSecurityContext*/,
   203         const TSecurityContext& /*aSecurityContext*/,
   199         CComponentInfo& aComponentInfo,
   204         CComponentInfo& aComponentInfo,
   200         TRequestStatus& aStatus )
   205         TRequestStatus& aStatus )
   201 	{
   206 	{
       
   207     iOperation = EGetComponentInfo;
   202     aStatus = KRequestPending;
   208     aStatus = KRequestPending;
   203     iClientStatus = &aStatus;
   209     iClientStatus = &aStatus;
   204 
   210 
   205     TRAPD( err, iAsyncLauncher->GetComponentInfoL( *iUiHandler, aFileHandle,
   211     TRAPD( err, iAsyncLauncher->GetComponentInfoL( UiHandlerL(), aFileHandle,
   206             *iInstallPrefs, aComponentInfo, iStatus ) );
   212             *iInstallPrefs, aComponentInfo, iStatus ) );
   207     FLOG_1( _L("CSisxSifPluginActiveImpl::GetComponentInfo, err = %d"), err );
   213     FLOG_1( _L("CSisxSifPluginActiveImpl::GetComponentInfo, err = %d"), err );
       
   214 
   208     if( err != KErrNone )
   215     if( err != KErrNone )
   209         {
   216         {
   210         CompleteRequest( aStatus, err );
   217         CompleteClientRequest( err );
   211         return;
   218         return;
   212         }
   219         }
   213 
       
   214     SetActive();
   220     SetActive();
   215 	}
   221 	}
   216 
   222 
   217 // ---------------------------------------------------------------------------
   223 // ---------------------------------------------------------------------------
   218 // CSisxSifPluginActiveImpl::Install()
   224 // CSisxSifPluginActiveImpl::Install()
   223         const TSecurityContext& aSecurityContext,
   229         const TSecurityContext& aSecurityContext,
   224         const COpaqueNamedParams& aInputParams,
   230         const COpaqueNamedParams& aInputParams,
   225         COpaqueNamedParams& aOutputParams,
   231         COpaqueNamedParams& aOutputParams,
   226         TRequestStatus& aStatus )
   232         TRequestStatus& aStatus )
   227 	{
   233 	{
   228     CommonRequestPreamble( aSecurityContext, aInputParams, aOutputParams, aStatus );
   234     iOperation = EInstall;
   229 
   235     CommonRequestPreamble( aInputParams, aOutputParams, aStatus );
   230     FLOG_2( _L("CSisxSifPluginActiveImpl::Install: %S, iSilentInstall=%d"),
   236 
   231             &aFileName, iSilentInstall );
   237     if( iUseSilentMode && !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
   232 
   238         {
       
   239         FLOG( _L("CSisxSifPluginActiveImpl: missing ECapabilityTrustedUI ERROR") );
       
   240         CompleteClientRequest( KErrPermissionDenied );
       
   241         return;
       
   242         }
       
   243 
       
   244     FLOG_2( _L("CSisxSifPluginActiveImpl::Install: %S, iUseSilentMode=%d"),
       
   245             &aFileName, iUseSilentMode );
   233     TRAPD( err, DoInstallL( aFileName ) );
   246     TRAPD( err, DoInstallL( aFileName ) );
   234     FLOG_2( _L("CSisxSifPluginActiveImpl::Install, iInstallRequest=%d, err=%d"),
   247     FLOG_1( _L("CSisxSifPluginActiveImpl::Install, err=%d"), err );
   235             iInstallRequest, err );
   248 
   236     if( err != KErrNone )
   249     if( err != KErrNone )
   237         {
   250         {
   238         CompleteRequest( aStatus, err );
   251         CompleteClientRequest( err );
   239         return;
   252         return;
   240         }
   253         }
   241 
       
   242     SetActive();
   254     SetActive();
   243 	}
   255 	}
   244 
   256 
   245 // ---------------------------------------------------------------------------
   257 // ---------------------------------------------------------------------------
   246 // CSisxSifPluginActiveImpl::Install()
   258 // CSisxSifPluginActiveImpl::Install()
   251         const TSecurityContext& aSecurityContext,
   263         const TSecurityContext& aSecurityContext,
   252         const COpaqueNamedParams& aInputParams,
   264         const COpaqueNamedParams& aInputParams,
   253         COpaqueNamedParams& aOutputParams,
   265         COpaqueNamedParams& aOutputParams,
   254         TRequestStatus& aStatus )
   266         TRequestStatus& aStatus )
   255 	{
   267 	{
   256     CommonRequestPreamble( aSecurityContext, aInputParams, aOutputParams, aStatus );
   268     iOperation = EInstall;
   257 
   269     CommonRequestPreamble( aInputParams, aOutputParams, aStatus );
   258     FLOG_1( _L("CSisxSifPluginActiveImpl::Install, iSilentInstall=%d"), iSilentInstall );
   270 
   259 
   271     if( iUseSilentMode && !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
   260     TInt err;
   272         {
   261     if( iSilentInstall )
   273         FLOG( _L("CSisxSifPluginActiveImpl: missing ECapabilityTrustedUI ERROR") );
       
   274         CompleteClientRequest( KErrPermissionDenied );
       
   275         return;
       
   276         }
       
   277 
       
   278     FLOG_1( _L("CSisxSifPluginActiveImpl::Install, iUseSilentMode=%d"), iUseSilentMode );
       
   279     TInt err = KErrNone;
       
   280     if( iUseSilentMode )
   262         {
   281         {
   263         // Silent install does a few addtional checks on the package to see if is
   282         // Silent install does a few addtional checks on the package to see if is
   264         // signed and had the required capabilities. So we need to the get the
   283         // signed and had the required capabilities. So we need to the get the
   265         // package component information without installing it. Real silent install
   284         // package component information without installing it. Real silent install
   266         // operation is started in RunL() after this GetComponentInfoL() completes.
   285         // operation is started in RunL() after this GetComponentInfoL() completes.
   267         SetSilentInstallFile( aFileHandle );
   286         SetSilentInstallFile( aFileHandle );
   268         TRAP( err, iAsyncLauncher->GetComponentInfoL( *iUiHandler, aFileHandle, *iInstallPrefs,
   287         TRAP( err, iAsyncLauncher->GetComponentInfoL( UiHandlerL( iUseSilentMode ),
   269                 *iComponentInfo, iStatus ) );
   288                 aFileHandle, *iInstallPrefs, *iComponentInfo, iStatus ) );
       
   289         FLOG_1( _L("CSisxSifPluginActiveImpl::GetComponentInfoL, err=%d"), err );
   270         }
   290         }
   271     else
   291     else
   272         {
   292         {
   273         // Proceed with the normal installation.
   293         // Proceed with the normal installation.
   274         TRAP( err, iAsyncLauncher->InstallL( *iUiHandler, aFileHandle, *iInstallPrefs, iStatus ) );
   294         TRAP( err, iAsyncLauncher->InstallL( UiHandlerL(), aFileHandle,
   275         iInstallRequest = ETrue;
   295                 *iInstallPrefs, iStatus ) );
   276         }
   296         FLOG_1( _L("CSisxSifPluginActiveImpl::Install, err=%d"), err );
   277 
   297         }
   278     FLOG_2( _L("CSisxSifPluginActiveImpl::Install, iInstallRequest=%d, err=%d"),
   298 
   279             iInstallRequest, err );
       
   280     if( err != KErrNone )
   299     if( err != KErrNone )
   281         {
   300         {
   282         CompleteRequest( aStatus, err );
   301         CompleteClientRequest( err );
   283         return;
   302         return;
   284         }
   303         }
   285 
       
   286     SetActive();
   304     SetActive();
   287 	}
   305 	}
   288 
   306 
   289 // ---------------------------------------------------------------------------
   307 // ---------------------------------------------------------------------------
   290 // CSisxSifPluginActiveImpl::Uninstall()
   308 // CSisxSifPluginActiveImpl::Uninstall()
   295         const TSecurityContext& aSecurityContext,
   313         const TSecurityContext& aSecurityContext,
   296         const COpaqueNamedParams& aInputParams,
   314         const COpaqueNamedParams& aInputParams,
   297         COpaqueNamedParams& aOutputParams,
   315         COpaqueNamedParams& aOutputParams,
   298         TRequestStatus& aStatus )
   316         TRequestStatus& aStatus )
   299 	{
   317 	{
   300     CommonRequestPreamble( aSecurityContext, aInputParams, aOutputParams, aStatus );
   318     iOperation = EUninstall;
   301 
   319     CommonRequestPreamble( aInputParams, aOutputParams, aStatus );
   302     TRAPD( err, DoUninstallL( aComponentId, aStatus ) );
   320 
       
   321     // Uninstall is always silent. TrustedUI capability is always required.
       
   322     if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
       
   323         {
       
   324         FLOG( _L( "CSisxSifPluginActiveImpl: missing ECapabilityTrustedUI ERROR") );
       
   325         CompleteClientRequest( KErrPermissionDenied );
       
   326         return;
       
   327         }
       
   328     iUseSilentMode = ETrue;     // no complete/error notes launched in RunL
       
   329 
       
   330     FLOG( _L("CSisxSifPluginActiveImpl::Uninstall") );
       
   331     TRAPD( err, DoUninstallL( aComponentId ) );
   303     FLOG_1( _L("CSisxSifPluginActiveImpl::Uninstall, err=%d"), err );
   332     FLOG_1( _L("CSisxSifPluginActiveImpl::Uninstall, err=%d"), err );
       
   333 
   304     if( err != KErrNone )
   334     if( err != KErrNone )
   305         {
   335         {
   306         CompleteRequest( aStatus, err );
   336         CompleteClientRequest( err );
   307         return;
   337         return;
   308         }
   338         }
   309 
       
   310     SetActive();
   339     SetActive();
   311 	}
   340 	}
   312 
   341 
   313 // ---------------------------------------------------------------------------
   342 // ---------------------------------------------------------------------------
   314 // CSisxSifPluginActiveImpl::Activate()
   343 // CSisxSifPluginActiveImpl::Activate()
   317 void CSisxSifPluginActiveImpl::Activate(
   346 void CSisxSifPluginActiveImpl::Activate(
   318         TComponentId aComponentId,
   347         TComponentId aComponentId,
   319         const TSecurityContext& /*aSecurityContext*/,
   348         const TSecurityContext& /*aSecurityContext*/,
   320         TRequestStatus& aStatus )
   349         TRequestStatus& aStatus )
   321 	{
   350 	{
       
   351     iOperation = EActivate;
   322     aStatus = KRequestPending;
   352     aStatus = KRequestPending;
   323     iClientStatus = &aStatus;
   353     iClientStatus = &aStatus;
   324 
   354 
   325     TRAPD( err, DoActivateL( aComponentId ) );
   355     TRAPD( err, DoActivateL( aComponentId ) );
   326     FLOG_2( _L("CSisxSifPluginActiveImpl::Activate, component %d, err=%d"), aComponentId, err );
   356     FLOG_2( _L("CSisxSifPluginActiveImpl::Activate, component %d, err=%d"), aComponentId, err );
   327     if( err != KErrNone )
   357     if( err != KErrNone )
   328         {
   358         {
   329         CompleteRequest( aStatus, err );
   359         CompleteClientRequest( err );
   330         return;
   360         return;
   331         }
   361         }
   332 
   362 
   333     iStatus = KRequestPending;
   363     iStatus = KRequestPending;
   334     CompleteRequest( iStatus, KErrNone );
   364     TRequestStatus* status = &iStatus;
       
   365     User::RequestComplete( status, KErrNone );
   335     SetActive();
   366     SetActive();
   336 	}
   367 	}
   337 
   368 
   338 // ---------------------------------------------------------------------------
   369 // ---------------------------------------------------------------------------
   339 // CSisxSifPluginActiveImpl::Deactivate()
   370 // CSisxSifPluginActiveImpl::Deactivate()
   342 void CSisxSifPluginActiveImpl::Deactivate(
   373 void CSisxSifPluginActiveImpl::Deactivate(
   343         TComponentId aComponentId,
   374         TComponentId aComponentId,
   344         const TSecurityContext& /*aSecurityContext*/,
   375         const TSecurityContext& /*aSecurityContext*/,
   345         TRequestStatus& aStatus )
   376         TRequestStatus& aStatus )
   346 	{
   377 	{
       
   378     iOperation = EDeactivate;
   347     aStatus = KRequestPending;
   379     aStatus = KRequestPending;
   348     iClientStatus = &aStatus;
   380     iClientStatus = &aStatus;
   349 
   381 
   350     Swi::RSisRegistryWritableSession sisRegSession;
       
   351     TRAPD( err, DoDeactivateL( aComponentId ) );
   382     TRAPD( err, DoDeactivateL( aComponentId ) );
   352     FLOG_2( _L("CSisxSifPluginActiveImpl::Deactivate, component %d, err=%d"), aComponentId, err );
   383     FLOG_2( _L("CSisxSifPluginActiveImpl::Deactivate, component %d, err=%d"), aComponentId, err );
   353     if( err != KErrNone )
   384     if( err != KErrNone )
   354         {
   385         {
   355         CompleteRequest( aStatus, err );
   386         CompleteClientRequest( err );
   356         return;
   387         return;
   357         }
   388         }
   358 
   389 
   359     iStatus = KRequestPending;
   390     iStatus = KRequestPending;
   360     CompleteRequest( iStatus, KErrNone );
   391     TRequestStatus* status = &iStatus;
       
   392     User::RequestComplete( status, KErrNone );
   361     SetActive();
   393     SetActive();
   362 	}
   394 	}
   363 
   395 
   364 // ---------------------------------------------------------------------------
   396 // ---------------------------------------------------------------------------
   365 // CSisxSifPluginActiveImpl::CSisxSifPluginActiveImpl()
   397 // CSisxSifPluginActiveImpl::CSisxSifPluginActiveImpl()
   376 //
   408 //
   377 void CSisxSifPluginActiveImpl::ConstructL()
   409 void CSisxSifPluginActiveImpl::ConstructL()
   378     {
   410     {
   379     User::LeaveIfError( iFs.Connect() );
   411     User::LeaveIfError( iFs.Connect() );
   380 
   412 
   381     iUiHandler = CSisxSifPluginUiHandler::NewL( iFs );
       
   382     iAsyncLauncher = Swi::CAsyncLauncher::NewL();
   413     iAsyncLauncher = Swi::CAsyncLauncher::NewL();
   383     iInstallPrefs = Swi::CInstallPrefs::NewL();
   414     iInstallPrefs = Swi::CInstallPrefs::NewL();
   384     iComponentInfo = CComponentInfo::NewL();
   415     iComponentInfo = CComponentInfo::NewL();
   385     }
   416     }
   386 
   417 
   387 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   388 // CSisxSifPluginActiveImpl::Complete()
   419 // CSisxSifPluginActiveImpl::UiHandlerL()
   389 // ---------------------------------------------------------------------------
   420 // ---------------------------------------------------------------------------
   390 //
   421 //
   391 void CSisxSifPluginActiveImpl::CompleteRequest( TRequestStatus& aStatus, TInt aResult )
   422 Swi::MUiHandler& CSisxSifPluginActiveImpl::UiHandlerL( TBool aUseSilentMode )
   392     {
   423     {
   393     TRequestStatus* statusPtr = &aStatus;
   424     Swi::MUiHandler* handler = NULL;
   394     User::RequestComplete( statusPtr, aResult );
   425 
       
   426     if( aUseSilentMode )
       
   427         {
       
   428         if( iUiHandler )
       
   429             {
       
   430             delete iUiHandler;
       
   431             iUiHandler = NULL;
       
   432             }
       
   433         if( !iUiHandlerSilent )
       
   434             {
       
   435             iUiHandlerSilent = CSisxSifPluginUiHandlerSilent::NewL( iFs );
       
   436             }
       
   437         handler = iUiHandlerSilent;
       
   438         }
       
   439     else
       
   440         {
       
   441         if( iUiHandlerSilent )
       
   442             {
       
   443             delete iUiHandlerSilent;
       
   444             iUiHandlerSilent = NULL;
       
   445             }
       
   446         if( !iUiHandler )
       
   447             {
       
   448             iUiHandler = CSisxSifPluginUiHandler::NewL( iFs );
       
   449             }
       
   450         handler = iUiHandler;
       
   451         }
       
   452 
       
   453     return *handler;
   395     }
   454     }
   396 
   455 
   397 // ---------------------------------------------------------------------------
   456 // ---------------------------------------------------------------------------
   398 // CSisxSifPluginActiveImpl::CommonRequestPreamble()
   457 // CSisxSifPluginActiveImpl::CommonRequestPreamble()
   399 // ---------------------------------------------------------------------------
   458 // ---------------------------------------------------------------------------
   400 //
   459 //
   401 void CSisxSifPluginActiveImpl::CommonRequestPreamble(
   460 void CSisxSifPluginActiveImpl::CommonRequestPreamble(
   402         const TSecurityContext& aSecurityContext,
       
   403         const COpaqueNamedParams& aInputParams,
   461         const COpaqueNamedParams& aInputParams,
   404         COpaqueNamedParams& aOutputParams,
   462         COpaqueNamedParams& aOutputParams,
   405         TRequestStatus& aStatus )
   463         TRequestStatus& aStatus )
   406     {
   464     {
   407     aStatus = KRequestPending;
   465     aStatus = KRequestPending;
   408     iClientStatus = &aStatus;
   466     iClientStatus = &aStatus;
   409 
   467 
       
   468     TInt silentInstall = 0;
       
   469     TRAPD( err, aInputParams.GetIntByNameL( KSifInParam_InstallSilently, silentInstall ) );
       
   470     iUseSilentMode = ( err == KErrNone && silentInstall != 0 );
       
   471     iIsPackageCheckedForSilentInstall = EFalse;
       
   472 
   410     iInputParams = &aInputParams;
   473     iInputParams = &aInputParams;
   411     iOutputParams = &aOutputParams;
   474     iOutputParams = &aOutputParams;
   412 
   475 
   413     // Check InstallSilently opaque input argument
       
   414     TInt silentInstall = 0;
       
   415     TRAP_IGNORE( aInputParams.GetIntByNameL( KSifInParam_InstallSilently, silentInstall ) );
       
   416     if( silentInstall )
       
   417         {
       
   418         iSilentInstall = ETrue;
       
   419         if( !aSecurityContext.HasCapability( ECapabilityTrustedUI ) )
       
   420             {
       
   421             FLOG( _L("CSisxSifPluginActiveImpl: missing ECapabilityTrustedUI ERROR") );
       
   422             CompleteRequest( aStatus, KErrPermissionDenied );
       
   423             iClientStatus = NULL;
       
   424             }
       
   425         }
       
   426 
       
   427     // TODO: KSifInParam_InstallInactive
   476     // TODO: KSifInParam_InstallInactive
   428     }
   477     }
   429 
   478 
   430 // ---------------------------------------------------------------------------
   479 // ---------------------------------------------------------------------------
       
   480 // CSisxSifPluginActiveImpl::CompleteClientRequest()
       
   481 // ---------------------------------------------------------------------------
       
   482 //
       
   483 void CSisxSifPluginActiveImpl::CompleteClientRequest( TInt aResult )
       
   484     {
       
   485     if( iClientStatus )
       
   486         {
       
   487         User::RequestComplete( iClientStatus, aResult );
       
   488         iClientStatus = NULL;
       
   489         }
       
   490     }
       
   491 
       
   492 // ---------------------------------------------------------------------------
   431 // CSisxSifPluginActiveImpl::DoInstallL()
   493 // CSisxSifPluginActiveImpl::DoInstallL()
   432 // ---------------------------------------------------------------------------
   494 // ---------------------------------------------------------------------------
   433 //
   495 //
   434 void CSisxSifPluginActiveImpl::DoInstallL( const TDesC& aFileName )
   496 void CSisxSifPluginActiveImpl::DoInstallL( const TDesC& aFileName )
   435     {
   497     {
   436     if( iSilentInstall )
   498     if( iUseSilentMode )
   437         {
   499         {
   438         // Silent install does a few addtional checks on the package to see if is
   500         // Silent install does a few addtional checks on the package to see if is
   439         // signed and had the required capabilities. So we need to the get the
   501         // signed and had the required capabilities. So we need to the get the
   440         // package component information without installing it. Real silent install
   502         // package component information without installing it. Real silent install
   441         // operation is started in RunL() after this GetComponentInfoL() completes.
   503         // operation is started in RunL() after this GetComponentInfoL() completes.
   442         SetSilentInstallFileL( aFileName );
   504         SetSilentInstallFileL( aFileName );
   443         iAsyncLauncher->GetComponentInfoL( *iUiHandler, aFileName, *iInstallPrefs,
   505         iIsPackageCheckedForSilentInstall = EFalse;
   444                 *iComponentInfo, iStatus );
   506         iAsyncLauncher->GetComponentInfoL( UiHandlerL( iUseSilentMode ), aFileName,
       
   507                 *iInstallPrefs, *iComponentInfo, iStatus );
   445         }
   508         }
   446     else
   509     else
   447         {
   510         {
   448         // Proceed with the normal installation.
   511         // Proceed with the normal installation.
   449         iAsyncLauncher->InstallL( *iUiHandler, aFileName, *iInstallPrefs, iStatus );
   512         iAsyncLauncher->InstallL( UiHandlerL(), aFileName, *iInstallPrefs, iStatus );
   450         iInstallRequest = ETrue;
       
   451         }
   513         }
   452     }
   514     }
   453 
   515 
   454 // ---------------------------------------------------------------------------
   516 // ---------------------------------------------------------------------------
   455 // CSisxSifPluginActiveImpl::DoUninstallL()
   517 // CSisxSifPluginActiveImpl::DoUninstallL()
   456 // ---------------------------------------------------------------------------
   518 // ---------------------------------------------------------------------------
   457 //
   519 //
   458 void CSisxSifPluginActiveImpl::DoUninstallL( TComponentId aComponentId, TRequestStatus& /*aStatus*/ )
   520 void CSisxSifPluginActiveImpl::DoUninstallL( TComponentId aComponentId )
   459     {
   521     {
   460     RSoftwareComponentRegistry scrSession;
   522     RSoftwareComponentRegistry scrSession;
   461     User::LeaveIfError( scrSession.Connect() );
   523     User::LeaveIfError( scrSession.Connect() );
   462     CleanupClosePushL( scrSession );
   524     CleanupClosePushL( scrSession );
   463 
   525 
   473         }
   535         }
   474 
   536 
   475     TUid objectId = TUid::Uid( intPropertyEntry->IntValue() );
   537     TUid objectId = TUid::Uid( intPropertyEntry->IntValue() );
   476     CleanupStack::PopAndDestroy( 2, &scrSession );      // propertyEntry, scrSession
   538     CleanupStack::PopAndDestroy( 2, &scrSession );      // propertyEntry, scrSession
   477 
   539 
   478     iAsyncLauncher->UninstallL( *iUiHandler, objectId, iStatus );
   540     iAsyncLauncher->UninstallL( UiHandlerL( iUseSilentMode ), objectId, iStatus );
   479     }
   541     }
   480 
   542 
   481 // ---------------------------------------------------------------------------
   543 // ---------------------------------------------------------------------------
   482 // CSisxSifPluginActiveImpl::DoActivateL()
   544 // CSisxSifPluginActiveImpl::DoActivateL()
   483 // ---------------------------------------------------------------------------
   545 // ---------------------------------------------------------------------------
   506 // CSisxSifPluginActiveImpl::ConvertToSifErrorCode()
   568 // CSisxSifPluginActiveImpl::ConvertToSifErrorCode()
   507 // ---------------------------------------------------------------------------
   569 // ---------------------------------------------------------------------------
   508 //
   570 //
   509 TInt CSisxSifPluginActiveImpl::ConvertToSifErrorCode( TInt aSwiErrorCode )
   571 TInt CSisxSifPluginActiveImpl::ConvertToSifErrorCode( TInt aSwiErrorCode )
   510     {
   572     {
       
   573     FLOG_1( _L("CSisxSifPluginActiveImpl::ConvertToSifErrorCode(), aSwiErrorCode=%d"),
       
   574             aSwiErrorCode );
       
   575 
   511     // TODO: need to show also SWI error code in UI somehow when necessary
   576     // TODO: need to show also SWI error code in UI somehow when necessary
   512 
   577 
   513     if( aSwiErrorCode > KSystemWideErrorsBoundary )
   578     if( aSwiErrorCode > KSystemWideErrorsBoundary )
   514         {
   579         {
   515         return aSwiErrorCode;
   580         return aSwiErrorCode;
   607 // CSisxSifPluginActiveImpl::GetLastInstalledComponentIdL()
   672 // CSisxSifPluginActiveImpl::GetLastInstalledComponentIdL()
   608 // ---------------------------------------------------------------------------
   673 // ---------------------------------------------------------------------------
   609 //
   674 //
   610 TComponentId CSisxSifPluginActiveImpl::GetLastInstalledComponentIdL()
   675 TComponentId CSisxSifPluginActiveImpl::GetLastInstalledComponentIdL()
   611     {
   676     {
   612     ASSERT( iInstallRequest );
   677     ASSERT( iOperation == EInstall );
   613 
   678 
   614     // Find the id of the last installed component and return it
   679     // Find the id of the last installed component and return it
   615     TInt uid;
   680     TInt uid;
   616     User::LeaveIfError( RProperty::Get( KUidSystemCategory, KUidSwiLatestInstallation, uid ) );
   681     User::LeaveIfError( RProperty::Get( KUidSystemCategory, KUidSwiLatestInstallation, uid ) );
   617 
   682 
   625 
   690 
   626     return componentId;
   691     return componentId;
   627     }
   692     }
   628 
   693 
   629 // ---------------------------------------------------------------------------
   694 // ---------------------------------------------------------------------------
   630 // CSisxSifPluginActiveImpl::NeedUserCapabilityL()
   695 // CSisxSifPluginActiveImpl::RequiresUserCapabilityL()
   631 // ---------------------------------------------------------------------------
   696 // ---------------------------------------------------------------------------
   632 //
   697 //
   633 TBool CSisxSifPluginActiveImpl::NeedUserCapabilityL()
   698 TBool CSisxSifPluginActiveImpl::RequiresUserCapabilityL()
   634     {
   699     {
   635     // Silent install is not allowed when the package requires additional capabilities
   700     // Silent install is not allowed when the package requires additional capabilities
   636     // than what it is signed for (Package may request for some capability that is not
   701     // than what it is signed for (Package may request for some capability that is not
   637     // granted by the certificate used to sign it).
   702     // granted by the certificate used to sign it).
   638     const TCapabilitySet& componentUserCaps( iComponentInfo->RootNodeL().UserGrantableCaps() );
   703     const TCapabilitySet& componentUserCaps( iComponentInfo->RootNodeL().UserGrantableCaps() );
   651 // CSisxSifPluginActiveImpl::ProcessSilentInstallL()
   716 // CSisxSifPluginActiveImpl::ProcessSilentInstallL()
   652 // ---------------------------------------------------------------------------
   717 // ---------------------------------------------------------------------------
   653 //
   718 //
   654 void CSisxSifPluginActiveImpl::ProcessSilentInstallL()
   719 void CSisxSifPluginActiveImpl::ProcessSilentInstallL()
   655     {
   720     {
   656     // We need to do this only once per installation request
   721     TBool isAuthenticated = ( iComponentInfo->RootNodeL().Authenticity() == EAuthenticated );
   657     iSilentInstall = EFalse;
   722     TBool requiresUserCapability = RequiresUserCapabilityL();
   658     iInstallRequest = ETrue;
   723     if( !isAuthenticated || requiresUserCapability )
   659 
   724         {
   660     // TODO: should self-signed packages that do not contain executables be allowed?
   725         if( !isAuthenticated )
   661     //TBool hasExecutable = iComponentInfo->RootNodeL().HasExecutable();
       
   662 
       
   663     TBool isNotAuthenticated = ( iComponentInfo->RootNodeL().Authenticity() == ENotAuthenticated );
       
   664     TBool reqUserCap = NeedUserCapabilityL();
       
   665     if( isNotAuthenticated || reqUserCap )
       
   666         {
       
   667         if( isNotAuthenticated )
       
   668             {
   726             {
   669             FLOG( _L("Silent Install is not allowed on unsigned or self-signed packages") );
   727             FLOG( _L("Silent Install is not allowed on unsigned or self-signed packages") );
   670             }
   728             }
   671         if( reqUserCap )
   729         if( requiresUserCapability )
   672             {
   730             {
   673             FLOG( _L("Silent Install is not allowed when user capabilities are required") );
   731             FLOG( _L("Silent Install is not allowed when user capabilities are required") );
   674             }
   732             }
   675         User::RequestComplete( iClientStatus, KErrPermissionDenied );
   733         CompleteClientRequest( KErrPermissionDenied );
   676         iClientStatus = NULL;
       
   677         }
   734         }
   678     else
   735     else
   679         {
   736         {
   680         TInt err = KErrNone;
   737         TInt err = KErrNone;
   681         if( iFileHandle )
   738         if( iFileHandle )
   682             {
   739             {
   683             TRAP( err, iAsyncLauncher->InstallL( *iUiHandler, *iFileHandle, *iInstallPrefs, iStatus ) );
   740             TRAP( err, iAsyncLauncher->InstallL( UiHandlerL( iUseSilentMode ), *iFileHandle,
       
   741                     *iInstallPrefs, iStatus ) );
   684             }
   742             }
   685         else if( iFileName )
   743         else if( iFileName )
   686             {
   744             {
   687             TRAP( err, iAsyncLauncher->InstallL( *iUiHandler, *iFileName, *iInstallPrefs, iStatus ) );
   745             TRAP( err, iAsyncLauncher->InstallL( UiHandlerL( iUseSilentMode ), *iFileName,
       
   746                     *iInstallPrefs, iStatus ) );
   688             }
   747             }
   689         else
   748         else
   690             {
   749             {
   691             Panic( ESisxSifInternalError );
   750             Panic( ESisxSifInternalError );
   692             }
   751             }
   695             {
   754             {
   696             SetActive();
   755             SetActive();
   697             }
   756             }
   698         else
   757         else
   699             {
   758             {
   700             User::RequestComplete( iClientStatus, err );
   759             CompleteClientRequest( err );
   701             iClientStatus = NULL;
       
   702             }
   760             }
   703         }
   761         }
   704     }
   762     }
   705 
   763 
   706 // ---------------------------------------------------------------------------
   764 // ---------------------------------------------------------------------------