|
1 /* |
|
2 * Copyright (c) 2002-2008 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 SendSm command |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "MSatApi.h" |
|
20 #include "MSatUtils.h" |
|
21 #include "MSatSystemState.h" |
|
22 #include "MSatUiSession.h" |
|
23 #include "SatSTypes.h" |
|
24 #include "SatSOpcodes.h" |
|
25 #include "MSatSUiClientHandler.h" |
|
26 #include "CSatSSendMessageNoLoggingHandler.h" |
|
27 #include "CSendSmHandler.h" |
|
28 #include "SatLog.h" |
|
29 #include "gsmerror.h" |
|
30 #include <exterror.h> |
|
31 #include "TSatExtErrorUtils.h" |
|
32 |
|
33 const TUint8 KPlus = 0x2b; // '+' character |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CSendSmHandler* CSendSmHandler::NewL( MSatUtils* aUtils ) |
|
42 { |
|
43 LOG( SIMPLE, "SENDSM: CSendSmHandler::NewL calling" ) |
|
44 |
|
45 CSendSmHandler* self = new( ELeave ) CSendSmHandler; |
|
46 |
|
47 CleanupStack::PushL( self ); |
|
48 self->BaseConstructL( aUtils ); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop( self ); |
|
51 |
|
52 LOG( SIMPLE, "SENDSM: CSendSmHandler::NewL exiting" ) |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // Destructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CSendSmHandler::~CSendSmHandler() |
|
61 { |
|
62 LOG( SIMPLE, "SENDSM: CSendSmHandler::~CSendSmHandler calling" ) |
|
63 |
|
64 delete iMsgSender; |
|
65 Cancel(); |
|
66 |
|
67 LOG( SIMPLE, "SENDSM: CSendSmHandler::~CSendSmHandler exiting" ) |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // From class MSatCommand. |
|
72 // Query response. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CSendSmHandler::ClientResponse() |
|
76 { |
|
77 LOG( SIMPLE, "SENDSM: CSendSmHandler::ClientResponse calling" ) |
|
78 |
|
79 // Query response from client. |
|
80 if ( iQueryRsp.iAccepted && !iNotificationSent ) |
|
81 { |
|
82 LOG( SIMPLE, "SENDSM: CSendSmHandler::ClientResponse Query response" ) |
|
83 // Send notification to UI |
|
84 // Register notification observer |
|
85 TRAP_IGNORE( iUtils->RegisterServiceRequestL( |
|
86 ESatSProactiveNotification, |
|
87 ESatSProactiveNotificationResponse, |
|
88 this ) ) |
|
89 |
|
90 // Get UISession. |
|
91 MSatUiSession* uiSession = iUtils->SatUiHandler().UiSession(); |
|
92 |
|
93 // Send command to SatClient. |
|
94 uiSession->SendCommand( &iNotificationDataPckg, |
|
95 &iNotificationRspPckg, ESatSProactiveNotification ); |
|
96 |
|
97 iNotificationSent = ETrue; |
|
98 } |
|
99 else if ( iNotificationRsp.iAccepted && iNotificationSent ) |
|
100 { |
|
101 LOG( SIMPLE, "SENDSM: CSendSmHandler::ClientResponse get response" ) |
|
102 // Then we can proceed with the msg sending |
|
103 if ( !iMsgSender->IsActive() ) |
|
104 { |
|
105 LOG( SIMPLE, |
|
106 "SENDSM: CSendSmHandler::ClientResponse start iMsgSender" ) |
|
107 iMsgSender->Start( iSendSmData ); |
|
108 } |
|
109 } |
|
110 else |
|
111 { |
|
112 if ( iQueryRsp.iSessionTerminatedByUser ) |
|
113 { |
|
114 LOG( SIMPLE, |
|
115 "SENDSM: CSendSmHandler::ClientResponse close ui session" ) |
|
116 // Next SimSession end will close the ui session |
|
117 iUtils->NotifyEvent( MSatUtils::ESessionTerminatedByUser ); |
|
118 } |
|
119 |
|
120 iSendSmRsp.iGeneralResult = RSat::KPCmdNotAcceptedByUser; |
|
121 iSendSmRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
122 iSendSmRsp.iAdditionalInfo.Zero(); |
|
123 iSendSmRsp.SetPCmdNumber( iSendSmData.PCmdNumber() ); |
|
124 |
|
125 TerminalRsp( RSat::ESendSm, iSendSmRspPckg ); |
|
126 } |
|
127 |
|
128 LOG( SIMPLE, "SENDSM: CSendSmHandler::ClientResponse exiting" ) |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // From class MSatEventObserver. |
|
133 // Event notification. |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CSendSmHandler::Event( TInt aEvent ) |
|
137 { |
|
138 LOG( SIMPLE, "SENDSM: CSendSmHandler::Event calling" ) |
|
139 LOG2( SIMPLE, "SENDSM: Event %i", aEvent ) |
|
140 if ( MSatUtils::EMoSmControlExecuting == aEvent ) |
|
141 { |
|
142 LOG( NORMAL, "SENDSM: Event EMoSmControlExecuting" ) |
|
143 iMoSmControlActive = ETrue; |
|
144 } |
|
145 else if ( MSatUtils::EMoSmControlDone == aEvent ) |
|
146 { |
|
147 LOG( NORMAL, "SENDSM: Event EMoSmControlDone" ) |
|
148 iMoSmControlActive = EFalse; |
|
149 // Check if Sendsm is waiting. |
|
150 if ( !IsActive() ) |
|
151 { |
|
152 LOG( SIMPLE, "SENDSM: CSendSmHandler::Event sendsm" ) |
|
153 // Do the Sendsm. |
|
154 HandleCommand(); |
|
155 } |
|
156 } |
|
157 |
|
158 CSatCommandHandler::Event( aEvent ); |
|
159 |
|
160 LOG( SIMPLE, "SENDSM: CSendSmHandler::Event exiting" ) |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // From class MSatEventObserver. |
|
165 // Notification that sms was sent. |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CSendSmHandler::SmsSent( TInt aErrorCode ) |
|
169 { |
|
170 LOG2( SIMPLE, "SENDSM: CSendSmHandler::SmsSent calling, &d", aErrorCode ) |
|
171 |
|
172 // Ui session is listening for sms sent event. |
|
173 iUtils->NotifyUiEvent( ESatSSmEndEvent, ESatEventNone, aErrorCode ); |
|
174 |
|
175 iSendSmRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
176 iSendSmRsp.iAdditionalInfo.Zero(); |
|
177 iSendSmRsp.SetPCmdNumber( iSendSmData.PCmdNumber() ); |
|
178 |
|
179 if ( KErrSatMoSmControlModified == aErrorCode ) |
|
180 { |
|
181 LOG( SIMPLE, "SENDSM: KErrSatMoSmControlModified" ) |
|
182 iSendSmRsp.iGeneralResult = RSat::KSuccess; |
|
183 } |
|
184 else if ( KErrSatMoSmControlBarred == aErrorCode ) |
|
185 { |
|
186 LOG( SIMPLE, "SENDSM: KErrSatMoSmControlBarred" ) |
|
187 iSendSmRsp.iGeneralResult = RSat::KInteractionWithCCPermanentError; |
|
188 |
|
189 // Additional info field contains extra info. |
|
190 iSendSmRsp.iInfoType = RSat::KControlInteraction; |
|
191 |
|
192 // Lower byte contains the SMS error cause. |
|
193 iSendSmRsp.iAdditionalInfo.SetLength( 1 ); |
|
194 iSendSmRsp.iAdditionalInfo[0] = |
|
195 static_cast<TUint16>( RSat::KActionNotAllowed ); |
|
196 } |
|
197 else if ( TSatExtErrorUtils::IsExtendedError( aErrorCode ) ) |
|
198 { |
|
199 LOG( SIMPLE, "SENDSM: Error code < KErrGsmSmsBase" ) |
|
200 |
|
201 // Map error value |
|
202 TUint8 addInfo( 0 ); |
|
203 |
|
204 if ( TSatExtErrorUtils::IsNetworkError( aErrorCode ) ) |
|
205 { |
|
206 LOG( SIMPLE, "SENDSM: NetworkError" ) |
|
207 // Map extended error |
|
208 addInfo = TSatExtErrorUtils::MapError( aErrorCode ); |
|
209 |
|
210 // Error utils found the correct response |
|
211 iSendSmRsp.iGeneralResult = RSat::KNetworkUnableToProcessCmd; |
|
212 // Additional info field contains extra info. |
|
213 iSendSmRsp.iInfoType = RSat::KSatNetworkErrorInfo; |
|
214 } |
|
215 else |
|
216 { |
|
217 LOG( SIMPLE, "SENDSM: MeError" ) |
|
218 // No need to modify mapped value |
|
219 addInfo = TSatExtErrorUtils::MapError( aErrorCode, EFalse ); |
|
220 |
|
221 // Return GSM Error specific value. |
|
222 iSendSmRsp.iGeneralResult = RSat::KSmsRpError; |
|
223 // Additional info field contains extra info. |
|
224 iSendSmRsp.iInfoType = RSat::KMeProblem; |
|
225 } |
|
226 |
|
227 // Add additional info into terminal response |
|
228 iSendSmRsp.iAdditionalInfo.SetLength( 1 ); |
|
229 iSendSmRsp.iAdditionalInfo[0] = static_cast<TUint16>( addInfo ); |
|
230 } |
|
231 else if ( ( KErrGsmSMSNoNetworkService == aErrorCode ) || |
|
232 ( KErrGsmSSNotAvailable == aErrorCode ) ) |
|
233 { |
|
234 LOG( SIMPLE, "SENDSM: UnableToProcessCmd" ) |
|
235 iSendSmRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
236 iSendSmRsp.iInfoType = RSat::KMeProblem; |
|
237 iSendSmRsp.iAdditionalInfo.SetLength( 1 ); |
|
238 iSendSmRsp.iAdditionalInfo[0] = RSat::KNoService; |
|
239 } |
|
240 else if ( KErrGeneral == aErrorCode ) |
|
241 { |
|
242 LOG( SIMPLE, "SENDSM: KErrGeneral" ) |
|
243 iSendSmRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
244 } |
|
245 else if ( KErrTimedOut == aErrorCode ) |
|
246 { |
|
247 LOG( SIMPLE, "SENDSM: KErrTimedOut" ) |
|
248 iSendSmRsp.iGeneralResult = RSat::KNetworkUnableToProcessCmd; |
|
249 } |
|
250 else |
|
251 { |
|
252 if ( !iPartialComprehension ) |
|
253 { |
|
254 if ( !iNotificationRsp.iRequestedIconDisplayed && // No icon displayed |
|
255 ( RSat::ESelfExplanatory == // Only icon |
|
256 iSendSmData.iIconId.iQualifier || |
|
257 RSat::ENotSelfExplanatory == // Icon and text |
|
258 iSendSmData.iIconId.iQualifier ) ) |
|
259 { |
|
260 LOG( SIMPLE, "SENDSM: KSuccessRequestedIconNotDisplayed" ) |
|
261 iSendSmRsp.iGeneralResult = |
|
262 RSat::KSuccessRequestedIconNotDisplayed; |
|
263 } |
|
264 else |
|
265 { |
|
266 LOG( SIMPLE, "SENDSM: Succeed" ) |
|
267 iSendSmRsp.iGeneralResult = RSat::KSuccess; |
|
268 } |
|
269 } |
|
270 else |
|
271 { |
|
272 LOG( SIMPLE, "SENDSM: KPartialComprehension" ) |
|
273 iPartialComprehension = EFalse; |
|
274 iSendSmRsp.iGeneralResult = RSat::KPartialComprehension; |
|
275 } |
|
276 } |
|
277 |
|
278 // If command had icon data and was done succesfully, report that icon |
|
279 // was not shown |
|
280 // To be removed when icons are allowed in this command |
|
281 if ( ( RSat::KSuccess == iSendSmRsp.iGeneralResult ) && |
|
282 iIconCommand ) |
|
283 { |
|
284 LOG( SIMPLE, |
|
285 "SENDSM: CSendSmHandler::SmsSent KSuccessRequestedIconNotDisplayed" ) |
|
286 iSendSmRsp.iGeneralResult = |
|
287 RSat::KSuccessRequestedIconNotDisplayed; |
|
288 } |
|
289 |
|
290 TerminalRsp( RSat::ESendSm, iSendSmRspPckg ); |
|
291 |
|
292 LOG( SIMPLE, "SENDSM: CSendSmHandler::SmsSent exiting" ) |
|
293 } |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // Sets the sca number and also sets the numbering plan and the type of number. |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 TBool CSendSmHandler::SetScaNumber( const RSat::TSatTelNumber& aScaNumber ) |
|
300 { |
|
301 LOG2( SIMPLE, |
|
302 "SENDSM: CSendSmHandler::SetScaNumber calling, aScaNumber :%S", |
|
303 &aScaNumber ) |
|
304 |
|
305 TBool scaAvailable ( EFalse ); |
|
306 |
|
307 iSendSmData.iAddress.iTelNumber = aScaNumber; |
|
308 if ( aScaNumber.Length() > 0 ) |
|
309 { |
|
310 LOG2( SIMPLE, "SENDSM: aScaNumber.Length: %d", aScaNumber.Length() ) |
|
311 const RSat::TAddress address = iSendSmData.iAddress; |
|
312 |
|
313 scaAvailable = ETrue; |
|
314 |
|
315 // Is the number in international format, ie first character is '+'. |
|
316 if ( KPlus == address.iTelNumber[0] ) |
|
317 { |
|
318 const RSat::TTypeOfNumber ton = address.iTypeOfNumber; |
|
319 |
|
320 // Set the type of number, if it is not known. |
|
321 if ( ( RSat::ETypeOfNumberNotSet == ton ) || |
|
322 ( RSat::EUnknownNumber == ton ) ) |
|
323 { |
|
324 LOG( SIMPLE, "SENDSM: International Number" ) |
|
325 iSendSmData.iAddress.iTypeOfNumber = |
|
326 RSat::EInternationalNumber; |
|
327 } |
|
328 |
|
329 const RSat::TNumberingPlan npi = address.iNumberPlan; |
|
330 |
|
331 // Set the numbering plan if it is not known. |
|
332 if ( ( RSat::ENumberingPlanNotSet == npi ) || |
|
333 ( RSat::EUnknownNumberingPlan == npi ) ) |
|
334 { |
|
335 LOG( SIMPLE, "SENDSM: Isdn Number Plan" ) |
|
336 iSendSmData.iAddress.iNumberPlan = RSat::EIsdnNumberPlan; |
|
337 } |
|
338 } |
|
339 } |
|
340 |
|
341 LOG2( SIMPLE, |
|
342 "SENDSM: CSendSmHandler::SetScaNumber exiting, scaAvailable:%i", |
|
343 scaAvailable ) |
|
344 return scaAvailable; |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // From class CActive. |
|
349 // Cancels the sat request. |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 void CSendSmHandler::DoCancel() |
|
353 { |
|
354 LOG( SIMPLE, "SENDSM: CSendSmHandler::DoCancel calling" ) |
|
355 |
|
356 iUtils->USatAPI().NotifySendSmCancel(); |
|
357 |
|
358 LOG( SIMPLE, "SENDSM: CSendSmHandler::DoCancel exiting" ) |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // From class CSatCommandHandler. |
|
363 // Requests the command notification. |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void CSendSmHandler::IssueUSATRequest( TRequestStatus& aStatus ) |
|
367 { |
|
368 LOG( SIMPLE, "SENDSM: CSendSmHandler::IssueUSATRequest calling" ) |
|
369 |
|
370 // Clear the IPC package. |
|
371 new (&iSendSmData) RSat::TSendSmV1(); |
|
372 iNeedUiSession = ETrue; |
|
373 iQueryRsp.iAccepted = EFalse; // default |
|
374 iNotificationRsp.iAccepted = EFalse; |
|
375 |
|
376 iUtils->USatAPI().NotifySendSm( aStatus, iSendSmPckg ); |
|
377 |
|
378 LOG( SIMPLE, "SENDSM: CSendSmHandler::IssueUSATRequest exiting" ) |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // From class CSatCommandHandler. |
|
383 // SendSm command is not allowed in following situations: |
|
384 // - Phone is not registered to homenetwork and roaming. |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 TBool CSendSmHandler::CommandAllowed() |
|
388 { |
|
389 LOG( SIMPLE, "SENDSM: CSendSmHandler::CommandAllowed calling" ) |
|
390 TBool commandAllowed( ETrue ); |
|
391 |
|
392 RMobilePhone::TMobilePhoneRegistrationStatus registrationStatus( |
|
393 iUtils->SystemState().GetNetworkRegistrationStatus() ); |
|
394 |
|
395 // Check the PC Suite backup / restore status. If it is ongoing, SendSm is |
|
396 // not allowed. |
|
397 const TBool backupOngoing( |
|
398 iUtils->SystemState().IsBackupProcessOngoing() ); |
|
399 |
|
400 if ( ( RSat::EAlphaIdProvided != iSendSmData.iAlphaId.iStatus ) && |
|
401 ( RSat::ESelfExplanatory == iSendSmData.iIconId.iQualifier || |
|
402 RSat::ENotSelfExplanatory == iSendSmData.iIconId.iQualifier ) ) |
|
403 { |
|
404 commandAllowed = EFalse; |
|
405 iSendSmRsp.iGeneralResult = RSat::KCmdDataNotUnderstood; |
|
406 iSendSmRsp.iInfoType = RSat::KNoAdditionalInfo; |
|
407 iSendSmRsp.iAdditionalInfo.Zero(); |
|
408 LOG( SIMPLE, "SENDSM: Not allowed data not understood" ) |
|
409 } |
|
410 else if ( ( RMobilePhone::ERegisteredOnHomeNetwork != |
|
411 registrationStatus ) && |
|
412 ( RMobilePhone::ERegisteredRoaming != registrationStatus ) || |
|
413 backupOngoing ) |
|
414 { |
|
415 commandAllowed = EFalse; |
|
416 iSendSmRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
417 iSendSmRsp.iInfoType = RSat::KMeProblem; |
|
418 iSendSmRsp.iAdditionalInfo.SetLength( 1 ); |
|
419 iSendSmRsp.iAdditionalInfo[0] = RSat::KNoService; |
|
420 LOG( SIMPLE, "SENDSM: Not allowed Me unable to process" ) |
|
421 } |
|
422 else if ( !IsSCAAvailable() ) |
|
423 { |
|
424 LOG( SIMPLE, "SENDSM: Not allowed !IsSCAAvailable()" ) |
|
425 commandAllowed = EFalse; |
|
426 iSendSmRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
427 iSendSmRsp.iInfoType = RSat::KMeProblem; |
|
428 iSendSmRsp.iAdditionalInfo.SetLength( 1 ); |
|
429 iSendSmRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
430 } |
|
431 // Set icon command flag whether icon data was received and set qualifier |
|
432 // to no icon id |
|
433 // To be removed when icons are allowed in this command |
|
434 else if ( ( RSat::ESelfExplanatory == |
|
435 iSendSmData.iIconId.iQualifier ) || |
|
436 ( RSat::ENotSelfExplanatory == |
|
437 iSendSmData.iIconId.iQualifier ) ) |
|
438 { |
|
439 LOG( SIMPLE, "SENDSM: ENoIconId" ) |
|
440 iIconCommand = ETrue; |
|
441 iSendSmData.iIconId.iQualifier = RSat::ENoIconId; |
|
442 } |
|
443 else |
|
444 { |
|
445 LOG( SIMPLE, "SENDSM: others" ) |
|
446 iIconCommand = EFalse; |
|
447 } |
|
448 |
|
449 //lint -e{961} else block not needed. |
|
450 if ( !commandAllowed ) |
|
451 { |
|
452 iSendSmRsp.SetPCmdNumber( iSendSmData.PCmdNumber() ); |
|
453 TerminalRsp( RSat::ESendSm, iSendSmRspPckg ); |
|
454 } |
|
455 |
|
456 LOG2( SIMPLE, "SENDSM: CSendSmHandler::CommandAllowed exiting,\ |
|
457 commandAllowed: %d", commandAllowed ) |
|
458 return commandAllowed; |
|
459 } |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // From class CSatCommandHandler. |
|
463 // Need for ui session. |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 TBool CSendSmHandler::NeedUiSession() |
|
467 { |
|
468 LOG( NORMAL, "SENDSM: CSendSmHandler::NeedUiSession calling" ) |
|
469 // Check do we need UI |
|
470 |
|
471 // Store the result for later use |
|
472 iNeedUiSession = !TransparentSmsSending(); |
|
473 // Notify Cover UI if it's supported |
|
474 if ( iNeedUiSession && iUtils->CoverUiSupported() ) |
|
475 { |
|
476 TSatCommandData medEventData; |
|
477 medEventData.iPCmdNumber = RSat::ESendSm; |
|
478 medEventData.iAlphaId = iSendSmData.iAlphaId; |
|
479 if ( iUtils->SystemState().IsConfirmSatOperationsOn() ) |
|
480 { |
|
481 LOG( NORMAL, |
|
482 "SENDSM: CSendSmHandler::NeedUiSession KSatLongDuration" ) |
|
483 medEventData.iDuration.iNumOfUnits = KSatLongDuration; |
|
484 } |
|
485 else |
|
486 { |
|
487 LOG( NORMAL, |
|
488 "SENDSM: CSendSmHandler::NeedUiSession KSatDefaultDuration" ) |
|
489 medEventData.iDuration.iNumOfUnits = KSatDefaultDuration; |
|
490 } |
|
491 |
|
492 medEventData.iDuration.iTimeUnit = RSat::ESeconds; |
|
493 medEventData.iIconID = iSendSmData.iIconId; |
|
494 TSatCommandPckg tPckg( medEventData ); |
|
495 iUtils->RaiseSatEvent( tPckg ); |
|
496 } |
|
497 |
|
498 LOG2( NORMAL, "SENDSM: CSendSmHandler::NeedUiSession exiting, \ |
|
499 iNeedUiSession: %d", iNeedUiSession ) |
|
500 return iNeedUiSession; |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // From class CSatCommandHandler. |
|
505 // Called when USAT API notifies that command. |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 void CSendSmHandler::HandleCommand() |
|
509 { |
|
510 LOG( SIMPLE, "SENDSM: CSendSmHandler::HandleCommand calling" ) |
|
511 |
|
512 // If mo sm control is active, command waits for the EMoSmControlDone event |
|
513 // and sends the command then. |
|
514 if ( !iMoSmControlActive ) |
|
515 { |
|
516 iUtils->NotifyEvent( MSatUtils::ESendSmExecuting ); |
|
517 |
|
518 if ( !iNeedUiSession ) |
|
519 { |
|
520 LOG( SIMPLE, |
|
521 "SENDSM: CSendSmHandler::HandleCommand not iNeedUiSession" ) |
|
522 // Dont show any messages in ui client, ETSI dictates that |
|
523 // if alpha is is provided and alpha id length is 0 then ui |
|
524 // should not show anyting. |
|
525 // This is OK also for icon support. |
|
526 // Icon is successfully processed. But not shown in this case. |
|
527 if ( !iMsgSender->IsActive() ) |
|
528 { |
|
529 LOG( SIMPLE, |
|
530 "SENDSM: CSendSmHandler::HandleCommand start iMsgSender" ) |
|
531 iMsgSender->Start( iSendSmData ); |
|
532 } |
|
533 } |
|
534 else |
|
535 { |
|
536 iQueryData.iCommand = ESatSSendSmQuery; |
|
537 iQueryData.iQueryText = iSendSmData.iAlphaId.iAlphaId; |
|
538 iQueryData.iIconId.iIdentifier = iSendSmData.iIconId.iIdentifier; |
|
539 |
|
540 iNotificationSent = EFalse; |
|
541 iNotificationData.iCommand = ESatSSendSmsNotify; |
|
542 iNotificationData.iText = iSendSmData.iAlphaId.iAlphaId; |
|
543 iNotificationData.iIconId.iIdentifier = |
|
544 iSendSmData.iIconId.iIdentifier; |
|
545 LOG2( NORMAL, "SENDSM: CSendSmHandler::HandleCommand \ |
|
546 iSendSmData.iIconId.iQualifier: %d", |
|
547 iSendSmData.iIconId.iQualifier ) |
|
548 switch ( iSendSmData.iIconId.iQualifier ) |
|
549 { |
|
550 case RSat::ESelfExplanatory: |
|
551 { |
|
552 // Icon qualifier is self explanatory (to display instead |
|
553 // of the alpha id or text string). |
|
554 iQueryData.iIconId.iIconQualifier = ESatSelfExplanatory; |
|
555 iNotificationData.iIconId.iIconQualifier = |
|
556 ESatSelfExplanatory; |
|
557 break; |
|
558 } |
|
559 |
|
560 case RSat::ENotSelfExplanatory: |
|
561 { |
|
562 // Icon qualifier is not self explanatory. |
|
563 iQueryData.iIconId.iIconQualifier = ESatNotSelfExplanatory; |
|
564 iNotificationData.iIconId.iIconQualifier = |
|
565 ESatNotSelfExplanatory; |
|
566 break; |
|
567 } |
|
568 |
|
569 default: |
|
570 { |
|
571 // Icon qualifier not present |
|
572 iQueryData.iIconId.iIconQualifier = ESatENoIconId; |
|
573 iNotificationData.iIconId.iIconQualifier = ESatENoIconId; |
|
574 break; |
|
575 } |
|
576 |
|
577 } |
|
578 LOG2( NORMAL, "SENDSM: CSendSmHandler::HandleCommand \ |
|
579 iSendSmData.iAlphaId.iStatus: %d", |
|
580 iSendSmData.iAlphaId.iStatus ) |
|
581 switch ( iSendSmData.iAlphaId.iStatus ) |
|
582 { |
|
583 case RSat::EAlphaIdNotPresent: |
|
584 { |
|
585 iQueryData.iAlphaIdStatus = ESatAlphaIdNotProvided; |
|
586 iNotificationData.iAlphaIdStatus = ESatAlphaIdNotProvided; |
|
587 break; |
|
588 } |
|
589 |
|
590 case RSat::EAlphaIdProvided: |
|
591 { |
|
592 iQueryData.iAlphaIdStatus = ESatAlphaIdNotNull; |
|
593 iNotificationData.iAlphaIdStatus = ESatAlphaIdNotNull; |
|
594 break; |
|
595 } |
|
596 |
|
597 default: |
|
598 { |
|
599 iQueryData.iAlphaIdStatus = ESatAlphaIdNull; |
|
600 iNotificationData.iAlphaIdStatus = ESatAlphaIdNull; |
|
601 break; |
|
602 } |
|
603 } |
|
604 |
|
605 // Check do we need to confirm operation from user |
|
606 if ( !iUtils->SystemState().IsConfirmSatOperationsOn() ) |
|
607 { |
|
608 LOG( SIMPLE, |
|
609 "SENDSM: CSendSmHandler::HandleCommand confirm operation" ) |
|
610 // No need to confirm, show only notification |
|
611 // Register notification observer |
|
612 TRAP_IGNORE( iUtils->RegisterServiceRequestL( |
|
613 ESatSProactiveNotification, |
|
614 ESatSProactiveNotificationResponse, |
|
615 this ) ) |
|
616 |
|
617 iUtils->SatUiHandler().UiSession()->SendCommand( |
|
618 &iNotificationDataPckg, |
|
619 &iNotificationRspPckg, |
|
620 ESatSProactiveNotification ); |
|
621 |
|
622 iNotificationSent = ETrue; |
|
623 } |
|
624 else |
|
625 { |
|
626 // Register service request handler for SendSm command, |
|
627 // If there is already service request for query, registering |
|
628 // updates command handler, so client responses comes to this |
|
629 // command handler |
|
630 TRAP_IGNORE( iUtils->RegisterServiceRequestL( |
|
631 ESatSProactiveQuery, |
|
632 ESatSProactiveQueryResponse, |
|
633 this ) ) |
|
634 |
|
635 iNotificationSent = EFalse; |
|
636 |
|
637 // Ask the user permission to send sms. Reply will come |
|
638 // to ClientResponse method. |
|
639 iUtils->SatUiHandler().UiSession()->SendCommand( |
|
640 &iQueryPckg, |
|
641 &iQueryRspPckg, |
|
642 ESatSProactiveQuery ); |
|
643 } |
|
644 } |
|
645 } |
|
646 |
|
647 LOG( SIMPLE, "SENDSM: CSendSmHandler::HandleCommand exiting" ) |
|
648 } |
|
649 |
|
650 // ----------------------------------------------------------------------------- |
|
651 // From class CSatCommandHandler. |
|
652 // Called when UI launch fails |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 void CSendSmHandler::UiLaunchFailed() |
|
656 { |
|
657 LOG( SIMPLE, "SENDSM: CSendSmHandler::UiLaunchFailed calling" ) |
|
658 |
|
659 iSendSmRsp.iGeneralResult = RSat::KMeUnableToProcessCmd; |
|
660 iSendSmRsp.iInfoType = RSat::KMeProblem; |
|
661 iSendSmRsp.iAdditionalInfo.SetLength( 1 ); |
|
662 iSendSmRsp.iAdditionalInfo[0] = RSat::KNoSpecificMeProblem; |
|
663 iSendSmRsp.SetPCmdNumber( iSendSmData.PCmdNumber() ); |
|
664 |
|
665 TerminalRsp( RSat::ESendSm, iSendSmRspPckg ); |
|
666 |
|
667 LOG( SIMPLE, "SENDSM: CSendSmHandler::UiLaunchFailed exiting" ) |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // C++ default constructor can NOT contain any code, that |
|
672 // might leave. |
|
673 // ----------------------------------------------------------------------------- |
|
674 // |
|
675 //lint -e{1403, 1769} Can not be initialized, harmless. |
|
676 CSendSmHandler::CSendSmHandler() : |
|
677 CSatCommandHandler(), |
|
678 iSendSmData(), |
|
679 iSendSmPckg( iSendSmData ), |
|
680 iSendSmRsp(), |
|
681 iSendSmRspPckg( iSendSmRsp ), |
|
682 iQueryData(), |
|
683 iQueryPckg( iQueryData ), |
|
684 iQueryRsp(), |
|
685 iQueryRspPckg( iQueryRsp ), |
|
686 iNotificationData(), |
|
687 iNotificationDataPckg( iNotificationData ), |
|
688 iNotificationRsp(), |
|
689 iNotificationRspPckg( iNotificationRsp ), |
|
690 // To be removed when icons are allowed in this command |
|
691 iIconCommand( EFalse ) |
|
692 { |
|
693 LOG( SIMPLE, |
|
694 "SENDSM: CSendSmHandler::CSendSmHandler calling - exiting" ) |
|
695 } |
|
696 |
|
697 // ----------------------------------------------------------------------------- |
|
698 // Symbian 2nd phase constructor can leave. |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 void CSendSmHandler::ConstructL() |
|
702 { |
|
703 LOG( SIMPLE, "SENDSM: CSendSmHandler::ConstructL calling" ) |
|
704 |
|
705 iMsgSender = CSatSSendMessageNoLoggingHandler::NewL( |
|
706 iUtils->USatAPI(), |
|
707 *this ); |
|
708 |
|
709 iUtils->RegisterL( this, MSatUtils::EMoSmControlExecuting ); |
|
710 iUtils->RegisterL( this, MSatUtils::EMoSmControlDone ); |
|
711 |
|
712 // Create request handler. This is same that LaunchBrowser uses, so this |
|
713 // is needed also in HandleCommand - function. |
|
714 iUtils->RegisterServiceRequestL( |
|
715 ESatSProactiveQuery, |
|
716 ESatSProactiveQueryResponse, |
|
717 this ); |
|
718 |
|
719 LOG( SIMPLE, "SENDSM: CSendSmHandler::ConstructL exiting" ) |
|
720 } |
|
721 |
|
722 // ----------------------------------------------------------------------------- |
|
723 // SMS sending should be transparent if alpha identifier is provided but it's |
|
724 // length is 0. Also user query setting is not on. |
|
725 // ----------------------------------------------------------------------------- |
|
726 // |
|
727 TBool CSendSmHandler::TransparentSmsSending() const |
|
728 { |
|
729 LOG( SIMPLE, "SENDSM: CSendSmHandler::TransparentSmsSending calling" ) |
|
730 |
|
731 TBool result( EFalse ); |
|
732 const RSat::TAlphaId alphaId( iSendSmData.iAlphaId ); |
|
733 |
|
734 if ( ( alphaId.iStatus == RSat::EAlphaIdProvided && |
|
735 alphaId.iAlphaId.Length() == 0 ) || |
|
736 alphaId.iStatus == RSat::EAlphaIdNull ) |
|
737 { |
|
738 LOG( SIMPLE, |
|
739 "SENDSM: CSendSmHandler::TransparentSmsSending EAlphaIdProvided" ) |
|
740 if ( !iUtils->SystemState().IsConfirmSatOperationsOn() ) |
|
741 { |
|
742 LOG( SIMPLE, |
|
743 "SENDSM: CSendSmHandler::TransparentSmsSending confirm" ) |
|
744 result = ETrue; |
|
745 } |
|
746 |
|
747 } |
|
748 |
|
749 LOG2( SIMPLE, "SENDSM: CSendSmHandler::TransparentSmsSending exiting: %i", |
|
750 result ) |
|
751 return result; |
|
752 } |
|
753 |
|
754 // ----------------------------------------------------------------------------- |
|
755 // Chaeck SCA availability. |
|
756 // ----------------------------------------------------------------------------- |
|
757 // |
|
758 TBool CSendSmHandler::IsSCAAvailable() |
|
759 { |
|
760 LOG( SIMPLE, "SENDSM: CSendSmHandler::IsSCAAvailable calling" ) |
|
761 |
|
762 TBool scaAvailable ( ETrue ); |
|
763 |
|
764 // If Service Center Address in not specified in proactive command, |
|
765 // the SCA is taken from shared data. SMSUi sets the SCA in the |
|
766 // shared data. If the SCA is not found from shared data, then |
|
767 // sending is not allowed. |
|
768 if ( 0 == iSendSmData.iAddress.iTelNumber.Length() ) |
|
769 { |
|
770 LOG( SIMPLE, "SENDSM: TelNumber is empty" ) |
|
771 |
|
772 // Address is not defined. |
|
773 if ( RSat::ETypeOfNumberNotSet == iSendSmData.iAddress.iTypeOfNumber ) |
|
774 { |
|
775 iPartialComprehension = EFalse; |
|
776 } |
|
777 |
|
778 // Address is set intentionally empty. |
|
779 else |
|
780 { |
|
781 iPartialComprehension = ETrue; |
|
782 LOG( SIMPLE, "SENDSM: The result is KPartialComprehension" ) |
|
783 } |
|
784 |
|
785 scaAvailable = SetScaNumber( iUtils->SystemState().SCANumber() ); |
|
786 } |
|
787 else |
|
788 { |
|
789 LOG( SIMPLE, "SENDSM: TelNumber is not empty." ) |
|
790 iPartialComprehension = EFalse; |
|
791 } |
|
792 |
|
793 LOG2( SIMPLE, |
|
794 "SENDSM: CSendSmHandler::IsSCAAvailable exiting: %i", scaAvailable ) |
|
795 return scaAvailable; |
|
796 } |