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