|
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 : CSatNotifyGetInkey.cpp |
|
15 // Part of : Common SIM ATK TSY / commonsimatktsy |
|
16 // Get inkey 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 "CSatNotifyGetInkey.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 CSatNotifyGetInkey* CSatNotifyGetInkey::NewL |
|
41 ( |
|
42 CSatNotificationsTsy* aNotificationsTsy |
|
43 ) |
|
44 { |
|
45 TFLOGSTRING("CSAT: CSatNotifyGetInkey::NewL"); |
|
46 CSatNotifyGetInkey* const satNotifyGetInkey = |
|
47 new ( ELeave ) CSatNotifyGetInkey( aNotificationsTsy ); |
|
48 CleanupStack::PushL( satNotifyGetInkey ); |
|
49 satNotifyGetInkey->ConstructL(); |
|
50 CleanupStack::Pop( satNotifyGetInkey ); |
|
51 TFLOGSTRING("CSAT: CSatNotifyGetInkey::NewL, end of method"); |
|
52 return satNotifyGetInkey; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSatNotifyGetInkey::~CSatNotifyGetInkey |
|
57 // Destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CSatNotifyGetInkey::~CSatNotifyGetInkey |
|
61 ( |
|
62 // None |
|
63 ) |
|
64 { |
|
65 TFLOGSTRING("CSAT: CSatNotifyGetInkey::~CSatNotifyGetInkey"); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSatNotifyGetInkey::CSatNotifyGetInkey |
|
70 // Default C++ constructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 CSatNotifyGetInkey::CSatNotifyGetInkey |
|
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 CSatNotifyGetInkey::ConstructL |
|
87 ( |
|
88 // None |
|
89 ) |
|
90 { |
|
91 TFLOGSTRING("CSAT: CSatNotifyGetInkey::ConstructL"); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CSatNotifyGetInkey::Notify |
|
96 // Save the request handle type for notification requested by ETel server |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TInt CSatNotifyGetInkey::Notify |
|
100 ( |
|
101 const TTsyReqHandle aTsyReqHandle, |
|
102 const TDataPackage& aPackage |
|
103 ) |
|
104 { |
|
105 TFLOGSTRING("CSAT: CSatNotifyGetInkey::Notify"); |
|
106 // Save data pointer to client side for completion |
|
107 iGetInkeyV2Pckg = reinterpret_cast<RSat::TGetInkeyV2Pckg*>( |
|
108 aPackage.Des1n() ); |
|
109 // Save the request handle |
|
110 iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, |
|
111 CSatTsy::ESatNotifyGetInkeyPCmdReqType ); |
|
112 // Check if requested notification is already pending |
|
113 iNotificationsTsy->NotifySatReadyForNotification( KGetInkey ); |
|
114 return KErrNone; |
|
115 } |
|
116 |
|
117 |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CSatNotifyGetInkey::CancelNotification |
|
121 // This method cancels an outstanding asynchronous |
|
122 // NotifySimSessionEnd request. |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 TInt CSatNotifyGetInkey::CancelNotification |
|
126 ( |
|
127 const TTsyReqHandle aTsyReqHandle |
|
128 ) |
|
129 { |
|
130 TFLOGSTRING("CSAT: CSatNotifyGetInkey::CancelNotification"); |
|
131 // Reset the request handle |
|
132 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
133 ResetTsyReqHandle( CSatTsy::ESatNotifyGetInkeyPCmdReqType ); |
|
134 // Reset the data pointer |
|
135 iGetInkeyV2Pckg = NULL; |
|
136 // Complete the request with KErrCancel |
|
137 iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
138 return KErrNone; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSatNotifyGetInkey::CompleteNotifyL |
|
143 // Complete Sim Session End notification to the client |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CSatNotifyGetInkey::CompleteNotifyL |
|
147 ( |
|
148 CSatDataPackage* aDataPackage, |
|
149 TInt aErrorCode |
|
150 ) |
|
151 { |
|
152 TFLOGSTRING("CSAT: CSatNotifyGetInkey::CompleteNotifyL"); |
|
153 TInt ret( KErrNone ); |
|
154 TInt returnValue( KErrNone ); |
|
155 |
|
156 // Unpack parameters |
|
157 TPtrC8* data; |
|
158 aDataPackage->UnPackData( &data ); |
|
159 TBuf<1> additionalInfo; |
|
160 |
|
161 // Reset req handle. Returns the deleted req handle |
|
162 TTsyReqHandle reqHandle = |
|
163 iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( |
|
164 CSatTsy::ESatNotifyGetInkeyPCmdReqType ); |
|
165 |
|
166 // Get ber tlv |
|
167 CBerTlv berTlv; |
|
168 berTlv.SetData( *data ); |
|
169 // Get command details tlv |
|
170 CTlv commandDetails; |
|
171 berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); |
|
172 iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( |
|
173 commandDetails.Data() ); |
|
174 // Get command qualifier |
|
175 TUint8 cmdQualifier( commandDetails.GetShortInfo( |
|
176 ETLV_CommandQualifier ) ); |
|
177 |
|
178 TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); |
|
179 |
|
180 // In case the request was ongoing, continue.. |
|
181 if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
182 { |
|
183 // Complete right away if error has occured, otherwise continue.. |
|
184 if ( KErrNone == aErrorCode ) |
|
185 { |
|
186 // Fill the get inkey structure |
|
187 RSat::TGetInkeyV2& getInkeyV2 = ( *iGetInkeyV2Pckg )(); |
|
188 |
|
189 getInkeyV2.SetPCmdNumber( pCmdNumber ); |
|
190 |
|
191 if ( KYesNoMask & cmdQualifier ) |
|
192 { |
|
193 // The character set bits are disabled and yes/no response |
|
194 // is requested |
|
195 getInkeyV2.iRspFormat = RSat::EYesNo; |
|
196 iRequestedRspFormat = K8BitDCS; |
|
197 } |
|
198 else |
|
199 { |
|
200 // The character set bits are enabled |
|
201 if ( KAlphabetMask & cmdQualifier ) |
|
202 { |
|
203 // Character set selected |
|
204 if ( KUCS2AlphabetMask & cmdQualifier ) |
|
205 { |
|
206 // UCS2 alphabet selected |
|
207 getInkeyV2.iRspFormat = RSat::ECharUcs2Alphabet; |
|
208 iRequestedRspFormat = KUCS2DCS; |
|
209 } |
|
210 else |
|
211 { |
|
212 // SMS default alphabet selected |
|
213 getInkeyV2.iRspFormat = RSat::ECharSmsDefaultAlphabet; |
|
214 iRequestedRspFormat = K8BitDCS; |
|
215 } |
|
216 } |
|
217 else |
|
218 { |
|
219 // Digits only selected |
|
220 getInkeyV2.iRspFormat = RSat::EDigitOnly; |
|
221 iRequestedRspFormat = K8BitDCS; |
|
222 } |
|
223 } |
|
224 |
|
225 // Help information. |
|
226 if ( KHelpAvailabilityMask & cmdQualifier ) |
|
227 { |
|
228 // Help information available |
|
229 getInkeyV2.iHelp = RSat::EHelpAvailable; |
|
230 } |
|
231 else |
|
232 { |
|
233 TFLOGSTRING("CSAT: CSatNotifyGetInkey::CompleteNotifyL,\ |
|
234 No Help available"); |
|
235 // No help |
|
236 getInkeyV2.iHelp = RSat::ENoHelpAvailable; |
|
237 } |
|
238 |
|
239 // Response Mode |
|
240 getInkeyV2.iMode = RSat::EGetInkeyRspModeNotSet; |
|
241 if ( KImmediateDigitResponse & cmdQualifier ) |
|
242 { |
|
243 // An immediate digit response (0-9, * and #) is requested. |
|
244 getInkeyV2.iMode = RSat::EImmediateDigitRsp; |
|
245 } |
|
246 else |
|
247 { |
|
248 getInkeyV2.iMode = RSat::EUserRspDisplayed; |
|
249 } |
|
250 |
|
251 // Get Inkey text |
|
252 CTlv textString; |
|
253 returnValue = berTlv.TlvByTagValue( &textString, KTlvTextStringTag ); |
|
254 |
|
255 if ( KErrNone == returnValue ) |
|
256 { |
|
257 // Convert and set text |
|
258 TSatUtility::SetText( textString, getInkeyV2.iText ); |
|
259 } |
|
260 else |
|
261 { |
|
262 TFLOGSTRING("CSAT: CSatNotifyGetInkey::CompleteNotifyL,\ |
|
263 Required values missing"); |
|
264 additionalInfo.Zero(); |
|
265 additionalInfo.Append( KNoCause ); |
|
266 CreateTerminalRespL( pCmdNumber, |
|
267 RSat::KErrorRequiredValuesMissing, additionalInfo ); |
|
268 |
|
269 ret = KErrCorrupt; |
|
270 } |
|
271 |
|
272 // IconId Optional |
|
273 TSatUtility::FillIconStructure( berTlv, getInkeyV2.iIconId ); |
|
274 // Duration |
|
275 TSatUtility::FillDurationStructure( berTlv, getInkeyV2.iDuration ); |
|
276 } |
|
277 else |
|
278 { |
|
279 ret = aErrorCode; |
|
280 } |
|
281 |
|
282 iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); |
|
283 } |
|
284 else |
|
285 { |
|
286 TFLOGSTRING("CSAT: CSatNotifyGetInkey::CompleteNotifyL,\ |
|
287 Request not ongoing"); |
|
288 additionalInfo.Zero(); |
|
289 additionalInfo.Append( KNoCause ); |
|
290 CreateTerminalRespL( pCmdNumber, RSat::KMeUnableToProcessCmd, |
|
291 additionalInfo ); |
|
292 } |
|
293 |
|
294 return ret; |
|
295 } |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CSatNotifyGetInkey::TerminalResponseL |
|
299 // Called by ETel server, passes terminal response to SIM card |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 TInt CSatNotifyGetInkey::TerminalResponseL |
|
303 ( |
|
304 TDes8* aRsp |
|
305 ) |
|
306 { |
|
307 TFLOGSTRING("CSAT: CSatNotifyGetInkey::TerminalResponseL"); |
|
308 |
|
309 TInt ret( KErrNone ); |
|
310 |
|
311 RSat::TGetInkeyRspV2Pckg* aRspPckg = |
|
312 reinterpret_cast<RSat::TGetInkeyRspV2Pckg*>( aRsp ); |
|
313 RSat::TGetInkeyRspV2& rspV2 = ( *aRspPckg ) (); |
|
314 |
|
315 TUint8 pCmdNumber( rspV2.PCmdNumber() ); |
|
316 |
|
317 // Checking that infotype is valid |
|
318 if ( ( RSat::KMeProblem != rspV2.iInfoType ) && |
|
319 ( RSat::KTextString != rspV2.iInfoType ) && |
|
320 ( RSat::KNoAdditionalInfo != rspV2.iInfoType ) ) |
|
321 { |
|
322 TFLOGSTRING("CSAT: CSatNotifyGetInkey::TerminalResponseL,\ |
|
323 Invalid Infotype"); |
|
324 ret = KErrCorrupt; |
|
325 } |
|
326 |
|
327 // Checking that the response type is valid |
|
328 if ( ( RSat::EDigitOnly != rspV2.iRspFormat )&& |
|
329 ( RSat::ECharSmsDefaultAlphabet != rspV2.iRspFormat ) && |
|
330 ( RSat::ECharUcs2Alphabet != rspV2.iRspFormat ) && |
|
331 ( RSat::EYesNo != rspV2.iRspFormat ) ) |
|
332 { |
|
333 TFLOGSTRING("CSAT: CSatNotifyGetInkey::TerminalResponseL,\ |
|
334 Invalid Response Format"); |
|
335 ret = KErrCorrupt; |
|
336 } |
|
337 |
|
338 // Check that general result value is valid |
|
339 if ( ( RSat::KSuccess != rspV2.iGeneralResult ) && |
|
340 ( RSat::KPSessionTerminatedByUser != rspV2.iGeneralResult ) && |
|
341 ( RSat::KBackwardModeRequestedByUser != rspV2.iGeneralResult ) && |
|
342 ( RSat::KNoResponseFromUser != rspV2.iGeneralResult ) && |
|
343 ( RSat::KHelpRequestedByUser != rspV2.iGeneralResult ) && |
|
344 ( RSat::KMeUnableToProcessCmd != rspV2.iGeneralResult ) && |
|
345 ( RSat::KCmdBeyondMeCapabilities != rspV2.iGeneralResult ) && |
|
346 ( RSat::KErrorRequiredValuesMissing != rspV2.iGeneralResult ) && |
|
347 ( RSat::KSuccessRequestedIconNotDisplayed != rspV2.iGeneralResult )) |
|
348 { |
|
349 TFLOGSTRING("CSAT: CSatNotifyGetInkey::TerminalResponseL,\ |
|
350 Invalid General Result"); |
|
351 // Invalid general result |
|
352 ret = KErrCorrupt; |
|
353 } |
|
354 |
|
355 // If there is Me (Mobile Entity) error, additional info is needed |
|
356 if ( ( RSat::KMeProblem == rspV2.iInfoType ) && |
|
357 ( NULL == rspV2.iAdditionalInfo.Length() ) ) |
|
358 { |
|
359 TFLOGSTRING("CSAT: CSatNotifyGetInkey::TerminalResponseL,\ |
|
360 Invalid Additional Info, ME Problem"); |
|
361 // Invalid additional info field |
|
362 ret = KErrCorrupt; |
|
363 } |
|
364 |
|
365 if ( ( RSat::KTextString == rspV2.iInfoType ) && |
|
366 ( NULL == rspV2.iAdditionalInfo.Length() ) ) |
|
367 { |
|
368 TFLOGSTRING("CSAT: CSatNotifyGetInkey::TerminalResponseL,\ |
|
369 Invalid Additional Info"); |
|
370 ret = KErrCorrupt; |
|
371 } |
|
372 |
|
373 else |
|
374 { |
|
375 // Do nothing |
|
376 } |
|
377 |
|
378 CreateTerminalRespL( pCmdNumber, ( TUint8 ) rspV2.iGeneralResult , |
|
379 rspV2.iAdditionalInfo, iRequestedRspFormat ); |
|
380 |
|
381 return ret; |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CSatNotifyGetInkey::CreateTerminalRespL |
|
386 // Constructs GetInkey specific part of terminal response and calls |
|
387 // DOS to send the actual message. |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 TInt CSatNotifyGetInkey::CreateTerminalRespL |
|
391 ( |
|
392 TUint8 aPCmdNumber, |
|
393 TUint8 aGeneralResult, |
|
394 TDesC16& aAdditionalInfo, |
|
395 TUint8 aDcs |
|
396 ) |
|
397 { |
|
398 TFLOGSTRING("CSAT: CSatNotifyGetInkey::CreateTerminalRespL"); |
|
399 |
|
400 TTlv tlvSpecificData; |
|
401 tlvSpecificData.AddTag( KTlvResultTag ); |
|
402 // General result |
|
403 tlvSpecificData.AddByte( aGeneralResult ); |
|
404 |
|
405 if ( !( iNotificationsTsy->CommandPerformedSuccessfully( |
|
406 aGeneralResult ) ) ) |
|
407 { |
|
408 switch ( aGeneralResult ) |
|
409 { |
|
410 // Cases in which additional info is not required |
|
411 case RSat::KPSessionTerminatedByUser: |
|
412 case RSat::KBackwardModeRequestedByUser: |
|
413 case RSat::KNoResponseFromUser: |
|
414 case RSat::KErrorRequiredValuesMissing: |
|
415 case RSat::KHelpRequestedByUser: |
|
416 { |
|
417 break; |
|
418 } |
|
419 default: |
|
420 { |
|
421 if ( NULL != aAdditionalInfo.Length() ) |
|
422 { |
|
423 tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] ); |
|
424 } |
|
425 break; |
|
426 } |
|
427 } |
|
428 } |
|
429 else |
|
430 { |
|
431 tlvSpecificData.AddTag( KTlvTextStringTag ); |
|
432 tlvSpecificData.AddByte( aDcs ); |
|
433 TBuf8<2> character; |
|
434 |
|
435 if ( aDcs & KUCS2DCS ) |
|
436 { |
|
437 TSatUtility::Copy16to8LE( aAdditionalInfo, character); |
|
438 tlvSpecificData.AddData( character ); |
|
439 TFLOGSTRING2("CSAT:CSatNotifyGetInkey::CreateTerminalRespL, %s \ |
|
440 character", &character ); |
|
441 } |
|
442 else |
|
443 { |
|
444 if ( NULL != aAdditionalInfo.Length()) |
|
445 { |
|
446 TBuf<1> addInfo; |
|
447 addInfo.Append( aAdditionalInfo ); |
|
448 TSatUtility::ConvertUnicode16To7Bit( addInfo, character ); |
|
449 } |
|
450 else |
|
451 { |
|
452 character.Append( 0x00 ); |
|
453 } |
|
454 tlvSpecificData.AddData( character ); |
|
455 } |
|
456 } |
|
457 |
|
458 // Prepare data |
|
459 iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber; |
|
460 TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag(); |
|
461 |
|
462 // Pack data |
|
463 CSatDataPackage dataPackage; |
|
464 dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data ); |
|
465 |
|
466 // Forward request to the DOS |
|
467 return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( |
|
468 ESatTerminalRsp, &dataPackage ); |
|
469 } |
|
470 |
|
471 // End of file |
|
472 |