os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/reconciliationplugin.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/reconciliationplugin.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,209 @@
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 "reconciliationplugin.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 +
1.27 +// Map the interface implementation UIDs to implementation factory functions
1.28 +const TImplementationProxy ImplementationTable[] =
1.29 + {
1.30 + IMPLEMENTATION_PROXY_ENTRY(0x102836F4, CFeatMgrReconciliationPlugin::NewL),
1.31 + };
1.32 +
1.33 +// Exported proxy for instantiation method resolution.
1.34 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
1.35 + {
1.36 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.37 + return ImplementationTable;
1.38 + }
1.39 +
1.40 +CFeatMgrReconciliationPlugin* CFeatMgrReconciliationPlugin::NewL()
1.41 + {
1.42 + CFeatMgrReconciliationPlugin* self = new(ELeave) CFeatMgrReconciliationPlugin();
1.43 + CleanupStack::PushL(self);
1.44 + self->ConstructL();
1.45 + CleanupStack::Pop(self);
1.46 + return self;
1.47 + }
1.48 +
1.49 +CFeatMgrReconciliationPlugin::~CFeatMgrReconciliationPlugin()
1.50 + {
1.51 + if ( iTimer )
1.52 + {
1.53 + delete iTimer;
1.54 + iTimer = NULL;
1.55 + }
1.56 + }
1.57 +
1.58 +CFeatMgrReconciliationPlugin::CFeatMgrReconciliationPlugin()
1.59 + {
1.60 + }
1.61 +
1.62 +void CFeatMgrReconciliationPlugin::ConstructL()
1.63 + {
1.64 + }
1.65 +
1.66 +void CFeatMgrReconciliationPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId,
1.67 + const TUint8 aTransId,
1.68 + TDesC8& /*aData*/ )
1.69 + {
1.70 + INFO_LOG2( "FeatMgrPlugin: Processing command: 0x%x, TransId: 0x%x",
1.71 + aCommandId, aTransId );
1.72 +
1.73 + switch ( aCommandId )
1.74 + {
1.75 + case FeatureInfoCommand::ELoadFeatureInfoCmdId:
1.76 + {
1.77 + INFO_LOG( "FeatMgrPlugin: Processed ELoadFeatureInfoCmdId" );
1.78 + // Load feature info
1.79 + }
1.80 + break;
1.81 + case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
1.82 + {
1.83 + INFO_LOG( "FeatMgrPlugin: Processed ELoadEnhancedFeatureInfoCmdId" );
1.84 + // Load feature info
1.85 + }
1.86 + break;
1.87 + default :
1.88 + {
1.89 + INFO_LOG1( "FeatMgrPlugin: Unknown Command: 0x%x", aCommandId );
1.90 + User::Leave(KErrNotSupported);
1.91 + }
1.92 + break;
1.93 + }
1.94 +
1.95 + TInt retval(KErrNone);
1.96 + TInt timeout( 50 ); // microseconds
1.97 +
1.98 + // create new timer
1.99 +
1.100 + if ( iTimer && !iTimer->IsActive() )
1.101 + {
1.102 + delete iTimer;
1.103 + iTimer = NULL;
1.104 + }
1.105 +
1.106 + iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this);
1.107 + }
1.108 +
1.109 +void CFeatMgrReconciliationPlugin::GenericTimerFiredL(
1.110 + MFeatureInfoPluginCallback& aService,
1.111 + FeatureInfoCommand::TFeatureInfoCmd aCommandId,
1.112 + TUint8 aTransId,
1.113 + TInt /*aRetVal*/ )
1.114 + {
1.115 + INFO_LOG2( "FeatMgr Plugin: GenericTimerFiredL (0x%x, 0x%x)",
1.116 + aCommandId, aTransId );
1.117 + TInt err( KErrNone );
1.118 +
1.119 + switch ( aCommandId )
1.120 + {
1.121 + case FeatureInfoCommand::ELoadFeatureInfoCmdId:
1.122 + {
1.123 + // Return some features and KErrNone.
1.124 + FeatureInfoCommand::TFeatureInfo featureList;
1.125 + TInt err( KErrNone );
1.126 + RArray<FeatureInfoCommand::TFeature> list;
1.127 + CleanupClosePushL( list );
1.128 + FeatureInfoCommand::TFeature feature1;
1.129 +
1.130 + feature1.iFeatureID = KDefaultSupportedUid.iUid;
1.131 + feature1.iValue = ETrue;
1.132 + list.AppendL(feature1);
1.133 + feature1.iFeatureID = KBlacklistedUid.iUid;
1.134 + feature1.iValue = ETrue;
1.135 + list.AppendL(feature1);
1.136 + feature1.iFeatureID = KModifiableUid.iUid;
1.137 + feature1.iValue = ETrue;
1.138 + list.AppendL(feature1);
1.139 +
1.140 +
1.141 + feature1.iFeatureID = KSupportedUpgradeableUid.iUid;
1.142 + feature1.iValue = ETrue;
1.143 + list.AppendL(feature1);
1.144 +
1.145 + feature1.iFeatureID = KSupportedUpgradeableBlacklistedUid.iUid;
1.146 + feature1.iValue = ETrue;
1.147 + list.AppendL(feature1);
1.148 +
1.149 + feature1.iFeatureID = KSupportedUpgradeableModifiableUid.iUid;
1.150 + feature1.iValue = ETrue;
1.151 + list.AppendL(feature1);
1.152 +
1.153 + feature1.iFeatureID = KSupportedUpgradeableModifiableUninitialisedUid.iUid;
1.154 + feature1.iValue = ETrue;
1.155 + list.AppendL(feature1);
1.156 +
1.157 + feature1.iFeatureID = KSupportedUpgradeableModifiablePersistedUid.iUid;
1.158 + feature1.iValue = ETrue;
1.159 + list.AppendL(feature1);
1.160 +
1.161 + featureList.iErrorCode = KErrNone;
1.162 + featureList.iList = list;
1.163 +
1.164 + FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
1.165 +
1.166 + TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));
1.167 +
1.168 + CleanupStack::PopAndDestroy( &list );
1.169 + break;
1.170 + }
1.171 +
1.172 + case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
1.173 + {
1.174 + // Return some features and KErrNone.
1.175 + FeatureInfoCommand::TEnhancedFeatureInfo featureList;
1.176 + RFeatureArray features;
1.177 + CleanupClosePushL( features );
1.178 + TBitFlags32 flags( 0 );
1.179 + flags.Set( EFeatureSupported );
1.180 + const TInt KDefaultData( 0x00ff00ff );
1.181 + TFeatureEntry entry( TUid::Uid(KNewUid.iUid), flags, KDefaultData );
1.182 + features.AppendL( entry );
1.183 + featureList.iErrorCode = KErrNone;
1.184 + featureList.iList = features;
1.185 +
1.186 + FeatureInfoCommand::TEnhancedFeatureInfoRespPckg resPackage(featureList);
1.187 +
1.188 + TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));
1.189 +
1.190 + CleanupStack::PopAndDestroy( &features );
1.191 + break;
1.192 + }
1.193 +
1.194 + default :
1.195 + break;
1.196 + }
1.197 +
1.198 + // TEST CASES END
1.199 +
1.200 + if ( err != KErrNone )
1.201 + {
1.202 + ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );
1.203 + }
1.204 +
1.205 + if ( iTimer && !iTimer->IsActive() )
1.206 + {
1.207 + delete iTimer;
1.208 + iTimer = NULL;
1.209 + INFO_LOG( "FeatMgr Plugin: GenericTimerFiredL - Removed obsolete timer" );
1.210 + }
1.211 + }
1.212 +