ncdengine/provider/client/src/ncdsilentinstalloperationproxy.cpp
changeset 0 ba25891c3a9e
child 18 3ba40be8e484
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:   Implements CNcdSilentInstallOperationProxy
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32strm.h>
       
    20 #include "ncdsilentinstalloperationproxy.h"
       
    21 #include "ncdnodemanagerproxy.h"
       
    22 #include "ncdinstallationservice.h"
       
    23 #include "ncdfileinfo.h"
       
    24 #include "ncdinstallinfo.h"
       
    25 #include "catalogsdebug.h"
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // NewLC
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CNcdSilentInstallOperationProxy* CNcdSilentInstallOperationProxy::NewLC( 
       
    35     MCatalogsClientServer& aSession,
       
    36     TInt aHandle,
       
    37     MNcdOperationProxyRemoveHandler* aRemoveHandler,
       
    38     CNcdNodeProxy* aNode,
       
    39     CNcdNodeManagerProxy* aNodeManager,
       
    40     MNcdInstallOperationObserver* aObserver,
       
    41     MNcdInstallationService& aInstallationService,
       
    42     const SwiUI::TInstallOptions& aInstallOptions )
       
    43     {
       
    44     CNcdSilentInstallOperationProxy* self =
       
    45         new( ELeave ) CNcdSilentInstallOperationProxy( aInstallationService, 
       
    46                                                        aInstallOptions );
       
    47     
       
    48     self->AddRef();
       
    49     CleanupReleasePushL( *self );    
       
    50     self->ConstructL( aSession, aHandle, aRemoveHandler, aNode, aNodeManager,
       
    51         aObserver );
       
    52     return self;
       
    53     }
       
    54 
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // Constructor
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 CNcdSilentInstallOperationProxy::CNcdSilentInstallOperationProxy( 
       
    61     MNcdInstallationService& aInstallationService,
       
    62     const SwiUI::TInstallOptions& aInstallOptions )
       
    63 : CNcdInstallOperationProxy( aInstallationService )
       
    64     {
       
    65     // Copy all the install options into the buffer that will be used
       
    66     // when silent installation is delegated to the installer.
       
    67     iInstallOptionsPackage = aInstallOptions;
       
    68     }
       
    69 
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Destructor
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CNcdSilentInstallOperationProxy::~CNcdSilentInstallOperationProxy()
       
    76     {
       
    77     DLTRACEIN(( "" ));
       
    78     // Cancel must be called here because base class will only call its own
       
    79     // DoCancel()
       
    80     Cancel();
       
    81     DLTRACEOUT(( "" ));    
       
    82     }
       
    83 
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // ConstructL
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CNcdSilentInstallOperationProxy::ConstructL( MCatalogsClientServer& aSession,
       
    90     TInt aHandle,
       
    91     MNcdOperationProxyRemoveHandler* aRemoveHandler,
       
    92     CNcdNodeProxy* aNode,
       
    93     CNcdNodeManagerProxy* aNodeManager,
       
    94     MNcdInstallOperationObserver* aObserver )
       
    95     {
       
    96     DLTRACEIN(( "" ));
       
    97 
       
    98     CNcdInstallOperationProxy::ConstructL( aSession, aHandle, aRemoveHandler, 
       
    99                                            aNode, aNodeManager,
       
   100                                            aObserver );
       
   101         
       
   102     DLTRACEOUT(( "" ));    
       
   103     }
       
   104 
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // From CActive
       
   108 // ?implementation_description
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 
       
   112 void CNcdSilentInstallOperationProxy::DoCancel()
       
   113     {
       
   114     DLTRACEIN((""));
       
   115     
       
   116     // These variables will contain the possible information
       
   117     // about the cancelled installation.
       
   118     HBufC* fileName( NULL );
       
   119     TUid appUid( TUid::Null() );
       
   120     TInt errorCode( KErrCancel );
       
   121 
       
   122     // Because the operation is going on, we have to stop the
       
   123     // silent installation of the installer.
       
   124     Installer().CancelSilentInstall( fileName, appUid, errorCode );
       
   125 
       
   126     // Only update succesfull info to the server.
       
   127     if ( errorCode == KErrNone )
       
   128         {
       
   129         // Cancellation did not have effect and the installation
       
   130         // was success for the current item.
       
   131         // Notice, that UpdateInfoToServerL will also delete the
       
   132         // used install file of the content.
       
   133         if ( fileName != NULL )
       
   134             {
       
   135             TRAP_IGNORE( 
       
   136                 UpdateInfoToServerL( *fileName, 
       
   137                                      appUid, 
       
   138                                      errorCode ) );            
       
   139             }
       
   140         else
       
   141             {
       
   142             TRAP_IGNORE( 
       
   143                 UpdateInfoToServerL( KNullDesC, 
       
   144                                      appUid, 
       
   145                                      errorCode ) );                        
       
   146             }
       
   147         }
       
   148 
       
   149     // No need for the fileName anymore.
       
   150     delete fileName;
       
   151     fileName = NULL;
       
   152 
       
   153     // Notice that if the errorCode is KErrNone, then UpdateInfoToServerL above
       
   154     // deleted the content install file and increased the current file count by one. 
       
   155     // So, we can directly compare CurrentFile() with FileCount() without adding 1 
       
   156     // for the current file index.
       
   157     if ( errorCode == KErrNone && CurrentFile() < FileCount() )
       
   158         {
       
   159         // Error code should be cancel because not all of the files
       
   160         // in the bundle where installed.
       
   161         errorCode = KErrCancel;
       
   162         }
       
   163         
       
   164     TRAP_IGNORE( UpdateOperationInfoToPurchaseHistoryL( errorCode ) );
       
   165     
       
   166     TRAP_IGNORE( NodeManager()->InternalizeRelatedNodesL( *NodeProxy() ) );
       
   167 
       
   168     // By setting the error code here, the parent class may inform the
       
   169     // report manager with the correct value.
       
   170     SetInstallationErrorCode( errorCode );
       
   171 
       
   172     // Let the parent handle other cancellations
       
   173     CNcdInstallOperationProxy::DoCancel();
       
   174     }    
       
   175 
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // Calls the functions of the installer. Child classes may call different functions.
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CNcdSilentInstallOperationProxy::UseInstallServiceL( const CNcdFileInfo& aFile )
       
   182     {
       
   183     DLTRACEIN((""));
       
   184     // Choose correct installation type
       
   185     switch( CurrentInfo().InstallType() )
       
   186         {
       
   187         case CNcdInstallInfo::ENcdInstallNormal:
       
   188             {            
       
   189             Installer().SilentInstallL(
       
   190                 iFileHandle, 
       
   191                 aFile.MimeType(), 
       
   192                 aFile.Purpose(), 
       
   193                 SilentInstallOptionsPackage() );
       
   194             break;
       
   195             }
       
   196         
       
   197         case CNcdInstallInfo::ENcdInstallJar: // flow through
       
   198         case CNcdInstallInfo::ENcdInstallJad:
       
   199             {
       
   200             Installer().SilentInstallJavaL( 
       
   201                 iFileHandle, 
       
   202                 aFile.MimeType(), 
       
   203                 aFile.Data(),
       
   204                 SilentInstallOptionsPackage() );             
       
   205             break;
       
   206             }            
       
   207         
       
   208         
       
   209         default:
       
   210             {
       
   211             // All cases should be handled
       
   212             DASSERT( 0 );
       
   213             break;
       
   214             }
       
   215         }
       
   216     DLTRACEOUT((""));   
       
   217     }
       
   218 
       
   219 
       
   220 const SwiUI::TInstallOptionsPckg& CNcdSilentInstallOperationProxy::SilentInstallOptionsPackage() const
       
   221     {
       
   222     DLTRACEIN((""));
       
   223     return iInstallOptionsPackage;
       
   224     }