os/kernelhwsrv/userlibandfileserver/fileserver/smassstorage/cusbmassstorageserver.cpp
First public contribution.
1 // Copyright (c) 2004-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
24 #include "usbmsshared.h"
25 #include "cusbmassstorageserver.h"
26 #include "cusbmassstoragesession.h"
27 #include "cusbmassstoragecontroller.h"
28 #include "massstoragedebug.h"
30 #include "usbmsserversecuritypolicy.h"
32 Constructs a USB mass storage Server
34 @return a pointer to CUsbMassStorageServer object
36 CUsbMassStorageServer* CUsbMassStorageServer::NewLC(CUsbMassStorageController& aController)
38 CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController);
39 CleanupStack::PushL(r);
40 r->StartL(KUsbMsServerName);
47 CUsbMassStorageServer::~CUsbMassStorageServer()
49 // Intentionally left blank
56 @param aController a USB mass storage controller reference
58 CUsbMassStorageServer::CUsbMassStorageServer(CUsbMassStorageController& aController)
59 : CPolicyServer(EPriorityHigh,KUsbMsServerPolicy)
60 , iController(aController)
62 __PRINT(_L("CUsbMassStorageServer::CUsbMassStorageServer\n"));
66 Create a new session on this server
68 @param &aVersion Version of client
69 @return A pointer to a session object to be used for the client
71 CSession2* CUsbMassStorageServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
73 TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber);
75 __PRINT(_L("CUsbMassStorageServer::NewSessionL\n"));
76 if (!User::QueryVersionSupported(v, aVersion))
77 User::Leave(KErrNotSupported);
79 CUsbMassStorageServer* ncThis = const_cast<CUsbMassStorageServer*>(this);
81 CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis);
88 Inform the client there has been an error.
90 @param aError The error that has occurred
92 void CUsbMassStorageServer::Error(TInt aError)
94 __PRINT1(_L("CUsbMassStorageServer::Error [aError=%d]\n"), aError);
96 Message().Complete(aError);
101 Increment the open session count (iSessionCount) by one.
103 @post the number of open sessions is incremented by one
105 void CUsbMassStorageServer::IncrementSessionCount()
107 __PRINT1(_L("CUsbMassStorageServer::IncrementSessionCount %d\n"), iSessionCount);
108 __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));
112 __PRINT(_L("CUsbMassStorageServer::IncrementSessionCount\n"));
116 Decrement the open session count (iSessionCount) by one.
118 @post the number of open sessions is decremented by one
120 void CUsbMassStorageServer::DecrementSessionCount()
122 __PRINT1(_L("CUsbMassStorageServer::DecrementSessionCount %d\n"), iSessionCount);
124 __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsSvrPncCat, EUsbMsPanicIllegalIPC));