|
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 view that handles listing and |
|
15 * unblocking blocked devices view. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <avkon.hrh> // AVKON components |
|
20 #include <akntitle.h> |
|
21 #include <aknViewAppUi.h> |
|
22 #include <BtuiViewResources.rsg> // Compiled resource ids |
|
23 #include <featmgr.h> // Feature Manager |
|
24 |
|
25 #include <AknGlobalNote.h> |
|
26 #include <aknnotewrappers.h> |
|
27 #include <StringLoader.h> // Series 60 localisation stringloader |
|
28 #include <AknMediatorFacade.h> |
|
29 #include <aknmessagequerydialog.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <aknnavi.h> |
|
32 #include <hlplch.h> // Help launcher |
|
33 #include <btengdiscovery.h> // for device search |
|
34 |
|
35 #include <ctsydomainpskeys.h> |
|
36 #include <bt_subscribe.h> |
|
37 #include <btengsettings.h> |
|
38 #include <centralrepository.h> |
|
39 #include <CoreApplicationUIsSDKCRKeys.h> |
|
40 #include <bamdesca.h> |
|
41 |
|
42 #include "debug.h" |
|
43 #include "btui.h" // Global declarations |
|
44 #include "BTUIPairedDevicesView.h" |
|
45 #include "BTUIDeviceContainer.h" |
|
46 #include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h> |
|
47 #include <csxhelp/bt.hlp.hrh> // Help IDs |
|
48 |
|
49 #include <gstabhelper.h> |
|
50 #include <btui.mbg> // Tab icon for General Setting |
|
51 #include "BTUIMainView.h" // base View. |
|
52 |
|
53 const TInt KAutoConnect2ndTry = 1; |
|
54 const TUint32 SetExcludePairedDeviceMask = 0x800000; |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CBTUIPairedDevicesView::NewL |
|
60 // Two phased constructor called by BT AppUI when serve as part of btui.exe |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 CBTUIPairedDevicesView* CBTUIPairedDevicesView::NewL(MBtuiPluginViewActivationObserver* aObserver) |
|
64 { |
|
65 CBTUIPairedDevicesView* self = new (ELeave) CBTUIPairedDevicesView(aObserver); |
|
66 CleanupStack::PushL(self); |
|
67 |
|
68 self->iConstructAsGsPlugin = EFalse; |
|
69 self->ConstructL(); |
|
70 CleanupStack::Pop(self); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CBTUIPairedDevicesView::NewLC |
|
76 // Two phased constructor called by mainView when serve as GS Plugin. |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CBTUIPairedDevicesView* CBTUIPairedDevicesView::NewLC(CBTUIMainView* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray) |
|
80 { |
|
81 CBTUIPairedDevicesView* self = new (ELeave) CBTUIPairedDevicesView(); |
|
82 CleanupStack::PushL( self ); |
|
83 |
|
84 self->iConstructAsGsPlugin = ETrue; |
|
85 self->ConstructL( aBaseView, aTabViewArray ); |
|
86 |
|
87 return self; |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------- |
|
92 // CBTUIPairedDevicesView::ConstructL |
|
93 // Symbian 2nd phase constructor can leave. |
|
94 // --------------------------------------------------------- |
|
95 // |
|
96 void CBTUIPairedDevicesView::ConstructL() |
|
97 { |
|
98 TRACE_FUNC_ENTRY |
|
99 |
|
100 BaseConstructL(R_BTUI_OTHER_DEVICES_VIEW); |
|
101 |
|
102 iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); |
|
103 iHelpEnabled = FeatureManager::FeatureSupported(KFeatureIdHelp); |
|
104 |
|
105 iDeviceSearcher = CBTEngDiscovery::NewL(this); |
|
106 iBtEngSettings = CBTEngSettings::NewL(this); |
|
107 iBTPluginMan = CBTUIPluginMan::NewL( AppUi() ); |
|
108 iIsAlreadyConnected = EFalse; |
|
109 iExpectedCallBack = 0; |
|
110 TRACE_INFO(_L("Initial iIsAlreadyConnected -> False")) |
|
111 TRACE_FUNC_EXIT |
|
112 } |
|
113 |
|
114 void CBTUIPairedDevicesView::ConstructL( CBTUIMainView* aBaseView, CArrayPtrFlat<MGSTabbedView>* aTabViewArray ) |
|
115 { |
|
116 TRACE_FUNC_ENTRY |
|
117 |
|
118 iBaseView = aBaseView, |
|
119 iTabHelper = CGSTabHelper::NewL(); |
|
120 aTabViewArray->AppendL(this); |
|
121 |
|
122 BaseConstructL(R_BTUI_OTHER_DEVICES_VIEW_GS); |
|
123 iCoverDisplayEnabled = FeatureManager::FeatureSupported(KFeatureIdCoverDisplay); |
|
124 iHelpEnabled = FeatureManager::FeatureSupported(KFeatureIdHelp); |
|
125 |
|
126 iDeviceSearcher = CBTEngDiscovery::NewL(this); |
|
127 iBtEngSettings=CBTEngSettings::NewL(this); |
|
128 iBTPluginMan = CBTUIPluginMan::NewL( AppUi() ); |
|
129 iIsAlreadyConnected = EFalse; |
|
130 TRACE_INFO(_L("Initial iIsAlreadyConnected = False")) |
|
131 iExpectedCallBack = 0; |
|
132 |
|
133 TRACE_FUNC_EXIT |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // CBTUIBlockedDevicesView::CBTUIBlockedDevicesView |
|
138 // --------------------------------------------------------- |
|
139 |
|
140 CBTUIPairedDevicesView::CBTUIPairedDevicesView( MBtuiPluginViewActivationObserver* aObserver ) |
|
141 : iActivationObserver(aObserver) |
|
142 { |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------- |
|
146 // Destructor |
|
147 // --------------------------------------------------------- |
|
148 // |
|
149 CBTUIPairedDevicesView::~CBTUIPairedDevicesView() |
|
150 { |
|
151 TRACE_FUNC_ENTRY |
|
152 |
|
153 //close dialogs if any |
|
154 TRAP_IGNORE( |
|
155 DialogDismissedL(EAknSoftkeyCancel); |
|
156 ); |
|
157 |
|
158 delete iActive; |
|
159 |
|
160 if (iContainer) |
|
161 { |
|
162 AppUi()->RemoveFromViewStack(*this, iContainer); |
|
163 delete iContainer; |
|
164 iContainer = NULL; |
|
165 } |
|
166 |
|
167 if(iDeviceSearcher) |
|
168 { |
|
169 // Canceling devicesearches is done by DialogDismissedL(), |
|
170 // so it is not done here |
|
171 delete iDeviceSearcher; |
|
172 iDeviceSearcher = NULL ; |
|
173 } |
|
174 delete iConnectDevice; |
|
175 iConnectDevice=NULL; |
|
176 |
|
177 delete iPairingDevice; |
|
178 delete iBtEngSettings; |
|
179 delete iBTPluginMan; |
|
180 |
|
181 if(iConstructAsGsPlugin) |
|
182 delete iTabHelper; |
|
183 |
|
184 TRACE_FUNC_EXIT |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------- |
|
188 // From CAknView |
|
189 // CBTUIPairedDevicesView::Id |
|
190 // --------------------------------------------------------- |
|
191 // |
|
192 TUid CBTUIPairedDevicesView::Id() const |
|
193 { |
|
194 TRACE_FUNC_ENTRY |
|
195 return KBtuiPluginUidPairedDevicesView;//KBTOtherDevicesViewId; |
|
196 } |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 // --------------------------------------------------------- |
|
202 // From CAknView |
|
203 // CBTUIPairedDevicesView::HandleCommandL |
|
204 // Redirects commands to the appui class. |
|
205 // --------------------------------------------------------- |
|
206 // |
|
207 void CBTUIPairedDevicesView::HandleCommandL(TInt aCommand) |
|
208 { |
|
209 TRACE_FUNC_ENTRY |
|
210 |
|
211 switch (aCommand) |
|
212 { |
|
213 |
|
214 case EAknSoftkeyBack: |
|
215 // do not exit if devicechange is in progress. |
|
216 if(iModel->DeviceChangeInProgress() ) |
|
217 return; |
|
218 AppUi()->ActivateLocalViewL(iBaseView->GetParentView().iViewUid ); |
|
219 break; |
|
220 |
|
221 case EAknSoftkeyExit: |
|
222 { |
|
223 TRACE_INFO(_L("EAknSoftkeyExit")) |
|
224 // do not exit if devicechange or bt discovery is in progress. |
|
225 if(iModel->DeviceChangeInProgress() |
|
226 || iSearchOngoing ) |
|
227 { |
|
228 TRACE_INFO(_L("exit denied, due to operation")) |
|
229 return; |
|
230 } |
|
231 |
|
232 TRACE_INFO(_L("exit in progress")) |
|
233 AppUi()->ProcessCommandL(EEikCmdExit); |
|
234 break; |
|
235 } |
|
236 |
|
237 case EAknCmdHelp: |
|
238 { |
|
239 #ifdef __SERIES60_HELP |
|
240 HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(),AppUi()->AppHelpContextL()); |
|
241 #endif |
|
242 break; |
|
243 } |
|
244 |
|
245 case EBTUICmdNewPairedDevice: |
|
246 { |
|
247 iSearchOngoing=ETrue; |
|
248 NewPairedDeviceDlgL(); |
|
249 break; |
|
250 } |
|
251 |
|
252 case EBTUICmdDelete: |
|
253 { |
|
254 DeleteDeviceDlgL(); |
|
255 break; |
|
256 } |
|
257 |
|
258 case EBTUICmdDeleteAll: |
|
259 { |
|
260 DeleteAllDevicesDlgL(); |
|
261 break; |
|
262 } |
|
263 |
|
264 case EBTUICmdGiveNickname: |
|
265 { |
|
266 RenameDeviceDlgL(); |
|
267 break; |
|
268 } |
|
269 |
|
270 case EBTUICmdSetTrusted: |
|
271 { |
|
272 ChangeDeviceSecurityL(ETrue); |
|
273 break; |
|
274 } |
|
275 |
|
276 case EBTUICmdSetUnTrusted: |
|
277 { |
|
278 ChangeDeviceSecurityL(EFalse); |
|
279 break; |
|
280 } |
|
281 |
|
282 case EBTUICmdConnect: |
|
283 case EBTUICmdConnectAudio: |
|
284 { |
|
285 TBTDevice device; |
|
286 device.iIndex = iContainer->CurrentItemIndex(); |
|
287 iModel->GetDevice(device); |
|
288 device.iOperation = EOpConnect; |
|
289 ConnectL( device, ETrue ); |
|
290 break; |
|
291 } |
|
292 |
|
293 case EBTUICmdDisconnect: |
|
294 { |
|
295 DisconnectL(); |
|
296 break; |
|
297 } |
|
298 |
|
299 case EBTUICmdSetBlocked: |
|
300 { |
|
301 BlockDeviceDlgL(); |
|
302 break; |
|
303 } |
|
304 |
|
305 case EBTUICmdSettings: |
|
306 { |
|
307 LaunchSettingViewL(); |
|
308 break; |
|
309 } |
|
310 |
|
311 default: |
|
312 { |
|
313 AppUi()->HandleCommandL(aCommand); |
|
314 break; |
|
315 } |
|
316 } |
|
317 TRACE_FUNC_EXIT |
|
318 } |
|
319 |
|
320 |
|
321 // --------------------------------------------------------- |
|
322 // From CAknView |
|
323 // CBTUIPairedDevicesView::DoActivateL |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 void CBTUIPairedDevicesView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, |
|
327 TUid /*aCustomMessageId*/, |
|
328 const TDesC8& /*aCustomMessage*/) |
|
329 { |
|
330 TRACE_FUNC_ENTRY |
|
331 |
|
332 iModel = CBTDevModel::NewL(EGroupPaired, this); |
|
333 iContainer = CBTUiDeviceContainer::NewL(ClientRect(), this, EGroupPaired, this); |
|
334 iContainer->SetMopParent(this); // MObjectProvider |
|
335 |
|
336 // Setup title |
|
337 HBufC* btTitlePairedDevices = |
|
338 iCoeEnv->AllocReadResourceLC(R_BT_TITLE_PAIRED_DEV); |
|
339 CEikStatusPane* statusPane = StatusPane(); |
|
340 CAknTitlePane* titlePane; |
|
341 titlePane = (CAknTitlePane*) statusPane->ControlL( |
|
342 TUid::Uid(EEikStatusPaneUidTitle)); |
|
343 titlePane->SetTextL(btTitlePairedDevices->Des()); |
|
344 CleanupStack::PopAndDestroy(btTitlePairedDevices); // btTitlePairedDevices |
|
345 btTitlePairedDevices = NULL; |
|
346 |
|
347 AppUi()->AddToStackL(*this, iContainer); |
|
348 |
|
349 if( iBaseView && iConstructAsGsPlugin) |
|
350 { |
|
351 iTabHelper->CreateTabGroupL( Id(), |
|
352 static_cast<CArrayPtrFlat<MGSTabbedView>*> |
|
353 (iBaseView->TabbedViews()) ); |
|
354 } |
|
355 |
|
356 // MSK menu is added here. |
|
357 // the left key menu is added by resources. |
|
358 MenuBar()->SetContextMenuTitleResourceId( |
|
359 R_BTUI_MENUBAR_OTHER_DEVICES_VIEW_CONTEXT); |
|
360 // notify observer |
|
361 if( iActivationObserver && iConstructAsGsPlugin == EFalse) |
|
362 { |
|
363 iActivationObserver->PluginViewActivated(EPairedDevicesViewId); |
|
364 } |
|
365 |
|
366 TRACE_FUNC_EXIT |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------- |
|
370 // From CAknView |
|
371 // CBTUIPairedDevicesView::DoDeactivate |
|
372 // --------------------------------------------------------- |
|
373 // |
|
374 void CBTUIPairedDevicesView::DoDeactivate() |
|
375 { |
|
376 TRACE_FUNC_ENTRY |
|
377 |
|
378 if (iContainer) |
|
379 { |
|
380 AppUi()->RemoveFromStack(iContainer); |
|
381 delete iContainer; |
|
382 iContainer = NULL; |
|
383 } |
|
384 if ( iDeviceSearcher ) |
|
385 { |
|
386 iDeviceSearcher->CancelSearchRemoteDevice(); |
|
387 } |
|
388 delete iModel; |
|
389 iModel=NULL; |
|
390 if(iConstructAsGsPlugin) |
|
391 iTabHelper->RemoveTabGroup(); |
|
392 delete iActive; |
|
393 iActive = NULL; |
|
394 iIsPairConnect = EFalse; |
|
395 TRACE_FUNC_EXIT |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------- |
|
399 // From CAknView |
|
400 // CBTUIPairedDevicesView::DynInitMenuPaneL |
|
401 // Shows only options supported for selected device, if any. |
|
402 // If not show only options supported regardless of selected |
|
403 // device |
|
404 // --------------------------------------------------------- |
|
405 // |
|
406 void CBTUIPairedDevicesView::DynInitMenuPaneL(TInt aResId, CEikMenuPane* aMenu) |
|
407 { |
|
408 TRACE_FUNC_ENTRY |
|
409 iActiveMenuPane = aMenu; |
|
410 // dim help if it exists and is not supported |
|
411 TInt tmp; |
|
412 if ( aMenu->MenuItemExists(EAknCmdHelp,tmp ) ) |
|
413 { |
|
414 aMenu->SetItemDimmed(EAknCmdHelp, |
|
415 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
416 } |
|
417 |
|
418 if ( aResId == R_BTUI_OTHER_DEVICES_VIEW_MENU ) |
|
419 { |
|
420 TInt index = iContainer->CurrentItemIndex(); |
|
421 |
|
422 // we only show "new pair device", "help" , "Exit" and "Delete All" if view contains device(s). |
|
423 aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); |
|
424 aMenu->SetItemDimmed(EBTUICmdDelete,ETrue); |
|
425 aMenu->SetItemDimmed(EBTUICmdSetTrusted,ETrue); |
|
426 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted,ETrue); |
|
427 aMenu->SetItemDimmed(EBTUICmdConnect,ETrue); |
|
428 aMenu->SetItemDimmed(EBTUICmdConnectAudio,ETrue); |
|
429 aMenu->SetItemDimmed(EBTUICmdDisconnect,ETrue); |
|
430 aMenu->SetItemDimmed(EBTUICmdSetBlocked,ETrue); |
|
431 aMenu->SetItemDimmed(EBTUICmdSettings,ETrue); |
|
432 aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); |
|
433 |
|
434 if ( index < 0 ) // No devices at list. Hide all device related commands. |
|
435 { |
|
436 aMenu->SetItemDimmed(EBTUICmdDeleteAll, ETrue); |
|
437 } |
|
438 |
|
439 } |
|
440 |
|
441 if ( aResId == R_BTUI_OTHER_DEVICES_VIEW_MENU_CONTEXT ) |
|
442 { |
|
443 TInt index = iContainer->CurrentItemIndex(); |
|
444 |
|
445 // If user is fast enough to click the RSK option between |
|
446 // bt discovery view and device found view, bt ui will crash. |
|
447 // Therefore, we disable commands if bt discovery is onging. |
|
448 // |
|
449 if(iSearchOngoing) |
|
450 { |
|
451 aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); |
|
452 aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); |
|
453 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, ETrue); |
|
454 aMenu->SetItemDimmed(EBTUICmdSetBlocked, ETrue); |
|
455 aMenu->SetItemDimmed(EBTUICmdDelete, ETrue); |
|
456 aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); |
|
457 aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); |
|
458 aMenu->SetItemDimmed(EBTUICmdDisconnect, ETrue); |
|
459 aMenu->SetItemDimmed(EBTUICmdNewPairedDevice, ETrue); |
|
460 return; |
|
461 } |
|
462 |
|
463 if(index < 0) // No devices at list. Hide all device related commands. |
|
464 { |
|
465 TRACE_INFO(_L("no devices in list")) |
|
466 |
|
467 aMenu->SetItemDimmed(EBTUICmdGiveNickname, ETrue); |
|
468 aMenu->SetItemDimmed(EBTUICmdSetTrusted, ETrue); |
|
469 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, ETrue); |
|
470 aMenu->SetItemDimmed(EBTUICmdSetBlocked, ETrue); |
|
471 aMenu->SetItemDimmed(EBTUICmdDelete, ETrue); |
|
472 aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); |
|
473 aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); |
|
474 aMenu->SetItemDimmed(EBTUICmdDisconnect, ETrue); |
|
475 aMenu->SetItemDimmed(EBTUICmdSettings, ETrue); |
|
476 } |
|
477 else // There are devices at list |
|
478 { |
|
479 TBTDevice device; |
|
480 device.iIndex = index; |
|
481 iModel->GetDevice(device); |
|
482 iMenuDevice = device; |
|
483 |
|
484 TRACE_INFO(_L("there are device in list")) |
|
485 |
|
486 TBool dim = (device.iStatus & EStatusTrusted) == EStatusTrusted; |
|
487 |
|
488 aMenu->SetItemDimmed(EBTUICmdSetTrusted, dim); |
|
489 aMenu->SetItemDimmed(EBTUICmdSetUnTrusted, !dim); |
|
490 |
|
491 // Check if device can be connected or disconnected |
|
492 dim = (! (device.iStatus & EStatusConnectable) |
|
493 || device.iStatus & EStatusBtuiConnected); |
|
494 |
|
495 if (dim) |
|
496 { |
|
497 aMenu->SetItemDimmed(EBTUICmdConnect, dim); |
|
498 aMenu->SetItemDimmed(EBTUICmdConnectAudio, dim); |
|
499 } |
|
500 else |
|
501 { |
|
502 if ( device.iDeviceClass.MajorDeviceClass() == EMajorDeviceComputer) |
|
503 { |
|
504 aMenu->SetItemDimmed(EBTUICmdConnect, ETrue); |
|
505 } |
|
506 else |
|
507 { |
|
508 aMenu->SetItemDimmed(EBTUICmdConnectAudio, ETrue); |
|
509 } |
|
510 } |
|
511 dim = (device.iStatus & EStatusBtuiConnected) != EStatusBtuiConnected; |
|
512 aMenu->SetItemDimmed(EBTUICmdDisconnect, dim); |
|
513 |
|
514 if ( !iBTPluginMan->IsPluginAvaiable(device.iDeviceClass) ) |
|
515 { |
|
516 aMenu->SetItemDimmed(EBTUICmdSettings, ETrue); |
|
517 } |
|
518 else |
|
519 { |
|
520 dim = (device.iStatus & EStatusBtuiConnected) != EStatusBtuiConnected; |
|
521 aMenu->SetItemDimmed(EBTUICmdSettings, dim); |
|
522 } |
|
523 //Hide New pair device |
|
524 aMenu->SetItemDimmed(EBTUICmdNewPairedDevice, ETrue); |
|
525 } |
|
526 } |
|
527 TRACE_FUNC_EXIT |
|
528 } |
|
529 |
|
530 |
|
531 // ---------------------------------------------------------- |
|
532 // CBTUIPairedDevicesView::RenameDeviceDlgL |
|
533 // ---------------------------------------------------------- |
|
534 // |
|
535 void CBTUIPairedDevicesView::RenameDeviceDlgL() |
|
536 { |
|
537 TRACE_FUNC_ENTRY |
|
538 |
|
539 TInt index = iContainer->CurrentItemIndex(); |
|
540 if(index == KErrNotFound) return; |
|
541 |
|
542 TBTDevice device; |
|
543 device.iIndex = index; |
|
544 iModel->GetDevice(device); |
|
545 TBTDeviceName name = device.iName; |
|
546 |
|
547 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(device.iName); |
|
548 TInt keypress = dlg->ExecuteLD(R_BT_ENTER_NICKNAME_QUERY); |
|
549 |
|
550 if(keypress) // User has accepted the dialog |
|
551 { |
|
552 if(device.iName != name) // Check if the user really changed the name |
|
553 { |
|
554 device.iOperation = EOpChangeName; |
|
555 // Remove trouble making control chars |
|
556 AknTextUtils::StripCharacters(device.iName, KAknStripListControlChars); |
|
557 device.iName.TrimAll(); // Remove extra spaces |
|
558 iModel->ChangeDevice(device); |
|
559 } |
|
560 } |
|
561 TRACE_FUNC_EXIT |
|
562 } |
|
563 |
|
564 |
|
565 // ---------------------------------------------------------- |
|
566 // CBTUIPairedDevicesView::NewPairedDeviceDlgL |
|
567 // |
|
568 // Initiate bonding (pairing) by opening the search dialog. |
|
569 // DeviceSearchComplete is called after that. |
|
570 // ---------------------------------------------------------- |
|
571 // |
|
572 void CBTUIPairedDevicesView::NewPairedDeviceDlgL() |
|
573 { |
|
574 TRACE_FUNC_ENTRY |
|
575 // we must not have other pairing in progress. |
|
576 // we maight issue an error, but none is defined by |
|
577 // ui spec. Anyhow this should be possible |
|
578 // only by pressing everything roo rapidly. |
|
579 if(iPairingDevice!=NULL) |
|
580 return; |
|
581 iPairingDevice = CBTDevice::NewL(); |
|
582 |
|
583 // Here we use last bit in device class to inform bt inquiry notifier |
|
584 // not to display the device which is already paired and in the paired |
|
585 // device list. |
|
586 |
|
587 // We use DeviceClass to tell btnotif not to show paired device in |
|
588 // bt discovery notifier through bteng. |
|
589 // Set bit 24 to 1 ( bit 24 is not used for any other purpose currently ) |
|
590 iPairingDevice->SetDeviceClass(iPairingDevice->DeviceClass().DeviceClass() | SetExcludePairedDeviceMask ); |
|
591 TInt err = iDeviceSearcher->SearchRemoteDevice(iPairingDevice, |
|
592 &iPairingDevNameEntry, |
|
593 iPairingDevice->DeviceClass().DeviceClass()); |
|
594 |
|
595 |
|
596 if(err != KErrNone) |
|
597 { |
|
598 delete iPairingDevice; |
|
599 iPairingDevice=NULL; |
|
600 TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); |
|
601 } |
|
602 TRACE_FUNC_EXIT |
|
603 } |
|
604 |
|
605 // ---------------------------------------------------------- |
|
606 // CBTUIPairedDevicesView::DeleteDeviceDlgL |
|
607 // ---------------------------------------------------------- |
|
608 // |
|
609 void CBTUIPairedDevicesView::DeleteDeviceDlgL() |
|
610 { |
|
611 TRACE_FUNC_ENTRY |
|
612 |
|
613 iExpectedCallBack = 0; |
|
614 TInt index = iContainer->CurrentItemIndex(); |
|
615 if(index == KErrNotFound) return; |
|
616 |
|
617 TBTDevice device; |
|
618 device.iIndex = index; |
|
619 iModel->GetDevice(device); |
|
620 |
|
621 HBufC* stringholder = NULL; |
|
622 |
|
623 TInt tmp=EStatusBtuiConnected|EStatusPhysicallyConnected; |
|
624 // Choose confirmation phrase |
|
625 // |
|
626 if ( device.iStatus & tmp ) |
|
627 { |
|
628 stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE_CONNECTED, |
|
629 device.iName); |
|
630 } |
|
631 else |
|
632 { |
|
633 stringholder = StringLoader::LoadLC(R_BT_WARN_ERASE, device.iName ); |
|
634 } |
|
635 |
|
636 // Create confirmation query |
|
637 // |
|
638 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
639 |
|
640 if(iCoverDisplayEnabled) |
|
641 { |
|
642 CleanupStack::PushL(dlg); |
|
643 dlg->PublishDialogL(ECmdShowBtWarnEraseNote, KUidCoverUiCategoryBtui); |
|
644 // initializes cover support |
|
645 CleanupStack::Pop(dlg); |
|
646 |
|
647 CAknMediatorFacade* covercl = AknMediatorFacade(dlg); // uses MOP, so control provided |
|
648 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
649 { |
|
650 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName) ;// takes copy so consts are ok too |
|
651 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
652 } |
|
653 } |
|
654 TInt keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_QUERY, *stringholder); |
|
655 |
|
656 CleanupStack::PopAndDestroy(stringholder); // stringholder |
|
657 |
|
658 if(keypress) // User has accepted the dialog |
|
659 { |
|
660 // If device is connected we need to first to disconnect |
|
661 // then unpair, otherwise unpairing does not succeed. |
|
662 if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) |
|
663 { |
|
664 iExpectedCallBack++; |
|
665 DisconnectWithoutQuery(); |
|
666 return; |
|
667 } |
|
668 device.iOperation = EOpUnpair; |
|
669 iModel->ChangeDevice(device); |
|
670 } |
|
671 |
|
672 TRACE_FUNC_EXIT |
|
673 } |
|
674 |
|
675 // ---------------------------------------------------------- |
|
676 // CBTUIPairedDevicesView::DeleteAllDevicesDlgL |
|
677 // ---------------------------------------------------------- |
|
678 // |
|
679 void CBTUIPairedDevicesView::DeleteAllDevicesDlgL() |
|
680 { |
|
681 TRACE_FUNC_ENTRY |
|
682 |
|
683 iExpectedCallBack = 0; |
|
684 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
685 TInt keypress = KErrNone; |
|
686 |
|
687 CleanupStack::PushL(dlg); |
|
688 |
|
689 // Choose and execute confirmation query |
|
690 // |
|
691 if (iModel->IsAnyDeviceConnected()) |
|
692 { |
|
693 if(iCoverDisplayEnabled) |
|
694 { |
|
695 dlg->PublishDialogL(ECmdShowBtWarnEraseAllConnectedQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
696 } |
|
697 |
|
698 keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_ALL_CONNECTED_QUERY); |
|
699 } |
|
700 else |
|
701 { |
|
702 if(iCoverDisplayEnabled) |
|
703 { |
|
704 dlg->PublishDialogL(ECmdShowBtWarnEraseAllQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
705 } |
|
706 |
|
707 keypress = dlg->ExecuteLD(R_BT_WARN_ERASE_ALL_QUERY); |
|
708 } |
|
709 CleanupStack::Pop(dlg); |
|
710 |
|
711 if(keypress) // User has accepted the dialog |
|
712 { |
|
713 TInt count = iContainer->CountItems(); |
|
714 for (TInt i = 0; i < count; i++) |
|
715 { |
|
716 // If device is connected we need to first to disconnect |
|
717 // then unpair, otherwise unpairing does not succeed. |
|
718 TBTDevice device; |
|
719 device.iIndex = i; |
|
720 iModel->GetDevice(device); |
|
721 if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) |
|
722 { |
|
723 iExpectedCallBack++; |
|
724 } |
|
725 } |
|
726 TRACE_INFO((_L("iExpectedCallBack %d"), iExpectedCallBack )) |
|
727 |
|
728 for (TInt i = 0; i < count; i++) |
|
729 { |
|
730 // If device is connected we need to first to disconnect |
|
731 // then unpair, otherwise unpairing does not succeed. |
|
732 TBTDevice device; |
|
733 device.iIndex = i; |
|
734 iModel->GetDevice(device); |
|
735 |
|
736 if((device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected) |
|
737 { |
|
738 //disconnect it first, removal will be done in |
|
739 //callback NotifyChangeDeviceCompleteL for ChangeDevice() below |
|
740 TRACE_INFO((_L("EOpDisconnect issued for %d"), i )) |
|
741 device.iOperation = EOpDisconnect; |
|
742 iModel->ChangeDevice(device); |
|
743 } |
|
744 else |
|
745 { |
|
746 //otherwise, just remove it from the paired view |
|
747 device.iOperation = EOpUnpair; |
|
748 iModel->ChangeDevice(device); |
|
749 } |
|
750 } |
|
751 } |
|
752 |
|
753 TRACE_FUNC_EXIT |
|
754 } |
|
755 // ---------------------------------------------------------- |
|
756 // CBTUIPairedDevicesView::BlockDeviceDlgL |
|
757 // ---------------------------------------------------------- |
|
758 void CBTUIPairedDevicesView::BlockDeviceDlgL() |
|
759 { |
|
760 TRACE_FUNC_ENTRY |
|
761 |
|
762 TInt index = iContainer->CurrentItemIndex(); |
|
763 if(index == KErrNotFound) return; |
|
764 |
|
765 TBTDevice device; |
|
766 device.iIndex = index; |
|
767 iModel->GetDevice(device); |
|
768 |
|
769 //check if this is connected device |
|
770 |
|
771 HBufC* header= iCoeEnv->AllocReadResourceLC(R_BT_OPTION_BLOCK_DEVICE_HEADER); |
|
772 |
|
773 HBufC* stringHolder = NULL; |
|
774 if (device.iStatus & (EStatusBtuiConnected|EStatusPhysicallyConnected) ) |
|
775 stringHolder = StringLoader::LoadLC( |
|
776 (iHelpEnabled? R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_HELP: |
|
777 R_BT_OPTION_BLOCK_CONNECTED_PAIRED_DEVICES_NOHELP ), |
|
778 device.iName); |
|
779 else |
|
780 stringHolder = StringLoader::LoadLC( |
|
781 (iHelpEnabled?R_BT_OPTION_BLOCK_PAIRED_DEVICE_HELP:R_BT_OPTION_BLOCK_PAIRED_DEVICE_NOHELP), |
|
782 device.iName); |
|
783 |
|
784 |
|
785 CAknMessageQueryDialog *queryDialog = CAknMessageQueryDialog::NewL (*stringHolder, |
|
786 CAknQueryDialog::EConfirmationTone); |
|
787 queryDialog->PrepareLC(R_BT_MESSAGE_QUERY); |
|
788 |
|
789 (queryDialog)->Heading()->SetTextL(*header); |
|
790 queryDialog->SetFocus(ETrue); |
|
791 |
|
792 TInt keypress=EFalse; |
|
793 #ifdef __SERIES60_HELP |
|
794 if (iHelpEnabled) |
|
795 { |
|
796 HBufC* queryLink = StringLoader::LoadL(R_BT_BLOCK_DEVICE_LINK); |
|
797 TCoeHelpContext hc(KBtuiUid3,KBT_HLP_BLOCKED); |
|
798 TCallBack helpCallBack(CBTUIPairedDevicesView::LaunchHelp , &hc); |
|
799 |
|
800 TRAPD(err, |
|
801 static_cast<CAknMessageQueryDialog*>(queryDialog)->SetLinkTextL(*queryLink); |
|
802 static_cast<CAknMessageQueryDialog*>(queryDialog)->SetLink(helpCallBack);); |
|
803 if(err==KErrNone) |
|
804 { |
|
805 keypress = queryDialog->RunLD(); |
|
806 } |
|
807 |
|
808 delete queryLink; |
|
809 queryLink = NULL; |
|
810 } |
|
811 else |
|
812 #endif |
|
813 { |
|
814 keypress = queryDialog->RunLD(); |
|
815 } |
|
816 |
|
817 CleanupStack::PopAndDestroy(stringHolder); |
|
818 CleanupStack::PopAndDestroy(header); |
|
819 |
|
820 if(keypress) |
|
821 { |
|
822 device.iOperation = EOpBlock; |
|
823 iModel->ChangeDevice(device); |
|
824 } |
|
825 TRACE_FUNC_EXIT |
|
826 } |
|
827 // ---------------------------------------------------------- |
|
828 // CBTUIPairedDevicesView::ChangeDeviceSecurityL |
|
829 // ---------------------------------------------------------- |
|
830 // |
|
831 void CBTUIPairedDevicesView::ChangeDeviceSecurityL(TBool aTrusted) |
|
832 { |
|
833 TRACE_FUNC_ENTRY |
|
834 |
|
835 TInt index = iContainer->CurrentItemIndex(); |
|
836 if(index == KErrNotFound) return; |
|
837 |
|
838 TBTDevice device; |
|
839 device.iIndex = index; |
|
840 iModel->GetDevice(device); |
|
841 |
|
842 if(aTrusted) |
|
843 { |
|
844 // set to trusted |
|
845 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
846 |
|
847 if(iCoverDisplayEnabled) |
|
848 { |
|
849 CleanupStack::PushL(dlg); |
|
850 dlg->PublishDialogL(ECmdShowBtAuthConfirmQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
851 CleanupStack::Pop(dlg); |
|
852 } |
|
853 TInt keypress = dlg->ExecuteLD(R_BT_SET_TRUSTED_QUERY); |
|
854 |
|
855 if(keypress) // User has accepted the dialog |
|
856 { |
|
857 device.iOperation = EOpTrust; |
|
858 iModel->ChangeDevice(device); |
|
859 } |
|
860 } |
|
861 else |
|
862 { |
|
863 device.iOperation = EOpUntrust; |
|
864 iModel->ChangeDevice(device); |
|
865 } |
|
866 TRACE_FUNC_EXIT |
|
867 } |
|
868 |
|
869 // ---------------------------------------------------- |
|
870 // CBTUIMainView::VisibilityModeChanged |
|
871 // ---------------------------------------------------- |
|
872 // |
|
873 void CBTUIPairedDevicesView::VisibilityModeChanged( TBTVisibilityMode ) |
|
874 { |
|
875 TRACE_FUNC_ENTRY |
|
876 |
|
877 |
|
878 TRACE_FUNC_EXIT |
|
879 } |
|
880 |
|
881 |
|
882 // ---------------------------------------------------- |
|
883 // CBTUIMainView::PowerStateChanged |
|
884 // ---------------------------------------------------- |
|
885 // |
|
886 void CBTUIPairedDevicesView::PowerStateChanged( TBTPowerStateValue ) |
|
887 { |
|
888 TRACE_FUNC_ENTRY |
|
889 |
|
890 if ( iIsConnectDevice ) |
|
891 { |
|
892 iModel->ChangeDevice(*iConnectDevice); |
|
893 iIsConnectDevice = EFalse; // reset flag |
|
894 } |
|
895 |
|
896 TRACE_FUNC_EXIT |
|
897 } |
|
898 |
|
899 // ---------------------------------------------------------- |
|
900 // CBTUIPairedDevicesView::ConnectL |
|
901 // ---------------------------------------------------------- |
|
902 // |
|
903 void CBTUIPairedDevicesView::ConnectL( |
|
904 const TBTDevice& aDevice, TBool aNewWaitNote ) |
|
905 { |
|
906 TRACE_FUNC_ENTRY |
|
907 |
|
908 iIsAlreadyConnected = EFalse; |
|
909 TRACE_INFO(_L("Set iIsAlreadyConnected -> False")) |
|
910 //Check that there is not more than max amount of connections allready. |
|
911 TInt connNum = 0; |
|
912 RProperty::Get(KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount, connNum); |
|
913 if(connNum > KBtUiMaxConnections) |
|
914 { |
|
915 ConnectCompleteL(KErrServerBusy, aDevice); |
|
916 } |
|
917 else if(CallOnGoing()&& connNum > 1) |
|
918 { |
|
919 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::ENoTone, |
|
920 CAknNoteDialog::ELongTimeout); |
|
921 if(iCoverDisplayEnabled) |
|
922 { |
|
923 CleanupStack::PushL(dlg); |
|
924 dlg->PublishDialogL(ECmdShowBtImpossibleIncallNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
925 CleanupStack::Pop(dlg); |
|
926 } |
|
927 |
|
928 dlg->ExecuteLD(R_BT_NOT_INCALL_NOTE); |
|
929 } |
|
930 else |
|
931 { |
|
932 if(TBTUIViewsCommonUtils::TurnBTOnIfNeededL(iBtEngSettings,iCoverDisplayEnabled)!= KErrNone) |
|
933 return; |
|
934 |
|
935 TInt errorCode = KErrNone; |
|
936 TBTPowerStateValue currentPowerMode; |
|
937 errorCode=iBtEngSettings->GetPowerState(currentPowerMode); |
|
938 |
|
939 if(errorCode) |
|
940 { |
|
941 // handle the error code |
|
942 return; |
|
943 } |
|
944 if ( aNewWaitNote ) |
|
945 { |
|
946 // Launch wait note |
|
947 OpenWaitNoteL(iWaitForConnectDlg,R_BT_CONNECTING_TO_WAIT_NOTE,R_BT_CONNECTING_TO , |
|
948 ECmdShowBtWaitConnectingToNote,aDevice.iName); |
|
949 } |
|
950 iConnectDevice=new(ELeave) TBTDevice(aDevice); |
|
951 iConnectDevice->iOperation=EOpConnect; |
|
952 |
|
953 if( currentPowerMode == EBTPowerOff ) |
|
954 { |
|
955 // turn on the flag IsConnectDevice |
|
956 // |
|
957 iIsConnectDevice = ETrue; |
|
958 } |
|
959 else |
|
960 { |
|
961 // connect device |
|
962 // |
|
963 iModel->ChangeDevice(*iConnectDevice); |
|
964 |
|
965 // reset IsConnectDevice flag |
|
966 iIsConnectDevice = EFalse; |
|
967 } |
|
968 } |
|
969 TRACE_FUNC_EXIT |
|
970 } |
|
971 |
|
972 // ---------------------------------------------------------- |
|
973 // CBTUIPairedDevicesView::OpenWaitNoteL |
|
974 // ---------------------------------------------------------- |
|
975 void CBTUIPairedDevicesView::OpenWaitNoteL(CAknWaitDialog*& aWaitDialog,TUint aNoteResource,TUint aNoteTextResource, |
|
976 TSecondaryDisplayBtuiDialogs aSec,const TDesC& aDevName) |
|
977 { |
|
978 TRAPD(err, |
|
979 HBufC* stringholder = StringLoader::LoadLC(aNoteTextResource , aDevName ); |
|
980 aWaitDialog = new (ELeave) CAknWaitDialog( |
|
981 reinterpret_cast<CEikDialog**>(&aWaitDialog), ETrue); |
|
982 aWaitDialog->PrepareLC(aNoteResource); |
|
983 aWaitDialog->SetTextL(*stringholder); |
|
984 |
|
985 if(iCoverDisplayEnabled) |
|
986 { |
|
987 aWaitDialog->PublishDialogL( |
|
988 aSec, KUidCoverUiCategoryBtui); // initializes cover support |
|
989 CAknMediatorFacade* covercl = AknMediatorFacade(aWaitDialog); // uses MOP, so control provided |
|
990 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
991 { |
|
992 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevName);// takes copy so consts are ok too |
|
993 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
994 } |
|
995 } |
|
996 aWaitDialog->SetCallback(this); // for capturing Cancel keypress |
|
997 aWaitDialog->RunLD(); |
|
998 |
|
999 CleanupStack::PopAndDestroy(stringholder); // stringholder |
|
1000 ); |
|
1001 // if the above functions leaves the iWaitNote is deleted, but |
|
1002 // not set to NULL. This will cause a problem, when |
|
1003 // the items may be deleted again, since it has to |
|
1004 // be a member variable, in order to be closed |
|
1005 // programmatically. |
|
1006 if(err!=KErrNone) |
|
1007 { |
|
1008 // that is why we set it to NULL here and |
|
1009 // continue leaving further. |
|
1010 aWaitDialog=NULL; |
|
1011 User::Leave(err); |
|
1012 } |
|
1013 } |
|
1014 |
|
1015 // ---------------------------------------------------------- |
|
1016 // CBTUIPairedDevicesView::LaunchSettingViewL |
|
1017 // ---------------------------------------------------------- |
|
1018 // |
|
1019 void CBTUIPairedDevicesView::LaunchSettingViewL() |
|
1020 { |
|
1021 TRACE_FUNC_ENTRY |
|
1022 |
|
1023 TInt index = iContainer->CurrentItemIndex(); |
|
1024 if(index == KErrNotFound) return; |
|
1025 TBTDevice device; |
|
1026 device.iIndex = index; |
|
1027 iModel->GetDevice(device); |
|
1028 |
|
1029 CAknView* settingView = iBTPluginMan->GetSettingViewL(device); |
|
1030 if(settingView != NULL) |
|
1031 { |
|
1032 TUid viewId = settingView->Id(); |
|
1033 if(( device.iStatus & EStatusBtuiConnected) == EStatusBtuiConnected ) |
|
1034 { |
|
1035 TBuf8<KMaxBCBluetoothNameLen> DeviceName; |
|
1036 DeviceName.Copy(device.iName); |
|
1037 AppUi()->ActivateLocalViewL( viewId, KNullUid, DeviceName); |
|
1038 } |
|
1039 else |
|
1040 { |
|
1041 AppUi()->ActivateLocalViewL( viewId ); |
|
1042 } |
|
1043 } |
|
1044 else |
|
1045 { |
|
1046 User::Leave(KErrNotFound); |
|
1047 } |
|
1048 |
|
1049 TRACE_FUNC_EXIT |
|
1050 } |
|
1051 |
|
1052 // ---------------------------------------------------------- |
|
1053 // CBTUIPairedDevicesView::DisconnectL |
|
1054 // ---------------------------------------------------------- |
|
1055 // |
|
1056 void CBTUIPairedDevicesView::DisconnectL() |
|
1057 { |
|
1058 TRACE_FUNC_ENTRY |
|
1059 |
|
1060 TInt index = iContainer->CurrentItemIndex(); |
|
1061 if(index == KErrNotFound) return; |
|
1062 |
|
1063 TBTDevice device; |
|
1064 device.iIndex = index; |
|
1065 iModel->GetDevice(device); |
|
1066 iDisconnectQueryDevice = device;//remember device related with query dialog |
|
1067 |
|
1068 // Create confirmation query |
|
1069 HBufC* stringholder = StringLoader::LoadLC(R_BT_DISCONNECT_FROM, device.iName); |
|
1070 iDisconnectQueryDlg = CAknQueryDialog::NewL(); |
|
1071 |
|
1072 if(iCoverDisplayEnabled) |
|
1073 { |
|
1074 CleanupStack::PushL(iDisconnectQueryDlg); |
|
1075 iDisconnectQueryDlg->PublishDialogL(ECmdShowDisconnectQuery, KUidCoverUiCategoryBtui); // initializes cover support |
|
1076 CleanupStack::Pop(iDisconnectQueryDlg); |
|
1077 |
|
1078 CAknMediatorFacade* covercl = AknMediatorFacade(iDisconnectQueryDlg); // uses MOP, so control provided |
|
1079 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1080 { |
|
1081 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(device.iName);// takes copy so consts are ok too |
|
1082 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 TInt keypress = iDisconnectQueryDlg->ExecuteLD(R_BT_DISCONNECT_FROM_QUERY, *stringholder); |
|
1087 |
|
1088 CleanupStack::PopAndDestroy(stringholder); // stringholder |
|
1089 |
|
1090 iDisconnectQueryDlg = NULL; |
|
1091 if(keypress) // User has accepted the dialog |
|
1092 { |
|
1093 device.iOperation = EOpDisconnect; |
|
1094 iModel->ChangeDevice(device); |
|
1095 } |
|
1096 TRACE_FUNC_EXIT |
|
1097 } |
|
1098 |
|
1099 // ---------------------------------------------------------- |
|
1100 // CBTUIPairedDevicesView::CancelDisconnectQueryDlgL |
|
1101 // ---------------------------------------------------------- |
|
1102 // |
|
1103 void CBTUIPairedDevicesView::CancelDisconnectQueryDlgL() |
|
1104 { |
|
1105 TRACE_FUNC_ENTRY |
|
1106 |
|
1107 if(iDisconnectQueryDlg) |
|
1108 { |
|
1109 delete iDisconnectQueryDlg; |
|
1110 iDisconnectQueryDlg = NULL; |
|
1111 } |
|
1112 |
|
1113 TRACE_FUNC_EXIT |
|
1114 } |
|
1115 |
|
1116 // ---------------------------------------------------------- |
|
1117 // CBTUIPairedDevicesView::DisconnectWithoutQuery |
|
1118 // ---------------------------------------------------------- |
|
1119 // |
|
1120 void CBTUIPairedDevicesView::DisconnectWithoutQuery() |
|
1121 { |
|
1122 TRACE_FUNC_ENTRY |
|
1123 |
|
1124 TInt index = iContainer->CurrentItemIndex(); |
|
1125 if(index == KErrNotFound) return; |
|
1126 |
|
1127 TBTDevice device; |
|
1128 device.iIndex = index; |
|
1129 iModel->GetDevice(device); |
|
1130 device.iOperation = EOpDisconnect; |
|
1131 iModel->ChangeDevice(device); |
|
1132 } |
|
1133 // ---------------------------------------------------------- |
|
1134 // CBTUIPairedDevicesView::ConnectCompleteL |
|
1135 // ---------------------------------------------------------- |
|
1136 // |
|
1137 void CBTUIPairedDevicesView::ConnectCompleteL(TInt aError,const TBTDevice& aDevice, |
|
1138 const RBTDevNameArray* aConflictingDeviceNames) |
|
1139 { |
|
1140 TRACE_FUNC_ENTRY |
|
1141 |
|
1142 // Dismiss wait note |
|
1143 // |
|
1144 if(iConnectDevice) |
|
1145 { |
|
1146 delete iConnectDevice; |
|
1147 iConnectDevice=NULL; |
|
1148 } |
|
1149 |
|
1150 if ( iIsPairConnect ) |
|
1151 { |
|
1152 iIsPairConnect = EFalse; |
|
1153 if ( aError != KErrNone && |
|
1154 aError != KErrCancel && |
|
1155 aError != KErrNotSupported && |
|
1156 aError != KErrAlreadyExists && |
|
1157 aError != KErrServerBusy ) |
|
1158 { |
|
1159 // It is possible that we started connecting too soon before the |
|
1160 // device moves to conntable mode from pairing mode. Let's try |
|
1161 // once more: |
|
1162 if ( !iActive ) |
|
1163 { |
|
1164 iActive = CBTUIActive::NewL( |
|
1165 this, KAutoConnect2ndTry, CActive::EPriorityStandard ); |
|
1166 } |
|
1167 iActive->RequestStatus() = KRequestPending; |
|
1168 iActive->GoActive(); |
|
1169 TRequestStatus* stptr = &( iActive->RequestStatus() ); |
|
1170 User::RequestComplete( stptr, KErrNone ); |
|
1171 TRACE_INFO( _L("CBTUIPairedDevicesView, sceadule auto connect 2nd try") ) |
|
1172 return; |
|
1173 } |
|
1174 } |
|
1175 |
|
1176 if(iWaitForConnectDlg) |
|
1177 { |
|
1178 TRACE_INFO(_L("waiting dialog is active, dismiss it")) |
|
1179 iWaitForConnectDlg->ProcessFinishedL(); |
|
1180 } |
|
1181 |
|
1182 switch (aError) |
|
1183 { |
|
1184 case KErrCancel: |
|
1185 TRACE_INFO(_L("aError = KErrCancel")) |
|
1186 break; |
|
1187 case KErrAlreadyExists: // connection exists allready |
|
1188 { |
|
1189 HBufC* stringholder = NULL; |
|
1190 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
|
1191 { |
|
1192 if(aConflictingDeviceNames->Count() == 1) |
|
1193 { |
|
1194 stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_PROMPT, |
|
1195 *(*aConflictingDeviceNames)[0],iCoeEnv ); |
|
1196 } |
|
1197 else |
|
1198 { |
|
1199 CPtrC16Array* aa=new(ELeave) CPtrC16Array(1+1); |
|
1200 aa->InsertL(0, *(*aConflictingDeviceNames)[0] ); |
|
1201 aa->InsertL(1, *(*aConflictingDeviceNames)[1] ); |
|
1202 stringholder=StringLoader::LoadLC(R_BT_DISCONNECT_FIRST_STEREO_PROMPT , |
|
1203 *aa,iCoeEnv); |
|
1204 delete(aa); |
|
1205 } |
|
1206 TRACE_INFO(_L("KErrAllreadyExists")) |
|
1207 } |
|
1208 else |
|
1209 { |
|
1210 // Showing a note in this case would always show a note with "%U" in it |
|
1211 // so the note is not shown at all |
|
1212 TRACE_INFO(_L("KErrAlreadyExists, but no device given, not showing a notification")) |
|
1213 break; |
|
1214 } |
|
1215 |
|
1216 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1217 |
|
1218 if(iCoverDisplayEnabled) |
|
1219 { |
|
1220 CleanupStack::PushL(note); |
|
1221 note->PublishDialogL(ECmdShowBtDisconnectFirstNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
1222 CleanupStack::Pop(note); |
|
1223 |
|
1224 CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided |
|
1225 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1226 { |
|
1227 if(aConflictingDeviceNames && aConflictingDeviceNames->Count()> 0) |
|
1228 { |
|
1229 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(*(*aConflictingDeviceNames)[0]); |
|
1230 } |
|
1231 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1232 } |
|
1233 } |
|
1234 |
|
1235 note->ExecuteLD(*stringholder); |
|
1236 CleanupStack::PopAndDestroy(stringholder); |
|
1237 } |
|
1238 break; |
|
1239 case KErrServerBusy: |
|
1240 { |
|
1241 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( |
|
1242 CAknNoteDialog::ENoTone,CAknNoteDialog::ELongTimeout); |
|
1243 if(iCoverDisplayEnabled) |
|
1244 { |
|
1245 CleanupStack::PushL(dlg); |
|
1246 dlg->PublishDialogL(ECmdBtuiShowBtBusyNote, KUidCoverUiCategoryBtui); // initializes cover support |
|
1247 CleanupStack::Pop(dlg); |
|
1248 } |
|
1249 |
|
1250 dlg->ExecuteLD(R_BT_BUSY); |
|
1251 } |
|
1252 break; |
|
1253 case KErrNone: |
|
1254 { |
|
1255 |
|
1256 TRACE_INFO(_L("aError = KErrNone")) |
|
1257 // Create note |
|
1258 // |
|
1259 CAknInformationNote* notePtr = new (ELeave) CAknInformationNote(); |
|
1260 |
|
1261 HBufC* stringHolder = NULL; |
|
1262 |
|
1263 if (!FeatureManager::FeatureSupported(KFeatureIdAccessoryFw)) |
|
1264 { |
|
1265 if (CallOnGoing()) |
|
1266 { |
|
1267 stringHolder = StringLoader::LoadLC(R_BT_AUDIOS_ACCESSORY_PROMPT); // qtn_bt_audio_accessory "Audio routed to BT handsfree" |
|
1268 |
|
1269 if(iCoverDisplayEnabled) |
|
1270 { |
|
1271 CleanupStack::PushL(notePtr); |
|
1272 notePtr->PublishDialogL(ECmdBtuiShowBtAudioAccessory, KUidCoverUiCategoryBtui); // initializes cover support |
|
1273 CleanupStack::Pop(notePtr); |
|
1274 } |
|
1275 |
|
1276 notePtr->ExecuteLD(*stringHolder); |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 TRACE_INFO(_L("No call ongoing. Connected to")) |
|
1281 stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); // "Connected to %U" |
|
1282 |
|
1283 if(iCoverDisplayEnabled) |
|
1284 { |
|
1285 CleanupStack::PushL(notePtr); |
|
1286 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
|
1287 CleanupStack::Pop(notePtr); |
|
1288 |
|
1289 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
|
1290 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1291 { |
|
1292 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1293 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 notePtr->ExecuteLD(*stringHolder); |
|
1298 } |
|
1299 } |
|
1300 else |
|
1301 { |
|
1302 TRACE_INFO(_L("AccFW Supported. Connected to")) |
|
1303 stringHolder = StringLoader::LoadLC(R_BT_CONF_CONNECTED_PROMPT, aDevice.iName); |
|
1304 |
|
1305 if(iCoverDisplayEnabled) |
|
1306 { |
|
1307 CleanupStack::PushL(notePtr); |
|
1308 notePtr->PublishDialogL(ECmdBtuiShowBtConfConnected, KUidCoverUiCategoryBtui); // initializes cover support |
|
1309 CleanupStack::Pop(notePtr); |
|
1310 |
|
1311 CAknMediatorFacade* covercl = AknMediatorFacade(notePtr); // uses MOP, so control provided |
|
1312 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1313 { |
|
1314 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1315 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1316 } |
|
1317 } |
|
1318 |
|
1319 notePtr->ExecuteLD(*stringHolder); |
|
1320 } |
|
1321 |
|
1322 CleanupStack::PopAndDestroy(stringHolder); |
|
1323 } |
|
1324 |
|
1325 TRAP_IGNORE(LaunchSettingViewL();) |
|
1326 break; |
|
1327 |
|
1328 case KErrNotSupported: |
|
1329 { |
|
1330 TRACE_INFO(_L("error = KErrNotSupported")) |
|
1331 |
|
1332 |
|
1333 // create note |
|
1334 // |
|
1335 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1336 HBufC* stringHolder = StringLoader::LoadLC(R_BT_DEVICE_NOT_SUPPORTED,aDevice.iName); |
|
1337 |
|
1338 if(iCoverDisplayEnabled) |
|
1339 { |
|
1340 CleanupStack::PushL(note); |
|
1341 note->PublishDialogL(ECmdBtuiShowBtDeviceNotSupported, KUidCoverUiCategoryBtui); // initializes cover support |
|
1342 CleanupStack::Pop(note); |
|
1343 |
|
1344 CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided |
|
1345 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1346 { |
|
1347 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice.iName); |
|
1348 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1349 } |
|
1350 } |
|
1351 note->ExecuteLD(*stringHolder); |
|
1352 CleanupStack::PopAndDestroy(stringHolder); |
|
1353 } |
|
1354 break; |
|
1355 |
|
1356 default: |
|
1357 { |
|
1358 // Create note |
|
1359 CAknInformationNote* note = new (ELeave) CAknInformationNote(); |
|
1360 HBufC* stringHolder=StringLoader::LoadLC(R_BT_DEVICE_NOT_AVAIL_NOTE ); |
|
1361 |
|
1362 if(iCoverDisplayEnabled) |
|
1363 { |
|
1364 CleanupStack::PushL(note); |
|
1365 note->PublishDialogL(ECmdBtuiShowBtDeviceNotAvail, KUidCoverUiCategoryBtui); // initializes cover support |
|
1366 CleanupStack::Pop(note); |
|
1367 |
|
1368 } |
|
1369 |
|
1370 note->ExecuteLD(*stringHolder); |
|
1371 CleanupStack::PopAndDestroy(stringHolder); |
|
1372 TRACE_INFO(_L("default error note BT-not-available")) |
|
1373 } |
|
1374 break; |
|
1375 } |
|
1376 TRACE_FUNC_EXIT |
|
1377 } |
|
1378 |
|
1379 // ------------------------------------------------------ |
|
1380 // CBTUIPairedDevicesView::LaunchHelp |
|
1381 // static help launching function for TCallback |
|
1382 // ------------------------------------------------------ |
|
1383 TInt CBTUIPairedDevicesView::LaunchHelp(TAny* aCoeHelpContext) |
|
1384 { |
|
1385 #ifdef __SERIES60_HELP |
|
1386 //TRACE_FUNC_ENTRY |
|
1387 TCoeHelpContext hc; |
|
1388 |
|
1389 if(aCoeHelpContext==NULL) |
|
1390 hc = TCoeHelpContext(KBtuiUid3,KBT_HLP_BLOCKED); |
|
1391 else |
|
1392 hc = *static_cast<TCoeHelpContext*>(aCoeHelpContext); |
|
1393 TRAPD(err, |
|
1394 CArrayFix< TCoeHelpContext >* array=new (ELeave) CArrayFixFlat< TCoeHelpContext >(1); |
|
1395 array->AppendL(hc); |
|
1396 CleanupStack::PushL(array); |
|
1397 // codescan will complain about CCoeEnv::Static(), however it is not reasonable |
|
1398 // avoidable, since this is static funtion. |
|
1399 HlpLauncher::LaunchHelpApplicationL(CCoeEnv::Static()->WsSession() , array); |
|
1400 CleanupStack::Pop(array); |
|
1401 ); |
|
1402 |
|
1403 // the array is not deleted, since deleting it will result |
|
1404 // to E32User-CBase 3. It is assumed that HlpLancher is taking care of it. |
|
1405 // however this has not been documented. |
|
1406 //TRACE_FUNC_EXIT |
|
1407 return err; |
|
1408 #else |
|
1409 return KErrNone; |
|
1410 #endif |
|
1411 } |
|
1412 |
|
1413 // ------------------------------------------------------ |
|
1414 // CBTUIPairedDevicesView::CallOnGoing |
|
1415 // ------------------------------------------------------ |
|
1416 TBool CBTUIPairedDevicesView::CallOnGoing() |
|
1417 { |
|
1418 TRACE_FUNC_ENTRY |
|
1419 TInt callState; |
|
1420 // Try to get the call state property |
|
1421 |
|
1422 TInt err = RProperty::Get(KPSUidCtsyCallInformation, |
|
1423 KCTsyCallState, callState); //KPSUidTelephonyCallInformation should be used // Check also,if retrieving the property value succeeded |
|
1424 return (err == KErrNone) ? |
|
1425 (callState != EPSCTsyCallStateNone && |
|
1426 callState != EPSCTsyCallStateUninitialized) : |
|
1427 EFalse; |
|
1428 } |
|
1429 // ---------------------------------------------------------- |
|
1430 // From MProgressDialogCallback |
|
1431 // CBTUIPairedDevicesView::DialogDismissedL |
|
1432 // |
|
1433 // Cancels pairing/connection operation if user has pressed Cancel softkey. |
|
1434 // Does nothing if the dialog has been dismissed by this program. |
|
1435 // ---------------------------------------------------------- |
|
1436 // |
|
1437 void CBTUIPairedDevicesView::DialogDismissedL(TInt aButtonId ) |
|
1438 { |
|
1439 TRACE_FUNC_ENTRY |
|
1440 |
|
1441 // it was not canceled, but dialog was closed |
|
1442 // because it ended normally, so there is nothing to clean up. |
|
1443 if( aButtonId != EAknSoftkeyCancel ) |
|
1444 return; |
|
1445 |
|
1446 // Cancel ongoing operations if any |
|
1447 // |
|
1448 if ( iWaitForConnectDlg) |
|
1449 { |
|
1450 if( iConnectDevice ) |
|
1451 { |
|
1452 iModel->CancelChange(*iConnectDevice); |
|
1453 delete iConnectDevice; |
|
1454 iConnectDevice=NULL; |
|
1455 iIsPairConnect = EFalse; |
|
1456 } |
|
1457 iWaitForConnectDlg = NULL; |
|
1458 } |
|
1459 if ( iWaitForPairingDlg ) |
|
1460 { |
|
1461 if( iPairingDevice ) |
|
1462 { |
|
1463 TBTDevice device; |
|
1464 device.iAddr = iPairingDevice->BDAddr(); |
|
1465 device.iOperation = EOpPair; |
|
1466 |
|
1467 iDeviceSearcher->CancelSearchRemoteDevice(); |
|
1468 |
|
1469 iModel->CancelChange(device); |
|
1470 |
|
1471 delete iPairingDevice; |
|
1472 iPairingDevice=NULL; |
|
1473 } |
|
1474 // The dialog has already been deleted by UI framework and |
|
1475 // must not be deleted manually. |
|
1476 iWaitForPairingDlg = NULL; |
|
1477 } |
|
1478 |
|
1479 TRACE_FUNC_EXIT |
|
1480 } |
|
1481 // ------------------------------------------------------ |
|
1482 // From MBTEngSdpResultReceiver |
|
1483 // CBTUIPairedDevicesView::ServiceSearchComplete |
|
1484 // not used and implemented as empty |
|
1485 // ------------------------------------------------------ |
|
1486 void CBTUIPairedDevicesView::ServiceSearchComplete(const RSdpRecHandleArray& , TUint , TInt) |
|
1487 { |
|
1488 TRACE_FUNC_ENTRY |
|
1489 } |
|
1490 // ------------------------------------------------------ |
|
1491 // From MBTEngSdpResultReceiver |
|
1492 // CBTUIPairedDevicesView::AttributeSearchComplete |
|
1493 // not used and implemented as empty |
|
1494 // ------------------------------------------------------ |
|
1495 void CBTUIPairedDevicesView::AttributeSearchComplete(TSdpServRecordHandle, |
|
1496 const RSdpResultArray& ,TInt) |
|
1497 { |
|
1498 TRACE_FUNC_ENTRY |
|
1499 } |
|
1500 // ------------------------------------------------------ |
|
1501 // From MBTEngSdpResultReceiver |
|
1502 // CBTUIPairedDevicesView::AttributeSearchComplete |
|
1503 // not used and implemented as empty |
|
1504 // ------------------------------------------------------ |
|
1505 void CBTUIPairedDevicesView::ServiceAttributeSearchComplete(TSdpServRecordHandle , |
|
1506 const RSdpResultArray& ,TInt ) |
|
1507 { |
|
1508 TRACE_FUNC_ENTRY |
|
1509 } |
|
1510 // ------------------------------------------------------ |
|
1511 // From MBTEngSdpResultReceiver |
|
1512 // CBTUIPairedDevicesView::DeviceSearchComplete |
|
1513 // ------------------------------------------------------ |
|
1514 void CBTUIPairedDevicesView::DeviceSearchComplete(CBTDevice* aDevice, TInt aErr) |
|
1515 { |
|
1516 TRACE_FUNC_ENTRY |
|
1517 |
|
1518 TRAPD(err, DeviceSearchCompleteL(aDevice, NULL, aErr); |
|
1519 ); |
|
1520 // something went wrong. |
|
1521 if(err != KErrNone) |
|
1522 { |
|
1523 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1524 } |
|
1525 iSearchOngoing=EFalse; |
|
1526 TRACE_FUNC_EXIT |
|
1527 } |
|
1528 |
|
1529 // ------------------------------------------------------ |
|
1530 // From MBTEngSdpResultReceiver |
|
1531 // CBTUIPairedDevicesView::DeviceSearchComplete |
|
1532 // ------------------------------------------------------ |
|
1533 void CBTUIPairedDevicesView::DeviceSearchComplete( CBTDevice* aDevice, |
|
1534 TNameEntry* aNameEntry, TInt aErr ) |
|
1535 { |
|
1536 TRACE_FUNC_ENTRY |
|
1537 |
|
1538 TRAPD(err, DeviceSearchCompleteL(aDevice, aNameEntry, aErr); |
|
1539 ); |
|
1540 // something went wrong. |
|
1541 if(err != KErrNone) |
|
1542 { |
|
1543 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1544 } |
|
1545 iSearchOngoing=EFalse; |
|
1546 TRACE_FUNC_EXIT |
|
1547 } |
|
1548 |
|
1549 // ------------------------------------------------------ |
|
1550 // CBTUIPairedDevicesView::DeviceSearchCompleteL |
|
1551 // Leaving version of DeviceSearchComplete |
|
1552 // ------------------------------------------------------ |
|
1553 |
|
1554 void CBTUIPairedDevicesView::DeviceSearchCompleteL(CBTDevice* aDevice, |
|
1555 TNameEntry* aNameEntry, TInt aErr) |
|
1556 { |
|
1557 TRACE_FUNC_ENTRY |
|
1558 iSearchOngoing=EFalse; |
|
1559 if ( !iPairingDevice ) |
|
1560 { |
|
1561 delete iModel; |
|
1562 iModel = NULL; |
|
1563 return; |
|
1564 } |
|
1565 // we must not have multiple pairings at the same time |
|
1566 __ASSERT_DEBUG(aDevice->BDAddr() == iPairingDevice->BDAddr(), |
|
1567 PANIC(EBTPanicTwoPairingAttemptsAtTheSameTime) ); |
|
1568 |
|
1569 // other error condition, most likely dialog cancel. |
|
1570 if(aErr != KErrNone && (aErr != KErrAlreadyExists)) |
|
1571 { |
|
1572 delete iPairingDevice; |
|
1573 iPairingDevice=NULL; |
|
1574 return; |
|
1575 } |
|
1576 |
|
1577 // In case user switches the view fast enough before searching starts, |
|
1578 // It crashes the whole btui by iModel is null value. |
|
1579 // We add an extra check here |
|
1580 // |
|
1581 if ( !iModel ) |
|
1582 { |
|
1583 delete iPairingDevice; |
|
1584 iPairingDevice=NULL; |
|
1585 return; |
|
1586 } |
|
1587 |
|
1588 TBTDevice *tmpDevice=iModel->CreateDeviceL(aDevice, aNameEntry); |
|
1589 CleanupStack::PushL(tmpDevice); |
|
1590 if(tmpDevice->iStatus & (EStatusPhysicallyConnected|EStatusBtuiConnected|EStatusPaired)) |
|
1591 { |
|
1592 ShowDisconnecNoteL(tmpDevice); |
|
1593 CleanupStack::PopAndDestroy(tmpDevice); |
|
1594 delete iPairingDevice; |
|
1595 iPairingDevice=NULL; |
|
1596 return; |
|
1597 } |
|
1598 else |
|
1599 { |
|
1600 // Launch wait note |
|
1601 OpenWaitNoteL(iWaitForPairingDlg,R_BT_WAITING,R_BT_WAITING_PROMPT, |
|
1602 ECmdShowBtWaitingNote,tmpDevice->iName); |
|
1603 |
|
1604 CleanupStack::PopAndDestroy(tmpDevice); |
|
1605 tmpDevice=NULL; |
|
1606 // and start the pairing |
|
1607 iModel->ChangeDevice(aDevice, aNameEntry, EOpPair); |
|
1608 // aDevice is not deleted, since it points to iPairingDevice and it is still used |
|
1609 // after this |
|
1610 } |
|
1611 TRACE_FUNC_EXIT |
|
1612 } |
|
1613 // ------------------------------------------------------ |
|
1614 // CBTUIPairedDevicesView::ShowDisconnecNote |
|
1615 // ------------------------------------------------------ |
|
1616 void CBTUIPairedDevicesView::ShowDisconnecNoteL(TBTDevice *aDevice) |
|
1617 { |
|
1618 HBufC* stringholder = StringLoader::LoadLC( |
|
1619 R_BT_DISCONNECT_FIRST_PROMPT, aDevice->iName); |
|
1620 |
|
1621 // Launch a waiting confirmation note |
|
1622 // |
|
1623 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote(ETrue); |
|
1624 |
|
1625 if(iCoverDisplayEnabled) |
|
1626 { |
|
1627 CleanupStack::PushL(note); |
|
1628 note->PublishDialogL(ECmdShowBtSuccesfullyPairedNote, |
|
1629 KUidCoverUiCategoryBtui); // initializes cover support |
|
1630 CAknMediatorFacade* covercl = AknMediatorFacade(note); // uses MOP, so control provided |
|
1631 if (covercl) // returns null if __COVER_DISPLAY is not defined |
|
1632 { |
|
1633 covercl->BufStream() << BTDeviceNameConverter::ToUTF8L(aDevice->iName);// takes copy so consts are ok too |
|
1634 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
1635 } |
|
1636 CleanupStack::Pop(note); |
|
1637 } |
|
1638 |
|
1639 note->ExecuteLD(*stringholder); |
|
1640 |
|
1641 CleanupStack::PopAndDestroy(stringholder); // stringholder |
|
1642 |
|
1643 } |
|
1644 |
|
1645 void CBTUIPairedDevicesView::ConnectIfNeededAfterPairL( TInt aCount ) |
|
1646 { |
|
1647 TRACE_FUNC_ENTRY |
|
1648 TBTDevice device; |
|
1649 device.iAddr = iPairConnectAddr; |
|
1650 iModel->GetDevice(device); |
|
1651 device.iOperation = EOpConnect; |
|
1652 ConnectL( device, ( aCount ) ? EFalse : ETrue ); |
|
1653 TRACE_FUNC_EXIT |
|
1654 } |
|
1655 |
|
1656 // ------------------------------------------------------ |
|
1657 // CBTUIPairedDevicesView::BondingCompleted |
|
1658 // called by NotifyChangeDeviceComplete |
|
1659 // ------------------------------------------------------ |
|
1660 void CBTUIPairedDevicesView::BondingCompleteL(TInt aError, const TBTDevice& aDevice) |
|
1661 { |
|
1662 TRACE_INFO((_L("aError=%d"), aError)) |
|
1663 // We need to make a copy of the device, since it may be cleaned up |
|
1664 // by device refresh. |
|
1665 TBTDevice bDevice= aDevice; |
|
1666 |
|
1667 // this may look useless, however if the device has a given shortName it is listed with it |
|
1668 // all the time. If you omnit this line it will be shown with its original deviceName, |
|
1669 // dispite it will be listed with the given name |
|
1670 iModel->GetDevice(bDevice); |
|
1671 |
|
1672 delete iPairingDevice; |
|
1673 iPairingDevice=NULL; |
|
1674 |
|
1675 // Dismiss wait note |
|
1676 if(iWaitForPairingDlg) |
|
1677 { |
|
1678 iWaitForPairingDlg->ProcessFinishedL(); |
|
1679 iWaitForPairingDlg = NULL; |
|
1680 } |
|
1681 |
|
1682 // Error handling |
|
1683 switch(aError) |
|
1684 { |
|
1685 case KErrCancel: |
|
1686 break; |
|
1687 case KErrAlreadyExists: // This is a legal return value |
|
1688 case KErrNone: |
|
1689 case KHCIErrorBase: |
|
1690 { |
|
1691 if( (bDevice.iStatus & EStatusConnectable) |
|
1692 && (bDevice.iDeviceClass.MajorDeviceClass() != EMajorDeviceComputer)) |
|
1693 // Only automatically query for a connectable device but not a computer |
|
1694 { |
|
1695 iPairConnectAddr = aDevice.iAddr; |
|
1696 iIsPairConnect = ETrue; |
|
1697 ConnectIfNeededAfterPairL( 0 ); |
|
1698 } |
|
1699 break; |
|
1700 } |
|
1701 default: |
|
1702 { |
|
1703 break; |
|
1704 } |
|
1705 } |
|
1706 TRACE_FUNC_EXIT |
|
1707 } |
|
1708 |
|
1709 // ----------------------------------------------- |
|
1710 // From MBTDeviceObserver |
|
1711 // CBTUIPairedDevicesView::RefreshDeviceList |
|
1712 // calls the container to refresh the deviceList |
|
1713 // ----------------------------------------------- |
|
1714 void CBTUIPairedDevicesView::RefreshDeviceList(const RDeviceArray* aDevices, |
|
1715 TInt aSelectedItemIndex) |
|
1716 { |
|
1717 TRACE_FUNC_ENTRY |
|
1718 TRAPD(err, |
|
1719 if(iContainer) |
|
1720 { |
|
1721 iContainer->RefreshDeviceListL(aDevices,aSelectedItemIndex); |
|
1722 } |
|
1723 ); |
|
1724 if (iActiveMenuPane && iActiveMenuPane->NumberOfItemsInPane()>0 ) |
|
1725 { |
|
1726 TInt index = iContainer->CurrentItemIndex(); |
|
1727 if ( index >=0 ) |
|
1728 { |
|
1729 TBTDevice device; |
|
1730 device.iIndex = index; |
|
1731 iModel->GetDevice(device); |
|
1732 if ( iMenuDevice.iAddr == device.iAddr && |
|
1733 ( ( iMenuDevice.iStatus & EStatusBtuiConnected ) != ( device.iStatus & EStatusBtuiConnected ) ) ) |
|
1734 { |
|
1735 TRACE_INFO(_L("Device status changed, update menupane")); |
|
1736 iMenuDevice = device; |
|
1737 iActiveMenuPane->Close(); |
|
1738 TRAP_IGNORE( this->ProcessCommandL(EAknSoftkeyOptions) ); |
|
1739 } |
|
1740 } |
|
1741 } |
|
1742 if(err!= KErrNone) |
|
1743 { |
|
1744 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1745 } |
|
1746 TRACE_FUNC_EXIT |
|
1747 } |
|
1748 |
|
1749 |
|
1750 // ----------------------------------------------- |
|
1751 // |
|
1752 // ----------------------------------------------- |
|
1753 void CBTUIPairedDevicesView::RequestCompletedL( CBTUIActive* aActive, TInt aId, |
|
1754 TInt aStatus ) |
|
1755 { |
|
1756 TRACE_INFO( ( _L("CBTUIPairedDevicesView::RequestCompletedL err %d"), aStatus ) ) |
|
1757 (void) aActive; |
|
1758 (void) aId; |
|
1759 (void) aStatus; |
|
1760 TRACE_INFO( _L("CBTUIPairedDevicesView, auto connect 2nd try ... ") ) |
|
1761 ConnectIfNeededAfterPairL( 1 ); |
|
1762 } |
|
1763 |
|
1764 // ----------------------------------------------- |
|
1765 // |
|
1766 // ----------------------------------------------- |
|
1767 void CBTUIPairedDevicesView::HandleError( CBTUIActive* aActive, TInt aId, |
|
1768 TInt aError ) |
|
1769 { |
|
1770 (void) aActive; |
|
1771 (void) aId; |
|
1772 (void) aError; |
|
1773 iIsPairConnect = EFalse; |
|
1774 } |
|
1775 |
|
1776 // --------------------------------------------------------- |
|
1777 // From MBTDeviceObserver |
|
1778 // CBTUIPairedDevicesView::NotifyChangeDeviceComplete |
|
1779 // This function implement the functionality of command complete. |
|
1780 // The lists of shown devices are refreshed by RefreshDeviceList, |
|
1781 // not by this function |
|
1782 // --------------------------------------------------------- |
|
1783 // |
|
1784 void CBTUIPairedDevicesView::NotifyChangeDeviceComplete(const TInt aErr, |
|
1785 const TBTDevice& aDevice, const RBTDevNameArray* aDevNameArray) |
|
1786 { |
|
1787 TRACE_FUNC_ENTRY |
|
1788 TBTDevice tmpDevice=aDevice; |
|
1789 TRAPD(err,NotifyChangeDeviceCompleteL(aErr,tmpDevice,aDevNameArray |
|
1790 );); |
|
1791 if(err!= KErrNone) |
|
1792 { |
|
1793 TRAP_IGNORE( TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); ); |
|
1794 } |
|
1795 TRACE_FUNC_EXIT |
|
1796 } |
|
1797 // --------------------------------------------------------- |
|
1798 // CBTUIPairedDevicesView::NotifyChangeDeviceCompleteL |
|
1799 // Leaving version of notifyChangeDevice |
|
1800 // --------------------------------------------------------- |
|
1801 |
|
1802 void CBTUIPairedDevicesView::NotifyChangeDeviceCompleteL(const TInt aErr, |
|
1803 const TBTDevice& aDevice, const RBTDevNameArray* aDevNameArray) |
|
1804 { |
|
1805 TRACE_FUNC_ENTRY |
|
1806 if(iContainer == NULL) return; |
|
1807 |
|
1808 TRACE_INFO((_L("aErr=%d"), aErr)) |
|
1809 TRACE_INFO((_L("aDevice.iOperation=%d"), aDevice.iOperation)) |
|
1810 TRACE_INFO((_L("aDevice.iStatus=%d"), aDevice.iStatus)) |
|
1811 TRACE_INFO((_L("iIsAlreadyConnected=%d"), iIsAlreadyConnected)) |
|
1812 |
|
1813 if (aDevice.iOperation == EOpDisconnect && iExpectedCallBack>0 ) |
|
1814 { |
|
1815 TBTDevice device; |
|
1816 device.iIndex = aDevice.iIndex; |
|
1817 iModel->GetDevice(device); |
|
1818 device.iOperation = EOpUnpair; |
|
1819 iModel->ChangeDevice(device); |
|
1820 iExpectedCallBack--; |
|
1821 } |
|
1822 |
|
1823 if( aDevice.iOperation == EOpConnect ) |
|
1824 { |
|
1825 if( aErr == KErrNone && iIsAlreadyConnected ) |
|
1826 { |
|
1827 TRACE_INFO(_L("Don't show notes several times for the same device with different profile connections")) |
|
1828 return; |
|
1829 } |
|
1830 ConnectCompleteL(aErr, aDevice, aDevNameArray ); |
|
1831 iIsAlreadyConnected = ETrue; |
|
1832 TRACE_INFO(_L("iIsAlreadyConnected False -> True")) |
|
1833 return; |
|
1834 } |
|
1835 if(aDevice.iOperation == EOpPair) |
|
1836 { |
|
1837 BondingCompleteL(aErr, aDevice); |
|
1838 } |
|
1839 if(aErr != KErrNone) |
|
1840 { |
|
1841 // The user tried to rename to a name that allready exists. |
|
1842 if(aDevice.iOperation == EOpChangeName && aErr == KErrAlreadyExists) |
|
1843 { |
|
1844 CAknNoteDialog* dlg2 = new (ELeave) CAknNoteDialog(CAknNoteDialog::EErrorTone, |
|
1845 CAknNoteDialog::ELongTimeout); |
|
1846 dlg2->ExecuteLD(R_BT_NAME_EXISTS_NOTE); |
|
1847 |
|
1848 RenameDeviceDlgL(); |
|
1849 return; |
|
1850 } |
|
1851 // Need to properly handle situation when "Disconnect from xxx" query |
|
1852 // has been shown and paired device has been turned off simultaneously. |
|
1853 // CancelDisconnectQuery dialog need to be closed. |
|
1854 if(aErr == KErrDisconnected) |
|
1855 { |
|
1856 if(iDisconnectQueryDlg && aDevice.iAddr == iDisconnectQueryDevice.iAddr) |
|
1857 CancelDisconnectQueryDlgL(); |
|
1858 |
|
1859 TRACE_FUNC_EXIT |
|
1860 return; |
|
1861 } |
|
1862 // show general error if any of these failed |
|
1863 if( aDevice.iOperation== EOpTrust || |
|
1864 aDevice.iOperation== EOpUntrust || |
|
1865 aDevice.iOperation== EOpBlock || |
|
1866 aDevice.iOperation== EOpChangeName) |
|
1867 { |
|
1868 TBTUIViewsCommonUtils::ShowGeneralErrorNoteL(); |
|
1869 } |
|
1870 return; |
|
1871 } |
|
1872 |
|
1873 if(aDevice.iOperation == EOpUntrust) |
|
1874 { |
|
1875 // Unauthorise ok note, |
|
1876 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog(CAknNoteDialog::EConfirmationTone, |
|
1877 CAknNoteDialog::ELongTimeout); |
|
1878 |
|
1879 if(iCoverDisplayEnabled) |
|
1880 { |
|
1881 CleanupStack::PushL(dlg); |
|
1882 dlg->PublishDialogL(ECmdShowBtDevSetAsUntrustNote, KUidCoverUiCategoryBtui); |
|
1883 // initializes cover support |
|
1884 CleanupStack::Pop(dlg); |
|
1885 } |
|
1886 dlg->ExecuteLD( R_BT_DEVICE_UNTRUSTED_NOTE ); |
|
1887 } |
|
1888 TRACE_FUNC_EXIT |
|
1889 } |
|
1890 |
|
1891 // --------------------------------------------------------------------------- |
|
1892 // CBTUIPairedDevicesView::CreateTabIconL() |
|
1893 // Creates icon for tab. |
|
1894 // --------------------------------------------------------------------------- |
|
1895 // |
|
1896 CGulIcon* CBTUIPairedDevicesView::CreateTabIconL() |
|
1897 { |
|
1898 TFileName bmpFilename; |
|
1899 bmpFilename += KBitmapFileDrive; |
|
1900 bmpFilename += KDC_APP_BITMAP_DIR; |
|
1901 bmpFilename += KBtuiBmpFileName; |
|
1902 |
|
1903 CGulIcon* icon = AknsUtils::CreateGulIconL( |
|
1904 AknsUtils::SkinInstance(), |
|
1905 KAknsIIDQgnPropBtDevicesTab3, |
|
1906 bmpFilename, |
|
1907 EMbmBtuiQgn_prop_bt_devices_tab3, |
|
1908 EMbmBtuiQgn_prop_bt_devices_tab3_mask ); |
|
1909 |
|
1910 return icon; |
|
1911 } |
|
1912 |
|
1913 // End of File |
|
1914 |