|
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 // Name : strtsecurityeventobserver.cpp |
|
15 // Part of : System Startup / StrtSecObs |
|
16 // Implementation of CStrtSecurityEventObserver class |
|
17 // Version : %version: 1 % << Don't touch! Updated by Synergy at check-out. |
|
18 // This material, including documentation and any related computer |
|
19 // programs, is protected by copyright controlled by Nokia. All |
|
20 // rights are reserved. Copying, including reproducing, storing, |
|
21 // adapting or translating, any or all of this material requires the |
|
22 // prior written consent of Nokia. This material also contains |
|
23 // confidential information which may not be disclosed to others |
|
24 // without the prior written consent of Nokia. |
|
25 // Template version: 4.1.1 |
|
26 // Nokia Core OS * |
|
27 // File renamed from strtsecurityeventobserver.cpp to ssmsecurityeventobserver.cpp as part of Core OS transfer. |
|
28 // |
|
29 |
|
30 |
|
31 |
|
32 #include "strtsecphaseobserver.h" |
|
33 #include "ssmsecurityeventobserver.h" |
|
34 #include "ssmsecuritynotecontroller.h" |
|
35 #include "ssmuiproviderdll.h" |
|
36 #include "ssmdebug.h" |
|
37 |
|
38 const TInt KDefaultPhoneIndex = 0; |
|
39 |
|
40 EXPORT_C MSsmUtility* CStrtSecurityEventObserver::NewL() |
|
41 { |
|
42 CStrtSecurityEventObserver* self = new( ELeave ) CStrtSecurityEventObserver(); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop(self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 void CStrtSecurityEventObserver::InitializeL() |
|
50 { |
|
51 |
|
52 } |
|
53 void CStrtSecurityEventObserver::StartL() |
|
54 { |
|
55 Activate(); |
|
56 } |
|
57 void CStrtSecurityEventObserver::Release() |
|
58 { |
|
59 delete this; |
|
60 } |
|
61 |
|
62 CStrtSecurityEventObserver::~CStrtSecurityEventObserver() |
|
63 { |
|
64 Cancel(); |
|
65 iPhone.Close(); |
|
66 |
|
67 if (iTelServer.Handle()) |
|
68 { |
|
69 iTelServer.UnloadPhoneModule(*iTsyModuleName); |
|
70 iTelServer.Close(); |
|
71 } |
|
72 delete iTsyModuleName; |
|
73 delete iController; |
|
74 delete iSecPhaseObserver; |
|
75 } |
|
76 |
|
77 void CStrtSecurityEventObserver::DoCancel() |
|
78 { |
|
79 iPhone.CancelAsyncRequest(EMobilePhoneNotifySecurityEvent); |
|
80 } |
|
81 |
|
82 void CStrtSecurityEventObserver::RunL() |
|
83 { |
|
84 TInt errorCode = iStatus.Int(); |
|
85 if (errorCode == KErrNone) |
|
86 { |
|
87 DEBUGPRINT2A("SecurityEvent %d occurred", iEvent); |
|
88 ProcessSecurityEvent(); |
|
89 Activate(); |
|
90 } |
|
91 else |
|
92 { |
|
93 DEBUGPRINT2A("Security Event Observer received error: %d - not reactivating", iStatus.Int()); |
|
94 } |
|
95 } |
|
96 |
|
97 CStrtSecurityEventObserver::CStrtSecurityEventObserver() |
|
98 : CActive(EPriorityStandard), |
|
99 iSecPhaseObserver(NULL), |
|
100 iController(NULL) |
|
101 { |
|
102 CActiveScheduler::Add(this); |
|
103 } |
|
104 |
|
105 void CStrtSecurityEventObserver::ConstructL() |
|
106 { |
|
107 iTsyModuleName = CSsmUiSpecific::GetTsyModuleNameL(); |
|
108 |
|
109 TInt errorCode = iTelServer.Connect(); |
|
110 User::LeaveIfError(errorCode); |
|
111 |
|
112 errorCode = iTelServer.LoadPhoneModule(*iTsyModuleName); |
|
113 if (errorCode != KErrNone && errorCode != KErrAlreadyExists) |
|
114 { |
|
115 // KErrAlreadyExists may be returned if some other has already loaded |
|
116 // the TSY module. |
|
117 User::Leave(errorCode); |
|
118 } |
|
119 |
|
120 RTelServer::TPhoneInfo info; |
|
121 errorCode = iTelServer.GetPhoneInfo(KDefaultPhoneIndex, info); |
|
122 User::LeaveIfError(errorCode); |
|
123 |
|
124 errorCode = iPhone.Open(iTelServer, info.iName); |
|
125 User::LeaveIfError(errorCode); |
|
126 |
|
127 iSecPhaseObserver = CStrtSecPhaseObserver::NewL(); |
|
128 iController = CStrtSecurityNoteController::NewL(); |
|
129 } |
|
130 |
|
131 void CStrtSecurityEventObserver::Activate() |
|
132 { |
|
133 iPhone.NotifySecurityEvent(iStatus, iEvent); |
|
134 SetActive(); |
|
135 } |
|
136 |
|
137 void CStrtSecurityEventObserver::ProcessSecurityEvent() |
|
138 { |
|
139 switch (iEvent) |
|
140 { |
|
141 case RMobilePhone::EPin1Required: |
|
142 SimCodeRequest(ESecCodePIN1); |
|
143 break; |
|
144 case RMobilePhone::EPuk1Required: |
|
145 SimCodeRequest(ESecCodePUK1); |
|
146 break; |
|
147 case RMobilePhone::EPin2Required: |
|
148 SimCodeRequest(ESecCodePIN2); |
|
149 break; |
|
150 case RMobilePhone::EPuk2Required: |
|
151 SimCodeRequest(ESecCodePUK2); |
|
152 break; |
|
153 case RMobilePhone::EPhonePasswordRequired: |
|
154 SecCodeRequest(ESecCodePasswd); |
|
155 break; |
|
156 case RMobilePhone::EPin1Verified: |
|
157 CodeVerifyIndication(ESecCodePIN1); |
|
158 break; |
|
159 case RMobilePhone::EPin2Verified: |
|
160 CodeVerifyIndication(ESecCodePIN2); |
|
161 break; |
|
162 case RMobilePhone::EPuk1Verified: |
|
163 CodeVerifyIndication(ESecCodePUK1); |
|
164 break; |
|
165 case RMobilePhone::EPuk2Verified: |
|
166 CodeVerifyIndication(ESecCodePUK2); |
|
167 break; |
|
168 case RMobilePhone::EPhonePasswordVerified: |
|
169 CodeVerifyIndication(ESecCodePasswd); |
|
170 break; |
|
171 case RMobilePhone::EUSIMAppPinRequired: |
|
172 OtherCodeRequest(ESecCodeAppPIN1); |
|
173 break; |
|
174 case RMobilePhone::EUSIMAppPinVerified: |
|
175 CodeVerifyIndication(ESecCodeAppPIN1); |
|
176 break; |
|
177 case RMobilePhone::ESecondUSIMAppPinRequired: |
|
178 OtherCodeRequest(ESecCodeAppPIN2); |
|
179 break; |
|
180 case RMobilePhone::ESecondUSIMAppPinVerified: |
|
181 CodeVerifyIndication(ESecCodeAppPIN2); |
|
182 break; |
|
183 case RMobilePhone::EUniversalPinRequired: |
|
184 SimCodeRequest(ESecCodeUPIN); |
|
185 break; |
|
186 case RMobilePhone::EUniversalPinVerified: |
|
187 CodeVerifyIndication(ESecCodeUPIN); |
|
188 break; |
|
189 case RMobilePhone::EUniversalPukRequired: |
|
190 SimCodeRequest(ESecCodeUPUK); |
|
191 break; |
|
192 case RMobilePhone::EUniversalPukVerified: |
|
193 CodeVerifyIndication(ESecCodeUPUK); |
|
194 break; |
|
195 default: |
|
196 DEBUGPRINT2A("Event %d not handled", iEvent); |
|
197 break; |
|
198 } |
|
199 } |
|
200 |
|
201 void CStrtSecurityEventObserver::SimCodeRequest( |
|
202 const TStrtSecurityNoteType aNoteType ) |
|
203 { |
|
204 DEBUGPRINT2A("Sim code request: %d", aNoteType); |
|
205 if (iSecPhaseObserver->IsSecurityPhaseSimOk()) |
|
206 { |
|
207 iController->SecurityNoteRequested(aNoteType); |
|
208 } |
|
209 else |
|
210 { |
|
211 DEBUGPRINT1A("Startup SIM phase is not over yet, discarding request"); |
|
212 } |
|
213 } |
|
214 |
|
215 void CStrtSecurityEventObserver::SecCodeRequest( |
|
216 const TStrtSecurityNoteType aNoteType ) |
|
217 { |
|
218 DEBUGPRINT2A("Security code request: %d", aNoteType); |
|
219 if (iSecPhaseObserver->IsSecurityPhaseSecOk()) |
|
220 { |
|
221 iController->SecurityNoteRequested(aNoteType); |
|
222 } |
|
223 else |
|
224 { |
|
225 DEBUGPRINT1A("Startup SEC phase is not over yet, discarding request"); |
|
226 } |
|
227 } |
|
228 |
|
229 void CStrtSecurityEventObserver::OtherCodeRequest( |
|
230 const TStrtSecurityNoteType aNoteType ) |
|
231 { |
|
232 DEBUGPRINT2A("Other code request: %d", aNoteType); |
|
233 iController->SecurityNoteRequested(aNoteType); |
|
234 } |
|
235 |
|
236 void CStrtSecurityEventObserver::CodeVerifyIndication( |
|
237 const TStrtSecurityNoteType aNoteType ) |
|
238 { |
|
239 DEBUGPRINT2A("Security code verified: %d", aNoteType); |
|
240 iController->SecurityCodeVerified(aNoteType); |
|
241 } |