|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifdef USING_CTSY_DISPATCHER |
|
17 |
|
18 /** |
|
19 * This file contains additional function definitions for the CMmSecurityTsy class |
|
20 * in CTSY for use when the CTSY is used with the CTSY Dispatcher. |
|
21 */ |
|
22 |
|
23 //INCLUDES |
|
24 #include "cmmsecuritytsy.h" |
|
25 #include "cmmphonetsy.h" |
|
26 #include "cmmtsyreqhandlestore.h" |
|
27 #include "cmmphoneextinterface.h" |
|
28 #include "CMmCustomSecurityTsy.h" |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CMmSecurityTsy::VerifySecurityCodeL |
|
32 // This method sends a security code requiring verification to |
|
33 // the phone. If code is required for lock setting, it sends it to the |
|
34 // extension and orders re-execution of SetLockSetting function. |
|
35 // (other items were commented in a header). |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 TInt CMmSecurityTsy::VerifySecurityCodeL( |
|
39 const TTsyReqHandle aTsyReqHandle, |
|
40 const TDataPackage& aPackage ) |
|
41 { |
|
42 |
|
43 RMobilePhone::TMobilePhoneSecurityCode* type = |
|
44 reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCode*> |
|
45 ( aPackage.Ptr1() ); |
|
46 RMobilePhone::TCodeAndUnblockCode* codes = |
|
47 reinterpret_cast<RMobilePhone::TCodeAndUnblockCode*> |
|
48 ( aPackage.Ptr2() ); |
|
49 |
|
50 // Get request handle to check whether server is busy with previous |
|
51 // request |
|
52 TTsyReqHandle reqHandle = iMmPhoneTsy->iTsyReqHandleStore-> |
|
53 GetTsyReqHandle( CMmPhoneTsy::EMultimodePhoneVerifySecurityCode ); |
|
54 |
|
55 if ( 0 < reqHandle ) |
|
56 { |
|
57 //The request is already in processing because of previous request |
|
58 //Complete request with status value informing the client about |
|
59 //the situation. |
|
60 iMmPhoneTsy->ReqCompleted( aTsyReqHandle, KErrServerBusy ); |
|
61 } |
|
62 else |
|
63 { |
|
64 |
|
65 TInt ret( KErrArgument ); |
|
66 |
|
67 //check that the code is available |
|
68 if ( 0 != codes->iCode.Length() ) |
|
69 { |
|
70 if ( RMobilePhone::ESecurityCodePin1 == *type ) |
|
71 { |
|
72 TFLOGSTRING("TSY: CMmSecurityTsy::VerifySecurityCodeL - PIN VERIFY REQUESTED"); |
|
73 iLastPinRequested = EPin1Requested; |
|
74 } |
|
75 if ( RMobilePhone::ESecurityCodePin2 == *type ) |
|
76 { |
|
77 TFLOGSTRING("TSY: CMmSecurityTsy::VerifySecurityCodeL - PIN2 VERIFY REQUESTED"); |
|
78 iLastPinRequested = EPin2Requested; |
|
79 } |
|
80 //This is to prevent unnecessary PIN1 request after PUK code |
|
81 //request. Corrected at the same time with error TKEN-5WFJ7Y |
|
82 if ( ( ( RMobilePhone::ESecurityCodePuk1 == *type ) || |
|
83 ( RMobilePhone::ESecurityCodePuk2 == *type ) ) && |
|
84 ( 0 < codes->iUnblockCode.Length() ) ) |
|
85 { |
|
86 TFLOGSTRING("TSY: CMmSecurityTsy::VerifySecurityCodeL - PUK VERIFY REQUESTED"); |
|
87 iPukCodeVerify = ETrue; |
|
88 } |
|
89 //This is to prevent unnecessary PIN1 request after phone password |
|
90 //request (PYRA-5UBCLC) |
|
91 if ( RMobilePhone::ESecurityCodePhonePassword == *type ) |
|
92 { |
|
93 TFLOGSTRING("TSY: CMmSecurityTsy::VerifySecurityCodeL - PHONE PASSWORD VERIFY REQUESTED"); |
|
94 iPhonePasswordVerify = ETrue; |
|
95 } |
|
96 iMmPhoneTsy->iMmPhoneExtInterface->DeliverCode( *codes ); |
|
97 |
|
98 // CheckSecurityCode needs to set the lock as well, so pass the |
|
99 // code for lock setting |
|
100 if ( iMmPhoneTsy->iMmCustomTsy ) |
|
101 { |
|
102 iMmPhoneTsy->iMmCustomTsy->DeliverCodeL( *codes ); |
|
103 } |
|
104 |
|
105 ret = iMmPhoneTsy->iMmPhoneExtInterface-> |
|
106 VerifySecurityCodeL( aPackage ); |
|
107 |
|
108 if ( KErrNone == ret ) |
|
109 { |
|
110 iMmPhoneTsy->iReqHandleType = |
|
111 CMmPhoneTsy::EMultimodePhoneVerifySecurityCode; |
|
112 } |
|
113 else |
|
114 { |
|
115 // Complete verify with error |
|
116 iMmPhoneTsy->ReqCompleted( aTsyReqHandle, ret ); |
|
117 |
|
118 // If FDN request is on-going, complete is also with error |
|
119 reqHandle = iMmPhoneTsy->iTsyReqHandleStore-> |
|
120 GetTsyReqHandle( |
|
121 CMmPhoneTsy::EMultimodePhoneSetFdnSetting ); |
|
122 if ( reqHandle != |
|
123 CMmPhoneTsy::EMultimodePhoneReqHandleUnknown ) |
|
124 { |
|
125 iMmPhoneTsy->CompleteSetFdnSettingL( ret ); |
|
126 } |
|
127 reqHandle = iMmPhoneTsy->iTsyReqHandleStore-> |
|
128 GetTsyReqHandle( |
|
129 CMmPhoneTsy::EMultimodePhoneSetLockSetting ); |
|
130 |
|
131 if ( CMmPhoneTsy::EMultimodePhoneReqHandleUnknown != |
|
132 reqHandle && EActiveCodeToUpinAskUpin == |
|
133 iActiveCodeToUpinState ) |
|
134 { |
|
135 //Verifying UPIN failed |
|
136 CompleteSetLockSetting( ret, |
|
137 RMobilePhone::EStatusLockUnknown, |
|
138 RMobilePhone::ELockSetUnknown ); |
|
139 } |
|
140 } |
|
141 } |
|
142 else |
|
143 { |
|
144 iMmPhoneTsy->ReqCompleted( aTsyReqHandle, KErrArgument ); |
|
145 } |
|
146 |
|
147 } // end check request handle |
|
148 |
|
149 return KErrNone; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CMmSecurityTsy::CompleteVerifySecurityCodeL |
|
154 // This method completes an outstanding asynchronous |
|
155 // VerifySecurityCode request |
|
156 // (other items were commented in a header). |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CMmSecurityTsy::CompleteVerifySecurityCodeL( |
|
160 TInt aErrorCode ) |
|
161 { |
|
162 TFLOGSTRING2("TSY: CMmSecurityTsy::CompleteVerifySecurityCode - Error:%d", aErrorCode); |
|
163 |
|
164 TTsyReqHandle reqHandle = iMmPhoneTsy->iTsyReqHandleStore-> |
|
165 ResetTsyReqHandle( CMmPhoneTsy::EMultimodePhoneVerifySecurityCode ); |
|
166 |
|
167 if ( CMmPhoneTsy::EMultimodePhoneReqHandleUnknown != reqHandle ) |
|
168 { |
|
169 // Complete the request |
|
170 iMmPhoneTsy->ReqCompleted( reqHandle, aErrorCode ); |
|
171 |
|
172 // This needs to be done for PIN code verification when user has |
|
173 // dual line SIM and user has changed the line. If PIN code |
|
174 // verification fails, we need to request PIN code again. |
|
175 |
|
176 // NOTE! This MUST NOT happen in bootup when PIN code is verified |
|
177 // and NOT when PIN code is changed to ON/OFF from settings. |
|
178 |
|
179 // DO NOT complete if SetLockSetting is called -> PIN ON/OFF change |
|
180 // from general settings. |
|
181 |
|
182 // Not completed if PUK code verify or Phonepassword verify |
|
183 TTsyReqHandle phoneSetLockSettingHandle = |
|
184 iMmPhoneTsy->iTsyReqHandleStore->GetTsyReqHandle( |
|
185 CMmPhoneTsy::EMultimodePhoneSetLockSetting ); |
|
186 |
|
187 // DO NOT complete if booting up |
|
188 if ( ( iMmPhoneTsy->iBootState.iSecReady ) && |
|
189 ( iLastPinRequested != EPinUnknown ) && |
|
190 ( CMmPhoneTsy::EMultimodePhoneReqHandleUnknown == |
|
191 phoneSetLockSettingHandle ) && |
|
192 ( KErrNone != aErrorCode ) && |
|
193 ( !iPukCodeVerify ) && |
|
194 ( !iPhonePasswordVerify ) ) |
|
195 { |
|
196 // IF PIN1 REQUESTED LAST |
|
197 if ( iLastPinRequested == EPin1Requested ) |
|
198 { |
|
199 TFLOGSTRING("TSY: CMmSecurityTsy::CompleteVerifySecurityCodeL - PIN VERIFICATION NEEDED"); |
|
200 CompleteNotifySecurityEventL( RMobilePhone::EPin1Required, |
|
201 KErrNone ); |
|
202 iLastPinRequested = EPinUnknown; |
|
203 } |
|
204 // IF PIN2 REQUESTED LAST |
|
205 if (iLastPinRequested == EPin2Requested) |
|
206 { |
|
207 TFLOGSTRING("TSY: CMmSecurityTsy::CompleteVerifySecurityCodeL - PIN2"); |
|
208 iLastPinRequested = EPinUnknown; |
|
209 } |
|
210 } |
|
211 else if ( CMmPhoneTsy::EMultimodePhoneReqHandleUnknown != |
|
212 phoneSetLockSettingHandle && EActiveCodeToUpinAskUpin == |
|
213 iActiveCodeToUpinState ) |
|
214 { |
|
215 TFLOGSTRING("TSY: CMmSecurityTsy::CompleteVerifySecurityCodeL - iActiveCodeToUpinState = EActiveCodeToUpinAskPin"); |
|
216 if ( KErrNone == aErrorCode ) |
|
217 { |
|
218 iActiveCodeToUpinState = EActiveCodeToUpinAskPin; |
|
219 CompleteNotifySecurityEventL( |
|
220 RMobilePhone::EPin1Required, KErrNone ); |
|
221 } |
|
222 else |
|
223 { |
|
224 iActiveCodeToUpinState = EActiveCodeToUpinIdle; |
|
225 CompleteSetLockSetting( KErrAccessDenied, |
|
226 RMobilePhone::EStatusLockUnknown, |
|
227 RMobilePhone::ELockSetUnknown ); |
|
228 } |
|
229 } |
|
230 //Set iPukCodeVerify to EFalse |
|
231 iPukCodeVerify = EFalse; |
|
232 |
|
233 //Set iPhonePasswordVerify to EFalse |
|
234 iPhonePasswordVerify = EFalse; |
|
235 |
|
236 // FDN HANDLING |
|
237 reqHandle = iMmPhoneTsy->iTsyReqHandleStore->GetTsyReqHandle( |
|
238 CMmPhoneTsy::EMultimodePhoneSetFdnSetting ); |
|
239 |
|
240 if ( reqHandle != CMmPhoneTsy::EMultimodePhoneReqHandleUnknown ) |
|
241 { |
|
242 if ( KErrNone == aErrorCode ) |
|
243 { |
|
244 aErrorCode = iMmPhoneTsy->iMmPhoneExtInterface-> |
|
245 SetFdnSetting( iMmPhoneTsy->iRetFdnSetting ); |
|
246 } |
|
247 else |
|
248 { |
|
249 iMmPhoneTsy->CompleteSetFdnSettingL( aErrorCode ); |
|
250 } |
|
251 } |
|
252 |
|
253 if ( phoneSetLockSettingHandle != CMmPhoneTsy::EMultimodePhoneReqHandleUnknown ) |
|
254 if ( KErrNone == aErrorCode ) |
|
255 { |
|
256 CMmDataPackage dataPackage; |
|
257 //add into the package the stored lock and setting |
|
258 dataPackage.PackData( &iLockSettingPhoneLock, &iLockSetting ); |
|
259 aErrorCode = iMmPhoneTsy->iMmPhoneExtInterface-> |
|
260 SetLockSettingL( &dataPackage ); |
|
261 } |
|
262 else |
|
263 { |
|
264 CompleteSetLockSetting( aErrorCode, RMobilePhone::EStatusLockUnknown, RMobilePhone::ELockSetUnknown ); |
|
265 } |
|
266 |
|
267 // Reset just used code, empty for next round. |
|
268 RMobilePhone::TCodeAndUnblockCode codes; |
|
269 _LIT( KNullCharacter, "\0" ); |
|
270 codes.iCode.Copy( KNullCharacter ); |
|
271 iMmPhoneTsy->iMmPhoneExtInterface->DeliverCode( codes ); |
|
272 } |
|
273 } |
|
274 |
|
275 #endif //USING_CTSY_DISPATCHER |