// // ---------------------------------------------------------------------------------- // CASYStubCmdHandlerBase::ProcessCommandL() // ---------------------------------------------------------------------------------- // void CASYStubCmdHandlerBase::ProcessCommandL( const TProcessCmdId aCommand, const TASYCmdParams& aCmdParams ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Enter" ) ) ); CASYMainServiceBase* mainServiceBase = ASYMainServiceBase(); COMPONENT_TRACE( ( _L( "AsyStub - CASYStubCmdHandlerBase::ProcessCommandL - mainServiceBase (0x%x)" ), &mainServiceBase ) ); TASYCommandParamRecord cmdParams( aCmdParams() );//For debugging if( aCommand == ECmdGetObjectValue || aCommand == ECmdSetObjectValue ) { ProcessObjectL( aCommand, aCmdParams ); } else { CASYStubMainServiceBase* AsyStub = reinterpret_cast<CASYStubMainServiceBase*> ( mainServiceBase ); COMPONENT_TRACE( ( _L( "AsyStub - CASYStubCmdHandlerBase::ProcessCommandL - AsyStub (0x%x)" ), &AsyStub ) ); AsyStub->AsyStubMainServicePointerReceivedL(); COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Return" ) ) ); TInt aTestCaseID = AsyStub->GetTestCaseID(); // Do something with this TTFCapability aCapabilityS = AsyStub->GetAndRemoveCapability(); switch( aCommand ) { case ECmdGetValueBool: { TUint32 name; aCmdParams().iNameRecord.GetName( name ); TAccValueTypeTBool aCmdResponse; aCmdResponse.iValue = EFalse; if( name == aCapabilityS.iCapability ) { if( 0 != aCapabilityS.iTimeMs ) { //Serve asynchronously Start( aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool ); } else { aCmdResponse.iValue = aCapabilityS.iValue; ProcessResponseL( aCmdResponse ); } } else { TRACE_ASSERT_ALWAYS; ProcessResponseL( aCmdResponse, KErrArgument ); } } break; case ECmdGetValueTDes8: { // Worm is fired through the Accessory Server. TBuf8<80> worm( _L8("Malicious Worm Attach with extra long data with extra long content" ) ); ProcessResponseL( worm, KErrNone ); } break; case ECmdSetValueBool: { TUint32 name; aCmdParams().iNameRecord.GetName( name ); TAccValueTypeTBool aCmdResponse; aCmdResponse.iValue = EFalse; if( name == aCapabilityS.iCapability && aCmdParams().iCmdValue == aCapabilityS.iValue ) { if( aCapabilityS.iTimeMs ) { //Serve asynchronously Start( aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool ); } else { aCmdResponse.iValue = aCmdParams().iCmdValue; ProcessResponseL( aCmdResponse ); } } else { TRACE_ASSERT_ALWAYS; ProcessResponseL( aCmdResponse, KErrArgument ); } } break; case ECmdProcessCommandInit: { TAccValueTypeTBool boolInitResponse; TBool everyThing( ETrue ); // If everything is ok if( everyThing ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is ok" ) ) ); boolInitResponse.iValue = ETrue; ProcessResponseL( boolInitResponse ); } // If everything is not ok else { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is not ok" ) ) ); boolInitResponse.iValue = EFalse; TInt errCode( KErrGeneral ); ProcessResponseL( boolInitResponse, errCode ); } } break; //for user selection.... case ECmdAccessoryUpdated: { TAccValueTypeTBool boolInitResponse; TBool everyThing( ETrue ); //get capabilities CAccPolSubblockNameArray* iNameArray = CAccPolSubblockNameArray::NewL(); RAccessoryServer server; server.Connect(); RAccessorySingleConnection connectionBase; connectionBase.CreateSubSession( server ); connectionBase.GetSubblockNameArrayL( cmdParams.iGenericID, *iNameArray ); RArray<TUint32>& array = *TAccPolSubblockNameArrayAccessor::Array( iNameArray ); for( TInt i( 0 ); i < array.Count(); i++ ) { TUint32 name = array[i]; TAccPolNameRecord nameRecord; nameRecord.SetNameL( name ); TAccValueTypeTInt value; TRAPD( err, connectionBase.GetValueL( cmdParams.iGenericID, nameRecord, value)); if( err != KErrNone ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Capability 0x%x has no value!"), name ) ); } name = 0; } connectionBase.CloseSubSession(); server.Close(); delete iNameArray; // If everything is ok if( everyThing ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is ok" ) ) ); boolInitResponse.iValue = ETrue; ProcessResponseL( boolInitResponse ); } // If everything is not ok else { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is not ok" ) ) ); boolInitResponse.iValue = EFalse; TInt errCode( KErrGeneral ); ProcessResponseL( boolInitResponse, errCode ); } } break; default: { COMPONENT_TRACE( ( _L( "BTASYStub - CBTBTASYStubCmdHandlerBase::ProcessCommandL() - ERROR: unhandled command" ) ) ); TRACE_ASSERT_ALWAYS; User::Panic( _L("ASY Stub"), KErrGeneral ); } break; } } }
// ---------------------------------------------------------------------------------- // CASYStubCmdHandlerBase::ProcessCommandL() // ---------------------------------------------------------------------------------- void CASYStubCmdHandlerBase::ProcessCommandL( const TProcessCmdId aCommand, const TASYCmdParams& aCmdParams ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Enter" ) ) ); CASYMainServiceBase* mainServiceBase = ASYMainServiceBase(); COMPONENT_TRACE( ( _L( "AsyStub - CASYStubCmdHandlerBase::ProcessCommandL - mainServiceBase (0x%x)" ), &mainServiceBase ) ); CASYStubMainServiceBase* AsyStub = reinterpret_cast<CASYStubMainServiceBase*>( mainServiceBase ); COMPONENT_TRACE( ( _L( "AsyStub - CASYStubCmdHandlerBase::ProcessCommandL - AsyStub (0x%x)" ), &AsyStub ) ); TTFCapability aCapabilityS = AsyStub->GetAndRemoveCapability(); TASYCommandParamRecord cmdParams( aCmdParams() );//For debugging COMPONENT_TRACE( ( _L( "AsyStub - CASYStubCmdHandlerBase::ProcessCommandL - command: (0x%x)" ), aCommand ) ); switch ( aCommand ) { case ECmdGetValueBool: { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Get value Bool" ) ) ); TUint32 name; aCmdParams().iNameRecord.GetName( name ); TAccValueTypeTBool aCmdResponse = { EFalse }; if( name == aCapabilityS.iCapability ) { if( 0 != aCapabilityS.iTimeMs ) { //Serve asynchronously Start( aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool ); } else { aCmdResponse.iValue = aCapabilityS.iValue; ProcessResponseL( aCmdResponse ); } } else { TRACE_ASSERT_ALWAYS; ProcessResponseL( aCmdResponse, KErrArgument ); } } break; case ECmdSetValueBool: { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Set value Bool" ) ) ); TUint32 name; aCmdParams().iNameRecord.GetName( name ); TAccValueTypeTBool aCmdResponse = { EFalse }; if( name == aCapabilityS.iCapability && aCmdParams().iCmdValue == aCapabilityS.iValue ) { if( aCapabilityS.iTimeMs ) { //Serve asynchronously Start( aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool ); } else { aCmdResponse.iValue = aCmdParams().iCmdValue; ProcessResponseL( aCmdResponse ); } } else { TRACE_ASSERT_ALWAYS; ProcessResponseL( aCmdResponse, KErrArgument ); } } break; case ECmdProcessCommandInit: { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Process command init" ) ) ); TAccValueTypeTBool boolInitResponse; TBool everyThing( ETrue ); // If everything is ok if ( everyThing ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is ok" ) ) ); boolInitResponse.iValue = ETrue; ProcessResponseL( boolInitResponse ); } // If everything is not ok else { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is not ok" ) ) ); boolInitResponse.iValue = EFalse; TInt errCode( KErrGeneral ); ProcessResponseL( boolInitResponse, errCode ); } } break; // For user selection... case ECmdAccessoryUpdated: { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Accessory updated" ) ) ); TAccValueTypeTBool boolInitResponse; TBool everyThing( ETrue ); //get capabilities CAccPolSubblockNameArray* nameArray = CAccPolSubblockNameArray::NewL(); CleanupStack::PushL( nameArray ); RAccessoryServer server; server.Connect(); RAccessorySingleConnection connectionBase; connectionBase.CreateSubSession( server); connectionBase.GetSubblockNameArrayL( cmdParams.iGenericID, *nameArray ); RArray<TUint32>& array = *TAccPolSubblockNameArrayAccessor::Array( nameArray ); for ( TInt i( 0 ); i < array.Count(); i++ ) { TUint32 name = array[ i ]; TAccPolNameRecord nameRecord; nameRecord.SetNameL( name ); TAccValueTypeTInt value; TRAPD( err, connectionBase.GetValueL( cmdParams.iGenericID, nameRecord, value ) ); if ( err != KErrNone ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Capability 0x%x has no value!" ), name ) ); } name = 0; } connectionBase.CloseSubSession(); server.Close(); CleanupStack::PopAndDestroy( nameArray ); // If everything is ok if ( everyThing ) { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is ok" ) ) ); boolInitResponse.iValue = ETrue; ProcessResponseL( boolInitResponse ); } // If everything is not ok else { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - everything is not ok" ) ) ); boolInitResponse.iValue = EFalse; TInt errCode( KErrGeneral ); ProcessResponseL( boolInitResponse, errCode ); } } break; case ECmdGetSupportedBTProfiles: { COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Get BT profiles - Here is something wrong" ) ) ); TASYBTAccInfo btInfo; btInfo.iReserved = 0; TBTDevAddr btAddr( aCmdParams().iCmdValue ); switch( aCmdParams().iCmdValue ) { case KBTAddrCarkit: { btInfo.iDeviceInfo = 0x191; btInfo.iDeviceType = KDTCarKit; btInfo.iProfiles = KAccInfoHFP; btInfo.iSupportedFeatures.At(0) = 1; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadsetHSPAndHFP: { btInfo.iDeviceInfo = 0x192; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHSP | KAccInfoHFP; btInfo.iSupportedFeatures.At( 0 ) = 1; btInfo.iSupportedFeatures.At( 1 ) = 2; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadsetHSP: { btInfo.iDeviceInfo = 0x193; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHSP; btInfo.iSupportedFeatures.At(0) = 1; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadsetHFP: { btInfo.iDeviceInfo = 0x194; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHFP; btInfo.iSupportedFeatures.At(1) = 1; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadsetAVRCP: { btInfo.iDeviceInfo = 0x195; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHFP; btInfo.iSupportedFeatures.At(1) = 1; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadseA2DP: { btInfo.iDeviceInfo = 0x196; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHFP; btInfo.iSupportedFeatures.At(1) = 1; btInfo.iReserved |= KAccInfoDRM; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadsetEmptyPR: { btInfo.iDeviceInfo = 0x197; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = 0; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrHeadsetNokiaSPId: { btInfo.iDeviceInfo = 0x181; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHSP; btInfo.iSupportedFeatures.At(0) = 1; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; case KBTAddrNoResponse: { // No response } break; case KBTAddrErrCode: { btInfo.iDeviceInfo = 0x198; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHSP; btInfo.iSupportedFeatures.At( 0 ) = 1; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrGeneral ); } break; case KBTAllBitsOn: // All supported bits on { btInfo.iDeviceInfo = 0x198; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHSP | KAccInfoHFP | KAccInfoAVRCP | KAccInfoA2DP; btInfo.iSupportedFeatures.At( 0 ) = 0xFFFF; btInfo.iSupportedFeatures.At( 1 ) = 0xFFFF; btInfo.iSupportedFeatures.At( 2 ) = 0xFFFF; btInfo.iSupportedFeatures.At( 3 ) = 0xFFFF; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; default: { btInfo.iDeviceInfo = 0x181; btInfo.iDeviceType = KDTHeadset; btInfo.iProfiles = KAccInfoHSP | KAccInfoHFP; btInfo.iSupportedFeatures.At( 0 ) = 1; btInfo.iSupportedFeatures.At( 1 ) = 2; TASYBTAccInfoPckgC btInfoPckgC( btInfo ); ProcessResponseL( btInfoPckgC, KErrNone ); } break; } break; } default: { COMPONENT_TRACE( ( _L( "BTASYStub - CBTBTASYStubCmdHandlerBase::ProcessCommandL() - ERROR: unhandled command" ) ) ); TRACE_ASSERT_ALWAYS; User::Panic(_L("ASY Stub"), KErrGeneral ); } break; } COMPONENT_TRACE( ( _L( "ASYStub - CASYStubCmdHandlerBase::ProcessCommandL() - Return" ) ) ); }
// // ---------------------------------------------------------------------------------- // CASYStubCmdHandlerBase::ProcessCommandL() // ---------------------------------------------------------------------------------- // void CASYStubCmdHandlerBase::ProcessCommandL( const TProcessCmdId aCommand, const TASYCmdParams& aCmdParams ) { CASYMainServiceBase* mainServiceBase = ASYMainServiceBase(); CASYStubMainServiceBase* AsyStub = reinterpret_cast<CASYStubMainServiceBase*>( mainServiceBase ); AsyStub->AsyStubMainServicePointerReceivedL(); TTFCapability aCapabilityS = AsyStub->GetAndRemoveCapability(); TASYCommandParamRecord cmdParams ( aCmdParams() );//For debugging switch ( aCommand ) { case ECmdGetValueBool: { TUint32 name; aCmdParams().iNameRecord.GetName( name ); TAccValueTypeTBool aCmdResponse = {EFalse}; if( name == aCapabilityS.iCapability ) { if( 0 != aCapabilityS.iTimeMs ) { //Serve asynchronously Start(aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool ); } else { aCmdResponse.iValue = aCapabilityS.iValue; ProcessResponseL(aCmdResponse); } } else { ProcessResponseL(aCmdResponse, KErrArgument); } } break; case ECmdGetValueTDes8: { // Worm is fired through the Accessory Server. TBuf8<22> worm(_L8("Malicious Worm Attach" )); ProcessResponseL( worm, KErrNone ); } break; case ECmdSetValueBool: { TUint32 name; aCmdParams().iNameRecord.GetName( name ); TAccValueTypeTBool aCmdResponse = { EFalse }; if( name == aCapabilityS.iCapability && aCmdParams().iCmdValue == aCapabilityS.iValue ) { if( aCapabilityS.iTimeMs ) { //Serve asynchronously Start(aCapabilityS.iTimeMs, aCapabilityS.iValue, EAPVBool ); } else { aCmdResponse.iValue = aCmdParams().iCmdValue; ProcessResponseL(aCmdResponse); } } else { ProcessResponseL(aCmdResponse, KErrArgument); } } break; case ECmdProcessCommandInit: { TAccValueTypeTBool boolInitResponse; TBool everyThing( ETrue ); // If everything is ok if ( everyThing ) { boolInitResponse.iValue = ETrue; ProcessResponseL( boolInitResponse ); } // If everything is not ok else { boolInitResponse.iValue = EFalse; TInt errCode( KErrGeneral ); ProcessResponseL( boolInitResponse, errCode ); } } break; //for user selection.... case ECmdAccessoryUpdated: { /* TAccValueTypeTBool boolInitResponse; TBool everyThing( ETrue ); //get capabilities CAccPolSubblockNameArray* iNameArray = CAccPolSubblockNameArray::NewL(); RAccessoryServer server; server.Connect(); RAccessorySingleConnection connectionBase; connectionBase.CreateSubSession( server); connectionBase.GetSubblockNameArrayL( cmdParams.iGenericID, *iNameArray); RArray<TUint32>& array = *TAccPolSubblockNameArrayAccessor::Array( iNameArray); for ( TInt i(0); i < array.Count(); i++) { TUint32 name = array[ i]; TAccPolNameRecord nameRecord; nameRecord.SetNameL( name); TAccValueTypeTInt value; TRAPD( err, connectionBase.GetValueL( cmdParams.iGenericID, nameRecord, value)); if ( err != KErrNone) { } name = 0; } connectionBase.CloseSubSession(); server.Close(); delete iNameArray; // If everything is ok if ( everyThing ) { boolInitResponse.iValue = ETrue; ProcessResponseL( boolInitResponse ); } // If everything is not ok else { boolInitResponse.iValue = EFalse; TInt errCode( KErrGeneral ); ProcessResponseL( boolInitResponse, errCode ); }*/ } break; default: { User::Panic(_L("ASY Stub"), KErrGeneral ); } break; } }