userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmsserver.cpp
changeset 43 96e5fb8b040d
equal deleted inserted replaced
-1:000000000000 43:96e5fb8b040d
       
     1 // Copyright (c) 2008-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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // cusbhostmsderver.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21 */
       
    22 
       
    23 #include <e32svr.h>
       
    24 #include "msctypes.h"
       
    25 #include "shared.h"
       
    26 #include "msgservice.h"
       
    27 #include "usbmshostpanic.h"
       
    28 #include "cusbhostmssession.h"
       
    29 #include "cusbhostmsserver.h"
       
    30 #include "msdebug.h"
       
    31 #include "debug.h"
       
    32 #include "securitypolicy.h"
       
    33 
       
    34 /**
       
    35 Constructs a USB mass storage Server
       
    36 */
       
    37 CUsbHostMsServer* CUsbHostMsServer::NewLC()
       
    38 	{
       
    39     __MSFNSLOG
       
    40 	CUsbHostMsServer* r = new (ELeave) CUsbHostMsServer();
       
    41 	CleanupStack::PushL(r);
       
    42 	r->StartL(KUsbHostMsServerName);
       
    43 	return r;
       
    44 	}
       
    45 
       
    46 /**
       
    47 Destructor
       
    48 */
       
    49 CUsbHostMsServer::~CUsbHostMsServer()
       
    50 	{
       
    51     __MSFNLOG
       
    52     // Intentionally left blank
       
    53 	}
       
    54 
       
    55 
       
    56 /**
       
    57 Constructor
       
    58 */
       
    59 CUsbHostMsServer::CUsbHostMsServer()
       
    60 :   CPolicyServer(EPriorityHigh,KUsbMsServerPolicy, EGlobalSharableSessions)
       
    61 	{
       
    62     __MSFNLOG
       
    63 	}
       
    64 
       
    65 
       
    66 /**
       
    67 Create a new session on this server.
       
    68 
       
    69 @param aVersion Version of client
       
    70 @param aMessage& Not used
       
    71 
       
    72 @return CSession2* A pointer to a session object to be used for the client
       
    73 */
       
    74 CSession2* CUsbHostMsServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
       
    75 	{
       
    76     __MSFNSLOG
       
    77 	TVersion v(KUsbHostMsSrvMajorVersionNumber,
       
    78                KUsbHostMsSrvMinorVersionNumber,
       
    79                KUsbHostMsSrvBuildVersionNumber);
       
    80 	if (!User::QueryVersionSupported(v, aVersion))
       
    81 		User::Leave(KErrNotSupported);
       
    82 
       
    83 	CUsbHostMsServer* ncThis = const_cast<CUsbHostMsServer*>(this);
       
    84 
       
    85 	CUsbHostMsSession* sess = CUsbHostMsSession::NewL(*ncThis);
       
    86 
       
    87 	return sess;
       
    88 	}
       
    89 
       
    90 
       
    91 /**
       
    92 Inform the client there has been an error.
       
    93 
       
    94 @param aError The error that has occurred
       
    95 */
       
    96 void CUsbHostMsServer::Error(TInt aError)
       
    97 	{
       
    98     __MSFNLOG
       
    99 	__HOSTPRINT1(_L("CUsbHostMsServer::Error [aError=%d]\n"), aError);
       
   100 
       
   101 	Message().Complete(aError);
       
   102 	ReStart();
       
   103 	}
       
   104 
       
   105 /**
       
   106 Increment the open session count (iSessionCount) by one.
       
   107 
       
   108 @post The number of open sessions is incremented by one
       
   109 */
       
   110 void CUsbHostMsServer::IncrementSessionCount()
       
   111 	{
       
   112     __MSFNLOG
       
   113 	__HOSTPRINT1(_L("CUsbHostMsServer::IncrementSessionCount %d\n"), iSessionCount);
       
   114 	__ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsHostPanicCat, EUsbMsPanicIllegalIPC));
       
   115 
       
   116 	++iSessionCount;
       
   117 
       
   118 	__HOSTPRINT(_L("CUsbHostMsServer::IncrementSessionCount\n"));
       
   119 	}
       
   120 
       
   121 /**
       
   122 Decrement the open session count (iSessionCount) by one.
       
   123 
       
   124 @post The number of open sessions is decremented by one
       
   125 */
       
   126 void CUsbHostMsServer::DecrementSessionCount()
       
   127 	{
       
   128     __MSFNLOG
       
   129 	__HOSTPRINT1(_L("CUsbHostMsServer::DecrementSessionCount %d\n"), iSessionCount);
       
   130 
       
   131 	__ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsHostPanicCat, EUsbMsPanicIllegalIPC));
       
   132 
       
   133 	--iSessionCount;
       
   134 	}
       
   135