|
1 /* |
|
2 * Copyright (c) 2001-2009 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 the License "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 PapNotifDlg dialog plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 9 % |
|
20 */ |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <coemain.h> |
|
24 #include <eikenv.h> |
|
25 #include <bautils.h> |
|
26 #include <data_caging_path_literals.hrh> |
|
27 #include <papnotifdlgui.rsg> |
|
28 |
|
29 #include <e32property.h> // For RProperty |
|
30 #include <UikonInternalPSKeys.h> // For KPSUidUikon and KUikGlobalNotesAllowed. |
|
31 |
|
32 #include <EapTtlsPapNotifierStruct.h> |
|
33 #include "papnotifdlgplugin.h" |
|
34 #include "papauthdialog.h" |
|
35 #include "papchallengemsgdialog.h" |
|
36 #include "papchallengereplydialog.h" |
|
37 |
|
38 // CONSTANTS |
|
39 //static const TUint KUtf8UnicodeRatio = 2; |
|
40 |
|
41 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CreateNotifiersL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 LOCAL_C void CreateNotifiersL( CArrayPtrFlat< MEikSrvNotifierBase2 >* aNotifiers ) |
|
48 { |
|
49 MEikSrvNotifierBase2 *serNotify; |
|
50 serNotify = CPapNotifDialogPlugin::NewL(); |
|
51 CleanupStack::PushL( serNotify ); |
|
52 aNotifiers->AppendL( serNotify ); |
|
53 CleanupStack::Pop( serNotify ); |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // NotifierArray |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CArrayPtr< MEikSrvNotifierBase2 >* NotifierArray() |
|
62 { |
|
63 // NotifierArray() can't leave |
|
64 CArrayPtrFlat< MEikSrvNotifierBase2 >* array = |
|
65 new CArrayPtrFlat< MEikSrvNotifierBase2 >( KPluginGranularity ); |
|
66 |
|
67 if ( array ) |
|
68 { |
|
69 TRAPD( err, CreateNotifiersL( array ) ); |
|
70 |
|
71 if( err ) |
|
72 { |
|
73 TInt count = array->Count(); |
|
74 |
|
75 while( count-- ) |
|
76 { |
|
77 ( *array )[ count ]->Release(); |
|
78 } |
|
79 |
|
80 delete array; |
|
81 array = NULL; |
|
82 } |
|
83 } |
|
84 |
|
85 return( array ); |
|
86 } |
|
87 |
|
88 |
|
89 ////////////////////////////////////////////////////////////// |
|
90 // PAP dialog plugin |
|
91 ///////////////////////////////////////////////////////////// |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CPapNotifDialogPlugin::CPapNotifDialogPlugin |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CPapNotifDialogPlugin::CPapNotifDialogPlugin() |
|
98 : iCancelled( EFalse ), |
|
99 iAuthDlgDismissed( EFalse ), |
|
100 iChallengeMsgDismissed( EFalse ), |
|
101 iChallengeReplyDismissed( EFalse ) |
|
102 { |
|
103 iManager = NULL; |
|
104 } |
|
105 |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CPapNotifDialogPlugin::~CPapNotifDialogPlugin |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CPapNotifDialogPlugin::~CPapNotifDialogPlugin() |
|
112 { |
|
113 CCoeEnv::Static()->DeleteResourceFile( iResource ); |
|
114 |
|
115 if ( !iAuthDlgDismissed ) |
|
116 { |
|
117 delete iPapAuthDialog; |
|
118 } |
|
119 |
|
120 if ( !iChallengeMsgDismissed ) |
|
121 { |
|
122 delete iPapChallengeMsgDialog; |
|
123 } |
|
124 |
|
125 if ( !iChallengeReplyDismissed ) |
|
126 { |
|
127 delete iPapChallengeReplyDialog; |
|
128 } |
|
129 |
|
130 } |
|
131 |
|
132 |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CPapNotifDialogPlugin::RegisterL |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 CPapNotifDialogPlugin::TNotifierInfo CPapNotifDialogPlugin::RegisterL() |
|
139 { |
|
140 iInfo.iUid = KUidPapDialog; |
|
141 iInfo.iPriority = ENotifierPriorityHigh; |
|
142 iInfo.iChannel = KUidPapDialog; |
|
143 return iInfo; |
|
144 } |
|
145 |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CPapNotifDialogPlugin::NewL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 CPapNotifDialogPlugin* CPapNotifDialogPlugin::NewL() |
|
152 { |
|
153 CPapNotifDialogPlugin* self = new( ELeave ) CPapNotifDialogPlugin(); |
|
154 CleanupStack::PushL( self ); |
|
155 self->ConstructL(); |
|
156 CleanupStack::Pop( self ); |
|
157 return self; |
|
158 } |
|
159 |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CPapNotifDialogPlugin::ConstructL |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CPapNotifDialogPlugin::ConstructL() |
|
166 { |
|
167 #if defined( _DEBUG ) || defined( DEBUG ) |
|
168 RDebug::Print(_L("CPapNotifDialogPlugin::ConstructL") ); |
|
169 #endif |
|
170 |
|
171 TFileName fileName; |
|
172 |
|
173 fileName.Append( KDriveZ ); |
|
174 fileName.Append( KDC_RESOURCE_FILES_DIR ); |
|
175 fileName.Append( KResourceFileName ); |
|
176 |
|
177 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName ); |
|
178 iResource = CCoeEnv::Static()->AddResourceFileL( fileName ); |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CPapNotifDialogPlugin::StartL |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TPtrC8 CPapNotifDialogPlugin::StartL( const TDesC8& /*aBuffer*/ ) |
|
187 { |
|
188 return KNullDesC8().Ptr(); |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CPapNotifDialogPlugin::StartL |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CPapNotifDialogPlugin::StartL( const TDesC8& aBuffer, |
|
197 TInt aReplySlot, |
|
198 const RMessagePtr2& aMessage ) |
|
199 { |
|
200 #if defined( _DEBUG ) || defined( DEBUG ) |
|
201 RDebug::Print(_L("CPapNotifDialogPlugin::StartL") ); |
|
202 #endif |
|
203 |
|
204 iCancelled = EFalse; |
|
205 iReplySlot = aReplySlot; |
|
206 iMessage = aMessage; |
|
207 |
|
208 // This object gets constructed only once but |
|
209 // can get called many times. |
|
210 // So initialize everything here. |
|
211 iAuthDlgDismissed = EFalse; |
|
212 iChallengeMsgDismissed = EFalse; |
|
213 iChallengeReplyDismissed = EFalse; |
|
214 iPapAuthDialog = NULL; |
|
215 iPapChallengeMsgDialog = NULL; |
|
216 iPapChallengeReplyDialog = NULL; |
|
217 iDataPtr = NULL; |
|
218 iDataPckgPtr = NULL; |
|
219 |
|
220 // We are about to display the password prompt. |
|
221 // Since this part of the code can be executed during the bootup, check if |
|
222 // the UI has really started up to display notes/dialogs. |
|
223 TInt notesAllowed = 0; |
|
224 TInt error = RProperty::Get( KPSUidUikon, KUikGlobalNotesAllowed, |
|
225 notesAllowed ); |
|
226 |
|
227 // The above call can return error. Ignore the error. What we care is |
|
228 // if notesAllowed has turned to 1 from 0. |
|
229 if ( notesAllowed ) |
|
230 { |
|
231 iDataPtr = new( ELeave ) TPapUiNotifierInfo; |
|
232 iDataPckgPtr = new( ELeave ) TPckg<TPapUiNotifierInfo>( *iDataPtr ); |
|
233 iDataPckgPtr->Copy( aBuffer ); |
|
234 |
|
235 #if defined( _DEBUG ) || defined( DEBUG ) |
|
236 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, state = %d"), iDataPtr->iState ); |
|
237 #endif |
|
238 |
|
239 switch ( iDataPtr->iState ) |
|
240 { |
|
241 case TPapUiNotifierInfo::EPapUiNotifierAuthQueryDialog: |
|
242 { |
|
243 iPapAuthDialog = CPapAuthDialog::NewL( |
|
244 iDataPtr->iUsrPwdInfo.iUserName, |
|
245 iDataPtr->iUsrPwdInfo.iPassword, |
|
246 this ); |
|
247 |
|
248 #if defined( _DEBUG ) || defined( DEBUG ) |
|
249 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, executing auth dialog") ); |
|
250 #endif |
|
251 |
|
252 iPapAuthDialog->ExecuteLD( R_PAPNOTIF_USERNAME_PASSWORD_QUERY ); |
|
253 |
|
254 #if defined( _DEBUG ) || defined( DEBUG ) |
|
255 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, auth dialog executed") ); |
|
256 #endif |
|
257 |
|
258 break; |
|
259 } |
|
260 |
|
261 case TPapUiNotifierInfo::EPapUiNotifierPapChallengeSize: |
|
262 { |
|
263 iChallengeSize = iDataPtr->iSrvChallengeSize; |
|
264 break; |
|
265 } |
|
266 |
|
267 case TPapUiNotifierInfo::EPapUiNotifierPapChallengeMsgDialog: |
|
268 { |
|
269 #if defined( _DEBUG ) || defined( DEBUG ) |
|
270 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, chal msg dialog start") ); |
|
271 #endif |
|
272 |
|
273 HBufC16* challengetext = HBufC16::NewLC( KMaxPapChallengeLength ); |
|
274 TPtr16 text = challengetext->Des(); |
|
275 text.Copy( iDataPtr->iPapChallenge ); |
|
276 |
|
277 #if defined( _DEBUG ) || defined( DEBUG ) |
|
278 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, create chal msg dialog") ); |
|
279 #endif |
|
280 |
|
281 iPapChallengeMsgDialog = CPapChallengeMsgDialog::NewL( text, |
|
282 this ); |
|
283 #if defined( _DEBUG ) || defined( DEBUG ) |
|
284 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, executing chal msg dialog") ); |
|
285 #endif |
|
286 |
|
287 iPapChallengeMsgDialog->ExecuteLD( R_PAP_CHALLENGE_MESSAGE_QUERY ); |
|
288 #if defined( _DEBUG ) || defined( DEBUG ) |
|
289 RDebug::Print(_L("CPapNotifDialogPlugin::StartL, chal msg dialog executed") ); |
|
290 #endif |
|
291 |
|
292 CleanupStack::PopAndDestroy( challengetext ); |
|
293 |
|
294 break; |
|
295 } |
|
296 |
|
297 case TPapUiNotifierInfo::EPapUiNotifierPapChallengeReplyQueryDialog: |
|
298 { |
|
299 // construct and show the challenge reply dialog, |
|
300 // save the reply in the password field |
|
301 iPapChallengeReplyDialog = CPapChallengeReplyDialog::NewL( |
|
302 iDataPtr->iUsrPwdInfo.iPassword, this ); |
|
303 iPapChallengeReplyDialog->ExecuteLD( R_PAP_CHALLENGE_REPLY_QUERY); |
|
304 |
|
305 break; |
|
306 } |
|
307 |
|
308 default: |
|
309 { |
|
310 break; |
|
311 } |
|
312 |
|
313 } |
|
314 |
|
315 } |
|
316 |
|
317 // In case if the notes are not allowed, this message gets completed when |
|
318 // EAPOL time out occurs and a subsequent call to cancel |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CPapNotifDialogPlugin::UpdateL |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 TPtrC8 CPapNotifDialogPlugin::UpdateL( const TDesC8& /*aBuffer*/ ) |
|
326 { |
|
327 return KNullDesC8().Ptr(); |
|
328 } |
|
329 |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CPapNotifDialogPlugin::Cancel |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CPapNotifDialogPlugin::Cancel() |
|
336 { |
|
337 #if defined( _DEBUG ) || defined( DEBUG ) |
|
338 RDebug::Print(_L("CPapNotifDialogPlugin::Cancel") ); |
|
339 #endif |
|
340 |
|
341 if ( !iCancelled ) |
|
342 { |
|
343 iCancelled = ETrue; |
|
344 |
|
345 if ( !iMessage.IsNull() ) |
|
346 { |
|
347 iMessage.Complete( KErrCancel ); |
|
348 } |
|
349 |
|
350 if ( !iAuthDlgDismissed && iPapAuthDialog ) |
|
351 { |
|
352 iAuthDlgDismissed = ETrue; |
|
353 delete iPapAuthDialog; |
|
354 iPapAuthDialog = NULL; |
|
355 } |
|
356 |
|
357 if ( !iChallengeMsgDismissed && iPapChallengeMsgDialog ) |
|
358 { |
|
359 iChallengeMsgDismissed = ETrue; |
|
360 delete iPapChallengeMsgDialog; |
|
361 iPapChallengeMsgDialog = NULL; |
|
362 } |
|
363 |
|
364 if ( !iChallengeReplyDismissed && iPapChallengeReplyDialog ) |
|
365 { |
|
366 iChallengeReplyDismissed = ETrue; |
|
367 delete iPapChallengeReplyDialog; |
|
368 iPapChallengeReplyDialog = NULL; |
|
369 } |
|
370 |
|
371 } |
|
372 |
|
373 if ( iDataPtr ) |
|
374 { |
|
375 delete iDataPtr; |
|
376 iDataPtr = NULL; |
|
377 } |
|
378 |
|
379 if ( iDataPckgPtr ) |
|
380 { |
|
381 delete iDataPckgPtr; |
|
382 iDataPckgPtr = NULL; |
|
383 } |
|
384 } |
|
385 |
|
386 |
|
387 // ----------------------------------------------------------------------------- |
|
388 // CPapNotifDialogPlugin::CompleteL |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CPapNotifDialogPlugin::CompleteL( TInt aStatus ) |
|
392 { |
|
393 #if defined( _DEBUG ) || defined( DEBUG ) |
|
394 RDebug::Print(_L("CPapNotifDialogPlugin::CompleteL") ); |
|
395 #endif |
|
396 |
|
397 if ( aStatus == KErrNone && !iMessage.IsNull() ) |
|
398 { |
|
399 iMessage.WriteL( iReplySlot, *iDataPckgPtr ); |
|
400 } |
|
401 |
|
402 iCancelled = ETrue; |
|
403 |
|
404 if ( !iMessage.IsNull() ) |
|
405 { |
|
406 iMessage.Complete( aStatus ); |
|
407 } |
|
408 |
|
409 if ( iDataPtr ) |
|
410 { |
|
411 delete iDataPtr; |
|
412 iDataPtr = NULL; |
|
413 } |
|
414 |
|
415 if ( iDataPckgPtr ) |
|
416 { |
|
417 delete iDataPckgPtr; |
|
418 iDataPckgPtr = NULL; |
|
419 } |
|
420 } |
|
421 |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CPapNotifDialogPlugin::Release |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 void CPapNotifDialogPlugin::Release() |
|
428 { |
|
429 delete this; |
|
430 } |
|
431 |
|
432 |
|
433 // ----------------------------------------------------------------------------- |
|
434 // CPapNotifDialogPlugin::Info |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 CPapNotifDialogPlugin::TNotifierInfo CPapNotifDialogPlugin::Info() const |
|
438 { |
|
439 return iInfo; |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CPapNotifDialogPlugin::Username |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 TDes& CPapNotifDialogPlugin::Username() |
|
447 { |
|
448 return ( iDataPtr->iUsrPwdInfo.iUserName ) ; |
|
449 } |
|
450 |
|
451 // ----------------------------------------------------------------------------- |
|
452 // CPapNotifDialogPlugin::Password |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 TDes& CPapNotifDialogPlugin::Password() |
|
456 { |
|
457 return ( iDataPtr->iUsrPwdInfo.iPassword ) ; |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // CPapNotifDialogPlugin::SetAuthDlgDismissed |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 void CPapNotifDialogPlugin::SetAuthDlgDismissed() |
|
465 { |
|
466 iAuthDlgDismissed = ETrue; |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CPapNotifDialogPlugin::SetChallengeMsgDismissed |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 void CPapNotifDialogPlugin::SetChallengeMsgDismissed() |
|
474 { |
|
475 iChallengeMsgDismissed = ETrue; |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CPapNotifDialogPlugin::SetChallengeReplyDismissed |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 void CPapNotifDialogPlugin::SetChallengeReplyDismissed() |
|
483 { |
|
484 iChallengeReplyDismissed = ETrue; |
|
485 } |
|
486 |
|
487 |
|
488 |
|
489 // End of File |