diff -r 20ac952a623c -r 321a10f609ef bthci/hci2implementations/hctls/usb_original/fdc/src/fdchctloriginal.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bthci/hci2implementations/hctls/usb_original/fdc/src/fdchctloriginal.cpp Thu Oct 14 11:16:56 2010 +0100 @@ -0,0 +1,248 @@ +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +/** +@file +@internalComponent +*/ + +#include "fdchctloriginal.h" + +#include +#include +#include +#include + +#include "fdchctloriginalserver.h" + +#include + +#ifdef __FLOG_ACTIVE +_LIT8(KLogComponent, "fdchctloriginal"); +#endif + + +CFdcHctlOriginal* CFdcHctlOriginal::NewL(MFdcPluginObserver& aObserver) + { + LOG_STATIC_FUNC + CFdcHctlOriginal* self = new(ELeave) CFdcHctlOriginal(aObserver); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +CFdcHctlOriginal::CFdcHctlOriginal(MFdcPluginObserver& aObserver) + : CFdcPlugin(aObserver) + { + LOG_FUNC + } + +CFdcHctlOriginal::~CFdcHctlOriginal() + { + LOG_FUNC + iHctlSession.Close(); + delete iServer; + } + +void CFdcHctlOriginal::ConstructL() + { + LOG_FUNC + iServer = CFdcHctlOriginalServer::NewL(*this); + } + +TAny* CFdcHctlOriginal::GetInterface(TUid aUid) + { + LOG_FUNC + LOG1(_L8("\taUid = 0x%08x"), aUid); + + TAny* ret = NULL; + if(aUid == TUid::Uid(KFdcInterfaceV1)) + { + ret = reinterpret_cast(static_cast(this)); + } + + LOG1(_L8("\tret = [0x%08x]"), ret); + return ret; + } + +TInt CFdcHctlOriginal::Mfi1NewFunction(TUint aDeviceId, + const TArray& aInterfaces, + const TUsbDeviceDescriptor& aDeviceDescriptor, + const TUsbConfigurationDescriptor& aConfigurationDescriptor) + { + LOG_FUNC + + // Normally an FDC is required to claim it's interfaces first. In this + // case we need to parse the descriptor tree to determine if the device + // firmware update interface is present. (We don't do firmware updates but + // we claim it until to provide successful device attachments. If a + // firmware update FDC is provided this should be removed.) +#ifdef SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE + TBool firmwareIntFound = EFalse; + TUint8 firmwareIntNum = 0xff; + + TUint8 KDfuInterfaceClass = 0xfe; + TUint8 KDfuInterfaceSubClass = 0x01; + + // Drop down a level from the configuration descriptor. + TUsbGenericDescriptor* descriptor = aConfigurationDescriptor.iFirstChild; + // Search across the interface tier (note doesn't handle DFU in IAD). + while(descriptor) + { + TUsbInterfaceDescriptor* interface; + if (interface = TUsbInterfaceDescriptor::Cast(descriptor), interface) + { + if( interface->InterfaceClass() == KDfuInterfaceClass && + interface->InterfaceSubClass() == KDfuInterfaceSubClass) + { + firmwareIntNum = interface->InterfaceNumber(); + firmwareIntFound = ETrue; + break; + } + } + descriptor = descriptor->iNextPeer; + } +#endif // SYMBIAN_FDC_HCTL_ORIGINAL_ACCEPT_FIRMWARE_UPDATE + + // We claim the interfaces we are to represent, we must claim the + // first interface given to us as FDF has already determined that + // we are to use it. + const TUint KNumOfHctlInterfaces = 2; + const TUint8 KAclInterfaceNum = 0x00, KScoInterfaceNum = 0x01; + TBool gotAcl = EFalse, gotSco = EFalse, fatalError = EFalse; + + for(TInt i=0; i