1 /* |
|
2 * Copyright (c) 2002-2007 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: This is the settings view of btui. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknViewAppUi.h> // AVKON components |
|
19 #include <avkon.hrh> |
|
20 #include <akntitle.h> |
|
21 #include <featmgr.h> // Feature Manager API |
|
22 |
|
23 #include "btui.hrh" // Menu commands |
|
24 #include "btui.h" |
|
25 #include "BTUIMainView.h" |
|
26 #include "BTUIMainContainer.h" |
|
27 #include "debug.h" |
|
28 #include "BTUIKeyWatcher.h" |
|
29 #include "BTUIPairedDevicesView.h" |
|
30 #include "BTUIBlockedDevicesView.h" |
|
31 |
|
32 #include <BtuiViewResources.rsg> // Compiled resource ids |
|
33 #include <AknGlobalNote.h> |
|
34 #include <aknnotewrappers.h> |
|
35 #include <aknradiobuttonsettingpage.h> |
|
36 #include <akntextsettingpage.h> |
|
37 #include <StringLoader.h> // Series 60 localisation stringloader |
|
38 #include <aknslidersettingpage.h> //visibility time setting page |
|
39 #include <data_caging_path_literals.hrh> |
|
40 #include <bautils.h> // BAFL utils (for language file) |
|
41 #include <btui.mbg> // application icon for General Setting |
|
42 #include <AknMediatorFacade.h> |
|
43 #include <AknUtils.h> // For char filter |
|
44 #include <CoreApplicationUIsSDKCRKeys.h> |
|
45 #include <hlplch.h> // Help launcher |
|
46 #include <secondarydisplay/BtuiSecondaryDisplayAPI.h> |
|
47 #include <btengprivatecrkeys.h> |
|
48 #include <gstabhelper.h> |
|
49 #include <gsfwviewuids.h> |
|
50 #include <gsparentplugin.h> |
|
51 #include <utf.h> // CnvUtfConverter |
|
52 #include <btfeaturescfg.h> // For EnterpriseEnablementL() |
|
53 #include <btnotif.h> |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CBTUIMainView::NewL |
|
57 // Two phased constructor |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 CBTUIMainView* CBTUIMainView::NewL(MBtuiPluginViewActivationObserver* aObserver) |
|
61 { |
|
62 //TRACE_FUNC_ENTRY |
|
63 |
|
64 CBTUIMainView* self = new (ELeave) CBTUIMainView(aObserver); |
|
65 |
|
66 // Set construction type, before ConstructL(). |
|
67 self->iConstructAsGsPlugin = EFalse; |
|
68 |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop(self); |
|
72 |
|
73 //TRACE_FUNC_EXIT |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CBTUIMainView::NewL |
|
80 // Two phased constructor |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CBTUIMainView* CBTUIMainView::NewGsPluginL() |
|
84 { |
|
85 //TRACE_FUNC_ENTRY |
|
86 |
|
87 CBTUIMainView* self = new (ELeave) CBTUIMainView(NULL); |
|
88 |
|
89 // Set construction type, before ConstructL(). |
|
90 self->iConstructAsGsPlugin = ETrue; |
|
91 |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL(); |
|
94 |
|
95 CleanupStack::Pop( self ); |
|
96 |
|
97 //TRACE_FUNC_EXIT |
|
98 return self; |
|
99 } |
|
100 |
|
101 |
|
102 // --------------------------------------------------------- |
|
103 // CBTUIMainView::CBTUIMainView |
|
104 // --------------------------------------------------------- |
|
105 |
|
106 CBTUIMainView::CBTUIMainView(MBtuiPluginViewActivationObserver* aObserver ) |
|
107 :iConstructAsGsPlugin(EFalse), iActivationObserver(aObserver) |
|
108 { |
|
109 } |
|
110 // --------------------------------------------------------- |
|
111 // CBTUIMainView::ConstructL |
|
112 // Symbian 2nd phase constructor can leave. |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 void CBTUIMainView::ConstructL() |
|
116 { |
|
117 TRACE_FUNC_ENTRY |
|
118 |
|
119 // Plugin load resource manually. |
|
120 // These resources are needed by BaseConstructL |
|
121 |
|
122 iEikEnv = CEikonEnv::Static(); |
|
123 |
|
124 TFileName filename; |
|
125 filename += KFileDrive; |
|
126 filename += KDC_RESOURCE_FILES_DIR; |
|
127 filename += KResourceFileName; |
|
128 |
|
129 BaflUtils::NearestLanguageFile(iEikEnv->FsSession(),filename); |
|
130 iResourceFileFlag=iEikEnv->AddResourceFileL(filename); |
|
131 |
|
132 // According to Construction type, different softkey resource will be used. |
|
133 // |
|
134 if(iConstructAsGsPlugin) |
|
135 { |
|
136 iViewArray = new CArrayPtrFlat<MGSTabbedView>( 3 ); |
|
137 iTabHelper = CGSTabHelper::NewL(); |
|
138 iViewArray->AppendL(this); |
|
139 iParentViewNotSetYet = ETrue; |
|
140 |
|
141 iKeyWatcher = CBTUIKeyWatcher::NewL(this, KBTUIPHYCountWatcher); |
|
142 |
|
143 // Construct OtherDeviceView |
|
144 // |
|
145 CAknView* pairedDeviceView = CBTUIPairedDevicesView::NewLC( this, iViewArray ); |
|
146 iAppUi->AddViewL( pairedDeviceView ); // Transfer ownership to CAknViewAppUi |
|
147 CleanupStack::Pop(pairedDeviceView ); |
|
148 |
|
149 // Construct BlockDeviceView |
|
150 // |
|
151 CAknView* blockedDeviceView = CBTUIBlockedDevicesView::NewLC( this, iViewArray ); |
|
152 iAppUi->AddViewL( blockedDeviceView ); // Transfer ownership to CAknViewAppUi |
|
153 CleanupStack::Pop(blockedDeviceView ); |
|
154 |
|
155 BaseConstructL( R_BTUI_MAIN_VIEW_GS_PLUGIN ); |
|
156 } |
|
157 else |
|
158 { |
|
159 BaseConstructL( R_BTUI_MAIN_VIEW ); |
|
160 } |
|
161 |
|
162 iBtEngSettings = CBTEngSettings::NewL(this); |
|
163 |
|
164 // Sets up TLS, must be done before FeatureManager is used. |
|
165 FeatureManager::InitializeLibL(); |
|
166 iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); |
|
167 |
|
168 |
|
169 TRACE_FUNC_EXIT |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // --------------------------------------------------------- |
|
174 // Destructor. |
|
175 // --------------------------------------------------------- |
|
176 // |
|
177 CBTUIMainView::~CBTUIMainView() |
|
178 { |
|
179 TRACE_FUNC_ENTRY |
|
180 |
|
181 iEikEnv->DeleteResourceFile(iResourceFileFlag); |
|
182 |
|
183 if ( iContainer ) |
|
184 { |
|
185 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
186 } |
|
187 |
|
188 delete iBtEngSettings; |
|
189 delete iContainer; |
|
190 delete iIdle; |
|
191 |
|
192 if(iConstructAsGsPlugin) |
|
193 { |
|
194 if ( iViewArray ) |
|
195 { |
|
196 iViewArray->Reset(); |
|
197 delete iViewArray; |
|
198 } |
|
199 |
|
200 delete iTabHelper; |
|
201 delete iKeyWatcher; |
|
202 } |
|
203 |
|
204 // Frees the TLS. Must be done after FeatureManager is used. |
|
205 FeatureManager::UnInitializeLib(); |
|
206 |
|
207 |
|
208 TRACE_FUNC_EXIT |
|
209 } |
|
210 |
|
211 // ---------------------------------------------------- |
|
212 // CBTUIMainView::PowerStateChanged |
|
213 // ---------------------------------------------------- |
|
214 // |
|
215 void CBTUIMainView::PowerStateChanged( TBTPowerStateValue ) |
|
216 { |
|
217 TRACE_FUNC_ENTRY |
|
218 if(iContainer) |
|
219 { |
|
220 iContainer->SettingChanged(EBTMainListItemPowerMode); |
|
221 } |
|
222 |
|
223 if( iConstructAsGsPlugin ) |
|
224 { |
|
225 UpdateParentView(); |
|
226 } |
|
227 TRACE_FUNC_EXIT |
|
228 } |
|
229 // ---------------------------------------------------- |
|
230 // CBTUIMainView::VisibilityModeChanged |
|
231 // ---------------------------------------------------- |
|
232 // |
|
233 void CBTUIMainView::VisibilityModeChanged( TBTVisibilityMode ) |
|
234 { |
|
235 TRACE_FUNC_ENTRY |
|
236 if(iContainer) |
|
237 { |
|
238 iContainer->SettingChanged(EBTMainListItemVisibilityMode); |
|
239 } |
|
240 |
|
241 if( iConstructAsGsPlugin ) |
|
242 { |
|
243 UpdateParentView(); |
|
244 } |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------- |
|
248 // From CAknView |
|
249 // CBTUIMainView::Id |
|
250 // --------------------------------------------------------- |
|
251 // |
|
252 TUid CBTUIMainView::Id() const |
|
253 { |
|
254 TRACE_FUNC_ENTRY |
|
255 if(iConstructAsGsPlugin) |
|
256 { |
|
257 return KGsBtuiPluginUid; //same as ecom impl UID, required by GS interface. |
|
258 } |
|
259 else |
|
260 { |
|
261 return KBtuiPluginUidMainView; //view id |
|
262 } |
|
263 } |
|
264 // --------------------------------------------------------- |
|
265 // CBTUIMainView::HandleMiddleSoftkey |
|
266 // Handles middle soft key |
|
267 // --------------------------------------------------------- |
|
268 // |
|
269 void CBTUIMainView::HandleMiddleSoftkey() |
|
270 { |
|
271 TRACE_FUNC_ENTRY |
|
272 if( iContainer == NULL ) return; |
|
273 |
|
274 TInt currentHighLightPosition= iContainer->CurrentItemIndex(); |
|
275 switch(currentHighLightPosition) |
|
276 { |
|
277 case EBTMainListItemPowerMode: |
|
278 HandleCommand( EBTUICmdChangePowerStateSelect ); |
|
279 break; |
|
280 case EBTMainListItemVisibilityMode: |
|
281 HandleCommand( EBTUICmdChangeVisibilitySelect ); |
|
282 break; |
|
283 case EBTMainListItemNameSetting: |
|
284 HandleCommand( EBTUICmdChangeBTNameSelect ); |
|
285 break; |
|
286 |
|
287 // For Bluetooth SIM Access Profile feature |
|
288 // |
|
289 case EBTMainListItemSapMode: |
|
290 HandleCommand( EBTUICmdChangeSapStateSelect ); |
|
291 break; |
|
292 default: |
|
293 break; |
|
294 } |
|
295 TRACE_FUNC_EXIT |
|
296 } |
|
297 // --------------------------------------------------------- |
|
298 // TUid CBTUIMainView::HandleCommand |
|
299 // --------------------------------------------------------- |
|
300 // |
|
301 void CBTUIMainView::HandleCommand(TInt aCommand) |
|
302 { |
|
303 TRAP_IGNORE(HandleCommandL(aCommand)); |
|
304 } |
|
305 // --------------------------------------------------------- |
|
306 // CBTUIMainView::HandleCommandL |
|
307 // Redirects commands to the appui class. |
|
308 // --------------------------------------------------------- |
|
309 // |
|
310 void CBTUIMainView::HandleCommandL(TInt aCommand) |
|
311 { |
|
312 TRACE_INFO((_L(">> CBTUIMainView::HandleCommandL: %d"), aCommand)) |
|
313 switch ( aCommand ) |
|
314 { |
|
315 //middle soft key is handled here |
|
316 case EBTUICmdMSK: |
|
317 HandleMiddleSoftkey(); |
|
318 break; |
|
319 case EAknSoftkeyBack: |
|
320 AppUi()->ActivateLocalViewL(iParentView.iViewUid); |
|
321 break; |
|
322 |
|
323 case EAknSoftkeyExit: |
|
324 { |
|
325 AppUi()->ProcessCommandL(EEikCmdExit); |
|
326 break; |
|
327 } |
|
328 |
|
329 #ifdef __SERIES60_HELP |
|
330 case EAknCmdHelp: |
|
331 { |
|
332 HlpLauncher::LaunchHelpApplicationL( |
|
333 iEikonEnv->WsSession(), AppUi()->AppHelpContextL()); |
|
334 break; |
|
335 } |
|
336 #endif |
|
337 case EBTUICmdChangePowerStateMenu: |
|
338 { |
|
339 AskPowerModeDlgL(); |
|
340 break; |
|
341 } |
|
342 |
|
343 case EBTUICmdChangePowerStateSelect: |
|
344 { |
|
345 TBTPowerStateValue powerState; |
|
346 iBtEngSettings->GetPowerState(powerState); |
|
347 if(powerState==EBTPowerOn) |
|
348 { |
|
349 SetPowerStatusL( EFalse ); |
|
350 } |
|
351 else |
|
352 { |
|
353 SetPowerStatusL( ETrue ); |
|
354 } |
|
355 break; |
|
356 } |
|
357 |
|
358 case EBTUICmdChangeVisibilitySelect: // now both select key and menu command will triger the setting page. |
|
359 case EBTUICmdChangeVisibilityMenu: |
|
360 { |
|
361 AskVisibilityDlgL(); |
|
362 break; |
|
363 } |
|
364 |
|
365 case EBTUICmdChangeBTNameMenu: |
|
366 case EBTUICmdChangeBTNameSelect: |
|
367 { |
|
368 AskNewBtNameDlgL(); |
|
369 iContainer->SettingChanged(TBTMainListItemIndexes(iContainer->CurrentItemIndex())); |
|
370 break; |
|
371 } |
|
372 |
|
373 // For Bluetooth SIM Access Profile feature |
|
374 case EBTUICmdChangeSapStateSelect: |
|
375 { |
|
376 |
|
377 if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDataProfilesDisabled ) |
|
378 { |
|
379 RNotifier notifier; |
|
380 User::LeaveIfError(notifier.Connect()); |
|
381 CleanupClosePushL(notifier); |
|
382 User::LeaveIfError(notifier.StartNotifier(KBTEnterpriseItSecurityInfoNotifierUid, KNullDesC8 )); |
|
383 CleanupStack::PopAndDestroy(¬ifier); |
|
384 } |
|
385 else |
|
386 { |
|
387 TInt sapStatus; |
|
388 CRepository* repository = CRepository::NewL(KCRUidBTEngPrivateSettings); |
|
389 CleanupStack::PushL(repository); |
|
390 repository->Get(KBTSapEnabled, sapStatus); |
|
391 CleanupStack::PopAndDestroy(repository); |
|
392 |
|
393 if(sapStatus==EBTSapEnabled) |
|
394 { |
|
395 SetSapStatusL( EBTSapDisabled ); |
|
396 } |
|
397 else |
|
398 { |
|
399 SetSapStatusL( EBTSapEnabled ); |
|
400 } |
|
401 iContainer->SettingChanged( |
|
402 TBTMainListItemIndexes(iContainer->CurrentItemIndex())); |
|
403 } |
|
404 break; |
|
405 } |
|
406 |
|
407 // For Bluetooth SIM Access Profile feature |
|
408 case EBTUICmdChangeSapStateMenu: |
|
409 { |
|
410 AskSapModeDlgL(); |
|
411 iContainer->SettingChanged( |
|
412 TBTMainListItemIndexes(iContainer->CurrentItemIndex())); |
|
413 break; |
|
414 } |
|
415 |
|
416 default: |
|
417 { |
|
418 AppUi()->HandleCommandL( aCommand ); |
|
419 iContainer->SettingChanged( |
|
420 TBTMainListItemIndexes(iContainer->CurrentItemIndex())); |
|
421 break; |
|
422 } |
|
423 } |
|
424 TRACE_FUNC_EXIT |
|
425 } |
|
426 |
|
427 |
|
428 // --------------------------------------------------------- |
|
429 // From CAknView |
|
430 // CBTUIMainView::DoActivateL |
|
431 // --------------------------------------------------------- |
|
432 // |
|
433 void CBTUIMainView::DoActivateL( const TVwsViewId& aPrevViewId, |
|
434 TUid /*aCustomMessageId*/, |
|
435 const TDesC8& /*aCustomMessage*/) |
|
436 { |
|
437 TRACE_FUNC_ENTRY |
|
438 |
|
439 |
|
440 if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDisabled ) |
|
441 { |
|
442 RNotifier notifier; |
|
443 User::LeaveIfError(notifier.Connect()); |
|
444 CleanupClosePushL(notifier); |
|
445 User::LeaveIfError(notifier.StartNotifier(KBTEnterpriseItSecurityInfoNotifierUid, KNullDesC8 )); |
|
446 CleanupStack::PopAndDestroy(¬ifier); |
|
447 |
|
448 AppUi()->ActivateLocalViewL(aPrevViewId.iViewUid); //go back straight away |
|
449 return; |
|
450 } |
|
451 |
|
452 |
|
453 if( iConstructAsGsPlugin ) |
|
454 { |
|
455 // Only set parent view when entering BT GS setting. |
|
456 // since tab change chould make aPrevViewId assign to non-parent views. e.g. paired or blocked view. |
|
457 if(iParentViewNotSetYet) |
|
458 { |
|
459 iParentView = aPrevViewId; |
|
460 iParentViewNotSetYet = EFalse; |
|
461 } |
|
462 |
|
463 // Setup tab group |
|
464 iTabHelper->CreateTabGroupL( Id(), iViewArray ); |
|
465 } |
|
466 |
|
467 iContainer = new (ELeave) CBTUIMainContainer; |
|
468 iContainer->SetMopParent(this); // MObjectProvider |
|
469 iContainer->ConstructL( ClientRect(), this ); |
|
470 |
|
471 // Setup the title |
|
472 // |
|
473 HBufC* btTitleMain = iCoeEnv->AllocReadResourceLC(R_BT_TITLE_BLUETOOTH); |
|
474 CEikStatusPane* statusPane = StatusPane(); |
|
475 CAknTitlePane* titlePane; |
|
476 titlePane = (CAknTitlePane*) statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle)); |
|
477 titlePane->SetTextL(btTitleMain->Des()); |
|
478 CleanupStack::PopAndDestroy(btTitleMain); // btTitleMain |
|
479 btTitleMain = NULL; |
|
480 |
|
481 AppUi()->AddToStackL( *this, iContainer ); |
|
482 |
|
483 //Check if the local name has been set. If not ask user to set name |
|
484 |
|
485 TBool nameStatus = EFalse; |
|
486 TInt err = IsLocalNameModifiedL( nameStatus ); |
|
487 |
|
488 if( err || nameStatus == EBTLocalNameDefault ) |
|
489 { |
|
490 InitiateBTLocalNameQueryL(); // Ask local Bluetooth name if not given yet. |
|
491 } |
|
492 |
|
493 // notify observer |
|
494 if( iActivationObserver && iConstructAsGsPlugin == EFalse) |
|
495 { |
|
496 iActivationObserver->PluginViewActivated(EMainViewId); |
|
497 } |
|
498 |
|
499 TRACE_FUNC_EXIT |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------- |
|
503 // From CAknView |
|
504 // CBTUIMainView::DoDeactivate |
|
505 // --------------------------------------------------------- |
|
506 // |
|
507 void CBTUIMainView::DoDeactivate() |
|
508 { |
|
509 TRACE_FUNC_ENTRY |
|
510 |
|
511 if ( iContainer ) |
|
512 { |
|
513 AppUi()->RemoveFromStack( iContainer ); |
|
514 } |
|
515 |
|
516 delete iContainer; |
|
517 iContainer = NULL; |
|
518 |
|
519 if(iConstructAsGsPlugin) |
|
520 { |
|
521 iTabHelper->RemoveTabGroup(); |
|
522 CGSBaseView::DoDeactivate(); |
|
523 } |
|
524 TRACE_FUNC_EXIT |
|
525 |
|
526 } |
|
527 |
|
528 // --------------------------------------------------------- |
|
529 // From CAknView |
|
530 // CBTUIMainView::DynInitMenuPaneL |
|
531 // Shows selected item's context sensitive options menu. |
|
532 // --------------------------------------------------------- |
|
533 // |
|
534 void CBTUIMainView::DynInitMenuPaneL( TInt aResId, CEikMenuPane* aMenu ) |
|
535 { |
|
536 TRACE_FUNC_ENTRY |
|
537 |
|
538 // dim help if it exists and is not supported |
|
539 TInt tmp; |
|
540 if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) |
|
541 { |
|
542 aMenu->SetItemDimmed(EAknCmdHelp, |
|
543 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
544 } |
|
545 |
|
546 if ( aResId == R_BTUI_MAIN_VIEW_MENU ) |
|
547 { |
|
548 // Set all menus dimmed at first(hide them all) |
|
549 // |
|
550 aMenu->SetItemDimmed(EBTUICmdChangePowerStateMenu, ETrue); |
|
551 aMenu->SetItemDimmed(EBTUICmdChangeVisibilityMenu, ETrue); |
|
552 aMenu->SetItemDimmed(EBTUICmdChangeBTNameMenu, ETrue); |
|
553 if ( FeatureManager::FeatureSupported( KFeatureIdBtSap ) ) |
|
554 aMenu->SetItemDimmed(EBTUICmdChangeSapStateMenu, ETrue); |
|
555 |
|
556 } |
|
557 TRACE_FUNC_EXIT |
|
558 } |
|
559 |
|
560 // --------------------------------------------------------- |
|
561 // CBTUIMainView::SettingChangedL |
|
562 // Redraws the BT Name field. |
|
563 // --------------------------------------------------------- |
|
564 // |
|
565 void CBTUIMainView::SettingChangedL( TBTMainListItemIndexes aListItem ) |
|
566 { |
|
567 TRACE_FUNC_ENTRY |
|
568 if(iContainer) |
|
569 { |
|
570 iContainer->SettingChanged(aListItem); |
|
571 } |
|
572 |
|
573 } |
|
574 |
|
575 // ---------------------------------------------------- |
|
576 // CBTUIMainView::SetPowerStatusL |
|
577 // ---------------------------------------------------- |
|
578 // |
|
579 TInt CBTUIMainView::SetPowerStatusL( TBool aValue ) |
|
580 { |
|
581 TRACE_FUNC_ENTRY |
|
582 |
|
583 TInt errorCode = KErrNone; |
|
584 TBTPowerStateValue previousPowerMode; |
|
585 errorCode=iBtEngSettings->GetPowerState(previousPowerMode); |
|
586 if(errorCode) |
|
587 return errorCode; |
|
588 |
|
589 TBool legalToChange = ETrue; |
|
590 |
|
591 if ( ( previousPowerMode==EBTPowerOn ) && ( !aValue )) // power ON -> OFF |
|
592 { |
|
593 TRACE_INFO(_L("power ON -> OFF")) |
|
594 |
|
595 // Check active connections before query |
|
596 if( TBTUIViewsCommonUtils::IsAnyDeviceConnectedL()) |
|
597 { |
|
598 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
599 |
|
600 if(iCoverDisplayEnabled) |
|
601 { |
|
602 CleanupStack::PushL(dlg); |
|
603 dlg->PublishDialogL(ECmdShowBtSwitchOffAnywayQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
604 CleanupStack::Pop(dlg); |
|
605 } |
|
606 |
|
607 TInt keypress = dlg->ExecuteLD( R_BT_SWITCH_OFF_ANYWAY_QUERY ); |
|
608 if( !keypress ) // User has not accepted the dialog |
|
609 { |
|
610 legalToChange = EFalse; |
|
611 } |
|
612 } |
|
613 TRACE_INFO((_L("power ON -> OFF, legalToChange = %d"), legalToChange)) |
|
614 |
|
615 } |
|
616 else if ( ( !previousPowerMode ) && ( aValue ) ) // power OFF -> ON |
|
617 { |
|
618 TRACE_INFO(_L("power OFF -> ON")) |
|
619 |
|
620 TInt offlineModeOff = 0; // possible values are 0 and 1 |
|
621 TInt activationEnabled = 0; // possible values are 0 and 1 |
|
622 |
|
623 CRepository* repository = CRepository::NewL(KCRUidCoreApplicationUIs); |
|
624 CleanupStack::PushL(repository); |
|
625 repository->Get(KCoreAppUIsNetworkConnectionAllowed, offlineModeOff); |
|
626 // Closing connection: |
|
627 CleanupStack::PopAndDestroy(repository); |
|
628 repository =NULL; |
|
629 repository = CRepository::NewL(KCRUidBluetoothEngine); |
|
630 // Check activation enabled |
|
631 CleanupStack::PushL(repository); |
|
632 repository->Get(KBTEnabledInOffline, activationEnabled); |
|
633 // Closing connection: |
|
634 CleanupStack::PopAndDestroy(repository); |
|
635 |
|
636 |
|
637 TRACE_INFO((_L("power OFF -> ON, offlineModeOff = %d"), offlineModeOff )) |
|
638 TRACE_INFO((_L("power OFF -> ON, activationEnabled = %d"), activationEnabled )) |
|
639 |
|
640 // Is offline mode on |
|
641 // |
|
642 if ( !offlineModeOff ) |
|
643 { |
|
644 // Choose user interaction |
|
645 // |
|
646 if ( activationEnabled ) |
|
647 { |
|
648 // Create and show query |
|
649 // |
|
650 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
651 |
|
652 if(iCoverDisplayEnabled) |
|
653 { |
|
654 CleanupStack::PushL(dlg); |
|
655 dlg->PublishDialogL(ECmdShowBtActivateInOfflineQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
656 CleanupStack::Pop(dlg); |
|
657 } |
|
658 |
|
659 TInt keypress = dlg->ExecuteLD( R_BT_ACTIVATE_IN_OFFLINE_QUERY ); |
|
660 if( !keypress ) // User has not accepted the dialog |
|
661 { |
|
662 legalToChange = EFalse; |
|
663 } |
|
664 } |
|
665 else |
|
666 { |
|
667 legalToChange = EFalse; |
|
668 |
|
669 // Load a string, create and show a note |
|
670 // |
|
671 HBufC* stringHolder = StringLoader::LoadLC( R_BT_OFFLINE_DISABLED ); |
|
672 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
673 |
|
674 if(iCoverDisplayEnabled) |
|
675 { |
|
676 CleanupStack::PushL(note); |
|
677 note->PublishDialogL(ECmdShowBtOfflineDisabledNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
678 CleanupStack::Pop(note); |
|
679 } |
|
680 |
|
681 note->ExecuteLD( *stringHolder ); |
|
682 CleanupStack::PopAndDestroy(stringHolder); //stringHolder |
|
683 } |
|
684 } |
|
685 } |
|
686 |
|
687 TRACE_INFO((_L("legalToChange = %d"), legalToChange)) |
|
688 |
|
689 // Switch powermode |
|
690 // |
|
691 if ( legalToChange ) |
|
692 { |
|
693 |
|
694 TInt errorCode = KErrNone; |
|
695 TBTPowerStateValue powerMode; |
|
696 if(aValue) |
|
697 { |
|
698 powerMode=EBTPowerOn; |
|
699 } |
|
700 else |
|
701 { |
|
702 powerMode=EBTPowerOff; |
|
703 } |
|
704 |
|
705 errorCode=iBtEngSettings->SetPowerState(powerMode); |
|
706 |
|
707 if( (errorCode == KErrNone ) && (aValue)) |
|
708 |
|
709 { |
|
710 //Check the visibility mode |
|
711 TBTVisibilityMode visiMode; |
|
712 errorCode=iBtEngSettings->GetVisibilityMode(visiMode); |
|
713 if(errorCode==KErrNone) |
|
714 { |
|
715 if (visiMode == EBTVisibilityModeHidden) |
|
716 { |
|
717 //Show note |
|
718 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, |
|
719 CAknNoteDialog::ELongTimeout ); |
|
720 if(iCoverDisplayEnabled) |
|
721 { |
|
722 CleanupStack::PushL(dlg); |
|
723 dlg->PublishDialogL(ECmdBtuiShowBtHiddenFromOthersNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
724 CleanupStack::Pop(dlg); |
|
725 } |
|
726 |
|
727 dlg->ExecuteLD( R_BT_HIDDEN_FROM_OTHERS ); |
|
728 } |
|
729 } |
|
730 } |
|
731 if ( errorCode != KErrNone && errorCode != KErrAlreadyExists ) |
|
732 { |
|
733 TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL()); |
|
734 } |
|
735 |
|
736 } |
|
737 |
|
738 TRACE_INFO((_L("SetPowerStatusL() complete. errorCode = %d"), errorCode)) |
|
739 return errorCode; |
|
740 } |
|
741 |
|
742 // ---------------------------------------------------------- |
|
743 // CBTUIMainView::SetVisibilityStatusL |
|
744 // ---------------------------------------------------------- |
|
745 // |
|
746 void CBTUIMainView::SetVisibilityStatusL( TBTVisibilityMode aMode ) |
|
747 { |
|
748 TRACE_FUNC_ENTRY |
|
749 |
|
750 TInt errorCode = KErrNone; |
|
751 |
|
752 switch( aMode ) |
|
753 { |
|
754 case EBTVisibilityModeGeneral: |
|
755 { |
|
756 errorCode = iBtEngSettings->SetVisibilityMode(aMode); |
|
757 |
|
758 if(errorCode == KErrNone) |
|
759 { |
|
760 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, |
|
761 CAknNoteDialog::ELongTimeout ); |
|
762 |
|
763 if(iCoverDisplayEnabled) |
|
764 { |
|
765 CleanupStack::PushL(dlg); |
|
766 dlg->PublishDialogL(ECmdShowBtPhoneVisibToAllNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
767 CleanupStack::Pop(dlg); |
|
768 } |
|
769 dlg->ExecuteLD( R_BT_PHONE_VISIB_TO_OTH_NOTE ); |
|
770 } |
|
771 } |
|
772 break; |
|
773 |
|
774 case EBTVisibilityModeHidden: |
|
775 { |
|
776 errorCode = iBtEngSettings->SetVisibilityMode(aMode); |
|
777 |
|
778 if(errorCode == KErrNone) |
|
779 { |
|
780 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EConfirmationTone, |
|
781 CAknNoteDialog::ELongTimeout ); |
|
782 |
|
783 if(iCoverDisplayEnabled) |
|
784 { |
|
785 CleanupStack::PushL(dlg); |
|
786 dlg->PublishDialogL(ECmdBtuiShowBtHiddenFromOthersNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
787 CleanupStack::Pop(dlg); |
|
788 } |
|
789 dlg->ExecuteLD( R_BT_HIDDEN_FROM_OTHERS ); |
|
790 } |
|
791 } |
|
792 break; |
|
793 |
|
794 case EBTVisibilityModeTemporary: |
|
795 { |
|
796 // Asks user to turn on Bluetooth, if temporary visibility is chosen. |
|
797 if( TBTUIViewsCommonUtils::TurnBTOnIfNeededL(iBtEngSettings,iCoverDisplayEnabled) != KErrNone) |
|
798 { |
|
799 return; |
|
800 } |
|
801 TInt sliderValue = 1; |
|
802 CAknSettingPage* dlg = |
|
803 new(ELeave) CAknSliderSettingPage(R_VISIBILITY_TIME_SETTING_PAGE, |
|
804 sliderValue); |
|
805 |
|
806 if (dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) |
|
807 { |
|
808 errorCode = iBtEngSettings->SetVisibilityMode( aMode, sliderValue ); |
|
809 } |
|
810 } |
|
811 break; |
|
812 |
|
813 default: |
|
814 break; |
|
815 } |
|
816 |
|
817 if((errorCode != KErrNone) && (errorCode != KErrAlreadyExists)) |
|
818 { |
|
819 TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL()); |
|
820 } |
|
821 TRACE_FUNC_EXIT |
|
822 } |
|
823 |
|
824 // ---------------------------------------------------------- |
|
825 // CBTUIMainView::GetBTLocalName |
|
826 // ---------------------------------------------------------- |
|
827 // |
|
828 TDesC* CBTUIMainView::GetBTLocalName() |
|
829 { |
|
830 TRACE_FUNC_ENTRY |
|
831 |
|
832 iTempNameBuffer.Zero(); // Empty Local BT device name |
|
833 TInt err=iBtEngSettings->GetLocalName( iTempNameBuffer );// Store name into member variable |
|
834 if(err!=KErrNone) |
|
835 TRAP_IGNORE(TBTUIViewsCommonUtils::ShowGeneralErrorNoteL()); |
|
836 |
|
837 // Cut the excess part of the name away. The query can handle only |
|
838 // KBTUIMaxNameLength characters. |
|
839 // |
|
840 if( iTempNameBuffer.Length() > KBTUIMaxNameLength ) |
|
841 { |
|
842 iTempNameBuffer.SetLength( KBTUIMaxNameLength ); |
|
843 } |
|
844 TRACE_FUNC_EXIT |
|
845 return &iTempNameBuffer; // And return reference for it |
|
846 } |
|
847 |
|
848 // ---------------------------------------------------------- |
|
849 // CBTUIMainView::AskNewBtNameDlgL |
|
850 // ---------------------------------------------------------- |
|
851 // |
|
852 void CBTUIMainView::AskNewBtNameDlgL() |
|
853 { |
|
854 TRACE_FUNC_ENTRY |
|
855 |
|
856 // Cut the excess part of the name away. The query can handle only |
|
857 // KBTUIMaxNameLength characters. |
|
858 // |
|
859 if( iTempNameBuffer.Length() > KBTUIMaxNameLength ) |
|
860 { |
|
861 iTempNameBuffer.SetLength( KBTUIMaxNameLength ); |
|
862 } |
|
863 |
|
864 FOREVER |
|
865 { |
|
866 CAknTextSettingPage* dlg = new( ELeave )CAknTextSettingPage( R_BT_NAME_SETTING_PAGE, |
|
867 iTempNameBuffer ); |
|
868 if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) |
|
869 { |
|
870 // Remove trouble making control chars |
|
871 AknTextUtils::StripCharacters(iTempNameBuffer, KAknStripListControlChars); |
|
872 |
|
873 iTempNameBuffer.TrimAll(); // Remove spaces and check what is left.. |
|
874 if( iTempNameBuffer.Length() > 0 ) |
|
875 { |
|
876 |
|
877 if(iBtEngSettings->SetLocalName(iTempNameBuffer) != KErrNone) |
|
878 { |
|
879 TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); |
|
880 } |
|
881 TRACE_FUNC_EXIT |
|
882 return; |
|
883 } |
|
884 } |
|
885 else |
|
886 { |
|
887 TRACE_FUNC_EXIT |
|
888 return; // User has cancelled this operation |
|
889 } |
|
890 } |
|
891 |
|
892 } |
|
893 |
|
894 // ---------------------------------------------------------- |
|
895 // CBTUIMainView::AskPowerModeDlgL |
|
896 // ---------------------------------------------------------- |
|
897 // |
|
898 void CBTUIMainView::AskPowerModeDlgL() |
|
899 { |
|
900 TRACE_FUNC_ENTRY |
|
901 |
|
902 CDesCArrayFlat* items = iCoeEnv->ReadDesCArrayResourceL( R_BT_POWER_MODES ); |
|
903 CleanupStack::PushL(items); |
|
904 TBTPowerStateValue powerState; |
|
905 iBtEngSettings->GetPowerState(powerState); |
|
906 TInt currentItem = !powerState; // Implicit cast from Not-TBool to int (inverted) |
|
907 |
|
908 CAknRadioButtonSettingPage* dlg = new ( ELeave )CAknRadioButtonSettingPage( |
|
909 R_BT_POWER_SETTING_PAGE, currentItem, items ); |
|
910 if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) |
|
911 { |
|
912 SetPowerStatusL( static_cast<TBool>( !currentItem )); // Cast it back (invert again) |
|
913 } |
|
914 CleanupStack::PopAndDestroy(items); // items |
|
915 TRACE_FUNC_EXIT |
|
916 } |
|
917 |
|
918 // ---------------------------------------------------------- |
|
919 // CBTUIMainView::AskVisibilityDlgL |
|
920 // ---------------------------------------------------------- |
|
921 // |
|
922 void CBTUIMainView::AskVisibilityDlgL() |
|
923 { |
|
924 TRACE_FUNC_ENTRY |
|
925 |
|
926 CDesCArrayFlat* items = iCoeEnv->ReadDesCArrayResourceL( R_BT_VISIBILITY_MODES ); |
|
927 CleanupStack::PushL(items); |
|
928 |
|
929 TInt currentItem = 0; // Current position at radio button setting page |
|
930 TBTVisibilityMode currentMode; |
|
931 TInt errorCode(iBtEngSettings->GetVisibilityMode(currentMode)); |
|
932 if(errorCode==KErrNone) |
|
933 { |
|
934 |
|
935 switch( currentMode ) // Map from mode to radio button position at setting page |
|
936 { |
|
937 case EBTVisibilityModeGeneral: |
|
938 currentItem = 0; |
|
939 break; |
|
940 case EBTVisibilityModeTemporary: // temp visible |
|
941 currentItem = 1; |
|
942 break; |
|
943 case EBTVisibilityModeHidden: |
|
944 currentItem = 1+1; |
|
945 break; |
|
946 default: |
|
947 break; |
|
948 } |
|
949 |
|
950 // Ask new mode from user |
|
951 |
|
952 CAknRadioButtonSettingPage* dlg = new ( ELeave )CAknRadioButtonSettingPage( |
|
953 R_BT_VISIBILITY_SETTING_PAGE, currentItem, items ); |
|
954 if( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged )) |
|
955 { |
|
956 switch( currentItem ) // Map it back from radio button position to mode at setting page |
|
957 { |
|
958 case 0: |
|
959 SetVisibilityStatusL( EBTVisibilityModeGeneral ); |
|
960 break; |
|
961 |
|
962 case 1: |
|
963 SetVisibilityStatusL( EBTVisibilityModeTemporary ); |
|
964 break; |
|
965 |
|
966 case 1+1: |
|
967 SetVisibilityStatusL( EBTVisibilityModeHidden ); |
|
968 break; |
|
969 |
|
970 default: |
|
971 break; |
|
972 } |
|
973 } |
|
974 } |
|
975 else |
|
976 TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); |
|
977 |
|
978 |
|
979 CleanupStack::PopAndDestroy(items); // items |
|
980 } |
|
981 |
|
982 |
|
983 // ---------------------------------------------------- |
|
984 // CBTUIMainView::GetBtSettingsReference |
|
985 // |
|
986 // This method returns the reference to the settings class |
|
987 // ---------------------------------------------------- |
|
988 // |
|
989 CBTEngSettings* CBTUIMainView::GetBtSettingsReference() |
|
990 { |
|
991 TRACE_FUNC |
|
992 return iBtEngSettings; |
|
993 } |
|
994 |
|
995 // ---------------------------------------------------- |
|
996 // CBTUIMainView::InitiateBTLocalNameQueryL |
|
997 // |
|
998 // Initiate BT local name query after Symbian OS has entered |
|
999 // idle state. |
|
1000 // ---------------------------------------------------- |
|
1001 // |
|
1002 void CBTUIMainView::InitiateBTLocalNameQueryL() |
|
1003 { |
|
1004 TRACE_FUNC |
|
1005 |
|
1006 |
|
1007 __ASSERT_DEBUG( !iIdle, PANIC(EBTPanicClassMemberVariableNotNull) ); |
|
1008 |
|
1009 // Launch idle time regognition and execute local BT name query when ready |
|
1010 iIdle = CIdle::NewL(CActive::EPriorityIdle); |
|
1011 iIdle->Start(TCallBack(LaunchBTLocalNameQueryL, this)); |
|
1012 } |
|
1013 |
|
1014 // ---------------------------------------------------- |
|
1015 // CBTUIMainView::LaunchBTLocalNameQueryL |
|
1016 // |
|
1017 // Execute BT local name query. Symbian OS has entered |
|
1018 // idle state now. |
|
1019 // ---------------------------------------------------- |
|
1020 // |
|
1021 TInt CBTUIMainView::LaunchBTLocalNameQueryL(TAny* aMainView) |
|
1022 { |
|
1023 //TRACE_FUNC |
|
1024 |
|
1025 TInt errorCode = static_cast<CBTUIMainView*>(aMainView)->AskBTLocalNameQueryL(); |
|
1026 if( errorCode != KErrNone ) |
|
1027 { |
|
1028 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( CAknNoteDialog::EErrorTone, |
|
1029 CAknNoteDialog::ELongTimeout ); |
|
1030 if(static_cast<CBTUIMainView*>(aMainView)->iCoverDisplayEnabled) |
|
1031 { |
|
1032 CleanupStack::PushL(dlg); |
|
1033 dlg->PublishDialogL(ECmdShowBtGeneralErrorNote, KUidCoverUiCategoryBtui); // initializes cover support} |
|
1034 CleanupStack::Pop(dlg); |
|
1035 } |
|
1036 dlg->ExecuteLD( R_BT_GENERAL_ERROR_NOTE ); |
|
1037 } |
|
1038 return KErrNone; |
|
1039 } |
|
1040 |
|
1041 // ---------------------------------------------------- |
|
1042 // CBTUIMainView::AskBTLocalNameQueryL |
|
1043 // ---------------------------------------------------- |
|
1044 // |
|
1045 TInt CBTUIMainView::AskBTLocalNameQueryL() |
|
1046 { |
|
1047 TRACE_FUNC_ENTRY |
|
1048 |
|
1049 TInt errorCode = KErrNone; |
|
1050 iTempNameBuffer.Zero(); // Empty Local BT device name |
|
1051 |
|
1052 //Get default name if given by e.g. phone product |
|
1053 errorCode = RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothSetDeviceName, iTempNameBuffer ); |
|
1054 |
|
1055 if( errorCode || !iTempNameBuffer.Length() ) |
|
1056 { |
|
1057 errorCode = RProperty::Get( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetDeviceName, iTempNameBuffer ); |
|
1058 |
|
1059 if( errorCode || !iTempNameBuffer.Length() ) |
|
1060 { |
|
1061 RBTRegServ btRegServ; |
|
1062 RBTLocalDevice btReg; |
|
1063 TBTLocalDevice localDev; |
|
1064 |
|
1065 errorCode = btRegServ.Connect(); |
|
1066 |
|
1067 if( !errorCode ) |
|
1068 { |
|
1069 errorCode = btReg.Open( btRegServ ); |
|
1070 |
|
1071 if( !errorCode ) |
|
1072 { |
|
1073 // Read the BT local name from BT Registry. |
|
1074 errorCode = btReg.Get( localDev ); |
|
1075 |
|
1076 if( !errorCode ) |
|
1077 { |
|
1078 // The error can be > 0 if there are unconverted characters. |
|
1079 errorCode = CnvUtfConverter::ConvertToUnicodeFromUtf8( iTempNameBuffer, localDev.DeviceName() ); |
|
1080 } |
|
1081 } |
|
1082 } |
|
1083 |
|
1084 btReg.Close(); |
|
1085 btRegServ.Close(); |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 if(errorCode==KErrNone) |
|
1090 { |
|
1091 |
|
1092 // Cut the excess part of the name away. The query can handle only |
|
1093 // KBTUIMaxNameLength characters. |
|
1094 // |
|
1095 if( iTempNameBuffer.Length() > KBTUIMaxNameLength ) |
|
1096 { |
|
1097 iTempNameBuffer.SetLength( KBTUIMaxNameLength ); |
|
1098 } |
|
1099 |
|
1100 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( iTempNameBuffer ); |
|
1101 TInt keypress = dlg->ExecuteLD( R_BT_ENTER_LOCAL_NAME_QUERY ); |
|
1102 |
|
1103 if( keypress ) // User has accepted the dialog |
|
1104 { |
|
1105 // Remove trouble making control chars |
|
1106 AknTextUtils::StripCharacters(iTempNameBuffer, KAknStripListControlChars); |
|
1107 |
|
1108 iTempNameBuffer.TrimAll(); // Remove extra spaces |
|
1109 errorCode = iBtEngSettings->SetLocalName(iTempNameBuffer); |
|
1110 |
|
1111 this->SettingChangedL(EBTMainListItemNameSetting); // Redraw BT name |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 delete iIdle; iIdle = NULL; |
|
1116 TRACE_FUNC_EXIT |
|
1117 return errorCode; |
|
1118 } |
|
1119 |
|
1120 //--------------------------------------------------------------------- |
|
1121 // CBTUIMainView::GetCaption |
|
1122 //---------------------------------------------------------------------- |
|
1123 // |
|
1124 void CBTUIMainView::GetCaptionL( TDes& aCaption ) const |
|
1125 { |
|
1126 TRACE_FUNC |
|
1127 |
|
1128 // the resource file is already opened. |
|
1129 HBufC* result = StringLoader::LoadL( R_GS_BTUI_VIEW_CAPTION ); |
|
1130 aCaption.Copy( *result ); |
|
1131 delete result; |
|
1132 } |
|
1133 |
|
1134 |
|
1135 //--------------------------------------------------------------------- |
|
1136 // CBTUIMainView::CreateIconL |
|
1137 //---------------------------------------------------------------------- |
|
1138 // |
|
1139 CGulIcon* CBTUIMainView::CreateIconL( const TUid aIconType ) |
|
1140 { |
|
1141 TRACE_FUNC_ENTRY |
|
1142 |
|
1143 RefreshSettingsStatusL(); |
|
1144 CGulIcon* icon = NULL; |
|
1145 TFileName bmpFilename; |
|
1146 bmpFilename += KBitmapFileDrive; |
|
1147 bmpFilename += KDC_APP_BITMAP_DIR; |
|
1148 bmpFilename += KBtuiBmpFileName; |
|
1149 |
|
1150 if(aIconType == KGSIconTypeLbxItem) |
|
1151 { |
|
1152 |
|
1153 switch(iBtState) |
|
1154 { |
|
1155 case EBTOff: |
|
1156 icon = AknsUtils::CreateGulIconL( |
|
1157 AknsUtils::SkinInstance(), |
|
1158 KAknsIIDQgnPropSetAppsBtOff, |
|
1159 bmpFilename, |
|
1160 EMbmBtuiQgn_prop_set_apps_bt_off, |
|
1161 EMbmBtuiQgn_prop_set_apps_bt_off_mask ); |
|
1162 break; |
|
1163 case EBTOnShown: |
|
1164 icon = AknsUtils::CreateGulIconL( |
|
1165 AknsUtils::SkinInstance(), |
|
1166 KAknsIIDQgnPropSetAppsBtOnShown, |
|
1167 bmpFilename, |
|
1168 EMbmBtuiQgn_prop_set_apps_bt_on_shown, |
|
1169 EMbmBtuiQgn_prop_set_apps_bt_on_shown_mask ); |
|
1170 break; |
|
1171 case EBTOnHidden: |
|
1172 icon = AknsUtils::CreateGulIconL( |
|
1173 AknsUtils::SkinInstance(), |
|
1174 KAknsIIDQgnPropSetAppsBtOnHidden, |
|
1175 bmpFilename, |
|
1176 EMbmBtuiQgn_prop_set_apps_bt_on_hidden, |
|
1177 EMbmBtuiQgn_prop_set_apps_bt_on_hidden_mask ); |
|
1178 break; |
|
1179 case EBTConnectedShown: |
|
1180 icon = AknsUtils::CreateGulIconL( |
|
1181 AknsUtils::SkinInstance(), |
|
1182 KAknsIIDQgnPropSetAppsBtConnShown, |
|
1183 bmpFilename, |
|
1184 EMbmBtuiQgn_prop_set_apps_bt_conn_shown, |
|
1185 EMbmBtuiQgn_prop_set_apps_bt_conn_shown_mask ); |
|
1186 break; |
|
1187 case EBTConnectedHidden: |
|
1188 icon = AknsUtils::CreateGulIconL( |
|
1189 AknsUtils::SkinInstance(), |
|
1190 KAknsIIDQgnPropSetAppsBtConnHidden, |
|
1191 bmpFilename, |
|
1192 EMbmBtuiQgn_prop_set_apps_bt_conn_hidden, |
|
1193 EMbmBtuiQgn_prop_set_apps_bt_conn_hidden_mask ); |
|
1194 break; |
|
1195 } |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 icon = CGSPluginInterface::CreateIconL( aIconType ); |
|
1200 } |
|
1201 |
|
1202 return icon; |
|
1203 } |
|
1204 |
|
1205 |
|
1206 // --------------------------------------------------------------------------- |
|
1207 // CBTUIMainView::GetValue() |
|
1208 // Get 2nd row text for parent Connectivity View. |
|
1209 // --------------------------------------------------------------------------- |
|
1210 // |
|
1211 void CBTUIMainView::GetValue( const TGSPluginValueKeys aKey, TDes& aValue ) |
|
1212 { |
|
1213 TRACE_FUNC_ENTRY |
|
1214 |
|
1215 TRAP_IGNORE( GetValueL(aKey, aValue) ); |
|
1216 } |
|
1217 |
|
1218 // --------------------------------------------------------------------------- |
|
1219 // CBTUIMainView::GetValueL() |
|
1220 // --------------------------------------------------------------------------- |
|
1221 // |
|
1222 void CBTUIMainView::GetValueL( const TGSPluginValueKeys aKey, TDes& aValue ) |
|
1223 { |
|
1224 if(aKey == EGSPluginKeySettingsItemValueString) |
|
1225 { |
|
1226 HBufC* secondary = NULL; |
|
1227 RefreshSettingsStatusL(); |
|
1228 switch(iBtState) |
|
1229 { |
|
1230 case EBTOff: |
|
1231 secondary = StringLoader::LoadL( R_CP_DETAIL_BT_OFF ); |
|
1232 break; |
|
1233 case EBTOnShown: |
|
1234 secondary = StringLoader::LoadL( R_CP_DETAIL_BT_ON_SHOWN ); |
|
1235 break; |
|
1236 case EBTOnHidden: |
|
1237 secondary = StringLoader::LoadL( R_CP_DETAIL_BT_ON_HIDDEN ); |
|
1238 break; |
|
1239 case EBTConnectedShown: |
|
1240 secondary = StringLoader::LoadL( R_CP_DETAIL_BT_CONN_SHOWN ); |
|
1241 break; |
|
1242 case EBTConnectedHidden: |
|
1243 secondary = StringLoader::LoadL( R_CP_DETAIL_BT_CONN_HIDDEN ); |
|
1244 break; |
|
1245 } |
|
1246 aValue.Copy( *secondary ); |
|
1247 delete secondary; |
|
1248 } |
|
1249 } |
|
1250 |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // CBTUIMainView::CreateTabIconL() |
|
1253 // Creates icon for tab. |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // |
|
1256 CGulIcon* CBTUIMainView::CreateTabIconL() |
|
1257 { |
|
1258 TFileName bmpFilename; |
|
1259 bmpFilename += KBitmapFileDrive; |
|
1260 bmpFilename += KDC_APP_BITMAP_DIR; |
|
1261 bmpFilename += KBtuiBmpFileName; |
|
1262 |
|
1263 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
1264 AknsUtils::SkinInstance(), |
|
1265 KAknsIIDQgnPropBtSetTab3, |
|
1266 bmpFilename, |
|
1267 EMbmBtuiQgn_prop_bt_set_tab3, |
|
1268 EMbmBtuiQgn_prop_bt_set_tab3_mask ); |
|
1269 |
|
1270 return icon; |
|
1271 } |
|
1272 |
|
1273 // --------------------------------------------------------------------------- |
|
1274 // CBTUIMainView::RefreshSettingsStatusL() |
|
1275 // Get the current BT settings: power, visibility and connection. |
|
1276 // --------------------------------------------------------------------------- |
|
1277 // |
|
1278 void CBTUIMainView::RefreshSettingsStatusL() |
|
1279 { |
|
1280 |
|
1281 if ( BluetoothFeatures::EnterpriseEnablementL() == BluetoothFeatures::EDisabled ) |
|
1282 { |
|
1283 iBtState = EBTOff; |
|
1284 } |
|
1285 else |
|
1286 { |
|
1287 TBTPowerStateValue powerState; |
|
1288 iBtEngSettings->GetPowerState(powerState); |
|
1289 |
|
1290 TBTVisibilityMode currentMode; |
|
1291 iBtEngSettings->GetVisibilityMode(currentMode); |
|
1292 |
|
1293 TBool connected = TBTUIViewsCommonUtils::IsAnyDeviceConnectedL(); |
|
1294 |
|
1295 if(powerState == EBTPowerOff) |
|
1296 iBtState = EBTOff; |
|
1297 else |
|
1298 { |
|
1299 if( !connected && (currentMode == EBTVisibilityModeGeneral || |
|
1300 currentMode == EBTVisibilityModeTemporary)) |
|
1301 iBtState = EBTOnShown; |
|
1302 |
|
1303 else if(!connected && currentMode == EBTVisibilityModeHidden) |
|
1304 iBtState = EBTOnHidden; |
|
1305 |
|
1306 else if(connected && (currentMode == EBTVisibilityModeGeneral || |
|
1307 currentMode == EBTVisibilityModeTemporary)) |
|
1308 iBtState = EBTConnectedShown; |
|
1309 |
|
1310 else if(connected && currentMode == EBTVisibilityModeHidden) |
|
1311 iBtState = EBTConnectedHidden; |
|
1312 } |
|
1313 } |
|
1314 } |
|
1315 |
|
1316 // ---------------------------------------------------- |
|
1317 // CBTUIMainView::UpdateParentView |
|
1318 // |
|
1319 // Update Connectivity View when it's the current |
|
1320 // active view and the key watched is changed. |
|
1321 // ---------------------------------------------------- |
|
1322 void CBTUIMainView::UpdateParentView() |
|
1323 { |
|
1324 if(iConstructAsGsPlugin) |
|
1325 { |
|
1326 CGSParentPlugin* parent = static_cast<CGSParentPlugin*>(AppUi()->View( KGSConPluginUid )); |
|
1327 if( parent ) |
|
1328 { |
|
1329 parent->UpdateView(); |
|
1330 } |
|
1331 } |
|
1332 } |
|
1333 |
|
1334 // --------------------------------------------------------------------------- |
|
1335 // CBTUIMainView::NewContainerL |
|
1336 // Creates new iContainer. |
|
1337 // --------------------------------------------------------------------------- |
|
1338 // |
|
1339 void CBTUIMainView::NewContainerL() |
|
1340 { |
|
1341 //As a transparent view, do nothing here. |
|
1342 } |
|
1343 |
|
1344 // --------------------------------------------------------------------------- |
|
1345 // CBTUIMainView::HandleListBoxSelectionL |
|
1346 // Handle any user actions while in the list view. |
|
1347 // --------------------------------------------------------------------------- |
|
1348 // |
|
1349 void CBTUIMainView::HandleListBoxSelectionL() |
|
1350 { |
|
1351 //As a base-view, it's transparent, so do nothing here. |
|
1352 } |
|
1353 |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // CBTUIMainView::GetParentView |
|
1356 // --------------------------------------------------------------------------- |
|
1357 // |
|
1358 TVwsViewId CBTUIMainView::GetParentView() |
|
1359 { |
|
1360 return iParentView; |
|
1361 } |
|
1362 |
|
1363 // --------------------------------------------------------------------------- |
|
1364 // CBTUIMainView::TabbedViews() |
|
1365 // Returns pointer to tabbed views of application. |
|
1366 // --------------------------------------------------------------------------- |
|
1367 // |
|
1368 CArrayPtrFlat<MGSTabbedView>* CBTUIMainView::TabbedViews() |
|
1369 { |
|
1370 return iViewArray; |
|
1371 } |
|
1372 |
|
1373 |
|
1374 // --------------------------------------------------------------------------- |
|
1375 // CBTUIMainView::IsLocalNameModified |
|
1376 // Checks from central repository whether the Bluetooth friendly name |
|
1377 // has been modified . |
|
1378 // --------------------------------------------------------------------------- |
|
1379 // |
|
1380 TInt CBTUIMainView::IsLocalNameModifiedL( TBool& aStatus ) |
|
1381 { |
|
1382 TRACE_FUNC_ENTRY |
|
1383 |
|
1384 aStatus = (TBool) EBTLocalNameDefault; |
|
1385 |
|
1386 TInt val = 0; |
|
1387 CRepository* cenRep = NULL; |
|
1388 TInt err = KErrNone; |
|
1389 TRAP_IGNORE(cenRep = CRepository::NewL( KCRUidBTEngPrivateSettings )); |
|
1390 |
|
1391 err = cenRep->Get( KBTLocalNameChanged, val ); |
|
1392 |
|
1393 if ( val != 0 ) |
|
1394 { |
|
1395 aStatus = (TBool) EBTLocalNameSet; |
|
1396 } |
|
1397 delete cenRep; |
|
1398 cenRep = NULL; |
|
1399 TRACE_FUNC_EXIT |
|
1400 return err; |
|
1401 } |
|
1402 |
|