equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
28 #include "msmmterminator.h" |
28 #include "msmmterminator.h" |
29 #include "msmmdismountusbdrives.h" |
29 #include "msmmdismountusbdrives.h" |
30 |
30 |
31 #include <usb/hostms/msmmpolicypluginbase.h> |
31 #include <usb/hostms/msmmpolicypluginbase.h> |
32 #include <usb/usblogger.h> |
32 #include <usb/usblogger.h> |
33 |
33 #include "OstTraceDefinitions.h" |
34 #ifdef __FLOG_ACTIVE |
34 #ifdef OST_TRACE_COMPILER_IN_USE |
35 _LIT8(KLogComponent, "UsbHostMsmmServer"); |
35 #include "msmmserverTraces.h" |
36 #endif |
36 #endif |
|
37 |
37 |
38 |
38 // Static public functions |
39 // Static public functions |
39 TInt CMsmmServer::ThreadFunction() |
40 TInt CMsmmServer::ThreadFunction() |
40 { |
41 { |
41 TInt ret = KErrNone; |
42 TInt ret = KErrNone; |
43 __UHEAP_MARK; |
44 __UHEAP_MARK; |
44 // Create the cleanup stack |
45 // Create the cleanup stack |
45 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
46 CTrapCleanup* cleanupStack = CTrapCleanup::New(); |
46 if (cleanupStack) |
47 if (cleanupStack) |
47 { |
48 { |
48 #ifdef __FLOG_ACTIVE |
|
49 (void)CUsbLog::Connect(); |
|
50 #endif |
|
51 |
|
52 TRAP(ret, ThreadFunctionL()); |
49 TRAP(ret, ThreadFunctionL()); |
53 |
|
54 #ifdef __FLOG_ACTIVE |
|
55 CUsbLog::Close(); |
|
56 #endif |
|
57 |
50 |
58 delete cleanupStack; |
51 delete cleanupStack; |
59 } |
52 } |
60 else |
53 else |
61 { |
54 { |
66 return ret; |
59 return ret; |
67 } |
60 } |
68 |
61 |
69 void CMsmmServer::ThreadFunctionL() |
62 void CMsmmServer::ThreadFunctionL() |
70 { |
63 { |
71 LOG_STATIC_FUNC_ENTRY |
64 OstTraceFunctionEntry0( CMSMMSERVER_THREADFUNCTIONL_ENTRY ); |
72 |
65 |
73 TSecureId creatorSID = User::CreatorSecureId(); |
66 TSecureId creatorSID = User::CreatorSecureId(); |
74 if (KFDFWSecureId != creatorSID) |
67 if (KFDFWSecureId != creatorSID) |
75 { |
68 { |
76 // Only FDF process can be the creator of the MSMM server |
69 // Only FDF process can be the creator of the MSMM server |
94 // request messages from clients. |
87 // request messages from clients. |
95 CActiveScheduler::Start(); |
88 CActiveScheduler::Start(); |
96 |
89 |
97 // Free the server and active scheduler. |
90 // Free the server and active scheduler. |
98 CleanupStack::PopAndDestroy(2, scheduler); |
91 CleanupStack::PopAndDestroy(2, scheduler); |
|
92 OstTraceFunctionExit0( CMSMMSERVER_THREADFUNCTIONL_EXIT ); |
99 } |
93 } |
100 |
94 |
101 CPolicyServer::TCustomResult CMsmmServer::CustomSecurityCheckL( |
95 CPolicyServer::TCustomResult CMsmmServer::CustomSecurityCheckL( |
102 const RMessage2& aMsg, |
96 const RMessage2& aMsg, |
103 TInt& /*aAction*/, |
97 TInt& /*aAction*/, |
120 |
114 |
121 // Public functions |
115 // Public functions |
122 // Construction and destruction |
116 // Construction and destruction |
123 CMsmmServer* CMsmmServer::NewLC() |
117 CMsmmServer* CMsmmServer::NewLC() |
124 { |
118 { |
125 LOG_STATIC_FUNC_ENTRY |
119 OstTraceFunctionEntry0( CMSMMSERVER_NEWLC_ENTRY ); |
|
120 |
126 CMsmmServer* self = new (ELeave) CMsmmServer(EPriorityHigh); |
121 CMsmmServer* self = new (ELeave) CMsmmServer(EPriorityHigh); |
127 CleanupStack::PushL(self); |
122 CleanupStack::PushL(self); |
128 |
123 |
129 // Create a server with unique server name |
124 // Create a server with unique server name |
130 self->StartL(KMsmmServerName); |
125 self->StartL(KMsmmServerName); |
131 self->ConstructL(); |
126 self->ConstructL(); |
132 |
127 |
|
128 OstTraceFunctionExit0( CMSMMSERVER_NEWLC_EXIT ); |
133 return self; |
129 return self; |
134 } |
130 } |
135 |
131 |
136 CMsmmServer::~CMsmmServer() |
132 CMsmmServer::~CMsmmServer() |
137 { |
133 { |
138 LOG_FUNC |
134 OstTraceFunctionEntry0( CMSMMSERVER_CMSMMSERVER_DES_ENTRY ); |
|
135 |
139 delete iPolicyPlugin; |
136 delete iPolicyPlugin; |
140 delete iEventQueue; |
137 delete iEventQueue; |
141 delete iEngine; |
138 delete iEngine; |
142 delete iTerminator; |
139 delete iTerminator; |
143 delete iDismountErrData; |
140 delete iDismountErrData; |
146 |
143 |
147 #ifndef __OVER_DUMMYCOMPONENT__ |
144 #ifndef __OVER_DUMMYCOMPONENT__ |
148 iFs.RemoveProxyDrive(KPROXYDRIVENAME); |
145 iFs.RemoveProxyDrive(KPROXYDRIVENAME); |
149 iFs.Close(); |
146 iFs.Close(); |
150 #endif |
147 #endif |
|
148 OstTraceFunctionExit0( CMSMMSERVER_CMSMMSERVER_DES_EXIT ); |
151 } |
149 } |
152 |
150 |
153 // CMsmmServer APIs |
151 // CMsmmServer APIs |
154 CSession2* CMsmmServer::NewSessionL(const TVersion& aVersion, |
152 CSession2* CMsmmServer::NewSessionL(const TVersion& aVersion, |
155 const RMessage2& aMessage) const |
153 const RMessage2& aMessage) const |
156 { |
154 { |
157 LOG_FUNC |
155 OstTraceFunctionEntry0( CMSMMSERVER_NEWSESSIONL_ENTRY ); |
158 |
156 |
159 if (KMaxClientCount <= SessionNumber()) |
157 if (KMaxClientCount <= SessionNumber()) |
160 { |
158 { |
161 // There is a connection to MSMM server already. |
159 // There is a connection to MSMM server already. |
162 // Currently design of MSMM can have two clients, one FDF and the other Indicator UI |
160 // Currently design of MSMM can have two clients, one FDF and the other Indicator UI |
163 // at any time. |
161 // at any time. |
164 User::Leave(KErrInUse); |
162 User::Leave(KErrInUse); |
165 } |
163 } |
166 |
164 |
167 // Check the client-side API version number against the server version |
165 // Check the client-side API version number against the server version |
180 return CMsmmSession::NewL(*(const_cast<CMsmmServer*>(this)), *iEventQueue); |
178 return CMsmmSession::NewL(*(const_cast<CMsmmServer*>(this)), *iEventQueue); |
181 } |
179 } |
182 |
180 |
183 TInt CMsmmServer::SessionNumber() const |
181 TInt CMsmmServer::SessionNumber() const |
184 { |
182 { |
185 LOG_FUNC |
183 OstTraceFunctionEntry0( CMSMMSERVER_SESSIONNUMBER_ENTRY ); |
186 |
|
187 return iNumSessions; |
184 return iNumSessions; |
188 } |
185 } |
189 |
186 |
190 void CMsmmServer::AddSession() |
187 void CMsmmServer::AddSession() |
191 { |
188 { |
192 LOG_FUNC |
189 OstTraceFunctionEntry0( CMSMMSERVER_ADDSESSION_ENTRY ); |
193 |
190 |
194 ++iNumSessions; |
191 ++iNumSessions; |
195 iTerminator->Cancel(); |
192 iTerminator->Cancel(); |
|
193 OstTraceFunctionExit0( CMSMMSERVER_ADDSESSION_EXIT ); |
196 } |
194 } |
197 |
195 |
198 void CMsmmServer::RemoveSession() |
196 void CMsmmServer::RemoveSession() |
199 { |
197 { |
200 LOG_FUNC |
198 OstTraceFunctionEntry0( CMSMMSERVER_REMOVESESSION_ENTRY ); |
201 |
199 |
202 --iNumSessions; |
200 --iNumSessions; |
203 if (iNumSessions == 0) |
201 if (iNumSessions == 0) |
204 { |
202 { |
205 // Discard all pending adding interface events from queue |
203 // Discard all pending adding interface events from queue |
207 // handled in it. |
205 // handled in it. |
208 iEventQueue->Finalize(); |
206 iEventQueue->Finalize(); |
209 iTerminator->Cancel(); |
207 iTerminator->Cancel(); |
210 iTerminator->Start(); |
208 iTerminator->Start(); |
211 } |
209 } |
212 } |
210 |
213 |
211 OstTraceFunctionExit0( CMSMMSERVER_REMOVESESSION_EXIT ); |
214 void CMsmmServer::DismountUsbDrivesL(TUSBMSDeviceDescription& aDevice) |
212 } |
215 { |
213 |
216 LOG_FUNC |
214 void CMsmmServer::DismountUsbDrivesL(TUSBMSDeviceDescription& aDevice) |
|
215 { |
|
216 OstTraceFunctionEntry0( CMSMMSERVER_DISMOUNTUSBDRIVERSL_ENTRY ); |
217 delete iDismountManager; |
217 delete iDismountManager; |
218 iDismountManager = NULL; |
218 iDismountManager = NULL; |
219 iDismountManager= CMsmmDismountUsbDrives::NewL(); |
219 iDismountManager= CMsmmDismountUsbDrives::NewL(); |
220 |
220 |
221 //Also notify the MSMM plugin of beginning of dismounting |
221 //Also notify the MSMM plugin of beginning of dismounting |
227 |
227 |
228 TRAP_IGNORE(iPolicyPlugin->SendErrorNotificationL(*iDismountErrData)); |
228 TRAP_IGNORE(iPolicyPlugin->SendErrorNotificationL(*iDismountErrData)); |
229 |
229 |
230 // Start dismounting |
230 // Start dismounting |
231 iDismountManager->DismountUsbDrives(*iPolicyPlugin, aDevice); |
231 iDismountManager->DismountUsbDrives(*iPolicyPlugin, aDevice); |
232 } |
232 OstTraceFunctionExit0( CMSMMSERVER_DISMOUNTUSBDRIVERSL_EXIT ); |
|
233 } |
|
234 |
233 |
235 |
234 // Private functions |
236 // Private functions |
235 // CMsmmServer Construction |
237 // CMsmmServer Construction |
236 CMsmmServer::CMsmmServer(TInt aPriority) |
238 CMsmmServer::CMsmmServer(TInt aPriority) |
237 :CPolicyServer(aPriority, KMsmmServerSecurityPolicy, EUnsharableSessions) |
239 :CPolicyServer(aPriority, KMsmmServerSecurityPolicy, EUnsharableSessions) |
238 { |
240 { |
239 LOG_FUNC |
241 OstTraceFunctionEntry0( CMSMMSERVER_CMSMMSERVER_CONS_ENTRY ); |
240 // |
|
241 } |
242 } |
242 |
243 |
243 void CMsmmServer::ConstructL() |
244 void CMsmmServer::ConstructL() |
244 { |
245 { |
245 LOG_FUNC |
246 OstTraceFunctionEntry0( CMSMMSERVER_CONSTRUCTL_ENTRY ); |
246 |
247 |
247 iEngine = CMsmmEngine::NewL(); |
248 iEngine = CMsmmEngine::NewL(); |
248 iEventQueue = CDeviceEventQueue::NewL(*this); |
249 iEventQueue = CDeviceEventQueue::NewL(*this); |
249 iTerminator = CMsmmTerminator::NewL(*iEventQueue); |
250 iTerminator = CMsmmTerminator::NewL(*iEventQueue); |
250 iPolicyPlugin = CMsmmPolicyPluginBase::NewL(); |
251 iPolicyPlugin = CMsmmPolicyPluginBase::NewL(); |
267 } |
268 } |
268 #endif |
269 #endif |
269 |
270 |
270 // Start automatic shutdown timer |
271 // Start automatic shutdown timer |
271 iTerminator->Start(); |
272 iTerminator->Start(); |
|
273 OstTraceFunctionExit0( CMSMMSERVER_CONSTRUCTL_EXIT ); |
272 } |
274 } |
273 |
275 |
274 // End of file |
276 // End of file |