os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/cusbmassstorageserver.cpp
Update contrib.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Implements a Symbian OS server that exposes the RUsbMassStorage API
27 #include "usbmsshared.h"
30 #include "usbmsclientpanic.h"
31 #include "cusbmassstorageserver.h"
32 #include "cusbmassstoragesession.h"
33 #include "cusbmassstoragecontroller.h"
36 #include "usbmsserversecuritypolicy.h"
38 Constructs a USB mass storage Server
40 @return a pointer to CUsbMassStorageServer object
42 CUsbMassStorageServer* CUsbMassStorageServer::NewLC(CUsbMassStorageController& aController)
44 CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController);
45 CleanupStack::PushL(r);
46 r->StartL(KUsbMsServerName);
53 CUsbMassStorageServer::~CUsbMassStorageServer()
55 // Intentionally left blank
62 @param aController a USB mass storage controller reference
64 CUsbMassStorageServer::CUsbMassStorageServer(CUsbMassStorageController& aController)
65 : CPolicyServer(EPriorityHigh,KUsbMsServerPolicy)
66 , iController(aController)
68 __PRINT(_L("CUsbMassStorageServer::CUsbMassStorageServer\n"));
72 Create a new session on this server
74 @param &aVersion Version of client
75 @return A pointer to a session object to be used for the client
77 CSession2* CUsbMassStorageServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
79 TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber);
81 __PRINT(_L("CUsbMassStorageServer::NewSessionL\n"));
82 if (!User::QueryVersionSupported(v, aVersion))
83 User::Leave(KErrNotSupported);
85 CUsbMassStorageServer* ncThis = const_cast<CUsbMassStorageServer*>(this);
87 CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis);
94 Inform the client there has been an error.
96 @param aError The error that has occurred
98 void CUsbMassStorageServer::Error(TInt aError)
100 __PRINT1(_L("CUsbMassStorageServer::Error [aError=%d]\n"), aError);
102 Message().Complete(aError);
107 Increment the open session count (iSessionCount) by one.
109 @post the number of open sessions is incremented by one
111 void CUsbMassStorageServer::IncrementSessionCount()
113 __PRINT1(_L("CUsbMassStorageServer::IncrementSessionCount %d\n"), iSessionCount);
114 __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsClientPanicCat, EUsbMsPanicIllegalIPC));
118 __PRINT(_L("CUsbMassStorageServer::IncrementSessionCount\n"));
122 Decrement the open session count (iSessionCount) by one.
124 @post the number of open sessions is decremented by one
126 void CUsbMassStorageServer::DecrementSessionCount()
128 __PRINT1(_L("CUsbMassStorageServer::DecrementSessionCount %d\n"), iSessionCount);
130 __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsClientPanicCat, EUsbMsPanicIllegalIPC));