|
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 : CSatNotifySetupEventList.cpp |
|
15 // Part of : Common SIM ATK TSY / commonsimatktsy |
|
16 // Set Up event list 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 "CSatNotifySetUpEventList.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 // CSatNotifySetUpEventList::NewL |
|
37 // Two-phased constructor. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CSatNotifySetUpEventList* CSatNotifySetUpEventList::NewL |
|
41 ( |
|
42 CSatNotificationsTsy* aNotificationsTsy |
|
43 ) |
|
44 { |
|
45 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::NewL"); |
|
46 CSatNotifySetUpEventList* const satNotifySetUpEventList = |
|
47 new ( ELeave ) CSatNotifySetUpEventList( aNotificationsTsy ); |
|
48 CleanupStack::PushL( satNotifySetUpEventList ); |
|
49 satNotifySetUpEventList->ConstructL(); |
|
50 CleanupStack::Pop( satNotifySetUpEventList ); |
|
51 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::NewL, end of method"); |
|
52 return satNotifySetUpEventList; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSatNotifySetUpEventList::~CSatNotifySetUpEventList |
|
57 // Destructor |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CSatNotifySetUpEventList::~CSatNotifySetUpEventList |
|
61 ( |
|
62 // None |
|
63 ) |
|
64 { |
|
65 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::~CSatNotifySetUpEventList"); |
|
66 } |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSatNotifySetUpEventList::CSatNotifySetUpEventList |
|
69 // Default C++ constructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CSatNotifySetUpEventList::CSatNotifySetUpEventList |
|
73 ( |
|
74 CSatNotificationsTsy* aNotificationsTsy |
|
75 ) : iNotificationsTsy ( aNotificationsTsy ) |
|
76 { |
|
77 // None |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CSatNotifySetUpEventList::ConstructL |
|
82 // Symbian 2nd phase constructor |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CSatNotifySetUpEventList::ConstructL |
|
86 ( |
|
87 // None |
|
88 ) |
|
89 { |
|
90 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::ConstructL, does nothing"); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CSatNotifySetupEventList::Notify |
|
95 // Save the request handle type for notification requested by ETel server |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TInt CSatNotifySetUpEventList::Notify |
|
99 ( |
|
100 const TTsyReqHandle aTsyReqHandle, |
|
101 const TDataPackage& aPackage |
|
102 ) |
|
103 { |
|
104 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::Notify"); |
|
105 // Save data pointer to client side for completion |
|
106 iSetUpEventListV1Pckg = reinterpret_cast<RSat::TSetUpEventListV1Pckg*>( |
|
107 aPackage.Des1n() ); |
|
108 |
|
109 // Save the request handle |
|
110 iNotificationsTsy->iSatTsy->SaveReqHandle( aTsyReqHandle, |
|
111 CSatTsy::ESatNotifySetUpEventListPCmdReqType ); |
|
112 |
|
113 // Check if requested notification is already pending |
|
114 iNotificationsTsy->NotifySatReadyForNotification( KSetUpEventList ); |
|
115 |
|
116 return KErrNone; |
|
117 } |
|
118 |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CSatNotifySetupEventList::CancelNotification |
|
123 // This method cancels an outstanding asynchronous |
|
124 // NotifySetUpEventList request. |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CSatNotifySetUpEventList::CancelNotification |
|
128 ( |
|
129 const TTsyReqHandle aTsyReqHandle |
|
130 ) |
|
131 { |
|
132 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::CancelNotification"); |
|
133 |
|
134 // Reset the request handle |
|
135 iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( |
|
136 CSatTsy::ESatNotifySetUpEventListPCmdReqType ); |
|
137 |
|
138 // Reset the data pointer |
|
139 iSetUpEventListV1Pckg = NULL; |
|
140 // Complete the request with KErrCancel |
|
141 iNotificationsTsy->iSatTsy->ReqCompleted( aTsyReqHandle, KErrCancel ); |
|
142 |
|
143 return KErrNone; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CSatNotifySetupEventList::CompleteNotifyL |
|
148 // This method completes an outstanding asynchronous |
|
149 // SetUpEventList request. |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 TInt CSatNotifySetUpEventList::CompleteNotifyL |
|
153 ( |
|
154 CSatDataPackage* aDataPackage, |
|
155 TInt aErrorCode |
|
156 ) |
|
157 { |
|
158 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::CompleteNotifyL"); |
|
159 TInt ret( KErrNone ); |
|
160 TUint8 generalResult( RSat::KSuccess ); |
|
161 |
|
162 // Unpack parameters |
|
163 TPtrC8* data; |
|
164 aDataPackage->UnPackData( &data ); |
|
165 TBuf<1> additionalInfo; |
|
166 // Reset req handle. Returns the req handle |
|
167 TTsyReqHandle reqHandle = iNotificationsTsy->iSatReqHandleStore-> |
|
168 TsyReqHandle( CSatTsy::ESatNotifySetUpEventListPCmdReqType ); |
|
169 |
|
170 // Get ber tlv |
|
171 CBerTlv berTlv; |
|
172 berTlv.SetData( *data ); |
|
173 // Get command details tlv |
|
174 CTlv commandDetails; |
|
175 berTlv.TlvByTagValue( &commandDetails, KTlvCommandDetailsTag ); |
|
176 iNotificationsTsy->iTerminalRespData.iCommandDetails.Copy( |
|
177 commandDetails.Data() ); |
|
178 |
|
179 TUint8 pCmdNumber( commandDetails.GetShortInfo( ETLV_CommandNumber ) ); |
|
180 |
|
181 // In case the request was ongoing, continue.. |
|
182 if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
183 { |
|
184 // Complete right away if error has occured, otherwise continue.. |
|
185 if ( KErrNone == aErrorCode ) |
|
186 { |
|
187 // Let's fill the set up event list structure |
|
188 RSat::TSetUpEventListV1& setUpEventListV1 = |
|
189 ( *iSetUpEventListV1Pckg )(); |
|
190 |
|
191 setUpEventListV1.SetPCmdNumber( pCmdNumber ); |
|
192 |
|
193 CTlv eventListTlv; |
|
194 ret = berTlv.TlvByTagValue( &eventListTlv, KTlvEventListTag ); |
|
195 |
|
196 //Initialize Type to Not set |
|
197 setUpEventListV1.iType = RSat::ESetUpEventListTypeNotSet; |
|
198 |
|
199 // If the returnValue is KErrNone |
|
200 if ( KErrNone == ret ) |
|
201 { |
|
202 iEvents = 0; |
|
203 TPtrC8 setUpEventList = eventListTlv.GetData( ETLV_EventList ); |
|
204 TUint16 eventListLength = eventListTlv.GetLength(); |
|
205 if ( !eventListLength ) |
|
206 { |
|
207 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::\ |
|
208 CompleteNotifyL, Event list empty"); |
|
209 setUpEventListV1.iType = RSat::ERemoveExistingEventList; |
|
210 // Remove events from TSY:s list, No events = 0 |
|
211 iNotificationsTsy->iSatTsy->SetUpEventList( 0 ); |
|
212 } |
|
213 else |
|
214 { |
|
215 setUpEventListV1.iType = RSat::EUpdateEventList; |
|
216 TInt8 i( 0 ); |
|
217 TBuf8<14> eventListBuf; |
|
218 eventListBuf.FillZ( 14 ); |
|
219 for ( i = 0; i < eventListLength; i++ ) |
|
220 { |
|
221 if( KLocalConnection < setUpEventList[i] ) |
|
222 { |
|
223 // Invalid event code |
|
224 generalResult = RSat::KCmdBeyondMeCapabilities; |
|
225 } |
|
226 else if( !eventListBuf[setUpEventList[i]] ) |
|
227 { |
|
228 // Each event type shall not appear more than ones |
|
229 eventListBuf[ setUpEventList[i] ] = 0x01; |
|
230 |
|
231 switch( setUpEventList[i] ) |
|
232 { |
|
233 case KMTCall: |
|
234 { |
|
235 iEvents += RSat::KMTCall; |
|
236 break; |
|
237 } |
|
238 case KCallConnected: |
|
239 { |
|
240 iEvents += RSat::KCallConnected; |
|
241 break; |
|
242 } |
|
243 case KCallDisconnected: |
|
244 { |
|
245 iEvents += RSat::KCallDisconnected; |
|
246 break; |
|
247 } |
|
248 case KLocationStatus: |
|
249 { |
|
250 iEvents += RSat::KLocationStatus; |
|
251 break; |
|
252 } |
|
253 case KUserActivity: |
|
254 { |
|
255 setUpEventListV1.iEvents |
|
256 += RSat::KUserActivity; |
|
257 iEvents += RSat::KUserActivity; |
|
258 break; |
|
259 } |
|
260 case KIdleScreenAvailable: |
|
261 { |
|
262 setUpEventListV1.iEvents |
|
263 += RSat::KIdleScreenAvailable; |
|
264 iEvents += RSat::KIdleScreenAvailable; |
|
265 break; |
|
266 } |
|
267 case KCardReaderStatus: |
|
268 { |
|
269 setUpEventListV1.iEvents |
|
270 += RSat::KCardReaderStatus; |
|
271 iEvents += RSat::KCardReaderStatus; |
|
272 break; |
|
273 } |
|
274 case KLanguageSelection: |
|
275 { |
|
276 setUpEventListV1.iEvents |
|
277 += RSat::KLanguageSelection; |
|
278 iEvents += RSat::KLanguageSelection; |
|
279 break; |
|
280 } |
|
281 case KBrowserTermination: |
|
282 { |
|
283 setUpEventListV1.iEvents |
|
284 += RSat::KBrowserTermination; |
|
285 iEvents += RSat::KBrowserTermination; |
|
286 break; |
|
287 } |
|
288 case KDataAvailable: |
|
289 { |
|
290 setUpEventListV1.iEvents |
|
291 += RSat::KDataAvailable; |
|
292 iEvents += RSat::KDataAvailable; |
|
293 break; |
|
294 } |
|
295 case KChannelStatus: |
|
296 { |
|
297 setUpEventListV1.iEvents |
|
298 += RSat::KChannelStatus; |
|
299 iEvents += RSat::KChannelStatus; |
|
300 break; |
|
301 } |
|
302 case KAccessTechnologyChange: |
|
303 { |
|
304 iEvents += RSat::KAccessTechnologyChange; |
|
305 break; |
|
306 } |
|
307 case KDisplayParamsChanges: |
|
308 { |
|
309 setUpEventListV1.iEvents |
|
310 += RSat::KDisplayParamsChanges; |
|
311 iEvents += RSat::KDisplayParamsChanges; |
|
312 break; |
|
313 } |
|
314 case KLocalConnection: |
|
315 { |
|
316 setUpEventListV1.iEvents |
|
317 += RSat::KLocalConnection; |
|
318 iEvents += RSat::KLocalConnection; |
|
319 break; |
|
320 } |
|
321 default: |
|
322 { |
|
323 break; |
|
324 } |
|
325 } // switch ( setUpEventList[i] ) |
|
326 } // else if( !eventListBuf[setUpEventList[i]] ) |
|
327 } // for ( i = 0; i < eventListLength; i++ ) |
|
328 } // else ( if ( !eventListLength ) ) |
|
329 }// if( KErrNone == ret ) |
|
330 else |
|
331 { |
|
332 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::CompleteNotifyL,\ |
|
333 Event list missing"); |
|
334 // Event list is missing |
|
335 generalResult = RSat::KErrorRequiredValuesMissing; |
|
336 } |
|
337 }// if ( KErrNone == aErrorCode ) |
|
338 else |
|
339 { |
|
340 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::CompleteNotifyL,\ |
|
341 Error occurred in LSAT"); |
|
342 // Error code received from LicenceeSimAtkTsy |
|
343 return ret; |
|
344 } |
|
345 |
|
346 } // if ( CSatTsy::ESatReqHandleUnknown != reqHandle ) |
|
347 else |
|
348 { |
|
349 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::CompleteNotifyL,\ |
|
350 Request not ongoing"); |
|
351 generalResult = RSat::KMeUnableToProcessCmd; |
|
352 } |
|
353 |
|
354 if ( RSat::KSuccess != generalResult ) |
|
355 { |
|
356 additionalInfo.Zero(); |
|
357 additionalInfo.Append( KNoCause ); |
|
358 CreateTerminalRespL( pCmdNumber, generalResult, additionalInfo ); |
|
359 } |
|
360 else |
|
361 { |
|
362 // Reset req handle. Returns the deleted req handle |
|
363 TTsyReqHandle reqHandle = |
|
364 iNotificationsTsy->iSatReqHandleStore->ResetTsyReqHandle( |
|
365 CSatTsy::ESatNotifySetUpEventListPCmdReqType ); |
|
366 iNotificationsTsy->iSatTsy->ReqCompleted( reqHandle, ret ); |
|
367 } |
|
368 |
|
369 return ret; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CSatNotifySetupEventList::TerminalResponseL |
|
374 // Called by ETel server, passes terminal response to SIM card |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 TInt CSatNotifySetUpEventList::TerminalResponseL |
|
378 ( |
|
379 TDes8* aRsp |
|
380 ) |
|
381 { |
|
382 TFLOGSTRING("CSAT:CSatNotifySetUpEventList::TerminalResponseL"); |
|
383 |
|
384 TInt ret( KErrNone ); |
|
385 TBuf<1> additionalInfo; |
|
386 |
|
387 RSat::TSetUpEventListRspV1Pckg* aRspPckg = |
|
388 reinterpret_cast<RSat::TSetUpEventListRspV1Pckg*>( aRsp ); |
|
389 RSat::TSetUpEventListRspV1& rspV1 = ( *aRspPckg ) (); |
|
390 |
|
391 // Checking first that transaction ID is the same as in proactive message |
|
392 TUint8 pCmdNumber( rspV1.PCmdNumber() ); |
|
393 |
|
394 // Check that general result value is valid |
|
395 if ( ( RSat::KSuccess != rspV1.iGeneralResult ) |
|
396 && ( RSat::KCmdBeyondMeCapabilities != rspV1.iGeneralResult ) |
|
397 && ( RSat::KPartialComprehension != rspV1.iGeneralResult ) |
|
398 && ( RSat::KMissingInformation != rspV1.iGeneralResult ) |
|
399 && ( RSat::KMeUnableToProcessCmd != rspV1.iGeneralResult ) |
|
400 && ( RSat::KCmdTypeNotUnderstood != rspV1.iGeneralResult ) |
|
401 && ( RSat::KCmdDataNotUnderstood != rspV1.iGeneralResult ) |
|
402 && ( RSat::KCmdNumberNotKnown != rspV1.iGeneralResult ) |
|
403 && ( RSat::KErrorRequiredValuesMissing != rspV1.iGeneralResult ) ) |
|
404 { |
|
405 TFLOGSTRING("CSAT:CSatNotifySetUpEventList::TerminalResponseL,\ |
|
406 Invalid General Result"); |
|
407 // Invalid general result |
|
408 ret = KErrCorrupt; |
|
409 } |
|
410 |
|
411 if ((RSat::KMeUnableToProcessCmd == rspV1.iGeneralResult) && (RSat::KMeProblem != rspV1.iInfoType)) |
|
412 { |
|
413 // it's obligatory to provide additional info and KMeProblem flag for KMeUnableToProcessCmd error code |
|
414 TFLOGSTRING("CSAT:CSatNotifySetUpEventList::TerminalResponseL,\ |
|
415 KMeProblem flag is not specified"); |
|
416 ret = KErrCorrupt; |
|
417 } |
|
418 |
|
419 // If there is Me (Mobile Entity) error, additional info is needed |
|
420 if ( ( RSat::KMeProblem == rspV1.iInfoType ) ) |
|
421 { |
|
422 // Check the length of additional info |
|
423 if ( 0 != rspV1.iAdditionalInfo.Length() ) |
|
424 { |
|
425 additionalInfo.Append( ( TUint8 )rspV1.iAdditionalInfo[0] ); |
|
426 } |
|
427 else |
|
428 { |
|
429 TFLOGSTRING("CSAT:CSatNotifySetUpEventList::TerminalResponseL,\ |
|
430 Invalid Additional Info"); |
|
431 // Invalid additional info field |
|
432 ret = KErrCorrupt; |
|
433 } |
|
434 } |
|
435 |
|
436 if( RSat::KSuccess == rspV1.iGeneralResult ) |
|
437 { |
|
438 // Set events to TSY:s list |
|
439 iNotificationsTsy->iSatTsy->SetUpEventList( iEvents ); |
|
440 } |
|
441 |
|
442 // Creating the terminal response message |
|
443 TInt response = CreateTerminalRespL( pCmdNumber, static_cast<TUint8>( |
|
444 rspV1.iGeneralResult ), additionalInfo ); |
|
445 |
|
446 if(KErrNone == ret) |
|
447 ret = response; |
|
448 |
|
449 return ret; |
|
450 } |
|
451 |
|
452 // ----------------------------------------------------------------------------- |
|
453 // CSatNotifySetupEventList::CreateTerminalRespL |
|
454 // Constructs SetUpEventList specific part of terminal response and calls |
|
455 // DOS to send the actual message. |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 TInt CSatNotifySetUpEventList::CreateTerminalRespL |
|
459 ( |
|
460 TUint8 aPCmdNumber, |
|
461 TUint8 aGeneralResult, |
|
462 TDesC16& aAdditionalInfo |
|
463 ) |
|
464 { |
|
465 TFLOGSTRING("CSAT: CSatNotifySetUpEventList::CreateTerminalRespL"); |
|
466 // Create and append response data |
|
467 TTlv tlvSpecificData; |
|
468 // Create General Result TLV here |
|
469 tlvSpecificData.AddTag( KTlvResultTag ); |
|
470 // General result |
|
471 tlvSpecificData.AddByte( aGeneralResult ); |
|
472 |
|
473 if ( ( RSat::KSuccess != aGeneralResult ) && |
|
474 ( RSat::KCmdBeyondMeCapabilities != aGeneralResult ) && |
|
475 ( RSat::KErrorRequiredValuesMissing != aGeneralResult ) ) |
|
476 { |
|
477 if ( aAdditionalInfo.Length()>0 ) |
|
478 { |
|
479 tlvSpecificData.AddByte( ( TUint8 ) aAdditionalInfo[0] ); |
|
480 } |
|
481 } |
|
482 |
|
483 // Prepare data |
|
484 iNotificationsTsy->iTerminalRespData.iPCmdNumber = aPCmdNumber; |
|
485 TPtrC8 data = tlvSpecificData.GetDataWithoutTopLevelTag(); |
|
486 // Pack data |
|
487 CSatDataPackage dataPackage; |
|
488 dataPackage.PackData( &iNotificationsTsy->iTerminalRespData, &data ); |
|
489 |
|
490 // Forward request to the DOS |
|
491 return iNotificationsTsy->iSatTsy->MessageManager()->HandleRequestL( |
|
492 ESatTerminalRsp, &dataPackage ); |
|
493 } |
|
494 |
|
495 // End of file |
|
496 |