connectivitymodules/SeCon/services/pcd/src/sconinstaller.cpp
changeset 36 9ba7f05d28a5
parent 20 e1de7d03f843
child 64 a62b67d1f67c
equal deleted inserted replaced
35:0ca79e3612d9 36:9ba7f05d28a5
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 
    20 #include <s32mem.h> // For RBufWriteStream
    21 #include <pathinfo.h>
    21 #include <utf.h>  // for CnvUtfConverter
    22 #include <swi/sisregistryentry.h>
    22 //#include <pathinfo.h>
    23 #include <swi/sisregistrypackage.h>
    23 #include <usif/sif/sifcommon.h>
    24 #include <swi/sisregistrysession.h>
    24 
    25 #include <SWInstDefs.h>
    25 using namespace Usif;
    26 #include <mmf/common/mmfcontrollerpluginresolver.h>
       
    27 #include <javaregistry.h>
       
    28 
       
    29 using namespace Java;
       
    30 
    26 
    31 #include "debug.h"
    27 #include "debug.h"
    32 #include "sconinstaller.h"
    28 #include "sconinstaller.h"
    33 #include "sconpcdconsts.h"
    29 #include "sconpcdconsts.h"
    34 #include "sconpcdutility.h"
    30 #include "sconpcdutility.h"
    35 
    31 
    36 _LIT8( KWidgetMimeType, "application/x-nokia-widget");
       
    37 
    32 
    38 const TInt KSConSeConUidValue = 0x101f99f6;
    33 const TInt KSConSeConUidValue = 0x101f99f6;
    39 const TUid KSConSeConUid = {KSConSeConUidValue};
    34 const TUid KSConSeConUid = {KSConSeConUidValue};
    40 
    35 
       
    36 _LIT8(KValSep, "=");
       
    37 _LIT8(KComma, ",");
       
    38 _LIT8(KLineEnd, "\r\n");
       
    39 
    41 // ============================= MEMBER FUNCTIONS ===============================
    40 // ============================= MEMBER FUNCTIONS ===============================
    42 
    41 
    43 
    42 CSConAppInstaller* CSConAppInstaller::NewL( CSConInstallerQueue* aQueue, RFs& aFs )
       
    43     {
       
    44     CSConAppInstaller* self = new (ELeave) CSConAppInstaller( aQueue, aFs );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
    44 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    45 // CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue )
    51 // CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue )
    46 // Constructor
    52 // Constructor
    47 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    48 //
    54 //
    49 CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs ) :
    55 CSConAppInstaller::CSConAppInstaller( CSConInstallerQueue* aQueue, RFs& aFs ) :
    50     CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
    56     CActive( EPriorityStandard ), iQueue( aQueue ), iFs( aFs )
    51     {
    57     {
    52     TRACE_FUNC;
    58     CActiveScheduler::Add( this );
       
    59     }
       
    60 
       
    61 void CSConAppInstaller::ConstructL()
       
    62     {
       
    63     iSifOptions = COpaqueNamedParams::NewL();
       
    64     iSifResults = COpaqueNamedParams::NewL();
    53     }
    65     }
    54 
    66 
    55 // -----------------------------------------------------------------------------
    67 // -----------------------------------------------------------------------------
    56 // CSConAppInstaller::~CSConAppInstaller()
    68 // CSConAppInstaller::~CSConAppInstaller()
    57 // Destructor
    69 // Destructor
    58 // -----------------------------------------------------------------------------
    70 // -----------------------------------------------------------------------------
    59 //
    71 //
    60 CSConAppInstaller::~CSConAppInstaller()
    72 CSConAppInstaller::~CSConAppInstaller()
    61     {
    73     {
    62     TRACE_FUNC;
    74     TRACE_FUNC;
    63     iSWInst.Close();
    75     Cancel();
       
    76     iSwInstaller.Close();
       
    77     delete iSifOptions;
       
    78     delete iSifResults;
    64     }
    79     }
    65 
    80 
    66 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
    67 // CSConAppInstaller::StartInstaller( TInt& aTaskId )
    82 // CSConAppInstaller::StartInstaller( TInt& aTaskId )
    68 // Starts the installer task
    83 // Starts the installer task
    77     
    92     
    78     TInt ret = iQueue->GetTask( aTaskId, task );
    93     TInt ret = iQueue->GetTask( aTaskId, task );
    79     
    94     
    80     if( aTaskId > 0 && ret != KErrNotFound )
    95     if( aTaskId > 0 && ret != KErrNotFound )
    81         {
    96         {
    82         if ( iInstallerState != EIdle || IsActive() )
    97         if ( IsActive() )
    83             {
    98             {
    84             LOGGER_WRITE("WARNING! SConAppInstaller was not on idle state!");
    99             LOGGER_WRITE("WARNING! SConAppInstaller was not on idle state!");
    85             iQueue->CompleteTask( aTaskId, KErrInUse );
   100             iQueue->CompleteTask( aTaskId, KErrInUse );
    86             TRACE_FUNC_EXIT;
   101             TRACE_FUNC_EXIT;
    87             return;
   102             return;
    93         
   108         
    94         switch( task->GetServiceId() )
   109         switch( task->GetServiceId() )
    95             {
   110             {
    96             case EInstall :
   111             case EInstall :
    97                 iQueue->ChangeQueueProcessStatus();
   112                 iQueue->ChangeQueueProcessStatus();
    98                 err = iSWInst.Connect();
   113                 err = iSwInstaller.Connect();
    99                 
       
   100                 if( err == KErrNone )
   114                 if( err == KErrNone )
   101                     {
   115                     {
   102                     if ( task->iInstallParams->iMode == ESilentInstall )
   116                     TRAP(err, ProcessInstallL( *task->iInstallParams ));
   103                     	{
   117                     if( err != KErrNone )
   104                     	LOGGER_WRITE( "Begin silent installation.. " );
   118                         {
   105                     	iOptions.iUntrusted = SwiUI::EPolicyNotAllowed;
   119                         LOGGER_WRITE_1( "StartInstaller ProcessInstallL err: %d", err );
   106                         iOptions.iOCSP = SwiUI::EPolicyNotAllowed;
   120                         iStatus = KRequestPending;
   107                         iOptionsPckg = iOptions;
   121                         SetActive();
   108                         iInstallerState = ESilentInstalling;
   122                         status = &iStatus;
   109                     	iSWInst.SilentInstall( iStatus, task->iInstallParams->iPath, iOptionsPckg );
   123                         User::RequestComplete( status, err );
   110                     	}
   124                         }
   111                     else
       
   112                     	{
       
   113                     	LOGGER_WRITE( "Begin to install.. " );
       
   114                     	iInstallerState = EInstalling;
       
   115                         iSWInst.Install( iStatus, task->iInstallParams->iPath );
       
   116                     	}
       
   117                     }
   125                     }
   118                 
   126                 
   119                 break;
   127                 break;
   120             case EUninstall :
   128             case EUninstall :
   121                 iQueue->ChangeQueueProcessStatus();
   129                 iQueue->ChangeQueueProcessStatus();
   122                 err = iSWInst.Connect();
   130                 err = iSwInstaller.Connect();
   123                 
       
   124                 if( err == KErrNone )
   131                 if( err == KErrNone )
   125                     {
   132                     {
   126                     LOGGER_WRITE( "Begin to uninstall.. " );
   133                     LOGGER_WRITE( "Begin to uninstall.. " );
   127                     
   134                     
   128                     TRAP( err, ProcessUninstallL( *task->iUninstallParams ) );
   135                     TRAP( err, ProcessUninstallL( *task->iUninstallParams ) );
   129                     if( err != KErrNone )
   136                     if( err != KErrNone )
   130                         {
   137                         {
   131                         LOGGER_WRITE_1( "StartInstaller ProcessUninstallL err: %d", err );
   138                         LOGGER_WRITE_1( "StartInstaller ProcessUninstallL err: %d", err );
       
   139                         iStatus = KRequestPending;
       
   140                         SetActive();
   132                         status = &iStatus;
   141                         status = &iStatus;
   133                         User::RequestComplete( status, err );
   142                         User::RequestComplete( status, err );
   134                         }
   143                         }
   135                     }
   144                     }
   136                 
   145                 
   137                 break;
   146                 break;
   138             case EListInstalledApps :
   147             case EListInstalledApps :
   139                 iQueue->ChangeQueueProcessStatus();
   148                 iQueue->ChangeQueueProcessStatus();
   140                 iInstallerState = EListingInstalledApps;
   149                 iStatus = KRequestPending;
       
   150                 SetActive();
   141                 TRAP( err, ProcessListInstalledAppsL() );
   151                 TRAP( err, ProcessListInstalledAppsL() );
   142                 status = &iStatus;
   152                 status = &iStatus;
   143                 User::RequestComplete( status, err );
   153                 User::RequestComplete( status, err );
   144                 break;
   154                 break;
   145             default :
   155             default :
   146                 break;
   156                 break;
   147             }
   157             }
   148 
       
   149         SetActive();
       
   150         }
   158         }
   151     TRACE_FUNC_EXIT;
   159     TRACE_FUNC_EXIT;
   152     }
   160     }
   153 
   161 
   154 // -----------------------------------------------------------------------------
   162 // -----------------------------------------------------------------------------
   161     TRACE_FUNC_ENTRY;
   169     TRACE_FUNC_ENTRY;
   162     //If the task is the current task, cancel it first
   170     //If the task is the current task, cancel it first
   163     if( iCurrentTask == aTaskId )
   171     if( iCurrentTask == aTaskId )
   164         {
   172         {
   165         Cancel();
   173         Cancel();
   166         iSWInst.Close();
   174         iSwInstaller.Close();
   167         }
   175         }
   168     TRACE_FUNC_EXIT;
   176     TRACE_FUNC_EXIT;
   169     }
   177     }
   170 
   178 
   171 // -----------------------------------------------------------------------------
   179 // -----------------------------------------------------------------------------
   173 // returns installer activity status
   181 // returns installer activity status
   174 // -----------------------------------------------------------------------------
   182 // -----------------------------------------------------------------------------
   175 //
   183 //
   176 TBool CSConAppInstaller::InstallerActive() const
   184 TBool CSConAppInstaller::InstallerActive() const
   177     {
   185     {
   178     if ( iInstallerState == EIdle )
   186     return IsActive();
   179         {
       
   180         return EFalse;
       
   181         }
       
   182     else
       
   183         {
       
   184         return ETrue;
       
   185         }
       
   186     }
   187     }
   187 
   188 
   188 // -----------------------------------------------------------------------------
   189 // -----------------------------------------------------------------------------
   189 // CSConAppInstaller::DoCancel()
   190 // CSConAppInstaller::DoCancel()
   190 // Implementation of CActive::DoCancel()
   191 // Implementation of CActive::DoCancel()
   192 //
   193 //
   193 void CSConAppInstaller::DoCancel()
   194 void CSConAppInstaller::DoCancel()
   194     {
   195     {
   195     TRACE_FUNC_ENTRY;
   196     TRACE_FUNC_ENTRY;
   196     
   197     
   197     switch (iInstallerState)
   198     LOGGER_WRITE("Cancel iSwInstaller");
   198         {
   199     iSwInstaller.CancelOperation();
   199         case EInstalling:
   200     /*
   200             LOGGER_WRITE("Cancel normal install");
       
   201             iSWInst.CancelAsyncRequest( SwiUI::ERequestInstall );
       
   202             break;
       
   203         case ESilentInstalling:
       
   204             LOGGER_WRITE("Cancel silent install");
       
   205             iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentInstall );
       
   206             break;
       
   207         case EUninstalling:
       
   208             LOGGER_WRITE("Cancel normal uninstall");
       
   209             iSWInst.CancelAsyncRequest( SwiUI::ERequestUninstall );
       
   210             break;
       
   211         case ESilentUninstalling:
       
   212             LOGGER_WRITE("Cancel silent uninstall");
       
   213             iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentUninstall );
       
   214             break;
       
   215         case ECustomUninstalling: 
       
   216             LOGGER_WRITE("Cancel custom uninstall");
       
   217             iSWInst.CancelAsyncRequest( SwiUI::ERequestCustomUninstall );
       
   218             break;
       
   219         case ESilentCustomUnistalling:
       
   220             LOGGER_WRITE("Cancel silent custom uninstall");
       
   221             iSWInst.CancelAsyncRequest( SwiUI::ERequestSilentCustomUninstall );
       
   222             break;
       
   223         default:
       
   224             LOGGER_WRITE("WARNING! Unknown state");
       
   225             break;
       
   226         }
       
   227     iInstallerState = EIdle;
       
   228     
       
   229     // find and complete current task
   201     // find and complete current task
   230     CSConTask* task = NULL;
   202     CSConTask* task = NULL;
   231     TInt ret = iQueue->GetTask( iCurrentTask, task );
   203     TInt ret = iQueue->GetTask( iCurrentTask, task );
   232 
   204 
   233     if ( iCurrentTask > 0 && ret != KErrNotFound )
   205     if ( iCurrentTask > 0 && ret != KErrNotFound )
   243                 break;
   215                 break;
   244             default :
   216             default :
   245                 break;
   217                 break;
   246             }
   218             }
   247         }
   219         }
       
   220         */
   248     TRACE_FUNC_EXIT;
   221     TRACE_FUNC_EXIT;
   249     }
   222     }
   250 
   223 
   251 // -----------------------------------------------------------------------------
   224 // -----------------------------------------------------------------------------
   252 // CSConAppInstaller::RunL()
   225 // CSConAppInstaller::RunL()
   254 // -----------------------------------------------------------------------------
   227 // -----------------------------------------------------------------------------
   255 //
   228 //
   256 void CSConAppInstaller::RunL()
   229 void CSConAppInstaller::RunL()
   257     {
   230     {
   258     TRACE_FUNC_ENTRY;
   231     TRACE_FUNC_ENTRY;
   259     iInstallerState = EIdle;
   232     iSwInstaller.Close();
   260     iSWInst.Close();
       
   261     iQueue->ChangeQueueProcessStatus();
   233     iQueue->ChangeQueueProcessStatus();
   262     TInt err( iStatus.Int() );
   234     TInt err( iStatus.Int() );
   263     LOGGER_WRITE_1( "CSConAppInstaller::RunL() iStatus.Int() : returned %d", err );
   235     LOGGER_WRITE_1( "CSConAppInstaller::RunL() iStatus.Int() : returned %d", err );
   264     
   236     
   265     CSConTask* task = NULL;
   237     CSConTask* task = NULL;
   266     TInt taskErr = iQueue->GetTask( iCurrentTask, task );
   238     TInt taskErr = iQueue->GetTask( iCurrentTask, task );
   267     
   239     if( taskErr == KErrNone )
   268     LOGGER_WRITE_1( "CSConAppInstaller::RunL() GetTask %d", taskErr );
   240         {
       
   241         if ( task->GetServiceId() == EInstall || task->GetServiceId() == EUninstall )
       
   242             {
       
   243             TRAPD(dataErr, WriteTaskDataL( *task ));
       
   244             if (dataErr)
       
   245                 {
       
   246                 LOGGER_WRITE_1("WriteTaskDataL err: %d", dataErr);
       
   247                 }
       
   248             }
   269         
   249         
   270     if( taskErr == KErrNone )
       
   271         {
       
   272         if( task->GetServiceId() == EInstall && err == KErrNone )
   250         if( task->GetServiceId() == EInstall && err == KErrNone )
   273             {
   251             {
   274             LOGGER_WRITE( "CSConAppInstaller::RunL() : before DeleteFile" );
   252             LOGGER_WRITE( "CSConAppInstaller::RunL() : before DeleteFile" );
   275             //delete sis after succesfull install
   253             //delete sis after succesfull install
   276             DeleteFile( task->iInstallParams->iPath );
   254             DeleteFile( task->iInstallParams->iPath );
   279     
   257     
   280     iQueue->CompleteTask( iCurrentTask, err );
   258     iQueue->CompleteTask( iCurrentTask, err );
   281     TRACE_FUNC_EXIT;
   259     TRACE_FUNC_EXIT;
   282     }
   260     }
   283 
   261 
       
   262 // -----------------------------------------------------------------------------
       
   263 // CSConAppInstaller::WriteTaskDataL()
       
   264 // Writes data to task
       
   265 // -----------------------------------------------------------------------------
       
   266 //
       
   267 void CSConAppInstaller::WriteTaskDataL( CSConTask& aTask )
       
   268     {
       
   269     TRACE_FUNC_ENTRY;
       
   270     CBufFlat* buffer = CBufFlat::NewL(200);
       
   271     CleanupStack::PushL(buffer);
       
   272     RBufWriteStream stream( *buffer );
       
   273     CleanupClosePushL( stream );
       
   274     
       
   275     ExternalizeResultArrayIntValL( KSifOutParam_ComponentId , stream);
       
   276     ExternalizeResultIntValL( KSifOutParam_ErrCategory , stream);
       
   277     ExternalizeResultIntValL( KSifOutParam_ErrCode , stream);
       
   278     ExternalizeResultIntValL( KSifOutParam_ExtendedErrCode , stream);
       
   279     ExternalizeResultStringValL( KSifOutParam_ErrMessage , stream);
       
   280     ExternalizeResultStringValL( KSifOutParam_ErrMessageDetails , stream);
       
   281     
       
   282     stream.CommitL();
       
   283     
       
   284     buffer->Compress();
       
   285     
       
   286     HBufC8* data = HBufC8::NewL( buffer->Size() );
       
   287     TPtr8 dataPtr = data->Des();
       
   288     buffer->Read( 0, dataPtr, buffer->Size() );
       
   289     
       
   290     if ( aTask.GetServiceId() == EInstall )
       
   291         {
       
   292         if ( aTask.iInstallParams->iData )
       
   293             {
       
   294             delete aTask.iInstallParams->iData;
       
   295             aTask.iInstallParams->iData = NULL;
       
   296             }
       
   297         aTask.iInstallParams->iData = data;
       
   298         data = NULL;
       
   299         }
       
   300     else if ( aTask.GetServiceId() == EUninstall )
       
   301         {
       
   302         if ( aTask.iUninstallParams->iData )
       
   303             {
       
   304             delete aTask.iUninstallParams->iData;
       
   305             aTask.iUninstallParams->iData = NULL;
       
   306             }
       
   307         aTask.iUninstallParams->iData = data;
       
   308         data = NULL;
       
   309         }
       
   310     else
       
   311         {
       
   312         delete data;
       
   313         data = NULL;
       
   314         }
       
   315     
       
   316     CleanupStack::PopAndDestroy( &stream );
       
   317     CleanupStack::PopAndDestroy( buffer );
       
   318     TRACE_FUNC_EXIT;
       
   319     }
       
   320 
       
   321 void CSConAppInstaller::ExternalizeResultArrayIntValL( const TDesC& aName, RWriteStream& aStream )
       
   322     {
       
   323     TRACE_FUNC_ENTRY;
       
   324     RArray<TInt> valueArray;
       
   325     TRAPD(err, valueArray = iSifResults->IntArrayByNameL(aName));
       
   326     if ( !err && valueArray.Count() > 0 )
       
   327         {
       
   328         LOGGER_WRITE_1("count: %d", valueArray.Count());
       
   329         TBuf8<100> nameBuf;
       
   330         err = CnvUtfConverter::ConvertFromUnicodeToUtf8( nameBuf, aName );
       
   331         if (!err)
       
   332             {
       
   333             LOGGER_WRITE("2");
       
   334             aStream.WriteL( nameBuf, nameBuf.Length() );
       
   335             aStream.WriteL( KValSep, 1 );
       
   336             aStream.WriteInt32L( valueArray[0] );
       
   337             for (TInt i=1; i<valueArray.Count(); i++)
       
   338                 {
       
   339                 aStream.WriteL( KComma, 1 );
       
   340                 aStream.WriteInt32L( valueArray[i] );
       
   341                 }
       
   342             aStream.WriteL( KLineEnd, 2 );
       
   343             }
       
   344         }
       
   345     TRACE_FUNC_EXIT;
       
   346     }
       
   347 // -----------------------------------------------------------------------------
       
   348 // CSConAppInstaller::ExternalizeResultIntValL()
       
   349 // Read integer value and write it to stream
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void CSConAppInstaller::ExternalizeResultIntValL( const TDesC& aName, RWriteStream& aStream )
       
   353     {
       
   354     TRACE_FUNC_ENTRY;
       
   355     TInt value;
       
   356     TBool found(EFalse);
       
   357     found = iSifResults->GetIntByNameL(aName, value);
       
   358 
       
   359     if (found)
       
   360         {
       
   361         TBuf8<100> nameBuf;
       
   362         TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8( nameBuf, aName );
       
   363         if (!err)
       
   364             {
       
   365             aStream.WriteL( nameBuf, nameBuf.Length() );
       
   366             aStream.WriteL( KValSep, 1 );
       
   367             aStream.WriteInt32L( value );
       
   368             aStream.WriteL( KLineEnd, 2 );
       
   369             }
       
   370         }
       
   371     TRACE_FUNC_EXIT;
       
   372     }
       
   373 
       
   374 // -----------------------------------------------------------------------------
       
   375 // CSConAppInstaller::ExternalizeResultStringValL()
       
   376 // Read string value and write it to stream
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 void CSConAppInstaller::ExternalizeResultStringValL( const TDesC& aName, RWriteStream& aStream )
       
   380     {
       
   381     TRACE_FUNC_ENTRY;
       
   382     const TDesC& strValue = iSifResults->StringByNameL( aName );
       
   383     if (strValue.Length() > 0)
       
   384         {
       
   385         TBuf8<100> nameBuf;
       
   386         TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8( nameBuf, aName );
       
   387         if (!err)
       
   388             {
       
   389             HBufC8* nameVal = CnvUtfConverter::ConvertFromUnicodeToUtf8L( strValue );
       
   390             CleanupStack::PushL( nameVal );
       
   391             aStream.WriteL( nameBuf, nameBuf.Length() );
       
   392             aStream.WriteL( KValSep, 1 );
       
   393             aStream.WriteL( nameVal->Des(), nameVal->Length() );
       
   394             aStream.WriteL( KLineEnd, 2 );
       
   395             CleanupStack::PopAndDestroy( nameVal );
       
   396             }
       
   397         }
       
   398     TRACE_FUNC_EXIT;
       
   399     }
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CSConAppInstaller::ProcessInstallL()
       
   403 // Executes Install task
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 void CSConAppInstaller::ProcessInstallL( const CSConInstall& aInstallParams )
       
   407     {
       
   408     TRACE_FUNC_ENTRY;
       
   409     iSifOptions->Cleanup();
       
   410     iSifResults->Cleanup();
       
   411     
       
   412     if ( aInstallParams.iMode == ESilentInstall )
       
   413         {
       
   414         LOGGER_WRITE( "Begin silent installation.. " );
       
   415         
       
   416         iSifOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );
       
   417         iSifOptions->AddIntL( Usif::KSifInParam_PerformOCSP, EFalse );   
       
   418         // Note if upgrade is allowed, see NeedsInstallingL function.
       
   419         iSifOptions->AddIntL( Usif::KSifInParam_AllowUpgrade, ETrue );
       
   420         iSifOptions->AddIntL( Usif::KSifInParam_AllowUntrusted, EFalse );
       
   421         iSifOptions->AddIntL( Usif::KSifInParam_GrantCapabilities, EFalse ); 
       
   422         // Defined for the install.
       
   423         iSifOptions->AddIntL( Usif::KSifInParam_InstallOptionalItems, ETrue );          
       
   424         iSifOptions->AddIntL( Usif::KSifInParam_IgnoreOCSPWarnings, ETrue );            
       
   425         iSifOptions->AddIntL( Usif::KSifInParam_AllowAppShutdown, ETrue );
       
   426         iSifOptions->AddIntL( Usif::KSifInParam_AllowDownload, ETrue );
       
   427         iSifOptions->AddIntL( Usif::KSifInParam_AllowOverwrite, ETrue );
       
   428 
       
   429         iSwInstaller.Install( aInstallParams.iPath, *iSifOptions,
       
   430                 *iSifResults, iStatus, ETrue );
       
   431         }
       
   432     else
       
   433         {
       
   434         LOGGER_WRITE( "Begin to install.. " );
       
   435         
       
   436         iSwInstaller.Install( aInstallParams.iPath, *iSifOptions,
       
   437                 *iSifResults, iStatus, ETrue );
       
   438         }
       
   439     SetActive();
       
   440     TRACE_FUNC_EXIT;
       
   441     }
   284 
   442 
   285 // -----------------------------------------------------------------------------
   443 // -----------------------------------------------------------------------------
   286 // CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
   444 // CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
   287 // Execures UnInstall task
   445 // Executes UnInstall task
   288 // -----------------------------------------------------------------------------
   446 // -----------------------------------------------------------------------------
   289 //
   447 //
   290 void CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
   448 void CSConAppInstaller::ProcessUninstallL( const CSConUninstall& aUninstallParams )
   291     {
   449     {
   292     TRACE_FUNC_ENTRY;
   450     TRACE_FUNC_ENTRY;
   293     LOGGER_WRITE_1( "aUid: 0x%08x", aUninstallParams.iUid.iUid );
   451     LOGGER_WRITE_1( "aUid: 0x%08x", aUninstallParams.iUid.iUid );
   294     LOGGER_WRITE_1( "aName: %S", &aUninstallParams.iName );
   452     LOGGER_WRITE_1( "aName: %S", &aUninstallParams.iName );
   295     LOGGER_WRITE_1( "aVendor: %S", &aUninstallParams.iVendor );
   453     LOGGER_WRITE_1( "aVendor: %S", &aUninstallParams.iVendor );
   296     LOGGER_WRITE_1( "aType: %d", aUninstallParams.iType );
   454     LOGGER_WRITE_1( "aType: %d", aUninstallParams.iType );
   297     LOGGER_WRITE_1( "aMode: %d", aUninstallParams.iMode );
   455     LOGGER_WRITE_1( "aMode: %d", aUninstallParams.iMode );
   298     switch ( aUninstallParams.iType )
   456     
   299 	    {
   457     if ( aUninstallParams.iUid == KSConSeConUid )
   300 	    case ESisApplication:
       
   301 	    case ESisAugmentation:
       
   302 	    	UninstallSisL( aUninstallParams );
       
   303 	    	break;
       
   304 	    case EJavaApplication:
       
   305 	    	UninstallJavaL( aUninstallParams.iUid,
       
   306     			aUninstallParams.iMode);
       
   307 	    	break;
       
   308 	    case EWidgetApplication:
       
   309 	    	UninstallWidget( aUninstallParams.iUid,
       
   310 	    		aUninstallParams.iMode );
       
   311 	    	break;
       
   312 	    default:
       
   313 	    	User::Leave( KErrNotSupported );
       
   314 	    }
       
   315     
       
   316     TRACE_FUNC_EXIT;
       
   317     }
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // CSConAppInstaller::UninstallSisL( const CSConUninstall& aUninstallParams )
       
   321 // Uninstall sis package or augmentation
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CSConAppInstaller::UninstallSisL( const CSConUninstall& aUninstallParams )
       
   325 	{
       
   326 	TRACE_FUNC_ENTRY;
       
   327 
       
   328 	if ( aUninstallParams.iUid == KSConSeConUid )
       
   329 	    {
   458 	    {
   330 	    LOGGER_WRITE("Cannot uninstall itself, leave");
   459 	    LOGGER_WRITE("Cannot uninstall itself, leave");
   331 	    // cannot uninstall itself
   460 	    // cannot uninstall itself
   332 	    User::Leave( SwiUI::KSWInstErrFileInUse );
   461 	    User::Leave( KErrInUse ); //SwiUI::KSWInstErrFileInUse );
   333 	    }
   462 	    }
   334 	
   463     TComponentId componentId = aUninstallParams.iUid.iUid;
   335 	Swi::RSisRegistrySession sisRegistry;
   464     iSifOptions->Cleanup();
   336     User::LeaveIfError( sisRegistry.Connect() );
   465     iSifResults->Cleanup();
   337     CleanupClosePushL( sisRegistry );
   466     
   338     //Check if uid belongs to SIS package
   467     if ( aUninstallParams.iMode == ESilentInstall)
   339     if( !sisRegistry.IsInstalledL( aUninstallParams.iUid ) )
   468         {
   340         {
   469         iSifOptions->AddIntL( Usif::KSifInParam_InstallSilently, ETrue );
   341         CleanupStack::PopAndDestroy( &sisRegistry );
   470         iSwInstaller.Uninstall( componentId, *iSifOptions, *iSifResults, iStatus, ETrue );
   342         User::Leave( KErrNotFound );
       
   343         }
       
   344     
       
   345     Swi::RSisRegistryEntry entry;
       
   346     CleanupClosePushL(entry);
       
   347     User::LeaveIfError( entry.Open( sisRegistry, aUninstallParams.iUid ) );
       
   348     if ( aUninstallParams.iType == ESisAugmentation )
       
   349         {
       
   350         // augmentation pkg
       
   351         LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL ESisAugmentation" );
       
   352         
       
   353         TBool augmentationFound(EFalse);
       
   354         // Get possible augmentations
       
   355         RPointerArray<Swi::CSisRegistryPackage> augPackages;
       
   356         CleanupResetAndDestroyPushL( augPackages );
       
   357         entry.AugmentationsL( augPackages );
       
   358         for ( TInt j( 0 ); j < augPackages.Count() && !augmentationFound; j++ )
       
   359             {
       
   360             Swi::RSisRegistryEntry augmentationEntry;
       
   361             CleanupClosePushL( augmentationEntry );
       
   362             augmentationEntry.OpenL( sisRegistry, *augPackages[j] );
       
   363             
       
   364             HBufC* augPackageName = augmentationEntry.PackageNameL();
       
   365             CleanupStack::PushL( augPackageName );
       
   366             HBufC* augUniqueVendorName = augmentationEntry.UniqueVendorNameL();
       
   367             CleanupStack::PushL( augUniqueVendorName );
       
   368             
       
   369             if ( !augmentationEntry.IsInRomL() 
       
   370                 && augmentationEntry.IsPresentL()
       
   371                 && aUninstallParams.iName.Compare( *augPackageName ) == 0
       
   372                 && aUninstallParams.iVendor.Compare( *augUniqueVendorName ) == 0 )
       
   373                 {
       
   374                 // Correct augmentation found, uninstall it.
       
   375                 augmentationFound = ETrue;
       
   376                 TInt augmentationIndex = augPackages[j]->Index();
       
   377                 LOGGER_WRITE_1( "CSConAppInstaller::ProcessUninstallL augmentationIndex %d", augmentationIndex );
       
   378         
       
   379                 SwiUI::TOpUninstallIndexParam params;
       
   380                 params.iUid = aUninstallParams.iUid;
       
   381                 params.iIndex = augmentationIndex;
       
   382                 SwiUI::TOpUninstallIndexParamPckg pckg( params );
       
   383                 SwiUI::TOperation operation( SwiUI::EOperationUninstallIndex );
       
   384                 if( aUninstallParams.iMode == ESilentInstall )
       
   385                     {
       
   386                     LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : silent aug-sis-uninstall" );
       
   387                     SwiUI::TUninstallOptionsPckg options;
       
   388                     iInstallerState = ESilentCustomUnistalling;
       
   389                     iSWInst.SilentCustomUninstall( iStatus, operation, options, pckg, KSISMIMEType );
       
   390                     }
       
   391                 else
       
   392                     {
       
   393                     LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : unsilent aug-sis-uninstall" )
       
   394                     iInstallerState = ECustomUninstalling;
       
   395                     iSWInst.CustomUninstall( iStatus, operation, pckg, KSISMIMEType );
       
   396                     }
       
   397                 }
       
   398             CleanupStack::PopAndDestroy( augUniqueVendorName );
       
   399             CleanupStack::PopAndDestroy( augPackageName );
       
   400             CleanupStack::PopAndDestroy( &augmentationEntry );
       
   401             }  
       
   402         CleanupStack::PopAndDestroy( &augPackages );
       
   403         
       
   404         if ( !augmentationFound )
       
   405             {
       
   406             LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL augmentation not found -> Leave" );
       
   407             User::Leave( KErrNotFound );
       
   408             }
       
   409         }
   471         }
   410     else
   472     else
   411         {
   473         {
   412         // Only uninstall if not in rom and is present
   474         iSwInstaller.Uninstall( componentId, *iSifOptions, *iSifResults, iStatus, ETrue );
   413         if ( !entry.IsInRomL() && entry.IsPresentL() )
   475         }
   414             { 
   476     SetActive();
   415             if ( aUninstallParams.iMode == ESilentInstall )
   477     TRACE_FUNC_EXIT;
   416                 {
   478     }
   417                 LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : silent sis-uninstall" );
       
   418                 SwiUI::TUninstallOptionsPckg options;
       
   419                 iInstallerState = ESilentUninstalling;
       
   420                 iSWInst.SilentUninstall( iStatus, aUninstallParams.iUid, options, KSISMIMEType );
       
   421                 }
       
   422             else
       
   423                 {
       
   424                 LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL : unsilent sis-uninstall" )
       
   425                 iInstallerState = EUninstalling;
       
   426                 iSWInst.Uninstall( iStatus, aUninstallParams.iUid, KSISMIMEType );
       
   427                 }
       
   428             }
       
   429         else
       
   430             {
       
   431             LOGGER_WRITE( "CSConAppInstaller::ProcessUninstallL sis not present -> Leave" );
       
   432             User::Leave( KErrNotFound );
       
   433             }
       
   434         }
       
   435     
       
   436     CleanupStack::PopAndDestroy( &entry );
       
   437 	CleanupStack::PopAndDestroy( &sisRegistry );
       
   438 	TRACE_FUNC_EXIT;
       
   439 	}
       
   440 
       
   441 // -----------------------------------------------------------------------------
       
   442 // CSConAppInstaller::UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode )
       
   443 // Uninstall java package
       
   444 // -----------------------------------------------------------------------------
       
   445 //
       
   446 void CSConAppInstaller::UninstallJavaL( const TUid& aUid, const TSConInstallMode aMode )
       
   447 	{
       
   448 	TRACE_FUNC_ENTRY;
       
   449 	CJavaRegistry* javaRegistry = CJavaRegistry::NewLC( );
       
   450 	TBool entryExist = javaRegistry->RegistryEntryExistsL( aUid );
       
   451 	CleanupStack::PopAndDestroy( javaRegistry ); 
       
   452 	
       
   453     if( entryExist )
       
   454         {
       
   455         if( aMode == ESilentInstall )
       
   456             {
       
   457             LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL : silent midlet-uninstall" )
       
   458             SwiUI::TUninstallOptionsPckg options;
       
   459             iInstallerState = ESilentUninstalling;
       
   460             iSWInst.SilentUninstall( iStatus, aUid, options, KMidletMIMEType );
       
   461             }
       
   462         else
       
   463             {
       
   464             LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL : unsilent midlet-uninstall" )
       
   465             iInstallerState = EUninstalling;
       
   466             iSWInst.Uninstall( iStatus, aUid, KMidletMIMEType );
       
   467             }
       
   468         }
       
   469     else
       
   470         {
       
   471         LOGGER_WRITE( "CSConAppInstaller::UninstallJavaL java entry does not exist -> Leave" )
       
   472         User::Leave( KErrNotFound );
       
   473         }
       
   474     TRACE_FUNC_EXIT;
       
   475 	}
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CSConAppInstaller::UninstallWidget( const TUid& aUid, const TSConInstallMode aMode )
       
   479 // Uninstall widget
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 void CSConAppInstaller::UninstallWidget( const TUid& aUid, const TSConInstallMode aMode )
       
   483 	{
       
   484 	TRACE_FUNC_ENTRY;
       
   485 	if( aMode == ESilentInstall )
       
   486         {
       
   487         LOGGER_WRITE( "CSConAppInstaller::UninstallWidget : silent uninstall" )
       
   488         SwiUI::TUninstallOptionsPckg options;
       
   489         iInstallerState = ESilentUninstalling;
       
   490         iSWInst.SilentUninstall( iStatus, aUid, options, KWidgetMimeType );
       
   491         }
       
   492     else
       
   493         {
       
   494         LOGGER_WRITE( "CSConAppInstaller::UninstallWidget : unsilent uninstall" )
       
   495         iInstallerState = EUninstalling;
       
   496         iSWInst.Uninstall( iStatus, aUid, KWidgetMimeType );
       
   497         }
       
   498 	TRACE_FUNC_EXIT;
       
   499 	}
       
   500 
       
   501     
   479     
   502 //--------------------------------------------------------------------------------
   480 //--------------------------------------------------------------------------------
   503 //void CSConAppInstaller::ProcessListInstalledAppsL()
   481 //void CSConAppInstaller::ProcessListInstalledAppsL()
   504 //--------------------------------------------------------------------------------
   482 //--------------------------------------------------------------------------------
   505 //
   483 //