os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/slowstartplugin.cpp
First public contribution.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "slowstartplugin.h"
19 #include <featmgr/featureinfoplugin.h>
20 #include "featmgrdebug.h"
21 #include "efm_test_consts.h"
22 #include <ecom/implementationproxy.h>
23 #include "featmgrconfiguration.h"
26 // Map the interface implementation UIDs to implementation factory functions
27 const TImplementationProxy ImplementationTable[] =
29 IMPLEMENTATION_PROXY_ENTRY(0x102836FC, CFeatMgrSlowStartPlugin::NewL),
32 // Exported proxy for instantiation method resolution.
33 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
35 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
36 return ImplementationTable;
39 CFeatMgrSlowStartPlugin* CFeatMgrSlowStartPlugin::NewL()
41 CFeatMgrSlowStartPlugin* self = new(ELeave) CFeatMgrSlowStartPlugin();
42 CleanupStack::PushL(self);
44 CleanupStack::Pop(self);
48 CFeatMgrSlowStartPlugin::~CFeatMgrSlowStartPlugin()
52 CFeatMgrSlowStartPlugin::CFeatMgrSlowStartPlugin()
56 void CFeatMgrSlowStartPlugin::ConstructL()
60 void CFeatMgrSlowStartPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId,
61 const TUint8 aTransId,
64 INFO_LOG2( "FeatMgr SlowStart Plugin: Processing command: 0x%x, TransId: 0x%x",
65 aCommandId, aTransId );
67 // Slow things down with a 1/2 second delay.
72 case FeatureInfoCommand::ELoadFeatureInfoCmdId:
74 INFO_LOG( "FeatMgr SlowStart Plugin: Processed ELoadFeatureInfoCmdId" );
78 case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
80 INFO_LOG( "FeatMgr SlowStart Plugin: extended command interface not supported");
81 User::Leave(KErrNotSupported);
85 INFO_LOG1( "FeatMgr SlowStart Plugin: Unknown Command: 0x%x", aCommandId );
86 User::Leave(KErrNotSupported);
91 TInt retval(KErrNone);
92 TInt timeout( 0.5*KDefaultFeatMgrTimer ); // We don't actually want to timeout, but add an extra delay.
95 if ( iTimer && !iTimer->IsActive() )
101 iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this);
105 void CFeatMgrSlowStartPlugin::GenericTimerFiredL(
106 MFeatureInfoPluginCallback& aService,
107 FeatureInfoCommand::TFeatureInfoCmd aCommandId,
111 CFeatMgrBasePlugin::GenericTimerFiredL(aService,aCommandId,aTransId,aRetVal);
112 INFO_LOG2( "FeatMgr SlowStart Plugin: GenericTimerFiredL (0x%x, 0x%x)",
113 aCommandId, aTransId );
115 TInt err( KErrNone );
117 // Delay things a little.
120 switch ( aCommandId )
122 case FeatureInfoCommand::ELoadFeatureInfoCmdId:
124 // Return some features and KErrNone.
125 FeatureInfoCommand::TFeatureInfo featureList;
126 TInt err( KErrNone );
127 RArray<FeatureInfoCommand::TFeature> list;
128 CleanupClosePushL( list );
129 FeatureInfoCommand::TFeature feature1;
131 feature1.iFeatureID = KSlowStartPluginUid.iUid;
132 feature1.iValue = ETrue;
133 list.AppendL(feature1);
135 featureList.iErrorCode = KErrNone;
136 featureList.iList = list;
138 FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
140 TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));
142 CleanupStack::PopAndDestroy( &list );
152 if ( err != KErrNone )
154 ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );