|
1 /* |
|
2 * Copyright (c) 2000 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 terminalsecurity components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 #include <e32debug.h> |
|
22 #include <etelmm.h> |
|
23 #include <rmmcustomapi.h> |
|
24 |
|
25 |
|
26 |
|
27 #include <e32property.h> |
|
28 #include <PSVariables.h> // Property values |
|
29 |
|
30 |
|
31 |
|
32 #include <mmtsy_names.h> |
|
33 |
|
34 #include "SCPLockNotificationEventHandler.h" |
|
35 #include "SCPServer.h" |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // |
|
42 CSCPLockNotificationEventHandler::CSCPLockNotificationEventHandler( |
|
43 CSCPServer* aServer |
|
44 ) |
|
45 : CSCPLockEventHandler( aServer ), |
|
46 iQueryState(ESCPLNQueryStateNotification) |
|
47 { |
|
48 Dprint( (_L("--> CSCPLockNotificationEventHandler::\ |
|
49 CSCPLockNotificationEventHandler()") )); |
|
50 |
|
51 Dprint( (_L("<-- CSCPLockNotificationEventHandler::\ |
|
52 CSCPLockNotificationEventHandler()") )); |
|
53 } |
|
54 |
|
55 |
|
56 // Symbian 2nd phase constructor can leave. |
|
57 void CSCPLockNotificationEventHandler::ConstructL() |
|
58 { |
|
59 Dprint( (_L("--> CSCPLockNotificationEventHandler::ConstructL()") )); |
|
60 |
|
61 BaseConstructL(); |
|
62 |
|
63 RegisterListener(); |
|
64 |
|
65 Dprint( (_L("<-- CSCPLockNotificationEventHandler::ConstructL()") )); |
|
66 } |
|
67 |
|
68 |
|
69 // Static constructor. |
|
70 CSCPLockNotificationEventHandler* CSCPLockNotificationEventHandler::NewL( |
|
71 CSCPServer* aServer |
|
72 ) |
|
73 { |
|
74 Dprint( (_L("--> CSCPLockNotificationEventHandler::NewL()") )); |
|
75 |
|
76 CSCPLockNotificationEventHandler* self = |
|
77 CSCPLockNotificationEventHandler::NewLC( aServer ); |
|
78 |
|
79 CleanupStack::Pop( self ); |
|
80 |
|
81 Dprint( (_L("<-- CSCPLockNotificationEventHandler::NewL()") )); |
|
82 return self; |
|
83 } |
|
84 |
|
85 |
|
86 // Static constructor, leaves object pointer to the cleanup stack. |
|
87 CSCPLockNotificationEventHandler* CSCPLockNotificationEventHandler::NewLC( |
|
88 CSCPServer* aServer |
|
89 ) |
|
90 { |
|
91 Dprint( (_L("--> CSCPLockNotificationEventHandler::NewLC()") )); |
|
92 |
|
93 CSCPLockNotificationEventHandler* self = |
|
94 new (ELeave) CSCPLockNotificationEventHandler( aServer ); |
|
95 |
|
96 CleanupStack::PushL( self ); |
|
97 self->ConstructL(); |
|
98 |
|
99 Dprint( (_L("<-- CSCPLockNotificationEventHandler::NewLC()") )); |
|
100 return self; |
|
101 } |
|
102 |
|
103 |
|
104 // Destructor |
|
105 CSCPLockNotificationEventHandler::~CSCPLockNotificationEventHandler() |
|
106 { |
|
107 Dprint( (_L("--> CSCPLockNotificationEventHandler::\ |
|
108 ~CSCPLockNotificationEventHandler()") )); |
|
109 |
|
110 if ( IsActive() ) |
|
111 { |
|
112 Dprint( (_L("CSCPLockNotificationEventHandler::\ |
|
113 ~CSCPLockNotificationEventHandler(): Cancelling call") )); |
|
114 Cancel(); |
|
115 } |
|
116 |
|
117 Dprint( (_L("<-- CSCPLockNotificationEventHandler::\ |
|
118 ~CSCPLockNotificationEventHandler()") )); |
|
119 } |
|
120 |
|
121 |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // TInt CSCPLockNotificationEventHandler::RegisterListener() |
|
125 // Registers this object for receiving security events via |
|
126 // NotifyOnSecurityEvent. |
|
127 // |
|
128 // Status : Approved |
|
129 // --------------------------------------------------------- |
|
130 // |
|
131 TInt CSCPLockNotificationEventHandler::RegisterListener() |
|
132 { |
|
133 TInt ret; |
|
134 |
|
135 // Register for notifications for security events |
|
136 Dprint( (_L("CSCPLockNotificationEventHandler::\ |
|
137 RegisterListener(): Running NotifySecurityEvent") )); |
|
138 |
|
139 iPhone->NotifySecurityEvent( iStatus, iEvent ); |
|
140 |
|
141 iQueryState = ESCPLNQueryStateNotification; |
|
142 |
|
143 Dprint( (_L("CSCPLockNotificationEventHandler::\ |
|
144 RegisterListener(): Running SetActive") )); |
|
145 SetActive(); |
|
146 ret = KErrNone; |
|
147 |
|
148 return ret; |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------- |
|
152 // void CSCPLockNotificationEventHandler::RunL() |
|
153 // When the correct security event is received, the code query is |
|
154 // verified via VerifySecurityCode. This method also handles the |
|
155 // response for this call. |
|
156 // |
|
157 // Status : Approved |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 void CSCPLockNotificationEventHandler::RunL() |
|
161 { |
|
162 Dprint( (_L("--> CSCPLockNotificationEventHandler::RunL()") )); |
|
163 |
|
164 switch ( iQueryState ) |
|
165 { |
|
166 case ( ESCPLNQueryStateNotification ): |
|
167 { |
|
168 // Event received |
|
169 if ( iEvent == RMobilePhone::EPhonePasswordRequired ) |
|
170 { |
|
171 Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\ |
|
172 EPhonePasswordRequired event received") )); |
|
173 |
|
174 RMobilePhone::TMobilePhoneSecurityCode secCodeType = |
|
175 RMobilePhone::ESecurityCodePhonePassword; |
|
176 |
|
177 RMobilePhone::TMobilePassword password; |
|
178 RMobilePhone::TMobilePassword required_fourth; |
|
179 required_fourth.Zero(); |
|
180 iServer->GetCode( password ); |
|
181 |
|
182 iPhone->VerifySecurityCode(iStatus, secCodeType, |
|
183 password, required_fourth); |
|
184 |
|
185 // Start waiting for verification response |
|
186 iQueryState = ESCPLNQueryStateVerification; |
|
187 SetActive(); |
|
188 } |
|
189 else |
|
190 { |
|
191 Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\ |
|
192 Invalid event received") )); |
|
193 // Re-run registration, this event is not the one we're waiting for |
|
194 RegisterListener(); |
|
195 } |
|
196 |
|
197 break; |
|
198 } |
|
199 |
|
200 case ( ESCPLNQueryStateVerification ): |
|
201 { |
|
202 // Verification response |
|
203 if ( iStatus.Int() == KErrNone ) |
|
204 { |
|
205 Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\ |
|
206 VerifySecurityCode OK") )); |
|
207 } |
|
208 else |
|
209 { |
|
210 Dprint( (_L("CSCPLockNotificationEventHandler::RunL():\ |
|
211 VerifySecurityCode ERROR %d"), iStatus.Int() )); |
|
212 } |
|
213 break; |
|
214 } |
|
215 } |
|
216 |
|
217 |
|
218 Dprint( (_L("<-- CSCPLockNotificationEventHandler::RunL()") )); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------- |
|
222 // void CSCPLockNotificationEventHandler::DoCancel() |
|
223 // Cancels the currently ongoing request. |
|
224 // |
|
225 // Status : Approved |
|
226 // --------------------------------------------------------- |
|
227 // |
|
228 void CSCPLockNotificationEventHandler::DoCancel() |
|
229 { |
|
230 Dprint( (_L("--> CSCPLockNotificationEventHandler::DoCancel()") )); |
|
231 |
|
232 switch ( iQueryState ) |
|
233 { |
|
234 case ( ESCPLNQueryStateNotification ): |
|
235 iPhone->CancelAsyncRequest( EMobilePhoneNotifySecurityEvent ); |
|
236 break; |
|
237 |
|
238 case ( ESCPLNQueryStateVerification ): |
|
239 iPhone->CancelAsyncRequest( EMobilePhoneVerifySecurityCode ); |
|
240 break; |
|
241 } |
|
242 |
|
243 Dprint( (_L("<-- CSCPLockNotificationEventHandler::DoCancel()") )); |
|
244 } |
|
245 |
|
246 |
|
247 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
248 |
|
249 // End of File |
|
250 |