|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <centralrepository.h> |
|
20 #include <settingsinternalcrkeys.h> |
|
21 #include "AutoKeyguardObserver.h" |
|
22 #include "AutoKeyguardCenRepI.h" |
|
23 |
|
24 |
|
25 |
|
26 // ================= MEMBER FUNCTIONS ======================= |
|
27 // |
|
28 // ---------------------------------------------------------- |
|
29 // CAutoKeyguardCenRepI::NewLC() |
|
30 // Two-phased constructor. |
|
31 // ---------------------------------------------------------- |
|
32 // |
|
33 CAutoKeyguardCenRepI* CAutoKeyguardCenRepI::NewLC(CAutoKeyguardObserver* aObserver) |
|
34 { |
|
35 CAutoKeyguardCenRepI* self = new (ELeave) CAutoKeyguardCenRepI(aObserver); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // |
|
42 // ---------------------------------------------------------- |
|
43 // CAutoKeyguardCenRepI::NewL() |
|
44 // Two-phased constructor. |
|
45 // ---------------------------------------------------------- |
|
46 // |
|
47 CAutoKeyguardCenRepI* CAutoKeyguardCenRepI::NewL(CAutoKeyguardObserver* aObserver) |
|
48 { |
|
49 CAutoKeyguardCenRepI* self = NewLC(aObserver); |
|
50 CleanupStack::Pop(); //self |
|
51 return self; |
|
52 } |
|
53 |
|
54 // |
|
55 // ---------------------------------------------------------- |
|
56 // CAutoKeyguardCenRepI::~CAutoKeyguardCenRepI() |
|
57 // Destructor |
|
58 // ---------------------------------------------------------- |
|
59 // |
|
60 CAutoKeyguardCenRepI::~CAutoKeyguardCenRepI() |
|
61 { |
|
62 if(iNotifyHandler) |
|
63 { |
|
64 iNotifyHandler->StopListening(); |
|
65 delete iNotifyHandler; |
|
66 } |
|
67 if(iSession) |
|
68 delete iSession; |
|
69 } |
|
70 // |
|
71 // ---------------------------------------------------------- |
|
72 // CAutoKeyguardCenRepI::CAutoKeyguardCenRepI() |
|
73 // C++ default constructor |
|
74 // ---------------------------------------------------------- |
|
75 // |
|
76 CAutoKeyguardCenRepI::CAutoKeyguardCenRepI(CAutoKeyguardObserver* aObserver):iObserver(aObserver) |
|
77 { |
|
78 } |
|
79 |
|
80 // |
|
81 // ---------------------------------------------------------- |
|
82 // CAutoKeyguardCenRepI::ConstructL() |
|
83 // Symbian OS default constructor |
|
84 // ---------------------------------------------------------- |
|
85 // |
|
86 void CAutoKeyguardCenRepI::ConstructL() |
|
87 { |
|
88 // init cenrep connection |
|
89 iSession = CRepository::NewL(KCRUidSecuritySettings); |
|
90 |
|
91 iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iSession, CCenRepNotifyHandler::EIntKey, KSettingsAutomaticKeyguardTime); |
|
92 iNotifyHandler->StartListeningL(); |
|
93 } |
|
94 |
|
95 // |
|
96 // ---------------------------------------------------------- |
|
97 // CAutoKeyguardCenRepI::HandleNotifyInt() |
|
98 // Handles autoKeyguard period changes. Called by CenRep. |
|
99 // ---------------------------------------------------------- |
|
100 // |
|
101 void CAutoKeyguardCenRepI::HandleNotifyInt(TUint32 aId, TInt /*aNewValue*/) |
|
102 { |
|
103 if(aId == KSettingsAutomaticKeyguardTime) |
|
104 { |
|
105 #if defined(_DEBUG) |
|
106 RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardCenRepI::HandleNotifyInt() Reset timeout")); |
|
107 #endif |
|
108 ResetInactivityTimeout(); |
|
109 } |
|
110 return; |
|
111 } |
|
112 |
|
113 void CAutoKeyguardCenRepI::HandleNotifyError(TUint32 /*aId*/, TInt /*error*/, CCenRepNotifyHandler* /*aHandler*/) |
|
114 { |
|
115 return; |
|
116 } |
|
117 |
|
118 void CAutoKeyguardCenRepI::HandleNotifyGeneric(TUint32 aId) |
|
119 { |
|
120 if ( aId == NCentralRepositoryConstants::KInvalidNotificationId ) |
|
121 {//Repository wide reset caused generic notification |
|
122 #if defined(_DEBUG) |
|
123 RDebug::Print(_L("(AUTOLOCK)CAutoKeyguardCenRepI::HandleNotifyGeneric() Reset timeout")); |
|
124 #endif |
|
125 ResetInactivityTimeout(); |
|
126 } |
|
127 return; |
|
128 } |
|
129 |
|
130 // |
|
131 // ---------------------------------------------------------- |
|
132 // CAutoKeyguardCenRepI::ResetInactivityTimeoutL() |
|
133 // Resets autoKeyguard timer |
|
134 // ---------------------------------------------------------- |
|
135 // |
|
136 void CAutoKeyguardCenRepI::ResetInactivityTimeout() |
|
137 { |
|
138 iObserver->ResetInactivityTimeout(); |
|
139 } |
|
140 |
|
141 // |
|
142 // ---------------------------------------------------------- |
|
143 // CAutoKeyguardCenRepI::Timeout() |
|
144 // Returns currents autoKeyguard period (in seconds) |
|
145 // ---------------------------------------------------------- |
|
146 // |
|
147 TInt CAutoKeyguardCenRepI::Timeout() |
|
148 { |
|
149 TInt period = 0; |
|
150 iSession->Get(KSettingsAutomaticKeyguardTime, period); |
|
151 return period; |
|
152 } |
|
153 |
|
154 // END OF FILE |