1 /* |
|
2 * Copyright (c) 2001-2010 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 GtcNotif dialog plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 12.1.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 <gtcnotifdlgui.rsg> |
|
28 #include <e32base.h> |
|
29 #include <StringLoader.h> |
|
30 |
|
31 #include <e32property.h> // For RProperty |
|
32 #include <UikonInternalPSKeys.h> // For KPSUidUikon and KUikGlobalNotesAllowed. |
|
33 |
|
34 #include "GtcNotifDlgPlugin.h" |
|
35 #include "GTCResponseQueryDialog.h" |
|
36 #include "GTCMessageDisplayDialog.h" |
|
37 |
|
38 |
|
39 // CONSTANTS |
|
40 static const TInt KMaxLengthOfGtcResponse = 256; |
|
41 |
|
42 // Ratio between ascii and unicode character sizes |
|
43 static const TUint KAsciiUnicodeRatio = 2; |
|
44 |
|
45 |
|
46 |
|
47 // ================= OTHER EXPORTED FUNCTIONS ============== |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CreateNotifiersL |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 LOCAL_C void CreateNotifiersL( |
|
54 CArrayPtrFlat< MEikSrvNotifierBase2 >* aNotifiers ) |
|
55 { |
|
56 MEikSrvNotifierBase2 *serNotify; |
|
57 |
|
58 serNotify = CGtcDialogPlugin::NewL(); |
|
59 CleanupStack::PushL( serNotify ); |
|
60 aNotifiers->AppendL( serNotify ); |
|
61 CleanupStack::Pop( serNotify ); |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // NotifierArray |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C CArrayPtr< MEikSrvNotifierBase2 >* NotifierArray() |
|
70 { |
|
71 // NotifierArray() can't leave |
|
72 CArrayPtrFlat< MEikSrvNotifierBase2 >* array = |
|
73 new CArrayPtrFlat< MEikSrvNotifierBase2 >( KPluginGranularity ); |
|
74 |
|
75 if ( array ) |
|
76 { |
|
77 TRAPD( err, CreateNotifiersL( array ) ); |
|
78 |
|
79 if( err ) |
|
80 { |
|
81 TInt count = array->Count(); |
|
82 |
|
83 while( count-- ) |
|
84 { |
|
85 ( *array )[ count ]->Release(); |
|
86 } |
|
87 |
|
88 delete array; |
|
89 array = NULL; |
|
90 } |
|
91 } |
|
92 |
|
93 return( array ); |
|
94 } |
|
95 |
|
96 |
|
97 ////////////////////////////////////////////////////////////// |
|
98 // Gtc dialog plugin |
|
99 ///////////////////////////////////////////////////////////// |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CGtcDialogPlugin::CGtcDialogPlugin |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CGtcDialogPlugin::CGtcDialogPlugin() |
|
106 : iCancelled( EFalse ), |
|
107 iGtcMessageCancelled( EFalse ) |
|
108 { |
|
109 iManager = NULL; |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CGtcDialogPlugin::~CGtcDialogPlugin |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CGtcDialogPlugin::~CGtcDialogPlugin() |
|
118 { |
|
119 CCoeEnv::Static()->DeleteResourceFile( iResource ); |
|
120 |
|
121 if ( !iGtcMessageCancelled ) |
|
122 { |
|
123 delete iGTCMessageDisplayDlg; |
|
124 } |
|
125 |
|
126 if ( !iCancelled ) |
|
127 { |
|
128 delete iGTCResponseQueryDlg; |
|
129 } |
|
130 } |
|
131 |
|
132 |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CGtcDialogPlugin::RegisterL |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 CGtcDialogPlugin::TNotifierInfo CGtcDialogPlugin::RegisterL() |
|
139 { |
|
140 iInfo.iUid = KUidGtcDialog; |
|
141 iInfo.iPriority = ENotifierPriorityHigh; |
|
142 iInfo.iChannel = KUidGtcDialog; |
|
143 return iInfo; |
|
144 } |
|
145 |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CGtcDialogPlugin::NewL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 CGtcDialogPlugin* CGtcDialogPlugin::NewL() |
|
152 { |
|
153 CGtcDialogPlugin* self = new ( ELeave ) CGtcDialogPlugin(); |
|
154 CleanupStack::PushL( self ); |
|
155 self->ConstructL(); |
|
156 CleanupStack::Pop( self ); |
|
157 return self; |
|
158 } |
|
159 |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CGtcDialogPlugin::ConstructL |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CGtcDialogPlugin::ConstructL() |
|
166 { |
|
167 TFileName fileName; |
|
168 |
|
169 fileName.Append( KDriveZ ); |
|
170 fileName.Append( KDC_RESOURCE_FILES_DIR ); |
|
171 fileName.Append( KResourceFileName ); |
|
172 |
|
173 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName ); |
|
174 iResource = CCoeEnv::Static()->AddResourceFileL( fileName ); |
|
175 } |
|
176 |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CGtcDialogPlugin::StartL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TPtrC8 CGtcDialogPlugin::StartL( const TDesC8& /*aBuffer*/ ) |
|
183 { |
|
184 return KNullDesC8().Ptr(); |
|
185 } |
|
186 |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CGtcDialogPlugin::StartL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CGtcDialogPlugin::StartL( const TDesC8& aBuffer, |
|
193 TInt aReplySlot, |
|
194 const RMessagePtr2& aMessage ) |
|
195 { |
|
196 iCancelled = EFalse; |
|
197 iReplySlot = aReplySlot; |
|
198 iMessage = aMessage; |
|
199 |
|
200 // This object gets constructed only once where as this gets called many |
|
201 // times, if user is not answering the query. |
|
202 // So initialize everything here itself. |
|
203 iGTCResponseQueryDlg = NULL; |
|
204 iGTCMessageDisplayDlg = NULL; |
|
205 iDataPtr = NULL; |
|
206 iDataPckgPtr = NULL; |
|
207 iGtcMessageCancelled = EFalse; |
|
208 |
|
209 // We are about to display the password prompt. |
|
210 // Since this part of the code can be executed during the bootup, check if |
|
211 // the UI has really started up to display notes/dialogs. |
|
212 TInt notesAllowed = 0; |
|
213 TInt error = RProperty::Get( KPSUidUikon, KUikGlobalNotesAllowed, |
|
214 notesAllowed ); |
|
215 |
|
216 // The above call can return error. Don't care the error. What we care is |
|
217 // if notesAllowed has turned to 1 from 0. |
|
218 if ( notesAllowed ) |
|
219 { |
|
220 // Display EAP-GTC message if there's one... |
|
221 if ( aBuffer.Length() != 0 ) |
|
222 { |
|
223 HBufC16* buffer = HBufC16::NewLC( aBuffer.Size() / |
|
224 KAsciiUnicodeRatio ); |
|
225 TPtr16 text = buffer->Des(); |
|
226 text.Copy( reinterpret_cast<TUint16 *>( const_cast<TUint8 *> ( |
|
227 aBuffer.Ptr() ) ), aBuffer.Size() / |
|
228 KAsciiUnicodeRatio ); |
|
229 |
|
230 iGTCMessageDisplayDlg = CGTCMessageDisplayDialog::NewL( text, |
|
231 this ); |
|
232 iGTCMessageDisplayDlg->ExecuteLD( R_MESSAGE_QUERY ); |
|
233 |
|
234 // Do not set iGTCMessageDisplayDlg to NULL here, because then |
|
235 // a timeout cancel will cause a crash. Prevent double deletion |
|
236 // by checking iGtcMessageCancelled in the destructor. |
|
237 |
|
238 CleanupStack::PopAndDestroy( buffer ); |
|
239 } |
|
240 else |
|
241 { |
|
242 // Show the data query directly since there is no message to display. |
|
243 CompleteMessageDisplayL( KErrNone ); |
|
244 } |
|
245 } |
|
246 |
|
247 // In case if the notes are not allowed, this message gets completed when |
|
248 // EAPOL time out occurs and a subsequent call to cancel from |
|
249 // eap_am_type_securid_symbian_c::DoCancel(). |
|
250 |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CGtcDialogPlugin::UpdateL |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 TPtrC8 CGtcDialogPlugin::UpdateL( const TDesC8& /*aBuffer*/ ) |
|
259 { |
|
260 return KNullDesC8().Ptr(); |
|
261 } |
|
262 |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CGtcDialogPlugin::Cancel |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CGtcDialogPlugin::Cancel() |
|
269 { |
|
270 if ( !iCancelled ) |
|
271 { |
|
272 iCancelled = ETrue; |
|
273 |
|
274 if ( !iMessage.IsNull() ) |
|
275 { |
|
276 iMessage.Complete( KErrCancel ); |
|
277 } |
|
278 |
|
279 if ( iGTCResponseQueryDlg ) |
|
280 { |
|
281 delete iGTCResponseQueryDlg; |
|
282 iGTCResponseQueryDlg = NULL; |
|
283 } |
|
284 |
|
285 if ( !iGtcMessageCancelled && iGTCMessageDisplayDlg ) |
|
286 { |
|
287 iGtcMessageCancelled = ETrue; |
|
288 delete iGTCMessageDisplayDlg; |
|
289 iGTCMessageDisplayDlg = NULL; |
|
290 } |
|
291 } |
|
292 |
|
293 if( iDataPtr ) |
|
294 { |
|
295 delete iDataPtr; |
|
296 iDataPtr = NULL; |
|
297 } |
|
298 |
|
299 if( iDataPckgPtr ) |
|
300 { |
|
301 delete iDataPckgPtr; |
|
302 iDataPckgPtr = NULL; |
|
303 } |
|
304 } |
|
305 |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CGtcDialogPlugin::CompleteL |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 void CGtcDialogPlugin::CompleteL( TInt aStatus ) |
|
312 { |
|
313 if ( aStatus == KErrNone && !iMessage.IsNull() ) |
|
314 { |
|
315 iMessage.WriteL( iReplySlot, *iDataPckgPtr); |
|
316 } |
|
317 |
|
318 iCancelled = ETrue; |
|
319 |
|
320 if ( !iMessage.IsNull() ) |
|
321 { |
|
322 iMessage.Complete( aStatus ); |
|
323 } |
|
324 |
|
325 if( iDataPtr ) |
|
326 { |
|
327 delete iDataPtr; |
|
328 iDataPtr = NULL; |
|
329 } |
|
330 |
|
331 if( iDataPckgPtr ) |
|
332 { |
|
333 delete iDataPckgPtr; |
|
334 iDataPckgPtr = NULL; |
|
335 } |
|
336 } |
|
337 |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CGtcDialogPlugin::Release |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 void CGtcDialogPlugin::Release() |
|
344 { |
|
345 delete this; |
|
346 } |
|
347 |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CGtcDialogPlugin::Info |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 CGtcDialogPlugin::TNotifierInfo CGtcDialogPlugin::Info() const |
|
354 { |
|
355 return iInfo; |
|
356 } |
|
357 |
|
358 |
|
359 // ----------------------------------------------------------------------------- |
|
360 // CGtcDialogPlugin::CompleteMessageDisplayL |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 void CGtcDialogPlugin::CompleteMessageDisplayL( TInt aStatus ) |
|
364 { |
|
365 iGtcMessageCancelled = ETrue; |
|
366 |
|
367 if ( aStatus == KErrNone ) |
|
368 { |
|
369 // Now user has acknowledged the GTC message. |
|
370 // Show the response query to enter the password. |
|
371 |
|
372 iDataPtr = new( ELeave ) TEapGtcUsernamePasswordInfo; |
|
373 iDataPckgPtr = new( ELeave ) TPckg<TEapGtcUsernamePasswordInfo>( |
|
374 *iDataPtr ); |
|
375 |
|
376 TBuf16<KMaxLengthOfGtcResponse> response; |
|
377 |
|
378 iGTCResponseQueryDlg = CGTCResponseQueryDialog::NewL( |
|
379 iDataPtr->iPasscode, this ); |
|
380 |
|
381 HBufC* text = StringLoader::LoadLC( R_GTC_RESPONSE ); |
|
382 iGTCResponseQueryDlg->SetPromptL( *text ); |
|
383 CleanupStack::PopAndDestroy( text ); |
|
384 |
|
385 iGTCResponseQueryDlg->ExecuteLD( R_GTC_PASSWORD_QUERY); |
|
386 |
|
387 // Do not set iGTCResponseQueryDlg to NULL here, because then |
|
388 // a timeout cancel will cause a crash. Prevent double deletion |
|
389 // by checking iCancelled in the destructor. |
|
390 } |
|
391 else |
|
392 { |
|
393 // User probably cancelled the message, some how. |
|
394 // Can not continue to show the password query. |
|
395 if ( !iMessage.IsNull() ) |
|
396 { |
|
397 iMessage.Complete( aStatus ); |
|
398 } |
|
399 } |
|
400 } |
|
401 |
|
402 |
|
403 // End of File |
|