homescreenpluginsrv/hspsmanager/src/hspsinstaller.cpp
changeset 0 79c6a41cd166
child 27 2c7f27287390
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 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 "hsps_builds_cfg.hrh"
       
    20 
       
    21 #include <e32base.h>
       
    22 #include "hspsinstaller.h"
       
    23 #include "hspsthemeserver.h"
       
    24 #include "hspsinstallationhandler.h"
       
    25 #include "hspsthememanagement.h"
       
    26 
       
    27 // ========================= MEMBER FUNCTIONS ==================================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CHSPSInstaller::NewL()
       
    31 // Two-phased constructor.
       
    32 // -----------------------------------------------------------------------------
       
    33 CHSPSInstaller* CHSPSInstaller::NewL(
       
    34     ChspsThemeServer& aServer )
       
    35     {
       
    36     CHSPSInstaller* self = new ( ELeave ) CHSPSInstaller( aServer );
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CHSPSInstaller::ConstructL()
       
    45 // Symbian 2nd phase constructor can leave.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 void CHSPSInstaller::ConstructL()
       
    49     {
       
    50     iInstallationHandler = ChspsInstallationHandler::NewL( iServer );
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CHSPSInstaller::CHSPSInstaller()
       
    55 // C++ default constructor can NOT contain any code, that might leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 CHSPSInstaller::CHSPSInstaller( 
       
    58     ChspsThemeServer& aServer ): 
       
    59     CActive(EPriorityStandard), 
       
    60     iServer( aServer ) 
       
    61     {
       
    62     CActiveScheduler::Add( this );
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CHSPSInstaller::~CHSPSInstaller()
       
    67 // Destructor.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 CHSPSInstaller::~CHSPSInstaller()
       
    71     {            
       
    72     Cancel(); // Causes call to DoCancel()    
       
    73     delete iLoop;
       
    74     delete iInstallationHandler;
       
    75     }
       
    76 
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CHSPSInstaller::InstallConfigurationL
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 ThspsServiceCompletedMessage CHSPSInstaller::InstallConfigurationL( 
       
    83     const TDesC& aFileName )
       
    84     {            	
       
    85     // Start installation by reading the manifest file
       
    86     iRet = iInstallationHandler->hspsInstallTheme( aFileName, iHeaderData );    
       
    87     if ( iRet == EhspsInstallThemeSuccess && !IsActive() )
       
    88         {                
       
    89         // Continue with remaining installation phases
       
    90         SetActive();
       
    91         iInstallationHandler->hspsInstallNextPhaseL( iHeaderData, iStatus );        
       
    92         
       
    93         // Wait until the installation phases have been executed (async->sync) 
       
    94         iLoop = new ( ELeave )CActiveSchedulerWait();
       
    95         iLoop->Start();
       
    96         
       
    97         }
       
    98     
       
    99     return iRet;
       
   100     }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CHSPSInstaller::RunError
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TInt CHSPSInstaller::RunError( TInt /*aError*/ )
       
   107     {
       
   108     // Called when error occurred in asynchronous request
       
   109     iLoop->AsyncStop();    
       
   110     return KErrNone;
       
   111     }  
       
   112   
       
   113 // -----------------------------------------------------------------------------
       
   114 // CHSPSInstaller::RunL
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CHSPSInstaller::RunL()
       
   118     {
       
   119     iRet = (ThspsServiceCompletedMessage)iStatus.Int();
       
   120     switch ( iStatus.Int() )
       
   121         {                     
       
   122         case EhspsInstallPhaseSuccess:
       
   123         	{
       
   124         	// Execute next phase of the installation
       
   125             if ( !IsActive() )
       
   126                 {                
       
   127                 SetActive();
       
   128                 iInstallationHandler->hspsInstallNextPhaseL( iHeaderData, iStatus  );
       
   129                 }
       
   130         	}
       
   131         	break;
       
   132         	
       
   133         case EhspsInstallThemeSuccess:
       
   134         case EhspsInstallThemeFailed:                        
       
   135         default:
       
   136             {
       
   137             // Allow continuation of the InstallTheme function
       
   138             iLoop->AsyncStop();            
       
   139             }
       
   140         	break;
       
   141         }
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CHSPSInstaller::DoCancel()
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 void CHSPSInstaller::DoCancel()
       
   149     {
       
   150     // Cancels any outstanding operation - nothing to do  
       
   151     }
       
   152         
       
   153 // End of File