1 /* |
|
2 * Copyright (c) 2005 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: Model for Device & SIM security plug-in. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "GSAutoKeyguardPluginModel.h" |
|
21 |
|
22 #include <settingsinternalcrkeys.h> |
|
23 |
|
24 #include <bldvariant.hrh> |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 const TInt KGSSettingOff = 0; |
|
35 const TInt KGSDefaultAutoKeyguardTime = 60; |
|
36 const TInt KGSUseDefaultMaxAutoKeyguardTime = 0; |
|
37 |
|
38 // MODULE DATA STRUCTURES |
|
39 |
|
40 // LOCAL FUNCTION PROTOTYPES |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS ============================== |
|
43 |
|
44 // ========================= MEMBER FUNCTIONS ================================= |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CGSAutoKeyguardPluginModel::NewL |
|
48 // |
|
49 // Symbian OS two-phased constructor |
|
50 // ---------------------------------------------------------------------------- |
|
51 // |
|
52 CGSAutoKeyguardPluginModel* CGSAutoKeyguardPluginModel::NewL() |
|
53 { |
|
54 CGSAutoKeyguardPluginModel* self = new( ELeave ) CGSAutoKeyguardPluginModel; |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(); |
|
57 |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // CGSAutoKeyguardPluginModel::CGSAutoKeyguardPluginModel |
|
65 // |
|
66 // |
|
67 // C++ default constructor can NOT contain any code, that might leave. |
|
68 // ---------------------------------------------------------------------------- |
|
69 // |
|
70 CGSAutoKeyguardPluginModel::CGSAutoKeyguardPluginModel() |
|
71 { |
|
72 |
|
73 } |
|
74 |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CGSAutoKeyguardPluginModel::ConstructL |
|
78 // |
|
79 // Symbian OS default constructor can leave. |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 void CGSAutoKeyguardPluginModel::ConstructL() |
|
83 { |
|
84 iSecurityRepository = CRepository::NewL( KCRUidSecuritySettings ); |
|
85 } |
|
86 |
|
87 |
|
88 // ---------------------------------------------------------------------------- |
|
89 // CGSAutoKeyguardPluginModel::~CGSAutoKeyguardPluginModel |
|
90 // |
|
91 // Destructor |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 CGSAutoKeyguardPluginModel::~CGSAutoKeyguardPluginModel() |
|
95 { |
|
96 if(iSecurityRepository) |
|
97 { |
|
98 delete iSecurityRepository; |
|
99 iSecurityRepository = NULL; |
|
100 } |
|
101 |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------------------------------- |
|
105 // CGSAutoKeyguardPluginModel::AutoKeyguardPeriod(); |
|
106 // |
|
107 // Reads Autolock period from .ini file and returns it |
|
108 // ---------------------------------------------------------------------------- |
|
109 // |
|
110 TInt CGSAutoKeyguardPluginModel::AutoKeyguardPeriod() |
|
111 { |
|
112 TInt period = KGSSettingOff; |
|
113 |
|
114 if ( iSecurityRepository-> |
|
115 Get( KSettingsAutomaticKeyguardTime, period ) != KErrNone ) |
|
116 { |
|
117 period = KGSDefaultAutoKeyguardTime; |
|
118 iSecurityRepository->Set( KSettingsAutomaticKeyguardTime, period ); |
|
119 } |
|
120 |
|
121 return period; |
|
122 } |
|
123 |
|
124 // ---------------------------------------------------------------------------- |
|
125 // CGSAutoKeyguardPluginModel::AutoKeyguardMaxPeriod(); |
|
126 // |
|
127 // Reads Autokeyguard period maximum allowed value from .ini file and returns it |
|
128 // ---------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CGSAutoKeyguardPluginModel::AutoKeyguardMaxPeriod() |
|
131 { |
|
132 TInt maxPeriod(600); |
|
133 |
|
134 if ( iSecurityRepository-> |
|
135 Get( KSettingsMaxAutomaticKeyguardTime, maxPeriod ) != KErrNone ) |
|
136 { |
|
137 maxPeriod = KGSUseDefaultMaxAutoKeyguardTime; |
|
138 } |
|
139 return maxPeriod; |
|
140 } |
|
141 |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // CGSAutoKeyguardPluginModel::SetAutoKeyguardPeriod |
|
145 // |
|
146 // Writes Autokeyguard period time to Cenrep |
|
147 // ---------------------------------------------------------------------------- |
|
148 // |
|
149 TBool CGSAutoKeyguardPluginModel::SetAutoKeyguardPeriod( TInt aLockTime ) |
|
150 { |
|
151 TInt ret = iSecurityRepository->Set( KSettingsAutomaticKeyguardTime, aLockTime ); |
|
152 return ret; |
|
153 } |
|
154 |
|
155 // End of File |
|