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