os/kernelhwsrv/userlibandfileserver/fileserver/shostmassstorage/msproxy/hostusbmsfactory.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) 2008-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 the License "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
 @file
sl@0
    18
 @internalTechnology
sl@0
    19
*/
sl@0
    20
sl@0
    21
#include <f32fsys.h>
sl@0
    22
#include <e32property.h>
sl@0
    23
sl@0
    24
#include "hostusbmsproxy.h"
sl@0
    25
#include "hostusbmsfactory.h"
sl@0
    26
#include "debug.h"
sl@0
    27
sl@0
    28
CUsbHostMsProxyDriveFactory::CUsbHostMsProxyDriveFactory()
sl@0
    29
	{
sl@0
    30
	__MSFNSLOG
sl@0
    31
	}
sl@0
    32
sl@0
    33
CUsbHostMsProxyDriveFactory::~CUsbHostMsProxyDriveFactory()
sl@0
    34
	{
sl@0
    35
	__MSFNSLOG
sl@0
    36
	}
sl@0
    37
sl@0
    38
TInt CUsbHostMsProxyDriveFactory::Install()
sl@0
    39
	{
sl@0
    40
	__MSFNSLOG
sl@0
    41
	_LIT(KLoggerName,"usbhostms");
sl@0
    42
	return SetName(&KLoggerName);
sl@0
    43
	}
sl@0
    44
sl@0
    45
TInt CUsbHostMsProxyDriveFactory::CreateProxyDrive(CProxyDrive*& aMountProxyDrive,CMountCB* aMount)
sl@0
    46
	{
sl@0
    47
	__MSFNSLOG
sl@0
    48
    aMountProxyDrive = new CUsbHostMsProxyDrive(aMount,this);
sl@0
    49
    return (aMountProxyDrive==NULL) ? KErrNoMemory : KErrNone;
sl@0
    50
	}
sl@0
    51
sl@0
    52
sl@0
    53
extern "C" {
sl@0
    54
sl@0
    55
sl@0
    56
/* 
sl@0
    57
Create the proxy drive factory object for the usbhost mass storage proxy
sl@0
    58
*/
sl@0
    59
EXPORT_C CExtProxyDriveFactory* CreateFileSystem()
sl@0
    60
	{
sl@0
    61
	__MSFNSLOG
sl@0
    62
	return new CUsbHostMsProxyDriveFactory();
sl@0
    63
	}
sl@0
    64
}
sl@0
    65
sl@0
    66
/*
sl@0
    67
This function will be called to kick off a speculative probe for USB mass storage devices.
sl@0
    68
This function issues an application session request (through publish and subscribe) to the USB manager.
sl@0
    69
Upon USB Manager receiving this application session request in consent with the USB watcher application,
sl@0
    70
the Bus request is passed to the OTG  component to bringup the VBus, thus enumerating the mass storage
sl@0
    71
devices Upon enumerating the FDF will communicate with the Mount Manager which will allocate mass storage 
sl@0
    72
drives for the logical units and continues drive access through the Usb host mass storage proxy drive.
sl@0
    73
sl@0
    74
Ps: Note that the this request cant be handled by the MSC since, in the scenario where MSC is not running
sl@0
    75
initially, the request will try to create the process. Creation of process will involve the file server inturn
sl@0
    76
to load the MSC binary (.exe) to run. Since the RMessages are handled sequentially, the file server would not
sl@0
    77
be able to service the request until the AsyncEnuerate is completed. Where, the process creation will wait 
sl@0
    78
for the rendezvous to complete creating the deadlock situation. Hence the application session request is handled
sl@0
    79
in the factory object itself!
sl@0
    80
*/
sl@0
    81
void CUsbHostMsProxyDriveFactory::AsyncEnumerate()
sl@0
    82
{
sl@0
    83
	__MSFNSLOG
sl@0
    84
sl@0
    85
	RProperty prop;
sl@0
    86
	TInt ret;
sl@0
    87
sl@0
    88
	/* The property category is the USB manager */
sl@0
    89
	const TUid KUidUsbManCategory={0x101fe1db};
sl@0
    90
	/* The Key used is #6 for the Usb request session */
sl@0
    91
	const TInt KUsbRequestSessionProperty = 6;
sl@0
    92
sl@0
    93
	/* By this time the property should be available and allow us to get the handle.
sl@0
    94
		If the property is not created (for some reason), we do not have anything to do */
sl@0
    95
	ret = prop.Attach(KUidUsbManCategory, KUsbRequestSessionProperty);
sl@0
    96
    __PXYPRINT1(_L("Property attach returned %d"),ret);
sl@0
    97
	if(ret == KErrNone)
sl@0
    98
    {
sl@0
    99
		/* The Usb Manager does not evaluate the value passed through this property. 
sl@0
   100
			We pass 1 (an arbitary value) for completion */
sl@0
   101
		ret = prop.Set(KUidUsbManCategory, KUsbRequestSessionProperty, 1); 
sl@0
   102
	     __PXYPRINT1(_L("Property set returned %d"),ret);
sl@0
   103
		prop.Close();
sl@0
   104
	}
sl@0
   105
}
sl@0
   106