|
1 /* |
|
2 * Copyright (c) 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: Monitors device lock state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CVtEngDeviceLockMonitor.h" |
|
22 #include "CVTEngPubSubsListener.h" |
|
23 #include "CVtEngEventManager.h" |
|
24 #include "cvtlogger.h" |
|
25 |
|
26 #include <coreapplicationuisdomainpskeys.h> |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CVtEngDeviceLockMonitor::NewL |
|
32 // Two-phased constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CVtEngDeviceLockMonitor* CVtEngDeviceLockMonitor::NewL() |
|
36 { |
|
37 CVtEngDeviceLockMonitor* self = new ( ELeave ) CVtEngDeviceLockMonitor(); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // Destructor |
|
45 CVtEngDeviceLockMonitor::~CVtEngDeviceLockMonitor() |
|
46 { |
|
47 delete iAutolockListener; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CVtEngDeviceLockMonitor::NotifyState |
|
52 // Notifies UI about device lock state |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CVtEngDeviceLockMonitor::NotifyState() const |
|
56 { |
|
57 __VTPRINTENTER( "LockMonitor.NotifyState" ) |
|
58 |
|
59 TInt state = EAutolockStatusUninitialized; |
|
60 |
|
61 // Get autolock state |
|
62 TInt err = iAutolockListener->Get( state ); |
|
63 |
|
64 __VTPRINT2( DEBUG_GEN, "LockMonitor Get err: %d", err ); |
|
65 __VTPRINT2( DEBUG_GEN, "LockMonitor state: %d", state ); |
|
66 |
|
67 if( err == KErrNone ) |
|
68 { |
|
69 const TInt event = |
|
70 ( state <= EAutolockOff ) ? |
|
71 KVtEngDeviceLockOff : KVtEngDeviceLockOn; |
|
72 CVtEngEventManager::NotifyEvent( event ); |
|
73 } |
|
74 |
|
75 __VTPRINTEXIT( "LockMonitor.NotifyState" ) |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CVtEngDeviceLockMonitor::HandleNotifyPSL |
|
80 // Callback for autolock state change |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 void CVtEngDeviceLockMonitor::HandleNotifyPSL( |
|
84 const TUid aUid, |
|
85 const TInt& aKey, |
|
86 const TRequestStatus& aStatus ) |
|
87 { |
|
88 if ( aStatus == KErrNone && |
|
89 aUid == KPSUidCoreApplicationUIs && |
|
90 aKey == KCoreAppUIsAutolockStatus ) |
|
91 { |
|
92 NotifyState(); |
|
93 } |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CVtEngDeviceLockMonitor::CVtEngDeviceLockMonitor |
|
98 // C++ default constructor can NOT contain any code, that |
|
99 // might leave. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 CVtEngDeviceLockMonitor::CVtEngDeviceLockMonitor() |
|
103 { |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CVtEngDeviceLockMonitor::ConstructL |
|
108 // Symbian 2nd phase constructor can leave. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CVtEngDeviceLockMonitor::ConstructL() |
|
112 { |
|
113 __VTPRINTENTER( "LockMonitor.ConstructL" ) |
|
114 // Listener for autolock state |
|
115 iAutolockListener = CVtEngPubSubsListener::NewL( |
|
116 KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, this ); |
|
117 __VTPRINTEXIT( "LockMonitor.ConstructL" ) |
|
118 } |
|
119 |
|
120 // End of File |