os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/server/cusbotgserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/msman/server/cusbotgserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,112 @@
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 +#include "cusbotg.h"
1.36 +
1.37 +#include "msmanclientserver.h"
1.38 +#include "cusbotgserver.h"
1.39 +#include "cusbotgsession.h"
1.40 +
1.41 +#include "tmslog.h"
1.42 +
1.43 +CUsbOtgServer* CUsbOtgServer::NewLC()
1.44 + {
1.45 + __MSFNSLOG
1.46 + CUsbOtgServer* r = new (ELeave) CUsbOtgServer();
1.47 + CleanupStack::PushL(r);
1.48 + r->ConstructL();
1.49 + return r;
1.50 + }
1.51 +
1.52 +
1.53 +CUsbOtgServer::CUsbOtgServer()
1.54 +: CServer2(EPriorityLow)
1.55 + {
1.56 + __MSFNSLOG
1.57 + }
1.58 +
1.59 +
1.60 +void CUsbOtgServer::ConstructL()
1.61 + {
1.62 + __MSFNSLOG
1.63 +
1.64 + iUsbOtg = CUsbOtg::NewL();
1.65 + StartL(KUsbOtgServerName);
1.66 + }
1.67 +
1.68 +
1.69 +CUsbOtgServer::~CUsbOtgServer()
1.70 + {
1.71 + __MSFNSLOG
1.72 + delete iUsbOtg;
1.73 + }
1.74 +
1.75 +
1.76 +CSession2* CUsbOtgServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
1.77 + {
1.78 + __MSFNSLOG
1.79 + TVersion v(KUsbOtgSrvMajorVersionNumber, KUsbOtgSrvMinorVersionNumber, KUsbOtgSrvBuildVersionNumber);
1.80 +
1.81 + if (!User::QueryVersionSupported(v, aVersion))
1.82 + User::Leave(KErrNotSupported);
1.83 +
1.84 + CUsbOtgSession* session = CUsbOtgSession::NewL();
1.85 +
1.86 + return session;
1.87 + }
1.88 +
1.89 +
1.90 +
1.91 +TInt CUsbOtgServer::RunError(TInt aError)
1.92 + {
1.93 + __MSFNSLOG
1.94 +
1.95 + Message().Complete(aError);
1.96 + ReStart();
1.97 + return KErrNone;
1.98 + }
1.99 +
1.100 +
1.101 +void CUsbOtgServer::AddSession()
1.102 + {
1.103 + __MSFNSLOG
1.104 + ++iSessionCount;
1.105 + }
1.106 +
1.107 +void CUsbOtgServer::RemoveSession()
1.108 + {
1.109 + __MSFNSLOG
1.110 + if (--iSessionCount == 0)
1.111 + {
1.112 + User::After(1000000);
1.113 + CActiveScheduler::Stop();
1.114 + }
1.115 + }