|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : CSatNotifyGetInput.cpp |
|
15 // Part of : Common SIM ATK TSY / commonsimatktsy |
|
16 // Get Input notification functionality of Sat Tsy |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 //INCLUDES |
|
23 #include <satcs.h> // Etel SAT IPC definitions |
|
24 #include "CSatTsy.h" // Tsy class header |
|
25 #include "CSatNotifyGetInput.h" // Tsy class header |
|
26 #include "CSatNotificationsTsy.h" // Class header |
|
27 #include "CBerTlv.h" // Ber Tlv data handling |
|
28 #include "TTlv.h" // TTlv class |
|
29 #include "CSatDataPackage.h" // Parameter packing |
|
30 #include "TfLogger.h" // For TFLOGSTRING |
|
31 #include "TSatUtility.h" // Utilities |
|
32 #include "CSatTsyReqHandleStore.h" // Request handle class |
|
33 #include "cmmmessagemanagerbase.h" // Message manager class for forwarding req. |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CSatNotifyGetInkey::NewL |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CSatNotifyGetInput* CSatNotifyGetInput::NewL |
|
41 ( |
|
42 CSatNotificationsTsy* aNotificationsTsy |
|
43 ) |
|
44 { |
|
45 TFLOGSTRING("CSAT: CSatNotifyGetInput::NewL"); |
|
46 CSatNotifyGetInput* const satNotifyGetInput = |
|
47 new ( ELeave ) CSatNotifyGetInput( aNotificationsTsy ); |
|
48 CleanupStack::PushL( satNotifyGetInput ); |
|
49 satNotifyGetInput->ConstructL(); |
|
50 CleanupStack::Pop( satNotifyGetInput ); |
|
51 TFLOGSTRING("CSAT: CSatNotifyGetInput::NewL, end of method"); |
|
52 return satNotifyGetInput; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSatNotifyGetInput::~CSatNotifyGetInput |
|
57 // Destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CSatNotifyGetInput::~CSatNotifyGetInput |
|
61 ( |
|
62 // None |
|
63 ) |
|
64 { |
|
65 TFLOGSTRING("CSAT: CSatNotifyGetInput::~CSatNotifyGetInput"); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSatNotifyGetInput::CSatNotifyGetInput |
|
70 // Default C++ constructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CSatNotifyGetInput::CSatNotifyGetInput |
|
74 ( |
|
75 CSatNotificationsTsy* aNotificationsTsy |
|
76 ) : iNotificationsTsy ( aNotificationsTsy ) |
|
77 { |
|
78 // None |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CSatNotifyGetInkey::ConstructL |
|
83 // Symbian 2nd phase constructor |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CSatNotifyGetInput::ConstructL |
|
87 ( |
|
88 // None |
|
89 ) |
|
90 { |
|
91 TFLOGSTRING("CSAT: CSatNotifyGetInput::ConstructL"); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CSatNotifyGetInput::Notify |
|
96 // Save the request handle type for notification requested by ETel server |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TInt CSatNotifyGetInput::Notify |
|
100 ( |
|
101 const TTsyReqHandle aTsyReqHandle, |
|
102 const TDataPackage& aPackage |
|
103 ) |
|
104 { |
|
105 TFLOGSTRING("CSAT: CSatNotifyGetInput::Notify"); |
|
106 // Save data pointer to client side for completion |
|
107 iGetInputV1Pckg = reinterpret_cast<RSat::TGetInputV1Pckg*>( |
|
108 aPackage.Des1n() ); |
|
109 // Save the request handle |
|
110 iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, |
|
111 CSatTsy::ESatNotifyGetInputPCmdReqType ); |
|
112 // Check if requested notification is already pending |
|
113 iNotificationsTsy->NotifySatReadyForNotification( KGetInput ); |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CSatNotifyGetInput::CancelNotification |
|
119 // This method cancels an outstanding asynchronous |
|
120 // NotifyNotifyGetInput request. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TInt CSatNotifyGetInput::CancelNotification |
|
124 ( |
|
125 const TTsyReqHandle aTsyReqHandle |
|
126 ) |
|
127 { |
|
128 TFLOGSTRING("CSAT: CSatNotifyGetInput::CancelNotification"); |
|
129 // Reset the request handle |
|
130 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
131 ResetTsyReqHandle( |
|
132 CSatTsy::ESatNotifyGetInputPCmdReqType ); |
|
133 // Reset the data pointer |
|
134 iGetInputV1Pckg = NULL; |
|
135 // Complete the request with KErrCancel |
|
136 iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
137 return KErrNone; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CSatNotifyGetInput::CompleteNotifyL |
|
142 // Complete Sim Session End notification to the client |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 TInt CSatNotifyGetInput::CompleteNotifyL |
|
146 ( |
|
147 CSatDataPackage* aDataPackage, |
|
148 TInt aErrorCode |
|
149 ) |
|
150 { |
|
151 TFLOGSTRING("CSAT: CSatNotifyGetInput::CompleteNotifyL"); |
|
152 TInt returnValue( KErrNone ); |
|
153 TInt ret( KErrNone ); |
|
154 // Unpack parameters |
|
155 TPtrC8* data; |
|
156 aDataPackage->UnPackData( &data ); |
|
157 TBuf<1> additionalInfo; |
|
158 TBuf<1> emptyText; |
|
159 // Reset req handle. Returns the deleted req handle |
|
160 TTsyReqHandle reqHandle = |
|
161 iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( |
|
162 CSatTsy::ESatNotifyGetInputPCmdReqType ); |
|
163 // Get ber tlv |
|
164 CBerTlv berTlv; |
|
165 berTlv.SetData( *data ); |
|
166 |
|
167 // Get command details tlv |
|
168 CTlv commandDetails; |
|
169 berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); |
|
170 iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( commandDetails.Data() ); |
|
171 |
|
172 // Get command qualifier |
|
173 TUint8 cmdQualifier( commandDetails.GetShortInfo( |
|
174 ETLV_CommandQualifier ) ); |
|
175 |
|
176 TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); |
|
177 |
|
178 // In case the request was ongoing, continue.. |
|
179 if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
180 { |
|
181 // Complete right away if error has occured, otherwise continue.. |
|
182 if ( KErrNone == aErrorCode ) |
|
183 { |
|
184 // Fill the get input structure |
|
185 RSat::TGetInputV1& getInputV1 = ( *iGetInputV1Pckg )(); |
|
186 |
|
187 getInputV1.SetPCmdNumber( pCmdNumber ); |
|
188 |
|
189 if ( KUserInputMask & cmdQualifier ) |
|
190 { |
|
191 // User input hidden |
|
192 getInputV1.iInputDisplayOption = RSat::EHideUserInput; |
|
193 } |
|
194 else |
|
195 { |
|
196 // User input shown |
|
197 getInputV1.iInputDisplayOption = RSat::EDisplayUserInput; |
|
198 } |
|
199 |
|
200 |
|
201 // Character set selected |
|
202 if ( KUCS2AlphabetMask & cmdQualifier ) |
|
203 { |
|
204 // UCS2 alphabet selected |
|
205 getInputV1.iRspFormat = RSat::EUcs2Alphabet; |
|
206 } |
|
207 else if ( KAlphabetMask & cmdQualifier ) |
|
208 { |
|
209 if ( KGetInputSmsPackedMask & cmdQualifier ) |
|
210 { |
|
211 // SMS default alphabet |
|
212 getInputV1.iRspFormat = RSat::ESmsDefaultAlphabetPacked; |
|
213 } |
|
214 else |
|
215 { |
|
216 getInputV1.iRspFormat = RSat::ESmsDefaultAlphabetUnpacked; |
|
217 } |
|
218 } |
|
219 |
|
220 else |
|
221 { |
|
222 if ( KGetInputSmsPackedMask & cmdQualifier ) |
|
223 { |
|
224 // Digit only |
|
225 getInputV1.iRspFormat = RSat::EDigitOnlyPacked; |
|
226 } |
|
227 else |
|
228 { |
|
229 getInputV1.iRspFormat = RSat::EDigitOnlyUnpacked; |
|
230 } |
|
231 } |
|
232 |
|
233 |
|
234 // Help information. |
|
235 if ( KHelpAvailabilityMask & cmdQualifier ) |
|
236 { |
|
237 // Help information available |
|
238 getInputV1.iHelp = RSat::EHelpAvailable; |
|
239 } |
|
240 else |
|
241 { |
|
242 TFLOGSTRING("CSAT: CSatNotifyGetInput::CompleteNotifyL,\ |
|
243 No Help available"); |
|
244 // No help |
|
245 getInputV1.iHelp = RSat::ENoHelpAvailable; |
|
246 } |
|
247 |
|
248 |
|
249 // Get Input text |
|
250 getInputV1.iText.Zero(); |
|
251 CTlv textString; |
|
252 returnValue = berTlv.TlvByTagValue( &textString, KTlvTextStringTag ); |
|
253 |
|
254 if ( KErrNone == returnValue ) |
|
255 { |
|
256 // Convert and set text |
|
257 TSatUtility::SetText( textString, getInputV1.iText ); |
|
258 } |
|
259 else |
|
260 { |
|
261 TFLOGSTRING("CSAT: CSatNotifyGetInput::CompleteNotifyL,\ |
|
262 Input text missing"); |
|
263 additionalInfo.Zero(); |
|
264 additionalInfo.Append( KNoCause ); |
|
265 CreateTerminalRespL( pCmdNumber, |
|
266 RSat::KErrorRequiredValuesMissing, additionalInfo, |
|
267 emptyText, RSat::ESmsDefaultAlphabetUnpacked ); |
|
268 ret = KErrCorrupt; |
|
269 } |
|
270 |
|
271 TFLOGSTRING2("CSAT: GetInput, text: %S", &getInputV1.iText ); |
|
272 |
|
273 // Response length expected |
|
274 CTlv responseLength; |
|
275 returnValue = berTlv.TlvByTagValue( &responseLength, |
|
276 KTlvResponseLengthTag ); |
|
277 |
|
278 if ( KErrNone == returnValue ) |
|
279 { |
|
280 // Set minimum response length |
|
281 getInputV1.iRspLength.iMinRspLength = |
|
282 responseLength.GetShortInfo( ETLV_MinimumLengthOfResponse ); |
|
283 |
|
284 if ( RSat::KGetInputTextMaxSize < |
|
285 getInputV1.iRspLength.iMinRspLength ) |
|
286 { |
|
287 TFLOGSTRING("CSAT: CSatNotifyGetInput::CompleteNotifyL,\ |
|
288 Input text length exceeded"); |
|
289 additionalInfo.Zero(); |
|
290 additionalInfo.Append( KNoCause ); |
|
291 CreateTerminalRespL( pCmdNumber, |
|
292 RSat::KCmdDataNotUnderstood, additionalInfo, |
|
293 emptyText, RSat::ESmsDefaultAlphabetUnpacked ); |
|
294 ret = KErrCorrupt; |
|
295 } |
|
296 |
|
297 // Set maximum response length |
|
298 getInputV1.iRspLength.iMaxRspLength = |
|
299 responseLength.GetShortInfo( ETLV_MaximumLengthOfResponse ); |
|
300 } |
|
301 else |
|
302 { |
|
303 TFLOGSTRING("CSAT: CSatNotifyGetInput::CompleteNotifyL,\ |
|
304 Response length TLV missing"); |
|
305 // Mandatory reponse length tlv is missing |
|
306 additionalInfo.Zero(); |
|
307 additionalInfo.Append( KNoCause ); |
|
308 CreateTerminalRespL( pCmdNumber, |
|
309 RSat::KErrorRequiredValuesMissing, additionalInfo, |
|
310 emptyText, RSat::ESmsDefaultAlphabetUnpacked ); |
|
311 ret = KErrCorrupt; |
|
312 } |
|
313 |
|
314 // Default text to display (optional) |
|
315 getInputV1.iDefaultText.Zero(); |
|
316 returnValue = berTlv.TlvByTagValue( &textString, KTlvDefaultTextTag ); |
|
317 |
|
318 // If default text exist |
|
319 if ( KErrNone == returnValue ) |
|
320 { |
|
321 TSatUtility::SetText( textString, getInputV1.iDefaultText ); |
|
322 } |
|
323 |
|
324 // Iconid ( optional ) |
|
325 TSatUtility::FillIconStructure( berTlv, getInputV1.iIconId ); |
|
326 |
|
327 } // if ( KErrNone == aErrorCode ) |
|
328 else |
|
329 { |
|
330 ret = aErrorCode; |
|
331 } |
|
332 iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); |
|
333 } |
|
334 |
|
335 else |
|
336 { |
|
337 TFLOGSTRING("CSAT: CSatNotifyGetInput::CompleteNotifyL,\ |
|
338 Request not ongoing"); |
|
339 // Request not on, returning response immediately |
|
340 additionalInfo.Zero(); |
|
341 additionalInfo.Append( KNoCause ); |
|
342 CreateTerminalRespL( pCmdNumber, |
|
343 RSat::KMeUnableToProcessCmd, additionalInfo, |
|
344 emptyText, RSat::ESmsDefaultAlphabetUnpacked ); |
|
345 } |
|
346 |
|
347 return ret; |
|
348 |
|
349 } |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // CSatNotifyGetInput::TerminalResponseL |
|
353 // Called by ETel server, passes terminal response to SIM card |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 TInt CSatNotifyGetInput::TerminalResponseL |
|
357 ( |
|
358 TDes8* aRsp |
|
359 ) |
|
360 { |
|
361 TFLOGSTRING("CSAT: CSatNotifyGetInput::TerminalResponseL"); |
|
362 |
|
363 TInt returnValue( KErrNone ); |
|
364 TBuf<1>additionalInfo; |
|
365 |
|
366 RSat::TGetInputRspV1Pckg* aRspPckg = |
|
367 reinterpret_cast<RSat::TGetInputRspV1Pckg*>( aRsp ); |
|
368 RSat::TGetInputRspV1& rspV1 = ( *aRspPckg ) (); |
|
369 |
|
370 TFLOGSTRING3("CSAT: CSatNotifyGetInput::TerminalResponseL, \ |
|
371 iAdditionalInfo: %S, iInfoType: %d", |
|
372 &rspV1.iAdditionalInfo, rspV1.iInfoType); |
|
373 TFLOGSTRING2("CSAT:CSatNotifyGetInput::TerminalResponseL, \ |
|
374 iGeneralResult: %d", rspV1.iGeneralResult); |
|
375 |
|
376 // Get Proactive command number |
|
377 TUint8 pCmdNumber( rspV1.PCmdNumber() ); |
|
378 |
|
379 // Checking that the response type is valid |
|
380 if ( RSat::EGetInputRspFormatNotSet == rspV1.iRspFormat ) |
|
381 { |
|
382 returnValue = KErrCorrupt; |
|
383 } |
|
384 |
|
385 // Check that general result value is valid |
|
386 if ( ( RSat::KSuccess != rspV1.iGeneralResult ) |
|
387 && ( RSat::KPSessionTerminatedByUser != rspV1.iGeneralResult ) |
|
388 && ( RSat::KBackwardModeRequestedByUser != rspV1.iGeneralResult ) |
|
389 && ( RSat::KNoResponseFromUser != rspV1.iGeneralResult ) |
|
390 && ( RSat::KHelpRequestedByUser != rspV1.iGeneralResult ) |
|
391 && ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) |
|
392 && ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult )) |
|
393 { |
|
394 TFLOGSTRING("CSAT: CSatNotifyGetInput::TerminalResponseL,\ |
|
395 Invalid General Result"); |
|
396 // Invalid general result |
|
397 returnValue = KErrCorrupt; |
|
398 } |
|
399 |
|
400 // If there is Me (Mobile Entity) error, additional info is needed |
|
401 if ( ( RSat::KMeProblem == rspV1.iInfoType ) ) |
|
402 { |
|
403 // Check the length of additional info |
|
404 if ( rspV1.iAdditionalInfo.Length() != 0 ) |
|
405 { |
|
406 additionalInfo.Zero(); |
|
407 additionalInfo.Append( rspV1.iAdditionalInfo[0] ); |
|
408 } |
|
409 else |
|
410 { |
|
411 TFLOGSTRING("CSAT: CSatNotifyGetInput::TerminalResponseL,\ |
|
412 Invalid Additional Info"); |
|
413 // Invalid additional info field |
|
414 returnValue = KErrCorrupt; |
|
415 } |
|
416 } |
|
417 |
|
418 CreateTerminalRespL( pCmdNumber, ( TUint8 ) rspV1.iGeneralResult , |
|
419 additionalInfo, rspV1.iAdditionalInfo, ( TUint8 )rspV1.iRspFormat ); |
|
420 |
|
421 return returnValue; |
|
422 |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CSatNotifyGetInput::CreateTerminalRespL |
|
427 // Constructs GetInput specific part of terminal response and calls |
|
428 // DOS to send the actual message. |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 TInt CSatNotifyGetInput::CreateTerminalRespL |
|
432 ( |
|
433 TUint8 aPCmdNumber, |
|
434 TUint8 aGeneralResult, |
|
435 TDesC16& aAdditionalInfo, |
|
436 TDesC16& aTextString, |
|
437 TUint8 aDcs |
|
438 ) |
|
439 { |
|
440 TFLOGSTRING("CSAT: CSatNotifyGetInput::CreateTerminalRespL"); |
|
441 TTlv tlvSpecificData; |
|
442 TBuf8<KGetInputStringMaxSize> string; |
|
443 |
|
444 tlvSpecificData.AddTag( KTlvResultTag ); |
|
445 //General result |
|
446 tlvSpecificData.AddByte( aGeneralResult ); |
|
447 |
|
448 if ( RSat::KMeUnableToProcessCmd == aGeneralResult ) |
|
449 { |
|
450 if ( aAdditionalInfo.Length() > 0 ) |
|
451 { |
|
452 tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] ); |
|
453 } |
|
454 } |
|
455 |
|
456 if ( iNotificationsTsy->CommandPerformedSuccessfully( aGeneralResult ) ) |
|
457 { |
|
458 // Create TextString TLV |
|
459 tlvSpecificData.AddTag( KTlvTextStringTag ); |
|
460 |
|
461 |
|
462 if ( aTextString.Length() ) |
|
463 { |
|
464 TFLOGSTRING2("CSAT: CSatNotifyGetInput::CreateTerminalRespL \ |
|
465 aTextString: %S", &aTextString); |
|
466 switch ( aDcs ) |
|
467 { |
|
468 case RSat::EUcs2Alphabet: |
|
469 { |
|
470 TFLOGSTRING("CSAT: CSatNotifyGetInput::CreateTerminalRespL \ |
|
471 EUcs2Alphabet"); |
|
472 // Data coding scheme UCS2 (16-bit) |
|
473 tlvSpecificData.AddByte( KUCS2DCS ); |
|
474 |
|
475 if ( aTextString.Length() ) |
|
476 { |
|
477 TSatUtility::Copy16to8LE( aTextString, string ); |
|
478 tlvSpecificData.AddData( string ); |
|
479 } |
|
480 break; |
|
481 } |
|
482 |
|
483 case RSat::EDigitOnlyPacked: |
|
484 case RSat::ESmsDefaultAlphabetPacked: |
|
485 { |
|
486 TFLOGSTRING("CSAT: CSatNotifyGetInput::CreateTerminalRespL \ |
|
487 EDigitOnlyPacked/ESmsDefaultAlphabetPacked"); |
|
488 // Data coding scheme 7-bit default sms |
|
489 tlvSpecificData.AddByte( K7BitDefaultSmsDCS ); |
|
490 TSatUtility::UCSToPacked7( aTextString, string ); |
|
491 tlvSpecificData.AddData( string ); |
|
492 break; |
|
493 } |
|
494 |
|
495 case RSat::EDigitOnlyUnpacked: |
|
496 case RSat::ESmsDefaultAlphabetUnpacked: |
|
497 { |
|
498 TFLOGSTRING("CSAT: CSatNotifyGetInput::CreateTerminalRespL \ |
|
499 EDigitOnlyUnpacked/ESmsDefaultAlphabetUnpacked"); |
|
500 // Data coding scheme 8-bit |
|
501 tlvSpecificData.AddByte( K8BitDCS ); |
|
502 TSatUtility::ConvertUnicode16To7Bit( aTextString, string ); |
|
503 tlvSpecificData.AddData( string ); |
|
504 break; |
|
505 } |
|
506 default: |
|
507 // do nothing |
|
508 break; |
|
509 } |
|
510 |
|
511 TFLOGSTRING2("CSAT: CSatNotifyGetInput::CreateTerminalRespL \ |
|
512 string: %S", &string); |
|
513 } |
|
514 } |
|
515 // Prepare data |
|
516 iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber; |
|
517 TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag(); |
|
518 |
|
519 // Pack data |
|
520 CSatDataPackage dataPackage; |
|
521 dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data ); |
|
522 |
|
523 // Forward request to the DOS |
|
524 return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( |
|
525 ESatTerminalRsp, &dataPackage ); |
|
526 } |
|
527 |
|
528 // End of file |
|
529 |
|
530 |