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 CloseChannel command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "MSatApi.h" |
|
20 #include "MSatUtils.h" |
|
21 #include "MSatBIPUtils.h" |
|
22 #include "MSatUiSession.h" |
|
23 #include "SatSOpcodes.h" |
|
24 #include "MSatSUiClientHandler.h" |
|
25 #include "CCloseChannelHandler.h" |
|
26 #include "SatLog.h" |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CCloseChannelHandler* CCloseChannelHandler::NewL( MSatUtils* aUtils ) |
|
35 { |
|
36 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::NewL calling" ) |
|
37 |
|
38 CCloseChannelHandler* self = new( ELeave ) CCloseChannelHandler; |
|
39 |
|
40 CleanupStack::PushL( self ); |
|
41 self->BaseConstructL( aUtils ); |
|
42 // ConstructL not needed. |
|
43 CleanupStack::Pop( self ); |
|
44 |
|
45 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::NewL exiting" ) |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Destructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CCloseChannelHandler::~CCloseChannelHandler() |
|
54 { |
|
55 LOG( NORMAL, |
|
56 "CLOSECHANNEL: CCloseChannelHandler::~CCloseChannelHandler calling" ) |
|
57 |
|
58 Cancel(); |
|
59 |
|
60 LOG( NORMAL, |
|
61 "CLOSECHANNEL: CCloseChannelHandler::~CCloseChannelHandler exiting" ) |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // From class MSatCommand. |
|
66 // Response from client |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CCloseChannelHandler::ClientResponse() |
|
70 { |
|
71 LOG( NORMAL, |
|
72 "CLOSECHANNEL: CCloseChannelHandler::ClientResponse calling" ) |
|
73 |
|
74 // Send terminal response if closing channel doesn't have to be waited and |
|
75 // it was necessary to wait UI response due to icon response |
|
76 if ( !iWaitHandleCloseCommand && iWaitClientIconResponse ) |
|
77 { |
|
78 // requested icon not shown |
|
79 if ( !iCloseChannelUiRsp.iRequestedIconDisplayed ) |
|
80 { |
|
81 LOG( NORMAL, "CCloseChannelHandler::ClientResponse requested icon\ |
|
82 not shown" ) |
|
83 // Icons are not yet supported |
|
84 iCloseChannelRspData.iGeneralResult = |
|
85 RSat::KSuccessRequestedIconNotDisplayed; |
|
86 } |
|
87 else |
|
88 { |
|
89 LOG( NORMAL, "CCloseChannelHandler::ClientResponse success" ) |
|
90 iCloseChannelRspData.iGeneralResult = RSat::KSuccess; |
|
91 } |
|
92 |
|
93 iCloseChannelRspData.iInfoType = RSat::KNoAdditionalInfo; |
|
94 iCloseChannelRspData.iAdditionalInfo.Zero(); |
|
95 TerminalRsp( RSat::ECloseChannel, iCloseChannelRspPckg ); |
|
96 } |
|
97 |
|
98 iWaitClientIconResponse = EFalse; |
|
99 LOG( NORMAL, |
|
100 "CLOSECHANNEL: CCloseChannelHandler::ClientResponse calling" ) |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // From class CActive. |
|
105 // Cancels the sat request. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CCloseChannelHandler::DoCancel() |
|
109 { |
|
110 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::DoCancel calling" ) |
|
111 |
|
112 iUtils->USatAPI().NotifyCloseChannelCancel(); |
|
113 |
|
114 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::DoCancel exiting" ) |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // From class CSatCommandHandler. |
|
119 // Requests the command notification. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CCloseChannelHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
123 { |
|
124 LOG( NORMAL, |
|
125 "CLOSECHANNEL: CCloseChannelHandler::IssueUSATRequest calling" ) |
|
126 |
|
127 // Reset command data. |
|
128 new (&iCloseChannelData) RSat::TCloseChannelV2(); |
|
129 |
|
130 iUtils->USatAPI().NotifyCloseChannel( aStatus, iCloseChannelPckg ); |
|
131 |
|
132 LOG( NORMAL, |
|
133 "CLOSECHANNEL: CCloseChannelHandler::IssueUSATRequest exiting" ) |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // From class CSatCommandHandler. |
|
138 // Precheck before executing the command. |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TBool CCloseChannelHandler::CommandAllowed() |
|
142 { |
|
143 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::CommandAllowed calling" ) |
|
144 TBool commandAllowed( ETrue ); |
|
145 |
|
146 LOG2( NORMAL, |
|
147 "CLOSECHANNEL: CCloseChannelHandler::CommandAllowed \ |
|
148 iCloseChannelData.iAlphaId.iStatus: %d", |
|
149 iCloseChannelData.iAlphaId.iStatus ) |
|
150 |
|
151 LOG2( NORMAL, |
|
152 "CLOSECHANNEL: CCloseChannelHandler::CommandAllowed \ |
|
153 iCloseChannelData.iIconId.iQualifier: %d", |
|
154 iCloseChannelData.iIconId.iQualifier ) |
|
155 |
|
156 // If icon data without alpha id |
|
157 if ( ( RSat::EAlphaIdProvided != iCloseChannelData.iAlphaId.iStatus ) && |
|
158 ( ( RSat::ESelfExplanatory == |
|
159 iCloseChannelData.iIconId.iQualifier ) || |
|
160 ( RSat::ENotSelfExplanatory == |
|
161 iCloseChannelData.iIconId.iQualifier ) ) ) |
|
162 { |
|
163 commandAllowed = EFalse; |
|
164 iCloseChannelRspData.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
165 iCloseChannelRspData.iInfoType = RSat::KNoAdditionalInfo; |
|
166 iCloseChannelRspData.iAdditionalInfo.Zero(); |
|
167 iCloseChannelRspData.SetPCmdNumber( iCloseChannelData.PCmdNumber() ); |
|
168 TerminalRsp( RSat::ECloseChannel, iCloseChannelRspPckg ); |
|
169 LOG( SIMPLE, |
|
170 "CLOSECHANNEL: CCloseChannelHandler::CommandAllowed \ |
|
171 data not understood" ) |
|
172 } |
|
173 // Set icon command flag whether icon data was received and set qualifier |
|
174 // to no icon id |
|
175 // To be removed when icons are allowed in this command |
|
176 else if ( ( RSat::ESelfExplanatory == |
|
177 iCloseChannelData.iIconId.iQualifier ) || |
|
178 ( RSat::ENotSelfExplanatory == |
|
179 iCloseChannelData.iIconId.iQualifier ) ) |
|
180 { |
|
181 LOG( NORMAL, "CCloseChannelHandler::CommandAllowed set no icon id" ) |
|
182 iIconCommand = ETrue; |
|
183 iCloseChannelData.iIconId.iQualifier = RSat::ENoIconId; |
|
184 } |
|
185 else |
|
186 { |
|
187 LOG( NORMAL, "CCloseChannelHandler::CommandAllowed others" ) |
|
188 iIconCommand = EFalse; |
|
189 } |
|
190 |
|
191 LOG2( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::CommandAllowed \ |
|
192 exiting,commandAllowed: %d", commandAllowed ) |
|
193 return commandAllowed; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // From class CSatCommandHandler. |
|
198 // Need for ui session. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 TBool CCloseChannelHandler::NeedUiSession() |
|
202 { |
|
203 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::NeedUiSession calling" ) |
|
204 |
|
205 // UI is NOT needed in case where AlphaID is provided and it is a NULL |
|
206 const TBool retVal( !( RSat::EAlphaIdNull == |
|
207 iCloseChannelData.iAlphaId.iStatus ) ); |
|
208 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::NeedUiSession calling" ) |
|
209 |
|
210 // Send notification to Mediator client if Cover UI is supported |
|
211 if ( retVal && iUtils->CoverUiSupported() ) |
|
212 { |
|
213 LOG( NORMAL, "CCloseChannelHandler::NeedUiSession CoverUiSupported" ) |
|
214 TSatCommandData medEventData; |
|
215 medEventData.iPCmdNumber = RSat::ECloseChannel; |
|
216 medEventData.iAlphaId = iCloseChannelData.iAlphaId; |
|
217 medEventData.iDuration.iNumOfUnits = KSatDefaultDuration; |
|
218 medEventData.iIconID = iCloseChannelData.iIconId; |
|
219 TSatCommandPckg tPckg( medEventData ); |
|
220 iUtils->RaiseSatEvent( tPckg ); |
|
221 } |
|
222 |
|
223 LOG2( NORMAL, |
|
224 "CLOSECHANNEL: CCloseChannelHandler::NeedUiSession exiting,retVal: %d", |
|
225 retVal ) |
|
226 return retVal; |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // From class CSatCommandHandler. |
|
231 // Called when USAT API notifies that command. |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CCloseChannelHandler::HandleCommand() |
|
235 { |
|
236 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::HandleCommand calling" ) |
|
237 |
|
238 // Notify other's about this command execution. |
|
239 iUtils->NotifyEvent( MSatUtils::ECloseChannelExecuting ); |
|
240 |
|
241 TInt uiError( KErrNone ); |
|
242 |
|
243 // Reset flags |
|
244 iWaitHandleCloseCommand = EFalse; |
|
245 iWaitClientIconResponse = EFalse; |
|
246 |
|
247 // If information indication to the user is needed, show it now. |
|
248 if ( !( RSat::EAlphaIdNull == iCloseChannelData.iAlphaId.iStatus ) ) |
|
249 { |
|
250 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::HandleCommand \ |
|
251 Sending UI Notification" ) |
|
252 iWaitHandleCloseCommand = ETrue; |
|
253 uiError = SendUiNotification(); |
|
254 } |
|
255 LOG2( NORMAL, "CCloseChannelHandler::HandleCommand uiError: %i", |
|
256 uiError ) |
|
257 // Check UI error status |
|
258 if ( KErrNone == uiError ) |
|
259 { |
|
260 // Proceed with the command |
|
261 const TInt channelId( iCloseChannelData.iDestination ); |
|
262 LOG2( NORMAL, |
|
263 "CLOSECHANNEL: CCloseChannelHandler::HandleCommand channelId: %d", |
|
264 channelId ) |
|
265 if ( RSat::KChannel1 > channelId || RSat::KChannel7 < channelId ) |
|
266 { |
|
267 // Create the response IPC package |
|
268 iCloseChannelRspData.SetPCmdNumber( |
|
269 iCloseChannelData.PCmdNumber() ); |
|
270 iCloseChannelRspData.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
271 iCloseChannelRspData.iInfoType = RSat::KNoAdditionalInfo; |
|
272 iCloseChannelRspData.iAdditionalInfo.Zero(); |
|
273 iWaitClientIconResponse = EFalse; |
|
274 } |
|
275 else |
|
276 { |
|
277 // Close the channel |
|
278 const TInt err( iUtils->BipUtils().CloseChannel( channelId ) ); |
|
279 // Create the response IPC package |
|
280 iCloseChannelRspData.SetPCmdNumber( |
|
281 iCloseChannelData.PCmdNumber() ); |
|
282 |
|
283 // Check were the channel close-up success. |
|
284 if ( MSatBIPUtils::ESatBIPSuccess != err ) |
|
285 { |
|
286 LOG2( NORMAL, |
|
287 "CLOSECHANNEL: CCloseChannel::HandleCommand Error %i", err ) |
|
288 iCloseChannelRspData.iGeneralResult = |
|
289 RSat::KBearerIndepProtocolError; |
|
290 iCloseChannelRspData.iInfoType = RSat::KMeProblem; |
|
291 iCloseChannelRspData.iAdditionalInfo.SetLength( 1 ); |
|
292 iCloseChannelRspData.iAdditionalInfo[0] = |
|
293 static_cast<TUint8> ( err ); |
|
294 iWaitClientIconResponse = EFalse; |
|
295 } |
|
296 else |
|
297 { |
|
298 LOG( NORMAL, |
|
299 "CLOSECHANNEL: CCloseChannel::HandleCommand success") |
|
300 LOG2( NORMAL, |
|
301 "CLOSECHANNEL: CCloseChannel::HandleCommand \ |
|
302 iCloseChannelUiRsp.iRequestedIconDisplayed: %i", |
|
303 iCloseChannelUiRsp.iRequestedIconDisplayed ) |
|
304 |
|
305 LOG2( NORMAL, |
|
306 "CLOSECHANNEL: CCloseChannel::HandleCommand \ |
|
307 iCloseChannelData.iIconId.iQualifier: %i", |
|
308 iCloseChannelData.iIconId.iQualifier ) |
|
309 // requested icon not shown |
|
310 if ( !iCloseChannelUiRsp.iRequestedIconDisplayed && |
|
311 ( ( RSat::ENotSelfExplanatory == |
|
312 iCloseChannelData.iIconId.iQualifier ) || |
|
313 ( RSat::ESelfExplanatory == |
|
314 iCloseChannelData.iIconId.iQualifier ) ) ) |
|
315 { |
|
316 // Icons could not be shown |
|
317 iCloseChannelRspData.iGeneralResult = |
|
318 RSat::KSuccessRequestedIconNotDisplayed; |
|
319 } |
|
320 else |
|
321 { |
|
322 iCloseChannelRspData.iGeneralResult = RSat::KSuccess; |
|
323 } |
|
324 |
|
325 // No additional info for CloseChannel |
|
326 iCloseChannelRspData.iInfoType = RSat::KNoAdditionalInfo; |
|
327 iCloseChannelRspData.iAdditionalInfo.Zero(); |
|
328 } |
|
329 } |
|
330 |
|
331 iWaitHandleCloseCommand = EFalse; |
|
332 |
|
333 // If command had icon data and was done succesfully, report that icon |
|
334 // was not shown |
|
335 // To be removed when icons are allowed in this command |
|
336 if ( ( RSat::KSuccess == iCloseChannelRspData.iGeneralResult ) && |
|
337 iIconCommand ) |
|
338 { |
|
339 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::\ |
|
340 HandleCommand requested icon not shown" ) |
|
341 iCloseChannelRspData.iGeneralResult = |
|
342 RSat::KSuccessRequestedIconNotDisplayed; |
|
343 } |
|
344 |
|
345 // Send terminal response if UI response doesn't have to be waited |
|
346 if ( !iWaitClientIconResponse ) |
|
347 { |
|
348 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::\ |
|
349 HandleCommand send terminal response" ) |
|
350 TerminalRsp( RSat::ECloseChannel, iCloseChannelRspPckg ); |
|
351 } |
|
352 } |
|
353 |
|
354 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::HandleCommand exiting" ) |
|
355 } |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // From class CSatCommandHandler. |
|
359 // Indicates the failure of launching ui client. |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 void CCloseChannelHandler::UiLaunchFailed() |
|
363 { |
|
364 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::UiLaunchFailed calling" ) |
|
365 |
|
366 iCloseChannelRspData.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
367 iCloseChannelRspData.iInfoType = RSat::KMeProblem; |
|
368 iCloseChannelRspData.iAdditionalInfo.SetLength( 1 ); |
|
369 iCloseChannelRspData.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
370 iCloseChannelRspData.SetPCmdNumber( iCloseChannelData.PCmdNumber() ); |
|
371 TerminalRsp( RSat::ECloseChannel, iCloseChannelRspPckg ); |
|
372 |
|
373 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::UiLaunchFailed exiting" ) |
|
374 } |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // C++ default constructor can NOT contain any code, that |
|
378 // might leave. |
|
379 // ----------------------------------------------------------------------------- |
|
380 // |
|
381 //lint -e{1403, 1769} Can not be initialized. |
|
382 CCloseChannelHandler::CCloseChannelHandler() : |
|
383 CSatCommandHandler(), |
|
384 iCloseChannelData(), |
|
385 iCloseChannelPckg( iCloseChannelData ), |
|
386 iCloseChannelRspData(), |
|
387 iCloseChannelRspPckg( iCloseChannelRspData ), |
|
388 iCloseChannelUiData(), |
|
389 iCloseChannelUiPckg( iCloseChannelUiData ), |
|
390 iCloseChannelUiRsp(), |
|
391 iCloseChannelUiRspPckg( iCloseChannelUiRsp ), |
|
392 iWaitHandleCloseCommand( EFalse ), |
|
393 iWaitClientIconResponse( EFalse ), |
|
394 // To be removed when icons are allowed in this command |
|
395 iIconCommand( EFalse ) |
|
396 { |
|
397 LOG( NORMAL, "CLOSECHANNEL: CCloseChannelHandler::CCloseChannelHandler \ |
|
398 calling - exiting" ) |
|
399 } |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // Sends notification to UI. |
|
403 // ----------------------------------------------------------------------------- |
|
404 // |
|
405 TInt CCloseChannelHandler::SendUiNotification() |
|
406 { |
|
407 LOG( NORMAL, |
|
408 "CloseChannel: CCloseChannelHandler::SendUiNotification calling" ) |
|
409 |
|
410 // Register to ui service request |
|
411 TRAPD( uiError, iUtils->RegisterServiceRequestL( |
|
412 ESatSProactiveNotification, |
|
413 ESatSProactiveNotificationResponse, |
|
414 this ) ); |
|
415 LOG2( NORMAL, "CCloseChannelHandler::SendUiNotification uiError: %i", |
|
416 uiError ) |
|
417 if ( KErrNone != uiError ) |
|
418 { |
|
419 // Send error terminal response |
|
420 UiLaunchFailed(); |
|
421 } |
|
422 else |
|
423 { |
|
424 // Create IPC data to UI |
|
425 iCloseChannelUiData.iCommand = ESatSCloseChannelNotify; |
|
426 iCloseChannelUiData.iText = iCloseChannelData.iAlphaId.iAlphaId; |
|
427 iCloseChannelUiData.iIconId.iIdentifier |
|
428 = iCloseChannelData.iIconId.iIdentifier; |
|
429 |
|
430 // Define icon qualifier |
|
431 if ( RSat::ENotSelfExplanatory == |
|
432 iCloseChannelData.iIconId.iQualifier ) |
|
433 { |
|
434 LOG( NORMAL, "CloseChannel: CCloseChannelHandler::\ |
|
435 SendUiNotification ENotSelfExplanatory" ) |
|
436 iCloseChannelUiData.iIconId.iIconQualifier = |
|
437 ESatNotSelfExplanatory; |
|
438 // Terminal response may be only when UI has resposed |
|
439 iWaitClientIconResponse = ETrue; |
|
440 } |
|
441 else if ( RSat::ESelfExplanatory == |
|
442 iCloseChannelData.iIconId.iQualifier ) |
|
443 { |
|
444 LOG( NORMAL, "CloseChannel: CCloseChannelHandler::\ |
|
445 SendUiNotification ESelfExplanatory" ) |
|
446 iCloseChannelUiData.iIconId.iIconQualifier = ESatSelfExplanatory; |
|
447 // Terminal response may be only when UI has resposed |
|
448 iWaitClientIconResponse = ETrue; |
|
449 } |
|
450 else // Icon qualifier not present |
|
451 { |
|
452 LOG( NORMAL, "CloseChannel: CCloseChannelHandler::\ |
|
453 SendUiNotification others" ) |
|
454 iCloseChannelUiData.iIconId.iIconQualifier = ESatENoIconId; |
|
455 } |
|
456 LOG2( NORMAL, "CCloseChannelHandler::SendUiNotification \ |
|
457 iCloseChannelData.iAlphaId.iStatus: %i", |
|
458 iCloseChannelData.iAlphaId.iStatus ) |
|
459 // Define AlphaID status |
|
460 switch ( iCloseChannelData.iAlphaId.iStatus ) |
|
461 { |
|
462 case RSat::EAlphaIdNotPresent: |
|
463 { |
|
464 iCloseChannelUiData.iAlphaIdStatus = ESatAlphaIdNotProvided; |
|
465 break; |
|
466 } |
|
467 |
|
468 case RSat::EAlphaIdProvided: |
|
469 { |
|
470 iCloseChannelUiData.iAlphaIdStatus = ESatAlphaIdNotNull; |
|
471 break; |
|
472 } |
|
473 |
|
474 default: |
|
475 { |
|
476 iCloseChannelUiData.iAlphaIdStatus = ESatAlphaIdNull; |
|
477 break; |
|
478 } |
|
479 } |
|
480 |
|
481 // Send notification to UI |
|
482 MSatUiSession* session = iUtils->SatUiHandler().UiSession(); |
|
483 session->SendCommand( &iCloseChannelUiPckg, |
|
484 &iCloseChannelUiRspPckg, |
|
485 ESatSProactiveNotification ); |
|
486 } |
|
487 |
|
488 LOG( NORMAL, |
|
489 "CloseChannel: CCloseChannelHandler::SendUiNotification exiting" ) |
|
490 return uiError; |
|
491 } |
|