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