1 /* |
|
2 * Copyright (c) 2005-2006 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: Environment change observer for AI2 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bacntf.h> // for CEnvironmentChangeNotifier |
|
20 #include <coemain.h> |
|
21 #include <AknDef.h> // for KEikDynamicLayoutVariantSwitch |
|
22 #include "aienvironmentchangeobserver.h" |
|
23 #include "aistatemanager.h" |
|
24 #include "aifwpanic.h" |
|
25 #include "debug.h" |
|
26 |
|
27 CAiEnvironmentChangeObserver::CAiEnvironmentChangeObserver() |
|
28 { |
|
29 } |
|
30 |
|
31 CAiEnvironmentChangeObserver::~CAiEnvironmentChangeObserver() |
|
32 { |
|
33 if( iEnvironmentChangeNotifier ) |
|
34 { |
|
35 iEnvironmentChangeNotifier->Cancel(); |
|
36 delete iEnvironmentChangeNotifier; |
|
37 } |
|
38 } |
|
39 |
|
40 CAiEnvironmentChangeObserver* CAiEnvironmentChangeObserver::NewL( MAiStateManager* aStateManager ) |
|
41 { |
|
42 CAiEnvironmentChangeObserver* self = new (ELeave) CAiEnvironmentChangeObserver(); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL( aStateManager ); |
|
45 CleanupStack::Pop(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 void CAiEnvironmentChangeObserver::ConstructL( MAiStateManager* aStateManager ) |
|
50 { |
|
51 iStateManager = aStateManager; |
|
52 iEnvironmentChangeNotifier = CEnvironmentChangeNotifier::NewL( |
|
53 EActivePriorityLogonA, |
|
54 TCallBack( EnvironmentChangeCallBack, this ) ); |
|
55 iEnvironmentChangeNotifier->Start(); |
|
56 } |
|
57 |
|
58 TAiStateChanges CAiEnvironmentChangeObserver::Status() |
|
59 { |
|
60 // No statuses to report |
|
61 return ESMAIUnknownState; |
|
62 } |
|
63 |
|
64 TInt CAiEnvironmentChangeObserver::EnvironmentChangeCallBack(TAny* aPtr) |
|
65 { |
|
66 CAiEnvironmentChangeObserver* self = |
|
67 static_cast<CAiEnvironmentChangeObserver*>( aPtr ); |
|
68 |
|
69 __ASSERT_DEBUG( self, |
|
70 AiFwPanic::Panic( AiFwPanic::EAiFwPanic_NullPointerReference ) ); |
|
71 |
|
72 const TInt changes( self->iEnvironmentChangeNotifier->Change() ); |
|
73 |
|
74 // report environment changes |
|
75 if( changes & EChangesMidnightCrossover ) |
|
76 { |
|
77 __PRINTS("XAI: Event: Midnight crossover"); |
|
78 self->iStateManager->ReportStateChange( ESMAIMidnightCrossover ); |
|
79 } |
|
80 if( changes & EChangesSystemTime ) |
|
81 { |
|
82 __PRINTS("XAI: Event: Time changed"); |
|
83 self->iStateManager->ReportStateChange( ESMAITimeChanged ); |
|
84 } |
|
85 if( changes & EChangesLocale ) |
|
86 { |
|
87 __PRINTS("XAI: Event: Locale setting changed"); |
|
88 self->iStateManager->ReportStateChange( ESMAILocaleChanged ); |
|
89 } |
|
90 |
|
91 return EFalse; |
|
92 } |
|
93 |
|