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