|
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: Implementation of security operations |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPhCntMmiSecurityImpl.h" |
|
21 #include <secuimanualsecuritysettings.h> |
|
22 |
|
23 // CONSTANTS |
|
24 #ifdef _DEBUG |
|
25 _LIT( KPhCntMmiSecurity, "PhCntMmi" ); |
|
26 #endif // _DEBUG |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CPhCntMmiSecurityImpl::NewL |
|
32 // Two-phased constructor. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CPhCntMmiSecurityImpl* CPhCntMmiSecurityImpl::NewL() |
|
36 { |
|
37 CPhCntMmiSecurityImpl* self = |
|
38 new (ELeave) CPhCntMmiSecurityImpl; |
|
39 |
|
40 return self; |
|
41 } |
|
42 |
|
43 // Destructor |
|
44 CPhCntMmiSecurityImpl::~CPhCntMmiSecurityImpl() |
|
45 { |
|
46 DestroyModel(); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CPhCntMmiSecurityImpl::ChangePinL |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 TBool CPhCntMmiSecurityImpl::ChangePinL( |
|
54 TPinCommand aCommand, |
|
55 const TDesC& aCode, |
|
56 const TDesC& aNewPin, |
|
57 const TDesC& aVerifyNew ) |
|
58 { |
|
59 CManualSecuritySettings& model = CreateModelL(); |
|
60 |
|
61 // Initially, setting is pin2. |
|
62 CManualSecuritySettings::TPin pin = |
|
63 CManualSecuritySettings::EPin2; |
|
64 |
|
65 TBool result = EFalse; |
|
66 |
|
67 switch ( aCommand ) |
|
68 { |
|
69 case ECmdChangePin: |
|
70 |
|
71 // Change setting. |
|
72 // |
|
73 pin = CManualSecuritySettings::EPin1; |
|
74 |
|
75 // Flow through.. |
|
76 // |
|
77 case ECmdChangePin2: |
|
78 |
|
79 result = model.ChangePinL( |
|
80 pin, |
|
81 aCode, |
|
82 aNewPin, |
|
83 aVerifyNew ); |
|
84 break; |
|
85 |
|
86 case ECmdUnblockPin: |
|
87 |
|
88 // Change setting |
|
89 // |
|
90 pin = CManualSecuritySettings::EPin1; |
|
91 |
|
92 // Flow through.. |
|
93 // |
|
94 case ECmdUnblockPin2: |
|
95 |
|
96 result = model.UnblockPinL( |
|
97 pin, |
|
98 aCode, |
|
99 aNewPin, |
|
100 aVerifyNew ); |
|
101 break; |
|
102 |
|
103 default: |
|
104 // Case not handled, panic. |
|
105 Panic(); |
|
106 break; |
|
107 } |
|
108 |
|
109 return result; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CPhCntMmiSecurityImpl::ChangeSimLockL |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 TBool CPhCntMmiSecurityImpl::ChangeSimLockL( |
|
117 TSimCommand aCommand, |
|
118 const TDesC& aCode, |
|
119 const TDesC& aType ) |
|
120 { |
|
121 CManualSecuritySettings& model = CreateModelL(); |
|
122 TBool result = EFalse; |
|
123 |
|
124 switch ( aCommand ) |
|
125 { |
|
126 case ECmdOpenLock: |
|
127 result = |
|
128 model.UnlockSimL( aCode, aType ); |
|
129 break; |
|
130 case ECmdCloseLock: |
|
131 result = |
|
132 model.LockSimL( aCode, aType ); |
|
133 break; |
|
134 default: |
|
135 // Case not handled, panic. |
|
136 Panic(); |
|
137 break; |
|
138 } |
|
139 |
|
140 return result; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CPhCntMmiSecurityImpl::Cancel |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 void CPhCntMmiSecurityImpl::Cancel() |
|
148 { |
|
149 if ( iModel ) |
|
150 { |
|
151 iModel->CancelChangePin(); |
|
152 iModel->CancelUnblockPin(); |
|
153 iModel->CancelLockSim(); |
|
154 iModel->CancelUnlockSim(); |
|
155 |
|
156 DestroyModel(); |
|
157 } |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------- |
|
161 // CPhCntMmiSecurityImpl::CreateModelL |
|
162 // --------------------------------------------------------- |
|
163 // |
|
164 CManualSecuritySettings& |
|
165 CPhCntMmiSecurityImpl::CreateModelL() |
|
166 { |
|
167 if ( !iModel ) |
|
168 { |
|
169 iModel = CManualSecuritySettings::NewL(); |
|
170 } |
|
171 |
|
172 return *iModel; |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------- |
|
176 // CPhCntMmiSecurityImpl::DestroyModel |
|
177 // --------------------------------------------------------- |
|
178 // |
|
179 void CPhCntMmiSecurityImpl::DestroyModel() |
|
180 { |
|
181 delete iModel; |
|
182 iModel = NULL; |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // CPhCntMmiSecurityImpl::Panic |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 void CPhCntMmiSecurityImpl::Panic() |
|
190 { |
|
191 // We only panic with debug builds. |
|
192 __ASSERT_DEBUG( |
|
193 EFalse, |
|
194 User::Panic( KPhCntMmiSecurity, 0 ) ); |
|
195 } |
|
196 |
|
197 // End of File |
|
198 |