homescreensrv_plat/sapi_homescreenplugin/tsrc/common/src/mt_hspsinstallationservice.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2004 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 
       
    20 #include <e32svr.h>
       
    21 #include <flogger.h>
       
    22 #include <f32file.h>
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <bacline.h>
       
    26 #include <bautils.h>
       
    27 
       
    28 #include <hspsthememanagement.h>
       
    29 #include <hspsodt.h>
       
    30 #include <hspsclient.h>
       
    31 #include <hspsresult.h>
       
    32 
       
    33 #include "mt_hspsinstallationservice.h"
       
    34  
       
    35 // -----------------------------------------------------------------------------
       
    36 // CThemeInstaller::NewL()
       
    37 // 
       
    38 // 
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C MT_CHspsInstallationService* MT_CHspsInstallationService::NewL()
       
    42     {    
       
    43     MT_CHspsInstallationService* self = new ( ELeave ) MT_CHspsInstallationService;
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL( );
       
    46     CleanupStack::Pop( self );
       
    47     return( self );    
       
    48     }
       
    49 
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CThemeInstaller::ConstructL()
       
    53 // 
       
    54 // 
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void MT_CHspsInstallationService::ConstructL()
       
    58     {
       
    59     iResult = ChspsResult::NewL();
       
    60   	iHspsClient = ChspsClient::NewL( *this );
       
    61   	iHeader = NULL;  
       
    62     iLoop = new ( ELeave )CActiveSchedulerWait(); 
       
    63     }
       
    64    
       
    65 // -----------------------------------------------------------------------------
       
    66 // CThemeInstaller::~CThemeInstaller()
       
    67 // 
       
    68 // 
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 MT_CHspsInstallationService:: ~MT_CHspsInstallationService()
       
    72     {    
       
    73     delete iHspsClient;
       
    74     delete iResult;
       
    75     delete iHeader;
       
    76     delete iLoop;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Constructor.
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 MT_CHspsInstallationService::MT_CHspsInstallationService()
       
    84     {
       
    85     }     
       
    86 // -----------------------------------------------------------------------------
       
    87 // Gets program arguments and starts the installer
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 
       
    91 void MT_CHspsInstallationService::InstallConfigurationL(
       
    92     const TDesC& aManifestFileName )
       
    93     {    
       
    94     // Init
       
    95     RFs fs;           
       
    96     User::LeaveIfError( fs.Connect() );
       
    97     CleanupClosePushL( fs );
       
    98 
       
    99     // Check if the file exists
       
   100     BaflUtils baf;
       
   101     if( baf.FileExists( fs, aManifestFileName ) )
       
   102         {
       
   103         InstallThemeL( aManifestFileName );
       
   104         iLoop->Start();
       
   105         }
       
   106     else
       
   107         {
       
   108         User::Leave( KErrNotFound );
       
   109         }
       
   110     CleanupStack::PopAndDestroy( 1, &fs ); // directoryList, args, Fs   
       
   111     }
       
   112     
       
   113 // -----------------------------------------------------------------------------
       
   114 // Initiates installing of a confgiruation from the provided manifest file
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void MT_CHspsInstallationService::InstallThemeL( 
       
   118     const TDesC& aManifestFileName )
       
   119     {      	
       
   120     
       
   121 	if ( iHeader )
       
   122 		{
       
   123 		delete iHeader;
       
   124 		iHeader = NULL;
       
   125 		}			
       
   126 	iHeader = ChspsODT::NewL();
       
   127     
       
   128 	TParse p;
       
   129     p.Set( aManifestFileName, NULL, NULL );
       
   130     TPtrC ptr = p.NameAndExt();
       
   131     
       
   132 	ThspsServiceCompletedMessage ret = iHspsClient->hspsInstallTheme( aManifestFileName, *iHeader );
       
   133 	
       
   134 	switch ( ret )
       
   135 	    {
       
   136 	    case EhspsInstallThemeSuccess:
       
   137 	        // Installation completed - Update status
       
   138 	        iHspsClient->GethspsResult( *iResult );
       
   139 	        break;
       
   140 	    case EhspsInstallPhaseSuccess:
       
   141 	        // Continue installation
       
   142 	        iHspsClient->hspsInstallNextPhaseL( *iHeader );
       
   143 	        break;
       
   144 	    default:
       
   145 	        // Installation failed
       
   146 	        User::Leave( KErrGeneral );
       
   147 	        break;
       
   148 	    }
       
   149     } 
       
   150 
       
   151 void MT_CHspsInstallationService::UninstallConfigurationL(
       
   152     TInt aAppUid,
       
   153     TInt aConfUid )
       
   154     {
       
   155     ChspsODT* odt = ChspsODT::NewL();
       
   156     CleanupStack::PushL( odt );
       
   157     odt->SetRootUid( aAppUid );
       
   158     odt->SetThemeUid( aConfUid );
       
   159     odt->SetProviderUid( 270513751 );
       
   160     
       
   161     ThspsServiceCompletedMessage ret = iHspsClient->hspsRemoveThemeL( *odt );
       
   162     
       
   163     CleanupStack::PopAndDestroy( odt );
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // MT_CHspsInstallationService::HandlehspsClientMessage()
       
   168 // 
       
   169 // Handles events received from themeserver via hspsClient
       
   170 // -----------------------------------------------------------------------------
       
   171 
       
   172 void MT_CHspsInstallationService::HandlehspsClientMessage(
       
   173     ThspsServiceCompletedMessage aEvent )
       
   174 	{
       
   175     TInt errorCode = KErrNone;
       
   176 	
       
   177 	TBuf<KMaxHeaderDataLength8> tmp;
       
   178 	iHspsClient->GethspsResult(*iResult);
       
   179 
       
   180 	switch( aEvent )
       
   181 	    {
       
   182         case EhspsInstallThemeFailed:
       
   183             // Flow through
       
   184 	    case EhspsInstallThemeSuccess:
       
   185 	        // Installation completed
       
   186 	        iLoop->AsyncStop();
       
   187 	        break;
       
   188 	    default:
       
   189 	        // No operation - Continue installation
       
   190 	        break;
       
   191 	    }	
       
   192 	}
       
   193 
       
   194 // End of File