|
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: Light status observer for AI2 |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aipspropertyobserver.h> |
|
20 #include "ailightstatusobserver.h" |
|
21 #include "aistatemanager.h" |
|
22 #include "debug.h" |
|
23 |
|
24 CAiLightStatusObserver::CAiLightStatusObserver() |
|
25 { |
|
26 } |
|
27 |
|
28 CAiLightStatusObserver::~CAiLightStatusObserver() |
|
29 { |
|
30 delete iLight; |
|
31 } |
|
32 |
|
33 CAiLightStatusObserver* CAiLightStatusObserver::NewL( MAiStateManager* aStateManager ) |
|
34 { |
|
35 CAiLightStatusObserver* self = new (ELeave) CAiLightStatusObserver(); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL( aStateManager ); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 void CAiLightStatusObserver::ConstructL( MAiStateManager* aStateManager ) |
|
43 { |
|
44 iStateManager = aStateManager; |
|
45 iLight = CHWRMLight::NewL( this ); |
|
46 } |
|
47 |
|
48 TAiStateChanges CAiLightStatusObserver::Status() |
|
49 { |
|
50 // In future handle other screen lights here also.. |
|
51 CHWRMLight::TLightStatus status = iLight->LightStatus( CHWRMLight::EPrimaryDisplay ); |
|
52 if( status == CHWRMLight::ELightOn ) |
|
53 { |
|
54 return ESMAIBacklightOn; |
|
55 } |
|
56 else if( status == CHWRMLight::ELightOff ) |
|
57 { |
|
58 return ESMAIBacklightOff; |
|
59 } |
|
60 return ESMAIBacklightOn; |
|
61 } |
|
62 |
|
63 void CAiLightStatusObserver::LightStatusChanged( TInt aTarget, CHWRMLight::TLightStatus aStatus ) |
|
64 { |
|
65 if( aTarget == CHWRMLight::EPrimaryDisplay || |
|
66 aTarget == CHWRMLight::EPrimaryDisplayAndKeyboard ) |
|
67 { |
|
68 if( aStatus == CHWRMLight::ELightOn ) |
|
69 { |
|
70 __PRINTS("XAI: Light = ON"); |
|
71 iStateManager->ReportStateChange( ESMAIBacklightOn ); |
|
72 } |
|
73 else if( aStatus == CHWRMLight::ELightOff ) |
|
74 { |
|
75 __PRINTS("XAI: Light = OFF"); |
|
76 iStateManager->ReportStateChange( ESMAIBacklightOff ); |
|
77 } |
|
78 } |
|
79 } |
|
80 |