os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/slowstartplugin.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/slowstartplugin.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,157 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +#include "slowstartplugin.h"
    1.22 +#include <featmgr/featureinfoplugin.h>
    1.23 +#include "featmgrdebug.h"
    1.24 +#include "efm_test_consts.h"     
    1.25 +#include <ecom/implementationproxy.h>
    1.26 +#include "featmgrconfiguration.h"
    1.27 +
    1.28 +
    1.29 +// Map the interface implementation UIDs to implementation factory functions
    1.30 +const TImplementationProxy ImplementationTable[] =
    1.31 +    {
    1.32 +    IMPLEMENTATION_PROXY_ENTRY(0x102836FC,	CFeatMgrSlowStartPlugin::NewL),
    1.33 +    };
    1.34 +
    1.35 +// Exported proxy for instantiation method resolution.
    1.36 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
    1.37 +    {
    1.38 +    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
    1.39 +    return ImplementationTable;
    1.40 +    }
    1.41 +
    1.42 +CFeatMgrSlowStartPlugin* CFeatMgrSlowStartPlugin::NewL()
    1.43 +    {
    1.44 +    CFeatMgrSlowStartPlugin* self = new(ELeave) CFeatMgrSlowStartPlugin();
    1.45 +    CleanupStack::PushL(self);
    1.46 +    self->ConstructL();
    1.47 +    CleanupStack::Pop(self);
    1.48 +    return self;
    1.49 +    }
    1.50 +
    1.51 +CFeatMgrSlowStartPlugin::~CFeatMgrSlowStartPlugin()
    1.52 +    {
    1.53 +    }
    1.54 +
    1.55 +CFeatMgrSlowStartPlugin::CFeatMgrSlowStartPlugin()
    1.56 +    {
    1.57 +    }
    1.58 +
    1.59 +void CFeatMgrSlowStartPlugin::ConstructL()
    1.60 +    {
    1.61 +    }
    1.62 +
    1.63 +void CFeatMgrSlowStartPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId,
    1.64 +                                      const TUint8 aTransId,
    1.65 +                                      TDesC8& /*aData*/ )
    1.66 +    {
    1.67 +    INFO_LOG2( "FeatMgr SlowStart Plugin: Processing command: 0x%x, TransId: 0x%x", 
    1.68 +                         aCommandId, aTransId );
    1.69 +
    1.70 +    // Slow things down with a 1/2 second delay.
    1.71 +    User::After(200000);
    1.72 +           
    1.73 +    switch ( aCommandId )
    1.74 +        {
    1.75 +        case FeatureInfoCommand::ELoadFeatureInfoCmdId:
    1.76 +            {
    1.77 +            INFO_LOG( "FeatMgr SlowStart Plugin: Processed ELoadFeatureInfoCmdId" );
    1.78 +            // Load feature info
    1.79 +            }
    1.80 +            break;
    1.81 +        case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
    1.82 +            {
    1.83 +			INFO_LOG( "FeatMgr SlowStart Plugin: extended command interface not supported");
    1.84 +			User::Leave(KErrNotSupported);
    1.85 +            }
    1.86 +        default :
    1.87 +            {
    1.88 +            INFO_LOG1( "FeatMgr SlowStart Plugin: Unknown Command: 0x%x", aCommandId );
    1.89 +            User::Leave(KErrNotSupported);
    1.90 +            }
    1.91 +            break;
    1.92 +        }
    1.93 +        
    1.94 +    TInt retval(KErrNone);
    1.95 +    TInt timeout( 0.5*KDefaultFeatMgrTimer ); // We don't actually want to timeout, but add an extra delay.
    1.96 +
    1.97 +    // create new timer
    1.98 +    if ( iTimer && !iTimer->IsActive() )
    1.99 +        {
   1.100 +        delete iTimer;
   1.101 +        iTimer = NULL;
   1.102 +        }
   1.103 +        
   1.104 +    iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this);
   1.105 +    }
   1.106 +
   1.107 +
   1.108 +void CFeatMgrSlowStartPlugin::GenericTimerFiredL(
   1.109 +	    MFeatureInfoPluginCallback& aService,
   1.110 +	    FeatureInfoCommand::TFeatureInfoCmd aCommandId,
   1.111 +	    TUint8 aTransId,
   1.112 +	    TInt aRetVal )
   1.113 +	    {
   1.114 +	    CFeatMgrBasePlugin::GenericTimerFiredL(aService,aCommandId,aTransId,aRetVal);
   1.115 +	    INFO_LOG2( "FeatMgr SlowStart Plugin: GenericTimerFiredL (0x%x, 0x%x)", 
   1.116 +	                         aCommandId, aTransId );
   1.117 +	    
   1.118 +	    TInt err( KErrNone );
   1.119 +	    
   1.120 +	    // Delay things a little.
   1.121 +	    User::After(600000);
   1.122 +
   1.123 +	    switch ( aCommandId )
   1.124 +	        {
   1.125 +	        case FeatureInfoCommand::ELoadFeatureInfoCmdId:
   1.126 +	            {
   1.127 +	            // Return some features and KErrNone.
   1.128 +	            FeatureInfoCommand::TFeatureInfo featureList;
   1.129 +	            TInt err( KErrNone );
   1.130 +	            RArray<FeatureInfoCommand::TFeature> list;
   1.131 +	            CleanupClosePushL( list );
   1.132 +	            FeatureInfoCommand::TFeature feature1; 
   1.133 +
   1.134 +	            feature1.iFeatureID = KSlowStartPluginUid.iUid;
   1.135 +	            feature1.iValue = ETrue;
   1.136 +	            list.AppendL(feature1);
   1.137 +	            
   1.138 +	            featureList.iErrorCode = KErrNone;
   1.139 +	            featureList.iList = list;
   1.140 +	                
   1.141 +	            FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
   1.142 +	            
   1.143 +	            TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));    
   1.144 +	            
   1.145 +	            CleanupStack::PopAndDestroy( &list );
   1.146 +	            break;
   1.147 +	            }
   1.148 +	            
   1.149 +	        default :
   1.150 +	            break;
   1.151 +	        }
   1.152 +	    
   1.153 +	    // TEST CASES END
   1.154 +	 
   1.155 +	    if ( err != KErrNone )
   1.156 +	        {
   1.157 +	        ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );
   1.158 +	        }	    
   1.159 +	    }
   1.160 +