|
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 |
|
19 // INCLUDE FILES |
|
20 #include "ActiveSelectConnectionPlugin.h" |
|
21 #include "SelectConnectionDialog.h" |
|
22 #include "ConnectionDialogsLogger.h" |
|
23 #include "ConnectionInfo.h" |
|
24 #include "ConnectionInfoArray.h" |
|
25 #include "sortsnaputils.h" |
|
26 #include "cdbcols.h" |
|
27 |
|
28 #include <featmgr.h> |
|
29 #include <StringLoader.h> |
|
30 #include <AknIconArray.h> |
|
31 #include <AknsUtils.h> |
|
32 #include <AknIconUtils.h> |
|
33 #include <data_caging_path_literals.hrh> |
|
34 |
|
35 #include <cmdestinationext.h> |
|
36 #include <cmconnectionmethoddef.h> |
|
37 #include <cmpluginwlandef.h> |
|
38 |
|
39 #include <cmmanager.mbg> |
|
40 #include <CConnDlgPlugin.rsg> |
|
41 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
42 #include <commsdat.h> |
|
43 #else |
|
44 #include <commsdat.h> |
|
45 #include <commsdat_partner.h> |
|
46 #endif |
|
47 |
|
48 #include <wlancontainer.h> |
|
49 #include <metadatabase.h> |
|
50 |
|
51 // CONSTANTS |
|
52 |
|
53 // Category for all panics in this module |
|
54 _LIT( KASCPCategory, "Select Connection Plugin" ); |
|
55 |
|
56 LOCAL_D const TInt KIconsGranularity = 4; |
|
57 LOCAL_D const TInt KArrayGranularity = 4; |
|
58 LOCAL_D const TInt KMaxEntryLength = CommsDat::KMaxTextLength*2 + 20; |
|
59 /** |
|
60 * For iPeriodic Timer, 60 seconds |
|
61 */ |
|
62 LOCAL_C const TInt KTickDefaultInterval = 60000000; |
|
63 LOCAL_C const TInt KMicrosecondsToSecondsMultiplier = 1000000; |
|
64 |
|
65 // background scan automatic scanning value |
|
66 static const TUint KWlanBgScanIntervalAuto = 0xffffffff; |
|
67 |
|
68 using namespace CMManager; |
|
69 |
|
70 |
|
71 /////////////////////////////////////////////////////////////////////////////// |
|
72 |
|
73 // --------------------------------------------------------- |
|
74 // CActiveSelectConnectionPlugin::CActiveSelectConnectionPlugin() |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CActiveSelectConnectionPlugin::CActiveSelectConnectionPlugin( |
|
78 MEikSrvNotifierBase2* aPlugin, |
|
79 const TUint32 aElementId, |
|
80 TUint32 aBearerSet ) |
|
81 : iBearerSet( aBearerSet ), |
|
82 iReqBearerSet( aBearerSet ), |
|
83 iElementId( aElementId ), |
|
84 iPlugin( aPlugin ), |
|
85 iDialogConn( NULL ), |
|
86 iIsWLANFeatureSupported( EFalse ), |
|
87 iRefreshInterval( KTickDefaultInterval ), |
|
88 iHighlightedItem( -1 ), |
|
89 iDefaultDestId( 0 ), |
|
90 iDefaultCMId( 0 ) |
|
91 { |
|
92 } |
|
93 |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CActiveSelectConnectionPlugin* CActiveSelectConnectionPlugin::NewL() |
|
97 // --------------------------------------------------------- |
|
98 // |
|
99 CActiveSelectConnectionPlugin* CActiveSelectConnectionPlugin::NewL( |
|
100 MEikSrvNotifierBase2* aPlugin, |
|
101 const TUint32 aElementId, |
|
102 TUint32 aBearerSet ) |
|
103 { |
|
104 CLOG_ENTERFN( "CActiveSelectConnectionPlugin::NewL " ); |
|
105 |
|
106 CActiveSelectConnectionPlugin* self = new ( ELeave ) |
|
107 CActiveSelectConnectionPlugin( aPlugin, aElementId, |
|
108 aBearerSet ); |
|
109 CleanupStack::PushL( self ); |
|
110 self->ConstructL(); |
|
111 CleanupStack::Pop( self ); |
|
112 |
|
113 CLOG_LEAVEFN( "CActiveSelectConnectionPlugin::NewL " ); |
|
114 |
|
115 return self; |
|
116 } |
|
117 |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // CActiveSelectConnectionPlugin::ConstructL() |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 void CActiveSelectConnectionPlugin::ConstructL() |
|
124 { |
|
125 CLOG_ENTERFN( "CActiveSelectConnectionPlugin::ConstructL " ); |
|
126 |
|
127 CActiveBase::ConstructL(); |
|
128 |
|
129 FeatureManager::InitializeLibL(); |
|
130 |
|
131 iIsWLANFeatureSupported = FeatureManager::FeatureSupported( |
|
132 KFeatureIdProtocolWlan ); |
|
133 |
|
134 FeatureManager::UnInitializeLib(); |
|
135 |
|
136 iBearerSet |= ECommDbBearerVirtual; // To get also VPN APs |
|
137 |
|
138 #ifdef __WINS__ |
|
139 iBearerSet |= ECommDbBearerLAN; // To add Ethernet AP |
|
140 #endif // __WINS__ |
|
141 |
|
142 if ( iIsWLANFeatureSupported ) |
|
143 { |
|
144 CLOG_WRITE( "WLAN Supported!" ); |
|
145 iBearerSet |= ECommDbBearerWLAN; // To add WLan AP |
|
146 iRefreshInterval = GetRefreshIntervalL(); |
|
147 } |
|
148 |
|
149 |
|
150 |
|
151 iItems = new( ELeave ) CConnectionInfoArray(); |
|
152 iIcons = new( ELeave ) CAknIconArray( KIconsGranularity ); |
|
153 |
|
154 iCmManagerExt.OpenL(); |
|
155 |
|
156 TInt ret = iMPM.LaunchServer(); |
|
157 if ( ret != KErrAlreadyExists ) |
|
158 { |
|
159 User::LeaveIfError( ret ); |
|
160 } |
|
161 CLOG_LEAVEFN( "CActiveSelectConnectionPlugin::ConstructL " ); |
|
162 } |
|
163 |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CActiveSelectConnectionPlugin::~CActiveSelectConnectionPlugin() |
|
167 // --------------------------------------------------------- |
|
168 // |
|
169 CActiveSelectConnectionPlugin::~CActiveSelectConnectionPlugin() |
|
170 { |
|
171 CLOG_ENTERFN( "~CActiveSelectConnectionPlugin" ); |
|
172 Cancel(); |
|
173 |
|
174 if ( iItems ) |
|
175 { |
|
176 iItems->ResetAndDestroy(); |
|
177 } |
|
178 delete iItems; |
|
179 iItems = NULL; |
|
180 |
|
181 iCmManagerExt.Close(); |
|
182 iMPM.Close(); |
|
183 |
|
184 CLOG_LEAVEFN( "~CActiveSelectConnectionPlugin" ); |
|
185 } |
|
186 |
|
187 |
|
188 // --------------------------------------------------------- |
|
189 // CActiveSelectConnectionPlugin::Cancel() |
|
190 // --------------------------------------------------------- |
|
191 // |
|
192 void CActiveSelectConnectionPlugin::Cancel() |
|
193 { |
|
194 StopTimer(); |
|
195 CActive::Cancel(); |
|
196 |
|
197 if( iDialogConn && !( iDialogConn->GetOkToExit() ) ) |
|
198 { |
|
199 CLOG_WRITEF( _L( "iDialogConn->GetOkToExit() : %b" ), iDialogConn->GetOkToExit() ); |
|
200 delete iDialogConn; |
|
201 iDialogConn = NULL; |
|
202 } |
|
203 } |
|
204 |
|
205 |
|
206 // --------------------------------------------------------- |
|
207 // CActiveSelectConnectionPlugin::DoCancel() |
|
208 // --------------------------------------------------------- |
|
209 // |
|
210 void CActiveSelectConnectionPlugin::DoCancel() |
|
211 { |
|
212 } |
|
213 |
|
214 |
|
215 // --------------------------------------------------------- |
|
216 // CActiveSelectConnectionPlugin::RunL() |
|
217 // --------------------------------------------------------- |
|
218 // |
|
219 void CActiveSelectConnectionPlugin::RunL() |
|
220 { |
|
221 CLOG_ENTERFN( "CActiveSelectConnectionPlugin::RunL " ); |
|
222 |
|
223 if( iStatus == KErrNone ) |
|
224 { |
|
225 BuildConnectionListL(); |
|
226 iDialogConn->RefreshDialogL( iItems, iIcons, ETrue, iHighlightedItem ); |
|
227 } |
|
228 |
|
229 CLOG_LEAVEFN( "CActiveSelectConnectionPlugin::RunL " ); |
|
230 } |
|
231 |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // CActiveSelectConnectionPlugin::ShowSelectConnectionL() |
|
235 // --------------------------------------------------------- |
|
236 // |
|
237 void CActiveSelectConnectionPlugin::ShowSelectConnectionL() |
|
238 { |
|
239 CLOG_ENTERFN( "CActiveSelectConnectionPlugin::ShowSelectConnectionL" ); |
|
240 |
|
241 BuildConnectionListL(); |
|
242 |
|
243 iDialogConn = CSelectConnectionDialog::NewL( iPlugin, iRefreshInterval, |
|
244 iBearerSet, |
|
245 iIsWLANFeatureSupported, |
|
246 iDefaultCMId ); |
|
247 |
|
248 iDialogConn->PrepareAndRunLD( iItems, iIcons, EFalse, iHighlightedItem ); |
|
249 |
|
250 if( iRefreshInterval ) |
|
251 { |
|
252 StartTimerL( iRefreshInterval ); |
|
253 } |
|
254 |
|
255 CLOG_LEAVEFN( "CActiveSelectConnectionPlugin::ShowSelectConnectionL" ); |
|
256 } |
|
257 |
|
258 |
|
259 // --------------------------------------------------------- |
|
260 // CActiveSelectConnectionPlugin::BuildConnectionListL() |
|
261 // --------------------------------------------------------- |
|
262 // |
|
263 void CActiveSelectConnectionPlugin::BuildConnectionListL() |
|
264 { |
|
265 CLOG_ENTERFN( "CActiveSelectConnectionPlugin::BuildConnectionListL " ); |
|
266 |
|
267 // iItems and iIcons are allocated at construction and deallocated at |
|
268 // destruction. Unless memory allocation has failed, they cannot be NULL. |
|
269 __ASSERT_ALWAYS( iItems, User::Panic( KASCPCategory, KErrGeneral ) ); |
|
270 __ASSERT_ALWAYS( iIcons, User::Panic( KASCPCategory, KErrGeneral ) ); |
|
271 |
|
272 iItems->ResetAndDestroy(); |
|
273 iIcons->ResetAndDestroy(); |
|
274 |
|
275 _LIT( KDriveZ, "z:" ); // ROM folder |
|
276 // Name of the MBM file containing icons |
|
277 _LIT( KManagerIconFilename, "cmmanager.mbm" ); |
|
278 |
|
279 TFileName iconsFileName; |
|
280 |
|
281 iconsFileName.Append( KDriveZ ); |
|
282 iconsFileName.Append( KDC_APP_BITMAP_DIR ); |
|
283 iconsFileName.Append( KManagerIconFilename ); |
|
284 |
|
285 // iIcons->AppendL( AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), |
|
286 // KAknsIIDQgnIndiCbHotAdd, |
|
287 // iconsFileName, |
|
288 // EMbmCmmanagerQgn_indi_cb_hot_add, |
|
289 // EMbmCmmanagerQgn_indi_cb_hot_add_mask ) ); |
|
290 |
|
291 // Create color icon for marking the default connection |
|
292 // |
|
293 CFbsBitmap* bitmap = NULL; |
|
294 CFbsBitmap* mask = NULL; |
|
295 CGulIcon* icon = CGulIcon::NewLC(); |
|
296 |
|
297 AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(), |
|
298 KAknsIIDQgnIndiCbHotAdd, |
|
299 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13, |
|
300 bitmap, |
|
301 mask, |
|
302 iconsFileName, |
|
303 EMbmCmmanagerQgn_indi_cb_hot_add, |
|
304 EMbmCmmanagerQgn_indi_cb_hot_add_mask, |
|
305 KRgbBlack ); |
|
306 |
|
307 icon->SetBitmap( bitmap ); |
|
308 icon->SetMask( mask ); |
|
309 iIcons->AppendL( icon ); |
|
310 |
|
311 CleanupStack::Pop( icon ); |
|
312 |
|
313 TCmDefConnValue defaultConnSetting; |
|
314 |
|
315 iCmManagerExt.ReadDefConnL( defaultConnSetting ); |
|
316 if ( defaultConnSetting.iType == ECmDefConnDestination ) |
|
317 { |
|
318 iDefaultDestId = defaultConnSetting.iId; |
|
319 } |
|
320 else if ( defaultConnSetting.iType == ECmDefConnConnectionMethod ) |
|
321 { |
|
322 iDefaultCMId = defaultConnSetting.iId; |
|
323 } |
|
324 |
|
325 if ( iIsWLANFeatureSupported && (iReqBearerSet & ECommDbBearerWLAN) ) |
|
326 { |
|
327 AddSearchForWLanItemL(); |
|
328 } |
|
329 |
|
330 AddDestinationItemsL(); |
|
331 |
|
332 CLOG_WRITEF( _L( "iItems count: %d" ), iItems->Count() ); |
|
333 CLOG_LEAVEFN( "CActiveSelectConnectionPlugin::BuildConnectionListL " ); |
|
334 } |
|
335 |
|
336 |
|
337 // --------------------------------------------------------- |
|
338 // CActiveSelectConnectionPlugin::AddSearchForWLanItemL |
|
339 // --------------------------------------------------------- |
|
340 // |
|
341 void CActiveSelectConnectionPlugin::AddSearchForWLanItemL() |
|
342 { |
|
343 TUint32 easyWlanId = iCmManagerExt.EasyWlanIdL(); |
|
344 if ( easyWlanId ) |
|
345 { |
|
346 CLOG_WRITEF( _L( "easyWlanId %d" ), easyWlanId ); |
|
347 |
|
348 RCmConnectionMethodExt cmConnMethodExt; |
|
349 TRAPD( err, cmConnMethodExt = iCmManagerExt.ConnectionMethodL( |
|
350 easyWlanId ) ); |
|
351 if ( err == KErrNone ) |
|
352 { |
|
353 CleanupClosePushL( cmConnMethodExt ); |
|
354 |
|
355 CGulIcon* wlanIcon = ( CGulIcon* ) |
|
356 cmConnMethodExt.GetIntAttributeL( ECmBearerIcon ); |
|
357 CleanupStack::PopAndDestroy(); // cmConnMethodExt |
|
358 |
|
359 if ( wlanIcon ) |
|
360 { |
|
361 CleanupStack::PushL( wlanIcon ); |
|
362 iIcons->AppendL( wlanIcon ); |
|
363 |
|
364 // icon array took over ownership |
|
365 CleanupStack::Pop( wlanIcon ); |
|
366 |
|
367 // +1 because it "Zero terminates" the string |
|
368 TBuf<CommsDat::KMaxTextLength+1> nameSearch; |
|
369 _LIT( KIconIdNameEmpty, "%d\t%s\t" ); |
|
370 |
|
371 HBufC *msg = StringLoader::LoadL( R_WLAN_EASY_WLAN ); |
|
372 nameSearch = *msg; |
|
373 nameSearch.ZeroTerminate(); |
|
374 delete msg; |
|
375 |
|
376 TBuf<KMaxEntryLength> temp; |
|
377 temp.FillZ( KMaxEntryLength ); |
|
378 temp.Format( KIconIdNameEmpty, iIcons->Count()-1, |
|
379 nameSearch.Ptr() ); |
|
380 |
|
381 CConnectionInfo* conIn = CConnectionInfo::NewL( easyWlanId, |
|
382 0, temp ); |
|
383 CleanupStack::PushL( conIn ); |
|
384 iItems->AppendL( conIn ); |
|
385 CleanupStack::Pop( conIn ); |
|
386 iHighlightedItem = 0; |
|
387 } |
|
388 } |
|
389 } |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------- |
|
393 // CActiveSelectConnectionPlugin::AddDestinationItemsL |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 void CActiveSelectConnectionPlugin::AddDestinationItemsL() |
|
397 { |
|
398 /* TInt errConnect = iMPM.Connect(); |
|
399 CLOG_WRITEF( _L( "errConnect = %d" ), errConnect ); |
|
400 if ( errConnect == KErrNone ) |
|
401 {*/ |
|
402 TSortSnapUtils sortSnapUtils( iMPM ); |
|
403 RArray<TUint32> destIdArray( KArrayGranularity ); |
|
404 TRAPD( err, sortSnapUtils.GetDestIdArrayL( iCmManagerExt, destIdArray ) ); |
|
405 //TRAPD( err, iCmManagerExt.AllDestinationsL( destIdArray ) ); |
|
406 // Append the destinations to the list |
|
407 CLOG_WRITEF( _L( "GetDestIdArrayL returned with %d" ), err ); |
|
408 if ( err == KErrNone ) |
|
409 { |
|
410 CleanupClosePushL( destIdArray ); |
|
411 |
|
412 CLOG_WRITEF( _L( "destIdArray.Count() = %d" ), destIdArray.Count() ); |
|
413 for ( TInt i = 0; i < destIdArray.Count(); i++ ) |
|
414 { |
|
415 RCmDestinationExt cmDestExt = iCmManagerExt.DestinationL( |
|
416 destIdArray[i] ); |
|
417 CleanupClosePushL( cmDestExt ); |
|
418 if ( /*cmDestExt.ElementId() != iElementId &&*/ |
|
419 !cmDestExt.MetadataL( ESnapMetadataHiddenAgent ) ) |
|
420 { |
|
421 CLOG_WRITEF( _L( "Destination id %d, Total number of methods %d" ), |
|
422 destIdArray[i], cmDestExt.ConnectionMethodCount() ); |
|
423 |
|
424 #ifdef _DEBUG |
|
425 for ( TInt j = 0; |
|
426 j < cmDestExt.ConnectionMethodCount(); j++ ) |
|
427 { |
|
428 RCmConnectionMethodExt cmConnMethodExt; |
|
429 TRAP( err, cmConnMethodExt = |
|
430 cmDestExt.ConnectionMethodL( j ) ); |
|
431 if ( err == KErrNone ) |
|
432 { |
|
433 CleanupClosePushL( cmConnMethodExt ); |
|
434 HBufC* bufMethod = |
|
435 cmConnMethodExt.GetStringAttributeL( ECmName ); |
|
436 CleanupStack::PushL( bufMethod ); |
|
437 TBuf<CommsDat::KMaxTextLength+1> nameMethod; |
|
438 nameMethod = *bufMethod; |
|
439 nameMethod.ZeroTerminate(); |
|
440 |
|
441 /*CLOG_WRITEF( _L( "ConnMethod id %d, Method name %s" ), |
|
442 cmConnMethodExt.GetIntAttributeL( ECmIapId ), |
|
443 nameMethod.Ptr() );*/ |
|
444 |
|
445 CleanupStack::PopAndDestroy( bufMethod ); |
|
446 CleanupStack::PopAndDestroy(); // cmConnMethodExt |
|
447 } |
|
448 } |
|
449 #endif |
|
450 |
|
451 AddDestinationItemL( cmDestExt, destIdArray[i], i == 0, |
|
452 destIdArray[i] == iDefaultDestId, |
|
453 sortSnapUtils ); |
|
454 } |
|
455 CleanupStack::PopAndDestroy(); // cmDestExt |
|
456 } |
|
457 CleanupStack::PopAndDestroy(); // destIdArray |
|
458 } |
|
459 AddUncategorizedItemL( sortSnapUtils ); |
|
460 /* }*/ |
|
461 } |
|
462 |
|
463 |
|
464 // --------------------------------------------------------- |
|
465 // CActiveSelectConnectionPlugin::AddDestinationItemL |
|
466 // --------------------------------------------------------- |
|
467 // |
|
468 void CActiveSelectConnectionPlugin::AddDestinationItemL( |
|
469 RCmDestinationExt aDestination, |
|
470 TUint32 aDestId, |
|
471 TBool aFirstItem, |
|
472 TBool aDefaultDest, |
|
473 TSortSnapUtils& aSortSnapUtils ) |
|
474 { |
|
475 TMpmSnapBuffer list; |
|
476 |
|
477 TInt errMPM = aSortSnapUtils.GetSortSnapData( aDestId, list ); |
|
478 CLOG_WRITEF( _L( "errMPM = %d. list.Count() = %d" ), errMPM, list.Count() ); |
|
479 |
|
480 if ( errMPM == KErrNone ) |
|
481 { |
|
482 for ( TInt numCM = 0; numCM < list.Count(); numCM++ ) |
|
483 { |
|
484 RCmConnectionMethodExt cmConnMethodExt; |
|
485 TRAPD( err, cmConnMethodExt = iCmManagerExt.ConnectionMethodL( |
|
486 list.iIapId[numCM] ) ); |
|
487 |
|
488 CLOG_WRITEF( _L( "Trapped err = %d" ), err ); |
|
489 |
|
490 if ( err == KErrNone ) |
|
491 { |
|
492 CleanupClosePushL( cmConnMethodExt ); |
|
493 if ( iBearerSet & cmConnMethodExt.GetIntAttributeL( |
|
494 ECmCommsDBBearerType ) ) |
|
495 { |
|
496 HBufC* bufBest = cmConnMethodExt.GetStringAttributeL( |
|
497 ECmName ); |
|
498 |
|
499 CleanupStack::PopAndDestroy(); // cmConnMethodExt |
|
500 CleanupStack::PushL( bufBest ); |
|
501 |
|
502 _LIT( KIconIdNameBest, "%d\t%s\t\"%s\"" ); |
|
503 _LIT( KIconIdNameBestDefaultConn, "%d\t%s\t\"%s\"\t0" ); |
|
504 |
|
505 TBuf<CommsDat::KMaxTextLength+1> nameBest; |
|
506 nameBest = *bufBest; |
|
507 nameBest.ZeroTerminate(); |
|
508 CleanupStack::PopAndDestroy( bufBest ); |
|
509 |
|
510 TBuf<CommsDat::KMaxTextLength+1> nameDest; |
|
511 HBufC* name = aDestination.NameLC(); |
|
512 nameDest = *name; |
|
513 nameDest.ZeroTerminate(); |
|
514 CleanupStack::PopAndDestroy( name ); |
|
515 |
|
516 CGulIcon* destIcon = aDestination.IconL(); |
|
517 if ( destIcon ) |
|
518 { |
|
519 CleanupStack::PushL( destIcon ); |
|
520 iIcons->AppendL( destIcon ); |
|
521 |
|
522 // icon array took over ownership |
|
523 CleanupStack::Pop( destIcon ); |
|
524 |
|
525 TBuf<KMaxEntryLength> temp; |
|
526 temp.FillZ( KMaxEntryLength ); |
|
527 if ( aDefaultDest ) |
|
528 { |
|
529 temp.Format( KIconIdNameBestDefaultConn, |
|
530 iIcons->Count()-1, |
|
531 nameDest.Ptr(), nameBest.Ptr() ); |
|
532 } |
|
533 else |
|
534 { |
|
535 temp.Format( KIconIdNameBest, |
|
536 iIcons->Count()-1, |
|
537 nameDest.Ptr(), nameBest.Ptr() ); |
|
538 } |
|
539 |
|
540 CConnectionInfo* conIn = |
|
541 CConnectionInfo::NewL( 0, aDestId, temp ); |
|
542 CleanupStack::PushL( conIn ); |
|
543 iItems->AppendL( conIn ); |
|
544 CleanupStack::Pop( conIn ); |
|
545 |
|
546 if ( aFirstItem || |
|
547 aDestination.MetadataL( ESnapMetadataHighlight ) ) |
|
548 { // It sets the highlight to the |
|
549 // first Destination (Internet), |
|
550 // but if it finds another with |
|
551 // the bit set, then it changes |
|
552 iHighlightedItem = iItems->Count()-1; |
|
553 } |
|
554 } |
|
555 |
|
556 numCM = list.Count(); // break; |
|
557 } |
|
558 else |
|
559 { |
|
560 CleanupStack::PopAndDestroy(); // cmConnMethodExt |
|
561 } |
|
562 } |
|
563 } |
|
564 } |
|
565 } |
|
566 |
|
567 |
|
568 // --------------------------------------------------------- |
|
569 // CActiveSelectConnectionPlugin::AddUncategorizedItemL |
|
570 // --------------------------------------------------------- |
|
571 // |
|
572 void CActiveSelectConnectionPlugin::AddUncategorizedItemL(TSortSnapUtils& aSortSnapUtils ) |
|
573 { |
|
574 TMpmSnapBuffer list; |
|
575 |
|
576 TInt errMPM = aSortSnapUtils.GetSortSnapData( 0, list ); |
|
577 CLOG_WRITEF( _L( "Uncategorized: errMPM = %d. list.Count() = %d" ), errMPM, list.Count() ); |
|
578 |
|
579 if ( errMPM == KErrNone ) |
|
580 { |
|
581 TUint numOfUncatToBeListed = 0; |
|
582 |
|
583 for ( TInt numCM = 0; numCM < list.Count(); numCM++ ) |
|
584 { |
|
585 RCmConnectionMethodExt cmConnMethodExt; |
|
586 TRAPD( err, cmConnMethodExt = iCmManagerExt.ConnectionMethodL( |
|
587 list.iIapId[numCM] ) ); |
|
588 if ( err == KErrNone ) |
|
589 { |
|
590 CleanupClosePushL( cmConnMethodExt ); |
|
591 if ( iBearerSet & cmConnMethodExt.GetIntAttributeL( |
|
592 ECmCommsDBBearerType ) ) |
|
593 { |
|
594 numOfUncatToBeListed++; |
|
595 } |
|
596 CleanupStack::PopAndDestroy(); // cmConnMethodExt |
|
597 } |
|
598 } |
|
599 |
|
600 if ( ( iBearerSet & ECommDbBearerWLAN ) && iIsWLANFeatureSupported ) |
|
601 { |
|
602 numOfUncatToBeListed += CountAdhocWlanIapsL(); |
|
603 } |
|
604 |
|
605 if ( numOfUncatToBeListed > 0 ) |
|
606 { |
|
607 CGulIcon* uncatIcon = |
|
608 ( CGulIcon* )iCmManagerExt.UncategorizedIconL(); |
|
609 if ( uncatIcon ) |
|
610 { |
|
611 CleanupStack::PushL( uncatIcon ); |
|
612 iIcons->AppendL( uncatIcon ); |
|
613 CleanupStack::Pop( uncatIcon ); // icon array took over ownership |
|
614 |
|
615 // +1 because it "Zero terminates" the string |
|
616 TBuf<CommsDat::KMaxTextLength+1> nameUncat; |
|
617 TBuf<CommsDat::KMaxTextLength+1> numUncat; |
|
618 |
|
619 HBufC *bufUncat = StringLoader::LoadL( R_LIST_UNCATEGORIZED ); |
|
620 nameUncat = *bufUncat; |
|
621 nameUncat.ZeroTerminate(); |
|
622 delete bufUncat; |
|
623 |
|
624 HBufC *bufNumOfUncat; |
|
625 if ( numOfUncatToBeListed == 1 ) |
|
626 { |
|
627 bufNumOfUncat = StringLoader::LoadL( R_CONN_METHODS_ONE ); |
|
628 } |
|
629 else |
|
630 { |
|
631 bufNumOfUncat = StringLoader::LoadL( R_CONN_METHODS_MANY, |
|
632 numOfUncatToBeListed ); |
|
633 } |
|
634 |
|
635 numUncat = *bufNumOfUncat; |
|
636 numUncat.ZeroTerminate(); |
|
637 delete bufNumOfUncat; |
|
638 |
|
639 TBuf<KMaxEntryLength> temp; |
|
640 _LIT( KIconIdNameNumber, "%d\t%s\t%s" ); |
|
641 |
|
642 temp.FillZ( KMaxEntryLength ); |
|
643 temp.Format( KIconIdNameNumber, iIcons->Count()-1, nameUncat.Ptr(), |
|
644 numUncat.Ptr() ); |
|
645 |
|
646 CConnectionInfo* conIn = CConnectionInfo::NewL( 0, 0, temp ); |
|
647 CleanupStack::PushL( conIn ); |
|
648 iItems->AppendL( conIn ); |
|
649 CleanupStack::Pop( conIn ); |
|
650 if ( iHighlightedItem < 0 ) |
|
651 { |
|
652 iHighlightedItem = 0; |
|
653 } |
|
654 } |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 |
|
660 // --------------------------------------------------------- |
|
661 // CActiveSelectConnectionPlugin::GetElementIDL |
|
662 // --------------------------------------------------------- |
|
663 // |
|
664 TUint32 CActiveSelectConnectionPlugin::GetElementIDL( TUint32 aIAPId, |
|
665 TUint32 aDestinationId ) |
|
666 { |
|
667 TUint32 retval = 0; |
|
668 TInt err; |
|
669 |
|
670 if ( aDestinationId ) |
|
671 { |
|
672 RCmDestinationExt cmDestExt; |
|
673 TRAP( err, cmDestExt = iCmManagerExt.DestinationL( aDestinationId ) ); |
|
674 if ( err == KErrNone ) |
|
675 { |
|
676 retval = cmDestExt.ElementId(); |
|
677 cmDestExt.Close(); |
|
678 } |
|
679 } |
|
680 else if ( aIAPId ) |
|
681 { |
|
682 RCmConnectionMethodExt cmConnMethodExt; |
|
683 TRAP( err, cmConnMethodExt = iCmManagerExt.ConnectionMethodL( |
|
684 aIAPId ) ); |
|
685 if ( err == KErrNone ) |
|
686 { |
|
687 CleanupClosePushL( cmConnMethodExt ); |
|
688 retval = cmConnMethodExt.GetIntAttributeL( ECmElementID ); |
|
689 CleanupStack::PopAndDestroy(); // cmConnMethodExt |
|
690 } |
|
691 } |
|
692 |
|
693 return retval; |
|
694 } |
|
695 |
|
696 |
|
697 // --------------------------------------------------------- |
|
698 // CActiveSelectConnectionPlugin::GetRefreshIntervalL() |
|
699 // --------------------------------------------------------- |
|
700 // |
|
701 TInt CActiveSelectConnectionPlugin::GetRefreshIntervalL( ) |
|
702 { |
|
703 CLOG_ENTERFN( "CActiveSelectConnectionPlugin::GetRefreshInterval" ); |
|
704 |
|
705 TInt variant( KTickDefaultInterval ); |
|
706 |
|
707 |
|
708 CMDBSession* session = CMDBSession::NewL(KCDLatestVersion); |
|
709 CleanupStack::PushL( session ); |
|
710 |
|
711 //session->OpenTransactionL(); |
|
712 TMDBElementId tableId = 0; |
|
713 |
|
714 tableId = CCDWlanDeviceSettingsRecord::TableIdL( *session); |
|
715 |
|
716 CCDWlanDeviceSettingsRecord* record = new(ELeave) |
|
717 CCDWlanDeviceSettingsRecord(tableId); |
|
718 CleanupStack::PushL(record); |
|
719 |
|
720 record->iWlanDeviceSettingsType = KWlanUserSettings; |
|
721 |
|
722 if(record->FindL( *session )) |
|
723 { |
|
724 record->LoadL( *session ); |
|
725 |
|
726 // In case iBgScanInterval is -1 (= automatic) then just use |
|
727 // KTickDefaultInterval as refresh interval |
|
728 if ( record->iBgScanInterval != KWlanBgScanIntervalAuto |
|
729 && record->iBgScanInterval > 0 ) |
|
730 { |
|
731 variant = record->iBgScanInterval; |
|
732 variant = variant * KMicrosecondsToSecondsMultiplier; |
|
733 } |
|
734 } |
|
735 CleanupStack::PopAndDestroy( record ); |
|
736 |
|
737 //session->CommitTransactionL(); |
|
738 |
|
739 CleanupStack::PopAndDestroy( session ); |
|
740 |
|
741 TUint32 variantToLog = variant; |
|
742 |
|
743 CLOG_WRITEF( _L( "Refresh interval (microseconds) : %d" ), variantToLog ); |
|
744 |
|
745 CLOG_LEAVEFN( "CActiveSelectConnectionPlugin::GetRefreshInterval" ); |
|
746 |
|
747 return variant; |
|
748 } |
|
749 |
|
750 // --------------------------------------------------------- |
|
751 // CActiveSelectConnectionPlugin::CountAdhocWlanIapsL() |
|
752 // --------------------------------------------------------- |
|
753 // |
|
754 TInt CActiveSelectConnectionPlugin::CountAdhocWlanIapsL() |
|
755 { |
|
756 CLOG_ENTERFN( "CActiveSelectExplicit::CountAdhocWlanIapsL " ); |
|
757 |
|
758 // Creating a session with the latest version |
|
759 CMDBSession* db = CMDBSession::NewLC( CMDBSession::LatestVersion() ); |
|
760 db->SetAttributeMask( ECDProtectedWrite ); |
|
761 |
|
762 // Create wlan service record set (RArray (or RPtrArray?)) |
|
763 CMDBRecordSet<CCDWlanServiceRecord>* wlanSet = |
|
764 new (ELeave)CMDBRecordSet<CCDWlanServiceRecord>( CCDWlanServiceRecord::TableIdL( *db ) ); |
|
765 CleanupStack::PushL( wlanSet ); |
|
766 |
|
767 // Create wlan service record |
|
768 CCDWlanServiceRecord* wlanRecord = |
|
769 new (ELeave)CCDWlanServiceRecord( CCDWlanServiceRecord::TableIdL( *db ) ); |
|
770 |
|
771 CleanupStack::PushL( wlanRecord ); |
|
772 |
|
773 // Set ConnectionMode field in wlan service record (see wlancontainer.h) |
|
774 // This works with EWlanOperatingModeAdhoc, fails with EWlanConnectionModeAdhoc |
|
775 wlanRecord->iWlanConnMode.SetL( EWlanOperatingModeAdhoc ); |
|
776 |
|
777 // Append wlan service record to wlan service record set (currently empty) |
|
778 wlanSet->iRecords.AppendL( wlanRecord ); |
|
779 CleanupStack::Pop( wlanRecord ); // ownership moved to RPointerArray |
|
780 |
|
781 TInt wlanRecordCount( 0 ); |
|
782 |
|
783 // Find matcing wlan service records |
|
784 if( wlanSet->FindL( *db ) ) |
|
785 { |
|
786 wlanRecordCount = wlanSet->iRecords.Count(); |
|
787 |
|
788 for ( TInt i = 0; i < wlanRecordCount; i++ ) |
|
789 { |
|
790 // Load the current record again to be sure all fields are up to date |
|
791 wlanRecord->SetElementId( wlanSet->iRecords[i]->ElementId() ); |
|
792 |
|
793 // Load will only look at ElementId and updates the rest of the fields |
|
794 wlanRecord->LoadL( *db ); |
|
795 |
|
796 if ( wlanRecord->iWLanSSID.IsNull() ) |
|
797 { |
|
798 // Count active Easy WLAN using adhoc out |
|
799 wlanRecordCount--; |
|
800 break; |
|
801 } |
|
802 } |
|
803 |
|
804 CLOG_WRITEF( _L("wlanSet record count = %d"), wlanRecordCount ); |
|
805 } |
|
806 else |
|
807 { |
|
808 CLOG_WRITEF( _L("no matcing wlan records found." )); |
|
809 } |
|
810 |
|
811 CleanupStack::PopAndDestroy( wlanSet ); |
|
812 CleanupStack::PopAndDestroy( db ); |
|
813 |
|
814 CLOG_LEAVEFN( "CActiveSelectExplicit::CountAdhocWlanIapsL" ); |
|
815 |
|
816 return ( wlanRecordCount ); |
|
817 } |
|
818 |
|
819 // End of File |