ncdengine/provider/server/src/ncdinstalloperationimpl.cpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdinstalloperationimpl.h"
       
    20 
       
    21 #include <s32mem.h>
       
    22 #include <f32file.h>
       
    23 #include <bautils.h>
       
    24 
       
    25 #include "catalogsbasemessage.h"
       
    26 #include "ncdnodemanager.h"
       
    27 #include "ncdnodeimpl.h"
       
    28 #include "ncdnodeidentifier.h"
       
    29 #include "catalogsutils.h"
       
    30 #include "catalogscontext.h"
       
    31 #include "ncdproviderdefines.h"
       
    32 #include "ncdnodeclassids.h"
       
    33 #include "catalogsconstants.h"
       
    34 #include "ncdinstallinfo.h"
       
    35 #include "ncdfileinfo.h"
       
    36 #include "ncdpurchasehistorydbimpl.h"
       
    37 #include "ncdutils.h"
       
    38 #include "ncderrors.h"
       
    39 #include "ncdoperationremovehandler.h"
       
    40 #include "ncdnodeinstallimpl.h"
       
    41 #include "ncdnodedownloadimpl.h"
       
    42 #include "ncdnodecontentinfoimpl.h"
       
    43 #include "ncdnodemetadataimpl.h"
       
    44 #include "ncdnodelink.h"
       
    45 #include "ncdproviderutils.h"
       
    46 #include "ncdpurchasehistoryutils.h"
       
    47 #include "ncdinstallreportobserver.h"
       
    48 #include "catalogsaccesspointmanager.h"
       
    49 #include "catalogsconnectionmethod.h"
       
    50 #include "catalogshttpconnectionmanager.h"
       
    51 #include "ncdgeneralmanager.h"
       
    52 
       
    53 #include "catalogsdebug.h"
       
    54 
       
    55 // ======== MEMBER FUNCTIONS ========
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // NewL
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CNcdInstallOperation* CNcdInstallOperation::NewL(
       
    62     MNcdOperationRemoveHandler& aRemoveHandler,
       
    63     const CNcdNodeIdentifier& aNodeId,
       
    64     CNcdGeneralManager& aGeneralManager,
       
    65     MCatalogsHttpSession& aHttpSession,
       
    66     MNcdInstallReportObserver& aReportObserver,
       
    67     MCatalogsSession& aSession )
       
    68     {
       
    69     CNcdInstallOperation* self = new( ELeave ) CNcdInstallOperation( 
       
    70         aRemoveHandler,
       
    71         aGeneralManager,
       
    72         aHttpSession,        
       
    73         aReportObserver,
       
    74         aSession );
       
    75     CleanupClosePushL( *self );
       
    76     self->ConstructL( aNodeId );
       
    77 
       
    78     CleanupStack::Pop();
       
    79     return self;
       
    80     }
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Destructor
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CNcdInstallOperation::~CNcdInstallOperation()
       
    88     {
       
    89     DLTRACEIN((""));
       
    90     
       
    91     delete iNodeId;
       
    92     
       
    93     // Deletes the JAD from disk and also deletes iJadFile
       
    94     DeleteJad();
       
    95     DLTRACEOUT((""));
       
    96     }
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // Node Id getter
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 const CNcdNodeIdentifier& CNcdInstallOperation::NodeIdentifier() const
       
   103     {
       
   104     return *iNodeId;
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // Cancel
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 void CNcdInstallOperation::Cancel() 
       
   112     {    
       
   113     DLTRACEIN(( "" ));
       
   114     
       
   115     // Nothing to do here. Most of the install operation
       
   116     // functionality is in proxy side.
       
   117     
       
   118     DLTRACEOUT(( "" ));
       
   119     }
       
   120 
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // Receive message
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CNcdInstallOperation::ReceiveMessage( 
       
   127         MCatalogsBaseMessage* aMessage,
       
   128         TInt aFunctionNumber )
       
   129     {
       
   130     DLTRACEIN((""));
       
   131 
       
   132     DASSERT( aMessage );
       
   133     
       
   134     DLINFO(( "Handle: %i, aFunctionNumber=%d",
       
   135             aMessage->Handle(),
       
   136             aFunctionNumber));
       
   137 
       
   138     // Now, we can be sure that rest of the time iMessage exists.
       
   139     // This member variable is set for the CounterPartLost function.
       
   140     iMessage = aMessage;
       
   141     
       
   142     TRAPD( err, DoReceiveMessageL( aMessage, aFunctionNumber ) ); 
       
   143     
       
   144     if ( err != KErrNone ) 
       
   145         {
       
   146         DLINFO(( ( "Error: %d" ), err ));
       
   147         CompleteMessage( iMessage, 
       
   148             ENCDOperationMessageCompletionError,
       
   149             err );
       
   150         }
       
   151 
       
   152     // Because the message should not be used after this, set it NULL.
       
   153     // So, CounterPartLost function will know that no messages are
       
   154     // waiting the response at the moment.
       
   155     iMessage = NULL;
       
   156 
       
   157     DLTRACEOUT((""));
       
   158     }
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // Counter part lost
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void CNcdInstallOperation::CounterPartLost( const MCatalogsSession& aSession )
       
   166     {
       
   167     DLTRACEIN((""));
       
   168 
       
   169     // This function may be called whenever -- when the message is waiting
       
   170     // response or when the message does not exist.
       
   171     // iMessage may be NULL here, because in the end of the
       
   172     // ReceiveMessage it is set to NULL. The life time of the message
       
   173     // ends shortly after CompleteAndRelease is called.
       
   174     if ( iMessage != NULL )
       
   175         {
       
   176         iMessage->CounterPartLost( aSession );
       
   177         }    
       
   178 
       
   179     DLTRACEOUT((""));    
       
   180     }
       
   181 
       
   182 // ---------------------------------------------------------------------------
       
   183 // RunOperation
       
   184 // ---------------------------------------------------------------------------
       
   185 //
       
   186 TInt CNcdInstallOperation::RunOperation()
       
   187     {
       
   188     DLTRACEIN(( "Pending message: %X", iPendingMessage ));    
       
   189     
       
   190    
       
   191     DLTRACEOUT((""));
       
   192     return KErrNone;
       
   193     }
       
   194 
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // Initializer
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 TInt CNcdInstallOperation::Initialize()
       
   201     {
       
   202     DLTRACEIN( ( "" ) );
       
   203 
       
   204     TRAPD( err,
       
   205         {
       
   206         DLTRACE(("Writing initialize response"));
       
   207         CBufBase* buf = CBufFlat::NewL( KBufExpandSize );
       
   208         CleanupStack::PushL( buf );
       
   209 
       
   210         RBufWriteStream stream( *buf );
       
   211         CleanupClosePushL( stream );
       
   212          
       
   213         // write completion code
       
   214         stream.WriteInt32L( ENCDOperationMessageCompletionInit );        
       
   215 
       
   216         // Get the file count from the node and return it to the proxy
       
   217         // Notice here that the node has to have some kind of metadata
       
   218         // in order the install operation to start.
       
   219         DLINFO(("Get the metadata of the node"));
       
   220         CNcdNode& node( iNodeManager->NodeL( *iNodeId ) );
       
   221         CNcdNodeMetaData& metaData( node.NodeMetaDataL() );
       
   222         DLINFO(("Get the install object of the metadata."));
       
   223         CNcdNodeInstall& install( metaData.InstallL() );        
       
   224         stream.WriteInt32L( install.DownloadedFiles().MdcaCount() );        
       
   225         
       
   226         CleanupStack::PopAndDestroy( &stream );        
       
   227 
       
   228         DLINFO(("Create report"));
       
   229         // Because everything has gone smoothly so far,
       
   230         // create the install report for the server reports.
       
   231         CreateReportL();        
       
   232         
       
   233         DLTRACE(("Response length: %i", buf->Size() ));
       
   234 
       
   235         iPendingMessage->CompleteAndReleaseL( buf->Ptr(0), KErrNone );
       
   236         iPendingMessage = NULL;
       
   237         CleanupStack::PopAndDestroy( buf );
       
   238         });
       
   239     
       
   240     if ( err != KErrNone ) 
       
   241         {
       
   242         DLTRACE( ( "Err: %d", err ) );
       
   243         iPendingMessage->CompleteAndRelease( err );
       
   244         iPendingMessage = NULL;
       
   245         }
       
   246     DLTRACEOUT(( "err: %d", err ));
       
   247     return err;    
       
   248     }
       
   249 
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // Constructor
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 CNcdInstallOperation::CNcdInstallOperation( 
       
   256     MNcdOperationRemoveHandler& aRemoveHandler,    
       
   257     CNcdGeneralManager& aGeneralManager,
       
   258     MCatalogsHttpSession& aHttpSession,    
       
   259     MNcdInstallReportObserver& aReportObserver,
       
   260     MCatalogsSession& aSession ) : 
       
   261     CNcdBaseOperation( aGeneralManager, &aRemoveHandler, EInstallOperation, aSession ),
       
   262     iHttpSession( aHttpSession ),
       
   263     iAccessPointManager( aGeneralManager.AccessPointManager() ),
       
   264     iReportObserver( aReportObserver ),
       
   265     iReportId( KNcdReportNotSupported )
       
   266     {
       
   267     }
       
   268 
       
   269 
       
   270 // ---------------------------------------------------------------------------
       
   271 // ConstructL
       
   272 // ---------------------------------------------------------------------------
       
   273 //
       
   274 void CNcdInstallOperation::ConstructL( const CNcdNodeIdentifier& aNodeId )
       
   275     {
       
   276     DLTRACEIN( ( "" ) );
       
   277     // Call ConstructL for the base class
       
   278     CNcdBaseOperation::ConstructL();
       
   279     
       
   280     // copy the identifier
       
   281     iNodeId = CNcdNodeIdentifier::NewL( aNodeId );
       
   282     
       
   283     iInstallService = &CNcdProviderUtils::InstallationServiceL();
       
   284     DLTRACEOUT(( "" ));
       
   285     }    
       
   286     
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // Gets info for an installable file from the node
       
   290 // ---------------------------------------------------------------------------
       
   291 //        
       
   292 void CNcdInstallOperation::GetFileInfoL( MCatalogsBaseMessage& aMessage )
       
   293     {
       
   294     DLTRACEIN((""));
       
   295     TInt nextFile = ReadFileIndexL( aMessage );
       
   296     
       
   297     CNcdNode& node( iNodeManager->NodeL( *iNodeId ) );
       
   298     // Notice that in order the node to start install, the
       
   299     // node has to have some kind of metadata
       
   300     CNcdNodeMetaData& metaData( node.NodeMetaDataL() );
       
   301     CNcdNodeDownload& nodeDl = metaData.DownloadL();
       
   302     CNcdNodeInstall& install( metaData.InstallL() );
       
   303     
       
   304     // Check that file index is in the valid range
       
   305     if ( nextFile < 0 || nextFile >= install.DownloadedFiles().MdcaCount() ) 
       
   306         {
       
   307         DLERROR(("Invalid index"));
       
   308         User::Leave( KErrArgument );
       
   309         }
       
   310 
       
   311     // Get item purpose        
       
   312     TUint completePurpose = 0;
       
   313     TPtrC contentMime;
       
   314     
       
   315     DeleteJad();
       
   316     
       
   317     TRAPD( error, 
       
   318         {
       
   319         const CNcdNodeContentInfo& contentInfo = 
       
   320             node.NodeMetaData()->ContentInfoL();
       
   321         
       
   322         completePurpose = contentInfo.Purpose();
       
   323         contentMime.Set( contentInfo.MimeType() );
       
   324         DLINFO(( _L("Content mime: %S"), &contentMime ));
       
   325         });
       
   326     
       
   327     LeaveIfNotErrorL( error, KErrNotFound );    
       
   328     
       
   329     // By default, use unknown purpose since installer
       
   330     // uses purpose for installing themes
       
   331     TNcdItemPurpose purpose = ENcdItemPurposeUnknown;
       
   332 
       
   333     // Check if the purpose includes theme or application
       
   334     if ( completePurpose & ENcdItemPurposeTheme ) 
       
   335         {
       
   336         DLTRACE(("Purpose: Theme"));
       
   337         purpose = ENcdItemPurposeTheme;
       
   338         }
       
   339     else if ( completePurpose & ENcdItemPurposeApplication 
       
   340         || completePurpose & ENcdItemPurposeGame 
       
   341         || completePurpose & ENcdItemPurposeScreensaver )
       
   342         {
       
   343         DLTRACE(("Purpose: Application"));
       
   344         purpose = ENcdItemPurposeApplication;
       
   345         }
       
   346     
       
   347     // Used to index downloadInfos.
       
   348     TInt downloadInfoIndex = nextFile;        
       
   349     
       
   350     // This check used to be for handling rights objects that were not really
       
   351     // rights objects, eg. a picture given in the rights uri but now it has
       
   352     // been removed
       
   353     if ( install.DownloadedFiles().MdcaCount() >
       
   354          nodeDl.DownloadInfo().Count() )
       
   355         {
       
   356         DLERROR(("Too many downloaded files, leaving with KErrCorrupt"));
       
   357         User::Leave( KErrCorrupt );
       
   358         }
       
   359     
       
   360     DLTRACE(("File index: %d, downloadInfoIndex: %d", nextFile, downloadInfoIndex ));
       
   361     CNcdFileInfo* fileInfo = NULL;
       
   362 
       
   363     // Use normal install by default
       
   364     CNcdInstallInfo::TNcdInstallType installType = 
       
   365         CNcdInstallInfo::ENcdInstallNormal;
       
   366         
       
   367             
       
   368     // Skip files that have not been downloaded or are already installed
       
   369     // Files that are downloaded are not skipped, doesn't matter 
       
   370     // if they are installed or not
       
   371     while( nextFile < install.DownloadedFiles().MdcaCount() &&
       
   372            ( !install.DownloadedFiles().MdcaPoint( nextFile ).Length() ||
       
   373            // Check if file is missing and is installed, if it's missing
       
   374            // and not installed, we give an error by failing the installation
       
   375            // on proxy side when the file is missing
       
   376             ( !BaflUtils::FileExists( CNcdProviderUtils::FileSession(), 
       
   377                 install.DownloadedFiles().MdcaPoint( nextFile ) ) && (                    
       
   378             install.IsContentInstalledL( nextFile, EFalse ) >= ENcdApplicationInstalled ||
       
   379             // unless the file is launcher application which we can happily skip over
       
   380             IsOneOf( nodeDl.DownloadInfo()[ downloadInfoIndex ]->ContentUsage(),
       
   381                 MNcdPurchaseDownloadInfo::ELauncher,                
       
   382                 MNcdPurchaseDownloadInfo::ELauncherOpen,
       
   383                 MNcdPurchaseDownloadInfo::EConsumable ) ) ) ) )
       
   384         {
       
   385         DLTRACE(("Skipping installed files or not downloaded files"));            
       
   386         nextFile++;    
       
   387         downloadInfoIndex++;
       
   388         }
       
   389    
       
   390     // We may have skipped over the last possible file so we have to 
       
   391     // complete the operation
       
   392     if ( nextFile == install.DownloadedFiles().MdcaCount() ) 
       
   393         {
       
   394         DLERROR(("Either nothing has been downloaded or everything is already installed"));
       
   395         HandleAllFilesInstalledL( nextFile, aMessage );
       
   396         DLTRACEOUT(("Operation complete because all files have been installed"));
       
   397         return;
       
   398         }
       
   399         
       
   400     // Shortcut to correct download info
       
   401     MNcdPurchaseDownloadInfo* downloadInfo( 
       
   402         nodeDl.DownloadInfo()[ downloadInfoIndex ] );       
       
   403 
       
   404     // Set dependency flag that we know not to update dependency/launcher
       
   405     iIsDependency = NcdPurchaseHistoryUtils::IsDependency( *downloadInfo );
       
   406         
       
   407     
       
   408     DLINFO(( _L("Descriptor type: %S"), &downloadInfo->DescriptorType() ));
       
   409     DLINFO(( _L("Descriptor name: %S"), &downloadInfo->DescriptorName() ));
       
   410     DLINFO(( _L("Descriptor URI: %S"), &downloadInfo->DescriptorUri() ));
       
   411                 
       
   412     
       
   413     if ( downloadInfo->ContentMimeType().MatchF( 
       
   414             KMimeTypeMatch1JavaApplication ) != KErrNotFound ||
       
   415          downloadInfo->ContentMimeType().MatchF( 
       
   416             KMimeTypeMatch2JavaApplication ) != KErrNotFound ||
       
   417          contentMime.MatchF( 
       
   418             KMimeTypeMatch1JavaApplication ) != KErrNotFound ||
       
   419          contentMime.MatchF( 
       
   420             KMimeTypeMatch2JavaApplication ) != KErrNotFound )
       
   421 
       
   422         {
       
   423         if ( downloadInfo->DescriptorType().CompareF( 
       
   424             KDescriptorTypeJad ) == 0 )
       
   425             {
       
   426             DLINFO(("Java app with JAD"));
       
   427             purpose = ENcdItemPurposeApplication;
       
   428             installType = CNcdInstallInfo::ENcdInstallJad;                
       
   429             }
       
   430         else 
       
   431             {            
       
   432             DLINFO(("Java-application"));
       
   433             // Ensure that purpose is correct
       
   434             purpose = ENcdItemPurposeApplication;
       
   435             installType = CNcdInstallInfo::ENcdInstallJar;
       
   436             }
       
   437         }
       
   438     else if ( downloadInfo->ContentMimeType().MatchF(
       
   439             KMimeTypeMatchJad ) != KErrNotFound ||
       
   440         contentMime.MatchF( KMimeTypeMatchJad ) != KErrNotFound )
       
   441         {
       
   442         DLINFO(("Java app with JAD"));
       
   443         purpose = ENcdItemPurposeApplication;        
       
   444         installType = CNcdInstallInfo::ENcdInstallJad;                
       
   445         }
       
   446 
       
   447 
       
   448     DLTRACE(("Creating fileinfo"));
       
   449     // Create file info for proxy-side installer
       
   450     fileInfo = CNcdFileInfo::NewLC( 
       
   451         install.DownloadedFiles().MdcaPoint( nextFile ), 
       
   452         nodeDl.DownloadInfo()[ downloadInfoIndex ]->ContentMimeType(), 
       
   453         purpose );
       
   454 
       
   455     if ( installType == CNcdInstallInfo::ENcdInstallJad ) 
       
   456         {
       
   457         DLINFO(( _L("Descriptor type: %S"), &downloadInfo->DescriptorType() ));
       
   458         DLINFO(( _L("Descriptor name: %S"), &downloadInfo->DescriptorName() ));
       
   459         DLINFO(( _L("Descriptor URI: %S"), &downloadInfo->DescriptorUri() ));
       
   460         DLINFO(( "Descriptor Data: %S", &downloadInfo->DescriptorData() ));
       
   461         if ( downloadInfo->DescriptorData().Length() ) 
       
   462             {
       
   463             // This "if" is an ugly fix for embedded DD descriptors where
       
   464             // the .dm file is given in downloaddetails 
       
   465             if ( !(downloadInfo->DescriptorType() == KDescriptorTypeOdd &&
       
   466                 downloadInfo->ContentUri().Length() ) )
       
   467                 {
       
   468                 // Writing JAD to file on this side because proxies can't
       
   469                 // write to engine's private dir
       
   470                 DeletePtr( iJadFile );
       
   471                 iJadFile = 
       
   472                     CNcdProviderUtils::InstallationServiceL().WriteJadL(
       
   473                         fileInfo->FilePath(), downloadInfo->DescriptorData() );
       
   474                 }
       
   475             }
       
   476         else 
       
   477             {
       
   478             DLINFO(("No descriptor for JAD install"));                        
       
   479             }
       
   480         // Ensure that mime is JAD
       
   481         fileInfo->SetMimeTypeL( KMimeTypeMatchJad );
       
   482         }
       
   483     
       
   484         
       
   485     CNcdInstallInfo* info = CNcdInstallInfo::NewL( fileInfo,
       
   486         installType );
       
   487     CleanupStack::Pop( fileInfo );
       
   488     CleanupStack::PushL( info );
       
   489     info->SetIndex( nextFile );    
       
   490         
       
   491     MCatalogsBaseMessage* message = &aMessage;
       
   492     // Send the info back
       
   493     TInt err = CompleteMessage( 
       
   494         message, 
       
   495         ENCDOperationMessageCompletionComplete,
       
   496         *info, 
       
   497         KErrNone );
       
   498     
       
   499     CleanupStack::PopAndDestroy( info );
       
   500     DLTRACEOUT(("err: %d", err));
       
   501     }
       
   502 
       
   503 
       
   504 // ---------------------------------------------------------------------------
       
   505 // Completes the message correctly when all files have already been installed
       
   506 // ---------------------------------------------------------------------------
       
   507 //        
       
   508 void CNcdInstallOperation::HandleAllFilesInstalledL( 
       
   509     TInt aFinalIndex, MCatalogsBaseMessage& aMessage )
       
   510     {
       
   511     DLTRACEIN((""));
       
   512     CNcdInstallInfo* info = CNcdInstallInfo::NewL( NULL,
       
   513         CNcdInstallInfo::ENcdInstallNormal );            
       
   514     CleanupStack::PushL( info );
       
   515     info->SetIndex( aFinalIndex );    
       
   516         
       
   517     MCatalogsBaseMessage* message = &aMessage;
       
   518     // Send the info back
       
   519     TInt err = CompleteMessage( 
       
   520         message, 
       
   521         ENCDOperationMessageCompletionComplete,
       
   522         *info, 
       
   523         KErrNone );
       
   524     CleanupStack::PopAndDestroy( info );
       
   525     DLTRACEOUT(("Err: %d", err));
       
   526     }
       
   527 
       
   528 
       
   529 // ---------------------------------------------------------------------------
       
   530 // Updates the info of an installed file
       
   531 // ---------------------------------------------------------------------------
       
   532 //        
       
   533 void CNcdInstallOperation::UpdateInstalledFileInfoL( 
       
   534     MCatalogsBaseMessage& aMessage )
       
   535     {
       
   536     DLTRACEIN((""));
       
   537     
       
   538     RCatalogsMessageReader reader;
       
   539     reader.OpenLC( aMessage );
       
   540         
       
   541     // Read input message
       
   542     DLTRACE(("Reading file index"));
       
   543     TInt index = reader().ReadInt32L();
       
   544 
       
   545     // Read the info from the stream
       
   546     CNcdFileInfo* info = CNcdFileInfo::NewLC( reader() );
       
   547     
       
   548     // Read uids of installed applications
       
   549     TInt appUids = reader().ReadInt32L();
       
   550     DLTRACE(( "Reading app uids: %d", appUids ));
       
   551     RArray<TUid> uids;
       
   552     CleanupClosePushL( uids );
       
   553     uids.ReserveL( appUids );
       
   554     while( appUids ) 
       
   555         {
       
   556         uids.AppendL( TUid::Uid( reader().ReadInt32L() ) );
       
   557         DLINFO(("Read UID: %x", uids[uids.Count() - 1] ));
       
   558         --appUids;
       
   559         }
       
   560     
       
   561     
       
   562     // Installed dependencies/upgrades are not updated to purchase history
       
   563     if ( !iIsDependency ) 
       
   564         {        
       
   565         //update purchase history with the info         
       
   566         UpdatePurchaseHistoryL( *info, uids, 
       
   567             aMessage.Session().Context().FamilyId() );
       
   568         }
       
   569         
       
   570     CleanupStack::PopAndDestroy( 3, &reader );   // uids, info, reader
       
   571     
       
   572     DLTRACE(("Updating node from purchase history"));
       
   573     // Update node from the purchase history
       
   574     iNodeManager->InstallHandlerL( *iNodeId );
       
   575         
       
   576     DLTRACE(("Completing message"));
       
   577     MCatalogsBaseMessage* message = &aMessage;
       
   578     TInt err = CompleteMessage( 
       
   579         message, 
       
   580         ENCDOperationMessageCompletionComplete,
       
   581         KErrNone );
       
   582     
       
   583     DLTRACEOUT((""));
       
   584     }
       
   585 
       
   586 
       
   587 void CNcdInstallOperation::CreateReportL()
       
   588     {
       
   589     DLTRACEIN((""));  
       
   590     CNcdNode& node( iNodeManager->NodeL( *iNodeId ) ); 
       
   591     CNcdNodeMetaData& metaData( node.NodeMetaDataL() );
       
   592     
       
   593     TNcdReportStatusInfo info( ENcdReportCreate, KErrNone );
       
   594     // Use the node identifier to identify the content in install report.
       
   595     // Node id uniquely identifies the node that contains contents
       
   596     // that will be installed. One node may contains multiple contents but
       
   597     // they are all thought as one bundle, in one operation. Also, notice that 
       
   598     // multiple nodes can contain same metadata and same content.
       
   599 
       
   600     /**
       
   601      * @ Get timestamp and purchase option id from purchase details and
       
   602      * set them to the report
       
   603      */
       
   604     iReportId = 
       
   605         iReportObserver.RegisterInstallL( 
       
   606             iNodeId->NodeId(),
       
   607             metaData.Identifier(),
       
   608             info,
       
   609             metaData.Identifier().ServerUri(),
       
   610             metaData.Identifier().NodeNameSpace() );
       
   611 
       
   612     // Access point is set when report is started.
       
   613     // Then base message is used to get required info.
       
   614     }
       
   615 
       
   616 
       
   617 void CNcdInstallOperation::StartReportL( MCatalogsBaseMessage& aMessage )
       
   618     {
       
   619     DLTRACEIN((""));
       
   620     // Set access point for report.
       
   621     UpdateReportAccessPointL( aMessage.Session().Context().FamilyId() );    
       
   622 
       
   623     TNcdReportStatusInfo info( ENcdReportStart, KErrNone );
       
   624     iReportObserver.ReportInstallStatusL(
       
   625             iReportId,
       
   626             info );
       
   627 
       
   628     // If this leaves, ReceiveMessge will complete the message.
       
   629     aMessage.CompleteAndRelease( KErrNone );
       
   630     }
       
   631     
       
   632     
       
   633 void CNcdInstallOperation::CompleteReportL( MCatalogsBaseMessage& aMessage )
       
   634     {
       
   635     DLTRACEIN((""));
       
   636     RCatalogsMessageReader reader;
       
   637     reader.OpenLC( aMessage );
       
   638     
       
   639     RReadStream& stream( reader() );
       
   640     TInt errorCode( stream.ReadInt32L() );
       
   641         
       
   642     CleanupStack::PopAndDestroy( &reader );        
       
   643 
       
   644     TNcdReportStatus status( ENcdReportSuccess );
       
   645     if ( errorCode == KErrNone )
       
   646         {
       
   647         status = ENcdReportSuccess;
       
   648         }
       
   649     else if ( errorCode == KErrCancel )
       
   650         {
       
   651         status = ENcdReportCancel;
       
   652         }
       
   653     else 
       
   654         {
       
   655         status = ENcdReportFail;
       
   656         }
       
   657     
       
   658     // Create the status info object with the given info.
       
   659     TNcdReportStatusInfo info( status, errorCode );
       
   660     
       
   661     iReportObserver.ReportInstallStatusL(
       
   662             iReportId,
       
   663             info );
       
   664 
       
   665     // If this leaves, ReceiveMessge will complete the message.
       
   666     aMessage.CompleteAndRelease( KErrNone );
       
   667     }
       
   668 
       
   669 
       
   670 // ---------------------------------------------------------------------------
       
   671 // UpdateReportAccessPointL
       
   672 // ---------------------------------------------------------------------------
       
   673 //
       
   674 void CNcdInstallOperation::UpdateReportAccessPointL( const TUid& aClientUid )
       
   675     {
       
   676     DLTRACEIN((""));
       
   677 
       
   678     CNcdPurchaseHistoryDb& db = iNodeManager->PurchaseHistory();    
       
   679     CNcdNode& node( iNodeManager->NodeL( *iNodeId ) ); 
       
   680     CNcdNodeMetaData& metadata( node.NodeMetaDataL() );
       
   681     
       
   682     CNcdPurchaseDetails* purchase = 
       
   683         NcdPurchaseHistoryUtils::PurchaseDetailsLC(
       
   684             db,
       
   685             aClientUid,
       
   686             metadata.Identifier(),
       
   687             EFalse );
       
   688                 
       
   689     // Create origin identifier
       
   690     CNcdNodeIdentifier* originIdentifier = 
       
   691         CNcdNodeIdentifier::NewL(
       
   692             node.Identifier().NodeNameSpace(), 
       
   693             purchase->OriginNodeId(), 
       
   694             node.Identifier().ClientUid() );
       
   695 
       
   696     CleanupStack::PopAndDestroy( purchase );
       
   697     
       
   698     CleanupStack::PushL( originIdentifier );
       
   699     
       
   700     // Get report ap    
       
   701     TUint32 apId( 0 );
       
   702 
       
   703     TInt error = 
       
   704         iAccessPointManager.AccessPointIdL(
       
   705             *originIdentifier, 
       
   706             MCatalogsAccessPointManager::EBrowse, 
       
   707             aClientUid, 
       
   708             apId );
       
   709         
       
   710     TCatalogsConnectionMethod reportAp;
       
   711     if ( error == KErrNone ) 
       
   712         {
       
   713         DLTRACE(( "Setting access point %d for reports", apId ))   
       
   714         reportAp = 
       
   715             TCatalogsConnectionMethod( 
       
   716                 apId, 
       
   717                 ECatalogsConnectionMethodTypeAccessPoint );
       
   718         }
       
   719     
       
   720     if ( reportAp.iId == 0 ) 
       
   721         {
       
   722         reportAp = iHttpSession.ConnectionManager().DefaultConnectionMethod();
       
   723         }
       
   724 
       
   725     CleanupStack::PopAndDestroy( originIdentifier );
       
   726 
       
   727     iReportObserver.SetInstallReportAccessPoint( 
       
   728         iReportId,
       
   729         reportAp );
       
   730     }
       
   731 
       
   732 
       
   733 // ---------------------------------------------------------------------------
       
   734 // Updates purchase history
       
   735 // ---------------------------------------------------------------------------
       
   736 //        
       
   737 void CNcdInstallOperation::UpdatePurchaseHistoryL( const CNcdFileInfo& aInfo,
       
   738     const RArray<TUid>& aAppUids, const TUid& aClientUid )
       
   739     {
       
   740     DLTRACEIN((""));
       
   741     
       
   742     CNcdPurchaseHistoryDb& db = iNodeManager->PurchaseHistory();    
       
   743     CNcdNode& node( iNodeManager->NodeL( *iNodeId ) ); 
       
   744     CNcdNodeMetaData& metadata( node.NodeMetaDataL() );
       
   745     
       
   746     CNcdPurchaseDetails* purchase = NcdPurchaseHistoryUtils::PurchaseDetailsLC(
       
   747         db,
       
   748         aClientUid,
       
   749         metadata.Identifier(),
       
   750         EFalse );
       
   751                 
       
   752     
       
   753     CNcdPurchaseInstallInfo* installInfo = CNcdPurchaseInstallInfo::NewLC();    
       
   754        
       
   755     const CNcdNodeContentInfo* contentInfo = NULL;                
       
   756     TRAPD( err, contentInfo = &metadata.ContentInfoL() );            
       
   757 
       
   758     LeaveIfNotErrorL( err, KErrNotFound );
       
   759     
       
   760     if ( aAppUids.Count() ) 
       
   761         {
       
   762         DLTRACE(("Updating installed application info"));
       
   763         // Use application UID from the protocol if it exists
       
   764         if ( contentInfo && contentInfo->Uid() != TUid::Null() ) 
       
   765             {
       
   766             DLINFO(( "Using UID from Content info: %x", 
       
   767                 contentInfo->Uid().iUid ));
       
   768             installInfo->SetApplicationUid( contentInfo->Uid() );
       
   769             }
       
   770         else
       
   771             {                
       
   772             DLINFO(( "Using UID from installer: %x", aAppUids[0].iUid ));
       
   773             installInfo->SetApplicationUid( aAppUids[0] );
       
   774             }
       
   775         
       
   776         // Theme version number's are not updated from sis registry
       
   777         if ( aInfo.Purpose() != ENcdItemPurposeTheme &&
       
   778              aInfo.FilePath().Length() ) 
       
   779             {
       
   780             DLTRACE(( _L("Got version number from sis registry: %S"), 
       
   781                 &aInfo.FilePath() ));
       
   782                 
       
   783             installInfo->SetApplicationVersionL(
       
   784                 aInfo.FilePath() );
       
   785             }
       
   786         else if ( contentInfo ) 
       
   787             {        
       
   788             DLTRACE(("Content info exists"));        
       
   789             // Use application version from the protocol
       
   790             DLINFO(( _L("Setting app version: %S"), 
       
   791                 &contentInfo->Version() ));
       
   792             installInfo->SetApplicationVersionL( 
       
   793                 contentInfo->Version() );
       
   794             }
       
   795             
       
   796         }
       
   797     else if ( aInfo.Purpose() == ENcdItemPurposeTheme )
       
   798         {
       
   799         DLTRACE(("Updating installed theme info"));
       
   800         installInfo->SetThemeNameL( aInfo.FilePath() );
       
   801         }
       
   802     else
       
   803         {
       
   804         DLTRACE(("Updating installed content info"));
       
   805         DLINFO(( _L("Installed file: %S"), &aInfo.FilePath() ));
       
   806         
       
   807         // Save the filename 
       
   808         installInfo->SetFilenameL( aInfo.FilePath() );
       
   809         }
       
   810     
       
   811     // update purpose to purchase history
       
   812     
       
   813     // if purpose in content info was unknown, we use the one gotten from installer
       
   814     // since it may have been updated to something more specific
       
   815     if ( contentInfo && contentInfo->Purpose() != ENcdItemPurposeUnknown )     
       
   816         {        
       
   817         TUint newPurpose = contentInfo->Purpose();
       
   818         if ( aInfo.Purpose() == ENcdItemPurposeApplication ) 
       
   819             {
       
   820             // This ensures that games etc. stuff that were installed like 
       
   821             // applications, are also handled like applications 
       
   822             newPurpose |= ENcdItemPurposeApplication;
       
   823             }
       
   824         DLTRACE(("Setting purpose as %d", newPurpose));
       
   825         purchase->SetItemPurpose( newPurpose );
       
   826         }
       
   827     else
       
   828         {        
       
   829         // backup in case we didn't get content info for some reason
       
   830         DLINFO(("Didn't get ContentInfo, updating purpose from FileInfo"));
       
   831         purchase->SetItemPurpose( purchase->ItemPurpose() | aInfo.Purpose() );
       
   832         }
       
   833     
       
   834     DLINFO(("Item purpose: %d", purchase->ItemPurpose() ));
       
   835     // Add install info to purchase details. Ownership is transferred
       
   836     
       
   837     if ( ReplaceInstallInfoL( *purchase, *installInfo ) )
       
   838         {
       
   839         CleanupStack::PopAndDestroy( installInfo );
       
   840         }
       
   841     else 
       
   842         {
       
   843         DLTRACE(("Adding install info to purchase details"));    
       
   844         purchase->AddInstallInfoL( installInfo );        
       
   845         CleanupStack::Pop( installInfo );
       
   846         }
       
   847 
       
   848     DLTRACE(("Saving purchase details"));                
       
   849     db.SavePurchaseL( *purchase, EFalse );    
       
   850     CleanupStack::PopAndDestroy( purchase );
       
   851     
       
   852     DLTRACEOUT((""));
       
   853     }
       
   854 
       
   855 
       
   856 // ---------------------------------------------------------------------------
       
   857 // Checks if the details already contain a matching info
       
   858 // ---------------------------------------------------------------------------
       
   859 //        
       
   860 TBool CNcdInstallOperation::ReplaceInstallInfoL( 
       
   861     MNcdPurchaseDetails& aDetails, 
       
   862     const MNcdPurchaseInstallInfo& aInfo )
       
   863     {
       
   864     DLTRACEIN((""));
       
   865     TArray< MNcdPurchaseInstallInfo* > installInfos( 
       
   866         aDetails.InstallInfoL() );
       
   867         
       
   868     TParsePtrC path( aInfo.Filename() );
       
   869     TPtrC installedFile( path.NameAndExt() );
       
   870     DLTRACE(("Going through %d install infos", installInfos.Count() ));
       
   871     for ( TInt i = 0; i < installInfos.Count(); ++i )
       
   872         {
       
   873         MNcdPurchaseInstallInfo& oldInfo( *installInfos[ i ] );
       
   874         
       
   875         if ( ( oldInfo.ApplicationUid() == aInfo.ApplicationUid() &&
       
   876                oldInfo.ApplicationVersion() == aInfo.ApplicationVersion() &&
       
   877                oldInfo.ThemeName() == aInfo.ThemeName() ) ||
       
   878                // also replace empty infos, hopefully this doesn't break anything
       
   879                // because this is needed in order to correctly handle cancelled
       
   880                // theme installations or more spefically successful theme installations
       
   881                // after a cancelled theme installation
       
   882              ( oldInfo.ApplicationUid() == KNullUid && 
       
   883                oldInfo.ApplicationVersion() == KNullDesC &&
       
   884                // replace the old info if theme name is empty or if the old theme name
       
   885                // is not empty but the new info is entirely empty == reinstalling a theme
       
   886                ( oldInfo.ThemeName() == KNullDesC || 
       
   887                 ( aInfo.ApplicationUid() == KNullUid &&
       
   888                   aInfo.ApplicationVersion() == KNullDesC &&
       
   889                   aInfo.ThemeName() == KNullDesC ) ) ) )
       
   890              
       
   891             {
       
   892             // Parse the filename from the file path
       
   893             TParsePtrC oldPath( oldInfo.Filename() );
       
   894             if ( oldPath.NameAndExt() == installedFile ) 
       
   895                 {                
       
   896                 DLTRACEOUT(("Info already exists"));
       
   897                 
       
   898                 // Update the filename in case the file has been installed
       
   899                 // to a different drive than before
       
   900                 CNcdPurchaseInstallInfo* modInfo = 
       
   901                     static_cast<CNcdPurchaseInstallInfo*>( installInfos[i] );
       
   902                 
       
   903                 // This updates the theme name in the following case:
       
   904                 // 1. theme was already installed when bought and installed with the client
       
   905                 // 2. user uninstalled the theme
       
   906                 // 3. user downloaded and installed the theme again
       
   907                 if ( oldInfo.ThemeName() == KNullDesC ) 
       
   908                     {
       
   909                     modInfo->SetThemeNameL( aInfo.ThemeName() );
       
   910                     }
       
   911                 modInfo->SetFilenameL( aInfo.Filename() );
       
   912                 return ETrue;
       
   913                 }
       
   914             }                    
       
   915         }
       
   916     
       
   917     // This tries to update an existing java app uid when we are reinstalling
       
   918     // java apps    
       
   919     TArray< MNcdPurchaseDownloadInfo* > downloadInfos(
       
   920         aDetails.DownloadInfoL() );        
       
   921         
       
   922     if ( installInfos.Count() &&
       
   923          aInfo.ApplicationUid() != KNullUid && 
       
   924          downloadInfos.Count() >= installInfos.Count() )        
       
   925         {   
       
   926         TBool isJava = EFalse;
       
   927         for ( TInt i = 0; i < downloadInfos.Count(); ++i )
       
   928             {
       
   929             if ( IsJava( downloadInfos[i]->ContentMimeType(), ETrue ) )
       
   930                 {
       
   931                 isJava = ETrue;
       
   932                 break;
       
   933                 }
       
   934             }
       
   935         
       
   936         if ( !isJava ) 
       
   937             {
       
   938             DLTRACEOUT(("No java app"));
       
   939             return EFalse;
       
   940             }
       
   941             
       
   942         DLTRACE(("Update the uid of the first existing app"));
       
   943         for ( TInt i = 0; i < installInfos.Count(); ++i ) 
       
   944             {
       
   945             MNcdPurchaseInstallInfo& oldInfo( *installInfos[ i ] );
       
   946             if ( oldInfo.ApplicationUid() != KNullUid ) 
       
   947                 {
       
   948                 DLTRACE(("Updating application uid from %x to %x",
       
   949                     oldInfo.ApplicationUid(), aInfo.ApplicationUid() ));
       
   950                 // Update the app uid for java app                
       
   951                 CNcdPurchaseInstallInfo* modInfo = 
       
   952                     static_cast<CNcdPurchaseInstallInfo*>( installInfos[i] );
       
   953                 
       
   954                 modInfo->SetApplicationUid( aInfo.ApplicationUid() );
       
   955                 modInfo->SetApplicationVersionL( aInfo.ApplicationVersion() );
       
   956                 return ETrue;
       
   957                 }                
       
   958             }
       
   959         }
       
   960         
       
   961     return EFalse;
       
   962     }
       
   963 
       
   964 
       
   965 // ---------------------------------------------------------------------------
       
   966 // Checks if the given mime type matches a java app
       
   967 // ---------------------------------------------------------------------------
       
   968 //        
       
   969 TBool CNcdInstallOperation::IsJava( 
       
   970     const TDesC& aMimeType, 
       
   971     TBool aAcceptJad ) const
       
   972     {
       
   973     DLTRACEIN(( _L("aMimeType: %S"), &aMimeType ));
       
   974     
       
   975     TBool matches = aMimeType.MatchF( KMimeTypeMatch1JavaApplication ) != KErrNotFound ||
       
   976                   aMimeType.MatchF( KMimeTypeMatch2JavaApplication ) != KErrNotFound;
       
   977 
       
   978     if ( !matches && aAcceptJad ) 
       
   979         {
       
   980         matches = aMimeType.MatchF( KMimeTypeMatchJad ) != KErrNotFound;
       
   981         }
       
   982     DLTRACEOUT(("Matched: %d", matches));
       
   983     return matches;    
       
   984     }
       
   985 
       
   986 
       
   987 // ---------------------------------------------------------------------------
       
   988 // Gets the path to the file indexed by the message
       
   989 // ---------------------------------------------------------------------------
       
   990 //        
       
   991 HBufC* CNcdInstallOperation::FilePathLC( 
       
   992     MCatalogsBaseMessage& aMessage )
       
   993     {
       
   994     DLTRACEIN((""));
       
   995     TInt fileIndex = ReadFileIndexL( aMessage );
       
   996     
       
   997     CNcdNode& node( iNodeManager->NodeL( *iNodeId ) );
       
   998     // Notice that in order the node to start install, the
       
   999     // node has to have some kind of metadata
       
  1000     CNcdNodeMetaData& metaData( node.NodeMetaDataL() );    
       
  1001     CNcdNodeInstall& install( metaData.InstallL() );
       
  1002     
       
  1003     // Check that file index is in the valid range
       
  1004     if ( fileIndex < 0 || fileIndex >= install.DownloadedFiles().MdcaCount() ) 
       
  1005         {
       
  1006         DLERROR(("Invalid index: %d", fileIndex ));
       
  1007         User::Leave( KErrArgument );
       
  1008         }
       
  1009                     
       
  1010     DLTRACEOUT(( _L("Filepath %S from index: %d"), 
       
  1011         &install.DownloadedFiles().MdcaPoint( fileIndex ), fileIndex ));
       
  1012 
       
  1013     return install.DownloadedFiles().MdcaPoint( fileIndex ).AllocLC();
       
  1014     }
       
  1015 
       
  1016 
       
  1017 // ---------------------------------------------------------------------------
       
  1018 // Opens a file
       
  1019 // ---------------------------------------------------------------------------
       
  1020 //  
       
  1021 void CNcdInstallOperation::OpenFileL( 
       
  1022     MCatalogsBaseMessage& aMessage )
       
  1023     {
       
  1024     DLTRACEIN((""));
       
  1025     RFs fs;
       
  1026     User::LeaveIfError( fs.Connect() );
       
  1027     CleanupClosePushL( fs );
       
  1028     
       
  1029     DLTRACE(("Sharing the file server"));
       
  1030     User::LeaveIfError( fs.ShareProtected() );
       
  1031     
       
  1032     DLTRACE(("Trying to open the file"));
       
  1033     RFile file;
       
  1034     CleanupClosePushL( file );
       
  1035     
       
  1036     // Ugly hackfix for handling JADs
       
  1037     if ( iJadFile ) 
       
  1038         {
       
  1039         User::LeaveIfError( file.Open( fs, 
       
  1040             *iJadFile,
       
  1041             NcdProviderDefines::KNcdSharableFileOpenFlags ) );                        
       
  1042         }
       
  1043     else
       
  1044         {
       
  1045         HBufC* path = FilePathLC( aMessage ); 
       
  1046         User::LeaveIfError( file.Open( fs, 
       
  1047             *path,
       
  1048             NcdProviderDefines::KNcdSharableFileOpenFlags ) );                
       
  1049         CleanupStack::PopAndDestroy( path );
       
  1050         }
       
  1051     DLTRACE(("File open, transferring to client"));
       
  1052     
       
  1053     aMessage.CompleteAndReleaseL( fs, file );
       
  1054     
       
  1055     DLTRACE(("File transferred"));
       
  1056     CleanupStack::PopAndDestroy( 2, &fs ); // file, fs    
       
  1057     }
       
  1058 
       
  1059 
       
  1060 // ---------------------------------------------------------------------------
       
  1061 // Does the actual message handling
       
  1062 // ---------------------------------------------------------------------------
       
  1063 //        
       
  1064 void CNcdInstallOperation::DoReceiveMessageL( 
       
  1065         MCatalogsBaseMessage* aMessage,
       
  1066         TInt aFunctionNumber )
       
  1067     {
       
  1068     DLTRACEIN((""));
       
  1069     switch ( aFunctionNumber )
       
  1070         {
       
  1071         case ENCDOperationFunctionGetData:
       
  1072             {
       
  1073             GetFileInfoL( *aMessage );
       
  1074             break;
       
  1075             }
       
  1076             
       
  1077         case ENCDOperationFunctionSetData:
       
  1078             {
       
  1079             UpdateInstalledFileInfoL( *aMessage );
       
  1080             break;
       
  1081             }
       
  1082 
       
  1083         case ENcdOperationFunctionOpenFile:
       
  1084             {
       
  1085             OpenFileL( *aMessage );
       
  1086             break;
       
  1087             }
       
  1088 
       
  1089         case ENcdOperationFunctionDeleteFile:
       
  1090             {
       
  1091             DeleteFileL( *aMessage );
       
  1092             break;
       
  1093             }
       
  1094 
       
  1095         case ENCDOperationFunctionReportStart:
       
  1096             {
       
  1097             StartReportL( *aMessage );
       
  1098             break;
       
  1099             }
       
  1100 
       
  1101         case ENCDOperationFunctionReportComplete:
       
  1102             {
       
  1103             CompleteReportL( *aMessage );
       
  1104             break;
       
  1105             }
       
  1106 
       
  1107         default:
       
  1108             {
       
  1109             DLTRACE(("Calling baseclass"));
       
  1110             // Call implementation in the base class
       
  1111             CNcdBaseOperation::ReceiveMessage( aMessage, aFunctionNumber );            
       
  1112             break;
       
  1113             }            
       
  1114         } 
       
  1115     DLTRACEOUT((""));
       
  1116     }
       
  1117 
       
  1118 
       
  1119 // ---------------------------------------------------------------------------
       
  1120 // Deletes a file index by the message. Also JAD is deleted if necessary
       
  1121 // ---------------------------------------------------------------------------
       
  1122 //        
       
  1123 void CNcdInstallOperation::DeleteFileL( MCatalogsBaseMessage& aMessage )
       
  1124     {
       
  1125     DLTRACEIN((""));
       
  1126     HBufC* path = FilePathLC( aMessage );
       
  1127     // Delete installed SIS/JAR/content file
       
  1128     User::LeaveIfError( iInstallService->DeleteFile( *path ) );      
       
  1129     
       
  1130     CleanupStack::PopAndDestroy( path );
       
  1131     // If we installed JAD+JAR we must delete JAD separately.
       
  1132     DeleteJad();
       
  1133     
       
  1134     aMessage.CompleteAndReleaseL( KErrNone, KErrNone );    
       
  1135     }
       
  1136 
       
  1137 
       
  1138 // ---------------------------------------------------------------------------
       
  1139 // Reads a file index from the message
       
  1140 // ---------------------------------------------------------------------------
       
  1141 //        
       
  1142 TInt CNcdInstallOperation::ReadFileIndexL( MCatalogsBaseMessage& aMessage )
       
  1143     {
       
  1144     RCatalogsMessageReader reader;
       
  1145     reader.OpenLC( aMessage );
       
  1146     
       
  1147     // Read the requested file index
       
  1148     TInt fileIndex = reader().ReadInt32L();
       
  1149     CleanupStack::PopAndDestroy( &reader );
       
  1150     return fileIndex;
       
  1151     }
       
  1152 
       
  1153 
       
  1154 // ---------------------------------------------------------------------------
       
  1155 // Deletes JAD from disk and the filename
       
  1156 // ---------------------------------------------------------------------------
       
  1157 //        
       
  1158 void CNcdInstallOperation::DeleteJad()
       
  1159     {
       
  1160     DLTRACEIN((""));
       
  1161     
       
  1162     if ( iJadFile && iInstallService ) 
       
  1163         {        
       
  1164         // Error is ignored because we can't handle disk errors in 
       
  1165         // any special way and other errors will make themselves known
       
  1166         // anyway
       
  1167         iInstallService->DeleteFile( *iJadFile );              
       
  1168         }
       
  1169     
       
  1170     DeletePtr( iJadFile );
       
  1171     }