userlibandfileserver/fileserver/shostmassstorage/server/src/cusbhostmsserver.cpp
changeset 297 b2826f67641f
parent 31 56f325a607ea
equal deleted inserted replaced
296:94f2adf59133 297:b2826f67641f
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 // cusbhostmsderver.cpp
    14 // cusbhostmsderver.cpp
    15 // 
    15 //
    16 //
    16 //
    17 
    17 
    18 /**
    18 /**
    19  @file
    19  @file
    20  @internalTechnology
    20  @internalTechnology
    25 #include "shared.h"
    25 #include "shared.h"
    26 #include "msgservice.h"
    26 #include "msgservice.h"
    27 #include "usbmshostpanic.h"
    27 #include "usbmshostpanic.h"
    28 #include "cusbhostmssession.h"
    28 #include "cusbhostmssession.h"
    29 #include "cusbhostmsserver.h"
    29 #include "cusbhostmsserver.h"
    30 #include "msdebug.h"
       
    31 #include "debug.h"
       
    32 #include "securitypolicy.h"
    30 #include "securitypolicy.h"
       
    31 
       
    32 #include "OstTraceDefinitions.h"
       
    33 #ifdef OST_TRACE_COMPILER_IN_USE
       
    34 #include "cusbhostmsserverTraces.h"
       
    35 #endif
       
    36 
    33 
    37 
    34 /**
    38 /**
    35 Constructs a USB mass storage Server
    39 Constructs a USB mass storage Server
    36 */
    40 */
    37 CUsbHostMsServer* CUsbHostMsServer::NewLC()
    41 CUsbHostMsServer* CUsbHostMsServer::NewLC()
    38 	{
    42     {
    39     __MSFNSLOG
    43     CUsbHostMsServer* r = new (ELeave) CUsbHostMsServer();
    40 	CUsbHostMsServer* r = new (ELeave) CUsbHostMsServer();
    44     CleanupStack::PushL(r);
    41 	CleanupStack::PushL(r);
    45     r->StartL(KUsbHostMsServerName);
    42 	r->StartL(KUsbHostMsServerName);
    46     return r;
    43 	return r;
    47     }
    44 	}
       
    45 
    48 
    46 /**
    49 /**
    47 Destructor
    50 Destructor
    48 */
    51 */
    49 CUsbHostMsServer::~CUsbHostMsServer()
    52 CUsbHostMsServer::~CUsbHostMsServer()
    50 	{
    53     {
    51     __MSFNLOG
       
    52     // Intentionally left blank
    54     // Intentionally left blank
    53 	}
    55     }
    54 
    56 
    55 
    57 
    56 /**
    58 /**
    57 Constructor
    59 Constructor
    58 */
    60 */
    59 CUsbHostMsServer::CUsbHostMsServer()
    61 CUsbHostMsServer::CUsbHostMsServer()
    60 :   CPolicyServer(EPriorityHigh,KUsbMsServerPolicy, EGlobalSharableSessions)
    62 :   CPolicyServer(EPriorityHigh,KUsbMsServerPolicy, EGlobalSharableSessions)
    61 	{
    63     {
    62     __MSFNLOG
    64     }
    63 	}
       
    64 
    65 
    65 
    66 
    66 /**
    67 /**
    67 Create a new session on this server.
    68 Create a new session on this server.
    68 
    69 
    70 @param aMessage& Not used
    71 @param aMessage& Not used
    71 
    72 
    72 @return CSession2* A pointer to a session object to be used for the client
    73 @return CSession2* A pointer to a session object to be used for the client
    73 */
    74 */
    74 CSession2* CUsbHostMsServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
    75 CSession2* CUsbHostMsServer::NewSessionL(const TVersion &aVersion, const RMessage2& /*aMessage*/) const
    75 	{
    76     {
    76     __MSFNSLOG
    77     TVersion v(KUsbHostMsSrvMajorVersionNumber,
    77 	TVersion v(KUsbHostMsSrvMajorVersionNumber,
       
    78                KUsbHostMsSrvMinorVersionNumber,
    78                KUsbHostMsSrvMinorVersionNumber,
    79                KUsbHostMsSrvBuildVersionNumber);
    79                KUsbHostMsSrvBuildVersionNumber);
    80 	if (!User::QueryVersionSupported(v, aVersion))
    80     if (!User::QueryVersionSupported(v, aVersion))
    81 		User::Leave(KErrNotSupported);
    81         User::Leave(KErrNotSupported);
    82 
    82 
    83 	CUsbHostMsServer* ncThis = const_cast<CUsbHostMsServer*>(this);
    83     CUsbHostMsServer* ncThis = const_cast<CUsbHostMsServer*>(this);
    84 
    84 
    85 	CUsbHostMsSession* sess = CUsbHostMsSession::NewL(*ncThis);
    85     CUsbHostMsSession* sess = CUsbHostMsSession::NewL(*ncThis);
    86 
    86 
    87 	return sess;
    87     return sess;
    88 	}
    88     }
    89 
    89 
    90 
    90 
    91 /**
    91 /**
    92 Inform the client there has been an error.
    92 Inform the client there has been an error.
    93 
    93 
    94 @param aError The error that has occurred
    94 @param aError The error that has occurred
    95 */
    95 */
    96 void CUsbHostMsServer::Error(TInt aError)
    96 void CUsbHostMsServer::Error(TInt aError)
    97 	{
    97     {
    98     __MSFNLOG
    98     OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSSERVER_10,
    99 	__HOSTPRINT1(_L("CUsbHostMsServer::Error [aError=%d]\n"), aError);
    99               "CUsbHostMsServer::Error [aError=%d]\n", aError);
   100 
   100 
   101 	Message().Complete(aError);
   101     Message().Complete(aError);
   102 	ReStart();
   102     ReStart();
   103 	}
   103     }
   104 
   104 
   105 /**
   105 /**
   106 Increment the open session count (iSessionCount) by one.
   106 Increment the open session count (iSessionCount) by one.
   107 
   107 
   108 @post The number of open sessions is incremented by one
   108 @post The number of open sessions is incremented by one
   109 */
   109 */
   110 void CUsbHostMsServer::IncrementSessionCount()
   110 void CUsbHostMsServer::IncrementSessionCount()
   111 	{
   111     {
   112     __MSFNLOG
   112     OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSSERVER_11,
   113 	__HOSTPRINT1(_L("CUsbHostMsServer::IncrementSessionCount %d\n"), iSessionCount);
   113               "CUsbHostMsServer::IncrementSessionCount %d", iSessionCount);
   114 	__ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsHostPanicCat, EUsbMsPanicIllegalIPC));
   114     __ASSERT_DEBUG(iSessionCount >= 0, User::Panic(KUsbMsHostPanicCat, EUsbMsPanicIllegalIPC));
   115 
   115 
   116 	++iSessionCount;
   116     ++iSessionCount;
   117 
   117     }
   118 	__HOSTPRINT(_L("CUsbHostMsServer::IncrementSessionCount\n"));
       
   119 	}
       
   120 
   118 
   121 /**
   119 /**
   122 Decrement the open session count (iSessionCount) by one.
   120 Decrement the open session count (iSessionCount) by one.
   123 
   121 
   124 @post The number of open sessions is decremented by one
   122 @post The number of open sessions is decremented by one
   125 */
   123 */
   126 void CUsbHostMsServer::DecrementSessionCount()
   124 void CUsbHostMsServer::DecrementSessionCount()
   127 	{
   125     {
   128     __MSFNLOG
   126     OstTrace1(TRACE_SHOSTMASSSTORAGE_HOST, CUSBHOSTMSSERVER_12,
   129 	__HOSTPRINT1(_L("CUsbHostMsServer::DecrementSessionCount %d\n"), iSessionCount);
   127               "CUsbHostMsServer::DecrementSessionCount %d", iSessionCount);
   130 
   128 
   131 	__ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsHostPanicCat, EUsbMsPanicIllegalIPC));
   129     __ASSERT_DEBUG(iSessionCount > 0, User::Panic(KUsbMsHostPanicCat, EUsbMsPanicIllegalIPC));
   132 
   130 
   133 	--iSessionCount;
   131     --iSessionCount;
   134 	}
   132     }
   135 
   133