|
1 /* |
|
2 * Copyright (c) 2002 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 "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 plugins (base & all derived). |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "ConnDlgPlugin.h" |
|
20 #include "AuthenticationDialog.h" |
|
21 #include "ReconnectDialog.h" |
|
22 #include "QosDialog.h" |
|
23 #include "NewIapDialog.h" |
|
24 #include "ActiveIapPlugin.h" |
|
25 |
|
26 #include "ActiveSelectConnectionPlugin.h" |
|
27 #include "CConnDlgPrivateCRKeys.h" |
|
28 #include <centralrepository.h> |
|
29 |
|
30 #include "ConnectionDialogsUidDefs.h" |
|
31 #include "ConnectionDialogsLogger.h" |
|
32 |
|
33 #include <eikenv.h> |
|
34 #include <bautils.h> |
|
35 #include <e32property.h> |
|
36 #include <rmpm.h> |
|
37 |
|
38 #include <CConnDlgPlugin.rsg> |
|
39 #include <data_caging_path_literals.hrh> |
|
40 |
|
41 using namespace CommsDat; |
|
42 |
|
43 // CONSTANTS |
|
44 |
|
45 // RSC file name. |
|
46 _LIT( KResourceFileName, "CConnDlgPlugin.rsc" ); |
|
47 |
|
48 // Panic string |
|
49 _LIT( KConnDlgPluginPanic, "CConnDlgPlugin" ); |
|
50 |
|
51 LOCAL_D const TInt KPluginGranularity = 4; |
|
52 |
|
53 #if defined(_DEBUG) |
|
54 _LIT( KErrActiveObjectNull, "iActivePlugin not NULL" ); |
|
55 #endif |
|
56 |
|
57 |
|
58 |
|
59 LOCAL_C void CreateNotifiersL( |
|
60 CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers ); |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // NotifierArray() |
|
67 // Lib main entry point |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 |
|
71 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray() |
|
72 { |
|
73 CArrayPtrFlat<MEikSrvNotifierBase2>* array = new (ELeave) |
|
74 CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity ); |
|
75 |
|
76 if ( array ) |
|
77 { |
|
78 TRAPD( err, CreateNotifiersL( array ) ); |
|
79 if( err ) |
|
80 { |
|
81 TInt count = array->Count(); |
|
82 while( count-- ) |
|
83 { |
|
84 (*array)[count]->Release(); |
|
85 } |
|
86 delete array; |
|
87 array = NULL; |
|
88 } |
|
89 } |
|
90 |
|
91 return( array ); |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CreateNotifiersL |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 LOCAL_C void CreateNotifiersL( |
|
100 CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers ) |
|
101 { |
|
102 MEikSrvNotifierBase2 *serNotify; |
|
103 TBool resourceFileResponsible = ETrue; |
|
104 |
|
105 serNotify = CConnDlgIapPlugin::NewL( resourceFileResponsible ); |
|
106 CleanupStack::PushL( serNotify ); |
|
107 aNotifiers->AppendL( serNotify ); |
|
108 CleanupStack::Pop( serNotify ); |
|
109 |
|
110 resourceFileResponsible = EFalse; // Only the first has to load resources |
|
111 |
|
112 serNotify = CConnDlgAuthenticationPlugin::NewL( resourceFileResponsible ); |
|
113 CleanupStack::PushL( serNotify ); |
|
114 aNotifiers->AppendL( serNotify ); |
|
115 CleanupStack::Pop( serNotify ); |
|
116 |
|
117 serNotify = CConnDlgReconnectPlugin::NewL( resourceFileResponsible ); |
|
118 CleanupStack::PushL( serNotify ); |
|
119 aNotifiers->AppendL( serNotify ); |
|
120 CleanupStack::Pop( serNotify ); |
|
121 |
|
122 serNotify = CConnDlgNewIapPlugin::NewL( resourceFileResponsible ); |
|
123 CleanupStack::PushL( serNotify ); |
|
124 aNotifiers->AppendL( serNotify ); |
|
125 CleanupStack::Pop( serNotify ); |
|
126 |
|
127 serNotify = CConnDlgQosPlugin::NewL( resourceFileResponsible ); |
|
128 CleanupStack::PushL( serNotify ); |
|
129 aNotifiers->AppendL( serNotify ); |
|
130 CleanupStack::Pop( serNotify ); |
|
131 |
|
132 serNotify = CConnDlgSelectConnectionPlugin::NewL( |
|
133 resourceFileResponsible ); |
|
134 CleanupStack::PushL( serNotify ); |
|
135 aNotifiers->AppendL( serNotify ); |
|
136 CleanupStack::Pop( serNotify ); |
|
137 } |
|
138 |
|
139 |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CConnDlgIapPlugin::TNotifierInfo CConnDlgIapPlugin::RegisterL() |
|
143 // --------------------------------------------------------- |
|
144 // |
|
145 CConnDlgIapPlugin::TNotifierInfo CConnDlgIapPlugin::RegisterL() |
|
146 { |
|
147 iInfo.iUid = KUidCConnDlgIap; |
|
148 iInfo.iPriority = ENotifierPriorityHigh; |
|
149 iInfo.iChannel = KUidCConnDlgIap; |
|
150 |
|
151 return iInfo; |
|
152 } |
|
153 |
|
154 |
|
155 // --------------------------------------------------------- |
|
156 // void CConnDlgIapPlugin::StartL |
|
157 // --------------------------------------------------------- |
|
158 // |
|
159 |
|
160 void CConnDlgIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot, |
|
161 const RMessagePtr2& aMessage ) |
|
162 { |
|
163 iPrefs.Copy( (TPtrC8) aBuffer ); |
|
164 |
|
165 iCancelled = EFalse; |
|
166 iReplySlot = aReplySlot; |
|
167 iMessage = aMessage; |
|
168 |
|
169 // Check if there is a suitable active connection |
|
170 TInt iap( 0 ); |
|
171 TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1 |
|
172 |
|
173 // Is there active User connection |
|
174 TInt err = GetUserConnection( iap ); |
|
175 |
|
176 if ( err != KErrNone || iap == 0 ) |
|
177 { |
|
178 // Is there any active connection |
|
179 err = GetActiveConnection( iap, bearer ); |
|
180 } |
|
181 |
|
182 if ( ( err == KErrNone ) && |
|
183 ( iap != 0 ) && |
|
184 ( iPrefs().iBearerSet & bearer ) ) |
|
185 { |
|
186 // a suitable connection is already active |
|
187 iIAP = iap; |
|
188 CompleteL( KErrNone ); |
|
189 } |
|
190 else |
|
191 { |
|
192 // display a dialog |
|
193 __ASSERT_DEBUG( !iActivePlugin, |
|
194 User::Panic( KErrActiveObjectNull, KErrNone ) ); |
|
195 |
|
196 iActivePlugin = CActiveCConnDlgIapPlugin::NewL( this, iPrefs() ); |
|
197 iActivePlugin->StartSearchIAPsL(); |
|
198 } |
|
199 } |
|
200 |
|
201 |
|
202 |
|
203 // --------------------------------------------------------- |
|
204 // void CConnDlgIapPlugin::Cancel() |
|
205 // --------------------------------------------------------- |
|
206 // |
|
207 void CConnDlgIapPlugin::Cancel() |
|
208 { |
|
209 delete iActivePlugin; |
|
210 iActivePlugin = NULL; |
|
211 |
|
212 if ( !iCancelled ) |
|
213 { |
|
214 iCancelled = ETrue; |
|
215 if ( !iMessage.IsNull() ) |
|
216 { |
|
217 iMessage.Complete( KErrCancel ); |
|
218 } |
|
219 } |
|
220 } |
|
221 |
|
222 |
|
223 // --------------------------------------------------------- |
|
224 // void CConnDlgIapPlugin::CompleteL( TInt aStatus ) |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 void CConnDlgIapPlugin::CompleteL( TInt aStatus ) |
|
228 { |
|
229 CLOG_ENTERFN( "CConnDlgIapPlugin::CompleteL" ); |
|
230 |
|
231 iCancelled = ETrue; |
|
232 if ( !iMessage.IsNull() ) |
|
233 { |
|
234 if ( aStatus == KErrNone ) |
|
235 { |
|
236 iMessage.WriteL( iReplySlot, TPckg<TUint32>( iIAP ) ); |
|
237 } |
|
238 |
|
239 CLOG_WRITEF( _L( "CConnDlgIapPlugin::CompleteL iIAP : %d" ), iIAP ); |
|
240 |
|
241 iMessage.Complete( aStatus ); |
|
242 } |
|
243 Cancel(); |
|
244 |
|
245 CLOG_LEAVEFN( "CConnDlgIapPlugin::CompleteL" ); |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------- |
|
250 // CConnDlgIapPlugin* CConnDlgIapPlugin::NewL() |
|
251 // --------------------------------------------------------- |
|
252 // |
|
253 CConnDlgIapPlugin* CConnDlgIapPlugin::NewL( |
|
254 const TBool aResourceFileResponsible ) |
|
255 { |
|
256 CConnDlgIapPlugin* self = new (ELeave) CConnDlgIapPlugin(); |
|
257 CleanupStack::PushL( self ); |
|
258 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
259 CleanupStack::Pop(); |
|
260 |
|
261 return self; |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CConnDlgIapPlugin::SetPreferredIapIdL |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 void CConnDlgIapPlugin::SetPreferredIapIdL( TUint32 aIAPId ) |
|
269 { |
|
270 CLOG_ENTERFN( "CConnDlgIapPlugin::SetPreferredIapIdL " ); |
|
271 |
|
272 iIAP = aIAPId; |
|
273 |
|
274 CLOG_LEAVEFN( "CConnDlgIapPlugin::SetPreferredIapIdL " ); |
|
275 } |
|
276 |
|
277 |
|
278 // --------------------------------------------------------- |
|
279 // CConnDlgIapPlugin::GetActiveConnection |
|
280 // --------------------------------------------------------- |
|
281 // |
|
282 TInt CConnDlgIapPlugin::GetActiveConnection( TInt& aIapId, |
|
283 TInt& aBearer ) |
|
284 { |
|
285 aIapId = 0; |
|
286 aBearer = 0; |
|
287 |
|
288 TInt err = RProperty::Get( KMPMActiveConnectionCategory, |
|
289 KMPMPSKeyActiveConnectionIap, |
|
290 aIapId ); |
|
291 |
|
292 CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId ); |
|
293 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
294 |
|
295 if ( err == KErrNone ) |
|
296 { |
|
297 err = RProperty::Get( KMPMActiveConnectionCategory, |
|
298 KMPMPSKeyActiveConnectionBearer, |
|
299 aBearer ); |
|
300 } |
|
301 |
|
302 CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer ); |
|
303 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
304 CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet ); |
|
305 |
|
306 return err; |
|
307 } |
|
308 |
|
309 |
|
310 // --------------------------------------------------------- |
|
311 // CConnDlgIapPlugin::GetUserConnection |
|
312 // --------------------------------------------------------- |
|
313 // |
|
314 TInt CConnDlgIapPlugin::GetUserConnection( TInt& aIapId ) |
|
315 { |
|
316 aIapId = 0; |
|
317 |
|
318 TInt err = RProperty::Get( KMPMUserConnectionCategory, |
|
319 KMPMPSKeyUserConnectionIap, |
|
320 aIapId ); |
|
321 |
|
322 CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId ); |
|
323 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
324 |
|
325 return err; |
|
326 } |
|
327 |
|
328 |
|
329 // --------------------------------------------------------- |
|
330 // CConnDlgAuthenticationPlugin::TNotifierInfo |
|
331 // CConnDlgAuthenticationPlugin::RegisterL() |
|
332 // --------------------------------------------------------- |
|
333 // |
|
334 CConnDlgAuthenticationPlugin::TNotifierInfo |
|
335 CConnDlgAuthenticationPlugin::RegisterL() |
|
336 { |
|
337 iInfo.iUid = KUidCConnDlgAuthentication; |
|
338 iInfo.iPriority = ENotifierPriorityHigh; |
|
339 iInfo.iChannel = KUidCConnDlgAuthentication; |
|
340 |
|
341 return iInfo; |
|
342 } |
|
343 |
|
344 |
|
345 // --------------------------------------------------------- |
|
346 // void CConnDlgAuthenticationPlugin::StartL |
|
347 // --------------------------------------------------------- |
|
348 // |
|
349 |
|
350 void CConnDlgAuthenticationPlugin::StartL( const TDesC8& aBuffer, |
|
351 TInt aReplySlot, |
|
352 const RMessagePtr2& aMessage ) |
|
353 { |
|
354 CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::StartL" ); |
|
355 |
|
356 if ( aBuffer.Length() > iAuthPairBuff.Length() ) |
|
357 { |
|
358 CLOG_WRITE( "User::Panic, EConnDlgIllegalRequest" ); |
|
359 User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest ); |
|
360 } |
|
361 |
|
362 iAuthPairBuff.Copy( aBuffer ); |
|
363 |
|
364 iReplySlot = aReplySlot; |
|
365 iMessage = aMessage; |
|
366 iCancelled = EFalse; |
|
367 |
|
368 GetAuthenticationL(); |
|
369 |
|
370 CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::StartL" ); |
|
371 } |
|
372 |
|
373 |
|
374 |
|
375 // --------------------------------------------------------- |
|
376 // void CConnDlgAuthenticationPlugin::Cancel() |
|
377 // --------------------------------------------------------- |
|
378 // |
|
379 void CConnDlgAuthenticationPlugin::Cancel() |
|
380 { |
|
381 CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::Cancel" ); |
|
382 |
|
383 if ( !iCancelled ) |
|
384 { |
|
385 iCancelled = ETrue; |
|
386 if ( !iMessage.IsNull() ) |
|
387 { |
|
388 iMessage.Complete( KErrCancel ); |
|
389 } |
|
390 delete iDialog; |
|
391 iDialog = NULL; |
|
392 } |
|
393 |
|
394 CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::Cancel" ); |
|
395 } |
|
396 |
|
397 |
|
398 // --------------------------------------------------------- |
|
399 // void CConnDlgAuthenticationPlugin::GetAuthenticationL() |
|
400 // --------------------------------------------------------- |
|
401 // |
|
402 void CConnDlgAuthenticationPlugin::GetAuthenticationL() |
|
403 { |
|
404 CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" ); |
|
405 |
|
406 iDialog = CAuthenticationDialog::NewL( this, iAuthPairBuff().iUsername, |
|
407 iAuthPairBuff().iPassword ); |
|
408 |
|
409 |
|
410 iDialog->ExecuteLD( R_CONNDLG_AUTHENTICATION ); |
|
411 |
|
412 CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::GetAuthenticationL" ); |
|
413 } |
|
414 |
|
415 |
|
416 // --------------------------------------------------------- |
|
417 // void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus ) |
|
418 // --------------------------------------------------------- |
|
419 // |
|
420 void CConnDlgAuthenticationPlugin::CompleteL( TInt aStatus ) |
|
421 { |
|
422 CLOG_ENTERFN( "CConnDlgAuthenticationPlugin::CompleteL" ); |
|
423 |
|
424 iCancelled = ETrue; |
|
425 if ( !iMessage.IsNull() ) |
|
426 { |
|
427 if ( aStatus == KErrNone ) |
|
428 { |
|
429 iMessage.WriteL( iReplySlot, iAuthPairBuff ); |
|
430 } |
|
431 |
|
432 iMessage.Complete( aStatus ); |
|
433 } |
|
434 Cancel(); |
|
435 |
|
436 CLOG_LEAVEFN( "CConnDlgAuthenticationPlugin::CompleteL" ); |
|
437 } |
|
438 |
|
439 |
|
440 // --------------------------------------------------------- |
|
441 // CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL() |
|
442 // --------------------------------------------------------- |
|
443 // |
|
444 CConnDlgAuthenticationPlugin* CConnDlgAuthenticationPlugin::NewL( |
|
445 const TBool aResourceFileResponsible ) |
|
446 { |
|
447 CConnDlgAuthenticationPlugin* self = new (ELeave) |
|
448 CConnDlgAuthenticationPlugin(); |
|
449 CleanupStack::PushL( self ); |
|
450 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
451 CleanupStack::Pop(); |
|
452 |
|
453 return self; |
|
454 } |
|
455 |
|
456 |
|
457 // --------------------------------------------------------- |
|
458 // CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin() |
|
459 // --------------------------------------------------------- |
|
460 // |
|
461 CConnDlgAuthenticationPlugin::CConnDlgAuthenticationPlugin() |
|
462 : iAuthPair( TAuthenticationPair() ) |
|
463 { |
|
464 } |
|
465 |
|
466 |
|
467 // --------------------------------------------------------- |
|
468 // CConnDlgQosPlugin::TNotifierInfo CConnDlgQosPlugin::RegisterL() |
|
469 // --------------------------------------------------------- |
|
470 // |
|
471 CConnDlgQosPlugin::TNotifierInfo CConnDlgQosPlugin::RegisterL() |
|
472 { |
|
473 iInfo.iUid = KUidCConnDlgQos; |
|
474 iInfo.iPriority = ENotifierPriorityHigh; |
|
475 iInfo.iChannel = KUidCConnDlgQos; |
|
476 |
|
477 return iInfo; |
|
478 } |
|
479 |
|
480 |
|
481 // --------------------------------------------------------- |
|
482 // void CConnDlgQosPlugin::StartL |
|
483 // --------------------------------------------------------- |
|
484 // |
|
485 void CConnDlgQosPlugin::StartL( const TDesC8& /*aBuffer*/, TInt aReplySlot, |
|
486 const RMessagePtr2& aMessage ) |
|
487 { |
|
488 iReplySlot = aReplySlot; |
|
489 iMessage = aMessage; |
|
490 iCancelled = EFalse; |
|
491 |
|
492 GetReconnectL(); |
|
493 } |
|
494 |
|
495 |
|
496 // --------------------------------------------------------- |
|
497 // void CConnDlgQosPlugin::Cancel() |
|
498 // --------------------------------------------------------- |
|
499 // |
|
500 void CConnDlgQosPlugin::Cancel() |
|
501 { |
|
502 if ( !iCancelled ) |
|
503 { |
|
504 iCancelled = ETrue; |
|
505 if ( !iMessage.IsNull() ) |
|
506 { |
|
507 iMessage.Complete( KErrCancel ); |
|
508 } |
|
509 delete iDialog; |
|
510 iDialog = NULL; |
|
511 } |
|
512 } |
|
513 |
|
514 |
|
515 // --------------------------------------------------------- |
|
516 // void CConnDlgQosPlugin::GetReconnectL() |
|
517 // --------------------------------------------------------- |
|
518 // |
|
519 void CConnDlgQosPlugin::GetReconnectL() |
|
520 { |
|
521 iDialog = new (ELeave) CQosDialog( this, iBool ); |
|
522 iDialog->ExecuteLD( R_CONNDLG_QOS ); |
|
523 } |
|
524 |
|
525 |
|
526 // --------------------------------------------------------- |
|
527 // void CConnDlgQosPlugin::CompleteL( TInt aStatus ) |
|
528 // --------------------------------------------------------- |
|
529 // |
|
530 void CConnDlgQosPlugin::CompleteL( TInt aStatus ) |
|
531 { |
|
532 iCancelled = ETrue; |
|
533 if ( !iMessage.IsNull() ) |
|
534 { |
|
535 if ( aStatus == KErrNone ) |
|
536 { |
|
537 TRAP_IGNORE( iMessage.WriteL( iReplySlot, TPckg<TBool>( iBool ) ) ); |
|
538 } |
|
539 |
|
540 iMessage.Complete( aStatus ); |
|
541 } |
|
542 Cancel(); |
|
543 } |
|
544 |
|
545 |
|
546 // --------------------------------------------------------- |
|
547 // CConnDlgQosPlugin* CConnDlgQosPlugin::NewL() |
|
548 // --------------------------------------------------------- |
|
549 // |
|
550 CConnDlgQosPlugin* CConnDlgQosPlugin::NewL( |
|
551 const TBool aResourceFileResponsible ) |
|
552 { |
|
553 CConnDlgQosPlugin* self = new (ELeave) CConnDlgQosPlugin(); |
|
554 CleanupStack::PushL( self ); |
|
555 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
556 CleanupStack::Pop(); |
|
557 |
|
558 return self; |
|
559 } |
|
560 |
|
561 |
|
562 // --------------------------------------------------------- |
|
563 // CConnDlgReconnectPlugin::RegisterL() |
|
564 // --------------------------------------------------------- |
|
565 // |
|
566 CConnDlgReconnectPlugin::TNotifierInfo CConnDlgReconnectPlugin::RegisterL() |
|
567 { |
|
568 iInfo.iUid = KUidCConnDlgReconnect; |
|
569 iInfo.iPriority = ENotifierPriorityHigh; |
|
570 iInfo.iChannel = KUidCConnDlgReconnect; |
|
571 |
|
572 return iInfo; |
|
573 } |
|
574 |
|
575 |
|
576 // --------------------------------------------------------- |
|
577 // void CConnDlgReconnectPlugin::StartL |
|
578 // --------------------------------------------------------- |
|
579 // |
|
580 void CConnDlgReconnectPlugin::StartL( const TDesC8& /*aBuffer*/, |
|
581 TInt aReplySlot, |
|
582 const RMessagePtr2& aMessage ) |
|
583 { |
|
584 iReplySlot = aReplySlot; |
|
585 iMessage = aMessage; |
|
586 iCancelled = EFalse; |
|
587 |
|
588 GetReconnectL(); |
|
589 } |
|
590 |
|
591 |
|
592 // --------------------------------------------------------- |
|
593 // void CConnDlgReconnectPlugin::Cancel() |
|
594 // --------------------------------------------------------- |
|
595 // |
|
596 void CConnDlgReconnectPlugin::Cancel() |
|
597 { |
|
598 if ( !iCancelled ) |
|
599 { |
|
600 iCancelled = ETrue; |
|
601 if ( !iMessage.IsNull() ) |
|
602 { |
|
603 iMessage.Complete( KErrCancel ); |
|
604 } |
|
605 delete iDialog; |
|
606 iDialog = NULL; |
|
607 } |
|
608 } |
|
609 |
|
610 |
|
611 // --------------------------------------------------------- |
|
612 // void CConnDlgReconnectPlugin::GetReconnectL() |
|
613 // --------------------------------------------------------- |
|
614 // |
|
615 void CConnDlgReconnectPlugin::GetReconnectL() |
|
616 { |
|
617 iDialog = new (ELeave) CReconnectDialog( this, iBool ); |
|
618 iDialog->ExecuteLD( R_CONNDLG_RECONNECT ); |
|
619 } |
|
620 |
|
621 |
|
622 // --------------------------------------------------------- |
|
623 // void CConnDlgReconnectPlugin::CompleteL( TInt aStatus ) |
|
624 // --------------------------------------------------------- |
|
625 // |
|
626 void CConnDlgReconnectPlugin::CompleteL( TInt aStatus ) |
|
627 { |
|
628 iCancelled = ETrue; |
|
629 if ( !iMessage.IsNull() ) |
|
630 { |
|
631 if ( aStatus == KErrNone ) |
|
632 { |
|
633 iMessage.WriteL( iReplySlot, TPckg<TBool>( iBool ) ); |
|
634 } |
|
635 |
|
636 iMessage.Complete( aStatus ); |
|
637 } |
|
638 Cancel(); |
|
639 |
|
640 } |
|
641 |
|
642 |
|
643 // --------------------------------------------------------- |
|
644 // CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL() |
|
645 // --------------------------------------------------------- |
|
646 // |
|
647 CConnDlgReconnectPlugin* CConnDlgReconnectPlugin::NewL( |
|
648 const TBool aResourceFileResponsible ) |
|
649 { |
|
650 CConnDlgReconnectPlugin* self = new (ELeave) CConnDlgReconnectPlugin(); |
|
651 CleanupStack::PushL( self ); |
|
652 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
653 CleanupStack::Pop(); |
|
654 |
|
655 return self; |
|
656 } |
|
657 |
|
658 |
|
659 // --------------------------------------------------------- |
|
660 // CConnDlgNewIapPlugin::TNotifierInfo CConnDlgNewIapPlugin::RegisterL() |
|
661 // --------------------------------------------------------- |
|
662 // |
|
663 CConnDlgNewIapPlugin::TNotifierInfo CConnDlgNewIapPlugin::RegisterL() |
|
664 { |
|
665 iInfo.iUid = KUidCConnDlgNewIap; |
|
666 iInfo.iPriority = ENotifierPriorityHigh; |
|
667 iInfo.iChannel = KUidCConnDlgNewIap; |
|
668 |
|
669 return iInfo; |
|
670 } |
|
671 |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // void CConnDlgNewIapPlugin::StartL |
|
675 // --------------------------------------------------------- |
|
676 // |
|
677 |
|
678 void CConnDlgNewIapPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot, |
|
679 const RMessagePtr2& aMessage ) |
|
680 { |
|
681 if ( aBuffer.Length() > iPrefs.Length() ) |
|
682 { |
|
683 User::Panic( KConnDlgPluginPanic, EConnDlgIllegalRequest ); |
|
684 } |
|
685 |
|
686 iPrefs.Copy( aBuffer ); |
|
687 iReplySlot = aReplySlot; |
|
688 iMessage = aMessage; |
|
689 iCancelled = EFalse; |
|
690 |
|
691 GetNewIapL(); |
|
692 } |
|
693 |
|
694 |
|
695 // --------------------------------------------------------- |
|
696 // void CConnDlgNewIapPlugin::Cancel() |
|
697 // --------------------------------------------------------- |
|
698 // |
|
699 void CConnDlgNewIapPlugin::Cancel() |
|
700 { |
|
701 if ( !iCancelled ) |
|
702 { |
|
703 iCancelled = ETrue; |
|
704 if ( !iMessage.IsNull() ) |
|
705 { |
|
706 iMessage.Complete( KErrCancel ); |
|
707 } |
|
708 delete iDialog; |
|
709 iDialog = NULL; |
|
710 } |
|
711 } |
|
712 |
|
713 |
|
714 // --------------------------------------------------------- |
|
715 // void CConnDlgNewIapPlugin::GetNewIapL() |
|
716 // --------------------------------------------------------- |
|
717 // |
|
718 void CConnDlgNewIapPlugin::GetNewIapL() |
|
719 { |
|
720 iDialog = new (ELeave) CNewIapDialog( this, iConnect, iPrefs() ); |
|
721 iDialog->ExecuteLD( R_CONNDLG_NEW_IAP ); |
|
722 } |
|
723 |
|
724 |
|
725 // --------------------------------------------------------- |
|
726 // void CConnDlgNewIapPlugin::CompleteL( TInt aStatus ) |
|
727 // --------------------------------------------------------- |
|
728 // |
|
729 void CConnDlgNewIapPlugin::CompleteL( TInt aStatus ) |
|
730 { |
|
731 iCancelled = ETrue; |
|
732 if ( !iMessage.IsNull() ) |
|
733 { |
|
734 if ( aStatus == KErrNone ) |
|
735 { |
|
736 iMessage.WriteL( iReplySlot, TPckg<TBool>( iConnect ) ); |
|
737 } |
|
738 |
|
739 iMessage.Complete( aStatus ); |
|
740 } |
|
741 Cancel(); |
|
742 } |
|
743 |
|
744 |
|
745 // --------------------------------------------------------- |
|
746 // CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL() |
|
747 // --------------------------------------------------------- |
|
748 // |
|
749 CConnDlgNewIapPlugin* CConnDlgNewIapPlugin::NewL( |
|
750 const TBool aResourceFileResponsible ) |
|
751 { |
|
752 CConnDlgNewIapPlugin* self = new (ELeave) CConnDlgNewIapPlugin(); |
|
753 CleanupStack::PushL( self ); |
|
754 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
755 CleanupStack::Pop(); |
|
756 |
|
757 return self; |
|
758 } |
|
759 |
|
760 |
|
761 // --------------------------------------------------------- |
|
762 // CConnDlgSelectConnectionPlugin::TNotifierInfo |
|
763 // CConnDlgSelectConnectionPlugin::RegisterL() |
|
764 // --------------------------------------------------------- |
|
765 // |
|
766 CConnDlgSelectConnectionPlugin::TNotifierInfo |
|
767 CConnDlgSelectConnectionPlugin::RegisterL() |
|
768 { |
|
769 iInfo.iUid = KUidCConnDlgSelectConn; |
|
770 iInfo.iPriority = ENotifierPriorityHigh; |
|
771 iInfo.iChannel = KUidCConnDlgSelectConn; |
|
772 |
|
773 return iInfo; |
|
774 } |
|
775 |
|
776 |
|
777 // --------------------------------------------------------- |
|
778 // void CConnDlgSelectConnectionPlugin::StartL |
|
779 // --------------------------------------------------------- |
|
780 // |
|
781 |
|
782 void CConnDlgSelectConnectionPlugin::StartL( const TDesC8& aBuffer, |
|
783 TInt aReplySlot, |
|
784 const RMessagePtr2& aMessage ) |
|
785 { |
|
786 if ( iActivePlugin ) |
|
787 { |
|
788 aMessage.Complete( KErrServerBusy ); |
|
789 return; |
|
790 } |
|
791 |
|
792 iPrefs.Copy( ( TPtrC8 ) aBuffer ); |
|
793 |
|
794 iCancelled = ETrue; // This method could leave before displaying the dialog. |
|
795 iReplySlot = aReplySlot; |
|
796 iMessage = aMessage; |
|
797 |
|
798 __ASSERT_DEBUG( !iActivePlugin, |
|
799 User::Panic( KErrActiveObjectNull, KErrNone ) ); |
|
800 |
|
801 iElementID = iPrefs().iRank; |
|
802 iActivePlugin = CActiveSelectConnectionPlugin::NewL( this, |
|
803 iElementID, |
|
804 iPrefs().iBearerSet ); |
|
805 // Check if there is a suitable active connection |
|
806 TInt snap( 0 ); |
|
807 TInt iap( 0 ); |
|
808 TInt bearer( ECommDbBearerWLAN ); // User conn. is always WLAN in 9.1 |
|
809 |
|
810 // Is there active User connection |
|
811 TInt err = GetUserConnection( iap, snap ); |
|
812 |
|
813 if ( ( err != KErrNone ) || ( iap == 0 && snap == 0 ) ) |
|
814 { |
|
815 // Is there any active connection |
|
816 err = GetActiveConnection( iap, snap, bearer ); |
|
817 } |
|
818 |
|
819 if ( ( err == KErrNone ) && |
|
820 ( iap != 0 || snap != 0 ) && |
|
821 ( iPrefs().iBearerSet & bearer ) && |
|
822 ( iPrefs().iDirection == 0 ) ) // JavaVM sets iDirection to "1" |
|
823 { |
|
824 // a suitable connection is already active |
|
825 SetElementIDL( iap, snap ); |
|
826 CompleteL( KErrNone ); |
|
827 } |
|
828 else |
|
829 { |
|
830 // display dialog |
|
831 iActivePlugin->ShowSelectConnectionL(); |
|
832 iCancelled = EFalse; // Dialog is now up and running |
|
833 } |
|
834 } |
|
835 |
|
836 |
|
837 |
|
838 // --------------------------------------------------------- |
|
839 // void CConnDlgSelectConnectionPlugin::Cancel() |
|
840 // --------------------------------------------------------- |
|
841 // |
|
842 void CConnDlgSelectConnectionPlugin::Cancel() |
|
843 { |
|
844 CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::Cancel" ); |
|
845 |
|
846 delete iActivePlugin; |
|
847 CLOG_WRITE( "iActivePlugin deleted" ); |
|
848 iActivePlugin = NULL; |
|
849 CLOG_WRITE( "iActivePlugin NULLed" ); |
|
850 |
|
851 if ( !iCancelled ) |
|
852 { |
|
853 CLOG_WRITE( "iCancelled == EFalse" ); |
|
854 iCancelled = ETrue; |
|
855 if ( !iMessage.IsNull() ) |
|
856 { |
|
857 CLOG_WRITE( "Going to Complete iMessage (KErrCancel)" ); |
|
858 iMessage.Complete( KErrCancel ); |
|
859 CLOG_WRITE( "iMessage completed" ); |
|
860 } |
|
861 } |
|
862 |
|
863 CLOG_LEAVEFN( "CConnDlgSelectConnectionPlugin::Cancel" ); |
|
864 } |
|
865 |
|
866 |
|
867 // --------------------------------------------------------- |
|
868 // void CConnDlgSelectConnectionPlugin::CompleteL( TInt aStatus ) |
|
869 // --------------------------------------------------------- |
|
870 // |
|
871 void CConnDlgSelectConnectionPlugin::CompleteL( TInt aStatus ) |
|
872 { |
|
873 CLOG_ENTERFN( "CConnDlgSelectConnectionPlugin::CompleteL" ); |
|
874 |
|
875 iCancelled = ETrue; |
|
876 if ( !iMessage.IsNull() ) |
|
877 { |
|
878 if ( aStatus == KErrNone ) |
|
879 { |
|
880 iMessage.WriteL( iReplySlot, TPckg<TUint32>( iElementID ) ); |
|
881 } |
|
882 |
|
883 CLOG_WRITEF( _L( "CConnDlgSelectConnectionPlugin::CompleteL iElementID : %d" ), iElementID ); |
|
884 |
|
885 iMessage.Complete( aStatus ); |
|
886 } |
|
887 Cancel(); |
|
888 |
|
889 CLOG_LEAVEFN( "CConnDlgSelectConnectionPlugin::CompleteL" ); |
|
890 } |
|
891 |
|
892 |
|
893 // --------------------------------------------------------- |
|
894 // CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL() |
|
895 // --------------------------------------------------------- |
|
896 // |
|
897 CConnDlgSelectConnectionPlugin* CConnDlgSelectConnectionPlugin::NewL( |
|
898 const TBool aResourceFileResponsible ) |
|
899 { |
|
900 CConnDlgSelectConnectionPlugin* self = |
|
901 new (ELeave) CConnDlgSelectConnectionPlugin(); |
|
902 CleanupStack::PushL( self ); |
|
903 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
904 CleanupStack::Pop(); |
|
905 |
|
906 return self; |
|
907 } |
|
908 |
|
909 |
|
910 // --------------------------------------------------------- |
|
911 // CConnDlgSelectConnectionPlugin::SetSelectedIDsL |
|
912 // --------------------------------------------------------- |
|
913 // |
|
914 void CConnDlgSelectConnectionPlugin::SetElementIDL( TUint32 aIAPId, |
|
915 TUint32 aDestinationId ) |
|
916 { |
|
917 iElementID = iActivePlugin->GetElementIDL( aIAPId, aDestinationId ); |
|
918 } |
|
919 |
|
920 |
|
921 // --------------------------------------------------------- |
|
922 // CConnDlgSelectConnectionPlugin::GetUserConnection |
|
923 // --------------------------------------------------------- |
|
924 // |
|
925 TInt CConnDlgSelectConnectionPlugin::GetUserConnection( TInt& aIapId, |
|
926 TInt& aSnapId ) |
|
927 { |
|
928 aIapId = 0; |
|
929 aSnapId = 0; |
|
930 |
|
931 TInt err = RProperty::Get( KMPMUserConnectionCategory, |
|
932 KMPMPSKeyUserConnectionSnap, |
|
933 aSnapId ); |
|
934 |
|
935 if ( err != KErrNone || aSnapId == 0 ) |
|
936 { |
|
937 err = RProperty::Get( KMPMUserConnectionCategory, |
|
938 KMPMPSKeyUserConnectionIap, |
|
939 aIapId ); |
|
940 } |
|
941 |
|
942 CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionSnap : %d" ), aSnapId ); |
|
943 CLOG_WRITEF( _L( "KMPMPSKeyUserConnectionIap : %d" ), aIapId ); |
|
944 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
945 |
|
946 return err; |
|
947 } |
|
948 |
|
949 |
|
950 // --------------------------------------------------------- |
|
951 // CConnDlgSelectConnectionPlugin::GetActiveConnection |
|
952 // --------------------------------------------------------- |
|
953 // |
|
954 TInt CConnDlgSelectConnectionPlugin::GetActiveConnection( TInt& aIapId, |
|
955 TInt& aSnapId, |
|
956 TInt& aBearer ) |
|
957 { |
|
958 aIapId = 0; |
|
959 aSnapId = 0; |
|
960 aBearer = 0; |
|
961 |
|
962 TInt err = RProperty::Get( KMPMActiveConnectionCategory, |
|
963 KMPMPSKeyActiveConnectionSnap, |
|
964 aSnapId ); |
|
965 |
|
966 if ( err != KErrNone || aSnapId == 0 ) |
|
967 { |
|
968 err = RProperty::Get( KMPMActiveConnectionCategory, |
|
969 KMPMPSKeyActiveConnectionIap, |
|
970 aIapId ); |
|
971 } |
|
972 |
|
973 CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionSnap : %d" ), aSnapId ); |
|
974 CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionIap : %d" ), aIapId ); |
|
975 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
976 |
|
977 if ( err == KErrNone ) |
|
978 { |
|
979 err = RProperty::Get( KMPMActiveConnectionCategory, |
|
980 KMPMPSKeyActiveConnectionBearer, |
|
981 aBearer ); |
|
982 } |
|
983 |
|
984 CLOG_WRITEF( _L( "KMPMPSKeyActiveConnectionBearer : %d" ), aBearer ); |
|
985 CLOG_WRITEF( _L( "iPrefs().iBearerSet : %d" ), iPrefs().iBearerSet ); |
|
986 CLOG_WRITEF( _L( "err : %d" ), err ); |
|
987 |
|
988 return err; |
|
989 } |
|
990 |
|
991 // End of File |