19 @file |
19 @file |
20 @internalComponent |
20 @internalComponent |
21 */ |
21 */ |
22 |
22 |
23 #include "msmmserver.h" |
23 #include "msmmserver.h" |
|
24 #include <usb/hostms/msmmpolicypluginbase.h> |
24 #include "msmm_internal_def.h" |
25 #include "msmm_internal_def.h" |
25 #include "msmmsession.h" |
26 #include "msmmsession.h" |
26 #include "msmmengine.h" |
27 #include "msmmengine.h" |
27 #include "eventqueue.h" |
28 #include "eventqueue.h" |
28 #include "msmmterminator.h" |
29 #include "msmmterminator.h" |
29 #include "msmmdismountusbdrives.h" |
30 |
30 |
|
31 #include <usb/hostms/msmmpolicypluginbase.h> |
|
32 #include <usb/usblogger.h> |
31 #include <usb/usblogger.h> |
33 #include "OstTraceDefinitions.h" |
32 |
34 #ifdef OST_TRACE_COMPILER_IN_USE |
33 #ifdef __FLOG_ACTIVE |
35 #include "msmmserverTraces.h" |
34 _LIT8(KLogComponent, "UsbHostMsmmServer"); |
36 #endif |
35 #endif |
37 |
|
38 |
36 |
39 // Static public functions |
37 // Static public functions |
40 TInt CMsmmServer::ThreadFunction() |
38 TInt CMsmmServer::ThreadFunction() |
41 { |
39 { |
42 TInt ret = KErrNone; |
40 TInt ret = KErrNone; |
87 // request messages from clients. |
93 // request messages from clients. |
88 CActiveScheduler::Start(); |
94 CActiveScheduler::Start(); |
89 |
95 |
90 // Free the server and active scheduler. |
96 // Free the server and active scheduler. |
91 CleanupStack::PopAndDestroy(2, scheduler); |
97 CleanupStack::PopAndDestroy(2, scheduler); |
92 OstTraceFunctionExit0( CMSMMSERVER_THREADFUNCTIONL_EXIT ); |
98 } |
93 } |
|
94 |
|
95 CPolicyServer::TCustomResult CMsmmServer::CustomSecurityCheckL( |
|
96 const RMessage2& aMsg, |
|
97 TInt& /*aAction*/, |
|
98 TSecurityInfo& /*aMissing*/) |
|
99 { |
|
100 CPolicyServer::TCustomResult returnValue = CPolicyServer::EFail; |
|
101 |
|
102 TSecureId ClientSID = aMsg.SecureId(); |
|
103 |
|
104 if (KFDFWSecureId == ClientSID) |
|
105 { |
|
106 returnValue = CPolicyServer::EPass; |
|
107 } |
|
108 else if ((KSidHbDeviceDialogAppServer == ClientSID) && SessionNumber() > 0) |
|
109 { |
|
110 returnValue = CPolicyServer::EPass; |
|
111 } |
|
112 return returnValue; |
|
113 } |
|
114 |
99 |
115 // Public functions |
100 // Public functions |
116 // Construction and destruction |
101 // Construction and destruction |
117 CMsmmServer* CMsmmServer::NewLC() |
102 CMsmmServer* CMsmmServer::NewLC() |
118 { |
103 { |
119 OstTraceFunctionEntry0( CMSMMSERVER_NEWLC_ENTRY ); |
104 LOG_STATIC_FUNC_ENTRY |
120 |
|
121 CMsmmServer* self = new (ELeave) CMsmmServer(EPriorityHigh); |
105 CMsmmServer* self = new (ELeave) CMsmmServer(EPriorityHigh); |
122 CleanupStack::PushL(self); |
106 CleanupStack::PushL(self); |
123 |
107 |
124 // Create a server with unique server name |
108 // Create a server with unique server name |
125 self->StartL(KMsmmServerName); |
109 self->StartL(KMsmmServerName); |
126 self->ConstructL(); |
110 self->ConstructL(); |
127 |
111 |
128 OstTraceFunctionExit0( CMSMMSERVER_NEWLC_EXIT ); |
|
129 return self; |
112 return self; |
130 } |
113 } |
131 |
114 |
132 CMsmmServer::~CMsmmServer() |
115 CMsmmServer::~CMsmmServer() |
133 { |
116 { |
134 OstTraceFunctionEntry0( CMSMMSERVER_CMSMMSERVER_DES_ENTRY ); |
117 LOG_FUNC |
135 |
|
136 delete iPolicyPlugin; |
118 delete iPolicyPlugin; |
137 delete iEventQueue; |
119 delete iEventQueue; |
138 delete iEngine; |
120 delete iEngine; |
139 delete iTerminator; |
121 delete iTerminator; |
140 delete iDismountErrData; |
|
141 delete iDismountManager; |
|
142 REComSession::FinalClose(); |
122 REComSession::FinalClose(); |
143 |
123 |
144 #ifndef __OVER_DUMMYCOMPONENT__ |
124 #ifndef __OVER_DUMMYCOMPONENT__ |
145 iFs.RemoveProxyDrive(KPROXYDRIVENAME); |
125 iFs.RemoveProxyDrive(KPROXYDRIVENAME); |
146 iFs.Close(); |
126 iFs.Close(); |
147 #endif |
127 #endif |
148 OstTraceFunctionExit0( CMSMMSERVER_CMSMMSERVER_DES_EXIT ); |
|
149 } |
128 } |
150 |
129 |
151 // CMsmmServer APIs |
130 // CMsmmServer APIs |
152 CSession2* CMsmmServer::NewSessionL(const TVersion& aVersion, |
131 CSession2* CMsmmServer::NewSessionL(const TVersion& aVersion, |
153 const RMessage2& aMessage) const |
132 const RMessage2& aMessage) const |
154 { |
133 { |
155 OstTraceFunctionEntry0( CMSMMSERVER_NEWSESSIONL_ENTRY ); |
134 LOG_FUNC |
156 |
135 |
157 if (KMaxClientCount <= SessionNumber()) |
136 if (KMaxClientCount <= SessionNumber()) |
158 { |
137 { |
159 // There is a connection to MSMM server already. |
138 // There is a connection to MSMM server already. |
160 // Currently design of MSMM can have two clients, one FDF and the other Indicator UI |
139 // Currently design of MSMM allows only one activated client |
161 // at any time. |
140 // at any time. |
162 User::Leave(KErrInUse); |
141 User::Leave(KErrInUse); |
163 } |
142 } |
164 |
143 |
165 // Check the client-side API version number against the server version |
144 // Check the client-side API version number against the server version |
178 return CMsmmSession::NewL(*(const_cast<CMsmmServer*>(this)), *iEventQueue); |
157 return CMsmmSession::NewL(*(const_cast<CMsmmServer*>(this)), *iEventQueue); |
179 } |
158 } |
180 |
159 |
181 TInt CMsmmServer::SessionNumber() const |
160 TInt CMsmmServer::SessionNumber() const |
182 { |
161 { |
183 OstTraceFunctionEntry0( CMSMMSERVER_SESSIONNUMBER_ENTRY ); |
162 LOG_FUNC |
|
163 |
184 return iNumSessions; |
164 return iNumSessions; |
185 } |
165 } |
186 |
166 |
187 void CMsmmServer::AddSession() |
167 void CMsmmServer::AddSession() |
188 { |
168 { |
189 OstTraceFunctionEntry0( CMSMMSERVER_ADDSESSION_ENTRY ); |
169 LOG_FUNC |
190 |
170 |
191 ++iNumSessions; |
171 ++iNumSessions; |
192 iTerminator->Cancel(); |
172 iTerminator->Cancel(); |
193 OstTraceFunctionExit0( CMSMMSERVER_ADDSESSION_EXIT ); |
|
194 } |
173 } |
195 |
174 |
196 void CMsmmServer::RemoveSession() |
175 void CMsmmServer::RemoveSession() |
197 { |
176 { |
198 OstTraceFunctionEntry0( CMSMMSERVER_REMOVESESSION_ENTRY ); |
177 LOG_FUNC |
199 |
178 |
200 --iNumSessions; |
179 --iNumSessions; |
201 if (iNumSessions == 0) |
180 if (iNumSessions == 0) |
202 { |
181 { |
203 // Discard all pending adding interface events from queue |
182 // Discard all pending adding interface events from queue |
205 // handled in it. |
184 // handled in it. |
206 iEventQueue->Finalize(); |
185 iEventQueue->Finalize(); |
207 iTerminator->Cancel(); |
186 iTerminator->Cancel(); |
208 iTerminator->Start(); |
187 iTerminator->Start(); |
209 } |
188 } |
210 |
189 } |
211 OstTraceFunctionExit0( CMSMMSERVER_REMOVESESSION_EXIT ); |
|
212 } |
|
213 |
|
214 void CMsmmServer::DismountUsbDrivesL(TUSBMSDeviceDescription& aDevice) |
|
215 { |
|
216 OstTraceFunctionEntry0( CMSMMSERVER_DISMOUNTUSBDRIVERSL_ENTRY ); |
|
217 delete iDismountManager; |
|
218 iDismountManager = NULL; |
|
219 iDismountManager= CMsmmDismountUsbDrives::NewL(); |
|
220 |
|
221 //Also notify the MSMM plugin of beginning of dismounting |
|
222 iDismountErrData->iError = EHostMsEjectInProgress; |
|
223 iDismountErrData->iE32Error = KErrNone; |
|
224 iDismountErrData->iManufacturerString = aDevice.iManufacturerString; |
|
225 iDismountErrData->iProductString = aDevice.iProductString; |
|
226 iDismountErrData->iDriveName = 0x0; |
|
227 |
|
228 TRAP_IGNORE(iPolicyPlugin->SendErrorNotificationL(*iDismountErrData)); |
|
229 |
|
230 // Start dismounting |
|
231 iDismountManager->DismountUsbDrives(*iPolicyPlugin, aDevice); |
|
232 OstTraceFunctionExit0( CMSMMSERVER_DISMOUNTUSBDRIVERSL_EXIT ); |
|
233 } |
|
234 |
|
235 |
190 |
236 // Private functions |
191 // Private functions |
237 // CMsmmServer Construction |
192 // CMsmmServer Construction |
238 CMsmmServer::CMsmmServer(TInt aPriority) |
193 CMsmmServer::CMsmmServer(TInt aPriority) |
239 :CPolicyServer(aPriority, KMsmmServerSecurityPolicy, EUnsharableSessions) |
194 :CPolicyServer(aPriority, KMsmmServerSecurityPolicy, EUnsharableSessions) |
240 { |
195 { |
241 OstTraceFunctionEntry0( CMSMMSERVER_CMSMMSERVER_CONS_ENTRY ); |
196 LOG_FUNC |
|
197 // |
242 } |
198 } |
243 |
199 |
244 void CMsmmServer::ConstructL() |
200 void CMsmmServer::ConstructL() |
245 { |
201 { |
246 OstTraceFunctionEntry0( CMSMMSERVER_CONSTRUCTL_ENTRY ); |
202 LOG_FUNC |
247 |
203 |
248 iEngine = CMsmmEngine::NewL(); |
204 iEngine = CMsmmEngine::NewL(); |
249 iEventQueue = CDeviceEventQueue::NewL(*this); |
205 iEventQueue = CDeviceEventQueue::NewL(*this); |
250 iTerminator = CMsmmTerminator::NewL(*iEventQueue); |
206 iTerminator = CMsmmTerminator::NewL(*iEventQueue); |
251 iPolicyPlugin = CMsmmPolicyPluginBase::NewL(); |
207 iPolicyPlugin = CMsmmPolicyPluginBase::NewL(); |
252 iDismountErrData = new (ELeave) THostMsErrData; |
|
253 if (!iPolicyPlugin) |
208 if (!iPolicyPlugin) |
254 { |
209 { |
255 // Not any policy plugin implementation available |
210 // Not any policy plugin implementation available |
256 PanicServer(ENoPolicyPlugin); |
211 PanicServer(ENoPolicyPlugin); |
257 } |
212 } |