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: Container of event monitor classes |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <f32file.h> |
|
22 #include <syslangutil.h> |
|
23 #include "MSatEventMonitor.h" |
|
24 #include "MSatUtils.h" |
|
25 #include "MSatBIPUtils.h" |
|
26 #include "MSatSystemState.h" |
|
27 #include "TSatEventMonitorFactory.h" |
|
28 #include "CSatEventMonitorContainer.h" |
|
29 //lint -e766 Used inside TRAP macro, lint misfunction. |
|
30 #include "EnginePanic.h" |
|
31 #include "TUSatAPI.h" |
|
32 #include "SatSOpcodes.h" |
|
33 #include "SatLog.h" |
|
34 |
|
35 // CONSTANTS |
|
36 const TUint KLangTextSize( 2 ); |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CSatEventMonitorContainer::NewL |
|
42 // Two-phased constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CSatEventMonitorContainer* CSatEventMonitorContainer::NewL( |
|
46 TUSatAPI& aUsatAPI, |
|
47 MSatUtils& aSatUtils ) |
|
48 { |
|
49 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::NewL calling" ) |
|
50 |
|
51 CSatEventMonitorContainer* self = |
|
52 new( ELeave )CSatEventMonitorContainer( aUsatAPI, aSatUtils ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( /* self */ ); |
|
56 |
|
57 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::NewL exiting" ) |
|
58 return self; |
|
59 } |
|
60 |
|
61 // Destructor |
|
62 CSatEventMonitorContainer::~CSatEventMonitorContainer() |
|
63 { |
|
64 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
65 ~CSatEventMonitorContainer calling" ) |
|
66 |
|
67 iEventMonitors = NULL; |
|
68 |
|
69 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
70 ~CSatEventMonitorContainer exiting" ) |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CSatEventMonitorContainer::Event |
|
75 // From MSatEventObserver |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CSatEventMonitorContainer::Event( TInt aEvent ) |
|
79 { |
|
80 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::Event calling" ) |
|
81 |
|
82 //lint -e{961} else block meaningless, event handled elsewhere. |
|
83 if ( MSatUtils::EBipCommandExecuting == aEvent ) |
|
84 { |
|
85 LOG( SIMPLE, "EventMonitor: BIP Command Executing" ) |
|
86 iBipExecuting = ETrue; |
|
87 } |
|
88 else if ( MSatUtils::EBipCommandDoneExecuting == aEvent ) |
|
89 { |
|
90 LOG( SIMPLE, "EventMonitor: BIP Command NOT executing" ) |
|
91 iBipExecuting = EFalse; |
|
92 |
|
93 if ( iEventPending ) |
|
94 { |
|
95 iEventPending = EFalse; |
|
96 LOG( SIMPLE, "EventMonitor: Executing pending envelope" ) |
|
97 EventDownload( iPendingEvent, iPendingFirstArg, iPendingSecondArg ); |
|
98 } |
|
99 } |
|
100 |
|
101 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::Event exiting" ) |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CSatEventMonitorContainer::SetUpEventMonitors |
|
106 // Updates all event monitors in list. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TInt CSatEventMonitorContainer::SetUpEventMonitors( TUint aEvents ) |
|
110 { |
|
111 LOG2( SIMPLE, |
|
112 "SATENGINE: CSatEventMonitorContainer::SetUpEventMonitors calling %d", |
|
113 aEvents ) |
|
114 const TInt monitorCount( iEventMonitors->Count() ); |
|
115 TInt errCode = KErrNotSupported; |
|
116 LOG2( SIMPLE, "SATENGINE: CSatEventMonitorContainer::SetUpEventMonitors \ |
|
117 monitorCount: %i", monitorCount ) |
|
118 // Check is events supported |
|
119 if ( EventsSupported( aEvents ) ) |
|
120 { |
|
121 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
122 SetUpEventMonitors events supported" ) |
|
123 // Update all monitors from list |
|
124 for ( TInt index = 0; index < monitorCount; index++ ) |
|
125 { |
|
126 MSatEventMonitor* monitor = iEventMonitors->At( index ); |
|
127 __ASSERT_ALWAYS( monitor, PanicSatEngine( ESatEngineNullPointer ) ); |
|
128 // Update monitor |
|
129 errCode = monitor->UpdateMonitor( aEvents ); |
|
130 |
|
131 if ( KErrNone != errCode ) |
|
132 { |
|
133 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
134 SetUpEventMonitors KErrNone != errCode" ) |
|
135 // Error, cancel all monitors and end this loop |
|
136 CancelAllMonitors(); |
|
137 index = monitorCount; |
|
138 } |
|
139 } |
|
140 } |
|
141 |
|
142 LOG2( SIMPLE, |
|
143 "SATENGINE: CSatEventMonitorContainer::SetUpEventMonitors exiting %d", |
|
144 errCode ) |
|
145 |
|
146 return errCode; |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CSatEventMonitorContainer::CancelAllMonitors |
|
151 // Cancels all monitors in list. |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 TInt CSatEventMonitorContainer::CancelAllMonitors() |
|
155 { |
|
156 LOG( SIMPLE, |
|
157 "SATENGINE: CSatEventMonitorContainer::CancelAllMonitors calling" ) |
|
158 |
|
159 const TInt monitorCount( iEventMonitors->Count() ); |
|
160 LOG2( SIMPLE, "SATENGINE: CSatEventMonitorContainer::CancelAllMonitors \ |
|
161 monitorCount: %i", monitorCount ) |
|
162 // Cancel all monitors from list |
|
163 for ( TInt index = 0; index < monitorCount; index++ ) |
|
164 { |
|
165 MSatEventMonitor* monitor = iEventMonitors->At( index ); |
|
166 __ASSERT_ALWAYS( monitor, PanicSatEngine( ESatEngineNullPointer ) ); |
|
167 // Cancel monitor |
|
168 monitor->CancelMonitor(); |
|
169 } |
|
170 |
|
171 LOG( SIMPLE, |
|
172 "SATENGINE: CSatEventMonitorContainer::CancelAllMonitors exiting" ) |
|
173 |
|
174 return KErrNone; |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CSatEventMonitorContainer::LanguageSettingL |
|
179 // Resolves language ID |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CSatEventMonitorContainer::LanguageSettingL( TInt& aLanguage ) |
|
183 { |
|
184 LOG( SIMPLE, |
|
185 "SATENGINE: CSatEventMonitorContainer::LanguageSettingL calling" ) |
|
186 |
|
187 // Automatic Language setting is detected as 0. |
|
188 // There is no header file for this. This is only needed here. |
|
189 const TInt KAutomaticLanguageSetting( 0 ); |
|
190 |
|
191 // Special treatment for automatic language setting. |
|
192 if ( KAutomaticLanguageSetting == aLanguage ) |
|
193 { |
|
194 // Automatic language setting - Tries to take preferred |
|
195 // language from SIM card. |
|
196 |
|
197 // The following operations need a file server session. |
|
198 RFs fileServerSession; |
|
199 User::LeaveIfError( fileServerSession.Connect() ); |
|
200 CleanupClosePushL( fileServerSession ); |
|
201 |
|
202 // Automatic language setting |
|
203 // 1) look for SIM Preferred Language |
|
204 // 2) look if language is supported in phone |
|
205 // |
|
206 |
|
207 // Preferred language from SIM (Symbian coding). |
|
208 TInt simPreferredLanguageSymbianCoding; |
|
209 |
|
210 // Fetch SIM preferred language (Symbian coding) and see if it is |
|
211 // supported |
|
212 if ( KErrNone == SysLangUtil::RestoreSIMLanguage |
|
213 ( simPreferredLanguageSymbianCoding, &fileServerSession ) |
|
214 && SysLangUtil::IsValidLanguage |
|
215 ( simPreferredLanguageSymbianCoding, &fileServerSession ) ) |
|
216 { |
|
217 aLanguage = simPreferredLanguageSymbianCoding; |
|
218 LOG2( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
219 LanguageSettingL SIM preferred language is supported %d", |
|
220 aLanguage ) |
|
221 } |
|
222 else |
|
223 { |
|
224 // Either there is no SIM preferred language, or the SIM preferred |
|
225 // language is not supported. Then default language is used. |
|
226 SysLangUtil::GetDefaultLanguage( aLanguage, &fileServerSession ); |
|
227 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
228 LanguageSettingL No SIM preferred language" ) |
|
229 } |
|
230 |
|
231 CleanupStack::PopAndDestroy(); // fileServerSession |
|
232 } |
|
233 |
|
234 LOG( SIMPLE, |
|
235 "SATENGINE: CSatEventMonitorContainer::LanguageSettingL exiting" ) |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CSatEventMonitorContainer::EventDownload |
|
240 // Called when an event occurs. Handles that event and possibly sends |
|
241 // event download to SIM. |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CSatEventMonitorContainer::EventDownload( |
|
245 RSat::TEventList aSingleEvent, TInt aFirstArg, TInt aSecArg ) |
|
246 { |
|
247 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::EventDownload calling" ) |
|
248 |
|
249 //lint -e{961} Else block meaningless |
|
250 if ( ( iBipExecuting || IsActive() ) && !iEventPending ) |
|
251 { |
|
252 LOG( NORMAL, "EventMonitor: EventDownload BIP Command Executing" ) |
|
253 // If there is event download currently active, we cannot send next |
|
254 // event download, so we have to store this event. |
|
255 iPendingEvent = aSingleEvent; |
|
256 iPendingFirstArg = aFirstArg; |
|
257 iPendingSecondArg = aSecArg; |
|
258 iEventPending = ETrue; |
|
259 } |
|
260 else if ( !iEventPending ) |
|
261 { |
|
262 // No pending events, we can execute |
|
263 switch ( aSingleEvent ) |
|
264 { |
|
265 case RSat::KLanguageSelection: |
|
266 { |
|
267 LOG( NORMAL, "SATENGINE: Event LanguageSelection" ) |
|
268 LanguageSelectionEvent( aFirstArg ); |
|
269 break; |
|
270 } |
|
271 |
|
272 case RSat::KBrowserTermination: |
|
273 { |
|
274 LOG( NORMAL, "SATENGINE: Event BrowserTermination" ) |
|
275 BrowserTerminationEvent( aFirstArg ); |
|
276 break; |
|
277 } |
|
278 |
|
279 case RSat::KDataAvailable: |
|
280 { |
|
281 LOG( NORMAL, "SATENGINE: Event DataAvailable" ) |
|
282 DataAvailableEvent( aFirstArg, aSecArg ); |
|
283 break; |
|
284 } |
|
285 |
|
286 case RSat::KChannelStatus: |
|
287 { |
|
288 LOG( NORMAL, "SATENGINE: Event ChannelStatus" ) |
|
289 ChannelStatusEvent( aFirstArg, aSecArg ); |
|
290 break; |
|
291 } |
|
292 |
|
293 // These events does not have any data to be sent |
|
294 // to SIM |
|
295 case RSat::KUserActivity: |
|
296 case RSat::KIdleScreenAvailable: |
|
297 { |
|
298 LOG( NORMAL, "SATENGINE: Event UserActivity/IdleScreen" ) |
|
299 RSat::TEventDownloadBaseV2 eventDownload; |
|
300 RSat::TEventDownloadBaseV2Pckg eventDownloadPckg( |
|
301 eventDownload ); |
|
302 eventDownload.iDataAvailable = EFalse; |
|
303 iSat.EventDownload( iStatus, aSingleEvent, eventDownloadPckg ); |
|
304 iRemovableSingleEvent = aSingleEvent; |
|
305 break; |
|
306 } |
|
307 |
|
308 default: |
|
309 { |
|
310 LOG( NORMAL, "SATENGINE: BadRequest" ) |
|
311 __ASSERT_DEBUG( EFalse, PanicSatEngine( ESatSBadRequest ) ); |
|
312 } |
|
313 } |
|
314 |
|
315 SetActive(); |
|
316 } |
|
317 |
|
318 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::EventDownload exiting" ) |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CSatEventMonitorContainer::BipUtils |
|
323 // Returns the interface for BIP Utils |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 MSatBIPEventNotifier& CSatEventMonitorContainer::BipNotifier() |
|
327 { |
|
328 LOG( SIMPLE, |
|
329 "SATENGINE: CSatEventMonitorContainer::BipUtils calling-exiting" ) |
|
330 return iSatUtils.BipEventNotifier(); |
|
331 } |
|
332 |
|
333 // ----------------------------------------------------------------------------- |
|
334 // CSatEventMonitorContainer::SimRemoved |
|
335 // Updates event monitor list |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 void CSatEventMonitorContainer::SimRemoved() |
|
339 { |
|
340 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::SimRemoved calling" ) |
|
341 |
|
342 // If SIM is removed, all monitors must be cancelled. |
|
343 CancelAllMonitors(); |
|
344 |
|
345 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::SimRemoved exiting" ) |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CSatEventMonitorContainer::GetLanguageString |
|
350 // Gets the ISO639 language code. |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 void CSatEventMonitorContainer::GetLanguageString( const TInt aId, TDes& aText ) |
|
354 { |
|
355 LOG( SIMPLE, |
|
356 "SATENGINE: CSatEventMonitorContainer::GetLanguageString calling" ) |
|
357 |
|
358 aText = KNullDesC; |
|
359 TBuf<KLangTextSize> lanText; |
|
360 lanText.Copy( KNullDesC ); |
|
361 |
|
362 // Number of Symbian languages. |
|
363 TInt count( KNUMLANGSTRINGS ); |
|
364 // Index for searching loop. |
|
365 TInt i( 0 ); |
|
366 // Language structure for searching loop. |
|
367 SLangString language( KLangStrings[i] ); |
|
368 |
|
369 // Loop languages until one is found |
|
370 do { |
|
371 language = KLangStrings[i]; |
|
372 // Finds the appropriate language and gives a code for that. |
|
373 if ( language.iId == aId ) |
|
374 { |
|
375 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
376 GetLanguageString language.iId == aId" ) |
|
377 // Current language code in the loop is appended to reference. |
|
378 lanText.Append( |
|
379 *( language.iString ) << 8 | *( language.iString + 1 ) ); |
|
380 } |
|
381 i++; |
|
382 } |
|
383 while ( ( i <= count ) && ( language.iId != aId ) ); |
|
384 |
|
385 aText.Copy( lanText ); |
|
386 LOG2( SIMPLE, |
|
387 "SATENGINE: CSatEventMonitorContainer::GetLanguageString aId: %i", aId ) |
|
388 LOG2( SIMPLE, |
|
389 "SATENGINE: CSatEventMonitorContainer::GetLanguageString aId: %S", |
|
390 &aText ) |
|
391 LOG( SIMPLE, |
|
392 "SATENGINE: CSatEventMonitorContainer::GetLanguageString exiting" ) |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CSatEventMonitorContainer::RunL |
|
397 // From CActive |
|
398 // ----------------------------------------------------------------------------- |
|
399 // |
|
400 void CSatEventMonitorContainer::RunL() |
|
401 { |
|
402 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::RunL calling" ) |
|
403 |
|
404 if ( KErrCancel != iRemovableSingleEvent ) |
|
405 { |
|
406 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::RunL \ |
|
407 KErrCancel != iRemovableSingleEvent" ) |
|
408 //Remove event from list as these are not continuous events |
|
409 RemoveSingleEvent( |
|
410 static_cast<RSat::TEventList>( iRemovableSingleEvent ) ); |
|
411 iRemovableSingleEvent = KErrCancel; |
|
412 } |
|
413 |
|
414 // Check the request status |
|
415 if ( KErrNone != iStatus.Int() ) |
|
416 { |
|
417 LOG2( SIMPLE, |
|
418 "SATENGINE: CSatEventMonitorContainer::RunL with value %d", |
|
419 iStatus.Int() ) |
|
420 } |
|
421 |
|
422 // If there are events pending, send now |
|
423 if ( iEventPending ) |
|
424 { |
|
425 LOG( SIMPLE, |
|
426 "SATENGINE: CSatEventMonitorContainer::RunL Sending pending event" ) |
|
427 iEventPending = EFalse; |
|
428 |
|
429 // Send event |
|
430 EventDownload( iPendingEvent, iPendingFirstArg, iPendingSecondArg ); |
|
431 } |
|
432 |
|
433 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::RunL exiting" ) |
|
434 } |
|
435 |
|
436 // ----------------------------------------------------------------------------- |
|
437 // CSatEventMonitorContainer::DoCancel |
|
438 // From CActive |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 void CSatEventMonitorContainer::DoCancel() |
|
442 { |
|
443 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::DoCancel calling" ) |
|
444 |
|
445 CancelAllMonitors(); |
|
446 |
|
447 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::DoCancel exiting" ) |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // CSatEventMonitorContainer::CSatEventMonitorContainer |
|
452 // C++ default constructor can NOT contain any code, that |
|
453 // might leave. |
|
454 // ----------------------------------------------------------------------------- |
|
455 // |
|
456 CSatEventMonitorContainer::CSatEventMonitorContainer( TUSatAPI& aUsatAPI, |
|
457 MSatUtils& aSatUtils ) : |
|
458 CActive ( CActive::EPriorityStandard ), |
|
459 iSat( aUsatAPI ), |
|
460 iSatUtils( aSatUtils ) |
|
461 { |
|
462 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
463 CSatEventMonitorContainer calling" ) |
|
464 |
|
465 CActiveScheduler::Add( this ); |
|
466 |
|
467 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
468 CSatEventMonitorContainer exiting" ) |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // CSatEventMonitorContainer::ConstructL |
|
473 // Symbian 2nd phase constructor can leave. |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void CSatEventMonitorContainer::ConstructL() |
|
477 { |
|
478 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::ConstructL calling" ) |
|
479 |
|
480 iEventMonitors = TSatEventMonitorFactory::CreateEventMonitorsL( *this ); |
|
481 iRemovableSingleEvent = KErrCancel; |
|
482 |
|
483 iSatUtils.RegisterL( this, MSatUtils::EBipCommandExecuting ); |
|
484 iSatUtils.RegisterL( this, MSatUtils::EBipCommandDoneExecuting ); |
|
485 |
|
486 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::ConstructL exiting" ) |
|
487 } |
|
488 |
|
489 // ----------------------------------------------------------------------------- |
|
490 // CSatEventMonitorContainer::LanguageSelectionEvent |
|
491 // Handles LanguageSelection event and sends event download |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void CSatEventMonitorContainer::LanguageSelectionEvent( TInt aLanguageId ) |
|
495 { |
|
496 LOG( SIMPLE, |
|
497 "SATENGINE: CSatEventMonitorContainer::LanguageSelectionEvent calling" ) |
|
498 |
|
499 // Special event download package, |
|
500 // used exclusively for Language Selection events |
|
501 RSat::TLanguageSelectionEventV2 languageDownload; |
|
502 RSat::TLanguageSelectionEventV2Pckg languageDownloadPckg( |
|
503 languageDownload ); |
|
504 languageDownload.iDataAvailable = EFalse; |
|
505 |
|
506 // Resolve Language ID |
|
507 TRAPD( err, LanguageSettingL( aLanguageId ) ); |
|
508 LOG2( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
509 LanguageSelectionEvent err: %i", err ) |
|
510 if ( KErrNone == err ) |
|
511 { |
|
512 // Get Language string |
|
513 TBuf<1> languageTxt; |
|
514 GetLanguageString( aLanguageId, languageTxt ); |
|
515 |
|
516 // If language is found, put it to event download information |
|
517 if ( languageTxt.Length() != 0 ) |
|
518 { |
|
519 LOG( SIMPLE, |
|
520 "SATENGINE: CSatEventMonitorContainer::LanguageSelectionEvent \ |
|
521 languageTxt.Length() != 0" ) |
|
522 |
|
523 // Language selection event does have data. |
|
524 languageDownload.iDataAvailable = ETrue; |
|
525 |
|
526 // Integer argument is interpreted as language code. |
|
527 languageDownload.iLanguage = |
|
528 static_cast<TUint16>( languageTxt[0] ); |
|
529 } |
|
530 } |
|
531 |
|
532 // Send EventDownload to SIM |
|
533 iSat.EventDownload( |
|
534 iStatus, |
|
535 RSat::KLanguageSelection, |
|
536 languageDownloadPckg ); |
|
537 |
|
538 LOG( SIMPLE, |
|
539 "SATENGINE: CSatEventMonitorContainer::LanguageSelectionEvent exiting" ) |
|
540 } |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // CSatEventMonitorContainer::BrowserTerminationEvent |
|
544 // Handles browser termination event and sends event download |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 void CSatEventMonitorContainer::BrowserTerminationEvent( TInt aCause ) |
|
548 { |
|
549 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
550 BrowserTerminationEvent calling" ) |
|
551 |
|
552 // Special event download package, |
|
553 // used exclusively for Browser termination events. |
|
554 RSat::TBrowserTerminationEventV2 browserTermination; |
|
555 RSat::TBrowserTerminationEventV2Pckg browserTerminationPckg( |
|
556 browserTermination ); |
|
557 |
|
558 // Language selection event does have data. |
|
559 browserTermination.iDataAvailable = ETrue; |
|
560 |
|
561 // Browser termination event does have data. |
|
562 browserTermination.iCause = |
|
563 static_cast<RSat::TBrowserTerminationCause>( aCause ); |
|
564 |
|
565 // Send event download |
|
566 iSat.EventDownload( |
|
567 iStatus, |
|
568 RSat::KBrowserTermination, |
|
569 browserTerminationPckg ); |
|
570 |
|
571 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
572 BrowserTerminationEvent exiting" ) |
|
573 } |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // CSatEventMonitorContainer::DataAvailableEvent |
|
577 // Handles DataAvailable event and sends event download |
|
578 // ----------------------------------------------------------------------------- |
|
579 // |
|
580 void CSatEventMonitorContainer::DataAvailableEvent( |
|
581 const TInt aChannelId, const TInt aLength ) |
|
582 { |
|
583 LOG( SIMPLE, |
|
584 "SATENGINE: CSatEventMonitorContainer::DataAvailableEvent calling" ) |
|
585 |
|
586 RSat::TDataAvailableEventV2 dataAvailable; |
|
587 RSat::TDataAvailableEventV2Pckg dataAvailablePckg( dataAvailable ); |
|
588 RSat::TChannelStatus status; |
|
589 |
|
590 // BIP Utils will generate channel status |
|
591 TRAPD( err, |
|
592 status = iSatUtils.BipUtils().GenerateChannelStatusL( aChannelId, 0 ) ); |
|
593 |
|
594 // Check error |
|
595 LOG2( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
596 DataAvailableEvent ChannelStatus failed: %i", err ) |
|
597 if ( KErrNone == err ) |
|
598 { |
|
599 // Put the parameters to data package |
|
600 dataAvailable.iDataAvailable = ETrue; |
|
601 // If received more than 0xFF, we return 0xFF, because that iLength can |
|
602 // contain only one byte. |
|
603 TInt8 length( 0 ); |
|
604 |
|
605 if ( KSatBIPMoreThanMaxSize < aLength ) |
|
606 { |
|
607 LOG( SIMPLE, "SATENGINE: CSatEventMonitorContainer::\ |
|
608 DataAvailableEvent KSatBIPMoreThanMaxSize < aLength" ) |
|
609 length = static_cast<TInt8>( KSatBIPMoreThanMaxSize ); |
|
610 } |
|
611 else |
|
612 { |
|
613 length = static_cast<TInt8>( aLength ); |
|
614 } |
|
615 |
|
616 dataAvailable.iLength = length; |
|
617 dataAvailable.iStatus = status; |
|
618 // Send EventDownload to SIM |
|
619 iSat.EventDownload( |
|
620 iStatus, |
|
621 RSat::KDataAvailable, |
|
622 dataAvailablePckg ); |
|
623 } |
|
624 |
|
625 LOG( SIMPLE, |
|
626 "SATENGINE: CSatEventMonitorContainer::DataAvailableEvent exiting" ) |
|
627 } |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CSatEventMonitorContainer::ChannelStatusEvent |
|
631 // Handles ChannelStatus event and sends event download |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CSatEventMonitorContainer::ChannelStatusEvent( const TInt aChannelId, |
|
635 const TInt aStatus ) |
|
636 { |
|
637 LOG( SIMPLE, |
|
638 "SATENGINE: CSatEventMonitorContainer::ChannelStatusEvent calling" ) |
|
639 |
|
640 RSat::TChannelStatusEventV2 channelStatus; |
|
641 RSat::TChannelStatusEventV2Pckg channelStatusPckg( channelStatus ); |
|
642 RSat::TChannelStatus status; |
|
643 |
|
644 // BIP Utils will generate channel status |
|
645 TRAPD( err, status = iSatUtils.BipUtils().GenerateChannelStatusL( |
|
646 aChannelId, aStatus ) ); |
|
647 |
|
648 // Check error |
|
649 LOG2( NORMAL, "SATENGINE: CSatEventMonitorContainer::\ |
|
650 ChannelStatusEvent ChannelStatus failed: %i", err ) |
|
651 if ( KErrNone == err ) |
|
652 { |
|
653 |
|
654 LOG2( SIMPLE, "SatServer, ChannelStatus envelope: %b", status[0] ) |
|
655 // Put the parameters to data package |
|
656 channelStatus.iDataAvailable = ETrue; |
|
657 channelStatus.iStatus = status; |
|
658 // Send EventDownload to SIM |
|
659 iSat.EventDownload( |
|
660 iStatus, |
|
661 RSat::KChannelStatus, |
|
662 channelStatusPckg ); |
|
663 } |
|
664 |
|
665 LOG( SIMPLE, |
|
666 "SATENGINE: CSatEventMonitorContainer::ChannelStatusEvent exiting" ) |
|
667 } |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // CSatEventMonitorContainer::EventsSupported |
|
671 // Checks whether aEvents contains supported events only. |
|
672 // (other items were commented in a header). |
|
673 // ----------------------------------------------------------------------------- |
|
674 // |
|
675 TBool CSatEventMonitorContainer::EventsSupported( TUint aEvents ) const |
|
676 { |
|
677 LOG( SIMPLE, |
|
678 "SATENGINE: CSatEventMonitorContainer::EventsSupported calling" ) |
|
679 |
|
680 // Events supported and handled by this class. |
|
681 const TUint eventsSupported = |
|
682 RSat::KUserActivity | RSat::KIdleScreenAvailable | |
|
683 RSat::KLanguageSelection | RSat::KBrowserTermination | |
|
684 RSat::KDataAvailable | RSat::KChannelStatus; |
|
685 |
|
686 // If aEvents has even one event that is not supported (not found from |
|
687 // eventsSuported), then EventsSupported returns EFalse. |
|
688 |
|
689 // First the eventsSupported is masked and bits are inverted. Then that mask |
|
690 // is compared to aEvents and if there is even one bit that is not supposed |
|
691 // to be there, function returns EFalse. |
|
692 |
|
693 const TBool supported( !( ~( eventsSupported ) & aEvents ) ); |
|
694 |
|
695 LOG2( SIMPLE, |
|
696 "SATENGINE: CSatEventMonitorContainer::EventsSupported returning %i", |
|
697 supported ) |
|
698 return supported; |
|
699 } |
|
700 |
|
701 // ----------------------------------------------------------------------------- |
|
702 // CSatEventMonitorContainer::WriteLanguageSelectionTime |
|
703 // Sets time delay before reboot. |
|
704 // (other items were commented in a header). |
|
705 // ----------------------------------------------------------------------------- |
|
706 // |
|
707 TInt CSatEventMonitorContainer::WriteLanguageSelectionTime( TInt aTime ) |
|
708 { |
|
709 LOG( SIMPLE, |
|
710 "SATENGINE: CSatEventMonitorContainer::WriteLanguageSelectionTime \ |
|
711 calling-exiting" ) |
|
712 return iSatUtils.SystemState().WriteLanguageSelectionTime( aTime ); |
|
713 } |
|
714 |
|
715 // ----------------------------------------------------------------------------- |
|
716 // CSatEventMonitorContainer::RemoveSingleEvent |
|
717 // Removes single event from list |
|
718 // (other items were commented in a header). |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CSatEventMonitorContainer::RemoveSingleEvent( |
|
722 RSat::TEventList aSingleEvent ) |
|
723 { |
|
724 LOG( SIMPLE, |
|
725 "SATENGINE: CSatEventMonitorContainer::RemoveSingleEvent calling" ) |
|
726 |
|
727 const TInt monitorCount( iEventMonitors->Count() ); |
|
728 LOG2( SIMPLE, "SATENGINE: CSatEventMonitorContainer::RemoveSingleEvent \ |
|
729 monitorCount: %i", monitorCount ) |
|
730 |
|
731 // Cancel all monitors from list |
|
732 for ( TInt index = 0; index < monitorCount; index++ ) |
|
733 { |
|
734 MSatEventMonitor* monitor = iEventMonitors->At( index ); |
|
735 __ASSERT_ALWAYS( monitor, PanicSatEngine( ESatEngineNullPointer ) ); |
|
736 |
|
737 if ( monitor->IsMonitoringEvent( aSingleEvent ) ) |
|
738 { |
|
739 // Cancel monitor |
|
740 monitor->CancelMonitor(); |
|
741 } |
|
742 } |
|
743 |
|
744 LOG( SIMPLE, |
|
745 "SATENGINE: CSatEventMonitorContainer::RemoveSingleEvent exiting" ) |
|
746 } |
|
747 |
|
748 // End of File |
|