152 { |
152 { |
153 iPhone = WPPhoneFactory::CreateL(); |
153 iPhone = WPPhoneFactory::CreateL(); |
154 } |
154 } |
155 |
155 |
156 FLOG( _L( "CWPMessage::ProcessL: Creating engine" ) ); |
156 FLOG( _L( "CWPMessage::ProcessL: Creating engine" ) ); |
157 |
157 |
|
158 |
|
159 TInt value( 0 ); |
|
160 CRepository* rep = CRepository::NewLC( KOMAProvAuthenticationLV ); |
|
161 |
|
162 TInt error = rep->Set(KOMAProvIsUserPin, value); |
|
163 if(error != KErrNone) |
|
164 { |
|
165 FLOG( _L( "CWPMessage::ProcessL: set KOMAProvIsUserPin Failed" ) ); |
|
166 } |
|
167 |
|
168 error = rep->Set(KOMAProvCriticalAdapterSettingCount, value); |
|
169 if(error != KErrNone) |
|
170 { |
|
171 FLOG( _L( "CWPMessage::ProcessL: set KOMAProvCriticalAdapterSettingCount Failed" ) ); |
|
172 } |
|
173 |
|
174 CleanupStack::PopAndDestroy(); // rep |
|
175 |
158 // Read the message into the engine |
176 // Read the message into the engine |
159 CWPEngine* engine = CWPEngine::NewLC(); // on CS |
177 CWPEngine* engine = CWPEngine::NewLC(); // on CS |
160 |
178 |
161 FLOG( _L( "CWPMessage::ProcessL: Importing document" ) ); |
179 FLOG( _L( "CWPMessage::ProcessL: Importing document" ) ); |
162 engine->ImportDocumentL( iMessage->Body() ); |
180 engine->ImportDocumentL( iMessage->Body() ); |
163 |
181 |
164 FLOG( _L( "CWPMessage::ProcessL: Populating adapters" ) ); |
182 FLOG( _L( "CWPMessage::ProcessL: Populating adapters" ) ); |
|
183 |
165 engine->PopulateL(); |
184 engine->PopulateL(); |
166 |
185 |
167 FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Number of settings: (%d)"), engine->ItemCount())); |
186 FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Number of settings: (%d)"), engine->ItemCount())); |
168 // Check if the sender can be trusted |
187 // Check if the sender can be trusted |
169 TPtrC8 orig8( iMessage->Originator() ); |
188 TPtrC8 orig8( iMessage->Originator() ); |
178 |
197 |
179 // Try bootstrapping |
198 // Try bootstrapping |
180 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping" ) ); |
199 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping" ) ); |
181 CWPBootstrap* bootstrap = CWPBootstrap::NewL( iPhone->SubscriberId() ); |
200 CWPBootstrap* bootstrap = CWPBootstrap::NewL( iPhone->SubscriberId() ); |
182 CleanupStack::PushL( bootstrap ); |
201 CleanupStack::PushL( bootstrap ); |
183 |
202 |
184 CWPBootstrap::TBootstrapResult result( |
203 CWPBootstrap::TBootstrapResult result( |
185 bootstrap->BootstrapL( *iMessage, *engine, KNullDesC ) ); |
204 bootstrap->BootstrapL( *iMessage, *engine, KNullDesC ) ); |
186 CleanupStack::PopAndDestroy(); // bootstrap |
205 CleanupStack::PopAndDestroy(); // bootstrap |
187 |
206 |
188 FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Bootstrap result: (%d)"), result)); |
207 FTRACE(RDebug::Print(_L(" WPMessage::ProcessL: Bootstrap result: (%d)"), result)); |
189 // See UI specs figure 1 |
208 // See UI specs figure 1 |
|
209 |
|
210 TInt adapterCount( 0 ); |
|
211 TInt userPin(0); |
|
212 TInt allowCriticalSetting(0); |
|
213 |
|
214 CRepository* repository = CRepository::NewLC( KOMAProvAuthenticationLV ); |
|
215 TInt getErr = repository->Get( KOMAProvCriticalAdapterSettingCount, adapterCount); |
|
216 if(getErr != KErrNone) |
|
217 { |
|
218 FLOG( _L( "CWPMessage::ProcessL: set KOMAProvCriticalAdapterSettingCount Failed" ) ); |
|
219 } |
|
220 |
|
221 getErr = repository->Get( KOMAProvIsUserPin, userPin ); |
|
222 if(getErr != KErrNone) |
|
223 { |
|
224 FLOG( _L( "CWPMessage::PrepareEntryLC: set KOMAProvIsUserPin Failed" ) ); |
|
225 } |
|
226 |
|
227 getErr = repository->Get( KOMAProvAllowCriticalAdapterSetting, allowCriticalSetting ); |
|
228 if(getErr != KErrNone) |
|
229 { |
|
230 FLOG( _L( "CWPMessage::PrepareEntryLC: set KOMAProvIsUserPin Failed" ) ); |
|
231 } |
|
232 |
|
233 CleanupStack::PopAndDestroy(); // repository |
|
234 |
|
235 |
|
236 |
190 TBool haveSettings( engine->ItemCount() > 0 ); |
237 TBool haveSettings( engine->ItemCount() > 0 ); |
191 switch( result ) |
238 switch( result ) |
192 { |
239 { |
193 case CWPBootstrap::ENoBootstrap: |
240 case CWPBootstrap::ENoBootstrap: |
194 { |
241 { |
195 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENoBootstrap" ) ); |
242 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENoBootstrap" ) ); |
196 // If there's no bootstrap, just save the message |
243 // If there's no bootstrap, just save the message |
197 if( haveSettings ) |
244 |
|
245 if( haveSettings) |
198 { |
246 { |
199 StoreMsgL(); |
247 if(allowCriticalSetting) |
|
248 { |
|
249 if(!userPin) |
|
250 { |
|
251 StoreMsgL(); |
|
252 } |
|
253 else if(adapterCount != engine->ItemCount()) |
|
254 { |
|
255 StoreMsgL(); |
|
256 } |
|
257 } |
|
258 else |
|
259 { |
|
260 StoreMsgL(); |
|
261 } |
200 } |
262 } |
201 else |
263 else |
202 { |
264 { |
203 User::Leave( KErrCorrupt ); |
265 User::Leave( KErrCorrupt ); |
204 } |
266 } |
206 } |
268 } |
207 |
269 |
208 case CWPBootstrap::ENotAuthenticated: |
270 case CWPBootstrap::ENotAuthenticated: |
209 { |
271 { |
210 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENotAuthenticated" ) ); |
272 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping ENotAuthenticated" ) ); |
211 if( haveSettings ) |
273 |
212 { |
274 if(haveSettings) |
213 StoreMsgL(); |
275 { |
214 } |
276 if(allowCriticalSetting) |
|
277 { |
|
278 if(adapterCount != engine->ItemCount()) |
|
279 { |
|
280 StoreMsgL(); |
|
281 } |
|
282 } |
|
283 else |
|
284 { |
|
285 StoreMsgL(); |
|
286 } |
|
287 } |
215 else |
288 else |
216 { |
289 { |
217 |
|
218 // Message is ignored and an information SMs is put to Inbox. |
290 // Message is ignored and an information SMs is put to Inbox. |
219 //Information SMs can be Class0, based on operator requirement. |
291 //Information SMs can be Class0, based on operator requirement. |
220 TInt auth_value; |
292 if(allowCriticalSetting) |
221 CRepository * rep = 0; |
293 { |
222 TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV )); |
294 if(adapterCount != engine->ItemCount()) |
223 if(err == KErrNone) |
295 { |
224 { |
296 TInt auth_value; |
225 rep->Get( KOMAProvAuthFailMsgHandling, auth_value ); |
297 CRepository * rep = 0; |
226 delete rep; |
298 TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV )); |
|
299 if(err == KErrNone) |
|
300 { |
|
301 rep->Get( KOMAProvAuthFailMsgHandling, auth_value ); |
|
302 delete rep; |
227 |
303 |
228 if(auth_value == 1) |
304 if(auth_value == 1) |
229 StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED); |
305 StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED); |
|
306 else |
|
307 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
308 |
|
309 User::Leave( KErrAccessDenied ); |
|
310 } |
|
311 else |
|
312 { |
|
313 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
314 User::Leave( KErrAccessDenied ); |
|
315 } |
|
316 } |
|
317 } |
230 else |
318 else |
231 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
319 { |
|
320 TInt auth_value; |
|
321 CRepository * rep = 0; |
|
322 TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV )); |
|
323 if(err == KErrNone) |
|
324 { |
|
325 rep->Get( KOMAProvAuthFailMsgHandling, auth_value ); |
|
326 delete rep; |
232 |
327 |
233 User::Leave( KErrAccessDenied ); |
328 if(auth_value == 1) |
234 } |
329 StoreMsgclass0L(R_TEXT_AUTHENTICATION_FAILED); |
235 else |
330 else |
236 { |
331 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
237 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
332 |
238 User::Leave( KErrAccessDenied ); |
333 User::Leave( KErrAccessDenied ); |
239 } |
334 } |
240 } |
335 else |
|
336 { |
|
337 StoreMsgL(R_TEXT_AUTHENTICATION_FAILED); |
|
338 User::Leave( KErrAccessDenied ); |
|
339 } |
|
340 } |
|
341 } |
241 break; |
342 break; |
242 } |
343 } |
243 |
344 |
244 case CWPBootstrap::EPinRequired: |
345 case CWPBootstrap::EPinRequired: |
245 { |
346 { |
246 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EPinRequired" ) ); |
347 FLOG( _L( "CWPMessage::ProcessL: Bootstrapping EPinRequired" ) ); |
247 |
348 |
248 // If PIN is required, defer authentication to ProvisioningBC |
349 // If PIN is required, defer authentication to ProvisioningBC |
249 if( haveSettings ) |
350 if(haveSettings) |
250 { |
351 { |
251 StoreMsgL(); |
352 if(allowCriticalSetting) |
|
353 { |
|
354 if(!userPin) |
|
355 { |
|
356 StoreMsgL(); |
|
357 } |
|
358 else if(adapterCount != engine->ItemCount()) |
|
359 { |
|
360 StoreMsgL(); |
|
361 } |
|
362 } |
|
363 else |
|
364 { |
|
365 StoreMsgL(); |
|
366 } |
252 } |
367 } |
253 else |
368 else |
254 { |
369 { |
255 User::Leave( KErrCorrupt ); |
370 User::Leave( KErrCorrupt ); |
256 } |
371 } |
257 break; |
372 break; |
258 } |
373 } |
259 |
374 |
569 aEntry.iDate = time; |
684 aEntry.iDate = time; |
570 aEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
685 aEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
571 aEntry.iError = KErrNone; |
686 aEntry.iError = KErrNone; |
572 // iMtmData1 is been used/reserved for count, please don't use for any other purpose. |
687 // iMtmData1 is been used/reserved for count, please don't use for any other purpose. |
573 aEntry.SetMtmData1(3); |
688 aEntry.SetMtmData1(3); |
|
689 aEntry.SetMtmData2(0); |
|
690 |
|
691 TInt userPin = 0; |
|
692 CRepository* repository = CRepository::NewLC( KOMAProvAuthenticationLV ); |
|
693 TInt err = repository->Get( KOMAProvIsUserPin, userPin ); |
|
694 if(err != KErrNone) |
|
695 { |
|
696 FLOG( _L( "CWPMessage::PrepareEntryLC: set KOMAProvIsUserPin Failed" ) ); |
|
697 } |
|
698 CleanupStack::PopAndDestroy(); // repository |
|
699 |
|
700 if(userPin == 1) |
|
701 { |
|
702 aEntry.SetMtmData2(1); |
|
703 } |
|
704 |
574 FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) ); |
705 FLOG( _L( "CWPMessage::PrepareEntryLC create an invisible blank entry done" ) ); |
575 // Look up the details |
706 // Look up the details |
576 HBufC* details = NULL; |
707 HBufC* details = NULL; |
577 if( iMessage->Authenticated() ) |
708 if( iMessage->Authenticated() ) |
578 { |
709 { |