sl@0: // Copyright (c) 2004-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: // Implements a Symbian OS server that exposes the RUsbMassStorage API sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: */ sl@0: sl@0: #include sl@0: #include "usbmsshared.h" sl@0: #include "cusbmassstorageserver.h" sl@0: #include "cusbmassstoragesession.h" sl@0: #include "cusbmassstoragecontroller.h" sl@0: #include "massstoragedebug.h" sl@0: sl@0: #include "usbmsserversecuritypolicy.h" sl@0: /** sl@0: Constructs a USB mass storage Server sl@0: sl@0: @return a pointer to CUsbMassStorageServer object sl@0: */ sl@0: CUsbMassStorageServer* CUsbMassStorageServer::NewLC(CUsbMassStorageController& aController) sl@0: { sl@0: CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController); sl@0: CleanupStack::PushL(r); sl@0: r->StartL(KUsbMsServerName); sl@0: return r; sl@0: } sl@0: sl@0: /** sl@0: Destructor sl@0: */ sl@0: CUsbMassStorageServer::~CUsbMassStorageServer() sl@0: { sl@0: // Intentionally left blank sl@0: } sl@0: sl@0: sl@0: /** sl@0: Constructor sl@0: sl@0: @param aController a USB mass storage controller reference sl@0: */ sl@0: CUsbMassStorageServer::CUsbMassStorageServer(CUsbMassStorageController& aController) sl@0: : CPolicyServer(EPriorityHigh,KUsbMsServerPolicy) sl@0: , iController(aController) sl@0: { sl@0: __PRINT(_L("CUsbMassStorageServer::CUsbMassStorageServer\n")); sl@0: } sl@0: sl@0: /** sl@0: Create a new session on this server sl@0: sl@0: @param &aVersion Version of client sl@0: @return A pointer to a session object to be used for the client sl@0: */ sl@0: CSession2* CUsbMassStorageServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const sl@0: { sl@0: TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber); sl@0: sl@0: __PRINT(_L("CUsbMassStorageServer::NewSessionL\n")); sl@0: if (!User::QueryVersionSupported(v, aVersion)) sl@0: User::Leave(KErrNotSupported); sl@0: sl@0: CUsbMassStorageServer* ncThis = const_cast(this); sl@0: sl@0: CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis); sl@0: sl@0: return sess; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Inform the client there has been an error. sl@0: sl@0: @param aError The error that has occurred sl@0: */ sl@0: void CUsbMassStorageServer::Error(TInt aError) sl@0: { sl@0: __PRINT1(_L("CUsbMassStorageServer::Error [aError=%d]\n"), aError); sl@0: sl@0: Message().Complete(aError); sl@0: ReStart(); sl@0: } sl@0: sl@0: /** sl@0: Increment the open session count (iSessionCount) by one. sl@0: sl@0: @post the number of open sessions is incremented by one sl@0: */ sl@0: void CUsbMassStorageServer::IncrementSessionCount() sl@0: { sl@0: __PRINT1(_L("CUsbMassStorageServer::IncrementSessionCount %d\n"), iSessionCount); sl@0: __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC)); sl@0: sl@0: ++iSessionCount; sl@0: sl@0: __PRINT(_L("CUsbMassStorageServer::IncrementSessionCount\n")); sl@0: } sl@0: sl@0: /** sl@0: Decrement the open session count (iSessionCount) by one. sl@0: sl@0: @post the number of open sessions is decremented by one sl@0: */ sl@0: void CUsbMassStorageServer::DecrementSessionCount() sl@0: { sl@0: __PRINT1(_L("CUsbMassStorageServer::DecrementSessionCount %d\n"), iSessionCount); sl@0: sl@0: __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC)); sl@0: sl@0: --iSessionCount; sl@0: } sl@0: