1 /* |
|
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Handles MO ShortMessage Control command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "MSatApi.h" |
|
22 #include "MSatUtils.h" |
|
23 #include "MSatUiSession.h" |
|
24 #include "MSatSUiClientHandler.h" |
|
25 #include "CMoSmControlHandler.h" |
|
26 #include "SatLog.h" |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CMoSmControlHandler::CMoSmControlHandler |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 //lint -e{1403, 1769} Can not be initialized, harmless. |
|
37 CMoSmControlHandler::CMoSmControlHandler() : |
|
38 CSatCommandHandler(), |
|
39 iMoSmControlData(), |
|
40 iMoSmControlPckg( iMoSmControlData ), |
|
41 iMoSmControlSendData(), |
|
42 iMoSmControlSendPckg( iMoSmControlSendData ), |
|
43 iMoSmControlUiRespData(), |
|
44 iMoSmControlUiRespPckg( iMoSmControlUiRespData ) |
|
45 { |
|
46 LOG( SIMPLE, "MOSMCONTROL: \ |
|
47 CMoSmControlHandler::CMoSmControlHandler calling - exiting" ) |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CMoSmControlHandler::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CMoSmControlHandler::ConstructL() |
|
56 { |
|
57 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::ConstructL calling" ) |
|
58 |
|
59 // Register notification observer |
|
60 iUtils->RegisterServiceRequestL( |
|
61 ESatSProactiveNotification, |
|
62 ESatSProactiveNotificationResponse, |
|
63 this ); |
|
64 |
|
65 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::ConstructL exiting" ) |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CMoSmControlHandler::NewL |
|
70 // Two-phased constructor. |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CMoSmControlHandler* CMoSmControlHandler::NewL( MSatUtils* aUtils ) |
|
74 { |
|
75 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::NewL calling" ) |
|
76 |
|
77 CMoSmControlHandler* self = new( ELeave ) CMoSmControlHandler(); |
|
78 |
|
79 CleanupStack::PushL( self ); |
|
80 self->BaseConstructL( aUtils ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 |
|
84 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::NewL exiting" ) |
|
85 return self; |
|
86 } |
|
87 |
|
88 |
|
89 // Destructor |
|
90 CMoSmControlHandler::~CMoSmControlHandler() |
|
91 { |
|
92 LOG( SIMPLE, |
|
93 "MOSMCONTROL: CMoSmControlHandler::~CMoSmControlHandler calling" ) |
|
94 |
|
95 Cancel(); |
|
96 |
|
97 LOG( SIMPLE, |
|
98 "MOSMCONTROL: CMoSmControlHandler::~CMoSmControlHandler exiting" ) |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CMoSmControlHandler::ClientResponse |
|
103 // Handles responses from client. |
|
104 // (other items were commented in a header). |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CMoSmControlHandler::ClientResponse() |
|
108 { |
|
109 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::ClientResponse calling" ) |
|
110 |
|
111 // Start to receive more commands. We have to start again here because |
|
112 // we don't send terminal response, wich does this automatically. |
|
113 Start(); |
|
114 |
|
115 // Inform the system that we are finished executing. If there is proactive |
|
116 // SendSm command pending, it is notified and it continues from here. |
|
117 iUtils->NotifyEvent( MSatUtils::EMoSmControlDone ); |
|
118 |
|
119 // If we launched UI, close it. |
|
120 if ( !iUtils->SatUiHandler().UiLaunchedByUser() ) |
|
121 { |
|
122 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::ClientResponse \ |
|
123 ESimSessionEndCallBack" ) |
|
124 iUtils->NotifyEvent( MSatUtils::ESimSessionEndCallBack ); |
|
125 } |
|
126 |
|
127 else |
|
128 { |
|
129 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::ClientResponse \ |
|
130 EDelaySimSessionEnd" ) |
|
131 // Inform the session that we are done here. |
|
132 iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd ); |
|
133 } |
|
134 |
|
135 // We do not send TerminalResponse to SIM. |
|
136 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::ClientResponse exiting" ) |
|
137 } |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CMoSmControlHandler::DoCancel |
|
141 // Cancels the SAT request |
|
142 // (other items were commented in a header). |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CMoSmControlHandler::DoCancel() |
|
146 { |
|
147 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::DoCancel calling" ) |
|
148 |
|
149 iUtils->USatAPI().NotifyMoSmControlCancel(); |
|
150 |
|
151 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::DoCancel exiting" ) |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CMoSmControlHandler::IssueUSATRequest |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CMoSmControlHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
160 { |
|
161 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::IssueUSATRequest calling" ) |
|
162 |
|
163 // Clear the IPC package. |
|
164 new (&iMoSmControlData) RSat::TMoSmControlV1(); |
|
165 iNeedUiSession = EFalse; |
|
166 |
|
167 iUtils->USatAPI().NotifyMoSmControl( aStatus, iMoSmControlPckg ); |
|
168 |
|
169 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::IssueUSATRequest exiting" ) |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CMoSmControlHandler::CommandAllowed |
|
174 // (other items were commented in a header). |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TBool CMoSmControlHandler::CommandAllowed() |
|
178 { |
|
179 LOG( SIMPLE, |
|
180 "MOSMCONTROL: CMoSmControlHandler::CommandAllowed calling - exiting" ) |
|
181 return ETrue; |
|
182 } |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // CMoSmControlHandler::NeedUiSession |
|
186 // (other items were commented in a header). |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 TBool CMoSmControlHandler::NeedUiSession() |
|
190 { |
|
191 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::NeedUiSession calling" ) |
|
192 // UI is not needed, if control is AllowedWithMod and AlphaId is NULL or |
|
193 // control is Allowed and AlphaId is not provided |
|
194 |
|
195 const RSat::TAlphaIdStatus alphaId( iMoSmControlData.iAlphaId.iStatus ); |
|
196 const RSat::TControlResult control( iMoSmControlData.iResult ); |
|
197 |
|
198 const TBool alphaIdNull( RSat::EAlphaIdNull == alphaId || |
|
199 RSat::EAlphaIdNotSet == alphaId ); |
|
200 |
|
201 const TBool controlAllowed( |
|
202 RSat::EAllowedNoModification == control || |
|
203 RSat::EControlResultNotSet == control ); |
|
204 |
|
205 if ( RSat::EAllowedWithModifications == control && |
|
206 alphaIdNull ) |
|
207 { |
|
208 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::NeedUiSession \ |
|
209 RSat::EAllowedWithModifications == control" ) |
|
210 iNeedUiSession = EFalse; |
|
211 } |
|
212 else if ( controlAllowed && ( RSat::EAlphaIdProvided != alphaId ) ) |
|
213 { |
|
214 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::NeedUiSession \ |
|
215 RSat::EAlphaIdProvided != alphaId" ) |
|
216 iNeedUiSession = EFalse; |
|
217 } |
|
218 else |
|
219 { |
|
220 iNeedUiSession = ETrue; |
|
221 } |
|
222 |
|
223 LOG2( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::NeedUiSession exiting,\ |
|
224 iNeedUiSession:%d", iNeedUiSession ) |
|
225 return iNeedUiSession; |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CMoSmControlHandler::HandleCommand |
|
230 // (other items were commented in a header). |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 void CMoSmControlHandler::HandleCommand() |
|
234 { |
|
235 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::HandleCommand calling" ) |
|
236 |
|
237 // Notify other commands that we are executing. |
|
238 iUtils->NotifyEvent( MSatUtils::EMoSmControlExecuting ); |
|
239 LOG2( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::HandleCommand \ |
|
240 iNeedUiSession:%d", iNeedUiSession ) |
|
241 if ( iNeedUiSession ) |
|
242 { |
|
243 // Clear send data. |
|
244 TSatNotificationV1 temp; |
|
245 iMoSmControlSendData = temp; |
|
246 |
|
247 // Enums to UI related parameters |
|
248 TSatAlphaIdStatus satAlphaIdStatus; |
|
249 TSatControlResult satControlResult; |
|
250 LOG2( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::HandleCommand \ |
|
251 iMoSmControlData.iAlphaId.iStatus:%d", |
|
252 iMoSmControlData.iAlphaId.iStatus ) |
|
253 // Map RSat value |
|
254 switch ( iMoSmControlData.iAlphaId.iStatus ) |
|
255 { |
|
256 case RSat::EAlphaIdProvided : |
|
257 { |
|
258 satAlphaIdStatus = ESatAlphaIdNotNull; |
|
259 break; |
|
260 } |
|
261 |
|
262 case RSat::EAlphaIdNotPresent : |
|
263 { |
|
264 satAlphaIdStatus = ESatAlphaIdNotProvided; |
|
265 break; |
|
266 } |
|
267 |
|
268 // Use this also as a default value |
|
269 case RSat::EAlphaIdNull : |
|
270 case RSat::EAlphaIdNotSet : |
|
271 default : |
|
272 { |
|
273 satAlphaIdStatus = ESatAlphaIdNull; |
|
274 break; |
|
275 } |
|
276 } |
|
277 LOG2( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::HandleCommand \ |
|
278 iMoSmControlData.iResult:%d", iMoSmControlData.iResult ) |
|
279 // Map RSat value |
|
280 switch ( iMoSmControlData.iResult ) |
|
281 { |
|
282 case RSat::ENotAllowed : |
|
283 { |
|
284 satControlResult = ESatNotAllowed; |
|
285 break; |
|
286 } |
|
287 |
|
288 case RSat::EAllowedWithModifications : |
|
289 { |
|
290 satControlResult = ESatAllowedWithModifications; |
|
291 break; |
|
292 } |
|
293 |
|
294 // Use this also as a default value |
|
295 case RSat::EAllowedNoModification : |
|
296 case RSat::EControlResultNotSet : |
|
297 default : |
|
298 { |
|
299 satControlResult = ESatAllowedNoModification; |
|
300 break; |
|
301 } |
|
302 } |
|
303 |
|
304 // Build the IPC package. |
|
305 iMoSmControlSendData.iCommand = ESatSMoSmControlNotify; |
|
306 iMoSmControlSendData.iText = iMoSmControlData.iAlphaId.iAlphaId; |
|
307 iMoSmControlSendData.iAlphaIdStatus = satAlphaIdStatus; |
|
308 iMoSmControlSendData.iControlResult = satControlResult; |
|
309 |
|
310 // Register notification observer |
|
311 TRAPD( regErr, iUtils->RegisterServiceRequestL( |
|
312 ESatSProactiveNotification, |
|
313 ESatSProactiveNotificationResponse, |
|
314 this ) |
|
315 ); // TRAPD |
|
316 LOG2( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::HandleCommand \ |
|
317 regErr:%d", regErr ) |
|
318 // No need to check error value, since we cannot send terminal response |
|
319 // for this command |
|
320 if ( KErrNone == regErr ) |
|
321 { |
|
322 // Get UISession. |
|
323 MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession(); |
|
324 |
|
325 // Send command to SatClient. |
|
326 uiSession->SendCommand( &iMoSmControlSendPckg, |
|
327 &iMoSmControlUiRespPckg, ESatSProactiveNotification ); |
|
328 } |
|
329 } |
|
330 |
|
331 else |
|
332 { |
|
333 // Restart request since we don't get client response |
|
334 Start(); |
|
335 |
|
336 // Inform the system that we are finished executing. If there is |
|
337 // proactive |
|
338 // SendSm command pending, it is notified and it continues from here. |
|
339 iUtils->NotifyEvent( MSatUtils::EMoSmControlDone ); |
|
340 |
|
341 // Inform the session that we are done here. |
|
342 iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd ); |
|
343 } |
|
344 |
|
345 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::HandleCommand exiting" ) |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CMoSmControlHandler::UiLaunchFailed |
|
350 // (other items were commented in a header). |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 void CMoSmControlHandler::UiLaunchFailed() |
|
354 { |
|
355 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::UiLaunchFailed calling" ) |
|
356 |
|
357 // We cannot send terminal response to UICC since it doesn't |
|
358 // expect terminal response from MoSmControl command... |
|
359 |
|
360 // Inform the session that we are done here. |
|
361 iUtils->NotifyEvent( MSatUtils::EDelaySimSessionEnd ); |
|
362 |
|
363 // Start to receive more commands. |
|
364 Start(); |
|
365 |
|
366 LOG( SIMPLE, "MOSMCONTROL: CMoSmControlHandler::UiLaunchFailed exiting" ) |
|
367 } |
|
368 |
|
369 // End of File |
|