os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/server/cusbhostserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/server/cusbhostserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,114 @@
1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Implements a Symbian OS server that exposes the RUsbMassStorage API
1.18 +//
1.19 +//
1.20 +
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @internalTechnology
1.26 +*/
1.27 +
1.28 +#include <e32svr.h>
1.29 +#include <f32file.h>
1.30 +
1.31 +#include <d32usbdi_hubdriver.h>
1.32 +#include <d32otgdi.h>
1.33 +
1.34 +#include "usbtypes.h"
1.35 +
1.36 +#include "cusbhostao.h"
1.37 +#include "cusbhost.h"
1.38 +
1.39 +
1.40 +#include "msmanclientserver.h"
1.41 +#include "cusbhostserver.h"
1.42 +#include "cusbhostsession.h"
1.43 +
1.44 +#include "tmslog.h"
1.45 +
1.46 +CUsbHostServer* CUsbHostServer::NewLC()
1.47 + {
1.48 + __MSFNSLOG
1.49 + CUsbHostServer* r = new (ELeave) CUsbHostServer();
1.50 + CleanupStack::PushL(r);
1.51 + r->ConstructL();
1.52 + return r;
1.53 + }
1.54 +
1.55 +
1.56 +CUsbHostServer::CUsbHostServer()
1.57 +: CServer2(EPriorityLow)
1.58 + {
1.59 + __MSFNSLOG
1.60 + }
1.61 +
1.62 +
1.63 +void CUsbHostServer::ConstructL()
1.64 + {
1.65 + __MSFNSLOG
1.66 + iUsbHost = CUsbHost::NewL();
1.67 + StartL(KUsbHostServerName);
1.68 + }
1.69 +
1.70 +
1.71 +CUsbHostServer::~CUsbHostServer()
1.72 + {
1.73 + __MSFNSLOG
1.74 + delete iUsbHost;
1.75 + }
1.76 +
1.77 +
1.78 +CSession2* CUsbHostServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
1.79 + {
1.80 + __MSFNSLOG
1.81 + TVersion v(KUsbHostSrvMajorVersionNumber, KUsbHostSrvMinorVersionNumber, KUsbHostSrvBuildVersionNumber);
1.82 +
1.83 + if (!User::QueryVersionSupported(v, aVersion))
1.84 + User::Leave(KErrNotSupported);
1.85 +
1.86 + CUsbHostSession* session = CUsbHostSession::NewL();
1.87 +
1.88 + return session;
1.89 + }
1.90 +
1.91 +
1.92 +
1.93 +TInt CUsbHostServer::RunError(TInt aError)
1.94 + {
1.95 + __MSFNSLOG
1.96 +
1.97 + Message().Complete(aError);
1.98 + ReStart();
1.99 + return KErrNone;
1.100 + }
1.101 +
1.102 +
1.103 +void CUsbHostServer::AddSession()
1.104 + {
1.105 + __MSFNSLOG
1.106 + ++iSessionCount;
1.107 + }
1.108 +
1.109 +void CUsbHostServer::RemoveSession()
1.110 + {
1.111 + __MSFNSLOG
1.112 + if (--iSessionCount == 0)
1.113 + {
1.114 + User::After(1000000);
1.115 + CActiveScheduler::Stop();
1.116 + }
1.117 + }