os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/cusbmassstorageserver.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/shostmassstorage/testclient/usbtestmsclient/cusbmassstorageserver.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,133 @@
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 +#include "usbmsshared.h"
1.31 +#include "mstypes.h"
1.32 +#include "msctypes.h"
1.33 +#include "usbmsclientpanic.h"
1.34 +#include "cusbmassstorageserver.h"
1.35 +#include "cusbmassstoragesession.h"
1.36 +#include "cusbmassstoragecontroller.h"
1.37 +#include "debug.h"
1.38 +
1.39 +#include "usbmsserversecuritypolicy.h"
1.40 +/**
1.41 + Constructs a USB mass storage Server
1.42 +
1.43 + @return a pointer to CUsbMassStorageServer object
1.44 + */
1.45 +CUsbMassStorageServer* CUsbMassStorageServer::NewLC(CUsbMassStorageController& aController)
1.46 + {
1.47 + CUsbMassStorageServer* r = new (ELeave) CUsbMassStorageServer(aController);
1.48 + CleanupStack::PushL(r);
1.49 + r->StartL(KUsbMsServerName);
1.50 + return r;
1.51 + }
1.52 +
1.53 +/**
1.54 + Destructor
1.55 + */
1.56 +CUsbMassStorageServer::~CUsbMassStorageServer()
1.57 + {
1.58 + // Intentionally left blank
1.59 + }
1.60 +
1.61 +
1.62 +/**
1.63 + Constructor
1.64 +
1.65 + @param aController a USB mass storage controller reference
1.66 + */
1.67 +CUsbMassStorageServer::CUsbMassStorageServer(CUsbMassStorageController& aController)
1.68 + : CPolicyServer(EPriorityHigh,KUsbMsServerPolicy)
1.69 + , iController(aController)
1.70 + {
1.71 + __PRINT(_L("CUsbMassStorageServer::CUsbMassStorageServer\n"));
1.72 + }
1.73 +
1.74 +/**
1.75 + Create a new session on this server
1.76 +
1.77 + @param &aVersion Version of client
1.78 + @return A pointer to a session object to be used for the client
1.79 + */
1.80 +CSession2* CUsbMassStorageServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
1.81 + {
1.82 + TVersion v(KUsbMsSrvMajorVersionNumber,KUsbMsSrvMinorVersionNumber,KUsbMsSrvBuildVersionNumber);
1.83 +
1.84 + __PRINT(_L("CUsbMassStorageServer::NewSessionL\n"));
1.85 + if (!User::QueryVersionSupported(v, aVersion))
1.86 + User::Leave(KErrNotSupported);
1.87 +
1.88 + CUsbMassStorageServer* ncThis = const_cast<CUsbMassStorageServer*>(this);
1.89 +
1.90 + CUsbMassStorageSession* sess = CUsbMassStorageSession::NewL(*ncThis);
1.91 +
1.92 + return sess;
1.93 + }
1.94 +
1.95 +
1.96 +/**
1.97 + Inform the client there has been an error.
1.98 +
1.99 + @param aError The error that has occurred
1.100 + */
1.101 +void CUsbMassStorageServer::Error(TInt aError)
1.102 + {
1.103 + __PRINT1(_L("CUsbMassStorageServer::Error [aError=%d]\n"), aError);
1.104 +
1.105 + Message().Complete(aError);
1.106 + ReStart();
1.107 + }
1.108 +
1.109 +/**
1.110 + Increment the open session count (iSessionCount) by one.
1.111 +
1.112 + @post the number of open sessions is incremented by one
1.113 + */
1.114 +void CUsbMassStorageServer::IncrementSessionCount()
1.115 + {
1.116 + __PRINT1(_L("CUsbMassStorageServer::IncrementSessionCount %d\n"), iSessionCount);
1.117 + __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsClientPanicCat, EUsbMsPanicIllegalIPC));
1.118 +
1.119 + ++iSessionCount;
1.120 +
1.121 + __PRINT(_L("CUsbMassStorageServer::IncrementSessionCount\n"));
1.122 + }
1.123 +
1.124 +/**
1.125 + Decrement the open session count (iSessionCount) by one.
1.126 +
1.127 + @post the number of open sessions is decremented by one
1.128 + */
1.129 +void CUsbMassStorageServer::DecrementSessionCount()
1.130 + {
1.131 + __PRINT1(_L("CUsbMassStorageServer::DecrementSessionCount %d\n"), iSessionCount);
1.132 +
1.133 + __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsClientPanicCat, EUsbMsPanicIllegalIPC));
1.134 +
1.135 + --iSessionCount;
1.136 + }