os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/slowstartplugin.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 "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"
    24 
    25 
    26 // Map the interface implementation UIDs to implementation factory functions
    27 const TImplementationProxy ImplementationTable[] =
    28     {
    29     IMPLEMENTATION_PROXY_ENTRY(0x102836FC,	CFeatMgrSlowStartPlugin::NewL),
    30     };
    31 
    32 // Exported proxy for instantiation method resolution.
    33 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
    34     {
    35     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
    36     return ImplementationTable;
    37     }
    38 
    39 CFeatMgrSlowStartPlugin* CFeatMgrSlowStartPlugin::NewL()
    40     {
    41     CFeatMgrSlowStartPlugin* self = new(ELeave) CFeatMgrSlowStartPlugin();
    42     CleanupStack::PushL(self);
    43     self->ConstructL();
    44     CleanupStack::Pop(self);
    45     return self;
    46     }
    47 
    48 CFeatMgrSlowStartPlugin::~CFeatMgrSlowStartPlugin()
    49     {
    50     }
    51 
    52 CFeatMgrSlowStartPlugin::CFeatMgrSlowStartPlugin()
    53     {
    54     }
    55 
    56 void CFeatMgrSlowStartPlugin::ConstructL()
    57     {
    58     }
    59 
    60 void CFeatMgrSlowStartPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId,
    61                                       const TUint8 aTransId,
    62                                       TDesC8& /*aData*/ )
    63     {
    64     INFO_LOG2( "FeatMgr SlowStart Plugin: Processing command: 0x%x, TransId: 0x%x", 
    65                          aCommandId, aTransId );
    66 
    67     // Slow things down with a 1/2 second delay.
    68     User::After(200000);
    69            
    70     switch ( aCommandId )
    71         {
    72         case FeatureInfoCommand::ELoadFeatureInfoCmdId:
    73             {
    74             INFO_LOG( "FeatMgr SlowStart Plugin: Processed ELoadFeatureInfoCmdId" );
    75             // Load feature info
    76             }
    77             break;
    78         case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
    79             {
    80 			INFO_LOG( "FeatMgr SlowStart Plugin: extended command interface not supported");
    81 			User::Leave(KErrNotSupported);
    82             }
    83         default :
    84             {
    85             INFO_LOG1( "FeatMgr SlowStart Plugin: Unknown Command: 0x%x", aCommandId );
    86             User::Leave(KErrNotSupported);
    87             }
    88             break;
    89         }
    90         
    91     TInt retval(KErrNone);
    92     TInt timeout( 0.5*KDefaultFeatMgrTimer ); // We don't actually want to timeout, but add an extra delay.
    93 
    94     // create new timer
    95     if ( iTimer && !iTimer->IsActive() )
    96         {
    97         delete iTimer;
    98         iTimer = NULL;
    99         }
   100         
   101     iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this);
   102     }
   103 
   104 
   105 void CFeatMgrSlowStartPlugin::GenericTimerFiredL(
   106 	    MFeatureInfoPluginCallback& aService,
   107 	    FeatureInfoCommand::TFeatureInfoCmd aCommandId,
   108 	    TUint8 aTransId,
   109 	    TInt aRetVal )
   110 	    {
   111 	    CFeatMgrBasePlugin::GenericTimerFiredL(aService,aCommandId,aTransId,aRetVal);
   112 	    INFO_LOG2( "FeatMgr SlowStart Plugin: GenericTimerFiredL (0x%x, 0x%x)", 
   113 	                         aCommandId, aTransId );
   114 	    
   115 	    TInt err( KErrNone );
   116 	    
   117 	    // Delay things a little.
   118 	    User::After(600000);
   119 
   120 	    switch ( aCommandId )
   121 	        {
   122 	        case FeatureInfoCommand::ELoadFeatureInfoCmdId:
   123 	            {
   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; 
   130 
   131 	            feature1.iFeatureID = KSlowStartPluginUid.iUid;
   132 	            feature1.iValue = ETrue;
   133 	            list.AppendL(feature1);
   134 	            
   135 	            featureList.iErrorCode = KErrNone;
   136 	            featureList.iList = list;
   137 	                
   138 	            FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
   139 	            
   140 	            TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));    
   141 	            
   142 	            CleanupStack::PopAndDestroy( &list );
   143 	            break;
   144 	            }
   145 	            
   146 	        default :
   147 	            break;
   148 	        }
   149 	    
   150 	    // TEST CASES END
   151 	 
   152 	    if ( err != KErrNone )
   153 	        {
   154 	        ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );
   155 	        }	    
   156 	    }
   157