sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "hostusbmsproxy.h" sl@0: #include "hostusbmsfactory.h" sl@0: #include "debug.h" sl@0: sl@0: CUsbHostMsProxyDriveFactory::CUsbHostMsProxyDriveFactory() sl@0: { sl@0: __MSFNSLOG sl@0: } sl@0: sl@0: CUsbHostMsProxyDriveFactory::~CUsbHostMsProxyDriveFactory() sl@0: { sl@0: __MSFNSLOG sl@0: } sl@0: sl@0: TInt CUsbHostMsProxyDriveFactory::Install() sl@0: { sl@0: __MSFNSLOG sl@0: _LIT(KLoggerName,"usbhostms"); sl@0: return SetName(&KLoggerName); sl@0: } sl@0: sl@0: TInt CUsbHostMsProxyDriveFactory::CreateProxyDrive(CProxyDrive*& aMountProxyDrive,CMountCB* aMount) sl@0: { sl@0: __MSFNSLOG sl@0: aMountProxyDrive = new CUsbHostMsProxyDrive(aMount,this); sl@0: return (aMountProxyDrive==NULL) ? KErrNoMemory : KErrNone; sl@0: } sl@0: sl@0: sl@0: extern "C" { sl@0: sl@0: sl@0: /* sl@0: Create the proxy drive factory object for the usbhost mass storage proxy sl@0: */ sl@0: EXPORT_C CExtProxyDriveFactory* CreateFileSystem() sl@0: { sl@0: __MSFNSLOG sl@0: return new CUsbHostMsProxyDriveFactory(); sl@0: } sl@0: } sl@0: sl@0: /* sl@0: This function will be called to kick off a speculative probe for USB mass storage devices. sl@0: This function issues an application session request (through publish and subscribe) to the USB manager. sl@0: Upon USB Manager receiving this application session request in consent with the USB watcher application, sl@0: the Bus request is passed to the OTG component to bringup the VBus, thus enumerating the mass storage sl@0: devices Upon enumerating the FDF will communicate with the Mount Manager which will allocate mass storage sl@0: drives for the logical units and continues drive access through the Usb host mass storage proxy drive. sl@0: sl@0: Ps: Note that the this request cant be handled by the MSC since, in the scenario where MSC is not running sl@0: initially, the request will try to create the process. Creation of process will involve the file server inturn sl@0: to load the MSC binary (.exe) to run. Since the RMessages are handled sequentially, the file server would not sl@0: be able to service the request until the AsyncEnuerate is completed. Where, the process creation will wait sl@0: for the rendezvous to complete creating the deadlock situation. Hence the application session request is handled sl@0: in the factory object itself! sl@0: */ sl@0: void CUsbHostMsProxyDriveFactory::AsyncEnumerate() sl@0: { sl@0: __MSFNSLOG sl@0: sl@0: RProperty prop; sl@0: TInt ret; sl@0: sl@0: /* The property category is the USB manager */ sl@0: const TUid KUidUsbManCategory={0x101fe1db}; sl@0: /* The Key used is #6 for the Usb request session */ sl@0: const TInt KUsbRequestSessionProperty = 6; sl@0: sl@0: /* By this time the property should be available and allow us to get the handle. sl@0: If the property is not created (for some reason), we do not have anything to do */ sl@0: ret = prop.Attach(KUidUsbManCategory, KUsbRequestSessionProperty); sl@0: __PXYPRINT1(_L("Property attach returned %d"),ret); sl@0: if(ret == KErrNone) sl@0: { sl@0: /* The Usb Manager does not evaluate the value passed through this property. sl@0: We pass 1 (an arbitary value) for completion */ sl@0: ret = prop.Set(KUidUsbManCategory, KUsbRequestSessionProperty, 1); sl@0: __PXYPRINT1(_L("Property set returned %d"),ret); sl@0: prop.Close(); sl@0: } sl@0: } sl@0: