os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/reconciliationplugin.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 
    18 #include "reconciliationplugin.h"
    19 #include <featmgr/featureinfoplugin.h>
    20 #include "featmgrdebug.h"
    21 #include "efm_test_consts.h"     
    22 #include <ecom/implementationproxy.h>
    23 
    24 // Map the interface implementation UIDs to implementation factory functions
    25 const TImplementationProxy ImplementationTable[] =
    26     {
    27     IMPLEMENTATION_PROXY_ENTRY(0x102836F4,	CFeatMgrReconciliationPlugin::NewL),
    28     };
    29 
    30 // Exported proxy for instantiation method resolution.
    31 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
    32     {
    33     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
    34     return ImplementationTable;
    35     }
    36 
    37 CFeatMgrReconciliationPlugin* CFeatMgrReconciliationPlugin::NewL()
    38     {
    39     CFeatMgrReconciliationPlugin* self = new(ELeave) CFeatMgrReconciliationPlugin();
    40     CleanupStack::PushL(self);
    41     self->ConstructL();
    42     CleanupStack::Pop(self);
    43     return self;
    44     }
    45 
    46 CFeatMgrReconciliationPlugin::~CFeatMgrReconciliationPlugin()
    47     {
    48     if ( iTimer )
    49         {
    50         delete iTimer;
    51         iTimer = NULL;
    52         }
    53     }
    54 
    55 CFeatMgrReconciliationPlugin::CFeatMgrReconciliationPlugin()
    56     {
    57     }
    58 
    59 void CFeatMgrReconciliationPlugin::ConstructL()
    60     {
    61     }    
    62 
    63 void CFeatMgrReconciliationPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId,
    64         const TUint8 aTransId,
    65         TDesC8& /*aData*/ )
    66 	{
    67 	INFO_LOG2( "FeatMgrPlugin: Processing command: 0x%x, TransId: 0x%x", 
    68 	aCommandId, aTransId );
    69 	
    70 	switch ( aCommandId )
    71 	{
    72 	case FeatureInfoCommand::ELoadFeatureInfoCmdId:
    73 		{
    74 		INFO_LOG( "FeatMgrPlugin: Processed ELoadFeatureInfoCmdId" );
    75 		// Load feature info
    76 		}
    77 		break;
    78 	case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
    79 		{
    80 		INFO_LOG( "FeatMgrPlugin: Processed ELoadEnhancedFeatureInfoCmdId" );
    81 		// Load feature info
    82 		}
    83 		break;
    84 	default :
    85 		{
    86 		INFO_LOG1( "FeatMgrPlugin: Unknown Command: 0x%x", aCommandId );
    87 		User::Leave(KErrNotSupported);
    88 		}
    89 		break;
    90 	}
    91 	
    92 	TInt retval(KErrNone);
    93 	TInt timeout( 50 ); // microseconds
    94 	
    95 	// create new timer
    96 	
    97 	if ( iTimer && !iTimer->IsActive() )
    98 		{
    99 		delete iTimer;
   100 		iTimer = NULL;
   101 		}
   102 	
   103 	iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this);
   104 	}
   105 
   106 void CFeatMgrReconciliationPlugin::GenericTimerFiredL(
   107     MFeatureInfoPluginCallback& aService,
   108     FeatureInfoCommand::TFeatureInfoCmd aCommandId,
   109     TUint8 aTransId,
   110     TInt /*aRetVal*/ )
   111     {
   112     INFO_LOG2( "FeatMgr Plugin: GenericTimerFiredL (0x%x, 0x%x)", 
   113                          aCommandId, aTransId );
   114     TInt err( KErrNone );
   115     
   116         switch ( aCommandId )
   117         {
   118         case FeatureInfoCommand::ELoadFeatureInfoCmdId:
   119             {
   120             // Return some features and KErrNone.
   121             FeatureInfoCommand::TFeatureInfo featureList;
   122             TInt err( KErrNone );
   123             RArray<FeatureInfoCommand::TFeature> list;
   124             CleanupClosePushL( list );
   125             FeatureInfoCommand::TFeature feature1; 
   126 
   127             feature1.iFeatureID = KDefaultSupportedUid.iUid;
   128             feature1.iValue = ETrue;
   129             list.AppendL(feature1);
   130             feature1.iFeatureID = KBlacklistedUid.iUid;
   131             feature1.iValue = ETrue;
   132             list.AppendL(feature1);
   133 			feature1.iFeatureID = KModifiableUid.iUid;
   134             feature1.iValue = ETrue;
   135             list.AppendL(feature1);
   136 
   137             
   138             feature1.iFeatureID = KSupportedUpgradeableUid.iUid;
   139             feature1.iValue = ETrue;
   140             list.AppendL(feature1);
   141 
   142             feature1.iFeatureID = KSupportedUpgradeableBlacklistedUid.iUid;
   143             feature1.iValue = ETrue;
   144             list.AppendL(feature1);
   145 
   146             feature1.iFeatureID = KSupportedUpgradeableModifiableUid.iUid;
   147             feature1.iValue = ETrue;
   148             list.AppendL(feature1);
   149 
   150             feature1.iFeatureID = KSupportedUpgradeableModifiableUninitialisedUid.iUid;
   151             feature1.iValue = ETrue;
   152             list.AppendL(feature1);
   153             
   154             feature1.iFeatureID = KSupportedUpgradeableModifiablePersistedUid.iUid;
   155             feature1.iValue = ETrue;
   156             list.AppendL(feature1);
   157             
   158             featureList.iErrorCode = KErrNone;
   159             featureList.iList = list;
   160                 
   161             FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
   162             
   163             TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));    
   164             
   165             CleanupStack::PopAndDestroy( &list );
   166             break;
   167             }
   168             
   169         case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
   170             {
   171             // Return some features and KErrNone.
   172             FeatureInfoCommand::TEnhancedFeatureInfo featureList;
   173             RFeatureArray features; 
   174             CleanupClosePushL( features );
   175             TBitFlags32 flags( 0 );
   176             flags.Set( EFeatureSupported );
   177             const TInt KDefaultData( 0x00ff00ff );        
   178             TFeatureEntry entry( TUid::Uid(KNewUid.iUid), flags, KDefaultData );
   179             features.AppendL( entry );
   180             featureList.iErrorCode = KErrNone;
   181             featureList.iList = features;
   182                 
   183             FeatureInfoCommand::TEnhancedFeatureInfoRespPckg resPackage(featureList);
   184             
   185             TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));    
   186             
   187             CleanupStack::PopAndDestroy( &features );
   188             break;
   189             }
   190             
   191         default :
   192             break;
   193         }
   194     
   195     // TEST CASES END
   196  
   197     if ( err != KErrNone )
   198         {
   199         ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );
   200         }
   201     
   202     if ( iTimer && !iTimer->IsActive() )
   203         {
   204         delete iTimer;
   205         iTimer = NULL;            
   206         INFO_LOG( "FeatMgr Plugin: GenericTimerFiredL - Removed obsolete timer" );
   207         }
   208     }
   209