os/persistentdata/featuremgmt/featuremgr/test/helper/test_plugins/src/hangingplugin.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.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
sl@0
    18
#include "hangingplugin.h"
sl@0
    19
#include <featmgr/featureinfoplugin.h>
sl@0
    20
#include "featmgrdebug.h"
sl@0
    21
#include "efm_test_consts.h"     
sl@0
    22
#include <ecom/implementationproxy.h>
sl@0
    23
#include "featmgrconfiguration.h"
sl@0
    24
sl@0
    25
sl@0
    26
// Map the interface implementation UIDs to implementation factory functions
sl@0
    27
const TImplementationProxy ImplementationTable[] =
sl@0
    28
    {
sl@0
    29
    IMPLEMENTATION_PROXY_ENTRY(0x102836FA,	CFeatMgrHangingPlugin::NewL),
sl@0
    30
    };
sl@0
    31
sl@0
    32
// Exported proxy for instantiation method resolution.
sl@0
    33
EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
sl@0
    34
    {
sl@0
    35
    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
    36
    return ImplementationTable;
sl@0
    37
    }
sl@0
    38
sl@0
    39
CFeatMgrHangingPlugin* CFeatMgrHangingPlugin::NewL()
sl@0
    40
    {
sl@0
    41
    CFeatMgrHangingPlugin* self = new(ELeave) CFeatMgrHangingPlugin();
sl@0
    42
    CleanupStack::PushL(self);
sl@0
    43
    self->ConstructL();
sl@0
    44
    CleanupStack::Pop(self);
sl@0
    45
    return self;
sl@0
    46
    }
sl@0
    47
sl@0
    48
CFeatMgrHangingPlugin::~CFeatMgrHangingPlugin()
sl@0
    49
    {
sl@0
    50
    }
sl@0
    51
sl@0
    52
CFeatMgrHangingPlugin::CFeatMgrHangingPlugin()
sl@0
    53
    {
sl@0
    54
    }
sl@0
    55
sl@0
    56
void CFeatMgrHangingPlugin::ConstructL()
sl@0
    57
    {
sl@0
    58
    }
sl@0
    59
    
sl@0
    60
void CFeatMgrHangingPlugin::ProcessCommandL( const FeatureInfoCommand::TFeatureInfoCmd aCommandId,
sl@0
    61
                                      const TUint8 aTransId,
sl@0
    62
                                      TDesC8& /*aData*/ )
sl@0
    63
    {
sl@0
    64
    INFO_LOG2( "FeatMgr Hanging Plugin: Processing command: 0x%x, TransId: 0x%x", 
sl@0
    65
                         aCommandId, aTransId );
sl@0
    66
           
sl@0
    67
    switch ( aCommandId )
sl@0
    68
        {
sl@0
    69
        case FeatureInfoCommand::ELoadFeatureInfoCmdId:
sl@0
    70
            {
sl@0
    71
            INFO_LOG( "FeatMgr Hanging Plugin: Processed ELoadFeatureInfoCmdId" );
sl@0
    72
            // Load feature info
sl@0
    73
            }
sl@0
    74
            break;
sl@0
    75
        case FeatureInfoCommand::ELoadEnhancedFeatureInfoCmdId:
sl@0
    76
            {
sl@0
    77
			INFO_LOG( "FeatMgr Hanging Plugin: extended command interface not supported");
sl@0
    78
			User::Leave(KErrNotSupported);
sl@0
    79
            }
sl@0
    80
        default :
sl@0
    81
            {
sl@0
    82
            INFO_LOG1( "FeatMgr Hanging Plugin: Unknown Command: 0x%x", aCommandId );
sl@0
    83
            User::Leave(KErrNotSupported);
sl@0
    84
            }
sl@0
    85
            break;
sl@0
    86
        }
sl@0
    87
        
sl@0
    88
    TInt retval(KErrNone);
sl@0
    89
    TInt timeout( 1.5*KDefaultFeatMgrTimer ); // microseconds
sl@0
    90
sl@0
    91
    // create new timer
sl@0
    92
sl@0
    93
sl@0
    94
    if ( iTimer && !iTimer->IsActive() )
sl@0
    95
        {
sl@0
    96
        delete iTimer;
sl@0
    97
        iTimer = NULL;
sl@0
    98
        }
sl@0
    99
        
sl@0
   100
    iTimer = CPluginTimer::NewL(timeout, *iResponseCallback, aCommandId, aTransId, retval,this);
sl@0
   101
    }
sl@0
   102
    
sl@0
   103
    
sl@0
   104
void CFeatMgrHangingPlugin::GenericTimerFiredL(
sl@0
   105
	    MFeatureInfoPluginCallback& aService,
sl@0
   106
	    FeatureInfoCommand::TFeatureInfoCmd aCommandId,
sl@0
   107
	    TUint8 aTransId,
sl@0
   108
	    TInt aRetVal )
sl@0
   109
	    {
sl@0
   110
	    CFeatMgrBasePlugin::GenericTimerFiredL(aService,aCommandId,aTransId,aRetVal);
sl@0
   111
	    INFO_LOG2( "FeatMgr Hanging Plugin: GenericTimerFiredL (0x%x, 0x%x)", 
sl@0
   112
	                         aCommandId, aTransId );
sl@0
   113
	    
sl@0
   114
	    TInt err( KErrNone );
sl@0
   115
	    
sl@0
   116
	    switch ( aCommandId )
sl@0
   117
	        {
sl@0
   118
	        case FeatureInfoCommand::ELoadFeatureInfoCmdId:
sl@0
   119
	            {
sl@0
   120
	            // Return some features and KErrNone.
sl@0
   121
	            FeatureInfoCommand::TFeatureInfo featureList;
sl@0
   122
	            TInt err( KErrNone );
sl@0
   123
	            RArray<FeatureInfoCommand::TFeature> list;
sl@0
   124
	            CleanupClosePushL( list );
sl@0
   125
	            FeatureInfoCommand::TFeature feature1; 
sl@0
   126
sl@0
   127
	            feature1.iFeatureID = KHangingPluginUid.iUid;
sl@0
   128
	            feature1.iValue = ETrue;
sl@0
   129
	            list.AppendL(feature1);
sl@0
   130
	            
sl@0
   131
	            featureList.iErrorCode = KErrNone;
sl@0
   132
	            featureList.iList = list;
sl@0
   133
	                
sl@0
   134
	            FeatureInfoCommand::TFeatureInfoRespPckg resPackage(featureList);
sl@0
   135
	            
sl@0
   136
	            TRAP(err, aService.ProcessResponseL(aCommandId, aTransId, resPackage));    
sl@0
   137
	            
sl@0
   138
	            CleanupStack::PopAndDestroy( &list );
sl@0
   139
	            break;
sl@0
   140
	            }
sl@0
   141
	            
sl@0
   142
	        default :
sl@0
   143
	            break;
sl@0
   144
	        }
sl@0
   145
	    
sl@0
   146
	    // TEST CASES END
sl@0
   147
	 
sl@0
   148
	    if ( err != KErrNone )
sl@0
   149
	        {
sl@0
   150
	        ERROR_LOG1( "FeatMgr Plugin: Error in ProcessResponseL: %d", err );
sl@0
   151
	        }	    
sl@0
   152
	    }